Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sys_sm: Implemented sys_sm_shutdown() #13048

Merged
merged 3 commits into from
Dec 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions rpcs3/Emu/Cell/lv2/sys_process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,13 @@ void _sys_process_exit2(ppu_thread& ppu, s32 status, vm::ptr<sys_exit2_param> ar

// TODO: set prio, flags

lv2_exitspawn(ppu, argv, envp, data);
}

void lv2_exitspawn(ppu_thread& ppu, std::vector<std::string>& argv, std::vector<std::string>& envp, std::vector<u8>& data)
{
ppu.state += cpu_flag::wait;

Emu.CallFromMainThread([argv = std::move(argv), envp = std::move(envp), data = std::move(data)]() mutable
{
sys_process.success("Process finished -> %s", argv[0]);
Expand Down
1 change: 1 addition & 0 deletions rpcs3/Emu/Cell/lv2/sys_process.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ extern ps3_process_info_t g_ps3_process_info;
// Auxiliary functions
s32 process_getpid();
s32 process_get_sdk_version(u32 pid, s32& ver);
void lv2_exitspawn(ppu_thread& ppu, std::vector<std::string>& argv, std::vector<std::string>& envp, std::vector<u8>& data);

enum CellError : u32;
CellError process_is_spu_lock_line_reservation_address(u32 addr, u64 flags);
Expand Down
40 changes: 38 additions & 2 deletions rpcs3/Emu/Cell/lv2/sys_sm.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#include "stdafx.h"
#include "Emu/Memory/vm.h"
#include "Emu/System.h"

#include "Emu/Cell/ErrorCodes.h"
#include "Emu/Cell/PPUThread.h"
#include "Emu/Cell/lv2/sys_process.h"

#include "sys_sm.h"

Expand Down Expand Up @@ -41,9 +44,42 @@ error_code sys_sm_get_ext_event2(vm::ptr<u64> a1, vm::ptr<u64> a2, vm::ptr<u64>
return not_an_error(CELL_EAGAIN);
}

error_code sys_sm_shutdown(u16 op, vm::ptr<void> param, u64 size)
error_code sys_sm_shutdown(ppu_thread& ppu, u16 op, vm::ptr<void> param, u64 size)
{
sys_sm.todo("sys_sm_shutdown(op=0x%x, param=*0x%x, size=0x%x)", op, param, size);
ppu.state += cpu_flag::wait;

sys_sm.success("sys_sm_shutdown(op=0x%x, param=*0x%x, size=0x%x)", op, param, size);

if (!g_ps3_process_info.has_root_perm())
{
return CELL_ENOSYS;
}

switch (op)
{
case 0x100:
case 0x1100:
{
sys_sm.success("Received shutdown request from application");
_sys_process_exit(ppu, 0, 0, 0);
break;
}
case 0x200:
case 0x1200:
{
sys_sm.success("Received reboot request from application");
lv2_exitspawn(ppu, Emu.argv, Emu.envp, Emu.data);
break;
}
case 0x8201:
case 0x8202:
case 0x8204:
{
sys_sm.warning("Unsupported LPAR operation: 0x%x", op);
return CELL_ENOTSUP;
}
default: return CELL_EINVAL;
}

return CELL_OK;
}
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Emu/Cell/lv2/sys_sm.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// SysCalls

error_code sys_sm_get_ext_event2(vm::ptr<u64> a1, vm::ptr<u64> a2, vm::ptr<u64> a3, u64 a4);
error_code sys_sm_shutdown(u16 op, vm::ptr<void> param, u64 size);
error_code sys_sm_shutdown(ppu_thread& ppu, u16 op, vm::ptr<void> param, u64 size);
error_code sys_sm_get_params(vm::ptr<u8> a, vm::ptr<u8> b, vm::ptr<u32> c, vm::ptr<u64> d);
error_code sys_sm_control_led(u8 led, u8 action);
error_code sys_sm_ring_buzzer(u64 packet, u64 a1, u64 a2);
Expand Down