diff --git a/rpcs3/Emu/Cell/Modules/sys_ppu_thread_.cpp b/rpcs3/Emu/Cell/Modules/sys_ppu_thread_.cpp index 0251652754..d0d37b041d 100644 --- a/rpcs3/Emu/Cell/Modules/sys_ppu_thread_.cpp +++ b/rpcs3/Emu/Cell/Modules/sys_ppu_thread_.cpp @@ -14,6 +14,7 @@ extern logs::channel sysPrxForUser; vm::gvar g_ppu_atexit_lwm; vm::gvar[8]> g_ppu_atexit; vm::gvar g_ppu_once_mutex; +vm::gvar g_ppu_prx_lwm; static u32 s_tls_addr = 0; // TLS image address static u32 s_tls_file = 0; // TLS image size @@ -110,6 +111,12 @@ void sys_initialize_tls(ppu_thread& ppu, u64 main_thread_id, u32 tls_seg_addr, u attr->flags = 0; attr->name_u64 = "_lv2ppu\0"_u64; sys_mutex_create(g_ppu_once_mutex, attr); + + lwa->protocol = SYS_SYNC_PRIORITY; + lwa->recursive = SYS_SYNC_RECURSIVE; + lwa->name_u64 = "_lv2prx\0"_u64; + sys_lwmutex_create(g_ppu_prx_lwm, lwa); + // TODO: missing prx initialization } 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) @@ -262,6 +269,7 @@ void sysPrxForUser_sys_ppu_thread_init() REG_VNID(sysPrxForUser, 0x00000000u, g_ppu_atexit_lwm); REG_VNID(sysPrxForUser, 0x00000001u, g_ppu_once_mutex); REG_VNID(sysPrxForUser, 0x00000002u, g_ppu_atexit); + REG_VNID(sysPrxForUser, 0x00000003u, g_ppu_prx_lwm); REG_FUNC(sysPrxForUser, sys_initialize_tls); REG_FUNC(sysPrxForUser, sys_ppu_thread_create); diff --git a/rpcs3/Emu/Cell/Modules/sys_prx_.cpp b/rpcs3/Emu/Cell/Modules/sys_prx_.cpp index 1aaed756de..d94c13b2c8 100644 --- a/rpcs3/Emu/Cell/Modules/sys_prx_.cpp +++ b/rpcs3/Emu/Cell/Modules/sys_prx_.cpp @@ -7,6 +7,8 @@ extern logs::channel sysPrxForUser; +extern vm::gvar g_ppu_prx_lwm; + // Convert the array of 32-bit pointers to 64-bit pointers using stack allocation static auto convert_path_list(vm::cpptr path_list, s32 count) { @@ -36,51 +38,57 @@ static void entryx(ppu_thread& ppu, vm::ptr } } -error_code sys_prx_load_module(vm::cptr path, u64 flags, vm::ptr pOpt) +error_code sys_prx_load_module(ppu_thread& ppu, vm::cptr path, u64 flags, vm::ptr pOpt) { sysPrxForUser.warning("sys_prx_load_module(path=%s, flags=0x%x, pOpt=*0x%x)", path, flags, pOpt); - // TODO + sys_lwmutex_locker(ppu, g_ppu_prx_lwm); + return _sys_prx_load_module(path, flags, pOpt); } -error_code sys_prx_load_module_by_fd(s32 fd, u64 offset, u64 flags, vm::ptr pOpt) +error_code sys_prx_load_module_by_fd(ppu_thread& ppu, s32 fd, u64 offset, u64 flags, vm::ptr pOpt) { sysPrxForUser.warning("sys_prx_load_module_by_fd(fd=%d, offset=0x%x, flags=0x%x, pOpt=*0x%x)", fd, offset, flags, pOpt); - // TODO + sys_lwmutex_locker(ppu, g_ppu_prx_lwm); + return _sys_prx_load_module_by_fd(fd, offset, flags, pOpt); } -error_code sys_prx_load_module_on_memcontainer(vm::cptr path, u32 mem_ct, u64 flags, vm::ptr pOpt) +error_code sys_prx_load_module_on_memcontainer(ppu_thread& ppu, vm::cptr path, u32 mem_ct, u64 flags, vm::ptr pOpt) { sysPrxForUser.warning("sys_prx_load_module_on_memcontainer(path=%s, mem_ct=0x%x, flags=0x%x, pOpt=*0x%x)", path, mem_ct, flags, pOpt); - // TODO + sys_lwmutex_locker(ppu, g_ppu_prx_lwm); + return _sys_prx_load_module_on_memcontainer(path, mem_ct, flags, pOpt); } -error_code sys_prx_load_module_on_memcontainer_by_fd(s32 fd, u64 offset, u32 mem_ct, u64 flags, vm::ptr pOpt) +error_code sys_prx_load_module_on_memcontainer_by_fd(ppu_thread& ppu, s32 fd, u64 offset, u32 mem_ct, u64 flags, vm::ptr pOpt) { sysPrxForUser.warning("sys_prx_load_module_on_memcontainer_by_fd(fd=%d, offset=0x%x, mem_ct=0x%x, flags=0x%x, pOpt=*0x%x)", fd, offset, mem_ct, flags, pOpt); - // TODO + sys_lwmutex_locker(ppu, g_ppu_prx_lwm); + return _sys_prx_load_module_on_memcontainer_by_fd(fd, offset, mem_ct, flags, pOpt); } -error_code sys_prx_load_module_list(s32 count, vm::cpptr path_list, u64 flags, vm::ptr pOpt, vm::ptr id_list) +error_code sys_prx_load_module_list(ppu_thread& ppu, s32 count, vm::cpptr path_list, u64 flags, vm::ptr pOpt, vm::ptr id_list) { sysPrxForUser.todo("sys_prx_load_module_list(count=%d, path_list=**0x%x, flags=0x%x, pOpt=*0x%x, id_list=*0x%x)", count, path_list, flags, pOpt, id_list); - // TODO + sys_lwmutex_locker(ppu, g_ppu_prx_lwm); + return _sys_prx_load_module_list(count, convert_path_list(path_list, count), flags, pOpt, id_list); } -error_code sys_prx_load_module_list_on_memcontainer(s32 count, vm::cpptr path_list, u32 mem_ct, u64 flags, vm::ptr pOpt, vm::ptr id_list) +error_code sys_prx_load_module_list_on_memcontainer(ppu_thread& ppu, s32 count, vm::cpptr path_list, u32 mem_ct, u64 flags, vm::ptr pOpt, vm::ptr id_list) { sysPrxForUser.todo("sys_prx_load_module_list_on_memcontainer(count=%d, path_list=**0x%x, mem_ct=0x%x, flags=0x%x, pOpt=*0x%x, id_list=*0x%x)", count, path_list, mem_ct, flags, pOpt, id_list); - // TODO + sys_lwmutex_locker(ppu, g_ppu_prx_lwm); + return _sys_prx_load_module_list_on_memcontainer(count, convert_path_list(path_list, count), mem_ct, flags, pOpt, id_list); } @@ -93,7 +101,7 @@ error_code sys_prx_start_module(ppu_thread& ppu, u32 id, u32 args, vm::ptr return CELL_EINVAL; } - // TODO + sys_lwmutex_locker(ppu, g_ppu_prx_lwm); vm::var opt; opt->size = opt.size(); @@ -126,7 +134,7 @@ error_code sys_prx_stop_module(ppu_thread& ppu, u32 id, u32 args, vm::ptr return CELL_EINVAL; } - // TODO + sys_lwmutex_locker(ppu, g_ppu_prx_lwm); vm::var opt; opt->size = opt.size(); @@ -150,27 +158,30 @@ error_code sys_prx_stop_module(ppu_thread& ppu, u32 id, u32 args, vm::ptr return CELL_OK; } -error_code sys_prx_unload_module(u32 id, u64 flags, vm::ptr pOpt) +error_code sys_prx_unload_module(ppu_thread& ppu, u32 id, u64 flags, vm::ptr pOpt) { sysPrxForUser.warning("sys_prx_unload_module(id=0x%x, flags=0x%x, pOpt=*0x%x)", id, flags, pOpt); - // TODO + sys_lwmutex_locker(ppu, g_ppu_prx_lwm); + return _sys_prx_unload_module(id, flags, pOpt); } -error_code sys_prx_register_library(vm::ptr lib_entry) +error_code sys_prx_register_library(ppu_thread& ppu, vm::ptr lib_entry) { sysPrxForUser.warning("sys_prx_register_library(lib_entry=*0x%x)", lib_entry); - // TODO + sys_lwmutex_locker(ppu, g_ppu_prx_lwm); + return _sys_prx_register_library(lib_entry); } -error_code sys_prx_unregister_library(vm::ptr lib_entry) +error_code sys_prx_unregister_library(ppu_thread& ppu, vm::ptr lib_entry) { sysPrxForUser.warning("sys_prx_unregister_library(lib_entry=*0x%x)", lib_entry); - // TODO + sys_lwmutex_locker(ppu, g_ppu_prx_lwm); + return _sys_prx_unregister_library(lib_entry); }