rpcsx/rpcs3/Emu/Cell/lv2/sys_tty.cpp

43 lines
895 B
C++
Raw Normal View History

#include "stdafx.h"
#include "sys_tty.h"
2016-05-25 12:55:14 +02:00
namespace vm { using namespace ps3; }
2017-05-13 20:30:37 +02:00
logs::channel sys_tty("sys_tty");
2014-08-23 16:51:51 +02:00
extern fs::file g_tty;
error_code sys_tty_read(s32 ch, vm::ptr<char> buf, u32 len, vm::ptr<u32> preadlen)
{
2016-05-25 12:55:14 +02:00
sys_tty.fatal("sys_tty_read(ch=%d, buf=*0x%x, len=%d, preadlen=*0x%x)", ch, buf, len, preadlen);
2014-08-23 16:51:51 +02:00
2014-07-06 18:05:52 +02:00
// We currently do not support reading from the Console
fmt::throw_exception("Unimplemented" HERE);
}
error_code sys_tty_write(s32 ch, vm::cptr<char> buf, u32 len, vm::ptr<u32> pwritelen)
{
sys_tty.notice("sys_tty_write(ch=%d, buf=*0x%x, len=%d, pwritelen=*0x%x)", ch, buf, len, pwritelen);
2014-08-23 16:51:51 +02:00
2015-07-09 19:19:29 +02:00
if (ch > 15)
{
return CELL_EINVAL;
}
const u32 written_len = static_cast<s32>(len) > 0 ? len : 0;
2015-07-09 19:19:29 +02:00
if (written_len > 0 && g_tty)
2015-07-09 19:19:29 +02:00
{
g_tty.write(buf.get_ptr(), len);
2015-07-09 19:19:29 +02:00
}
if (!pwritelen)
{
return CELL_EFAULT;
}
*pwritelen = written_len;
return CELL_OK;
}