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

49 lines
1.2 KiB
C++
Raw Normal View History

#include "stdafx.h"
#include "Utilities/Log.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"
#include "Emu/SysCalls/SysCalls.h"
2014-08-23 16:51:51 +02:00
#include "sys_tty.h"
2014-08-23 16:51:51 +02:00
SysCallBase sys_tty("sys_tty");
2014-09-03 18:33:30 +02:00
s32 sys_tty_read(s32 ch, vm::ptr<void> buf, u32 len, vm::ptr<u32> preadlen)
{
2014-09-03 18:33:30 +02:00
sys_tty.Error("sys_tty_read(ch=%d, buf_addr=0x%x, len=%d, preadlen_addr=0x%x)", ch, buf.addr(), len, preadlen.addr());
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
2014-09-03 18:33:30 +02:00
*preadlen = 0;
2014-02-16 09:28:32 +01:00
Emu.Pause();
return CELL_OK;
}
s32 sys_tty_write(s32 ch, vm::cptr<void> buf, u32 len, vm::ptr<u32> pwritelen)
{
2014-09-03 18:33:30 +02:00
sys_tty.Log("sys_tty_write(ch=%d, buf_addr=0x%x, len=%d, preadlen_addr=0x%x)", ch, buf.addr(), len, pwritelen.addr());
2014-08-23 16:51:51 +02:00
2015-07-09 19:19:29 +02:00
if (ch > 15)
{
sys_tty.Error("sys_tty_write(): specified channel was higher than 15.");
return CELL_EINVAL;
}
if ((s32) len <= 0)
{
sys_tty.Error("sys_tty_write(): specified length was 0.");
return CELL_OK;
}
2014-09-03 18:33:30 +02:00
const std::string data((const char*)buf.get_ptr(), len);
2014-07-06 18:05:52 +02:00
if (ch == SYS_TTYP_PPU_STDOUT || ch == SYS_TTYP_SPU_STDOUT || (ch >= SYS_TTYP_USER1 && ch <= SYS_TTYP_USER13)) {
2014-09-03 18:33:30 +02:00
LOG_NOTICE(TTY, "%s", data.c_str());
}
2014-07-06 18:05:52 +02:00
if (ch == SYS_TTYP_PPU_STDERR) {
2014-09-03 18:33:30 +02:00
LOG_ERROR(TTY, "%s", data.c_str());
2014-07-06 18:05:52 +02:00
}
2014-09-15 00:17:24 +02:00
*pwritelen = (u32)data.size();
return CELL_OK;
}