rpcsx/ps3fw/sysPrxForUser.cpp

253 lines
6.2 KiB
C++
Raw Normal View History

2020-12-05 13:08:24 +01:00
#include "stdafx.h"
2016-03-21 20:42:14 +01:00
#include "Emu/Cell/PPUModule.h"
2021-03-23 20:32:50 +01:00
#include "Emu/Cell/timers.hpp"
2014-08-23 22:40:04 +02:00
#include "cellos/sys_mutex.h"
#include "cellos/sys_interrupt.h"
#include "cellos/sys_process.h"
#include "cellos/sys_ss.h"
#include "cellos/sys_tty.h"
#include "sysPrxForUser.h"
LOG_CHANNEL(sysPrxForUser);
2016-03-21 20:42:14 +01:00
vm::gvar<s32> sys_prx_version; // ???
vm::gvar<vm::ptr<void()>> g_ppu_atexitspawn;
vm::gvar<vm::ptr<void()>> g_ppu_at_Exitspawn;
extern vm::gvar<u32> g_ppu_exit_mutex;
2016-03-21 20:42:14 +01:00
u64 sys_time_get_system_time()
{
sysPrxForUser.trace("sys_time_get_system_time()");
2019-07-14 05:55:11 +02:00
return get_guest_system_time();
}
void sys_process_exit(ppu_thread& ppu, s32 status)
2017-09-16 13:52:15 +02:00
{
2017-09-16 19:43:02 +02:00
sysPrxForUser.warning("sys_process_exit(status=%d)", status);
2017-09-16 13:52:15 +02:00
sys_mutex_lock(ppu, *g_ppu_exit_mutex, 0);
2017-09-16 13:52:15 +02:00
// TODO (process atexit)
return _sys_process_exit(ppu, status, 0, 0);
2017-09-16 13:52:15 +02:00
}
void _sys_process_atexitspawn(vm::ptr<void()> func)
{
sysPrxForUser.warning("_sys_process_atexitspawn(0x%x)", func);
if (!*g_ppu_atexitspawn)
{
*g_ppu_atexitspawn = func;
}
}
void _sys_process_at_Exitspawn(vm::ptr<void()> func)
{
sysPrxForUser.warning("_sys_process_at_Exitspawn(0x%x)", func);
if (!*g_ppu_at_Exitspawn)
{
*g_ppu_at_Exitspawn = func;
}
}
s32 sys_process_is_stack(u32 p)
{
sysPrxForUser.trace("sys_process_is_stack(p=0x%x)", p);
2014-07-20 19:13:35 +02:00
// prx: compare high 4 bits with "0xD"
2015-07-11 22:44:53 +02:00
return (p >> 28) == 0xD;
}
2020-07-16 12:14:57 +02:00
error_code sys_process_get_paramsfo(vm::ptr<char> buffer)
{
sysPrxForUser.warning("sys_process_get_paramsfo(buffer=*0x%x)", buffer);
2015-08-02 04:15:49 +02:00
// prx: load some data (0x40 bytes) previously set by _sys_process_get_paramsfo syscall
return _sys_process_get_paramsfo(buffer);
}
2020-07-16 12:14:57 +02:00
error_code sys_get_random_number(vm::ptr<void> addr, u64 size)
2014-09-12 14:18:27 +02:00
{
sysPrxForUser.warning("sys_get_random_number(addr=*0x%x, size=%d)", addr, size);
2014-09-12 14:18:27 +02:00
2021-04-23 21:16:00 +02:00
if (size > RANDOM_NUMBER_MAX_SIZE)
{
return CELL_EINVAL;
}
switch (u32 rs = sys_ss_random_number_generator(2, addr, size))
{
case 0x80010501: return CELL_ENOMEM;
case 0x80010503: return CELL_EAGAIN;
case 0x80010509: return CELL_EINVAL;
default:
if (rs)
return CELL_EABORT;
}
2014-09-12 14:18:27 +02:00
return CELL_OK;
}
2020-07-16 12:14:57 +02:00
error_code console_getc()
2015-04-12 03:36:25 +02:00
{
sysPrxForUser.todo("console_getc()");
return CELL_OK;
2015-04-12 03:36:25 +02:00
}
void console_putc(ppu_thread& ppu, char ch)
2015-04-12 03:36:25 +02:00
{
sysPrxForUser.trace("console_putc(ch=0x%x)", ch);
sys_tty_write(ppu, 0, vm::var<char>(ch), 1, vm::var<u32>{});
2015-04-12 03:36:25 +02:00
}
error_code console_write(ppu_thread& ppu, vm::ptr<char> data, u32 len)
2015-04-12 03:36:25 +02:00
{
sysPrxForUser.trace("console_write(data=*0x%x, len=%d)", data, len);
sys_tty_write(ppu, 0, data, len, vm::var<u32>{});
return CELL_OK;
2015-04-12 03:36:25 +02:00
}
2020-07-16 12:14:57 +02:00
error_code cellGamePs1Emu_61CE2BCD()
{
2020-02-01 09:23:50 +01:00
UNIMPLEMENTED_FUNC(sysPrxForUser);
return CELL_OK;
}
2020-07-16 12:14:57 +02:00
error_code cellSysconfPs1emu_639ABBDE()
{
2020-02-01 09:23:50 +01:00
UNIMPLEMENTED_FUNC(sysPrxForUser);
return CELL_OK;
}
2020-07-16 12:14:57 +02:00
error_code cellSysconfPs1emu_6A12D11F()
{
2020-02-01 09:23:50 +01:00
UNIMPLEMENTED_FUNC(sysPrxForUser);
return CELL_OK;
}
2020-07-16 12:14:57 +02:00
error_code cellSysconfPs1emu_83E79A23()
{
2020-02-01 09:23:50 +01:00
UNIMPLEMENTED_FUNC(sysPrxForUser);
return CELL_OK;
}
2020-07-16 12:14:57 +02:00
error_code cellSysconfPs1emu_EFDDAF6C()
{
2020-02-01 09:23:50 +01:00
UNIMPLEMENTED_FUNC(sysPrxForUser);
return CELL_OK;
}
2020-07-16 12:14:57 +02:00
error_code sys_lv2coredump_D725F320()
2017-03-14 13:03:04 +01:00
{
sysPrxForUser.fatal("sys_lv2coredump_D725F320");
return CELL_OK;
2017-03-14 13:03:04 +01:00
}
2020-07-16 12:14:57 +02:00
error_code sys_get_bd_media_id()
{
2020-02-01 09:23:50 +01:00
UNIMPLEMENTED_FUNC(sysPrxForUser);
return CELL_OK;
}
2020-07-16 12:14:57 +02:00
error_code sys_get_console_id()
{
2020-02-01 09:23:50 +01:00
UNIMPLEMENTED_FUNC(sysPrxForUser);
return CELL_OK;
}
2020-07-16 12:14:57 +02:00
error_code sysPs2Disc_A84FD3C3()
{
2020-02-01 09:23:50 +01:00
UNIMPLEMENTED_FUNC(sysPrxForUser);
return CELL_OK;
}
2020-07-16 12:14:57 +02:00
error_code sysPs2Disc_BB7CD1AE()
{
2020-02-01 09:23:50 +01:00
UNIMPLEMENTED_FUNC(sysPrxForUser);
return CELL_OK;
}
2015-04-12 03:36:25 +02:00
extern void sysPrxForUser_sys_lwmutex_init(ppu_static_module*);
extern void sysPrxForUser_sys_lwcond_init(ppu_static_module*);
2015-08-02 04:15:49 +02:00
extern void sysPrxForUser_sys_ppu_thread_init();
extern void sysPrxForUser_sys_prx_init();
extern void sysPrxForUser_sys_heap_init();
extern void sysPrxForUser_sys_spinlock_init();
extern void sysPrxForUser_sys_mmapper_init();
extern void sysPrxForUser_sys_mempool_init();
extern void sysPrxForUser_sys_spu_init();
extern void sysPrxForUser_sys_game_init();
extern void sysPrxForUser_sys_libc_init();
2017-06-20 19:30:05 +02:00
extern void sysPrxForUser_sys_rsxaudio_init();
DECLARE(ppu_module_manager::sysPrxForUser)("sysPrxForUser", [](ppu_static_module* _this)
{
static ppu_static_module cellGamePs1Emu("cellGamePs1Emu", []()
{
REG_FNID(cellGamePs1Emu, 0x61CE2BCD, cellGamePs1Emu_61CE2BCD);
});
static ppu_static_module cellSysconfPs1emu("cellSysconfPs1emu", []()
{
REG_FNID(cellSysconfPs1emu, 0x639ABBDE, cellSysconfPs1emu_639ABBDE);
REG_FNID(cellSysconfPs1emu, 0x6A12D11F, cellSysconfPs1emu_6A12D11F);
REG_FNID(cellSysconfPs1emu, 0x83E79A23, cellSysconfPs1emu_83E79A23);
REG_FNID(cellSysconfPs1emu, 0xEFDDAF6C, cellSysconfPs1emu_EFDDAF6C);
});
static ppu_static_module sys_lv2coredump("sys_lv2coredump", []()
{
REG_FNID(sys_lv2coredump, 0xD725F320, sys_lv2coredump_D725F320);
});
static ppu_static_module sysBdMediaId("sysBdMediaId", []()
{
REG_FUNC(sysBdMediaId, sys_get_bd_media_id);
});
static ppu_static_module sysConsoleId("sysConsoleId", []()
{
REG_FUNC(sysConsoleId, sys_get_console_id);
});
static ppu_static_module sysPs2Disc("sysPs2Disc", []()
{
REG_FNID(sysPs2Disc, 0xA84FD3C3, sysPs2Disc_A84FD3C3);
REG_FNID(sysPs2Disc, 0xBB7CD1AE, sysPs2Disc_BB7CD1AE);
});
sysPrxForUser_sys_lwmutex_init(_this);
sysPrxForUser_sys_lwcond_init(_this);
sysPrxForUser_sys_ppu_thread_init();
sysPrxForUser_sys_prx_init();
sysPrxForUser_sys_heap_init();
sysPrxForUser_sys_spinlock_init();
sysPrxForUser_sys_mmapper_init();
sysPrxForUser_sys_mempool_init();
sysPrxForUser_sys_spu_init();
sysPrxForUser_sys_game_init();
sysPrxForUser_sys_libc_init();
sysPrxForUser_sys_rsxaudio_init();
REG_VAR(sysPrxForUser, sys_prx_version); // 0x7df066cf
REG_VAR(sysPrxForUser, g_ppu_atexitspawn).flag(MFF_HIDDEN);
REG_VAR(sysPrxForUser, g_ppu_at_Exitspawn).flag(MFF_HIDDEN);
REG_FUNC(sysPrxForUser, sys_time_get_system_time);
REG_FUNC(sysPrxForUser, sys_process_exit);
REG_FUNC(sysPrxForUser, _sys_process_atexitspawn);
REG_FUNC(sysPrxForUser, _sys_process_at_Exitspawn);
REG_FUNC(sysPrxForUser, sys_process_is_stack);
REG_FUNC(sysPrxForUser, sys_process_get_paramsfo); // 0xe75c40f2
REG_FUNC(sysPrxForUser, sys_get_random_number);
REG_FUNC(sysPrxForUser, console_getc);
REG_FUNC(sysPrxForUser, console_putc);
REG_FUNC(sysPrxForUser, console_write);
});