2012-11-15 01:39:56 +02:00
|
|
|
#include "stdafx.h"
|
2014-07-06 01:30:28 +02:00
|
|
|
#include "sys_tty.h"
|
2012-11-15 01:39:56 +02:00
|
|
|
|
2016-05-25 13:55:14 +03:00
|
|
|
namespace vm { using namespace ps3; }
|
|
|
|
|
|
2017-05-13 21:30:37 +03:00
|
|
|
logs::channel sys_tty("sys_tty");
|
2014-08-23 18:51:51 +04:00
|
|
|
|
2016-04-27 01:27:24 +03:00
|
|
|
extern fs::file g_tty;
|
|
|
|
|
|
2016-08-16 18:46:24 +03:00
|
|
|
error_code sys_tty_read(s32 ch, vm::ptr<char> buf, u32 len, vm::ptr<u32> preadlen)
|
2012-11-15 01:39:56 +02:00
|
|
|
{
|
2016-05-25 13:55:14 +03:00
|
|
|
sys_tty.fatal("sys_tty_read(ch=%d, buf=*0x%x, len=%d, preadlen=*0x%x)", ch, buf, len, preadlen);
|
2014-08-23 18:51:51 +04:00
|
|
|
|
2014-07-06 18:05:52 +02:00
|
|
|
// We currently do not support reading from the Console
|
2016-08-08 19:01:06 +03:00
|
|
|
fmt::throw_exception("Unimplemented" HERE);
|
2012-11-15 01:39:56 +02:00
|
|
|
}
|
|
|
|
|
|
2016-08-16 18:46:24 +03:00
|
|
|
error_code sys_tty_write(s32 ch, vm::cptr<char> buf, u32 len, vm::ptr<u32> pwritelen)
|
2012-11-15 01:39:56 +02:00
|
|
|
{
|
2016-01-13 00:57:16 +03:00
|
|
|
sys_tty.notice("sys_tty_write(ch=%d, buf=*0x%x, len=%d, pwritelen=*0x%x)", ch, buf, len, pwritelen);
|
2014-08-23 18:51:51 +04:00
|
|
|
|
2015-07-09 20:19:29 +03:00
|
|
|
if (ch > 15)
|
|
|
|
|
{
|
|
|
|
|
return CELL_EINVAL;
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-25 13:55:14 +03:00
|
|
|
if (static_cast<s32>(len) <= 0)
|
2015-07-09 20:19:29 +03:00
|
|
|
{
|
2015-07-27 17:59:21 +03:00
|
|
|
*pwritelen = 0;
|
|
|
|
|
|
2015-07-09 20:19:29 +03:00
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
2014-09-03 20:33:30 +04:00
|
|
|
|
2016-04-27 01:27:24 +03:00
|
|
|
if (g_tty)
|
|
|
|
|
{
|
|
|
|
|
g_tty.write(buf.get_ptr(), len);
|
|
|
|
|
}
|
2016-01-13 00:57:16 +03:00
|
|
|
|
2015-07-27 17:59:21 +03:00
|
|
|
*pwritelen = len;
|
|
|
|
|
|
2012-11-15 01:39:56 +02:00
|
|
|
return CELL_OK;
|
2013-06-30 11:46:29 +03:00
|
|
|
}
|