From 58adb6a1aa31ce5ca61eca699f4e20159a8980ad Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Fri, 30 Oct 2020 18:24:11 +0300 Subject: [PATCH] sys_ppu_thread: add cpu_flag::wait --- rpcs3/Emu/Cell/Modules/sys_ppu_thread_.cpp | 4 ++- rpcs3/Emu/Cell/lv2/sys_ppu_thread.cpp | 38 +++++++++++++++++----- rpcs3/Emu/Cell/lv2/sys_ppu_thread.h | 16 ++++----- 3 files changed, 41 insertions(+), 17 deletions(-) diff --git a/rpcs3/Emu/Cell/Modules/sys_ppu_thread_.cpp b/rpcs3/Emu/Cell/Modules/sys_ppu_thread_.cpp index 5e0880e85d..8062d47bf2 100644 --- a/rpcs3/Emu/Cell/Modules/sys_ppu_thread_.cpp +++ b/rpcs3/Emu/Cell/Modules/sys_ppu_thread_.cpp @@ -125,6 +125,8 @@ void sys_initialize_tls(ppu_thread& ppu, u64 main_thread_id, u32 tls_seg_addr, u error_code sys_ppu_thread_create(ppu_thread& ppu, vm::ptr thread_id, u32 entry, u64 arg, s32 prio, u32 stacksize, u64 flags, vm::cptr threadname) { + ppu.state += cpu_flag::wait; + sysPrxForUser.warning("sys_ppu_thread_create(thread_id=*0x%x, entry=0x%x, arg=0x%llx, prio=%d, stacksize=0x%x, flags=0x%llx, threadname=%s)", thread_id, entry, arg, prio, stacksize, flags, threadname); @@ -137,7 +139,7 @@ error_code sys_ppu_thread_create(ppu_thread& ppu, vm::ptr thread_id, u32 en } // Call the syscall - if (error_code res = _sys_ppu_thread_create(thread_id, vm::make_var(ppu_thread_param_t{ vm::cast(entry), tls_addr + 0x7030 }), arg, 0, prio, stacksize, flags, threadname)) + if (error_code res = _sys_ppu_thread_create(ppu, thread_id, vm::make_var(ppu_thread_param_t{ vm::cast(entry), tls_addr + 0x7030 }), arg, 0, prio, stacksize, flags, threadname)) { return res; } diff --git a/rpcs3/Emu/Cell/lv2/sys_ppu_thread.cpp b/rpcs3/Emu/Cell/lv2/sys_ppu_thread.cpp index 38c7424de5..8dc55262a4 100644 --- a/rpcs3/Emu/Cell/lv2/sys_ppu_thread.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_ppu_thread.cpp @@ -82,6 +82,8 @@ void _sys_ppu_thread_exit(ppu_thread& ppu, u64 errorcode) s32 sys_ppu_thread_yield(ppu_thread& ppu) { + ppu.state += cpu_flag::wait; + sys_ppu_thread.trace("sys_ppu_thread_yield()"); // Return 0 on successful context switch, 1 otherwise @@ -167,8 +169,10 @@ error_code sys_ppu_thread_join(ppu_thread& ppu, u32 thread_id, vm::ptr vptr return CELL_OK; } -error_code sys_ppu_thread_detach(u32 thread_id) +error_code sys_ppu_thread_detach(ppu_thread& ppu, u32 thread_id) { + ppu.state += cpu_flag::wait; + sys_ppu_thread.trace("sys_ppu_thread_detach(thread_id=0x%x)", thread_id); // Clean some detached thread (hack) @@ -237,6 +241,8 @@ error_code sys_ppu_thread_get_join_state(ppu_thread& ppu, vm::ptr isjoinabl error_code sys_ppu_thread_set_priority(ppu_thread& ppu, u32 thread_id, s32 prio) { + ppu.state += cpu_flag::wait; + sys_ppu_thread.trace("sys_ppu_thread_set_priority(thread_id=0x%x, prio=%d)", thread_id, prio); if (prio < (g_ps3_process_info.debug_or_root() ? -512 : 0) || prio > 3071) @@ -270,8 +276,10 @@ error_code sys_ppu_thread_set_priority(ppu_thread& ppu, u32 thread_id, s32 prio) return CELL_OK; } -error_code sys_ppu_thread_get_priority(u32 thread_id, vm::ptr priop) +error_code sys_ppu_thread_get_priority(ppu_thread& ppu, u32 thread_id, vm::ptr priop) { + ppu.state += cpu_flag::wait; + sys_ppu_thread.trace("sys_ppu_thread_get_priority(thread_id=0x%x, priop=*0x%x)", thread_id, priop); // Clean some detached thread (hack) @@ -309,8 +317,10 @@ error_code sys_ppu_thread_get_stack_information(ppu_thread& ppu, vm::ptr thread_id, vm::ptr param, u64 arg, u64 unk, s32 prio, u32 _stacksz, u64 flags, vm::cptr threadname) +error_code _sys_ppu_thread_create(ppu_thread& ppu, vm::ptr thread_id, vm::ptr param, u64 arg, u64 unk, s32 prio, u32 _stacksz, u64 flags, vm::cptr threadname) { + ppu.state += cpu_flag::wait; + sys_ppu_thread.warning("_sys_ppu_thread_create(thread_id=*0x%x, param=*0x%x, arg=0x%llx, unk=0x%llx, prio=%d, stacksize=0x%x, flags=0x%llx, threadname=*0x%x)", thread_id, param, arg, unk, prio, _stacksz, flags, threadname); @@ -439,6 +453,8 @@ error_code _sys_ppu_thread_create(vm::ptr thread_id, vm::ptr>(thread_id, [&](ppu_thread& thread) -> CellError @@ -506,8 +522,10 @@ error_code sys_ppu_thread_start(ppu_thread& ppu, u32 thread_id) return CELL_OK; } -error_code sys_ppu_thread_rename(u32 thread_id, vm::cptr name) +error_code sys_ppu_thread_rename(ppu_thread& ppu, u32 thread_id, vm::cptr name) { + ppu.state += cpu_flag::wait; + sys_ppu_thread.warning("sys_ppu_thread_rename(thread_id=0x%x, name=*0x%x)", thread_id, name); const auto thread = idm::get>(thread_id, [&](ppu_thread& thread) @@ -537,8 +555,10 @@ error_code sys_ppu_thread_rename(u32 thread_id, vm::cptr name) return CELL_OK; } -error_code sys_ppu_thread_recover_page_fault(u32 thread_id) +error_code sys_ppu_thread_recover_page_fault(ppu_thread& ppu, u32 thread_id) { + ppu.state += cpu_flag::wait; + sys_ppu_thread.warning("sys_ppu_thread_recover_page_fault(thread_id=0x%x)", thread_id); const auto thread = idm::get>(thread_id, [&](ppu_thread& thread) @@ -554,8 +574,10 @@ error_code sys_ppu_thread_recover_page_fault(u32 thread_id) return mmapper_thread_recover_page_fault(thread.ptr.get()); } -error_code sys_ppu_thread_get_page_fault_context(u32 thread_id, vm::ptr ctxt) +error_code sys_ppu_thread_get_page_fault_context(ppu_thread& ppu, u32 thread_id, vm::ptr ctxt) { + ppu.state += cpu_flag::wait; + sys_ppu_thread.todo("sys_ppu_thread_get_page_fault_context(thread_id=0x%x, ctxt=*0x%x)", thread_id, ctxt); const auto thread = idm::get>(thread_id, [&](ppu_thread& thread) diff --git a/rpcs3/Emu/Cell/lv2/sys_ppu_thread.h b/rpcs3/Emu/Cell/lv2/sys_ppu_thread.h index 3d92478e21..28bcb5ebb1 100644 --- a/rpcs3/Emu/Cell/lv2/sys_ppu_thread.h +++ b/rpcs3/Emu/Cell/lv2/sys_ppu_thread.h @@ -58,15 +58,15 @@ enum : u32 void _sys_ppu_thread_exit(ppu_thread& ppu, u64 errorcode); s32 sys_ppu_thread_yield(ppu_thread& ppu); // Return value is ignored by the library error_code sys_ppu_thread_join(ppu_thread& ppu, u32 thread_id, vm::ptr vptr); -error_code sys_ppu_thread_detach(u32 thread_id); +error_code sys_ppu_thread_detach(ppu_thread& ppu, u32 thread_id); error_code sys_ppu_thread_get_join_state(ppu_thread& ppu, vm::ptr isjoinable); // Error code is ignored by the library error_code sys_ppu_thread_set_priority(ppu_thread& ppu, u32 thread_id, s32 prio); -error_code sys_ppu_thread_get_priority(u32 thread_id, vm::ptr priop); +error_code sys_ppu_thread_get_priority(ppu_thread& ppu, u32 thread_id, vm::ptr priop); error_code sys_ppu_thread_get_stack_information(ppu_thread& ppu, vm::ptr sp); -error_code sys_ppu_thread_stop(u32 thread_id); -error_code sys_ppu_thread_restart(); -error_code _sys_ppu_thread_create(vm::ptr thread_id, vm::ptr param, u64 arg, u64 arg4, s32 prio, u32 stacksize, u64 flags, vm::cptr threadname); +error_code sys_ppu_thread_stop(ppu_thread& ppu, u32 thread_id); +error_code sys_ppu_thread_restart(ppu_thread& ppu); +error_code _sys_ppu_thread_create(ppu_thread& ppu, vm::ptr thread_id, vm::ptr param, u64 arg, u64 arg4, s32 prio, u32 stacksize, u64 flags, vm::cptr threadname); error_code sys_ppu_thread_start(ppu_thread& ppu, u32 thread_id); -error_code sys_ppu_thread_rename(u32 thread_id, vm::cptr name); -error_code sys_ppu_thread_recover_page_fault(u32 thread_id); -error_code sys_ppu_thread_get_page_fault_context(u32 thread_id, vm::ptr ctxt); +error_code sys_ppu_thread_rename(ppu_thread& ppu, u32 thread_id, vm::cptr name); +error_code sys_ppu_thread_recover_page_fault(ppu_thread& ppu, u32 thread_id); +error_code sys_ppu_thread_get_page_fault_context(ppu_thread& ppu, u32 thread_id, vm::ptr ctxt);