From 093ecc0a02926582a36e34d1c4249547a373007c Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Tue, 8 Sep 2015 14:29:27 +0300 Subject: [PATCH 1/6] CALL_FUNC macro fixed Now it can call any HLE function, possibly using LLE if available. --- rpcs3/Emu/SysCalls/Modules.h | 25 +- rpcs3/Emu/SysCalls/Modules/cellFiber.cpp | 92 +- rpcs3/Emu/SysCalls/Modules/cellSpurs.cpp | 2 - rpcs3/Emu/SysCalls/Modules/sys_lwmutex_.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/sys_net.cpp | 2 +- rpcs3/Emu/SysCalls/SC_FUNC.h | 12 +- rpcs3/Emu/SysCalls/SysCalls.cpp | 1438 +++++++++---------- 7 files changed, 787 insertions(+), 788 deletions(-) diff --git a/rpcs3/Emu/SysCalls/Modules.h b/rpcs3/Emu/SysCalls/Modules.h index 6855c42c4..4d1191dab 100644 --- a/rpcs3/Emu/SysCalls/Modules.h +++ b/rpcs3/Emu/SysCalls/Modules.h @@ -125,33 +125,36 @@ void hook_ppu_funcs(vm::ptr base, u32 size); bool patch_ppu_import(u32 addr, u32 index); -// call specified function directly if LLE is not available, call LLE equivalent in callback style otherwise -template inline auto hle_call_func(PPUThread& CPU, T func, u32 index, Args&&... args) -> decltype(func(std::forward(args)...)) +// Variable associated with registered HLE function +template struct ppu_func_by_func { static u32 index; }; + +template u32 ppu_func_by_func::index = 0xffffffffu; + +template> inline RT call_ppu_func(PPUThread& ppu, Args&&... args) { - const auto mfunc = get_ppu_func_by_index(index); + const auto mfunc = get_ppu_func_by_index(ppu_func_by_func::index); if (mfunc && mfunc->lle_func && (mfunc->flags & MFF_FORCED_HLE) == 0 && (mfunc->flags & MFF_NO_RETURN) == 0) { const u32 pc = vm::read32(mfunc->lle_func.addr()); const u32 rtoc = vm::read32(mfunc->lle_func.addr() + 4); - return cb_call(args)...)), Args...>(CPU, pc, rtoc, std::forward(args)...); + return cb_call(ppu, pc, rtoc, std::forward(args)...); } else { - return func(std::forward(args)...); + return Func(std::forward(args)...); } } -#define CALL_FUNC(cpu, func, ...) hle_call_func(cpu, func, g_ppu_func_index__##func, __VA_ARGS__) +// call specified function directly if LLE is not available, call LLE equivalent in callback style otherwise +#define CALL_FUNC(ppu, func, ...) call_ppu_func(ppu, __VA_ARGS__) -#define REG_FUNC(module, name) add_ppu_func(ModuleFunc(get_function_id(#name), 0, &module, #name, bind_func(name))) -#define REG_FUNC_FH(module, name) add_ppu_func(ModuleFunc(get_function_id(#name), MFF_FORCED_HLE, &module, #name, bind_func(name))) -#define REG_FUNC_NR(module, name) add_ppu_func(ModuleFunc(get_function_id(#name), MFF_NO_RETURN, &module, #name, bind_func(name))) +#define REG_FNID(module, nid, func, ...) (ppu_func_by_func::index = add_ppu_func(ModuleFunc(nid, { __VA_ARGS__ }, &module, #func, BIND_FUNC(func)))) -#define REG_UNNAMED(module, nid) add_ppu_func(ModuleFunc(0x##nid, 0, &module, "_nid_"#nid, bind_func(_nid_##nid))) +#define REG_FUNC(module, func, ...) REG_FNID(module, get_function_id(#func), func, __VA_ARGS__) -#define REG_SUB(module, ns, name, ...) add_ppu_func_sub({ __VA_ARGS__ }, #name, &module, bind_func(ns::name)) +#define REG_SUB(module, ns, name, ...) add_ppu_func_sub({ __VA_ARGS__ }, #name, &module, BIND_FUNC(ns::name)) #define SP_OP(type, op, sup) []() { s32 XXX = 0; SearchPatternEntry res = { (type), (op), 0, (sup) }; XXX = -1; res.mask = (op) ^ ~res.data; return res; }() #define SP_I(op) SP_OP(SPET_MASKED_OPCODE, op, 0) diff --git a/rpcs3/Emu/SysCalls/Modules/cellFiber.cpp b/rpcs3/Emu/SysCalls/Modules/cellFiber.cpp index df3456989..10c603b75 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellFiber.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellFiber.cpp @@ -293,57 +293,57 @@ s32 cellFiberPpuUtilWorkerControlInitializeWithAttribute() Module cellFiber("cellFiber", []() { - REG_FUNC_NR(cellFiber, _cellFiberPpuInitialize); + REG_FUNC(cellFiber, _cellFiberPpuInitialize, MFF_NO_RETURN); - REG_FUNC_NR(cellFiber, _cellFiberPpuSchedulerAttributeInitialize); - REG_FUNC_NR(cellFiber, cellFiberPpuInitializeScheduler); - REG_FUNC_NR(cellFiber, cellFiberPpuFinalizeScheduler); - REG_FUNC_NR(cellFiber, cellFiberPpuRunFibers); - REG_FUNC_NR(cellFiber, cellFiberPpuCheckFlags); - REG_FUNC_NR(cellFiber, cellFiberPpuHasRunnableFiber); + REG_FUNC(cellFiber, _cellFiberPpuSchedulerAttributeInitialize, MFF_NO_RETURN); + REG_FUNC(cellFiber, cellFiberPpuInitializeScheduler, MFF_NO_RETURN); + REG_FUNC(cellFiber, cellFiberPpuFinalizeScheduler, MFF_NO_RETURN); + REG_FUNC(cellFiber, cellFiberPpuRunFibers, MFF_NO_RETURN); + REG_FUNC(cellFiber, cellFiberPpuCheckFlags, MFF_NO_RETURN); + REG_FUNC(cellFiber, cellFiberPpuHasRunnableFiber, MFF_NO_RETURN); - REG_FUNC_NR(cellFiber, _cellFiberPpuAttributeInitialize); - REG_FUNC_NR(cellFiber, cellFiberPpuCreateFiber); - REG_FUNC_NR(cellFiber, cellFiberPpuExit); - REG_FUNC_NR(cellFiber, cellFiberPpuYield); - REG_FUNC_NR(cellFiber, cellFiberPpuJoinFiber); + REG_FUNC(cellFiber, _cellFiberPpuAttributeInitialize, MFF_NO_RETURN); + REG_FUNC(cellFiber, cellFiberPpuCreateFiber, MFF_NO_RETURN); + REG_FUNC(cellFiber, cellFiberPpuExit, MFF_NO_RETURN); + REG_FUNC(cellFiber, cellFiberPpuYield, MFF_NO_RETURN); + REG_FUNC(cellFiber, cellFiberPpuJoinFiber, MFF_NO_RETURN); REG_FUNC(cellFiber, cellFiberPpuSelf); - REG_FUNC_NR(cellFiber, cellFiberPpuSendSignal); - REG_FUNC_NR(cellFiber, cellFiberPpuWaitSignal); - REG_FUNC_NR(cellFiber, cellFiberPpuWaitFlag); - REG_FUNC_NR(cellFiber, cellFiberPpuGetScheduler); - REG_FUNC_NR(cellFiber, cellFiberPpuSetPriority); - REG_FUNC_NR(cellFiber, cellFiberPpuCheckStackLimit); + REG_FUNC(cellFiber, cellFiberPpuSendSignal, MFF_NO_RETURN); + REG_FUNC(cellFiber, cellFiberPpuWaitSignal, MFF_NO_RETURN); + REG_FUNC(cellFiber, cellFiberPpuWaitFlag, MFF_NO_RETURN); + REG_FUNC(cellFiber, cellFiberPpuGetScheduler, MFF_NO_RETURN); + REG_FUNC(cellFiber, cellFiberPpuSetPriority, MFF_NO_RETURN); + REG_FUNC(cellFiber, cellFiberPpuCheckStackLimit, MFF_NO_RETURN); - REG_FUNC_NR(cellFiber, _cellFiberPpuContextAttributeInitialize); - REG_FUNC_NR(cellFiber, cellFiberPpuContextInitialize); - REG_FUNC_NR(cellFiber, cellFiberPpuContextFinalize); - REG_FUNC_NR(cellFiber, cellFiberPpuContextRun); - REG_FUNC_NR(cellFiber, cellFiberPpuContextSwitch); - REG_FUNC_NR(cellFiber, cellFiberPpuContextSelf); - REG_FUNC_NR(cellFiber, cellFiberPpuContextReturnToThread); - REG_FUNC_NR(cellFiber, cellFiberPpuContextCheckStackLimit); + REG_FUNC(cellFiber, _cellFiberPpuContextAttributeInitialize, MFF_NO_RETURN); + REG_FUNC(cellFiber, cellFiberPpuContextInitialize, MFF_NO_RETURN); + REG_FUNC(cellFiber, cellFiberPpuContextFinalize, MFF_NO_RETURN); + REG_FUNC(cellFiber, cellFiberPpuContextRun, MFF_NO_RETURN); + REG_FUNC(cellFiber, cellFiberPpuContextSwitch, MFF_NO_RETURN); + REG_FUNC(cellFiber, cellFiberPpuContextSelf, MFF_NO_RETURN); + REG_FUNC(cellFiber, cellFiberPpuContextReturnToThread, MFF_NO_RETURN); + REG_FUNC(cellFiber, cellFiberPpuContextCheckStackLimit, MFF_NO_RETURN); - REG_FUNC_NR(cellFiber, cellFiberPpuContextRunScheduler); - REG_FUNC_NR(cellFiber, cellFiberPpuContextEnterScheduler); + REG_FUNC(cellFiber, cellFiberPpuContextRunScheduler, MFF_NO_RETURN); + REG_FUNC(cellFiber, cellFiberPpuContextEnterScheduler, MFF_NO_RETURN); - REG_FUNC_NR(cellFiber, cellFiberPpuSchedulerTraceInitialize); - REG_FUNC_NR(cellFiber, cellFiberPpuSchedulerTraceFinalize); - REG_FUNC_NR(cellFiber, cellFiberPpuSchedulerTraceStart); - REG_FUNC_NR(cellFiber, cellFiberPpuSchedulerTraceStop); + REG_FUNC(cellFiber, cellFiberPpuSchedulerTraceInitialize, MFF_NO_RETURN); + REG_FUNC(cellFiber, cellFiberPpuSchedulerTraceFinalize, MFF_NO_RETURN); + REG_FUNC(cellFiber, cellFiberPpuSchedulerTraceStart, MFF_NO_RETURN); + REG_FUNC(cellFiber, cellFiberPpuSchedulerTraceStop, MFF_NO_RETURN); - REG_FUNC_NR(cellFiber, _cellFiberPpuUtilWorkerControlAttributeInitialize); - REG_FUNC_NR(cellFiber, cellFiberPpuUtilWorkerControlRunFibers); - REG_FUNC_NR(cellFiber, cellFiberPpuUtilWorkerControlInitialize); - REG_FUNC_NR(cellFiber, cellFiberPpuUtilWorkerControlSetPollingMode); - REG_FUNC_NR(cellFiber, cellFiberPpuUtilWorkerControlJoinFiber); - REG_FUNC_NR(cellFiber, cellFiberPpuUtilWorkerControlDisconnectEventQueue); - REG_FUNC_NR(cellFiber, cellFiberPpuUtilWorkerControlSendSignal); - REG_FUNC_NR(cellFiber, cellFiberPpuUtilWorkerControlConnectEventQueueToSpurs); - REG_FUNC_NR(cellFiber, cellFiberPpuUtilWorkerControlFinalize); - REG_FUNC_NR(cellFiber, cellFiberPpuUtilWorkerControlWakeup); - REG_FUNC_NR(cellFiber, cellFiberPpuUtilWorkerControlCreateFiber); - REG_FUNC_NR(cellFiber, cellFiberPpuUtilWorkerControlShutdown); - REG_FUNC_NR(cellFiber, cellFiberPpuUtilWorkerControlCheckFlags); - REG_FUNC_NR(cellFiber, cellFiberPpuUtilWorkerControlInitializeWithAttribute); + REG_FUNC(cellFiber, _cellFiberPpuUtilWorkerControlAttributeInitialize, MFF_NO_RETURN); + REG_FUNC(cellFiber, cellFiberPpuUtilWorkerControlRunFibers, MFF_NO_RETURN); + REG_FUNC(cellFiber, cellFiberPpuUtilWorkerControlInitialize, MFF_NO_RETURN); + REG_FUNC(cellFiber, cellFiberPpuUtilWorkerControlSetPollingMode, MFF_NO_RETURN); + REG_FUNC(cellFiber, cellFiberPpuUtilWorkerControlJoinFiber, MFF_NO_RETURN); + REG_FUNC(cellFiber, cellFiberPpuUtilWorkerControlDisconnectEventQueue, MFF_NO_RETURN); + REG_FUNC(cellFiber, cellFiberPpuUtilWorkerControlSendSignal, MFF_NO_RETURN); + REG_FUNC(cellFiber, cellFiberPpuUtilWorkerControlConnectEventQueueToSpurs, MFF_NO_RETURN); + REG_FUNC(cellFiber, cellFiberPpuUtilWorkerControlFinalize, MFF_NO_RETURN); + REG_FUNC(cellFiber, cellFiberPpuUtilWorkerControlWakeup, MFF_NO_RETURN); + REG_FUNC(cellFiber, cellFiberPpuUtilWorkerControlCreateFiber, MFF_NO_RETURN); + REG_FUNC(cellFiber, cellFiberPpuUtilWorkerControlShutdown, MFF_NO_RETURN); + REG_FUNC(cellFiber, cellFiberPpuUtilWorkerControlCheckFlags, MFF_NO_RETURN); + REG_FUNC(cellFiber, cellFiberPpuUtilWorkerControlInitializeWithAttribute, MFF_NO_RETURN); }); diff --git a/rpcs3/Emu/SysCalls/Modules/cellSpurs.cpp b/rpcs3/Emu/SysCalls/Modules/cellSpurs.cpp index 6414f6343..1c706c775 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSpurs.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSpurs.cpp @@ -422,8 +422,6 @@ void spursHandlerWaitReady(PPUThread& ppu, vm::ptr spurs) if (spurs->handlerExiting.load()) { - extern u32 g_ppu_func_index__sys_lwmutex_unlock; // test - if (s32 rc = CALL_FUNC(ppu, sys_lwmutex_unlock, ppu, spurs.ptr(&CellSpurs::mutex))) { throw EXCEPTION("sys_lwmutex_unlock() failed (0x%x)", rc); diff --git a/rpcs3/Emu/SysCalls/Modules/sys_lwmutex_.cpp b/rpcs3/Emu/SysCalls/Modules/sys_lwmutex_.cpp index 6146af1a8..a9d9acf41 100644 --- a/rpcs3/Emu/SysCalls/Modules/sys_lwmutex_.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sys_lwmutex_.cpp @@ -276,13 +276,11 @@ s32 sys_lwmutex_unlock(PPUThread& ppu, vm::ptr lwmutex) return CELL_OK; } -u32 g_ppu_func_index__sys_lwmutex_unlock; // test - void sysPrxForUser_sys_lwmutex_init() { REG_FUNC(sysPrxForUser, sys_lwmutex_create); REG_FUNC(sysPrxForUser, sys_lwmutex_destroy); REG_FUNC(sysPrxForUser, sys_lwmutex_lock); REG_FUNC(sysPrxForUser, sys_lwmutex_trylock); - g_ppu_func_index__sys_lwmutex_unlock = REG_FUNC(sysPrxForUser, sys_lwmutex_unlock); // test + REG_FUNC(sysPrxForUser, sys_lwmutex_unlock); } diff --git a/rpcs3/Emu/SysCalls/Modules/sys_net.cpp b/rpcs3/Emu/SysCalls/Modules/sys_net.cpp index 034381eb6..0be717ad6 100644 --- a/rpcs3/Emu/SysCalls/Modules/sys_net.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sys_net.cpp @@ -614,7 +614,7 @@ namespace sys_net } // define additional macro for specific namespace -#define REG_FUNC_(name) add_ppu_func(ModuleFunc(get_function_id(#name), 0, &libnet, #name, bind_func(sys_net::name))) +#define REG_FUNC_(name) add_ppu_func(ModuleFunc(get_function_id(#name), 0, &libnet, #name, BIND_FUNC(sys_net::name))) Module libnet("sys_net", []() { diff --git a/rpcs3/Emu/SysCalls/SC_FUNC.h b/rpcs3/Emu/SysCalls/SC_FUNC.h index 50bd1d1d7..510c7fd0f 100644 --- a/rpcs3/Emu/SysCalls/SC_FUNC.h +++ b/rpcs3/Emu/SysCalls/SC_FUNC.h @@ -228,11 +228,11 @@ namespace ppu_func_detail bind_result::value>::put_result(ppu, call(ppu, func, arg_info_pack_t<>{})); } }; + + template force_inline void do_call(PPUThread& ppu, RT(*func)(T...)) + { + func_binder::do_call(ppu, func); + } } -template force_inline void call_ppu_func(PPUThread& ppu, RT(*func)(T...)) -{ - ppu_func_detail::func_binder::do_call(ppu, func); -} - -#define bind_func(func) [](PPUThread& ppu){ call_ppu_func(ppu, func); } +#define BIND_FUNC(func) [](PPUThread& ppu){ ppu_func_detail::do_call(ppu, func); } diff --git a/rpcs3/Emu/SysCalls/SysCalls.cpp b/rpcs3/Emu/SysCalls/SysCalls.cpp index 38a2e4c3e..4d765a46d 100644 --- a/rpcs3/Emu/SysCalls/SysCalls.cpp +++ b/rpcs3/Emu/SysCalls/SysCalls.cpp @@ -49,239 +49,239 @@ void null_func(PPUThread& ppu) const ppu_func_caller g_sc_table[1024] = { null_func, - bind_func(sys_process_getpid), //1 (0x001) - bind_func(sys_process_wait_for_child), //2 (0x002) ROOT - null_func,//bind_func(sys_process_exit), //3 (0x003) - bind_func(sys_process_get_status), //4 (0x004) DBG - bind_func(sys_process_detach_child), //5 (0x005) DBG + BIND_FUNC(sys_process_getpid), //1 (0x001) + BIND_FUNC(sys_process_wait_for_child), //2 (0x002) ROOT + null_func,//BIND_FUNC(sys_process_exit), //3 (0x003) + BIND_FUNC(sys_process_get_status), //4 (0x004) DBG + BIND_FUNC(sys_process_detach_child), //5 (0x005) DBG null_func, null_func, null_func, null_func, null_func, null_func, //6-11 UNS - bind_func(sys_process_get_number_of_object), //12 (0x00C) - bind_func(sys_process_get_id), //13 (0x00D) - bind_func(sys_process_is_spu_lock_line_reservation_address), //14 (0x00E) + BIND_FUNC(sys_process_get_number_of_object), //12 (0x00C) + BIND_FUNC(sys_process_get_id), //13 (0x00D) + BIND_FUNC(sys_process_is_spu_lock_line_reservation_address), //14 (0x00E) null_func, null_func, null_func, //15-17 UNS - bind_func(sys_process_getppid), //18 (0x012) - bind_func(sys_process_kill), //19 (0x013) + BIND_FUNC(sys_process_getppid), //18 (0x012) + BIND_FUNC(sys_process_kill), //19 (0x013) null_func, //20 (0x014) UNS - null_func,//bind_func(_sys_process_spawn), //21 (0x015) DBG - null_func,//bind_func(sys_process_exit), //22 (0x016) - bind_func(sys_process_wait_for_child2), //23 (0x017) DBG - null_func,//bind_func(), //24 (0x018) DBG - bind_func(sys_process_get_sdk_version), //25 (0x019) - null_func,//bind_func(_sys_process_exit), //26 (0x01A) - null_func,//bind_func(), //27 (0x01B) DBG - null_func,//bind_func(_sys_process_get_number_of_object)//28 (0x01C) ROOT - bind_func(sys_process_get_id), //29 (0x01D) ROOT - bind_func(_sys_process_get_paramsfo), //30 (0x01E) - null_func,//bind_func(sys_process_get_ppu_guid), //31 (0x01F) + null_func,//BIND_FUNC(_sys_process_spawn), //21 (0x015) DBG + null_func,//BIND_FUNC(sys_process_exit), //22 (0x016) + BIND_FUNC(sys_process_wait_for_child2), //23 (0x017) DBG + null_func,//BIND_FUNC(), //24 (0x018) DBG + BIND_FUNC(sys_process_get_sdk_version), //25 (0x019) + null_func,//BIND_FUNC(_sys_process_exit), //26 (0x01A) + null_func,//BIND_FUNC(), //27 (0x01B) DBG + null_func,//BIND_FUNC(_sys_process_get_number_of_object)//28 (0x01C) ROOT + BIND_FUNC(sys_process_get_id), //29 (0x01D) ROOT + BIND_FUNC(_sys_process_get_paramsfo), //30 (0x01E) + null_func,//BIND_FUNC(sys_process_get_ppu_guid), //31 (0x01F) null_func, null_func, null_func, null_func, null_func, null_func, null_func, null_func, null_func, //32-40 UNS - bind_func(_sys_ppu_thread_exit), //41 (0x029) + BIND_FUNC(_sys_ppu_thread_exit), //41 (0x029) null_func, //42 (0x02A) UNS - bind_func(sys_ppu_thread_yield), //43 (0x02B) - bind_func(sys_ppu_thread_join), //44 (0x02C) - bind_func(sys_ppu_thread_detach), //45 (0x02D) - bind_func(sys_ppu_thread_get_join_state), //46 (0x02E) - bind_func(sys_ppu_thread_set_priority), //47 (0x02F) DBG - bind_func(sys_ppu_thread_get_priority), //48 (0x030) - bind_func(sys_ppu_thread_get_stack_information), //49 (0x031) - null_func,//bind_func(sys_ppu_thread_stop), //50 (0x032) ROOT - null_func,//bind_func(sys_ppu_thread_restart), //51 (0x033) ROOT - bind_func(_sys_ppu_thread_create), //52 (0x034) DBG - bind_func(sys_ppu_thread_start), //53 (0x035) - null_func,//bind_func(sys_ppu_...), //54 (0x036) ROOT - null_func,//bind_func(sys_ppu_...), //55 (0x037) ROOT - bind_func(sys_ppu_thread_rename), //56 (0x038) - null_func,//bind_func(sys_ppu_thread_recover_page_fault)//57 (0x039) - null_func,//bind_func(sys_ppu_thread_get_page_fault_context),//58 (0x03A) + BIND_FUNC(sys_ppu_thread_yield), //43 (0x02B) + BIND_FUNC(sys_ppu_thread_join), //44 (0x02C) + BIND_FUNC(sys_ppu_thread_detach), //45 (0x02D) + BIND_FUNC(sys_ppu_thread_get_join_state), //46 (0x02E) + BIND_FUNC(sys_ppu_thread_set_priority), //47 (0x02F) DBG + BIND_FUNC(sys_ppu_thread_get_priority), //48 (0x030) + BIND_FUNC(sys_ppu_thread_get_stack_information), //49 (0x031) + null_func,//BIND_FUNC(sys_ppu_thread_stop), //50 (0x032) ROOT + null_func,//BIND_FUNC(sys_ppu_thread_restart), //51 (0x033) ROOT + BIND_FUNC(_sys_ppu_thread_create), //52 (0x034) DBG + BIND_FUNC(sys_ppu_thread_start), //53 (0x035) + null_func,//BIND_FUNC(sys_ppu_...), //54 (0x036) ROOT + null_func,//BIND_FUNC(sys_ppu_...), //55 (0x037) ROOT + BIND_FUNC(sys_ppu_thread_rename), //56 (0x038) + null_func,//BIND_FUNC(sys_ppu_thread_recover_page_fault)//57 (0x039) + null_func,//BIND_FUNC(sys_ppu_thread_get_page_fault_context),//58 (0x03A) null_func, //59 (0x03B) UNS - bind_func(sys_trace_create), //60 (0x03C) - bind_func(sys_trace_start), //61 (0x03D) - bind_func(sys_trace_stop), //62 (0x03E) - bind_func(sys_trace_update_top_index), //63 (0x03F) - bind_func(sys_trace_destroy), //64 (0x040) - bind_func(sys_trace_drain), //65 (0x041) - bind_func(sys_trace_attach_process), //66 (0x042) - bind_func(sys_trace_allocate_buffer), //67 (0x043) - bind_func(sys_trace_free_buffer), //68 (0x044) - bind_func(sys_trace_create2), //69 (0x045) - bind_func(sys_timer_create), //70 (0x046) - bind_func(sys_timer_destroy), //71 (0x047) - bind_func(sys_timer_get_information), //72 (0x048) - bind_func(_sys_timer_start), //73 (0x049) - bind_func(sys_timer_stop), //74 (0x04A) - bind_func(sys_timer_connect_event_queue), //75 (0x04B) - bind_func(sys_timer_disconnect_event_queue), //76 (0x04C) - null_func,//bind_func(sys_trace_create2_in_cbepm), //77 (0x04D) - null_func,//bind_func(sys_trace_...) //78 (0x04E) + BIND_FUNC(sys_trace_create), //60 (0x03C) + BIND_FUNC(sys_trace_start), //61 (0x03D) + BIND_FUNC(sys_trace_stop), //62 (0x03E) + BIND_FUNC(sys_trace_update_top_index), //63 (0x03F) + BIND_FUNC(sys_trace_destroy), //64 (0x040) + BIND_FUNC(sys_trace_drain), //65 (0x041) + BIND_FUNC(sys_trace_attach_process), //66 (0x042) + BIND_FUNC(sys_trace_allocate_buffer), //67 (0x043) + BIND_FUNC(sys_trace_free_buffer), //68 (0x044) + BIND_FUNC(sys_trace_create2), //69 (0x045) + BIND_FUNC(sys_timer_create), //70 (0x046) + BIND_FUNC(sys_timer_destroy), //71 (0x047) + BIND_FUNC(sys_timer_get_information), //72 (0x048) + BIND_FUNC(_sys_timer_start), //73 (0x049) + BIND_FUNC(sys_timer_stop), //74 (0x04A) + BIND_FUNC(sys_timer_connect_event_queue), //75 (0x04B) + BIND_FUNC(sys_timer_disconnect_event_queue), //76 (0x04C) + null_func,//BIND_FUNC(sys_trace_create2_in_cbepm), //77 (0x04D) + null_func,//BIND_FUNC(sys_trace_...) //78 (0x04E) null_func, //79 (0x04F) UNS - null_func,//bind_func(sys_interrupt_tag_create) //80 (0x050) - bind_func(sys_interrupt_tag_destroy), //81 (0x051) - bind_func(sys_event_flag_create), //82 (0x052) - bind_func(sys_event_flag_destroy), //83 (0x053) - bind_func(_sys_interrupt_thread_establish), //84 (0x054) - bind_func(sys_event_flag_wait), //85 (0x055) - bind_func(sys_event_flag_trywait), //86 (0x056) - bind_func(sys_event_flag_set), //87 (0x057) - bind_func(sys_interrupt_thread_eoi), //88 (0x058) - bind_func(_sys_interrupt_thread_disestablish), //89 (0x059) - bind_func(sys_semaphore_create), //90 (0x05A) - bind_func(sys_semaphore_destroy), //91 (0x05B) - bind_func(sys_semaphore_wait), //92 (0x05C) - bind_func(sys_semaphore_trywait), //93 (0x05D) - bind_func(sys_semaphore_post), //94 (0x05E) - bind_func(_sys_lwmutex_create), //95 (0x05F) - bind_func(_sys_lwmutex_destroy), //96 (0x060) - bind_func(_sys_lwmutex_lock), //97 (0x061) - bind_func(_sys_lwmutex_unlock), //98 (0x062) - bind_func(_sys_lwmutex_trylock), //99 (0x063) - bind_func(sys_mutex_create), //100 (0x064) - bind_func(sys_mutex_destroy), //101 (0x065) - bind_func(sys_mutex_lock), //102 (0x066) - bind_func(sys_mutex_trylock), //103 (0x067) - bind_func(sys_mutex_unlock), //104 (0x068) - bind_func(sys_cond_create), //105 (0x069) - bind_func(sys_cond_destroy), //106 (0x06A) - bind_func(sys_cond_wait), //107 (0x06B) - bind_func(sys_cond_signal), //108 (0x06C) - bind_func(sys_cond_signal_all), //109 (0x06D) - bind_func(sys_cond_signal_to), //110 (0x06E) - bind_func(_sys_lwcond_create), //111 (0x06F) - bind_func(_sys_lwcond_destroy), //112 (0x070) - bind_func(_sys_lwcond_queue_wait), //113 (0x071) - bind_func(sys_semaphore_get_value), //114 (0x072) - bind_func(_sys_lwcond_signal), //115 (0x073) - bind_func(_sys_lwcond_signal_all), //116 (0x074) - null_func,//bind_func(sys_semaphore_...) //117 (0x075) // internal, used by sys_lwmutex_unlock - bind_func(sys_event_flag_clear), //118 (0x076) - null_func,//bind_func(sys_event_...) //119 (0x077) ROOT - bind_func(sys_rwlock_create), //120 (0x078) - bind_func(sys_rwlock_destroy), //121 (0x079) - bind_func(sys_rwlock_rlock), //122 (0x07A) - bind_func(sys_rwlock_tryrlock), //123 (0x07B) - bind_func(sys_rwlock_runlock), //124 (0x07C) - bind_func(sys_rwlock_wlock), //125 (0x07D) - bind_func(sys_rwlock_trywlock), //126 (0x07E) - bind_func(sys_rwlock_wunlock), //127 (0x07F) - bind_func(sys_event_queue_create), //128 (0x080) - bind_func(sys_event_queue_destroy), //129 (0x081) - bind_func(sys_event_queue_receive), //130 (0x082) - bind_func(sys_event_queue_tryreceive), //131 (0x083) - bind_func(sys_event_flag_cancel), //132 (0x084) - bind_func(sys_event_queue_drain), //133 (0x085) - bind_func(sys_event_port_create), //134 (0x086) - bind_func(sys_event_port_destroy), //135 (0x087) - bind_func(sys_event_port_connect_local), //136 (0x088) - bind_func(sys_event_port_disconnect), //137 (0x089) - bind_func(sys_event_port_send), //138 (0x08A) - bind_func(sys_event_flag_get), //139 (0x08B) - null_func,//bind_func(sys_event_port_connect_ipc) //140 (0x08C) - bind_func(sys_timer_usleep), //141 (0x08D) - bind_func(sys_timer_sleep), //142 (0x08E) - null_func,//bind_func(sys_time_set_timezone) //143 (0x08F) ROOT - bind_func(sys_time_get_timezone), //144 (0x090) - bind_func(sys_time_get_current_time), //145 (0x091) - null_func,//bind_func(sys_time_get_system_time), //146 (0x092) ROOT - bind_func(sys_time_get_timebase_frequency), //147 (0x093) - null_func,//bind_func(_sys_rwlock_trywlock) //148 (0x094) + null_func,//BIND_FUNC(sys_interrupt_tag_create) //80 (0x050) + BIND_FUNC(sys_interrupt_tag_destroy), //81 (0x051) + BIND_FUNC(sys_event_flag_create), //82 (0x052) + BIND_FUNC(sys_event_flag_destroy), //83 (0x053) + BIND_FUNC(_sys_interrupt_thread_establish), //84 (0x054) + BIND_FUNC(sys_event_flag_wait), //85 (0x055) + BIND_FUNC(sys_event_flag_trywait), //86 (0x056) + BIND_FUNC(sys_event_flag_set), //87 (0x057) + BIND_FUNC(sys_interrupt_thread_eoi), //88 (0x058) + BIND_FUNC(_sys_interrupt_thread_disestablish), //89 (0x059) + BIND_FUNC(sys_semaphore_create), //90 (0x05A) + BIND_FUNC(sys_semaphore_destroy), //91 (0x05B) + BIND_FUNC(sys_semaphore_wait), //92 (0x05C) + BIND_FUNC(sys_semaphore_trywait), //93 (0x05D) + BIND_FUNC(sys_semaphore_post), //94 (0x05E) + BIND_FUNC(_sys_lwmutex_create), //95 (0x05F) + BIND_FUNC(_sys_lwmutex_destroy), //96 (0x060) + BIND_FUNC(_sys_lwmutex_lock), //97 (0x061) + BIND_FUNC(_sys_lwmutex_unlock), //98 (0x062) + BIND_FUNC(_sys_lwmutex_trylock), //99 (0x063) + BIND_FUNC(sys_mutex_create), //100 (0x064) + BIND_FUNC(sys_mutex_destroy), //101 (0x065) + BIND_FUNC(sys_mutex_lock), //102 (0x066) + BIND_FUNC(sys_mutex_trylock), //103 (0x067) + BIND_FUNC(sys_mutex_unlock), //104 (0x068) + BIND_FUNC(sys_cond_create), //105 (0x069) + BIND_FUNC(sys_cond_destroy), //106 (0x06A) + BIND_FUNC(sys_cond_wait), //107 (0x06B) + BIND_FUNC(sys_cond_signal), //108 (0x06C) + BIND_FUNC(sys_cond_signal_all), //109 (0x06D) + BIND_FUNC(sys_cond_signal_to), //110 (0x06E) + BIND_FUNC(_sys_lwcond_create), //111 (0x06F) + BIND_FUNC(_sys_lwcond_destroy), //112 (0x070) + BIND_FUNC(_sys_lwcond_queue_wait), //113 (0x071) + BIND_FUNC(sys_semaphore_get_value), //114 (0x072) + BIND_FUNC(_sys_lwcond_signal), //115 (0x073) + BIND_FUNC(_sys_lwcond_signal_all), //116 (0x074) + null_func,//BIND_FUNC(sys_semaphore_...) //117 (0x075) // internal, used by sys_lwmutex_unlock + BIND_FUNC(sys_event_flag_clear), //118 (0x076) + null_func,//BIND_FUNC(sys_event_...) //119 (0x077) ROOT + BIND_FUNC(sys_rwlock_create), //120 (0x078) + BIND_FUNC(sys_rwlock_destroy), //121 (0x079) + BIND_FUNC(sys_rwlock_rlock), //122 (0x07A) + BIND_FUNC(sys_rwlock_tryrlock), //123 (0x07B) + BIND_FUNC(sys_rwlock_runlock), //124 (0x07C) + BIND_FUNC(sys_rwlock_wlock), //125 (0x07D) + BIND_FUNC(sys_rwlock_trywlock), //126 (0x07E) + BIND_FUNC(sys_rwlock_wunlock), //127 (0x07F) + BIND_FUNC(sys_event_queue_create), //128 (0x080) + BIND_FUNC(sys_event_queue_destroy), //129 (0x081) + BIND_FUNC(sys_event_queue_receive), //130 (0x082) + BIND_FUNC(sys_event_queue_tryreceive), //131 (0x083) + BIND_FUNC(sys_event_flag_cancel), //132 (0x084) + BIND_FUNC(sys_event_queue_drain), //133 (0x085) + BIND_FUNC(sys_event_port_create), //134 (0x086) + BIND_FUNC(sys_event_port_destroy), //135 (0x087) + BIND_FUNC(sys_event_port_connect_local), //136 (0x088) + BIND_FUNC(sys_event_port_disconnect), //137 (0x089) + BIND_FUNC(sys_event_port_send), //138 (0x08A) + BIND_FUNC(sys_event_flag_get), //139 (0x08B) + null_func,//BIND_FUNC(sys_event_port_connect_ipc) //140 (0x08C) + BIND_FUNC(sys_timer_usleep), //141 (0x08D) + BIND_FUNC(sys_timer_sleep), //142 (0x08E) + null_func,//BIND_FUNC(sys_time_set_timezone) //143 (0x08F) ROOT + BIND_FUNC(sys_time_get_timezone), //144 (0x090) + BIND_FUNC(sys_time_get_current_time), //145 (0x091) + null_func,//BIND_FUNC(sys_time_get_system_time), //146 (0x092) ROOT + BIND_FUNC(sys_time_get_timebase_frequency), //147 (0x093) + null_func,//BIND_FUNC(_sys_rwlock_trywlock) //148 (0x094) null_func, //149 (0x095) UNS - bind_func(sys_raw_spu_create_interrupt_tag), //150 (0x096) - bind_func(sys_raw_spu_set_int_mask), //151 (0x097) - bind_func(sys_raw_spu_get_int_mask), //152 (0x098) - bind_func(sys_raw_spu_set_int_stat), //153 (0x099) - bind_func(sys_raw_spu_get_int_stat), //154 (0x09A) - null_func,//bind_func(sys_spu_image_get_information?) //155 (0x09B) - bind_func(sys_spu_image_open), //156 (0x09C) - null_func,//bind_func(sys_spu_image_import) //157 (0x09D) - null_func,//bind_func(sys_spu_image_close) //158 (0x09E) - null_func,//bind_func(sys_raw_spu_load) //159 (0x09F) - bind_func(sys_raw_spu_create), //160 (0x0A0) - bind_func(sys_raw_spu_destroy), //161 (0x0A1) + BIND_FUNC(sys_raw_spu_create_interrupt_tag), //150 (0x096) + BIND_FUNC(sys_raw_spu_set_int_mask), //151 (0x097) + BIND_FUNC(sys_raw_spu_get_int_mask), //152 (0x098) + BIND_FUNC(sys_raw_spu_set_int_stat), //153 (0x099) + BIND_FUNC(sys_raw_spu_get_int_stat), //154 (0x09A) + null_func,//BIND_FUNC(sys_spu_image_get_information?) //155 (0x09B) + BIND_FUNC(sys_spu_image_open), //156 (0x09C) + null_func,//BIND_FUNC(sys_spu_image_import) //157 (0x09D) + null_func,//BIND_FUNC(sys_spu_image_close) //158 (0x09E) + null_func,//BIND_FUNC(sys_raw_spu_load) //159 (0x09F) + BIND_FUNC(sys_raw_spu_create), //160 (0x0A0) + BIND_FUNC(sys_raw_spu_destroy), //161 (0x0A1) null_func, //162 (0x0A2) UNS - bind_func(sys_raw_spu_read_puint_mb), //163 (0x0A3) + BIND_FUNC(sys_raw_spu_read_puint_mb), //163 (0x0A3) null_func, //164 (0x0A4) UNS - bind_func(sys_spu_thread_get_exit_status), //165 (0x0A5) - bind_func(sys_spu_thread_set_argument), //166 (0x0A6) - null_func,//bind_func(sys_spu_thread_group_start_on_exit)//167(0x0A7) + BIND_FUNC(sys_spu_thread_get_exit_status), //165 (0x0A5) + BIND_FUNC(sys_spu_thread_set_argument), //166 (0x0A6) + null_func,//BIND_FUNC(sys_spu_thread_group_start_on_exit)//167(0x0A7) null_func, //168 (0x0A8) UNS - bind_func(sys_spu_initialize), //169 (0x0A9) - bind_func(sys_spu_thread_group_create), //170 (0x0AA) - bind_func(sys_spu_thread_group_destroy), //171 (0x0AB) - bind_func(sys_spu_thread_initialize), //172 (0x0AC) - bind_func(sys_spu_thread_group_start), //173 (0x0AD) - bind_func(sys_spu_thread_group_suspend), //174 (0x0AE) - bind_func(sys_spu_thread_group_resume), //175 (0x0AF) - bind_func(sys_spu_thread_group_yield), //176 (0x0B0) - bind_func(sys_spu_thread_group_terminate), //177 (0x0B1) - bind_func(sys_spu_thread_group_join), //178 (0x0B2) - null_func,//bind_func(sys_spu_thread_group_set_priority)//179 (0x0B3) - null_func,//bind_func(sys_spu_thread_group_get_priority)//180 (0x0B4) - bind_func(sys_spu_thread_write_ls), //181 (0x0B5) - bind_func(sys_spu_thread_read_ls), //182 (0x0B6) + BIND_FUNC(sys_spu_initialize), //169 (0x0A9) + BIND_FUNC(sys_spu_thread_group_create), //170 (0x0AA) + BIND_FUNC(sys_spu_thread_group_destroy), //171 (0x0AB) + BIND_FUNC(sys_spu_thread_initialize), //172 (0x0AC) + BIND_FUNC(sys_spu_thread_group_start), //173 (0x0AD) + BIND_FUNC(sys_spu_thread_group_suspend), //174 (0x0AE) + BIND_FUNC(sys_spu_thread_group_resume), //175 (0x0AF) + BIND_FUNC(sys_spu_thread_group_yield), //176 (0x0B0) + BIND_FUNC(sys_spu_thread_group_terminate), //177 (0x0B1) + BIND_FUNC(sys_spu_thread_group_join), //178 (0x0B2) + null_func,//BIND_FUNC(sys_spu_thread_group_set_priority)//179 (0x0B3) + null_func,//BIND_FUNC(sys_spu_thread_group_get_priority)//180 (0x0B4) + BIND_FUNC(sys_spu_thread_write_ls), //181 (0x0B5) + BIND_FUNC(sys_spu_thread_read_ls), //182 (0x0B6) null_func, //183 (0x0B7) UNS - bind_func(sys_spu_thread_write_snr), //184 (0x0B8) - bind_func(sys_spu_thread_group_connect_event), //185 (0x0B9) - bind_func(sys_spu_thread_group_disconnect_event), //186 (0x0BA) - bind_func(sys_spu_thread_set_spu_cfg), //187 (0x0BB) - bind_func(sys_spu_thread_get_spu_cfg), //188 (0x0BC) + BIND_FUNC(sys_spu_thread_write_snr), //184 (0x0B8) + BIND_FUNC(sys_spu_thread_group_connect_event), //185 (0x0B9) + BIND_FUNC(sys_spu_thread_group_disconnect_event), //186 (0x0BA) + BIND_FUNC(sys_spu_thread_set_spu_cfg), //187 (0x0BB) + BIND_FUNC(sys_spu_thread_get_spu_cfg), //188 (0x0BC) null_func, //189 (0x0BD) UNS - bind_func(sys_spu_thread_write_spu_mb), //190 (0x0BE) - bind_func(sys_spu_thread_connect_event), //191 (0x0BF) - bind_func(sys_spu_thread_disconnect_event), //192 (0x0C0) - bind_func(sys_spu_thread_bind_queue), //193 (0x0C1) - bind_func(sys_spu_thread_unbind_queue), //194 (0x0C2) + BIND_FUNC(sys_spu_thread_write_spu_mb), //190 (0x0BE) + BIND_FUNC(sys_spu_thread_connect_event), //191 (0x0BF) + BIND_FUNC(sys_spu_thread_disconnect_event), //192 (0x0C0) + BIND_FUNC(sys_spu_thread_bind_queue), //193 (0x0C1) + BIND_FUNC(sys_spu_thread_unbind_queue), //194 (0x0C2) null_func, //195 (0x0C3) UNS - bind_func(sys_raw_spu_set_spu_cfg), //196 (0x0C4) - bind_func(sys_raw_spu_get_spu_cfg), //197 (0x0C5) - null_func,//bind_func(sys_spu_thread_recover_page_fault)//198 (0x0C6) - null_func,//bind_func(sys_raw_spu_recover_page_fault) //199 (0x0C7) + BIND_FUNC(sys_raw_spu_set_spu_cfg), //196 (0x0C4) + BIND_FUNC(sys_raw_spu_get_spu_cfg), //197 (0x0C5) + null_func,//BIND_FUNC(sys_spu_thread_recover_page_fault)//198 (0x0C6) + null_func,//BIND_FUNC(sys_raw_spu_recover_page_fault) //199 (0x0C7) null_func, null_func, null_func, null_func, null_func, //204 UNS? null_func, null_func, null_func, null_func, null_func, //209 UNS? null_func, null_func, null_func, null_func, null_func, //214 UNS? - null_func,//bind_func(sys_dbg_mat_set_condition) //215 (0x0D7) - null_func,//bind_func(sys_dbg_mat_get_condition) //216 (0x0D8) - null_func,//bind_func(sys_dbg_...) //217 (0x0D9) DBG UNS? - null_func,//bind_func(sys_dbg_...) //218 (0x0DA) DBG UNS? - null_func,//bind_func(sys_dbg_...) //219 (0x0DB) DBG UNS? + null_func,//BIND_FUNC(sys_dbg_mat_set_condition) //215 (0x0D7) + null_func,//BIND_FUNC(sys_dbg_mat_get_condition) //216 (0x0D8) + null_func,//BIND_FUNC(sys_dbg_...) //217 (0x0D9) DBG UNS? + null_func,//BIND_FUNC(sys_dbg_...) //218 (0x0DA) DBG UNS? + null_func,//BIND_FUNC(sys_dbg_...) //219 (0x0DB) DBG UNS? null_func, null_func, null_func, null_func, null_func, //224 UNS null_func, null_func, null_func, null_func, null_func, //229 UNS? - null_func,//bind_func(sys_isolated_spu_create) //230 (0x0E6) ROOT - null_func,//bind_func(sys_isolated_spu_destroy) //231 (0x0E7) ROOT - null_func,//bind_func(sys_isolated_spu_start) //232 (0x0E8) ROOT - null_func,//bind_func(sys_isolated_spu_create_interrupt_tag) //233 (0x0E9) ROOT - null_func,//bind_func(sys_isolated_spu_set_int_mask) //234 (0x0EA) ROOT - null_func,//bind_func(sys_isolated_spu_get_int_mask) //235 (0x0EB) ROOT - null_func,//bind_func(sys_isolated_spu_set_int_stat) //236 (0x0EC) ROOT - null_func,//bind_func(sys_isolated_spu_get_int_stat) //237 (0x0ED) ROOT - null_func,//bind_func(sys_isolated_spu_set_spu_cfg) //238 (0x0EE) ROOT - null_func,//bind_func(sys_isolated_spu_get_spu_cfg) //239 (0x0EF) ROOT - null_func,//bind_func(sys_isolated_spu_read_puint_mb) //240 (0x0F0) ROOT + null_func,//BIND_FUNC(sys_isolated_spu_create) //230 (0x0E6) ROOT + null_func,//BIND_FUNC(sys_isolated_spu_destroy) //231 (0x0E7) ROOT + null_func,//BIND_FUNC(sys_isolated_spu_start) //232 (0x0E8) ROOT + null_func,//BIND_FUNC(sys_isolated_spu_create_interrupt_tag) //233 (0x0E9) ROOT + null_func,//BIND_FUNC(sys_isolated_spu_set_int_mask) //234 (0x0EA) ROOT + null_func,//BIND_FUNC(sys_isolated_spu_get_int_mask) //235 (0x0EB) ROOT + null_func,//BIND_FUNC(sys_isolated_spu_set_int_stat) //236 (0x0EC) ROOT + null_func,//BIND_FUNC(sys_isolated_spu_get_int_stat) //237 (0x0ED) ROOT + null_func,//BIND_FUNC(sys_isolated_spu_set_spu_cfg) //238 (0x0EE) ROOT + null_func,//BIND_FUNC(sys_isolated_spu_get_spu_cfg) //239 (0x0EF) ROOT + null_func,//BIND_FUNC(sys_isolated_spu_read_puint_mb) //240 (0x0F0) ROOT null_func, //241 (0x0F1) ROOT UNS null_func, //242 (0x0F2) ROOT UNS null_func, //243 (0x0F3) ROOT UNS - null_func,//bind_func(sys_spu_thread_group_system_set_next_group) //244 (0x0F4) ROOT - null_func,//bind_func(sys_spu_thread_group_system_unset_next_group) //245 (0x0F5) ROOT - null_func,//bind_func(sys_spu_thread_group_system_set_switch_group) //246 (0x0F6) ROOT - null_func,//bind_func(sys_spu_thread_group_system_unset_switch_group) //247 (0x0F7) ROOT - null_func,//bind_func(sys_spu_thread_group...) //248 (0x0F8) ROOT - null_func,//bind_func(sys_spu_thread_group...) //249 (0x0F9) ROOT - null_func,//bind_func(sys_spu_thread_group_set_cooperative_victims) //250 (0x0FA) - bind_func(sys_spu_thread_group_connect_event_all_threads), //251 (0x0FB) - bind_func(sys_spu_thread_group_disconnect_event_all_threads), //252 (0x0FC) - null_func,//bind_func() //253 (0x0FD) - null_func,//bind_func(sys_spu_thread_group_log) //254 (0x0FE) + null_func,//BIND_FUNC(sys_spu_thread_group_system_set_next_group) //244 (0x0F4) ROOT + null_func,//BIND_FUNC(sys_spu_thread_group_system_unset_next_group) //245 (0x0F5) ROOT + null_func,//BIND_FUNC(sys_spu_thread_group_system_set_switch_group) //246 (0x0F6) ROOT + null_func,//BIND_FUNC(sys_spu_thread_group_system_unset_switch_group) //247 (0x0F7) ROOT + null_func,//BIND_FUNC(sys_spu_thread_group...) //248 (0x0F8) ROOT + null_func,//BIND_FUNC(sys_spu_thread_group...) //249 (0x0F9) ROOT + null_func,//BIND_FUNC(sys_spu_thread_group_set_cooperative_victims) //250 (0x0FA) + BIND_FUNC(sys_spu_thread_group_connect_event_all_threads), //251 (0x0FB) + BIND_FUNC(sys_spu_thread_group_disconnect_event_all_threads), //252 (0x0FC) + null_func,//BIND_FUNC() //253 (0x0FD) + null_func,//BIND_FUNC(sys_spu_thread_group_log) //254 (0x0FE) null_func, null_func, null_func, null_func, null_func, //255-259 UNS - null_func,//bind_func(sys_spu_image_open_by_fd) //260 (0x104) + null_func,//BIND_FUNC(sys_spu_image_open_by_fd) //260 (0x104) null_func, null_func, null_func, null_func, //264 UNS null_func, null_func, null_func, null_func, null_func, //269 UNS @@ -292,117 +292,117 @@ const ppu_func_caller g_sc_table[1024] = null_func, null_func, null_func, null_func, null_func, //294 UNS null_func, null_func, null_func, null_func, null_func, //299 UNS - bind_func(sys_vm_memory_map), //300 (0x12C) - bind_func(sys_vm_unmap), //301 (0x12D) - bind_func(sys_vm_append_memory), //302 (0x12E) - bind_func(sys_vm_return_memory), //303 (0x12F) - bind_func(sys_vm_lock), //304 (0x130) - bind_func(sys_vm_unlock), //305 (0x131) - bind_func(sys_vm_touch), //306 (0x132) - bind_func(sys_vm_flush), //307 (0x133) - bind_func(sys_vm_invalidate), //308 (0x134) - bind_func(sys_vm_store), //309 (0x135) - bind_func(sys_vm_sync), //310 (0x136) - bind_func(sys_vm_test), //311 (0x137) - bind_func(sys_vm_get_statistics), //312 (0x138) - null_func,//bind_func(sys_vm_memory_map (different)) //313 (0x139) - null_func,//bind_func(sys_...) //314 (0x13A) - null_func,//bind_func(sys_...) //315 (0x13B) + BIND_FUNC(sys_vm_memory_map), //300 (0x12C) + BIND_FUNC(sys_vm_unmap), //301 (0x12D) + BIND_FUNC(sys_vm_append_memory), //302 (0x12E) + BIND_FUNC(sys_vm_return_memory), //303 (0x12F) + BIND_FUNC(sys_vm_lock), //304 (0x130) + BIND_FUNC(sys_vm_unlock), //305 (0x131) + BIND_FUNC(sys_vm_touch), //306 (0x132) + BIND_FUNC(sys_vm_flush), //307 (0x133) + BIND_FUNC(sys_vm_invalidate), //308 (0x134) + BIND_FUNC(sys_vm_store), //309 (0x135) + BIND_FUNC(sys_vm_sync), //310 (0x136) + BIND_FUNC(sys_vm_test), //311 (0x137) + BIND_FUNC(sys_vm_get_statistics), //312 (0x138) + null_func,//BIND_FUNC(sys_vm_memory_map (different)) //313 (0x139) + null_func,//BIND_FUNC(sys_...) //314 (0x13A) + null_func,//BIND_FUNC(sys_...) //315 (0x13B) null_func, null_func, null_func, null_func, null_func, null_func, null_func, null_func, //316-323 UNS - bind_func(sys_memory_container_create), //324 (0x144) DBG - bind_func(sys_memory_container_destroy), //325 (0x145) DBG - bind_func(sys_mmapper_allocate_fixed_address), //326 (0x146) - bind_func(sys_mmapper_enable_page_fault_notification), //327 (0x147) - null_func,//bind_func(sys_mmapper_...) //328 (0x148) - null_func,//bind_func(sys_mmapper_free_shared_memory) //329 (0x149) - bind_func(sys_mmapper_allocate_address), //330 (0x14A) - bind_func(sys_mmapper_free_address), //331 (0x14B) - null_func,//bind_func(sys_mmapper_allocate_shared_memory)//332(0x14C) - null_func,//bind_func(sys_mmapper_set_shared_memory_flag)//333(0x14D) - null_func,//bind_func(sys_mmapper_map_shared_memory) //334 (0x14E) - null_func,//bind_func(sys_mmapper_unmap_shared_memory) //335 (0x14F) - bind_func(sys_mmapper_change_address_access_right), //336 (0x150) - bind_func(sys_mmapper_search_and_map), //337 (0x151) - null_func,//bind_func(sys_mmapper_get_shared_memory_attribute) //338 (0x152) - null_func,//bind_func(sys_...) //339 (0x153) - null_func,//bind_func(sys_...) //340 (0x154) - bind_func(sys_memory_container_create), //341 (0x155) - bind_func(sys_memory_container_destroy), //342 (0x156) - bind_func(sys_memory_container_get_size), //343 (0x157) - null_func,//bind_func(sys_memory_budget_set) //344 (0x158) - null_func,//bind_func(sys_memory_...) //345 (0x159) - null_func,//bind_func(sys_memory_...) //346 (0x15A) + BIND_FUNC(sys_memory_container_create), //324 (0x144) DBG + BIND_FUNC(sys_memory_container_destroy), //325 (0x145) DBG + BIND_FUNC(sys_mmapper_allocate_fixed_address), //326 (0x146) + BIND_FUNC(sys_mmapper_enable_page_fault_notification), //327 (0x147) + null_func,//BIND_FUNC(sys_mmapper_...) //328 (0x148) + null_func,//BIND_FUNC(sys_mmapper_free_shared_memory) //329 (0x149) + BIND_FUNC(sys_mmapper_allocate_address), //330 (0x14A) + BIND_FUNC(sys_mmapper_free_address), //331 (0x14B) + null_func,//BIND_FUNC(sys_mmapper_allocate_shared_memory)//332(0x14C) + null_func,//BIND_FUNC(sys_mmapper_set_shared_memory_flag)//333(0x14D) + null_func,//BIND_FUNC(sys_mmapper_map_shared_memory) //334 (0x14E) + null_func,//BIND_FUNC(sys_mmapper_unmap_shared_memory) //335 (0x14F) + BIND_FUNC(sys_mmapper_change_address_access_right), //336 (0x150) + BIND_FUNC(sys_mmapper_search_and_map), //337 (0x151) + null_func,//BIND_FUNC(sys_mmapper_get_shared_memory_attribute) //338 (0x152) + null_func,//BIND_FUNC(sys_...) //339 (0x153) + null_func,//BIND_FUNC(sys_...) //340 (0x154) + BIND_FUNC(sys_memory_container_create), //341 (0x155) + BIND_FUNC(sys_memory_container_destroy), //342 (0x156) + BIND_FUNC(sys_memory_container_get_size), //343 (0x157) + null_func,//BIND_FUNC(sys_memory_budget_set) //344 (0x158) + null_func,//BIND_FUNC(sys_memory_...) //345 (0x159) + null_func,//BIND_FUNC(sys_memory_...) //346 (0x15A) null_func, //347 (0x15B) UNS - bind_func(sys_memory_allocate), //348 (0x15C) - bind_func(sys_memory_free), //349 (0x15D) - bind_func(sys_memory_allocate_from_container), //350 (0x15E) - bind_func(sys_memory_get_page_attribute), //351 (0x15F) - bind_func(sys_memory_get_user_memory_size), //352 (0x160) - null_func,//bind_func(sys_memory_get_user_memory_stat) //353 (0x161) - null_func,//bind_func(sys_memory_...) //354 (0x162) - null_func,//bind_func(sys_memory_...) //355 (0x163) - null_func,//bind_func(sys_memory_allocate_colored) //356 (0x164) - null_func,//bind_func(sys_memory_...) //357 (0x165) - null_func,//bind_func(sys_memory_...) //358 (0x166) - null_func,//bind_func(sys_memory_...) //359 (0x167) - null_func,//bind_func(sys_memory_...) //360 (0x168) - null_func,//bind_func(sys_memory_allocate_from_container_colored) //361 (0x169) - null_func,//bind_func(sys_mmapper_allocate_memory_from_container) //362 (0x16A) - null_func,//bind_func(sys_mmapper_...) //363 (0x16B) - null_func,//bind_func(sys_mmapper_...) //364 (0x16C) + BIND_FUNC(sys_memory_allocate), //348 (0x15C) + BIND_FUNC(sys_memory_free), //349 (0x15D) + BIND_FUNC(sys_memory_allocate_from_container), //350 (0x15E) + BIND_FUNC(sys_memory_get_page_attribute), //351 (0x15F) + BIND_FUNC(sys_memory_get_user_memory_size), //352 (0x160) + null_func,//BIND_FUNC(sys_memory_get_user_memory_stat) //353 (0x161) + null_func,//BIND_FUNC(sys_memory_...) //354 (0x162) + null_func,//BIND_FUNC(sys_memory_...) //355 (0x163) + null_func,//BIND_FUNC(sys_memory_allocate_colored) //356 (0x164) + null_func,//BIND_FUNC(sys_memory_...) //357 (0x165) + null_func,//BIND_FUNC(sys_memory_...) //358 (0x166) + null_func,//BIND_FUNC(sys_memory_...) //359 (0x167) + null_func,//BIND_FUNC(sys_memory_...) //360 (0x168) + null_func,//BIND_FUNC(sys_memory_allocate_from_container_colored) //361 (0x169) + null_func,//BIND_FUNC(sys_mmapper_allocate_memory_from_container) //362 (0x16A) + null_func,//BIND_FUNC(sys_mmapper_...) //363 (0x16B) + null_func,//BIND_FUNC(sys_mmapper_...) //364 (0x16C) null_func, //365 (0x16D) UNS null_func, //366 (0x16E) UNS - null_func,//bind_func(sys_uart_initialize) //367 (0x16F) ROOT - null_func,//bind_func(sys_uart_receive) //368 (0x170) ROOT - null_func,//bind_func(sys_uart_send) //369 (0x171) ROOT - null_func,//bind_func(sys_uart_get_params) //370 (0x172) ROOT + null_func,//BIND_FUNC(sys_uart_initialize) //367 (0x16F) ROOT + null_func,//BIND_FUNC(sys_uart_receive) //368 (0x170) ROOT + null_func,//BIND_FUNC(sys_uart_send) //369 (0x171) ROOT + null_func,//BIND_FUNC(sys_uart_get_params) //370 (0x172) ROOT null_func, //371 (0x173) UNS - null_func,//bind_func(sys_game_watchdog_start) //372 (0x174) - null_func,//bind_func(sys_game_watchdog_stop) //373 (0x175) - null_func,//bind_func(sys_game_watchdog_clear) //374 (0x176) - null_func,//bind_func(sys_game_set_system_sw_version) //375 (0x177) ROOT - null_func,//bind_func(sys_game_get_system_sw_version) //376 (0x178) ROOT - null_func,//bind_func(sys_sm_set_shop_mode) //377 (0x179) ROOT - null_func,//bind_func(sys_sm_get_ext_event2) //378 (0x17A) ROOT - null_func,//bind_func(sys_sm_shutdown) //379 (0x17B) ROOT - null_func,//bind_func(sys_sm_get_params) //380 (0x17C) DBG - null_func,//bind_func(sys_sm_get_inter_lpar_parameter) //381 (0x17D) ROOT - null_func,//bind_func(sys_sm_) //382 (0x17E) ROOT - null_func,//bind_func(sys_game_get_temperature) //383 (0x17F) ROOT - null_func,//bind_func(sys_sm_get_tzpb) //384 (0x180) ROOT - null_func,//bind_func(sys_sm_request_led) //385 (0x181) ROOT - null_func,//bind_func(sys_sm_control_led) //386 (0x182) ROOT - null_func,//bind_func(sys_sm_get_platform_info) //387 (0x183) DBG - null_func,//bind_func(sys_sm_ring_buzzer) //388 (0x184) ROOT - null_func,//bind_func(sys_sm_set_fan_policy) //389 (0x185) PM - null_func,//bind_func(sys_sm_request_error_log) //390 (0x186) ROOT - null_func,//bind_func(sys_sm_request_be_count) //391 (0x187) ROOT - null_func,//bind_func(sys_sm_ring_buzzer) //392 (0x188) ROOT - null_func,//bind_func(sys_sm_get_hw_config) //393 (0x189) ROOT - null_func,//bind_func(sys_sm_request_scversion) //394 (0x18A) ROOT - null_func,//bind_func(sys_sm_request_system_event_log) //395 (0x18B) PM - null_func,//bind_func(sys_sm_set_rtc_alarm) //396 (0x18C) ROOT - null_func,//bind_func(sys_sm_get_rtc_alarm) //397 (0x18D) ROOT - null_func,//bind_func(sys_console_write) //398 (0x18E) ROOT + null_func,//BIND_FUNC(sys_game_watchdog_start) //372 (0x174) + null_func,//BIND_FUNC(sys_game_watchdog_stop) //373 (0x175) + null_func,//BIND_FUNC(sys_game_watchdog_clear) //374 (0x176) + null_func,//BIND_FUNC(sys_game_set_system_sw_version) //375 (0x177) ROOT + null_func,//BIND_FUNC(sys_game_get_system_sw_version) //376 (0x178) ROOT + null_func,//BIND_FUNC(sys_sm_set_shop_mode) //377 (0x179) ROOT + null_func,//BIND_FUNC(sys_sm_get_ext_event2) //378 (0x17A) ROOT + null_func,//BIND_FUNC(sys_sm_shutdown) //379 (0x17B) ROOT + null_func,//BIND_FUNC(sys_sm_get_params) //380 (0x17C) DBG + null_func,//BIND_FUNC(sys_sm_get_inter_lpar_parameter) //381 (0x17D) ROOT + null_func,//BIND_FUNC(sys_sm_) //382 (0x17E) ROOT + null_func,//BIND_FUNC(sys_game_get_temperature) //383 (0x17F) ROOT + null_func,//BIND_FUNC(sys_sm_get_tzpb) //384 (0x180) ROOT + null_func,//BIND_FUNC(sys_sm_request_led) //385 (0x181) ROOT + null_func,//BIND_FUNC(sys_sm_control_led) //386 (0x182) ROOT + null_func,//BIND_FUNC(sys_sm_get_platform_info) //387 (0x183) DBG + null_func,//BIND_FUNC(sys_sm_ring_buzzer) //388 (0x184) ROOT + null_func,//BIND_FUNC(sys_sm_set_fan_policy) //389 (0x185) PM + null_func,//BIND_FUNC(sys_sm_request_error_log) //390 (0x186) ROOT + null_func,//BIND_FUNC(sys_sm_request_be_count) //391 (0x187) ROOT + null_func,//BIND_FUNC(sys_sm_ring_buzzer) //392 (0x188) ROOT + null_func,//BIND_FUNC(sys_sm_get_hw_config) //393 (0x189) ROOT + null_func,//BIND_FUNC(sys_sm_request_scversion) //394 (0x18A) ROOT + null_func,//BIND_FUNC(sys_sm_request_system_event_log) //395 (0x18B) PM + null_func,//BIND_FUNC(sys_sm_set_rtc_alarm) //396 (0x18C) ROOT + null_func,//BIND_FUNC(sys_sm_get_rtc_alarm) //397 (0x18D) ROOT + null_func,//BIND_FUNC(sys_console_write) //398 (0x18E) ROOT null_func, //399 (0x18F) UNS - null_func,//bind_func(sys_sm_...) //400 (0x190) PM - null_func,//bind_func(sys_sm_...) //401 (0x191) ROOT - bind_func(sys_tty_read), //402 (0x192) - bind_func(sys_tty_write), //403 (0x193) - null_func,//bind_func(sys_...) //404 (0x194) ROOT - null_func,//bind_func(sys_...) //405 (0x195) PM - null_func,//bind_func(sys_...) //406 (0x196) PM - null_func,//bind_func(sys_...) //407 (0x197) PM - null_func,//bind_func(sys_sm_get_tzpb) //408 (0x198) PM - null_func,//bind_func(sys_sm_get_fan_policy) //409 (0x199) PM - null_func,//bind_func(sys_game_board_storage_read) //410 (0x19A) - null_func,//bind_func(sys_game_board_storage_write) //411 (0x19B) - null_func,//bind_func(sys_game_get_rtc_status) //412 (0x19C) - null_func,//bind_func(sys_...) //413 (0x19D) ROOT - null_func,//bind_func(sys_...) //414 (0x19E) ROOT - null_func,//bind_func(sys_...) //415 (0x19F) ROOT + null_func,//BIND_FUNC(sys_sm_...) //400 (0x190) PM + null_func,//BIND_FUNC(sys_sm_...) //401 (0x191) ROOT + BIND_FUNC(sys_tty_read), //402 (0x192) + BIND_FUNC(sys_tty_write), //403 (0x193) + null_func,//BIND_FUNC(sys_...) //404 (0x194) ROOT + null_func,//BIND_FUNC(sys_...) //405 (0x195) PM + null_func,//BIND_FUNC(sys_...) //406 (0x196) PM + null_func,//BIND_FUNC(sys_...) //407 (0x197) PM + null_func,//BIND_FUNC(sys_sm_get_tzpb) //408 (0x198) PM + null_func,//BIND_FUNC(sys_sm_get_fan_policy) //409 (0x199) PM + null_func,//BIND_FUNC(sys_game_board_storage_read) //410 (0x19A) + null_func,//BIND_FUNC(sys_game_board_storage_write) //411 (0x19B) + null_func,//BIND_FUNC(sys_game_get_rtc_status) //412 (0x19C) + null_func,//BIND_FUNC(sys_...) //413 (0x19D) ROOT + null_func,//BIND_FUNC(sys_...) //414 (0x19E) ROOT + null_func,//BIND_FUNC(sys_...) //415 (0x19F) ROOT null_func, null_func, null_func, null_func, //419 UNS null_func, null_func, null_func, null_func, null_func, //424 UNS @@ -412,275 +412,275 @@ const ppu_func_caller g_sc_table[1024] = null_func, null_func, null_func, null_func, null_func, //444 UNS null_func, null_func, null_func, null_func, null_func, //449 UNS - null_func,//bind_func(sys_overlay_load_module) //450 (0x1C2) - null_func,//bind_func(sys_overlay_unload_module) //451 (0x1C3) - null_func,//bind_func(sys_overlay_get_module_list) //452 (0x1C4) - null_func,//bind_func(sys_overlay_get_module_info) //453 (0x1C5) - null_func,//bind_func(sys_overlay_load_module_by_fd) //454 (0x1C6) - null_func,//bind_func(sys_overlay_get_module_info2) //455 (0x1C7) - null_func,//bind_func(sys_overlay_get_sdk_version) //456 (0x1C8) - null_func,//bind_func(sys_overlay_get_module_dbg_info) //457 (0x1C9) - null_func,//bind_func(sys_overlay_get_module_dbg_info) //458 (0x1CA) + null_func,//BIND_FUNC(sys_overlay_load_module) //450 (0x1C2) + null_func,//BIND_FUNC(sys_overlay_unload_module) //451 (0x1C3) + null_func,//BIND_FUNC(sys_overlay_get_module_list) //452 (0x1C4) + null_func,//BIND_FUNC(sys_overlay_get_module_info) //453 (0x1C5) + null_func,//BIND_FUNC(sys_overlay_load_module_by_fd) //454 (0x1C6) + null_func,//BIND_FUNC(sys_overlay_get_module_info2) //455 (0x1C7) + null_func,//BIND_FUNC(sys_overlay_get_sdk_version) //456 (0x1C8) + null_func,//BIND_FUNC(sys_overlay_get_module_dbg_info) //457 (0x1C9) + null_func,//BIND_FUNC(sys_overlay_get_module_dbg_info) //458 (0x1CA) null_func, //459 (0x1CB) UNS - null_func,//bind_func(sys_prx_dbg_get_module_id_list) //460 (0x1CC) ROOT - null_func,//bind_func(sys_prx_get_module_id_by_address) //461 (0x1CD) + null_func,//BIND_FUNC(sys_prx_dbg_get_module_id_list) //460 (0x1CC) ROOT + null_func,//BIND_FUNC(sys_prx_get_module_id_by_address) //461 (0x1CD) null_func, //462 (0x1CE) UNS - null_func,//bind_func(sys_prx_load_module_by_fd) //463 (0x1CF) - null_func,//bind_func(sys_prx_load_module_on_memcontainer_by_fd) //464 (0x1D0) - bind_func(sys_prx_load_module_list), //465 (0x1D1) - null_func,//bind_func(sys_prx_load_module_list_on_memcontainer) //466 (0x1D2) - null_func,//bind_func(sys_prx_get_ppu_guid) //467 (0x1D3) - null_func,//bind_func(sys_...) //468 (0x1D4) ROOT + null_func,//BIND_FUNC(sys_prx_load_module_by_fd) //463 (0x1CF) + null_func,//BIND_FUNC(sys_prx_load_module_on_memcontainer_by_fd) //464 (0x1D0) + BIND_FUNC(sys_prx_load_module_list), //465 (0x1D1) + null_func,//BIND_FUNC(sys_prx_load_module_list_on_memcontainer) //466 (0x1D2) + null_func,//BIND_FUNC(sys_prx_get_ppu_guid) //467 (0x1D3) + null_func,//BIND_FUNC(sys_...) //468 (0x1D4) ROOT null_func, //469 (0x1D5) UNS - null_func,//bind_func(sys_...) //470 (0x1D6) ROOT - null_func,//bind_func(sys_...) //471 (0x1D7) ROOT - null_func,//bind_func(sys_...) //472 (0x1D8) ROOT - null_func,//bind_func(sys_...) //473 (0x1D9) - null_func,//bind_func(sys_...) //474 (0x1DA) - null_func,//bind_func(sys_...) //475 (0x1DB) ROOT - null_func,//bind_func(sys_...) //476 (0x1DC) ROOT + null_func,//BIND_FUNC(sys_...) //470 (0x1D6) ROOT + null_func,//BIND_FUNC(sys_...) //471 (0x1D7) ROOT + null_func,//BIND_FUNC(sys_...) //472 (0x1D8) ROOT + null_func,//BIND_FUNC(sys_...) //473 (0x1D9) + null_func,//BIND_FUNC(sys_...) //474 (0x1DA) + null_func,//BIND_FUNC(sys_...) //475 (0x1DB) ROOT + null_func,//BIND_FUNC(sys_...) //476 (0x1DC) ROOT null_func, null_func, null_func, //477-479 UNS - bind_func(sys_prx_load_module), //480 (0x1E0) - bind_func(sys_prx_start_module), //481 (0x1E1) - bind_func(sys_prx_stop_module), //482 (0x1E2) - bind_func(sys_prx_unload_module), //483 (0x1E3) - bind_func(sys_prx_register_module), //484 (0x1E4) - bind_func(sys_prx_query_module), //485 (0x1E5) - bind_func(sys_prx_register_library), //486 (0x1E6) - bind_func(sys_prx_unregister_library), //487 (0x1E7) - bind_func(sys_prx_link_library), //488 (0x1E8) - bind_func(sys_prx_unlink_library), //489 (0x1E9) - bind_func(sys_prx_query_library), //490 (0x1EA) + BIND_FUNC(sys_prx_load_module), //480 (0x1E0) + BIND_FUNC(sys_prx_start_module), //481 (0x1E1) + BIND_FUNC(sys_prx_stop_module), //482 (0x1E2) + BIND_FUNC(sys_prx_unload_module), //483 (0x1E3) + BIND_FUNC(sys_prx_register_module), //484 (0x1E4) + BIND_FUNC(sys_prx_query_module), //485 (0x1E5) + BIND_FUNC(sys_prx_register_library), //486 (0x1E6) + BIND_FUNC(sys_prx_unregister_library), //487 (0x1E7) + BIND_FUNC(sys_prx_link_library), //488 (0x1E8) + BIND_FUNC(sys_prx_unlink_library), //489 (0x1E9) + BIND_FUNC(sys_prx_query_library), //490 (0x1EA) null_func, //491 (0x1EB) UNS - null_func,//bind_func(sys_...) //492 (0x1EC) DBG - null_func,//bind_func(sys_prx_dbg_get_module_info) //493 (0x1ED) DBG - null_func,//bind_func(sys_prx_get_module_list), //494 (0x1EE) - null_func,//bind_func(sys_prx_get_module_info), //495 (0x1EF) - null_func,//bind_func(sys_prx_get_module_id_by_name), //496 (0x1F0) - null_func,//bind_func(sys_prx_load_module_on_memcontainer),//497 (0x1F1) - bind_func(sys_prx_start), //498 (0x1F2) - bind_func(sys_prx_stop), //499 (0x1F3) - null_func,//bind_func(sys_hid_manager_open) //500 (0x1F4) - null_func,//bind_func(sys_hid_manager_close) //501 (0x1F5) - null_func,//bind_func(sys_hid_manager_read) //502 (0x1F6) ROOT - null_func,//bind_func(sys_hid_manager_ioctl) //503 (0x1F7) - null_func,//bind_func(sys_hid_manager_map_logical_id_to_port_id) //504 (0x1F8) ROOT - null_func,//bind_func(sys_hid_manager_unmap_logical_id_to_port_id) //505 (0x1F9) ROOT - null_func,//bind_func(sys_hid_manager_add_hot_key_observer) //506 (0x1FA) ROOT - null_func,//bind_func(sys_hid_manager_remove_hot_key_observer) //507 (0x1FB) ROOT - null_func,//bind_func(sys_hid_manager_grab_focus) //508 (0x1FC) ROOT - null_func,//bind_func(sys_hid_manager_release_focus) //509 (0x1FD) ROOT - null_func,//bind_func(sys_hid_manager_...) //510 (0x1FE) - null_func,//bind_func(sys_hid_manager_set_...) //511 (0x1FF) ROOT - null_func,//bind_func(sys_hid_manager_...) //512 (0x200) ROOT - null_func,//bind_func(sys_hid_manager_...) //513 (0x201) - null_func,//bind_func(sys_hid_manager_...) //514 (0x202) + null_func,//BIND_FUNC(sys_...) //492 (0x1EC) DBG + null_func,//BIND_FUNC(sys_prx_dbg_get_module_info) //493 (0x1ED) DBG + null_func,//BIND_FUNC(sys_prx_get_module_list), //494 (0x1EE) + null_func,//BIND_FUNC(sys_prx_get_module_info), //495 (0x1EF) + null_func,//BIND_FUNC(sys_prx_get_module_id_by_name), //496 (0x1F0) + null_func,//BIND_FUNC(sys_prx_load_module_on_memcontainer),//497 (0x1F1) + BIND_FUNC(sys_prx_start), //498 (0x1F2) + BIND_FUNC(sys_prx_stop), //499 (0x1F3) + null_func,//BIND_FUNC(sys_hid_manager_open) //500 (0x1F4) + null_func,//BIND_FUNC(sys_hid_manager_close) //501 (0x1F5) + null_func,//BIND_FUNC(sys_hid_manager_read) //502 (0x1F6) ROOT + null_func,//BIND_FUNC(sys_hid_manager_ioctl) //503 (0x1F7) + null_func,//BIND_FUNC(sys_hid_manager_map_logical_id_to_port_id) //504 (0x1F8) ROOT + null_func,//BIND_FUNC(sys_hid_manager_unmap_logical_id_to_port_id) //505 (0x1F9) ROOT + null_func,//BIND_FUNC(sys_hid_manager_add_hot_key_observer) //506 (0x1FA) ROOT + null_func,//BIND_FUNC(sys_hid_manager_remove_hot_key_observer) //507 (0x1FB) ROOT + null_func,//BIND_FUNC(sys_hid_manager_grab_focus) //508 (0x1FC) ROOT + null_func,//BIND_FUNC(sys_hid_manager_release_focus) //509 (0x1FD) ROOT + null_func,//BIND_FUNC(sys_hid_manager_...) //510 (0x1FE) + null_func,//BIND_FUNC(sys_hid_manager_set_...) //511 (0x1FF) ROOT + null_func,//BIND_FUNC(sys_hid_manager_...) //512 (0x200) ROOT + null_func,//BIND_FUNC(sys_hid_manager_...) //513 (0x201) + null_func,//BIND_FUNC(sys_hid_manager_...) //514 (0x202) null_func, //515 (0x203) UNS - null_func,//bind_func(sys_config_open) //516 (0x204) - null_func,//bind_func(sys_config_close) //517 (0x205) - null_func,//bind_func(sys_config_get_service_event) //518 (0x206) - null_func,//bind_func(sys_config_add_service_listener) //519 (0x207) - null_func,//bind_func(sys_config_remove_service_listener) //520 (0x208) - null_func,//bind_func(sys_config_register_service) //521 (0x209) - null_func,//bind_func(sys_config_unregister_service) //522 (0x20A) - null_func,//bind_func(sys_config_io_event) //523 (0x20B) - null_func,//bind_func(sys_config_...) //524 (0x20C) - null_func,//bind_func(sys_config_...) //525 (0x20D) + null_func,//BIND_FUNC(sys_config_open) //516 (0x204) + null_func,//BIND_FUNC(sys_config_close) //517 (0x205) + null_func,//BIND_FUNC(sys_config_get_service_event) //518 (0x206) + null_func,//BIND_FUNC(sys_config_add_service_listener) //519 (0x207) + null_func,//BIND_FUNC(sys_config_remove_service_listener) //520 (0x208) + null_func,//BIND_FUNC(sys_config_register_service) //521 (0x209) + null_func,//BIND_FUNC(sys_config_unregister_service) //522 (0x20A) + null_func,//BIND_FUNC(sys_config_io_event) //523 (0x20B) + null_func,//BIND_FUNC(sys_config_...) //524 (0x20C) + null_func,//BIND_FUNC(sys_config_...) //525 (0x20D) null_func, //526 (0x20E) UNS null_func, //527 (0x20F) UNS null_func, //528 (0x210) UNS null_func, //529 (0x211) UNS - null_func,//bind_func(sys_usbd_initialize) //530 (0x212) - null_func,//bind_func(sys_usbd_finalize) //531 (0x213) - null_func,//bind_func(sys_usbd_get_device_list) //532 (0x214) - null_func,//bind_func(sys_usbd_get_descriptor_size) //533 (0x215) - null_func,//bind_func(sys_usbd_get_descriptor) //534 (0x216) - null_func,//bind_func(sys_usbd_register_ldd) //535 (0x217) - null_func,//bind_func(sys_usbd_unregister_ldd) //536 (0x218) - null_func,//bind_func(sys_usbd_open_pipe) //537 (0x219) - null_func,//bind_func(sys_usbd_open_default_pipe) //538 (0x21A) - null_func,//bind_func(sys_usbd_close_pipe) //539 (0x21B) - null_func,//bind_func(sys_usbd_receive_event) //540 (0x21C) - null_func,//bind_func(sys_usbd_detect_event) //541 (0x21D) - null_func,//bind_func(sys_usbd_attach) //542 (0x21E) - null_func,//bind_func(sys_usbd_transfer_data) //543 (0x21F) - null_func,//bind_func(sys_usbd_isochronous_transfer_data) //544 (0x220) - null_func,//bind_func(sys_usbd_get_transfer_status) //545 (0x221) - null_func,//bind_func(sys_usbd_get_isochronous_transfer_status) //546 (0x222) - null_func,//bind_func(sys_usbd_get_device_location) //547 (0x223) - null_func,//bind_func(sys_usbd_send_event) //548 (0x224) - null_func,//bind_func(sys_ubsd_...) //549 (0x225) - null_func,//bind_func(sys_usbd_allocate_memory) //550 (0x226) - null_func,//bind_func(sys_usbd_free_memory) //551 (0x227) - null_func,//bind_func(sys_ubsd_...) //552 (0x228) - null_func,//bind_func(sys_ubsd_...) //553 (0x229) - null_func,//bind_func(sys_ubsd_...) //554 (0x22A) - null_func,//bind_func(sys_ubsd_...) //555 (0x22B) - null_func,//bind_func(sys_usbd_get_device_speed) //556 (0x22C) - null_func,//bind_func(sys_ubsd_...) //557 (0x22D) - null_func,//bind_func(sys_ubsd_...) //558 (0x22E) - null_func,//bind_func(sys_usbd_register_extra_ldd) //559 (0x22F) - null_func,//bind_func(sys_...) //560 (0x230) ROOT - null_func,//bind_func(sys_...) //561 (0x231) ROOT - null_func,//bind_func(sys_...) //562 (0x232) ROOT - null_func,//bind_func(sys_...) //563 (0x233) - null_func,//bind_func(sys_...) //564 (0x234) - null_func,//bind_func(sys_...) //565 (0x235) - null_func,//bind_func(sys_...) //566 (0x236) - null_func,//bind_func(sys_...) //567 (0x237) - null_func,//bind_func(sys_...) //568 (0x238) - null_func,//bind_func(sys_...) //569 (0x239) - null_func,//bind_func(sys_...) //570 (0x23A) - null_func,//bind_func(sys_pad_ldd_unregister_controller) //571 (0x23B) - null_func,//bind_func(sys_pad_ldd_data_insert) //572 (0x23C) - null_func,//bind_func(sys_pad_dbg_ldd_set_data_insert_mode) //573 (0x23D) - null_func,//bind_func(sys_pad_ldd_register_controller) //574 (0x23E) - null_func,//bind_func(sys_pad_ldd_get_port_no) //575 (0x23F) + null_func,//BIND_FUNC(sys_usbd_initialize) //530 (0x212) + null_func,//BIND_FUNC(sys_usbd_finalize) //531 (0x213) + null_func,//BIND_FUNC(sys_usbd_get_device_list) //532 (0x214) + null_func,//BIND_FUNC(sys_usbd_get_descriptor_size) //533 (0x215) + null_func,//BIND_FUNC(sys_usbd_get_descriptor) //534 (0x216) + null_func,//BIND_FUNC(sys_usbd_register_ldd) //535 (0x217) + null_func,//BIND_FUNC(sys_usbd_unregister_ldd) //536 (0x218) + null_func,//BIND_FUNC(sys_usbd_open_pipe) //537 (0x219) + null_func,//BIND_FUNC(sys_usbd_open_default_pipe) //538 (0x21A) + null_func,//BIND_FUNC(sys_usbd_close_pipe) //539 (0x21B) + null_func,//BIND_FUNC(sys_usbd_receive_event) //540 (0x21C) + null_func,//BIND_FUNC(sys_usbd_detect_event) //541 (0x21D) + null_func,//BIND_FUNC(sys_usbd_attach) //542 (0x21E) + null_func,//BIND_FUNC(sys_usbd_transfer_data) //543 (0x21F) + null_func,//BIND_FUNC(sys_usbd_isochronous_transfer_data) //544 (0x220) + null_func,//BIND_FUNC(sys_usbd_get_transfer_status) //545 (0x221) + null_func,//BIND_FUNC(sys_usbd_get_isochronous_transfer_status) //546 (0x222) + null_func,//BIND_FUNC(sys_usbd_get_device_location) //547 (0x223) + null_func,//BIND_FUNC(sys_usbd_send_event) //548 (0x224) + null_func,//BIND_FUNC(sys_ubsd_...) //549 (0x225) + null_func,//BIND_FUNC(sys_usbd_allocate_memory) //550 (0x226) + null_func,//BIND_FUNC(sys_usbd_free_memory) //551 (0x227) + null_func,//BIND_FUNC(sys_ubsd_...) //552 (0x228) + null_func,//BIND_FUNC(sys_ubsd_...) //553 (0x229) + null_func,//BIND_FUNC(sys_ubsd_...) //554 (0x22A) + null_func,//BIND_FUNC(sys_ubsd_...) //555 (0x22B) + null_func,//BIND_FUNC(sys_usbd_get_device_speed) //556 (0x22C) + null_func,//BIND_FUNC(sys_ubsd_...) //557 (0x22D) + null_func,//BIND_FUNC(sys_ubsd_...) //558 (0x22E) + null_func,//BIND_FUNC(sys_usbd_register_extra_ldd) //559 (0x22F) + null_func,//BIND_FUNC(sys_...) //560 (0x230) ROOT + null_func,//BIND_FUNC(sys_...) //561 (0x231) ROOT + null_func,//BIND_FUNC(sys_...) //562 (0x232) ROOT + null_func,//BIND_FUNC(sys_...) //563 (0x233) + null_func,//BIND_FUNC(sys_...) //564 (0x234) + null_func,//BIND_FUNC(sys_...) //565 (0x235) + null_func,//BIND_FUNC(sys_...) //566 (0x236) + null_func,//BIND_FUNC(sys_...) //567 (0x237) + null_func,//BIND_FUNC(sys_...) //568 (0x238) + null_func,//BIND_FUNC(sys_...) //569 (0x239) + null_func,//BIND_FUNC(sys_...) //570 (0x23A) + null_func,//BIND_FUNC(sys_pad_ldd_unregister_controller) //571 (0x23B) + null_func,//BIND_FUNC(sys_pad_ldd_data_insert) //572 (0x23C) + null_func,//BIND_FUNC(sys_pad_dbg_ldd_set_data_insert_mode) //573 (0x23D) + null_func,//BIND_FUNC(sys_pad_ldd_register_controller) //574 (0x23E) + null_func,//BIND_FUNC(sys_pad_ldd_get_port_no) //575 (0x23F) null_func, //576 (0x240) UNS - null_func,//bind_func(sys_pad_manager_...) //577 (0x241) ROOT PM - null_func,//bind_func(sys_bluetooth_...) //578 (0x242) - null_func,//bind_func(sys_bluetooth_...) //579 (0x243) - null_func,//bind_func(sys_bluetooth_...) //580 (0x244) ROOT - null_func,//bind_func(sys_bluetooth_...) //581 (0x245) ROOT - null_func,//bind_func(sys_bluetooth_...) //582 (0x246) ROOT - null_func,//bind_func(sys_bluetooth_...) //583 (0x247) ROOT - null_func,//bind_func(sys_bluetooth_...) //584 (0x248) ROOT - null_func,//bind_func(sys_bluetooth_...) //585 (0x249) - null_func,//bind_func(sys_bluetooth_...) //586 (0x24A) - null_func,//bind_func(sys_bluetooth_...) //587 (0x24B) ROOT - null_func,//bind_func(sys_bluetooth_...) //588 (0x24C) - null_func,//bind_func(sys_bluetooth_...) //589 (0x24D) - null_func,//bind_func(sys_bluetooth_...) //590 (0x24E) ROOT - null_func,//bind_func(sys_bluetooth_...) //591 (0x24F) - null_func,//bind_func(sys_bluetooth_...) //592 (0x250) - null_func,//bind_func(sys_bluetooth_...) //593 (0x251) ROOT - null_func,//bind_func(sys_bluetooth_...) //594 (0x252) - null_func,//bind_func(sys_bluetooth_...) //595 (0x253) - null_func,//bind_func(sys_bluetooth_...) //596 (0x254) - null_func,//bind_func(sys_bluetooth_...) //597 (0x255) - null_func,//bind_func(sys_bluetooth_...) //598 (0x256) ROOT - null_func,//bind_func(sys_bluetooth_...) //599 (0x257) ROOT - null_func,//bind_func(sys_storage_open) //600 (0x258) ROOT - null_func,//bind_func(sys_storage_close) //601 (0x259) - null_func,//bind_func(sys_storage_read) //602 (0x25A) - null_func,//bind_func(sys_storage_write) //603 (0x25B) - null_func,//bind_func(sys_storage_send_device_command) //604 (0x25C) - null_func,//bind_func(sys_storage_async_configure) //605 (0x25D) - null_func,//bind_func(sys_storage_async_read) //606 (0x25E) - null_func,//bind_func(sys_storage_async_write) //607 (0x25F) - null_func,//bind_func(sys_storage_async_cancel) //608 (0x260) - null_func,//bind_func(sys_storage_get_device_info) //609 (0x261) ROOT - null_func,//bind_func(sys_storage_get_device_config) //610 (0x262) ROOT - null_func,//bind_func(sys_storage_report_devices) //611 (0x263) ROOT - null_func,//bind_func(sys_storage_configure_medium_event) //612 (0x264) ROOT - null_func,//bind_func(sys_storage_set_medium_polling_interval) //613 (0x265) - null_func,//bind_func(sys_storage_create_region) //614 (0x266) - null_func,//bind_func(sys_storage_delete_region) //615 (0x267) - null_func,//bind_func(sys_storage_execute_device_command) //616 (0x268) - null_func,//bind_func(sys_storage_check_region_acl) //617 (0x269) - null_func,//bind_func(sys_storage_set_region_acl) //618 (0x26A) - null_func,//bind_func(sys_storage_async_send_device_command) //619 (0x26B) - null_func,//bind_func(sys_...) //620 (0x26C) ROOT - null_func,//bind_func(sys_gamepad_ycon_if) //621 (0x26D) - null_func,//bind_func(sys_storage_get_region_offset) //622 (0x26E) - null_func,//bind_func(sys_storage_set_emulated_speed) //623 (0x26F) - null_func,//bind_func(sys_io_buffer_create) //624 (0x270) - null_func,//bind_func(sys_io_buffer_destroy) //625 (0x271) - null_func,//bind_func(sys_io_buffer_allocate) //626 (0x272) - null_func,//bind_func(sys_io_buffer_free) //627 (0x273) + null_func,//BIND_FUNC(sys_pad_manager_...) //577 (0x241) ROOT PM + null_func,//BIND_FUNC(sys_bluetooth_...) //578 (0x242) + null_func,//BIND_FUNC(sys_bluetooth_...) //579 (0x243) + null_func,//BIND_FUNC(sys_bluetooth_...) //580 (0x244) ROOT + null_func,//BIND_FUNC(sys_bluetooth_...) //581 (0x245) ROOT + null_func,//BIND_FUNC(sys_bluetooth_...) //582 (0x246) ROOT + null_func,//BIND_FUNC(sys_bluetooth_...) //583 (0x247) ROOT + null_func,//BIND_FUNC(sys_bluetooth_...) //584 (0x248) ROOT + null_func,//BIND_FUNC(sys_bluetooth_...) //585 (0x249) + null_func,//BIND_FUNC(sys_bluetooth_...) //586 (0x24A) + null_func,//BIND_FUNC(sys_bluetooth_...) //587 (0x24B) ROOT + null_func,//BIND_FUNC(sys_bluetooth_...) //588 (0x24C) + null_func,//BIND_FUNC(sys_bluetooth_...) //589 (0x24D) + null_func,//BIND_FUNC(sys_bluetooth_...) //590 (0x24E) ROOT + null_func,//BIND_FUNC(sys_bluetooth_...) //591 (0x24F) + null_func,//BIND_FUNC(sys_bluetooth_...) //592 (0x250) + null_func,//BIND_FUNC(sys_bluetooth_...) //593 (0x251) ROOT + null_func,//BIND_FUNC(sys_bluetooth_...) //594 (0x252) + null_func,//BIND_FUNC(sys_bluetooth_...) //595 (0x253) + null_func,//BIND_FUNC(sys_bluetooth_...) //596 (0x254) + null_func,//BIND_FUNC(sys_bluetooth_...) //597 (0x255) + null_func,//BIND_FUNC(sys_bluetooth_...) //598 (0x256) ROOT + null_func,//BIND_FUNC(sys_bluetooth_...) //599 (0x257) ROOT + null_func,//BIND_FUNC(sys_storage_open) //600 (0x258) ROOT + null_func,//BIND_FUNC(sys_storage_close) //601 (0x259) + null_func,//BIND_FUNC(sys_storage_read) //602 (0x25A) + null_func,//BIND_FUNC(sys_storage_write) //603 (0x25B) + null_func,//BIND_FUNC(sys_storage_send_device_command) //604 (0x25C) + null_func,//BIND_FUNC(sys_storage_async_configure) //605 (0x25D) + null_func,//BIND_FUNC(sys_storage_async_read) //606 (0x25E) + null_func,//BIND_FUNC(sys_storage_async_write) //607 (0x25F) + null_func,//BIND_FUNC(sys_storage_async_cancel) //608 (0x260) + null_func,//BIND_FUNC(sys_storage_get_device_info) //609 (0x261) ROOT + null_func,//BIND_FUNC(sys_storage_get_device_config) //610 (0x262) ROOT + null_func,//BIND_FUNC(sys_storage_report_devices) //611 (0x263) ROOT + null_func,//BIND_FUNC(sys_storage_configure_medium_event) //612 (0x264) ROOT + null_func,//BIND_FUNC(sys_storage_set_medium_polling_interval) //613 (0x265) + null_func,//BIND_FUNC(sys_storage_create_region) //614 (0x266) + null_func,//BIND_FUNC(sys_storage_delete_region) //615 (0x267) + null_func,//BIND_FUNC(sys_storage_execute_device_command) //616 (0x268) + null_func,//BIND_FUNC(sys_storage_check_region_acl) //617 (0x269) + null_func,//BIND_FUNC(sys_storage_set_region_acl) //618 (0x26A) + null_func,//BIND_FUNC(sys_storage_async_send_device_command) //619 (0x26B) + null_func,//BIND_FUNC(sys_...) //620 (0x26C) ROOT + null_func,//BIND_FUNC(sys_gamepad_ycon_if) //621 (0x26D) + null_func,//BIND_FUNC(sys_storage_get_region_offset) //622 (0x26E) + null_func,//BIND_FUNC(sys_storage_set_emulated_speed) //623 (0x26F) + null_func,//BIND_FUNC(sys_io_buffer_create) //624 (0x270) + null_func,//BIND_FUNC(sys_io_buffer_destroy) //625 (0x271) + null_func,//BIND_FUNC(sys_io_buffer_allocate) //626 (0x272) + null_func,//BIND_FUNC(sys_io_buffer_free) //627 (0x273) null_func, //628 (0x274) UNS null_func, //629 (0x275) UNS - null_func,//bind_func(sys_gpio_set) //630 (0x276) - null_func,//bind_func(sys_gpio_get) //631 (0x277) + null_func,//BIND_FUNC(sys_gpio_set) //630 (0x276) + null_func,//BIND_FUNC(sys_gpio_get) //631 (0x277) null_func, //632 (0x278) UNS - null_func,//bind_func(sys_fsw_connect_event) //633 (0x279) - null_func,//bind_func(sys_fsw_disconnect_event) //634 (0x27A) - null_func,//bind_func(sys_btsetting_if) //635 (0x27B) - null_func,//bind_func(sys_...) //636 (0x27C) - null_func,//bind_func(sys_...) //637 (0x27D) - null_func,//bind_func(sys_...) //638 (0x27E) + null_func,//BIND_FUNC(sys_fsw_connect_event) //633 (0x279) + null_func,//BIND_FUNC(sys_fsw_disconnect_event) //634 (0x27A) + null_func,//BIND_FUNC(sys_btsetting_if) //635 (0x27B) + null_func,//BIND_FUNC(sys_...) //636 (0x27C) + null_func,//BIND_FUNC(sys_...) //637 (0x27D) + null_func,//BIND_FUNC(sys_...) //638 (0x27E) null_func, //639 DEPRECATED null_func, null_func, null_func, null_func, null_func, //644 DEPRECATED null_func, null_func, null_func, null_func, null_func, //649 DEPRECATED - null_func,//bind_func(sys_rsxaudio_initialize) //650 (0x28A) - null_func,//bind_func(sys_rsxaudio_finalize) //651 (0x28B) - null_func,//bind_func(sys_rsxaudio_import_shared_memory) //652 (0x28C) - null_func,//bind_func(sys_rsxaudio_unimport_shared_memory) //653 (0x28D) - null_func,//bind_func(sys_rsxaudio_create_connection) //654 (0x28E) - null_func,//bind_func(sys_rsxaudio_close_connection) //655 (0x28F) - null_func,//bind_func(sys_rsxaudio_prepare_process) //656 (0x290) - null_func,//bind_func(sys_rsxaudio_start_process) //657 (0x291) - null_func,//bind_func(sys_rsxaudio_) //658 (0x292) - null_func,//bind_func(sys_rsxaudio_) //659 (0x293) + null_func,//BIND_FUNC(sys_rsxaudio_initialize) //650 (0x28A) + null_func,//BIND_FUNC(sys_rsxaudio_finalize) //651 (0x28B) + null_func,//BIND_FUNC(sys_rsxaudio_import_shared_memory) //652 (0x28C) + null_func,//BIND_FUNC(sys_rsxaudio_unimport_shared_memory) //653 (0x28D) + null_func,//BIND_FUNC(sys_rsxaudio_create_connection) //654 (0x28E) + null_func,//BIND_FUNC(sys_rsxaudio_close_connection) //655 (0x28F) + null_func,//BIND_FUNC(sys_rsxaudio_prepare_process) //656 (0x290) + null_func,//BIND_FUNC(sys_rsxaudio_start_process) //657 (0x291) + null_func,//BIND_FUNC(sys_rsxaudio_) //658 (0x292) + null_func,//BIND_FUNC(sys_rsxaudio_) //659 (0x293) null_func, null_func, null_func, null_func, null_func, //664 UNS null_func, //665 UNS - bind_func(sys_rsx_device_open), //666 (0x29A) - bind_func(sys_rsx_device_close), //667 (0x29B) - bind_func(sys_rsx_memory_allocate), //668 (0x29C) - bind_func(sys_rsx_memory_free), //669 (0x29D) - bind_func(sys_rsx_context_allocate), //670 (0x29E) - bind_func(sys_rsx_context_free), //671 (0x29F) - bind_func(sys_rsx_context_iomap), //672 (0x2A0) - bind_func(sys_rsx_context_iounmap), //673 (0x2A1) - bind_func(sys_rsx_context_attribute), //674 (0x2A2) - bind_func(sys_rsx_device_map), //675 (0x2A3) - bind_func(sys_rsx_device_unmap), //676 (0x2A4) - bind_func(sys_rsx_attribute), //677 (0x2A5) - null_func,//bind_func(sys_...) //678 (0x2A6) - null_func,//bind_func(sys_...) //679 (0x2A7) ROOT - null_func,//bind_func(sys_...) //680 (0x2A8) ROOT - null_func,//bind_func(sys_...) //681 (0x2A9) ROOT - null_func,//bind_func(sys_...) //682 (0x2AA) ROOT - null_func,//bind_func(sys_...) //683 (0x2AB) ROOT - null_func,//bind_func(sys_...) //684 (0x2AC) ROOT - null_func,//bind_func(sys_...) //685 (0x2AD) ROOT - null_func,//bind_func(sys_...) //686 (0x2AE) ROOT - null_func,//bind_func(sys_...) //687 (0x2AF) ROOT - null_func,//bind_func(sys_...) //688 (0x2B0) ROOT - null_func,//bind_func(sys_...) //689 (0x2B1) ROOT - null_func,//bind_func(sys_...) //690 (0x2B2) ROOT - null_func,//bind_func(sys_...) //691 (0x2B3) ROOT - null_func,//bind_func(sys_...) //692 (0x2B4) ROOT - null_func,//bind_func(sys_...) //693 (0x2B5) ROOT - null_func,//bind_func(sys_...) //694 (0x2B6) DEPRECATED - null_func,//bind_func(sys_...) //695 (0x2B7) DEPRECATED - null_func,//bind_func(sys_...) //696 (0x2B8) ROOT - null_func,//bind_func(sys_...) //697 (0x2B9) UNS - null_func,//bind_func(sys_...) //698 (0x2BA) UNS - null_func,//bind_func(sys_bdemu_send_command) //699 (0x2BB) - null_func,//bind_func(sys_net_bnet_accept) //700 (0x2BC) - null_func,//bind_func(sys_net_bnet_bind) //701 (0x2BD) - null_func,//bind_func(sys_net_bnet_connect) //702 (0x2BE) - null_func,//bind_func(sys_net_bnet_getpeername) //703 (0x2BF) - null_func,//bind_func(sys_net_bnet_getsockname) //704 (0x2C0) - null_func,//bind_func(sys_net_bnet_getsockopt) //705 (0x2C1) - null_func,//bind_func(sys_net_bnet_listen) //706 (0x2C2) - null_func,//bind_func(sys_net_bnet_recvfrom) //707 (0x2C3) - null_func,//bind_func(sys_net_bnet_recvmsg) //708 (0x2C4) - null_func,//bind_func(sys_net_bnet_sendmsg) //709 (0x2C5) - null_func,//bind_func(sys_net_bnet_sendto) //710 (0x2C6) - null_func,//bind_func(sys_net_bnet_setsockop) //711 (0x2C7) - null_func,//bind_func(sys_net_bnet_shutdown) //712 (0x2C8) - null_func,//bind_func(sys_net_bnet_socket) //713 (0x2C9) - null_func,//bind_func(sys_net_bnet_close) //714 (0x2CA) - null_func,//bind_func(sys_net_bnet_poll) //715 (0x2CB) - null_func,//bind_func(sys_net_bnet_select) //716 (0x2CC) - null_func,//bind_func(sys_net_open_dump) //717 (0x2CD) - null_func,//bind_func(sys_net_read_dump) //718 (0x2CE) - null_func,//bind_func(sys_net_close_dump) //719 (0x2CF) - null_func,//bind_func(sys_net_write_dump) //720 (0x2D0) - null_func,//bind_func(sys_net_abort) //721 (0x2D1) - null_func,//bind_func(sys_net_infoctl) //722 (0x2D2) - null_func,//bind_func(sys_net_control) //723 (0x2D3) - null_func,//bind_func(sys_net_bnet_ioctl) //724 (0x2D4) - null_func,//bind_func(sys_net_bnet_sysctl) //725 (0x2D5) - null_func,//bind_func(sys_net_eurus_post_command) //726 (0x2D6) + BIND_FUNC(sys_rsx_device_open), //666 (0x29A) + BIND_FUNC(sys_rsx_device_close), //667 (0x29B) + BIND_FUNC(sys_rsx_memory_allocate), //668 (0x29C) + BIND_FUNC(sys_rsx_memory_free), //669 (0x29D) + BIND_FUNC(sys_rsx_context_allocate), //670 (0x29E) + BIND_FUNC(sys_rsx_context_free), //671 (0x29F) + BIND_FUNC(sys_rsx_context_iomap), //672 (0x2A0) + BIND_FUNC(sys_rsx_context_iounmap), //673 (0x2A1) + BIND_FUNC(sys_rsx_context_attribute), //674 (0x2A2) + BIND_FUNC(sys_rsx_device_map), //675 (0x2A3) + BIND_FUNC(sys_rsx_device_unmap), //676 (0x2A4) + BIND_FUNC(sys_rsx_attribute), //677 (0x2A5) + null_func,//BIND_FUNC(sys_...) //678 (0x2A6) + null_func,//BIND_FUNC(sys_...) //679 (0x2A7) ROOT + null_func,//BIND_FUNC(sys_...) //680 (0x2A8) ROOT + null_func,//BIND_FUNC(sys_...) //681 (0x2A9) ROOT + null_func,//BIND_FUNC(sys_...) //682 (0x2AA) ROOT + null_func,//BIND_FUNC(sys_...) //683 (0x2AB) ROOT + null_func,//BIND_FUNC(sys_...) //684 (0x2AC) ROOT + null_func,//BIND_FUNC(sys_...) //685 (0x2AD) ROOT + null_func,//BIND_FUNC(sys_...) //686 (0x2AE) ROOT + null_func,//BIND_FUNC(sys_...) //687 (0x2AF) ROOT + null_func,//BIND_FUNC(sys_...) //688 (0x2B0) ROOT + null_func,//BIND_FUNC(sys_...) //689 (0x2B1) ROOT + null_func,//BIND_FUNC(sys_...) //690 (0x2B2) ROOT + null_func,//BIND_FUNC(sys_...) //691 (0x2B3) ROOT + null_func,//BIND_FUNC(sys_...) //692 (0x2B4) ROOT + null_func,//BIND_FUNC(sys_...) //693 (0x2B5) ROOT + null_func,//BIND_FUNC(sys_...) //694 (0x2B6) DEPRECATED + null_func,//BIND_FUNC(sys_...) //695 (0x2B7) DEPRECATED + null_func,//BIND_FUNC(sys_...) //696 (0x2B8) ROOT + null_func,//BIND_FUNC(sys_...) //697 (0x2B9) UNS + null_func,//BIND_FUNC(sys_...) //698 (0x2BA) UNS + null_func,//BIND_FUNC(sys_bdemu_send_command) //699 (0x2BB) + null_func,//BIND_FUNC(sys_net_bnet_accept) //700 (0x2BC) + null_func,//BIND_FUNC(sys_net_bnet_bind) //701 (0x2BD) + null_func,//BIND_FUNC(sys_net_bnet_connect) //702 (0x2BE) + null_func,//BIND_FUNC(sys_net_bnet_getpeername) //703 (0x2BF) + null_func,//BIND_FUNC(sys_net_bnet_getsockname) //704 (0x2C0) + null_func,//BIND_FUNC(sys_net_bnet_getsockopt) //705 (0x2C1) + null_func,//BIND_FUNC(sys_net_bnet_listen) //706 (0x2C2) + null_func,//BIND_FUNC(sys_net_bnet_recvfrom) //707 (0x2C3) + null_func,//BIND_FUNC(sys_net_bnet_recvmsg) //708 (0x2C4) + null_func,//BIND_FUNC(sys_net_bnet_sendmsg) //709 (0x2C5) + null_func,//BIND_FUNC(sys_net_bnet_sendto) //710 (0x2C6) + null_func,//BIND_FUNC(sys_net_bnet_setsockop) //711 (0x2C7) + null_func,//BIND_FUNC(sys_net_bnet_shutdown) //712 (0x2C8) + null_func,//BIND_FUNC(sys_net_bnet_socket) //713 (0x2C9) + null_func,//BIND_FUNC(sys_net_bnet_close) //714 (0x2CA) + null_func,//BIND_FUNC(sys_net_bnet_poll) //715 (0x2CB) + null_func,//BIND_FUNC(sys_net_bnet_select) //716 (0x2CC) + null_func,//BIND_FUNC(sys_net_open_dump) //717 (0x2CD) + null_func,//BIND_FUNC(sys_net_read_dump) //718 (0x2CE) + null_func,//BIND_FUNC(sys_net_close_dump) //719 (0x2CF) + null_func,//BIND_FUNC(sys_net_write_dump) //720 (0x2D0) + null_func,//BIND_FUNC(sys_net_abort) //721 (0x2D1) + null_func,//BIND_FUNC(sys_net_infoctl) //722 (0x2D2) + null_func,//BIND_FUNC(sys_net_control) //723 (0x2D3) + null_func,//BIND_FUNC(sys_net_bnet_ioctl) //724 (0x2D4) + null_func,//BIND_FUNC(sys_net_bnet_sysctl) //725 (0x2D5) + null_func,//BIND_FUNC(sys_net_eurus_post_command) //726 (0x2D6) null_func, null_func, null_func, //729 UNS null_func, null_func, null_func, null_func, null_func, //734 UNS @@ -698,189 +698,189 @@ const ppu_func_caller g_sc_table[1024] = null_func, null_func, null_func, null_func, null_func, //794 UNS null_func, null_func, null_func, null_func, null_func, //799 UNS - bind_func(sys_fs_test), //800 (0x320) - bind_func(sys_fs_open), //801 (0x321) - bind_func(sys_fs_read), //802 (0x322) - bind_func(sys_fs_write), //803 (0x323) - bind_func(sys_fs_close), //804 (0x324) - bind_func(sys_fs_opendir), //805 (0x325) - bind_func(sys_fs_readdir), //806 (0x326) - bind_func(sys_fs_closedir), //807 (0x327) - bind_func(sys_fs_stat), //808 (0x328) - bind_func(sys_fs_fstat), //809 (0x329) - null_func,//bind_func(sys_fs_link), //810 (0x32A) - bind_func(sys_fs_mkdir), //811 (0x32B) - bind_func(sys_fs_rename), //812 (0x32C) - bind_func(sys_fs_rmdir), //813 (0x32D) - bind_func(sys_fs_unlink), //814 (0x32E) - null_func,//bind_func(sys_fs_utime), //815 (0x32F) - null_func,//bind_func(sys_fs_access), //816 (0x330) - bind_func(sys_fs_fcntl), //817 (0x331) - bind_func(sys_fs_lseek), //818 (0x332) - null_func,//bind_func(sys_fs_fdatasync), //819 (0x333) - null_func,//bind_func(sys_fs_fsync), //820 (0x334) - bind_func(sys_fs_fget_block_size), //821 (0x335) - bind_func(sys_fs_get_block_size), //822 (0x336) - null_func,//bind_func(sys_fs_acl_read), //823 (0x337) - null_func,//bind_func(sys_fs_acl_write), //824 (0x338) - null_func,//bind_func(sys_fs_lsn_get_cda_size), //825 (0x339) - null_func,//bind_func(sys_fs_lsn_get_cda), //826 (0x33A) - null_func,//bind_func(sys_fs_lsn_lock), //827 (0x33B) - null_func,//bind_func(sys_fs_lsn_unlock), //828 (0x33C) - null_func,//bind_func(sys_fs_lsn_read), //829 (0x33D) - null_func,//bind_func(sys_fs_lsn_write), //830 (0x33E) - bind_func(sys_fs_truncate), //831 (0x33F) - bind_func(sys_fs_ftruncate), //832 (0x340) - null_func,//bind_func(sys_fs_symbolic_link), //833 (0x341) - bind_func(sys_fs_chmod), //834 (0x342) - null_func,//bind_func(sys_fs_chown), //835 (0x343) - null_func,//bind_func(sys_fs_newfs), //836 (0x344) - null_func,//bind_func(sys_fs_mount), //837 (0x345) - null_func,//bind_func(sys_fs_unmount), //838 (0x346) - null_func,//bind_func(sys_fs_sync), //839 (0x347) - null_func,//bind_func(sys_fs_disk_free), //840 (0x348) - null_func,//bind_func(sys_fs_get_mount_info_size), //841 (0x349) - null_func,//bind_func(sys_fs_get_mount_info), //842 (0x34A) - null_func,//bind_func(sys_fs_get_fs_info_size), //843 (0x34B) - null_func,//bind_func(sys_fs_get_fs_info), //844 (0x34C) - null_func,//bind_func(sys_fs_mapped_allocate), //845 (0x34D) - null_func,//bind_func(sys_fs_mapped_free), //846 (0x34E) - null_func,//bind_func(sys_fs_truncate2), //847 (0x34F) + BIND_FUNC(sys_fs_test), //800 (0x320) + BIND_FUNC(sys_fs_open), //801 (0x321) + BIND_FUNC(sys_fs_read), //802 (0x322) + BIND_FUNC(sys_fs_write), //803 (0x323) + BIND_FUNC(sys_fs_close), //804 (0x324) + BIND_FUNC(sys_fs_opendir), //805 (0x325) + BIND_FUNC(sys_fs_readdir), //806 (0x326) + BIND_FUNC(sys_fs_closedir), //807 (0x327) + BIND_FUNC(sys_fs_stat), //808 (0x328) + BIND_FUNC(sys_fs_fstat), //809 (0x329) + null_func,//BIND_FUNC(sys_fs_link), //810 (0x32A) + BIND_FUNC(sys_fs_mkdir), //811 (0x32B) + BIND_FUNC(sys_fs_rename), //812 (0x32C) + BIND_FUNC(sys_fs_rmdir), //813 (0x32D) + BIND_FUNC(sys_fs_unlink), //814 (0x32E) + null_func,//BIND_FUNC(sys_fs_utime), //815 (0x32F) + null_func,//BIND_FUNC(sys_fs_access), //816 (0x330) + BIND_FUNC(sys_fs_fcntl), //817 (0x331) + BIND_FUNC(sys_fs_lseek), //818 (0x332) + null_func,//BIND_FUNC(sys_fs_fdatasync), //819 (0x333) + null_func,//BIND_FUNC(sys_fs_fsync), //820 (0x334) + BIND_FUNC(sys_fs_fget_block_size), //821 (0x335) + BIND_FUNC(sys_fs_get_block_size), //822 (0x336) + null_func,//BIND_FUNC(sys_fs_acl_read), //823 (0x337) + null_func,//BIND_FUNC(sys_fs_acl_write), //824 (0x338) + null_func,//BIND_FUNC(sys_fs_lsn_get_cda_size), //825 (0x339) + null_func,//BIND_FUNC(sys_fs_lsn_get_cda), //826 (0x33A) + null_func,//BIND_FUNC(sys_fs_lsn_lock), //827 (0x33B) + null_func,//BIND_FUNC(sys_fs_lsn_unlock), //828 (0x33C) + null_func,//BIND_FUNC(sys_fs_lsn_read), //829 (0x33D) + null_func,//BIND_FUNC(sys_fs_lsn_write), //830 (0x33E) + BIND_FUNC(sys_fs_truncate), //831 (0x33F) + BIND_FUNC(sys_fs_ftruncate), //832 (0x340) + null_func,//BIND_FUNC(sys_fs_symbolic_link), //833 (0x341) + BIND_FUNC(sys_fs_chmod), //834 (0x342) + null_func,//BIND_FUNC(sys_fs_chown), //835 (0x343) + null_func,//BIND_FUNC(sys_fs_newfs), //836 (0x344) + null_func,//BIND_FUNC(sys_fs_mount), //837 (0x345) + null_func,//BIND_FUNC(sys_fs_unmount), //838 (0x346) + null_func,//BIND_FUNC(sys_fs_sync), //839 (0x347) + null_func,//BIND_FUNC(sys_fs_disk_free), //840 (0x348) + null_func,//BIND_FUNC(sys_fs_get_mount_info_size), //841 (0x349) + null_func,//BIND_FUNC(sys_fs_get_mount_info), //842 (0x34A) + null_func,//BIND_FUNC(sys_fs_get_fs_info_size), //843 (0x34B) + null_func,//BIND_FUNC(sys_fs_get_fs_info), //844 (0x34C) + null_func,//BIND_FUNC(sys_fs_mapped_allocate), //845 (0x34D) + null_func,//BIND_FUNC(sys_fs_mapped_free), //846 (0x34E) + null_func,//BIND_FUNC(sys_fs_truncate2), //847 (0x34F) null_func, null_func, //849 UNS null_func, null_func, null_func, null_func, null_func, //854 UNS null_func, null_func, null_func, null_func, null_func, //859 UNS - null_func,//bind_func(syscall_sys_ss_get_cache_of_analog_sunset_flag), //860 (0x35C) AUTHID - null_func,//bind_func(syscall_...) //861 ROOT - null_func,//bind_func(syscall_...) //862 ROOT - null_func,//bind_func(syscall_...) //863 ROOT - null_func,//bind_func(syscall_...) //864 DBG - null_func,//bind_func(sys_ss_random_number_generator), //865 (0x361) ROOT AUTHID - null_func,//bind_func(sys_...) //866 ROOT - null_func,//bind_func(sys_...) //867 ROOT - null_func,//bind_func(sys_...) //868 ROOT / DBG AUTHID - null_func,//bind_func(sys_...) //869 ROOT - null_func,//bind_func(sys_ss_get_console_id), //870 (0x366) - null_func,//bind_func(sys_ss_access_control_engine), //871 (0x367) DBG - null_func,//bind_func(sys_ss_get_open_psid), //872 (0x368) - null_func,//bind_func(sys_ss_get_cache_of_product_mode), //873 (0x369) - null_func,//bind_func(sys_ss_get_cache_of_flash_ext_flag), //874 (0x36A) - null_func,//bind_func(sys_ss_get_boot_device) //875 (0x36B) - null_func,//bind_func(sys_ss_disc_access_control) //876 (0x36C) - null_func,//bind_func(sys_ss_~utoken_if) //877 (0x36D) ROOT - null_func,//bind_func(sys_ss_ad_sign) //878 (0x36E) - null_func,//bind_func(sys_ss_media_id) //879 (0x36F) - null_func,//bind_func(sys_deci3_open) //880 (0x370) - null_func,//bind_func(sys_deci3_create_event_path) //881 (0x371) - null_func,//bind_func(sys_deci3_close) //882 (0x372) - null_func,//bind_func(sys_deci3_send) //883 (0x373) - null_func,//bind_func(sys_deci3_receive) //884 (0x374) - null_func,//bind_func(sys_deci3_open2) //885 (0x375) + null_func,//BIND_FUNC(syscall_sys_ss_get_cache_of_analog_sunset_flag), //860 (0x35C) AUTHID + null_func,//BIND_FUNC(syscall_...) //861 ROOT + null_func,//BIND_FUNC(syscall_...) //862 ROOT + null_func,//BIND_FUNC(syscall_...) //863 ROOT + null_func,//BIND_FUNC(syscall_...) //864 DBG + null_func,//BIND_FUNC(sys_ss_random_number_generator), //865 (0x361) ROOT AUTHID + null_func,//BIND_FUNC(sys_...) //866 ROOT + null_func,//BIND_FUNC(sys_...) //867 ROOT + null_func,//BIND_FUNC(sys_...) //868 ROOT / DBG AUTHID + null_func,//BIND_FUNC(sys_...) //869 ROOT + null_func,//BIND_FUNC(sys_ss_get_console_id), //870 (0x366) + null_func,//BIND_FUNC(sys_ss_access_control_engine), //871 (0x367) DBG + null_func,//BIND_FUNC(sys_ss_get_open_psid), //872 (0x368) + null_func,//BIND_FUNC(sys_ss_get_cache_of_product_mode), //873 (0x369) + null_func,//BIND_FUNC(sys_ss_get_cache_of_flash_ext_flag), //874 (0x36A) + null_func,//BIND_FUNC(sys_ss_get_boot_device) //875 (0x36B) + null_func,//BIND_FUNC(sys_ss_disc_access_control) //876 (0x36C) + null_func,//BIND_FUNC(sys_ss_~utoken_if) //877 (0x36D) ROOT + null_func,//BIND_FUNC(sys_ss_ad_sign) //878 (0x36E) + null_func,//BIND_FUNC(sys_ss_media_id) //879 (0x36F) + null_func,//BIND_FUNC(sys_deci3_open) //880 (0x370) + null_func,//BIND_FUNC(sys_deci3_create_event_path) //881 (0x371) + null_func,//BIND_FUNC(sys_deci3_close) //882 (0x372) + null_func,//BIND_FUNC(sys_deci3_send) //883 (0x373) + null_func,//BIND_FUNC(sys_deci3_receive) //884 (0x374) + null_func,//BIND_FUNC(sys_deci3_open2) //885 (0x375) null_func, //886 (0x376) UNS null_func, //887 (0x377) UNS null_func, //888 (0x378) UNS - null_func,//bind_func(sys_...) //889 (0x379) ROOT - null_func,//bind_func(sys_deci3_initialize) //890 (0x37A) - null_func,//bind_func(sys_deci3_terminate) //891 (0x37B) - null_func,//bind_func(sys_deci3_debug_mode) //892 (0x37C) - null_func,//bind_func(sys_deci3_show_status) //893 (0x37D) - null_func,//bind_func(sys_deci3_echo_test) //894 (0x37E) - null_func,//bind_func(sys_deci3_send_dcmp_packet) //895 (0x37F) - null_func,//bind_func(sys_deci3_dump_cp_register) //896 (0x380) - null_func,//bind_func(sys_deci3_dump_cp_buffer) //897 (0x381) + null_func,//BIND_FUNC(sys_...) //889 (0x379) ROOT + null_func,//BIND_FUNC(sys_deci3_initialize) //890 (0x37A) + null_func,//BIND_FUNC(sys_deci3_terminate) //891 (0x37B) + null_func,//BIND_FUNC(sys_deci3_debug_mode) //892 (0x37C) + null_func,//BIND_FUNC(sys_deci3_show_status) //893 (0x37D) + null_func,//BIND_FUNC(sys_deci3_echo_test) //894 (0x37E) + null_func,//BIND_FUNC(sys_deci3_send_dcmp_packet) //895 (0x37F) + null_func,//BIND_FUNC(sys_deci3_dump_cp_register) //896 (0x380) + null_func,//BIND_FUNC(sys_deci3_dump_cp_buffer) //897 (0x381) null_func, //898 (0x382) UNS - null_func,//bind_func(sys_deci3_test) //899 (0x383) - null_func,//bind_func(sys_dbg_stop_processes) //900 (0x384) - null_func,//bind_func(sys_dbg_continue_processes) //901 (0x385) - null_func,//bind_func(sys_dbg_stop_threads) //902 (0x386) - null_func,//bind_func(sys_dbg_continue_threads) //903 (0x387) - null_func,//bind_func(sys_dbg_read_process_memory) //904 (0x388) - null_func,//bind_func(sys_dbg_write_process_memory) //905 (0x389) - null_func,//bind_func(sys_dbg_read_thread_register) //906 (0x38A) - null_func,//bind_func(sys_dbg_write_thread_register) //907 (0x38B) - null_func,//bind_func(sys_dbg_get_process_list) //908 (0x38C) - null_func,//bind_func(sys_dbg_get_thread_list) //909 (0x38D) - null_func,//bind_func(sys_dbg_get_thread_info) //910 (0x38E) - null_func,//bind_func(sys_dbg_spu_thread_read_from_ls) //911 (0x38F) - null_func,//bind_func(sys_dbg_spu_thread_write_to_ls) //912 (0x390) - null_func,//bind_func(sys_dbg_kill_process) //913 (0x391) - null_func,//bind_func(sys_dbg_get_process_info) //914 (0x392) - null_func,//bind_func(sys_dbg_set_run_control_bit_to_spu) //915 (0x393) - null_func,//bind_func(sys_dbg_spu_thread_get_exception_cause) //916 (0x394) - null_func,//bind_func(sys_dbg_create_kernel_event_queue) //917 (0x395) - null_func,//bind_func(sys_dbg_read_kernel_event_queue) //918 (0x396) - null_func,//bind_func(sys_dbg_destroy_kernel_event_queue) //919 (0x397) - null_func,//bind_func(sys_dbg_get_process_event_ctrl_flag) //920 (0x398) - null_func,//bind_func(sys_dbg_set_process_event_cntl_flag) //921 (0x399) - null_func,//bind_func(sys_dbg_get_spu_thread_group_event_cntl_flag) //922 (0x39A) - null_func,//bind_func(sys_dbg_set_spu_thread_group_event_cntl_flag) //923 (0x39B) - null_func,//bind_func(sys_...) //924 (0x39C) - null_func,//bind_func(sys_dbg_get_raw_spu_list) //925 (0x39D) - null_func,//bind_func(sys_...) //926 (0x39E) - null_func,//bind_func(sys_...) //927 (0x3A0) - null_func,//bind_func(sys_...) //928 (0x3A1) - null_func,//bind_func(sys_...) //929 (0x3A2) - null_func,//bind_func(sys_...) //930 (0x3A3) - null_func,//bind_func(sys_...) //931 (0x3A4) - null_func,//bind_func(sys_dbg_get_mutex_list) //932 (0x3A4) - null_func,//bind_func(sys_dbg_get_mutex_information) //933 (0x3A5) - null_func,//bind_func(sys_dbg_get_cond_list) //934 (0x3A6) - null_func,//bind_func(sys_dbg_get_cond_information) //935 (0x3A7) - null_func,//bind_func(sys_dbg_get_rwlock_list) //936 (0x3A8) - null_func,//bind_func(sys_dbg_get_rwlock_information) //937 (0x3A9) - null_func,//bind_func(sys_dbg_get_lwmutex_list) //938 (0x3AA) - null_func,//bind_func(sys_dbg_get_address_from_dabr) //939 (0x3AB) - null_func,//bind_func(sys_dbg_set_address_to_dabr) //940 (0x3AC) - null_func,//bind_func(sys_dbg_get_lwmutex_information) //941 (0x3AD) - null_func,//bind_func(sys_dbg_get_event_queue_list) //942 (0x3AE) - null_func,//bind_func(sys_dbg_get_event_queue_information) //943 (0x3AF) - null_func,//bind_func(sys_dbg_initialize_ppu_exception_handler) //944 (0x3B0) - null_func,//bind_func(sys_dbg_finalize_ppu_exception_handler) //945 (0x3B1) DBG - null_func,//bind_func(sys_dbg_get_semaphore_list) //946 (0x3B2) - null_func,//bind_func(sys_dbg_get_semaphore_information) //947 (0x3B3) - null_func,//bind_func(sys_dbg_get_kernel_thread_list) //948 (0x3B4) - null_func,//bind_func(sys_dbg_get_kernel_thread_info) //949 (0x3B5) - null_func,//bind_func(sys_dbg_get_lwcond_list) //950 (0x3B6) - null_func,//bind_func(sys_dbg_get_lwcond_information) //951 (0x3B7) - null_func,//bind_func(sys_dbg_create_scratch_data_area_ext) //952 (0x3B8) - null_func,//bind_func(sys_dbg_vm_get_page_information) //953 (0x3B9) - null_func,//bind_func(sys_dbg_vm_get_info) //954 (0x3BA) - null_func,//bind_func(sys_dbg_enable_floating_point_enabled_exception) //955 (0x3BB) - null_func,//bind_func(sys_dbg_disable_floating_point_enabled_exception) //956 (0x3BC) - null_func,//bind_func(sys_dbg_...) //957 (0x3BD) DBG + null_func,//BIND_FUNC(sys_deci3_test) //899 (0x383) + null_func,//BIND_FUNC(sys_dbg_stop_processes) //900 (0x384) + null_func,//BIND_FUNC(sys_dbg_continue_processes) //901 (0x385) + null_func,//BIND_FUNC(sys_dbg_stop_threads) //902 (0x386) + null_func,//BIND_FUNC(sys_dbg_continue_threads) //903 (0x387) + null_func,//BIND_FUNC(sys_dbg_read_process_memory) //904 (0x388) + null_func,//BIND_FUNC(sys_dbg_write_process_memory) //905 (0x389) + null_func,//BIND_FUNC(sys_dbg_read_thread_register) //906 (0x38A) + null_func,//BIND_FUNC(sys_dbg_write_thread_register) //907 (0x38B) + null_func,//BIND_FUNC(sys_dbg_get_process_list) //908 (0x38C) + null_func,//BIND_FUNC(sys_dbg_get_thread_list) //909 (0x38D) + null_func,//BIND_FUNC(sys_dbg_get_thread_info) //910 (0x38E) + null_func,//BIND_FUNC(sys_dbg_spu_thread_read_from_ls) //911 (0x38F) + null_func,//BIND_FUNC(sys_dbg_spu_thread_write_to_ls) //912 (0x390) + null_func,//BIND_FUNC(sys_dbg_kill_process) //913 (0x391) + null_func,//BIND_FUNC(sys_dbg_get_process_info) //914 (0x392) + null_func,//BIND_FUNC(sys_dbg_set_run_control_bit_to_spu) //915 (0x393) + null_func,//BIND_FUNC(sys_dbg_spu_thread_get_exception_cause) //916 (0x394) + null_func,//BIND_FUNC(sys_dbg_create_kernel_event_queue) //917 (0x395) + null_func,//BIND_FUNC(sys_dbg_read_kernel_event_queue) //918 (0x396) + null_func,//BIND_FUNC(sys_dbg_destroy_kernel_event_queue) //919 (0x397) + null_func,//BIND_FUNC(sys_dbg_get_process_event_ctrl_flag) //920 (0x398) + null_func,//BIND_FUNC(sys_dbg_set_process_event_cntl_flag) //921 (0x399) + null_func,//BIND_FUNC(sys_dbg_get_spu_thread_group_event_cntl_flag) //922 (0x39A) + null_func,//BIND_FUNC(sys_dbg_set_spu_thread_group_event_cntl_flag) //923 (0x39B) + null_func,//BIND_FUNC(sys_...) //924 (0x39C) + null_func,//BIND_FUNC(sys_dbg_get_raw_spu_list) //925 (0x39D) + null_func,//BIND_FUNC(sys_...) //926 (0x39E) + null_func,//BIND_FUNC(sys_...) //927 (0x3A0) + null_func,//BIND_FUNC(sys_...) //928 (0x3A1) + null_func,//BIND_FUNC(sys_...) //929 (0x3A2) + null_func,//BIND_FUNC(sys_...) //930 (0x3A3) + null_func,//BIND_FUNC(sys_...) //931 (0x3A4) + null_func,//BIND_FUNC(sys_dbg_get_mutex_list) //932 (0x3A4) + null_func,//BIND_FUNC(sys_dbg_get_mutex_information) //933 (0x3A5) + null_func,//BIND_FUNC(sys_dbg_get_cond_list) //934 (0x3A6) + null_func,//BIND_FUNC(sys_dbg_get_cond_information) //935 (0x3A7) + null_func,//BIND_FUNC(sys_dbg_get_rwlock_list) //936 (0x3A8) + null_func,//BIND_FUNC(sys_dbg_get_rwlock_information) //937 (0x3A9) + null_func,//BIND_FUNC(sys_dbg_get_lwmutex_list) //938 (0x3AA) + null_func,//BIND_FUNC(sys_dbg_get_address_from_dabr) //939 (0x3AB) + null_func,//BIND_FUNC(sys_dbg_set_address_to_dabr) //940 (0x3AC) + null_func,//BIND_FUNC(sys_dbg_get_lwmutex_information) //941 (0x3AD) + null_func,//BIND_FUNC(sys_dbg_get_event_queue_list) //942 (0x3AE) + null_func,//BIND_FUNC(sys_dbg_get_event_queue_information) //943 (0x3AF) + null_func,//BIND_FUNC(sys_dbg_initialize_ppu_exception_handler) //944 (0x3B0) + null_func,//BIND_FUNC(sys_dbg_finalize_ppu_exception_handler) //945 (0x3B1) DBG + null_func,//BIND_FUNC(sys_dbg_get_semaphore_list) //946 (0x3B2) + null_func,//BIND_FUNC(sys_dbg_get_semaphore_information) //947 (0x3B3) + null_func,//BIND_FUNC(sys_dbg_get_kernel_thread_list) //948 (0x3B4) + null_func,//BIND_FUNC(sys_dbg_get_kernel_thread_info) //949 (0x3B5) + null_func,//BIND_FUNC(sys_dbg_get_lwcond_list) //950 (0x3B6) + null_func,//BIND_FUNC(sys_dbg_get_lwcond_information) //951 (0x3B7) + null_func,//BIND_FUNC(sys_dbg_create_scratch_data_area_ext) //952 (0x3B8) + null_func,//BIND_FUNC(sys_dbg_vm_get_page_information) //953 (0x3B9) + null_func,//BIND_FUNC(sys_dbg_vm_get_info) //954 (0x3BA) + null_func,//BIND_FUNC(sys_dbg_enable_floating_point_enabled_exception) //955 (0x3BB) + null_func,//BIND_FUNC(sys_dbg_disable_floating_point_enabled_exception) //956 (0x3BC) + null_func,//BIND_FUNC(sys_dbg_...) //957 (0x3BD) DBG null_func, //958 (0x3BE) UNS - null_func,//bind_func(sys_dbg_...) //959 (0x3BF) - null_func,//bind_func(sys_dbg_perfomance_monitor) //960 (0x3C0) - null_func,//bind_func(sys_dbg_...) //961 (0x3C1) - null_func,//bind_func(sys_dbg_...) //962 (0x3C2) - null_func,//bind_func(sys_dbg_...) //963 (0x3C3) - null_func,//bind_func(sys_dbg_...) //964 (0x3C4) - null_func,//bind_func(sys_dbg_...) //965 (0x3C5) - null_func,//bind_func(sys_dbg_...) //966 (0x3C6) - null_func,//bind_func(sys_dbg_...) //967 (0x3C7) - null_func,//bind_func(sys_dbg_...) //968 (0x3C8) - null_func,//bind_func(sys_dbg_...) //969 (0x3C9) - null_func,//bind_func(sys_dbg_get_event_flag_list) //970 (0x3CA) - null_func,//bind_func(sys_dbg_get_event_flag_information) //971 (0x3CB) - null_func,//bind_func(sys_dbg_...) //972 (0x3CC) - null_func,//bind_func(sys_dbg_...) //973 (0x3CD) - null_func,//bind_func(sys_dbg_...) //974 (0x3CE) - null_func,//bind_func(sys_dbg_read_spu_thread_context2) //975 (0x3CF) - null_func,//bind_func(sys_dbg_...) //976 (0x3D0) - null_func,//bind_func(sys_dbg_...) //977 (0x3D1) - null_func,//bind_func(sys_dbg_...) //978 (0x3D2) ROOT - null_func,//bind_func(sys_dbg_...) //979 (0x3D3) - null_func,//bind_func(sys_dbg_...) //980 (0x3D4) - null_func,//bind_func(sys_dbg_...) //981 (0x3D5) ROOT - null_func,//bind_func(sys_dbg_...) //982 (0x3D6) - null_func,//bind_func(sys_dbg_...) //983 (0x3D7) - null_func,//bind_func(sys_dbg_...) //984 (0x3D8) - null_func,//bind_func(sys_dbg_get_console_type) //985 (0x3D9) ROOT - null_func,//bind_func(sys_dbg_...) //986 (0x3DA) ROOT DBG - null_func,//bind_func(sys_dbg_...) //987 (0x3DB) ROOT - null_func,//bind_func(sys_dbg_..._ppu_exception_handler) //988 (0x3DC) - null_func,//bind_func(sys_dbg_...) //989 (0x3DD) + null_func,//BIND_FUNC(sys_dbg_...) //959 (0x3BF) + null_func,//BIND_FUNC(sys_dbg_perfomance_monitor) //960 (0x3C0) + null_func,//BIND_FUNC(sys_dbg_...) //961 (0x3C1) + null_func,//BIND_FUNC(sys_dbg_...) //962 (0x3C2) + null_func,//BIND_FUNC(sys_dbg_...) //963 (0x3C3) + null_func,//BIND_FUNC(sys_dbg_...) //964 (0x3C4) + null_func,//BIND_FUNC(sys_dbg_...) //965 (0x3C5) + null_func,//BIND_FUNC(sys_dbg_...) //966 (0x3C6) + null_func,//BIND_FUNC(sys_dbg_...) //967 (0x3C7) + null_func,//BIND_FUNC(sys_dbg_...) //968 (0x3C8) + null_func,//BIND_FUNC(sys_dbg_...) //969 (0x3C9) + null_func,//BIND_FUNC(sys_dbg_get_event_flag_list) //970 (0x3CA) + null_func,//BIND_FUNC(sys_dbg_get_event_flag_information) //971 (0x3CB) + null_func,//BIND_FUNC(sys_dbg_...) //972 (0x3CC) + null_func,//BIND_FUNC(sys_dbg_...) //973 (0x3CD) + null_func,//BIND_FUNC(sys_dbg_...) //974 (0x3CE) + null_func,//BIND_FUNC(sys_dbg_read_spu_thread_context2) //975 (0x3CF) + null_func,//BIND_FUNC(sys_dbg_...) //976 (0x3D0) + null_func,//BIND_FUNC(sys_dbg_...) //977 (0x3D1) + null_func,//BIND_FUNC(sys_dbg_...) //978 (0x3D2) ROOT + null_func,//BIND_FUNC(sys_dbg_...) //979 (0x3D3) + null_func,//BIND_FUNC(sys_dbg_...) //980 (0x3D4) + null_func,//BIND_FUNC(sys_dbg_...) //981 (0x3D5) ROOT + null_func,//BIND_FUNC(sys_dbg_...) //982 (0x3D6) + null_func,//BIND_FUNC(sys_dbg_...) //983 (0x3D7) + null_func,//BIND_FUNC(sys_dbg_...) //984 (0x3D8) + null_func,//BIND_FUNC(sys_dbg_get_console_type) //985 (0x3D9) ROOT + null_func,//BIND_FUNC(sys_dbg_...) //986 (0x3DA) ROOT DBG + null_func,//BIND_FUNC(sys_dbg_...) //987 (0x3DB) ROOT + null_func,//BIND_FUNC(sys_dbg_..._ppu_exception_handler) //988 (0x3DC) + null_func,//BIND_FUNC(sys_dbg_...) //989 (0x3DD) null_func, null_func, null_func, null_func, null_func, //994 UNS null_func, null_func, null_func, null_func, null_func, //999 UNS @@ -888,7 +888,7 @@ const ppu_func_caller g_sc_table[1024] = null_func, null_func, null_func, null_func, null_func, //1009 UNS null_func, null_func, null_func, null_func, null_func, //1014 UNS null_func, null_func, null_func, null_func, null_func, //1019 UNS - null_func, null_func, null_func, bind_func(cellGcmCallback), //1023 UNS + null_func, null_func, null_func, BIND_FUNC(cellGcmCallback), //1023 UNS }; void SysCalls::DoSyscall(PPUThread& CPU, u64 code) From 12f36cf31fb605967da9178d987a53cc099ec178 Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Tue, 8 Sep 2015 16:53:28 +0300 Subject: [PATCH 2/6] Experimental class template Module Allocates ps3 memory for specific instance T --- Utilities/Interval.h | 58 ++--- rpcs3/Emu/SysCalls/ModuleManager.cpp | 216 ++++++++++-------- rpcs3/Emu/SysCalls/ModuleManager.h | 7 +- rpcs3/Emu/SysCalls/Modules.cpp | 57 ++++- rpcs3/Emu/SysCalls/Modules.h | 57 ++++- rpcs3/Emu/SysCalls/Modules/cellAdec.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/cellAtrac.cpp | 2 +- rpcs3/Emu/SysCalls/Modules/cellAtrac.h | 2 +- rpcs3/Emu/SysCalls/Modules/cellAtracMulti.cpp | 2 +- rpcs3/Emu/SysCalls/Modules/cellAtracMulti.h | 2 +- rpcs3/Emu/SysCalls/Modules/cellAudio.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/cellAudioOut.cpp | 2 +- rpcs3/Emu/SysCalls/Modules/cellAvconfExt.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/cellBgdl.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/cellCamera.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/cellCelp8Enc.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/cellCelpEnc.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/cellDaisy.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/cellDmux.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/cellFiber.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/cellFont.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/cellFontFT.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/cellFs.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/cellGame.cpp | 6 +- rpcs3/Emu/SysCalls/Modules/cellGameExec.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/cellGem.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/cellGifDec.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/cellHttp.cpp | 8 +- rpcs3/Emu/SysCalls/Modules/cellHttpUtil.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/cellImejp.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/cellJpgDec.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/cellJpgEnc.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/cellKb.cpp | 2 +- rpcs3/Emu/SysCalls/Modules/cellKey2char.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/cellL10n.cpp | 5 +- rpcs3/Emu/SysCalls/Modules/cellMic.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/cellMouse.cpp | 2 +- rpcs3/Emu/SysCalls/Modules/cellMsgDialog.cpp | 2 +- rpcs3/Emu/SysCalls/Modules/cellMusic.cpp | 4 +- .../Emu/SysCalls/Modules/cellMusicDecode.cpp | 4 +- .../Emu/SysCalls/Modules/cellMusicExport.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/cellNetCtl.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/cellOskDialog.cpp | 6 +- rpcs3/Emu/SysCalls/Modules/cellOvis.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/cellPad.cpp | 2 +- rpcs3/Emu/SysCalls/Modules/cellPamf.cpp | 4 +- .../Emu/SysCalls/Modules/cellPhotoDecode.cpp | 4 +- .../Emu/SysCalls/Modules/cellPhotoExport.cpp | 4 +- .../Emu/SysCalls/Modules/cellPhotoImport.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/cellPngDec.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/cellPngEnc.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/cellPrint.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/cellRec.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/cellRemotePlay.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/cellResc.cpp | 6 +- rpcs3/Emu/SysCalls/Modules/cellRtc.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/cellRudp.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/cellSail.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/cellSailRec.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/cellSaveData.cpp | 8 +- rpcs3/Emu/SysCalls/Modules/cellSaveData.h | 2 - rpcs3/Emu/SysCalls/Modules/cellScreenshot.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/cellSearch.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/cellSheap.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/cellSpudll.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/cellSpurs.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/cellSpursJq.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/cellSpursSpu.cpp | 2 +- rpcs3/Emu/SysCalls/Modules/cellSsl.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/cellStorage.cpp | 2 +- rpcs3/Emu/SysCalls/Modules/cellSubdisplay.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/cellSync.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/cellSync2.cpp | 26 ++- rpcs3/Emu/SysCalls/Modules/cellSync2.h | 18 ++ rpcs3/Emu/SysCalls/Modules/cellSysconf.cpp | 6 +- rpcs3/Emu/SysCalls/Modules/cellSysmodule.cpp | 10 +- rpcs3/Emu/SysCalls/Modules/cellSysutil.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/cellSysutilAp.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/cellSysutilAvc.cpp | 6 +- .../Emu/SysCalls/Modules/cellSysutilAvc2.cpp | 4 +- .../Emu/SysCalls/Modules/cellSysutilMisc.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/cellUsbd.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/cellUsbpspcm.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/cellUserInfo.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/cellVdec.cpp | 4 +- .../Emu/SysCalls/Modules/cellVideoExport.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/cellVideoOut.cpp | 2 +- .../Emu/SysCalls/Modules/cellVideoUpload.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/cellVoice.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/cellVpost.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/cellWebBrowser.cpp | 2 +- rpcs3/Emu/SysCalls/Modules/libmixer.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/libsnd3.cpp | 2 +- rpcs3/Emu/SysCalls/Modules/libsnd3.h | 2 +- rpcs3/Emu/SysCalls/Modules/libsynth2.cpp | 2 +- rpcs3/Emu/SysCalls/Modules/libsynth2.h | 2 +- rpcs3/Emu/SysCalls/Modules/sceNp.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/sceNp2.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/sceNpClans.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/sceNpCommerce2.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/sceNpSns.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/sceNpTrophy.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/sceNpTus.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/sceNpUtil.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/sysPrxForUser.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/sys_game.cpp | 2 +- rpcs3/Emu/SysCalls/Modules/sys_heap.cpp | 2 +- rpcs3/Emu/SysCalls/Modules/sys_io.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/sys_libc.cpp | 6 +- rpcs3/Emu/SysCalls/Modules/sys_lv2dbg.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/sys_lwcond_.cpp | 2 +- rpcs3/Emu/SysCalls/Modules/sys_lwmutex_.cpp | 2 +- rpcs3/Emu/SysCalls/Modules/sys_mempool.cpp | 2 +- rpcs3/Emu/SysCalls/Modules/sys_mmapper_.cpp | 2 +- rpcs3/Emu/SysCalls/Modules/sys_net.cpp | 4 +- .../Emu/SysCalls/Modules/sys_ppu_thread_.cpp | 2 +- rpcs3/Emu/SysCalls/Modules/sys_prx_.cpp | 2 +- rpcs3/Emu/SysCalls/Modules/sys_spinlock.cpp | 2 +- rpcs3/Emu/SysCalls/Modules/sys_spu_.cpp | 2 +- rpcs3/Emu/SysCalls/lv2/sys_prx.cpp | 2 +- rpcs3/Emu/System.cpp | 2 - rpcs3/Loader/ELF64.cpp | 7 +- 123 files changed, 494 insertions(+), 379 deletions(-) diff --git a/Utilities/Interval.h b/Utilities/Interval.h index bc8009c74..120edcb07 100644 --- a/Utilities/Interval.h +++ b/Utilities/Interval.h @@ -1,42 +1,32 @@ #pragma once -template -struct BaseInterval +template struct range_t { - static const uint64_t zero = 0ull; - static const uint64_t notz = 0xffffffffffffffffull; + T1 _min; // first value + T2 _max; // second value +}; - T m_min, m_max; +template constexpr range_t, std::decay_t> make_range(T1&& _min, T2&& _max) +{ + return{ std::forward(_min), std::forward(_max) }; +} - static BaseInterval make(T min_value, T max_value) - { - BaseInterval res = { min_value, max_value }; - return res; - } +template constexpr bool operator <(const range_t& range, const T& value) +{ + return range._min < value && range._max < value; +} - static BaseInterval make() - { - return make((T&)zero, (T&)notz); - } +template constexpr bool operator <(const T& value, const range_t& range) +{ + return value < range._min && value < range._max; +} - bool getconst(T& result) - { - if (m_min == m_max) - { - result = m_min; - return true; - } - else - { - return false; - } - } +template constexpr bool operator ==(const range_t& range, const T& value) +{ + return !(value < range._min) && !(range._max < value); +} - bool isindef() - { - if (T == float) - { - - } - } -}; \ No newline at end of file +template constexpr bool operator ==(const T& value, const range_t& range) +{ + return !(value < range._min) && !(range._max < value); +} diff --git a/rpcs3/Emu/SysCalls/ModuleManager.cpp b/rpcs3/Emu/SysCalls/ModuleManager.cpp index a6a2d4b48..06b3a6691 100644 --- a/rpcs3/Emu/SysCalls/ModuleManager.cpp +++ b/rpcs3/Emu/SysCalls/ModuleManager.cpp @@ -2,116 +2,116 @@ #include "Modules.h" #include "ModuleManager.h" -extern Module cellAdec; -extern Module cellAtrac; -extern Module cellAtracMulti; -extern Module cellAudio; -extern Module cellAvconfExt; -extern Module cellBGDL; -extern Module cellCamera; -extern Module cellCelp8Enc; -extern Module cellCelpEnc; -extern Module cellDaisy; -extern Module cellDmux; -extern Module cellFiber; -extern Module cellFont; -extern Module cellFontFT; -extern Module cellFs; -extern Module cellGame; -extern Module cellGameExec; -extern Module cellGcmSys; -extern Module cellGem; -extern Module cellGifDec; -extern Module cellHttp; -extern Module cellHttps; -extern Module cellHttpUtil; -extern Module cellImeJp; -extern Module cellJpgDec; -extern Module cellJpgEnc; -extern Module cellKey2char; -extern Module cellL10n; -extern Module cellMic; -extern Module cellMusic; -extern Module cellMusicDecode; -extern Module cellMusicExport; -extern Module cellNetCtl; -extern Module cellOskDialog; -extern Module cellOvis; -extern Module cellPamf; -extern Module cellPhotoDecode; -extern Module cellPhotoExport; -extern Module cellPhotoImportUtil; -extern Module cellPngDec; -extern Module cellPngEnc; -extern Module cellPrint; -extern Module cellRec; -extern Module cellRemotePlay; -extern Module cellResc; -extern Module cellRtc; -extern Module cellRudp; -extern Module cellSail; -extern Module cellSailRec; -extern Module cellSaveData; -extern Module cellMinisSaveData; -extern Module cellScreenshot; -extern Module cellSearch; -extern Module cellSheap; -extern Module cellSpudll; -extern Module cellSpurs; -extern Module cellSpursJq; -extern Module cellSsl; -extern Module cellSubdisplay; -extern Module cellSync; -extern Module cellSync2; -extern Module cellSysconf; -extern Module cellSysmodule; -extern Module cellSysutil; -extern Module cellSysutilAp; -extern Module cellSysutilAvc; -extern Module cellSysutilAvc2; -extern Module cellSysutilMisc; -extern Module cellUsbd; -extern Module cellUsbPspcm; -extern Module cellUserInfo; -extern Module cellVdec; -extern Module cellVideoExport; -extern Module cellVideoUpload; -extern Module cellVoice; -extern Module cellVpost; -extern Module libmixer; -extern Module libsnd3; -extern Module libsynth2; -extern Module sceNp; -extern Module sceNp2; -extern Module sceNpClans; -extern Module sceNpCommerce2; -extern Module sceNpSns; -extern Module sceNpTrophy; -extern Module sceNpTus; -extern Module sceNpUtil; -extern Module sys_io; -extern Module libnet; -extern Module sysPrxForUser; -extern Module sys_libc; -extern Module sys_lv2dbg; +extern Module<> cellAdec; +extern Module<> cellAtrac; +extern Module<> cellAtracMulti; +extern Module<> cellAudio; +extern Module<> cellAvconfExt; +extern Module<> cellBGDL; +extern Module<> cellCamera; +extern Module<> cellCelp8Enc; +extern Module<> cellCelpEnc; +extern Module<> cellDaisy; +extern Module<> cellDmux; +extern Module<> cellFiber; +extern Module<> cellFont; +extern Module<> cellFontFT; +extern Module<> cellFs; +extern Module<> cellGame; +extern Module<> cellGameExec; +extern Module<> cellGcmSys; +extern Module<> cellGem; +extern Module<> cellGifDec; +extern Module<> cellHttp; +extern Module<> cellHttps; +extern Module<> cellHttpUtil; +extern Module<> cellImeJp; +extern Module<> cellJpgDec; +extern Module<> cellJpgEnc; +extern Module<> cellKey2char; +extern Module<> cellL10n; +extern Module<> cellMic; +extern Module<> cellMusic; +extern Module<> cellMusicDecode; +extern Module<> cellMusicExport; +extern Module<> cellNetCtl; +extern Module<> cellOskDialog; +extern Module<> cellOvis; +extern Module<> cellPamf; +extern Module<> cellPhotoDecode; +extern Module<> cellPhotoExport; +extern Module<> cellPhotoImportUtil; +extern Module<> cellPngDec; +extern Module<> cellPngEnc; +extern Module<> cellPrint; +extern Module<> cellRec; +extern Module<> cellRemotePlay; +extern Module<> cellResc; +extern Module<> cellRtc; +extern Module<> cellRudp; +extern Module<> cellSail; +extern Module<> cellSailRec; +extern Module<> cellSaveData; +extern Module<> cellMinisSaveData; +extern Module<> cellScreenshot; +extern Module<> cellSearch; +extern Module<> cellSheap; +extern Module<> cellSpudll; +extern Module<> cellSpurs; +extern Module<> cellSpursJq; +extern Module<> cellSsl; +extern Module<> cellSubdisplay; +extern Module<> cellSync; +extern Module cellSync2; +extern Module<> cellSysconf; +extern Module<> cellSysmodule; +extern Module<> cellSysutil; +extern Module<> cellSysutilAp; +extern Module<> cellSysutilAvc; +extern Module<> cellSysutilAvc2; +extern Module<> cellSysutilMisc; +extern Module<> cellUsbd; +extern Module<> cellUsbPspcm; +extern Module<> cellUserInfo; +extern Module<> cellVdec; +extern Module<> cellVideoExport; +extern Module<> cellVideoUpload; +extern Module<> cellVoice; +extern Module<> cellVpost; +extern Module<> libmixer; +extern Module<> libsnd3; +extern Module<> libsynth2; +extern Module<> sceNp; +extern Module<> sceNp2; +extern Module<> sceNpClans; +extern Module<> sceNpCommerce2; +extern Module<> sceNpSns; +extern Module<> sceNpTrophy; +extern Module<> sceNpTus; +extern Module<> sceNpUtil; +extern Module<> sys_io; +extern Module<> libnet; +extern Module<> sysPrxForUser; +extern Module<> sys_libc; +extern Module<> sys_lv2dbg; struct ModuleInfo { const s32 id; // -1 if the module doesn't have corresponding CELL_SYSMODULE_* id const char* const name; - Module* const module; + Module<>* const module; explicit operator bool() const { return module != nullptr; } - operator Module*() const + operator Module<>*() const { return module; } - Module* operator ->() const + Module<>* operator ->() const { return module; } @@ -243,7 +243,7 @@ void ModuleManager::Init() clear_ppu_functions(); - std::unordered_set processed; + std::unordered_set*> processed; for (auto& module : g_module_list) { @@ -272,7 +272,7 @@ void ModuleManager::Close() return; } - std::unordered_set processed; + std::unordered_set*> processed; for (auto& module : g_module_list) { @@ -285,7 +285,25 @@ void ModuleManager::Close() m_init = false; } -Module* ModuleManager::GetModuleByName(const char* name) +void ModuleManager::Alloc() +{ + if (!m_init) + { + return; + } + + std::unordered_set*> processed; + + for (auto& module : g_module_list) + { + if (module && module->on_alloc && processed.emplace(module).second) + { + module->on_alloc(); + } + } +} + +Module<>* ModuleManager::GetModuleByName(const char* name) { for (auto& module : g_module_list) { @@ -298,7 +316,7 @@ Module* ModuleManager::GetModuleByName(const char* name) return nullptr; } -Module* ModuleManager::GetModuleById(u16 id) +Module<>* ModuleManager::GetModuleById(u16 id) { for (auto& module : g_module_list) { diff --git a/rpcs3/Emu/SysCalls/ModuleManager.h b/rpcs3/Emu/SysCalls/ModuleManager.h index 45a4c7d69..593f278b3 100644 --- a/rpcs3/Emu/SysCalls/ModuleManager.h +++ b/rpcs3/Emu/SysCalls/ModuleManager.h @@ -1,6 +1,6 @@ #pragma once -class Module; +template class Module; class ModuleManager { @@ -12,8 +12,9 @@ public: void Init(); void Close(); + void Alloc(); - static Module* GetModuleByName(const char* name); - static Module* GetModuleById(u16 id); + static Module* GetModuleByName(const char* name); + static Module* GetModuleById(u16 id); static bool CheckModuleId(u16 id); }; diff --git a/rpcs3/Emu/SysCalls/Modules.cpp b/rpcs3/Emu/SysCalls/Modules.cpp index 51c295921..2e09e1a81 100644 --- a/rpcs3/Emu/SysCalls/Modules.cpp +++ b/rpcs3/Emu/SysCalls/Modules.cpp @@ -11,6 +11,7 @@ std::vector g_ppu_func_list; std::vector g_ppu_func_subs; +std::vector g_ps3_var_list; u32 add_ppu_func(ModuleFunc func) { @@ -25,21 +26,52 @@ u32 add_ppu_func(ModuleFunc func) if (f.id == func.id) { // if NIDs overlap or if the same function is added twice - throw EXCEPTION("NID already exists: 0x%08x (%s)", f.id, f.name); + throw EXCEPTION("FNID already exists: 0x%08x (%s)", f.id, f.name); } } - g_ppu_func_list.push_back(func); + g_ppu_func_list.emplace_back(std::move(func)); return (u32)g_ppu_func_list.size() - 1; } +void add_variable(u32 nid, Module<>* module, const char* name, u32(*addr)()) +{ + if (g_ps3_var_list.empty()) + { + g_ps3_var_list.reserve(0x4000); // as g_ppu_func_list + } + + for (auto& v : g_ps3_var_list) + { + if (v.id == nid) + { + throw EXCEPTION("VNID already exists: 0x%08x (%s)", nid, name); + } + } + + g_ps3_var_list.emplace_back(ModuleVariable{ nid, module, name, addr }); +} + +ModuleVariable* get_variable_by_nid(u32 nid) +{ + for (auto& v : g_ps3_var_list) + { + if (v.id == nid) + { + return &v; + } + } + + return nullptr; +} + u32 add_ppu_func_sub(StaticFunc func) { g_ppu_func_subs.emplace_back(func); return func.index; } -u32 add_ppu_func_sub(const std::initializer_list& ops, const char* name, Module* module, ppu_func_caller func) +u32 add_ppu_func_sub(const std::initializer_list& ops, const char* name, Module<>* module, ppu_func_caller func) { StaticFunc sf; sf.index = add_ppu_func(ModuleFunc(get_function_id(name), 0, module, name, func)); @@ -198,6 +230,7 @@ void clear_ppu_functions() { g_ppu_func_list.clear(); g_ppu_func_subs.clear(); + g_ps3_var_list.clear(); } u32 get_function_id(const char* name) @@ -497,18 +530,18 @@ bool patch_ppu_import(u32 addr, u32 index) return false; } -Module::Module(const char* name, void(*init)()) +Module<>::Module(const char* name, void(*init)()) : m_is_loaded(false) , m_name(name) , m_init(init) { } -Module::~Module() +Module<>::~Module() { } -void Module::Init() +void Module<>::Init() { on_load = nullptr; on_unload = nullptr; @@ -518,7 +551,7 @@ void Module::Init() m_init(); } -void Module::Load() +void Module<>::Load() { if (IsLoaded()) { @@ -533,7 +566,7 @@ void Module::Load() SetLoaded(true); } -void Module::Unload() +void Module<>::Unload() { if (!IsLoaded()) { @@ -548,22 +581,22 @@ void Module::Unload() SetLoaded(false); } -void Module::SetLoaded(bool loaded) +void Module<>::SetLoaded(bool loaded) { m_is_loaded = loaded; } -bool Module::IsLoaded() const +bool Module<>::IsLoaded() const { return m_is_loaded; } -const std::string& Module::GetName() const +const std::string& Module<>::GetName() const { return m_name; } -void Module::SetName(const std::string& name) +void Module<>::SetName(const std::string& name) { m_name = name; } diff --git a/rpcs3/Emu/SysCalls/Modules.h b/rpcs3/Emu/SysCalls/Modules.h index 4d1191dab..8c71731e6 100644 --- a/rpcs3/Emu/SysCalls/Modules.h +++ b/rpcs3/Emu/SysCalls/Modules.h @@ -7,7 +7,7 @@ namespace vm { using namespace ps3; } -class Module; +template class Module; // flags set in ModuleFunc enum : u32 @@ -30,7 +30,7 @@ struct ModuleFunc { u32 id; u32 flags; - Module* module; + Module<>* module; const char* name; ppu_func_caller func; vm::ptr lle_func; @@ -39,7 +39,7 @@ struct ModuleFunc { } - ModuleFunc(u32 id, u32 flags, Module* module, const char* name, ppu_func_caller func, vm::ptr lle_func = vm::null) + ModuleFunc(u32 id, u32 flags, Module<>* module, const char* name, ppu_func_caller func, vm::ptr lle_func = vm::null) : id(id) , flags(flags) , module(module) @@ -50,6 +50,14 @@ struct ModuleFunc } }; +struct ModuleVariable +{ + u32 id; + Module<>* module; + const char* name; + u32(*retrieve_addr)(); +}; + enum : u32 { SPET_MASKED_OPCODE, @@ -76,15 +84,19 @@ struct StaticFunc std::unordered_map labels; }; -class Module : public LogBase +template<> class Module : public LogBase { + friend class ModuleManager; + std::string m_name; bool m_is_loaded; void(*m_init)(); - Module() = delete; +protected: + std::function on_alloc; public: + Module() = delete; Module(const char* name, void(*init)()); Module(Module& other) = delete; @@ -111,15 +123,42 @@ public: void SetName(const std::string& name); }; +// Module<> with an instance of specified type in PS3 memory +template class Module : public Module +{ + u32 m_addr; + +public: + Module(const char* name, void(*init)()) + : Module(name, init) + { + on_alloc = [this] + { + static_assert(std::is_trivially_destructible::value, "Module<> instance must be trivially destructible"); + //static_assert(std::is_trivially_copy_assignable::value, "Module<> instance must be trivially copy-assignable"); + + // Allocate module instance and call the default constructor + new(vm::get_ptr(m_addr = vm::alloc(sizeof(T), vm::main)))T{}; + }; + } + + T* operator ->() const + { + return vm::get_ptr(m_addr); + } +}; + u32 add_ppu_func(ModuleFunc func); +void add_variable(u32 nid, Module<>* module, const char* name, u32(*addr)()); ModuleFunc* get_ppu_func_by_nid(u32 nid, u32* out_index = nullptr); ModuleFunc* get_ppu_func_by_index(u32 index); +ModuleVariable* get_variable_by_nid(u32 nid); void execute_ppu_func_by_index(PPUThread& CPU, u32 id); void clear_ppu_functions(); u32 get_function_id(const char* name); u32 add_ppu_func_sub(StaticFunc sf); -u32 add_ppu_func_sub(const std::initializer_list& ops, const char* name, Module* module, ppu_func_caller func); +u32 add_ppu_func_sub(const std::initializer_list& ops, const char* name, Module<>* module, ppu_func_caller func); void hook_ppu_funcs(vm::ptr base, u32 size); @@ -147,13 +186,17 @@ template(ppu, __VA_ARGS__) #define REG_FNID(module, nid, func, ...) (ppu_func_by_func::index = add_ppu_func(ModuleFunc(nid, { __VA_ARGS__ }, &module, #func, BIND_FUNC(func)))) #define REG_FUNC(module, func, ...) REG_FNID(module, get_function_id(#func), func, __VA_ARGS__) +#define REG_VNID(module, nid, var) add_variable(nid, &module, #var, []{ return vm::get_addr(&module->var); }) + +#define REG_VARIABLE(module, var) REG_VNID(module, get_function_id(#var), var) + #define REG_SUB(module, ns, name, ...) add_ppu_func_sub({ __VA_ARGS__ }, #name, &module, BIND_FUNC(ns::name)) #define SP_OP(type, op, sup) []() { s32 XXX = 0; SearchPatternEntry res = { (type), (op), 0, (sup) }; XXX = -1; res.mask = (op) ^ ~res.data; return res; }() diff --git a/rpcs3/Emu/SysCalls/Modules/cellAdec.cpp b/rpcs3/Emu/SysCalls/Modules/cellAdec.cpp index eb771ac21..de33e7002 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellAdec.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellAdec.cpp @@ -16,7 +16,7 @@ extern "C" #include "cellPamf.h" #include "cellAdec.h" -extern Module cellAdec; +extern Module<> cellAdec; AudioDecoder::AudioDecoder(s32 type, u32 addr, u32 size, vm::ptr func, u32 arg) : type(type) @@ -863,7 +863,7 @@ s32 cellAdecGetPcmItem(u32 handle, vm::pptr pcmItem) return CELL_OK; } -Module cellAdec("cellAdec", []() +Module<> cellAdec("cellAdec", []() { REG_FUNC(cellAdec, cellAdecQueryAttr); REG_FUNC(cellAdec, cellAdecOpen); diff --git a/rpcs3/Emu/SysCalls/Modules/cellAtrac.cpp b/rpcs3/Emu/SysCalls/Modules/cellAtrac.cpp index 590ba0145..9230874c6 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellAtrac.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellAtrac.cpp @@ -194,7 +194,7 @@ s32 cellAtracGetInternalErrorInfo(vm::ptr pHandle, vm::ptr return CELL_OK; } -Module cellAtrac("cellAtrac", []() +Module<> cellAtrac("cellAtrac", []() { REG_FUNC(cellAtrac, cellAtracSetDataAndGetMemSize); diff --git a/rpcs3/Emu/SysCalls/Modules/cellAtrac.h b/rpcs3/Emu/SysCalls/Modules/cellAtrac.h index 53a5058d5..391c83895 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellAtrac.h +++ b/rpcs3/Emu/SysCalls/Modules/cellAtrac.h @@ -58,4 +58,4 @@ struct CellAtracExtRes u8 priority[8]; }; -extern Module cellAtrac; +extern Module<> cellAtrac; diff --git a/rpcs3/Emu/SysCalls/Modules/cellAtracMulti.cpp b/rpcs3/Emu/SysCalls/Modules/cellAtracMulti.cpp index cc3bc9a2e..5eccf4839 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellAtracMulti.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellAtracMulti.cpp @@ -202,7 +202,7 @@ s32 cellAtracMultiGetInternalErrorInfo(vm::ptr pHandle, vm return CELL_OK; } -Module cellAtracMulti("cellAtrac", []() +Module<> cellAtracMulti("cellAtrac", []() { REG_FUNC(cellAtracMulti, cellAtracMultiSetDataAndGetMemSize); diff --git a/rpcs3/Emu/SysCalls/Modules/cellAtracMulti.h b/rpcs3/Emu/SysCalls/Modules/cellAtracMulti.h index a3bf5a04d..d2807ae34 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellAtracMulti.h +++ b/rpcs3/Emu/SysCalls/Modules/cellAtracMulti.h @@ -59,4 +59,4 @@ struct CellAtracMultiExtRes u8 priority[8]; }; -extern Module cellAtracMulti; +extern Module<> cellAtracMulti; diff --git a/rpcs3/Emu/SysCalls/Modules/cellAudio.cpp b/rpcs3/Emu/SysCalls/Modules/cellAudio.cpp index b3becabf3..2abd3091c 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellAudio.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellAudio.cpp @@ -14,7 +14,7 @@ #include "cellAudio.h" -extern Module cellAudio; +extern Module<> cellAudio; extern u64 get_system_time(); @@ -1001,7 +1001,7 @@ s32 cellAudioUnsetPersonalDevice(s32 iPersonalStream) return CELL_OK; } -Module cellAudio("cellAudio", []() +Module<> cellAudio("cellAudio", []() { g_audio.state.store(AUDIO_STATE_NOT_INITIALIZED); g_audio.buffer = 0; diff --git a/rpcs3/Emu/SysCalls/Modules/cellAudioOut.cpp b/rpcs3/Emu/SysCalls/Modules/cellAudioOut.cpp index ea1b47e6a..bc58d4d98 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellAudioOut.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellAudioOut.cpp @@ -4,7 +4,7 @@ #include "cellAudioOut.h" -extern Module cellSysutil; +extern Module<> cellSysutil; s32 cellAudioOutGetSoundAvailability(u32 audioOut, u32 type, u32 fs, u32 option) { diff --git a/rpcs3/Emu/SysCalls/Modules/cellAvconfExt.cpp b/rpcs3/Emu/SysCalls/Modules/cellAvconfExt.cpp index 3ae0c8b64..b4ff9a2d6 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellAvconfExt.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellAvconfExt.cpp @@ -7,7 +7,7 @@ #include "cellAudioOut.h" #include "cellVideoOut.h" -extern Module cellAvconfExt; +extern Module<> cellAvconfExt; f32 g_gamma; @@ -137,7 +137,7 @@ s32 cellVideoOutGetScreenSize(u32 videoOut, vm::ptr screenSize) } -Module cellAvconfExt("cellAvconfExt", []() +Module<> cellAvconfExt("cellAvconfExt", []() { g_gamma = 1.0f; diff --git a/rpcs3/Emu/SysCalls/Modules/cellBgdl.cpp b/rpcs3/Emu/SysCalls/Modules/cellBgdl.cpp index ff7bf62f4..b57d7befa 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellBgdl.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellBgdl.cpp @@ -3,7 +3,7 @@ #include "Emu/System.h" #include "Emu/SysCalls/Modules.h" -extern Module cellBGDL; +extern Module<> cellBGDL; // Return Codes enum @@ -40,7 +40,7 @@ s32 cellBGDLGetMode() return CELL_OK; } -Module cellBGDL("cellBGDL", []() +Module<> cellBGDL("cellBGDL", []() { REG_FUNC(cellBGDL, cellBGDLGetInfo); REG_FUNC(cellBGDL, cellBGDLGetInfo2); diff --git a/rpcs3/Emu/SysCalls/Modules/cellCamera.cpp b/rpcs3/Emu/SysCalls/Modules/cellCamera.cpp index b7b3dd4ca..e745a4e99 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellCamera.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellCamera.cpp @@ -7,7 +7,7 @@ #include "cellCamera.h" -extern Module cellCamera; +extern Module<> cellCamera; static const char* get_camera_attr_name(s32 value) { @@ -371,7 +371,7 @@ s32 cellCameraRemoveNotifyEventQueue2(u64 key) return CELL_OK; } -Module cellCamera("cellCamera", []() +Module<> cellCamera("cellCamera", []() { REG_FUNC(cellCamera, cellCameraInit); REG_FUNC(cellCamera, cellCameraEnd); diff --git a/rpcs3/Emu/SysCalls/Modules/cellCelp8Enc.cpp b/rpcs3/Emu/SysCalls/Modules/cellCelp8Enc.cpp index 676eeaa3a..b5e29f813 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellCelp8Enc.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellCelp8Enc.cpp @@ -3,7 +3,7 @@ #include "Emu/System.h" #include "Emu/SysCalls/Modules.h" -extern Module cellCelp8Enc; +extern Module<> cellCelp8Enc; // Return Codes enum @@ -70,7 +70,7 @@ s32 cellCelp8EncGetAu() return CELL_OK; } -Module cellCelp8Enc("cellCelp8Enc", []() +Module<> cellCelp8Enc("cellCelp8Enc", []() { REG_FUNC(cellCelp8Enc, cellCelp8EncQueryAttr); REG_FUNC(cellCelp8Enc, cellCelp8EncOpen); diff --git a/rpcs3/Emu/SysCalls/Modules/cellCelpEnc.cpp b/rpcs3/Emu/SysCalls/Modules/cellCelpEnc.cpp index 60041821a..2f2dd2c9e 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellCelpEnc.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellCelpEnc.cpp @@ -3,7 +3,7 @@ #include "Emu/System.h" #include "Emu/SysCalls/Modules.h" -extern Module cellCelpEnc; +extern Module<> cellCelpEnc; // Return Codes enum @@ -70,7 +70,7 @@ s32 cellCelpEncGetAu() return CELL_OK; } -Module cellCelpEnc("cellCelpEnc", []() +Module<> cellCelpEnc("cellCelpEnc", []() { REG_FUNC(cellCelpEnc, cellCelpEncQueryAttr); REG_FUNC(cellCelpEnc, cellCelpEncOpen); diff --git a/rpcs3/Emu/SysCalls/Modules/cellDaisy.cpp b/rpcs3/Emu/SysCalls/Modules/cellDaisy.cpp index 22cfb40b8..8556089ea 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellDaisy.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellDaisy.cpp @@ -2,7 +2,7 @@ #include "Emu/Memory/Memory.h" #include "Emu/SysCalls/Modules.h" -extern Module cellDaisy; +extern Module<> cellDaisy; s32 _ZN4cell5Daisy17LFQueue2PushCloseEPNS0_8LFQueue2EPFiPvjE() { @@ -265,7 +265,7 @@ s32 _QN4cell5Daisy22ScatterGatherInterlock7releaseEv() } -Module cellDaisy("cellDaisy", []() +Module<> cellDaisy("cellDaisy", []() { REG_FUNC(cellDaisy, _ZN4cell5Daisy17LFQueue2PushCloseEPNS0_8LFQueue2EPFiPvjE); REG_FUNC(cellDaisy, _ZN4cell5Daisy21LFQueue2GetPopPointerEPNS0_8LFQueue2EPij); diff --git a/rpcs3/Emu/SysCalls/Modules/cellDmux.cpp b/rpcs3/Emu/SysCalls/Modules/cellDmux.cpp index 490b1b5e2..c9f108c5d 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellDmux.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellDmux.cpp @@ -7,7 +7,7 @@ #include "cellPamf.h" #include "cellDmux.h" -extern Module cellDmux; +extern Module<> cellDmux; PesHeader::PesHeader(DemuxerStream& stream) : pts(CODEC_TS_INVALID) @@ -1178,7 +1178,7 @@ s32 cellDmuxFlushEs(u32 esHandle) return CELL_OK; } -Module cellDmux("cellDmux", []() +Module<> cellDmux("cellDmux", []() { REG_FUNC(cellDmux, cellDmuxQueryAttr); REG_FUNC(cellDmux, cellDmuxQueryAttr2); diff --git a/rpcs3/Emu/SysCalls/Modules/cellFiber.cpp b/rpcs3/Emu/SysCalls/Modules/cellFiber.cpp index 10c603b75..345db211f 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellFiber.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellFiber.cpp @@ -5,7 +5,7 @@ #include "cellFiber.h" -extern Module cellFiber; +extern Module<> cellFiber; s32 _cellFiberPpuInitialize() { @@ -291,7 +291,7 @@ s32 cellFiberPpuUtilWorkerControlInitializeWithAttribute() return CELL_OK; } -Module cellFiber("cellFiber", []() +Module<> cellFiber("cellFiber", []() { REG_FUNC(cellFiber, _cellFiberPpuInitialize, MFF_NO_RETURN); diff --git a/rpcs3/Emu/SysCalls/Modules/cellFont.cpp b/rpcs3/Emu/SysCalls/Modules/cellFont.cpp index 296d06b6e..52f1f1feb 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellFont.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellFont.cpp @@ -6,7 +6,7 @@ #include "Emu/FS/vfsFile.h" #include "cellFont.h" -extern Module cellFont; +extern Module<> cellFont; // Functions s32 cellFontInitializeWithRevision(u64 revisionFlags, vm::ptr config) @@ -741,7 +741,7 @@ s32 cellFontGraphicsGetLineRGBA() } -Module cellFont("cellFont", []() +Module<> cellFont("cellFont", []() { REG_FUNC(cellFont, cellFontSetFontsetOpenMode); REG_FUNC(cellFont, cellFontSetFontOpenMode); diff --git a/rpcs3/Emu/SysCalls/Modules/cellFontFT.cpp b/rpcs3/Emu/SysCalls/Modules/cellFontFT.cpp index e5b504899..74b64035e 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellFontFT.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellFontFT.cpp @@ -4,7 +4,7 @@ #include "cellFontFT.h" -extern Module cellFontFT; +extern Module<> cellFontFT; s32 cellFontInitLibraryFreeTypeWithRevision(u64 revisionFlags, vm::ptr config, vm::pptr lib) { @@ -27,7 +27,7 @@ s32 cellFontFTGetInitializedRevisionFlags() return CELL_OK; } -Module cellFontFT("cellFontFT", []() +Module<> cellFontFT("cellFontFT", []() { REG_FUNC(cellFontFT, cellFontInitLibraryFreeTypeWithRevision); REG_FUNC(cellFontFT, cellFontFTGetRevisionFlags); diff --git a/rpcs3/Emu/SysCalls/Modules/cellFs.cpp b/rpcs3/Emu/SysCalls/Modules/cellFs.cpp index 3d9f4ee8f..83d96244d 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellFs.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellFs.cpp @@ -12,7 +12,7 @@ #include "Emu/SysCalls/lv2/sys_fs.h" #include "cellFs.h" -extern Module cellFs; +extern Module<> cellFs; s32 cellFsOpen(vm::cptr path, s32 flags, vm::ptr fd, vm::cptr arg, u64 size) { @@ -1051,7 +1051,7 @@ s32 cellFsUnregisterL10nCallbacks() } -Module cellFs("cellFs", []() +Module<> cellFs("cellFs", []() { g_fs_aio_id = 1; diff --git a/rpcs3/Emu/SysCalls/Modules/cellGame.cpp b/rpcs3/Emu/SysCalls/Modules/cellGame.cpp index ca3e7e230..83b1a38be 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellGame.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellGame.cpp @@ -11,7 +11,7 @@ #include "cellSysutil.h" #include "cellGame.h" -extern Module cellGame; +extern Module<> cellGame; // Specified as second content_permission_t constructor argument to inform temporary directory static struct temporary_content_dir_tag_t{} const temporary_content_dir_tag{}; @@ -706,7 +706,7 @@ s32 cellGameUnregisterDiscChangeCallback() void cellSysutil_GameData_init() { - extern Module cellSysutil; + extern Module<> cellSysutil; REG_FUNC(cellSysutil, cellHddGameCheck); REG_FUNC(cellSysutil, cellHddGameCheck2); @@ -728,7 +728,7 @@ void cellSysutil_GameData_init() REG_FUNC(cellSysutil, cellGameUnregisterDiscChangeCallback); } -Module cellGame("cellGame", []() +Module<> cellGame("cellGame", []() { REG_FUNC(cellGame, cellGameBootCheck); REG_FUNC(cellGame, cellGamePatchCheck); diff --git a/rpcs3/Emu/SysCalls/Modules/cellGameExec.cpp b/rpcs3/Emu/SysCalls/Modules/cellGameExec.cpp index 5b2320063..491d4e735 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellGameExec.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellGameExec.cpp @@ -4,7 +4,7 @@ #include "cellGame.h" -extern Module cellGameExec; +extern Module<> cellGameExec; s32 cellGameSetExitParam() { @@ -45,7 +45,7 @@ s32 cellGameGetBootGameInfo(vm::ptr type, vm::ptr dirName, vm::ptr cellGameExec("cellGameExec", []() { REG_FUNC(cellGameExec, cellGameSetExitParam); REG_FUNC(cellGameExec, cellGameGetHomeDataExportPath); diff --git a/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp b/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp index 6fc5512ba..a4823d059 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp @@ -11,7 +11,7 @@ //#include "Emu/SysCalls/lv2/sys_process.h" #include "cellGcmSys.h" -extern Module cellGcmSys; +extern Module<> cellGcmSys; const u32 tiled_pitches[] = { 0x00000000, 0x00000200, 0x00000300, 0x00000400, @@ -1297,7 +1297,7 @@ s32 cellGcmCallback(vm::ptr context, u32 count) //---------------------------------------------------------------------------- -Module cellGcmSys("cellGcmSys", []() +Module<> cellGcmSys("cellGcmSys", []() { current_config.ioAddress = 0; current_config.localAddress = 0; diff --git a/rpcs3/Emu/SysCalls/Modules/cellGem.cpp b/rpcs3/Emu/SysCalls/Modules/cellGem.cpp index b2a906122..d2e44789e 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellGem.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellGem.cpp @@ -5,7 +5,7 @@ #include "cellGem.h" -extern Module cellGem; +extern Module<> cellGem; struct gem_t { @@ -273,7 +273,7 @@ s32 cellGemWriteExternalPort() return CELL_OK; } -Module cellGem("cellGem", []() +Module<> cellGem("cellGem", []() { REG_FUNC(cellGem, cellGemCalibrate); REG_FUNC(cellGem, cellGemClearStatusFlags); diff --git a/rpcs3/Emu/SysCalls/Modules/cellGifDec.cpp b/rpcs3/Emu/SysCalls/Modules/cellGifDec.cpp index 16789985a..97aed8964 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellGifDec.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellGifDec.cpp @@ -16,7 +16,7 @@ extern "C" #include "cellGifDec.h" -extern Module cellGifDec; +extern Module<> cellGifDec; // cellGifDec aliases (only for cellGifDec.cpp) using PPMainHandle = vm::pptr; @@ -303,7 +303,7 @@ s32 cellGifDecDestroy(PMainHandle mainHandle) return CELL_OK; } -Module cellGifDec("cellGifDec", []() +Module<> cellGifDec("cellGifDec", []() { REG_FUNC(cellGifDec, cellGifDecCreate); REG_FUNC(cellGifDec, cellGifDecExtCreate); diff --git a/rpcs3/Emu/SysCalls/Modules/cellHttp.cpp b/rpcs3/Emu/SysCalls/Modules/cellHttp.cpp index 4af23b0f4..ee6a48fcb 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellHttp.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellHttp.cpp @@ -2,8 +2,8 @@ #include "Emu/Memory/Memory.h" #include "Emu/SysCalls/Modules.h" -extern Module cellHttp; -extern Module cellHttps; +extern Module<> cellHttp; +extern Module<> cellHttps; s32 cellHttpInit() { @@ -599,7 +599,7 @@ s32 cellHttpClientSetSslIdDestroyCallback() return CELL_OK; } -Module cellHttp("cellHttp", []() +Module<> cellHttp("cellHttp", []() { REG_FUNC(cellHttp, cellHttpInit); REG_FUNC(cellHttp, cellHttpEnd); @@ -713,7 +713,7 @@ Module cellHttp("cellHttp", []() REG_FUNC(cellHttp, cellHttpClientSetSslIdDestroyCallback); }); -Module cellHttps("cellHttps", []() +Module<> cellHttps("cellHttps", []() { // cellHttps doesn't have functions (cellHttpsInit belongs to cellHttp, for example) }); diff --git a/rpcs3/Emu/SysCalls/Modules/cellHttpUtil.cpp b/rpcs3/Emu/SysCalls/Modules/cellHttpUtil.cpp index a61c787e7..4625593b1 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellHttpUtil.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellHttpUtil.cpp @@ -2,7 +2,7 @@ #include "Emu/Memory/Memory.h" #include "Emu/SysCalls/Modules.h" -extern Module cellHttpUtil; +extern Module<> cellHttpUtil; s32 cellHttpUtilParseUri() { @@ -124,7 +124,7 @@ s32 cellHttpUtilBase64Decoder() return CELL_OK; } -Module cellHttpUtil("cellHttpUtil", []() +Module<> cellHttpUtil("cellHttpUtil", []() { REG_FUNC(cellHttpUtil, cellHttpUtilParseUri); REG_FUNC(cellHttpUtil, cellHttpUtilParseUriPath); diff --git a/rpcs3/Emu/SysCalls/Modules/cellImejp.cpp b/rpcs3/Emu/SysCalls/Modules/cellImejp.cpp index 21f1cebe4..d1959b36c 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellImejp.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellImejp.cpp @@ -2,7 +2,7 @@ #include "Emu/Memory/Memory.h" #include "Emu/SysCalls/Modules.h" -extern Module cellImeJp; +extern Module<> cellImeJp; // Return Codes enum @@ -262,7 +262,7 @@ s32 cellImeJpConfirmPrediction() return CELL_OK; } -Module cellImeJp("cellImeJp", []() +Module<> cellImeJp("cellImeJp", []() { REG_FUNC(cellImeJp, cellImeJpOpen); REG_FUNC(cellImeJp, cellImeJpOpen2); diff --git a/rpcs3/Emu/SysCalls/Modules/cellJpgDec.cpp b/rpcs3/Emu/SysCalls/Modules/cellJpgDec.cpp index 3e7a1e55f..b7800f2f3 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellJpgDec.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellJpgDec.cpp @@ -15,7 +15,7 @@ extern "C" #include "cellJpgDec.h" -extern Module cellJpgDec; +extern Module<> cellJpgDec; s32 cellJpgDecCreate(u32 mainHandle, u32 threadInParam, u32 threadOutParam) { @@ -359,7 +359,7 @@ s32 cellJpgDecExtSetParameter() } -Module cellJpgDec("cellJpgDec", []() +Module<> cellJpgDec("cellJpgDec", []() { REG_FUNC(cellJpgDec, cellJpgDecCreate); REG_FUNC(cellJpgDec, cellJpgDecExtCreate); diff --git a/rpcs3/Emu/SysCalls/Modules/cellJpgEnc.cpp b/rpcs3/Emu/SysCalls/Modules/cellJpgEnc.cpp index c4352982a..2b91af18b 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellJpgEnc.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellJpgEnc.cpp @@ -2,7 +2,7 @@ #include "Emu/Memory/Memory.h" #include "Emu/SysCalls/Modules.h" -extern Module cellJpgEnc; +extern Module<> cellJpgEnc; // Error Codes enum @@ -75,7 +75,7 @@ s32 cellJpgEncReset() return CELL_OK; } -Module cellJpgEnc("cellJpgEnc", []() +Module<> cellJpgEnc("cellJpgEnc", []() { REG_FUNC(cellJpgEnc, cellJpgEncQueryAttr); REG_FUNC(cellJpgEnc, cellJpgEncOpen); diff --git a/rpcs3/Emu/SysCalls/Modules/cellKb.cpp b/rpcs3/Emu/SysCalls/Modules/cellKb.cpp index 99595c16b..bd55bef6f 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellKb.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellKb.cpp @@ -6,7 +6,7 @@ #include "Emu/Io/Keyboard.h" #include "cellKb.h" -extern Module sys_io; +extern Module<> sys_io; s32 cellKbInit(u32 max_connect) { diff --git a/rpcs3/Emu/SysCalls/Modules/cellKey2char.cpp b/rpcs3/Emu/SysCalls/Modules/cellKey2char.cpp index 9b7ab4655..72979257f 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellKey2char.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellKey2char.cpp @@ -2,7 +2,7 @@ #include "Emu/Memory/Memory.h" #include "Emu/SysCalls/Modules.h" -extern Module cellKey2char; +extern Module<> cellKey2char; // Return Codes enum @@ -46,7 +46,7 @@ s32 cellKey2CharSetArrangement() return CELL_OK; } -Module cellKey2char("cellKey2char", []() +Module<> cellKey2char("cellKey2char", []() { REG_FUNC(cellKey2char, cellKey2CharOpen); REG_FUNC(cellKey2char, cellKey2CharClose); diff --git a/rpcs3/Emu/SysCalls/Modules/cellL10n.cpp b/rpcs3/Emu/SysCalls/Modules/cellL10n.cpp index 12a38d26c..fe3f69383 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellL10n.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellL10n.cpp @@ -10,7 +10,7 @@ #include "cellL10n.h" -extern Module cellL10n; +extern Module<> cellL10n; // Translate code id to code name. some codepage may has another name. // If this makes your compilation fail, try replace the string code with one in "iconv -l" @@ -1163,7 +1163,8 @@ s32 UTF8stoUCS2s() throw EXCEPTION(""); } -Module cellL10n("cellL10n", []() + +Module<> cellL10n("cellL10n", []() { REG_FUNC(cellL10n, UCS2toEUCJP); REG_FUNC(cellL10n, l10n_convert); diff --git a/rpcs3/Emu/SysCalls/Modules/cellMic.cpp b/rpcs3/Emu/SysCalls/Modules/cellMic.cpp index 83ff0fae6..541db53ad 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellMic.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellMic.cpp @@ -5,7 +5,7 @@ #include "cellMic.h" -extern Module cellMic; +extern Module<> cellMic; s32 cellMicInit() { @@ -260,7 +260,7 @@ s32 cellMicGetDeviceIdentifier() return CELL_OK; } -Module cellMic("cellMic", []() +Module<> cellMic("cellMic", []() { REG_FUNC(cellMic, cellMicInit); REG_FUNC(cellMic, cellMicEnd); diff --git a/rpcs3/Emu/SysCalls/Modules/cellMouse.cpp b/rpcs3/Emu/SysCalls/Modules/cellMouse.cpp index 6fa25276a..ca0644888 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellMouse.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellMouse.cpp @@ -6,7 +6,7 @@ #include "Emu/Io/Mouse.h" #include "cellMouse.h" -extern Module sys_io; +extern Module<> sys_io; s32 cellMouseInit(u32 max_connect) { diff --git a/rpcs3/Emu/SysCalls/Modules/cellMsgDialog.cpp b/rpcs3/Emu/SysCalls/Modules/cellMsgDialog.cpp index 088c9147c..1a120d193 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellMsgDialog.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellMsgDialog.cpp @@ -7,7 +7,7 @@ #include "cellSysutil.h" #include "cellMsgDialog.h" -extern Module cellSysutil; +extern Module<> cellSysutil; extern u64 get_system_time(); diff --git a/rpcs3/Emu/SysCalls/Modules/cellMusic.cpp b/rpcs3/Emu/SysCalls/Modules/cellMusic.cpp index bd5993b56..8ef53bc23 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellMusic.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellMusic.cpp @@ -7,7 +7,7 @@ #include "cellMusic.h" -extern Module cellMusic; +extern Module<> cellMusic; struct music2_t { @@ -149,7 +149,7 @@ s32 cellMusicGetVolume2() } -Module cellMusic("cellMusic", []() +Module<> cellMusic("cellMusic", []() { REG_FUNC(cellMusic, cellMusicGetSelectionContext); REG_FUNC(cellMusic, cellMusicSetSelectionContext2); diff --git a/rpcs3/Emu/SysCalls/Modules/cellMusicDecode.cpp b/rpcs3/Emu/SysCalls/Modules/cellMusicDecode.cpp index f0fbb5dcd..0d86d8c1d 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellMusicDecode.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellMusicDecode.cpp @@ -2,7 +2,7 @@ #include "Emu/Memory/Memory.h" #include "Emu/SysCalls/Modules.h" -extern Module cellMusicDecode; +extern Module<> cellMusicDecode; // Return Codes enum @@ -145,7 +145,7 @@ s32 cellMusicDecodeGetContentsId2() } -Module cellMusicDecode("cellMusicDecode", []() +Module<> cellMusicDecode("cellMusicDecode", []() { REG_FUNC(cellMusicDecode, cellMusicDecodeInitialize); REG_FUNC(cellMusicDecode, cellMusicDecodeInitializeSystemWorkload); diff --git a/rpcs3/Emu/SysCalls/Modules/cellMusicExport.cpp b/rpcs3/Emu/SysCalls/Modules/cellMusicExport.cpp index 571a4a5e8..690188e00 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellMusicExport.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellMusicExport.cpp @@ -2,7 +2,7 @@ #include "Emu/Memory/Memory.h" #include "Emu/SysCalls/Modules.h" -extern Module cellMusicExport; +extern Module<> cellMusicExport; // Return Codes enum @@ -51,7 +51,7 @@ s32 cellMusicExportProgress() return CELL_OK; } -Module cellMusicExport("cellMusicExport", []() +Module<> cellMusicExport("cellMusicExport", []() { REG_FUNC(cellMusicExport, cellMusicExportInitialize); REG_FUNC(cellMusicExport, cellMusicExportInitialize2); diff --git a/rpcs3/Emu/SysCalls/Modules/cellNetCtl.cpp b/rpcs3/Emu/SysCalls/Modules/cellNetCtl.cpp index 37d75b17b..0fc131312 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellNetCtl.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellNetCtl.cpp @@ -28,7 +28,7 @@ #include #endif -extern Module cellNetCtl; +extern Module<> cellNetCtl; s32 cellNetCtlInit() { @@ -423,7 +423,7 @@ s32 cellGameUpdateCheckStartWithoutDialogAsyncEx() } -Module cellNetCtl("cellNetCtl", []() +Module<> cellNetCtl("cellNetCtl", []() { REG_FUNC(cellNetCtl, cellNetCtlInit); REG_FUNC(cellNetCtl, cellNetCtlTerm); diff --git a/rpcs3/Emu/SysCalls/Modules/cellOskDialog.cpp b/rpcs3/Emu/SysCalls/Modules/cellOskDialog.cpp index 1a0ead631..6a83bd544 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellOskDialog.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellOskDialog.cpp @@ -2,7 +2,7 @@ #include "Emu/Memory/Memory.h" #include "Emu/SysCalls/Modules.h" -extern Module cellOskDialog; +extern Module<> cellOskDialog; s32 cellOskDialogLoadAsync() { @@ -153,7 +153,7 @@ s32 cellOskDialogExtRegisterForceFinishCallback() void cellSysutil_OskDialog_init() { - extern Module cellSysutil; + extern Module<> cellSysutil; // cellOskDialog functions: REG_FUNC(cellSysutil, cellOskDialogLoadAsync); @@ -171,7 +171,7 @@ void cellSysutil_OskDialog_init() REG_FUNC(cellSysutil, cellOskDialogGetInputText); } -Module cellOskDialog("cellOskDialog", []() +Module<> cellOskDialog("cellOskDialog", []() { // cellOskDialogExt functions: REG_FUNC(cellOskDialog, cellOskDialogExtInputDeviceUnlock); diff --git a/rpcs3/Emu/SysCalls/Modules/cellOvis.cpp b/rpcs3/Emu/SysCalls/Modules/cellOvis.cpp index 500c053db..ca2814c1d 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellOvis.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellOvis.cpp @@ -4,7 +4,7 @@ namespace vm { using namespace ps3; } -extern Module cellOvis; +extern Module<> cellOvis; // Return Codes enum @@ -38,7 +38,7 @@ s32 cellOvisInvalidateOverlappedSegments() return CELL_OK; } -Module cellOvis("cellOvis", []() +Module<> cellOvis("cellOvis", []() { REG_FUNC(cellOvis, cellOvisGetOverlayTableSize); REG_FUNC(cellOvis, cellOvisInitializeOverlayTable); diff --git a/rpcs3/Emu/SysCalls/Modules/cellPad.cpp b/rpcs3/Emu/SysCalls/Modules/cellPad.cpp index 263f6a988..8d76b05de 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellPad.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellPad.cpp @@ -6,7 +6,7 @@ #include "Emu/Io/Pad.h" #include "cellPad.h" -extern Module sys_io; +extern Module<> sys_io; s32 cellPadInit(u32 max_connect) { diff --git a/rpcs3/Emu/SysCalls/Modules/cellPamf.cpp b/rpcs3/Emu/SysCalls/Modules/cellPamf.cpp index b954f0ad0..bfac839b1 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellPamf.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellPamf.cpp @@ -5,7 +5,7 @@ #include "cellPamf.h" -extern Module cellPamf; +extern Module<> cellPamf; s32 pamfStreamTypeToEsFilterId(u8 type, u8 ch, CellCodecEsFilterId& pEsFilterId) { @@ -733,7 +733,7 @@ s32 cellPamfEpIteratorMove(vm::ptr pIt, s32 steps, vm::ptr cellPamf("cellPamf", []() { REG_FUNC(cellPamf, cellPamfGetHeaderSize); REG_FUNC(cellPamf, cellPamfGetHeaderSize2); diff --git a/rpcs3/Emu/SysCalls/Modules/cellPhotoDecode.cpp b/rpcs3/Emu/SysCalls/Modules/cellPhotoDecode.cpp index f0eb743eb..8ede8c838 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellPhotoDecode.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellPhotoDecode.cpp @@ -2,7 +2,7 @@ #include "Emu/Memory/Memory.h" #include "Emu/SysCalls/Modules.h" -extern Module cellPhotoDecode; +extern Module<> cellPhotoDecode; // Return Codes enum @@ -56,7 +56,7 @@ s32 cellPhotoDecodeFromFile() return CELL_OK; } -Module cellPhotoDecode("cellPhotoDecode", []() +Module<> cellPhotoDecode("cellPhotoDecode", []() { REG_FUNC(cellPhotoDecode, cellPhotoDecodeInitialize); REG_FUNC(cellPhotoDecode, cellPhotoDecodeInitialize2); diff --git a/rpcs3/Emu/SysCalls/Modules/cellPhotoExport.cpp b/rpcs3/Emu/SysCalls/Modules/cellPhotoExport.cpp index 998a24b51..00b88fabc 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellPhotoExport.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellPhotoExport.cpp @@ -2,7 +2,7 @@ #include "Emu/Memory/Memory.h" #include "Emu/SysCalls/Modules.h" -extern Module cellPhotoExport; +extern Module<> cellPhotoExport; // Return Codes enum @@ -75,7 +75,7 @@ s32 cellPhotoExportProgress() return CELL_OK; } -Module cellPhotoExport("cellPhotoExport", []() +Module<> cellPhotoExport("cellPhotoExport", []() { REG_FUNC(cellPhotoExport, cellPhotoInitialize); REG_FUNC(cellPhotoExport, cellPhotoFinalize); diff --git a/rpcs3/Emu/SysCalls/Modules/cellPhotoImport.cpp b/rpcs3/Emu/SysCalls/Modules/cellPhotoImport.cpp index eaa9f3fe7..cb4bddb8f 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellPhotoImport.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellPhotoImport.cpp @@ -2,7 +2,7 @@ #include "Emu/Memory/Memory.h" #include "Emu/SysCalls/Modules.h" -extern Module cellPhotoImportUtil; +extern Module<> cellPhotoImportUtil; // Return Codes enum @@ -53,7 +53,7 @@ s32 cellPhotoImport2() return CELL_OK; } -Module cellPhotoImportUtil("cellPhotoImport", []() +Module<> cellPhotoImportUtil("cellPhotoImport", []() { REG_FUNC(cellPhotoImportUtil, cellPhotoImport); REG_FUNC(cellPhotoImportUtil, cellPhotoImport2); diff --git a/rpcs3/Emu/SysCalls/Modules/cellPngDec.cpp b/rpcs3/Emu/SysCalls/Modules/cellPngDec.cpp index dd059415e..c3e54231b 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellPngDec.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellPngDec.cpp @@ -15,7 +15,7 @@ extern "C" #include "cellPngDec.h" -extern Module cellPngDec; +extern Module<> cellPngDec; // cellPngDec aliases (only for cellPngDec.cpp) using PPMainHandle = vm::pptr; @@ -571,7 +571,7 @@ s32 cellPngDecGetTextChunk(PMainHandle mainHandle, PSubHandle subHandle, vm::ptr return CELL_OK; } -Module cellPngDec("cellPngDec", []() +Module<> cellPngDec("cellPngDec", []() { REG_FUNC(cellPngDec, cellPngDecGetUnknownChunks); REG_FUNC(cellPngDec, cellPngDecClose); diff --git a/rpcs3/Emu/SysCalls/Modules/cellPngEnc.cpp b/rpcs3/Emu/SysCalls/Modules/cellPngEnc.cpp index d65ed8a93..5317ed014 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellPngEnc.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellPngEnc.cpp @@ -2,7 +2,7 @@ #include "Emu/Memory/Memory.h" #include "Emu/SysCalls/Modules.h" -extern Module cellPngEnc; +extern Module<> cellPngEnc; // Error Codes enum @@ -69,7 +69,7 @@ s32 cellPngEncReset() return CELL_OK; } -Module cellPngEnc("cellPngEnc", []() +Module<> cellPngEnc("cellPngEnc", []() { REG_FUNC(cellPngEnc, cellPngEncQueryAttr); REG_FUNC(cellPngEnc, cellPngEncOpen); diff --git a/rpcs3/Emu/SysCalls/Modules/cellPrint.cpp b/rpcs3/Emu/SysCalls/Modules/cellPrint.cpp index 707cf908a..c64f0ea72 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellPrint.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellPrint.cpp @@ -2,7 +2,7 @@ #include "Emu/Memory/Memory.h" #include "Emu/SysCalls/Modules.h" -extern Module cellPrint; +extern Module<> cellPrint; // Error Codes enum @@ -101,7 +101,7 @@ s32 cellPrintSendBand() return CELL_OK; } -Module cellPrint("cellPrint", []() +Module<> cellPrint("cellPrint", []() { REG_FUNC(cellPrint, cellSysutilPrintInit); REG_FUNC(cellPrint, cellSysutilPrintShutdown); diff --git a/rpcs3/Emu/SysCalls/Modules/cellRec.cpp b/rpcs3/Emu/SysCalls/Modules/cellRec.cpp index 8886c882f..4a53e6f14 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellRec.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellRec.cpp @@ -2,7 +2,7 @@ #include "Emu/Memory/Memory.h" #include "Emu/SysCalls/Modules.h" -extern Module cellRec; +extern Module<> cellRec; s32 cellRecOpen() { @@ -40,7 +40,7 @@ s32 cellRecSetInfo() } -Module cellRec("cellRec", []() +Module<> cellRec("cellRec", []() { REG_FUNC(cellRec, cellRecOpen); REG_FUNC(cellRec, cellRecClose); diff --git a/rpcs3/Emu/SysCalls/Modules/cellRemotePlay.cpp b/rpcs3/Emu/SysCalls/Modules/cellRemotePlay.cpp index 024327e61..ffc5abb82 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellRemotePlay.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellRemotePlay.cpp @@ -2,7 +2,7 @@ #include "Emu/Memory/Memory.h" #include "Emu/SysCalls/Modules.h" -extern Module cellRemotePlay; +extern Module<> cellRemotePlay; s32 cellRemotePlayGetStatus() { @@ -45,7 +45,7 @@ s32 cellRemotePlayBreak() } -Module cellRemotePlay("cellRemotePlay", []() +Module<> cellRemotePlay("cellRemotePlay", []() { REG_FUNC(cellRemotePlay, cellRemotePlayGetStatus); REG_FUNC(cellRemotePlay, cellRemotePlaySetComparativeVolume); diff --git a/rpcs3/Emu/SysCalls/Modules/cellResc.cpp b/rpcs3/Emu/SysCalls/Modules/cellResc.cpp index 682b8ef00..6b898758f 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellResc.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellResc.cpp @@ -9,7 +9,7 @@ #include "Emu/RSX/GSRender.h" #include "cellResc.h" -extern Module cellResc; +extern Module<> cellResc; extern s32 cellVideoOutConfigure(u32 videoOut, vm::ptr config, vm::ptr option, u32 waitForEvent); extern s32 cellGcmSetFlipMode(u32 mode); @@ -564,7 +564,7 @@ void SetupSurfaces(vm::ptr& cntxt) r.m_surface_clip_y = 0; } -// Module Functions +// Module<> Functions s32 cellRescInit(vm::ptr initConfig) { cellResc.Warning("cellRescInit(initConfig=*0x%x)", initConfig); @@ -1247,7 +1247,7 @@ s32 cellRescCreateInterlaceTable(u32 ea_addr, float srcH, CellRescTableElement d } -Module cellResc("cellResc", []() +Module<> cellResc("cellResc", []() { s_rescInternalInstance = new CCellRescInternal(); diff --git a/rpcs3/Emu/SysCalls/Modules/cellRtc.cpp b/rpcs3/Emu/SysCalls/Modules/cellRtc.cpp index 278dc0a40..c7345653c 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellRtc.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellRtc.cpp @@ -5,7 +5,7 @@ #include "Utilities/rTime.h" #include "cellRtc.h" -extern Module cellRtc; +extern Module<> cellRtc; s64 convertToUNIXTime(u16 seconds, u16 minutes, u16 hours, u16 days, s32 years) { @@ -445,7 +445,7 @@ s32 cellRtcCompareTick(vm::ptr pTick0, vm::ptr pTick1) else return CELL_OK; } -Module cellRtc("cellRtc", []() +Module<> cellRtc("cellRtc", []() { REG_FUNC(cellRtc, cellRtcGetCurrentTick); REG_FUNC(cellRtc, cellRtcGetCurrentClock); diff --git a/rpcs3/Emu/SysCalls/Modules/cellRudp.cpp b/rpcs3/Emu/SysCalls/Modules/cellRudp.cpp index f5c430196..bf7db19e2 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellRudp.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellRudp.cpp @@ -6,7 +6,7 @@ #include "cellRudp.h" -extern Module cellRudp; +extern Module<> cellRudp; struct rudp_t { @@ -239,7 +239,7 @@ s32 cellRudpProcessEvents() return CELL_OK; } -Module cellRudp("cellRudp", []() +Module<> cellRudp("cellRudp", []() { REG_FUNC(cellRudp, cellRudpInit); REG_FUNC(cellRudp, cellRudpEnd); diff --git a/rpcs3/Emu/SysCalls/Modules/cellSail.cpp b/rpcs3/Emu/SysCalls/Modules/cellSail.cpp index c532f8626..96824026a 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSail.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSail.cpp @@ -8,7 +8,7 @@ #include "cellSail.h" #include "cellPamf.h" -extern Module cellSail; +extern Module<> cellSail; void playerBoot(vm::ptr pSelf, u64 userParam) { @@ -1042,7 +1042,7 @@ s32 cellSailPlayerUnregisterSource() return CELL_OK; } -Module cellSail("cellSail", []() +Module<> cellSail("cellSail", []() { REG_FUNC(cellSail, cellSailMemAllocatorInitialize); diff --git a/rpcs3/Emu/SysCalls/Modules/cellSailRec.cpp b/rpcs3/Emu/SysCalls/Modules/cellSailRec.cpp index 242e57079..2777d8d0c 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSailRec.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSailRec.cpp @@ -2,7 +2,7 @@ #include "Emu/Memory/Memory.h" #include "Emu/SysCalls/Modules.h" -extern Module cellSailRec; +extern Module<> cellSailRec; // Error Codes enum @@ -255,7 +255,7 @@ s32 cellSailRecorderDumpImage() return CELL_OK; } -Module cellSailRec("cellSailRec", []() +Module<> cellSailRec("cellSailRec", []() { REG_FUNC(cellSailRec, cellSailProfileSetEsAudioParameter); REG_FUNC(cellSailRec, cellSailProfileSetEsVideoParameter); diff --git a/rpcs3/Emu/SysCalls/Modules/cellSaveData.cpp b/rpcs3/Emu/SysCalls/Modules/cellSaveData.cpp index c43c6d55d..31245de1d 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSaveData.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSaveData.cpp @@ -10,7 +10,9 @@ #include "Loader/PSF.h" #include "cellSaveData.h" -extern Module cellSysutil; +extern Module<> cellSysutil; +extern Module<> cellSaveData; +extern Module<> cellMinisSaveData; std::unique_ptr g_savedata_dialog; @@ -958,7 +960,7 @@ void cellSysutil_SaveData_init() REG_FUNC(cellSysutil, cellSaveDataAutoSave); } -Module cellSaveData("cellSaveData", []() +Module<> cellSaveData("cellSaveData", []() { // libsysutil_savedata functions: REG_FUNC(cellSaveData, cellSaveDataUserGetListItem); @@ -975,7 +977,7 @@ Module cellSaveData("cellSaveData", []() REG_FUNC(cellSaveData, cellSaveDataListImport); }); -Module cellMinisSaveData("cellMinisSaveData", []() +Module<> cellMinisSaveData("cellMinisSaveData", []() { // libsysutil_savedata_psp functions: //REG_FUNC(cellMinisSaveData, cellMinisSaveDataDelete); // 0x6eb168b3 diff --git a/rpcs3/Emu/SysCalls/Modules/cellSaveData.h b/rpcs3/Emu/SysCalls/Modules/cellSaveData.h index 9101d75c0..5db4323b0 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSaveData.h +++ b/rpcs3/Emu/SysCalls/Modules/cellSaveData.h @@ -298,5 +298,3 @@ struct SaveDataDialogInstance virtual s32 ShowSaveDataList(std::vector& save_entries, s32 focused, vm::ptr listSet) = 0; }; - -extern class Module cellSaveData; diff --git a/rpcs3/Emu/SysCalls/Modules/cellScreenshot.cpp b/rpcs3/Emu/SysCalls/Modules/cellScreenshot.cpp index 808742395..95b8e15a4 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellScreenshot.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellScreenshot.cpp @@ -4,7 +4,7 @@ #include "Emu/SysCalls/Modules.h" #include "cellScreenshot.h" -extern Module cellScreenshot; +extern Module<> cellScreenshot; s32 cellScreenShotSetParameter() //const CellScreenShotSetParam *param { @@ -30,7 +30,7 @@ s32 cellScreenShotDisable() return CELL_OK; } -Module cellScreenshot("cellScreenshot", []() +Module<> cellScreenshot("cellScreenshot", []() { REG_FUNC(cellScreenshot, cellScreenShotSetParameter); REG_FUNC(cellScreenshot, cellScreenShotSetOverlayImage); diff --git a/rpcs3/Emu/SysCalls/Modules/cellSearch.cpp b/rpcs3/Emu/SysCalls/Modules/cellSearch.cpp index 62293ba55..291b470d9 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSearch.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSearch.cpp @@ -4,7 +4,7 @@ #include "Emu/SysCalls/Modules.h" #include "cellSearch.h" -extern Module cellSearch; +extern Module<> cellSearch; s32 cellSearchInitialize(CellSearchMode mode, u32 container, vm::ptr func, vm::ptr userData) { @@ -130,7 +130,7 @@ s32 cellSearchEnd() return CELL_OK; } -Module cellSearch("cellSearch", []() +Module<> cellSearch("cellSearch", []() { REG_FUNC(cellSearch, cellSearchInitialize); REG_FUNC(cellSearch, cellSearchFinalize); diff --git a/rpcs3/Emu/SysCalls/Modules/cellSheap.cpp b/rpcs3/Emu/SysCalls/Modules/cellSheap.cpp index 98599ba76..b8bd086ac 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSheap.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSheap.cpp @@ -2,7 +2,7 @@ #include "Emu/Memory/Memory.h" #include "Emu/SysCalls/Modules.h" -extern Module cellSheap; +extern Module<> cellSheap; // Return Codes enum @@ -121,7 +121,7 @@ s32 cellKeySheapQueueDelete() return CELL_OK; } -Module cellSheap("cellSheap", []() +Module<> cellSheap("cellSheap", []() { REG_FUNC(cellSheap, cellSheapInitialize); REG_FUNC(cellSheap, cellSheapAllocate); diff --git a/rpcs3/Emu/SysCalls/Modules/cellSpudll.cpp b/rpcs3/Emu/SysCalls/Modules/cellSpudll.cpp index 3ac245ae7..026b5be39 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSpudll.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSpudll.cpp @@ -2,7 +2,7 @@ #include "Emu/Memory/Memory.h" #include "Emu/SysCalls/Modules.h" -extern Module cellSpudll; +extern Module<> cellSpudll; s32 cellSpudllGetImageSize(vm::ptr psize, vm::cptr so_elf, vm::cptr config) { @@ -14,7 +14,7 @@ s32 cellSpudllHandleConfigSetDefaultValues(vm::ptr cellSpudll("cellSpudll", []() { REG_FUNC(cellSpudll, cellSpudllGetImageSize); REG_FUNC(cellSpudll, cellSpudllHandleConfigSetDefaultValues); diff --git a/rpcs3/Emu/SysCalls/Modules/cellSpurs.cpp b/rpcs3/Emu/SysCalls/Modules/cellSpurs.cpp index 1c706c775..b2a20633f 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSpurs.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSpurs.cpp @@ -22,7 +22,7 @@ // Externs //---------------------------------------------------------------------------- -extern Module cellSpurs; +extern Module<> cellSpurs; //---------------------------------------------------------------------------- // Function prototypes @@ -4205,7 +4205,7 @@ s32 cellSpursSemaphoreGetTasksetAddress() return CELL_OK; } -Module cellSpurs("cellSpurs", []() +Module<> cellSpurs("cellSpurs", []() { // Core REG_FUNC(cellSpurs, cellSpursInitialize); diff --git a/rpcs3/Emu/SysCalls/Modules/cellSpursJq.cpp b/rpcs3/Emu/SysCalls/Modules/cellSpursJq.cpp index 195d42154..1a943ebcc 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSpursJq.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSpursJq.cpp @@ -10,7 +10,7 @@ #include "cellSpurs.h" #include "cellSpursJq.h" -extern Module cellSpursJq; +extern Module<> cellSpursJq; s32 cellSpursJobQueueAttributeInitialize() { @@ -390,7 +390,7 @@ s32 cellSpursJobQueueUnsetExceptionEventHandler() return CELL_OK; } -Module cellSpursJq("cellSpursJq", []() +Module<> cellSpursJq("cellSpursJq", []() { REG_FUNC(cellSpursJq, cellSpursJobQueueAttributeInitialize); REG_FUNC(cellSpursJq, cellSpursJobQueueAttributeSetMaxGrab); diff --git a/rpcs3/Emu/SysCalls/Modules/cellSpursSpu.cpp b/rpcs3/Emu/SysCalls/Modules/cellSpursSpu.cpp index b61598727..2d313cda2 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSpursSpu.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSpursSpu.cpp @@ -15,7 +15,7 @@ // Externs //---------------------------------------------------------------------------- -extern Module cellSpurs; +extern Module<> cellSpurs; //---------------------------------------------------------------------------- // Function prototypes diff --git a/rpcs3/Emu/SysCalls/Modules/cellSsl.cpp b/rpcs3/Emu/SysCalls/Modules/cellSsl.cpp index dc39b2fb7..eaac5d776 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSsl.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSsl.cpp @@ -2,7 +2,7 @@ #include "Emu/Memory/Memory.h" #include "Emu/SysCalls/Modules.h" -extern Module cellSsl; +extern Module<> cellSsl; s32 cellSslInit() { @@ -88,7 +88,7 @@ s32 cellSslCertGetMd5Fingerprint() return CELL_OK; } -Module cellSsl("cellSsl", []() +Module<> cellSsl("cellSsl", []() { REG_FUNC(cellSsl, cellSslInit); REG_FUNC(cellSsl, cellSslEnd); diff --git a/rpcs3/Emu/SysCalls/Modules/cellStorage.cpp b/rpcs3/Emu/SysCalls/Modules/cellStorage.cpp index 90a49f9f8..07ce05e6a 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellStorage.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellStorage.cpp @@ -2,7 +2,7 @@ #include "Emu/Memory/Memory.h" #include "Emu/SysCalls/Modules.h" -extern Module cellSysutil; +extern Module<> cellSysutil; s32 cellStorageDataImportMove() { diff --git a/rpcs3/Emu/SysCalls/Modules/cellSubdisplay.cpp b/rpcs3/Emu/SysCalls/Modules/cellSubdisplay.cpp index 569fca2bf..a3ad66d2f 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSubdisplay.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSubdisplay.cpp @@ -4,7 +4,7 @@ #include "cellSubdisplay.h" -extern Module cellSubdisplay; +extern Module<> cellSubdisplay; s32 cellSubDisplayInit() { @@ -74,7 +74,7 @@ s32 cellSubDisplayGetPeerList() return CELL_OK; } -Module cellSubdisplay("cellSubdisplay", []() +Module<> cellSubdisplay("cellSubdisplay", []() { REG_FUNC(cellSubdisplay, cellSubDisplayInit); REG_FUNC(cellSubdisplay, cellSubDisplayEnd); diff --git a/rpcs3/Emu/SysCalls/Modules/cellSync.cpp b/rpcs3/Emu/SysCalls/Modules/cellSync.cpp index 8fc1d4cb7..3faae111a 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSync.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSync.cpp @@ -9,7 +9,7 @@ #include "Emu/Event.h" #include "cellSync.h" -extern Module cellSync; +extern Module<> cellSync; s32 cellSyncMutexInitialize(vm::ptr mutex) { @@ -1594,7 +1594,7 @@ s32 _cellSyncLFQueueDetachLv2EventQueue(vm::ptr spus, u32 num, vm::ptr cellSync("cellSync", []() { // setup error handler cellSync.on_error = [](s64 value, ModuleFunc* func) diff --git a/rpcs3/Emu/SysCalls/Modules/cellSync2.cpp b/rpcs3/Emu/SysCalls/Modules/cellSync2.cpp index c5ebc8911..4f5f4efee 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSync2.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSync2.cpp @@ -5,7 +5,17 @@ #include "cellSync2.h" -extern Module cellSync2; +struct Sync2Instance +{ + CellSync2CallerThreadType gCellSync2CallerThreadTypePpuThread; + CellSync2Notifier gCellSync2NotifierPpuThread; + CellSync2CallerThreadType gCellSync2CallerThreadTypePpuFiber; + CellSync2Notifier gCellSync2NotifierPpuFiber; + CellSync2Notifier gCellSync2NotifierSpursTask; + CellSync2Notifier gCellSync2NotifierSpursJobQueueJob; +}; + +extern Module cellSync2; s32 _cellSync2MutexAttributeInitialize(vm::ptr attr, u32 sdkVersion) { @@ -249,14 +259,14 @@ s32 cellSync2QueueGetDepth() return CELL_OK; } -Module cellSync2("cellSync2", []() +Module cellSync2("cellSync2", []() { - //REG_VARIABLE(cellSync2, gCellSync2CallerThreadTypePpuThread); - //REG_VARIABLE(cellSync2, gCellSync2NotifierPpuThread); - //REG_VARIABLE(cellSync2, gCellSync2CallerThreadTypePpuFiber); - //REG_VARIABLE(cellSync2, gCellSync2NotifierPpuFiber); - //REG_VARIABLE(cellSync2, gCellSync2NotifierSpursTask); - //REG_VARIABLE(cellSync2, gCellSync2NotifierSpursJobQueueJob); + REG_VARIABLE(cellSync2, gCellSync2CallerThreadTypePpuThread); + REG_VARIABLE(cellSync2, gCellSync2NotifierPpuThread); + REG_VARIABLE(cellSync2, gCellSync2CallerThreadTypePpuFiber); + REG_VARIABLE(cellSync2, gCellSync2NotifierPpuFiber); + REG_VARIABLE(cellSync2, gCellSync2NotifierSpursTask); + REG_VARIABLE(cellSync2, gCellSync2NotifierSpursJobQueueJob); REG_FUNC(cellSync2, _cellSync2MutexAttributeInitialize); REG_FUNC(cellSync2, cellSync2MutexEstimateBufferSize); diff --git a/rpcs3/Emu/SysCalls/Modules/cellSync2.h b/rpcs3/Emu/SysCalls/Modules/cellSync2.h index 50538dc57..01a430df4 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSync2.h +++ b/rpcs3/Emu/SysCalls/Modules/cellSync2.h @@ -77,3 +77,21 @@ struct CellSync2QueueAttribute }; CHECK_SIZE(CellSync2QueueAttribute, 128); + +struct CellSync2CallerThreadType +{ + be_t threadTypeId; + vm::bptr self; + vm::bptr waitSignal; + vm::bptr, s32, u64, u64)> allocateSignalReceiver; + vm::bptr freeSignalReceiver; + be_t spinWaitNanoSec; + be_t callbackArg; +}; + +struct CellSync2Notifier +{ + be_t threadTypeId; + vm::bptr sendSignal; + be_t callbackArg; +}; diff --git a/rpcs3/Emu/SysCalls/Modules/cellSysconf.cpp b/rpcs3/Emu/SysCalls/Modules/cellSysconf.cpp index 7988c5312..9a3a55f78 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSysconf.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSysconf.cpp @@ -2,7 +2,7 @@ #include "Emu/Memory/Memory.h" #include "Emu/SysCalls/Modules.h" -extern Module cellSysconf; +extern Module<> cellSysconf; s32 cellSysconfAbort() { @@ -21,13 +21,13 @@ s32 cellSysconfBtGetDeviceList() void cellSysutil_Sysconf_init() { - extern Module cellSysutil; + extern Module<> cellSysutil; REG_FUNC(cellSysutil, cellSysconfAbort); REG_FUNC(cellSysutil, cellSysconfOpen); } -Module cellSysconf("cellSysconf", []() +Module<> cellSysconf("cellSysconf", []() { REG_FUNC(cellSysconf, cellSysconfBtGetDeviceList); }); diff --git a/rpcs3/Emu/SysCalls/Modules/cellSysmodule.cpp b/rpcs3/Emu/SysCalls/Modules/cellSysmodule.cpp index db958914f..cf7b86c5a 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSysmodule.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSysmodule.cpp @@ -4,7 +4,7 @@ #include "Emu/SysCalls/ModuleManager.h" #include "Emu/SysCalls/Modules.h" -extern Module cellSysmodule; +extern Module<> cellSysmodule; enum { @@ -156,7 +156,7 @@ s32 cellSysmoduleLoadModule(u16 id) return CELL_SYSMODULE_ERROR_UNKNOWN; } - if (Module* m = Emu.GetModuleManager().GetModuleById(id)) + if (Module<>* m = Emu.GetModuleManager().GetModuleById(id)) { // CELL_SYSMODULE_ERROR_DUPLICATED shouldn't be returned m->Load(); @@ -174,7 +174,7 @@ s32 cellSysmoduleUnloadModule(u16 id) return CELL_SYSMODULE_ERROR_UNKNOWN; } - if (Module* m = Emu.GetModuleManager().GetModuleById(id)) + if (Module<>* m = Emu.GetModuleManager().GetModuleById(id)) { if (!m->IsLoaded()) { @@ -197,7 +197,7 @@ s32 cellSysmoduleIsLoaded(u16 id) return CELL_SYSMODULE_ERROR_UNKNOWN; } - if (Module* m = Emu.GetModuleManager().GetModuleById(id)) + if (Module<>* m = Emu.GetModuleManager().GetModuleById(id)) { if (!m->IsLoaded()) { @@ -209,7 +209,7 @@ s32 cellSysmoduleIsLoaded(u16 id) return CELL_SYSMODULE_LOADED; } -Module cellSysmodule("cellSysmodule", []() +Module<> cellSysmodule("cellSysmodule", []() { REG_FUNC(cellSysmodule, cellSysmoduleInitialize); REG_FUNC(cellSysmodule, cellSysmoduleFinalize); diff --git a/rpcs3/Emu/SysCalls/Modules/cellSysutil.cpp b/rpcs3/Emu/SysCalls/Modules/cellSysutil.cpp index bfd41f5d7..9003a933e 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSysutil.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSysutil.cpp @@ -9,7 +9,7 @@ #include "Emu/FS/VFS.h" #include "cellSysutil.h" -extern Module cellSysutil; +extern Module<> cellSysutil; std::unique_ptr g_sysutil; @@ -352,7 +352,7 @@ extern void cellSysutil_WebBrowser_init(); extern void cellSysutil_AudioOut_init(); extern void cellSysutil_VideoOut_init(); -Module cellSysutil("cellSysutil", []() +Module<> cellSysutil("cellSysutil", []() { g_sysutil = std::make_unique(); diff --git a/rpcs3/Emu/SysCalls/Modules/cellSysutilAp.cpp b/rpcs3/Emu/SysCalls/Modules/cellSysutilAp.cpp index a5277ffb3..bf1db4827 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSysutilAp.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSysutilAp.cpp @@ -2,7 +2,7 @@ #include "Emu/Memory/Memory.h" #include "Emu/SysCalls/Modules.h" -extern Module cellSysutilAp; +extern Module<> cellSysutilAp; // Return Codes enum @@ -35,7 +35,7 @@ s32 cellSysutilApOff() return CELL_OK; } -Module cellSysutilAp("cellSysutilAp", []() +Module<> cellSysutilAp("cellSysutilAp", []() { REG_FUNC(cellSysutilAp, cellSysutilApGetRequiredMemSize); REG_FUNC(cellSysutilAp, cellSysutilApOn); diff --git a/rpcs3/Emu/SysCalls/Modules/cellSysutilAvc.cpp b/rpcs3/Emu/SysCalls/Modules/cellSysutilAvc.cpp index 7e25b0105..b6d132419 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSysutilAvc.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSysutilAvc.cpp @@ -2,7 +2,7 @@ #include "Emu/Memory/Memory.h" #include "Emu/SysCalls/Modules.h" -extern Module cellSysutilAvc; +extern Module<> cellSysutilAvc; s32 cellSysutilAvcByeRequest() { @@ -218,7 +218,7 @@ s32 cellSysutilAvcExtGetWindowShowStatus() void cellSysutil_SysutilAvc_init() { - extern Module cellSysutil; + extern Module<> cellSysutil; REG_FUNC(cellSysutil, cellSysutilAvcByeRequest); REG_FUNC(cellSysutil, cellSysutilAvcCancelByeRequest); @@ -242,7 +242,7 @@ void cellSysutil_SysutilAvc_init() REG_FUNC(cellSysutil, cellSysutilAvcUnloadAsync); } -Module cellSysutilAvc("cellSysutilAvc", []() +Module<> cellSysutilAvc("cellSysutilAvc", []() { REG_FUNC(cellSysutilAvc, cellSysutilAvcExtInitOptionParam); REG_FUNC(cellSysutilAvc, cellSysutilAvcExtSetHideNamePlate); diff --git a/rpcs3/Emu/SysCalls/Modules/cellSysutilAvc2.cpp b/rpcs3/Emu/SysCalls/Modules/cellSysutilAvc2.cpp index 57c3661b7..f1df9939e 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSysutilAvc2.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSysutilAvc2.cpp @@ -7,7 +7,7 @@ #include "sceNp2.h" #include "cellSysutilAvc2.h" -extern Module cellSysutilAvc2; +extern Module<> cellSysutilAvc2; s32 cellSysutilAvc2GetPlayerInfo() { @@ -334,7 +334,7 @@ s32 cellSysutilAvc2GetWindowPosition() } -Module cellSysutilAvc2("cellSysutilAvc2", []() +Module<> cellSysutilAvc2("cellSysutilAvc2", []() { REG_FUNC(cellSysutilAvc2, cellSysutilAvc2GetPlayerInfo); REG_FUNC(cellSysutilAvc2, cellSysutilAvc2JoinChat); diff --git a/rpcs3/Emu/SysCalls/Modules/cellSysutilMisc.cpp b/rpcs3/Emu/SysCalls/Modules/cellSysutilMisc.cpp index 3800b104a..fead88412 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSysutilMisc.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSysutilMisc.cpp @@ -3,7 +3,7 @@ #include "Emu/Memory/Memory.h" #include "Emu/SysCalls/Modules.h" -extern Module cellSysutilMisc; +extern Module<> cellSysutilMisc; // License areas enum @@ -33,7 +33,7 @@ s32 cellSysutilGetLicenseArea() } } -Module cellSysutilMisc("cellSysutilMisc", []() +Module<> cellSysutilMisc("cellSysutilMisc", []() { REG_FUNC(cellSysutilMisc, cellSysutilGetLicenseArea); }); diff --git a/rpcs3/Emu/SysCalls/Modules/cellUsbd.cpp b/rpcs3/Emu/SysCalls/Modules/cellUsbd.cpp index decd6f680..11b2226ee 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellUsbd.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellUsbd.cpp @@ -4,7 +4,7 @@ #include "Emu/SysCalls/Modules.h" #include "cellUsbd.h" -extern Module cellUsbd; +extern Module<> cellUsbd; s32 cellUsbdInit() { @@ -152,7 +152,7 @@ s32 cellUsbdFreeMemory() return CELL_OK; } -Module cellUsbd("cellUsbd", []() +Module<> cellUsbd("cellUsbd", []() { REG_FUNC(cellUsbd, cellUsbdInit); REG_FUNC(cellUsbd, cellUsbdEnd); diff --git a/rpcs3/Emu/SysCalls/Modules/cellUsbpspcm.cpp b/rpcs3/Emu/SysCalls/Modules/cellUsbpspcm.cpp index c69e0cb85..30a9fe71d 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellUsbpspcm.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellUsbpspcm.cpp @@ -2,7 +2,7 @@ #include "Emu/Memory/Memory.h" #include "Emu/SysCalls/Modules.h" -extern Module cellUsbPspcm; +extern Module<> cellUsbPspcm; // Return Codes enum @@ -183,7 +183,7 @@ s32 cellUsbPspcmCancelWaitData() return CELL_OK; } -Module cellUsbPspcm("cellUsbPspcm", []() +Module<> cellUsbPspcm("cellUsbPspcm", []() { REG_FUNC(cellUsbPspcm, cellUsbPspcmInit); REG_FUNC(cellUsbPspcm, cellUsbPspcmEnd); diff --git a/rpcs3/Emu/SysCalls/Modules/cellUserInfo.cpp b/rpcs3/Emu/SysCalls/Modules/cellUserInfo.cpp index dce57c877..4907dca4a 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellUserInfo.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellUserInfo.cpp @@ -7,7 +7,7 @@ #include "Emu/FS/vfsFileBase.h" #include "cellUserInfo.h" -extern Module cellUserInfo; +extern Module<> cellUserInfo; s32 cellUserInfoGetStat(u32 id, vm::ptr stat) { @@ -73,7 +73,7 @@ s32 cellUserInfoGetList(vm::ptr listNum, vm::ptr list return CELL_OK; } -Module cellUserInfo("cellUserInfo", []() +Module<> cellUserInfo("cellUserInfo", []() { REG_FUNC(cellUserInfo, cellUserInfoGetStat); REG_FUNC(cellUserInfo, cellUserInfoSelectUser_ListType); diff --git a/rpcs3/Emu/SysCalls/Modules/cellVdec.cpp b/rpcs3/Emu/SysCalls/Modules/cellVdec.cpp index c9bf9ad67..fae09d405 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellVdec.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellVdec.cpp @@ -17,7 +17,7 @@ extern "C" #include "cellPamf.h" #include "cellVdec.h" -extern Module cellVdec; +extern Module<> cellVdec; VideoDecoder::VideoDecoder(s32 type, u32 profile, u32 addr, u32 size, vm::ptr func, u32 arg) : type(type) @@ -948,7 +948,7 @@ s32 cellVdecSetFrameRate(u32 handle, CellVdecFrameRate frc) return CELL_OK; } -Module cellVdec("cellVdec", []() +Module<> cellVdec("cellVdec", []() { //REG_VARIABLE(cellVdec, _cell_vdec_prx_ver); // 0x085a7ecb diff --git a/rpcs3/Emu/SysCalls/Modules/cellVideoExport.cpp b/rpcs3/Emu/SysCalls/Modules/cellVideoExport.cpp index b87d560c8..c70757f56 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellVideoExport.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellVideoExport.cpp @@ -2,7 +2,7 @@ #include "Emu/Memory/Memory.h" #include "Emu/SysCalls/Modules.h" -extern Module cellVideoExport; +extern Module<> cellVideoExport; s32 cellVideoExportProgress() { @@ -35,7 +35,7 @@ s32 cellVideoExportFinalize() } -Module cellVideoExport("cellVideoExport", []() +Module<> cellVideoExport("cellVideoExport", []() { REG_FUNC(cellVideoExport, cellVideoExportProgress); REG_FUNC(cellVideoExport, cellVideoExportInitialize2); diff --git a/rpcs3/Emu/SysCalls/Modules/cellVideoOut.cpp b/rpcs3/Emu/SysCalls/Modules/cellVideoOut.cpp index f1e7329f6..decb36196 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellVideoOut.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellVideoOut.cpp @@ -7,7 +7,7 @@ #include "Emu/RSX/GSManager.h" #include "cellVideoOut.h" -extern Module cellSysutil; +extern Module<> cellSysutil; s32 cellVideoOutGetState(u32 videoOut, u32 deviceIndex, vm::ptr state) { diff --git a/rpcs3/Emu/SysCalls/Modules/cellVideoUpload.cpp b/rpcs3/Emu/SysCalls/Modules/cellVideoUpload.cpp index 3bf7b3ce3..a6d7c3862 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellVideoUpload.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellVideoUpload.cpp @@ -2,14 +2,14 @@ #include "Emu/Memory/Memory.h" #include "Emu/SysCalls/Modules.h" -extern Module cellVideoUpload; +extern Module<> cellVideoUpload; s32 cellVideoUploadInitialize() { throw EXCEPTION(""); } -Module cellVideoUpload("cellVideoUpload", []() +Module<> cellVideoUpload("cellVideoUpload", []() { REG_FUNC(cellVideoUpload, cellVideoUploadInitialize); }); diff --git a/rpcs3/Emu/SysCalls/Modules/cellVoice.cpp b/rpcs3/Emu/SysCalls/Modules/cellVoice.cpp index 0195052ed..5083aa682 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellVoice.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellVoice.cpp @@ -3,7 +3,7 @@ #include "Emu/System.h" #include "Emu/SysCalls/Modules.h" -extern Module cellVoice; +extern Module<> cellVoice; // Error Codes enum @@ -237,7 +237,7 @@ s32 cellVoiceDebugTopology() return CELL_OK; } -Module cellVoice("cellVoice", []() +Module<> cellVoice("cellVoice", []() { REG_FUNC(cellVoice, cellVoiceConnectIPortToOPort); REG_FUNC(cellVoice, cellVoiceCreateNotifyEventQueue); diff --git a/rpcs3/Emu/SysCalls/Modules/cellVpost.cpp b/rpcs3/Emu/SysCalls/Modules/cellVpost.cpp index dfb113527..9989b12ff 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellVpost.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellVpost.cpp @@ -11,7 +11,7 @@ extern "C" #include "cellVpost.h" -extern Module cellVpost; +extern Module<> cellVpost; s32 cellVpostQueryAttr(vm::cptr cfgParam, vm::ptr attr) { @@ -137,7 +137,7 @@ s32 cellVpostExec(u32 handle, vm::cptr inPicBuff, vm::cptr cellVpost("cellVpost", []() { REG_FUNC(cellVpost, cellVpostQueryAttr); REG_FUNC(cellVpost, cellVpostOpen); diff --git a/rpcs3/Emu/SysCalls/Modules/cellWebBrowser.cpp b/rpcs3/Emu/SysCalls/Modules/cellWebBrowser.cpp index 1b429b741..04cfebfa8 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellWebBrowser.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellWebBrowser.cpp @@ -4,7 +4,7 @@ #include "cellWebBrowser.h" -extern Module cellSysutil; +extern Module<> cellSysutil; s32 cellWebBrowserActivate() { diff --git a/rpcs3/Emu/SysCalls/Modules/libmixer.cpp b/rpcs3/Emu/SysCalls/Modules/libmixer.cpp index 8748d2440..f2e9f82a3 100644 --- a/rpcs3/Emu/SysCalls/Modules/libmixer.cpp +++ b/rpcs3/Emu/SysCalls/Modules/libmixer.cpp @@ -9,7 +9,7 @@ #include "cellAudio.h" #include "libmixer.h" -extern Module libmixer; +extern Module<> libmixer; SurMixerConfig g_surmx; @@ -614,7 +614,7 @@ float cellSurMixerUtilNoteToRatio(u8 refNote, u8 note) throw EXCEPTION(""); } -Module libmixer("libmixer", []() +Module<> libmixer("libmixer", []() { g_surmx.audio_port = ~0; diff --git a/rpcs3/Emu/SysCalls/Modules/libsnd3.cpp b/rpcs3/Emu/SysCalls/Modules/libsnd3.cpp index c3c23c74a..74e5f84fb 100644 --- a/rpcs3/Emu/SysCalls/Modules/libsnd3.cpp +++ b/rpcs3/Emu/SysCalls/Modules/libsnd3.cpp @@ -290,7 +290,7 @@ s32 cellSnd3SMFGetKeyOnID(u32 smfID, u32 midiChannel, vm::ptr keyOnID) } -Module libsnd3("libsnd3", []() +Module<> libsnd3("libsnd3", []() { REG_SUB(libsnd3,, cellSnd3Init); REG_SUB(libsnd3,, cellSnd3Exit); diff --git a/rpcs3/Emu/SysCalls/Modules/libsnd3.h b/rpcs3/Emu/SysCalls/Modules/libsnd3.h index 80d8dc8c8..978d8b9a7 100644 --- a/rpcs3/Emu/SysCalls/Modules/libsnd3.h +++ b/rpcs3/Emu/SysCalls/Modules/libsnd3.h @@ -52,4 +52,4 @@ struct CellSnd3RequestQueueCtx be_t rearQueueSize; }; -extern Module libsnd3; +extern Module<> libsnd3; diff --git a/rpcs3/Emu/SysCalls/Modules/libsynth2.cpp b/rpcs3/Emu/SysCalls/Modules/libsynth2.cpp index 86b91edda..4e3b65158 100644 --- a/rpcs3/Emu/SysCalls/Modules/libsynth2.cpp +++ b/rpcs3/Emu/SysCalls/Modules/libsynth2.cpp @@ -104,7 +104,7 @@ u16 cellSoundSynth2Pitch2Note(u16 center_note, u16 center_fine, u16 pitch) } -Module libsynth2("libsynth2", []() +Module<> libsynth2("libsynth2", []() { REG_SUB(libsynth2,, cellSoundSynth2Config); REG_SUB(libsynth2,, cellSoundSynth2Init); diff --git a/rpcs3/Emu/SysCalls/Modules/libsynth2.h b/rpcs3/Emu/SysCalls/Modules/libsynth2.h index 2ebdebda4..6b972ad7c 100644 --- a/rpcs3/Emu/SysCalls/Modules/libsynth2.h +++ b/rpcs3/Emu/SysCalls/Modules/libsynth2.h @@ -18,4 +18,4 @@ struct CellSoundSynth2EffectAttr be_t feedback; }; -extern Module libsynth2; +extern Module<> libsynth2; diff --git a/rpcs3/Emu/SysCalls/Modules/sceNp.cpp b/rpcs3/Emu/SysCalls/Modules/sceNp.cpp index c926c7c38..5accb8e0d 100644 --- a/rpcs3/Emu/SysCalls/Modules/sceNp.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sceNp.cpp @@ -11,7 +11,7 @@ #include "Crypto/unedat.h" #include "sceNp.h" -extern Module sceNp; +extern Module<> sceNp; s32 sceNpInit(u32 poolsize, vm::ptr poolptr) { @@ -1521,7 +1521,7 @@ s32 _Z32_sce_np_sysutil_cxml_prepare_docPN16sysutil_cxmlutil11FixedMemoryERN4cxm } -Module sceNp("sceNp", []() +Module<> sceNp("sceNp", []() { REG_FUNC(sceNp, sceNpInit); REG_FUNC(sceNp, sceNpTerm); diff --git a/rpcs3/Emu/SysCalls/Modules/sceNp2.cpp b/rpcs3/Emu/SysCalls/Modules/sceNp2.cpp index baffd4f9c..197bde3c1 100644 --- a/rpcs3/Emu/SysCalls/Modules/sceNp2.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sceNp2.cpp @@ -5,7 +5,7 @@ #include "sceNp.h" #include "sceNp2.h" -extern Module sceNp2; +extern Module<> sceNp2; s32 sceNp2Init(u32 poolsize, vm::ptr poolptr) { @@ -384,7 +384,7 @@ s32 sceNpMatching2RegisterRoomMessageCallback() } -Module sceNp2("sceNp2", []() +Module<> sceNp2("sceNp2", []() { REG_FUNC(sceNp2, sceNpMatching2DestroyContext); REG_FUNC(sceNp2, sceNpMatching2LeaveLobby); diff --git a/rpcs3/Emu/SysCalls/Modules/sceNpClans.cpp b/rpcs3/Emu/SysCalls/Modules/sceNpClans.cpp index e046f3403..09ee7a4b0 100644 --- a/rpcs3/Emu/SysCalls/Modules/sceNpClans.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sceNpClans.cpp @@ -6,7 +6,7 @@ #include "sceNp.h" #include "sceNpClans.h" -extern Module sceNpClans; +extern Module<> sceNpClans; s32 sceNpClansInit(vm::ptr commId, vm::ptr passphrase, vm::ptr pool, vm::ptr poolSize, u32 flags) { @@ -255,7 +255,7 @@ s32 sceNpClansRemoveChallenge() return CELL_OK; } -Module sceNpClans("sceNpClans", []() +Module<> sceNpClans("sceNpClans", []() { REG_FUNC(sceNpClans, sceNpClansInit); REG_FUNC(sceNpClans, sceNpClansTerm); diff --git a/rpcs3/Emu/SysCalls/Modules/sceNpCommerce2.cpp b/rpcs3/Emu/SysCalls/Modules/sceNpCommerce2.cpp index 06623bf0f..0ae6ecf83 100644 --- a/rpcs3/Emu/SysCalls/Modules/sceNpCommerce2.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sceNpCommerce2.cpp @@ -4,7 +4,7 @@ #include "sceNpCommerce2.h" -extern Module sceNpCommerce2; +extern Module<> sceNpCommerce2; s32 sceNpCommerce2ExecuteStoreBrowse() { @@ -315,7 +315,7 @@ s32 sceNpCommerce2DoServiceListFinishAsync() throw EXCEPTION(""); } -Module sceNpCommerce2("sceNpCommerce2", []() +Module<> sceNpCommerce2("sceNpCommerce2", []() { REG_FUNC(sceNpCommerce2, sceNpCommerce2ExecuteStoreBrowse); REG_FUNC(sceNpCommerce2, sceNpCommerce2GetStoreBrowseUserdata); diff --git a/rpcs3/Emu/SysCalls/Modules/sceNpSns.cpp b/rpcs3/Emu/SysCalls/Modules/sceNpSns.cpp index ec50fc3a4..5ebfbbc0b 100644 --- a/rpcs3/Emu/SysCalls/Modules/sceNpSns.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sceNpSns.cpp @@ -3,7 +3,7 @@ #include "sceNpSns.h" -extern Module sceNpSns; +extern Module<> sceNpSns; s32 sceNpSnsFbInit(vm::ptr params) { @@ -66,7 +66,7 @@ s32 sceNpSnsFbLoadThrottle() } -Module sceNpSns("sceNpSns", []() +Module<> sceNpSns("sceNpSns", []() { REG_FUNC(sceNpSns, sceNpSnsFbInit); REG_FUNC(sceNpSns, sceNpSnsFbTerm); diff --git a/rpcs3/Emu/SysCalls/Modules/sceNpTrophy.cpp b/rpcs3/Emu/SysCalls/Modules/sceNpTrophy.cpp index 489d5fa94..976d578b2 100644 --- a/rpcs3/Emu/SysCalls/Modules/sceNpTrophy.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sceNpTrophy.cpp @@ -14,7 +14,7 @@ #include "sceNp.h" #include "sceNpTrophy.h" -extern Module sceNpTrophy; +extern Module<> sceNpTrophy; struct trophy_context_t { @@ -455,7 +455,7 @@ s32 sceNpTrophyGetTrophyIcon(u32 context, u32 handle, s32 trophyId, vm::ptr sceNpTrophy("sceNpTrophy", []() { REG_FUNC(sceNpTrophy, sceNpTrophyGetGameProgress); REG_FUNC(sceNpTrophy, sceNpTrophyRegisterContext); diff --git a/rpcs3/Emu/SysCalls/Modules/sceNpTus.cpp b/rpcs3/Emu/SysCalls/Modules/sceNpTus.cpp index 10abfcbd4..6bd4f62ac 100644 --- a/rpcs3/Emu/SysCalls/Modules/sceNpTus.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sceNpTus.cpp @@ -5,7 +5,7 @@ #include "sceNp.h" #include "sceNpTus.h" -extern Module sceNpTus; +extern Module<> sceNpTus; s32 sceNpTusInit() { @@ -333,7 +333,7 @@ s32 sceNpTusDeleteMultiSlotDataVUserAsync() return CELL_OK; } -Module sceNpTus("sceNpTus", []() +Module<> sceNpTus("sceNpTus", []() { REG_FUNC(sceNpTus, sceNpTusInit); REG_FUNC(sceNpTus, sceNpTusTerm); diff --git a/rpcs3/Emu/SysCalls/Modules/sceNpUtil.cpp b/rpcs3/Emu/SysCalls/Modules/sceNpUtil.cpp index fa8802bff..a0ad31b01 100644 --- a/rpcs3/Emu/SysCalls/Modules/sceNpUtil.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sceNpUtil.cpp @@ -5,7 +5,7 @@ #include "sceNp.h" #include "sceNpUtil.h" -extern Module sceNpUtil; +extern Module<> sceNpUtil; s32 sceNpUtilBandwidthTestInitStart(u32 prio, size_t stack) { @@ -31,7 +31,7 @@ s32 sceNpUtilBandwidthTestAbort() return CELL_OK; } -Module sceNpUtil("sceNpUtil", []() +Module<> sceNpUtil("sceNpUtil", []() { REG_FUNC(sceNpUtil, sceNpUtilBandwidthTestInitStart); REG_FUNC(sceNpUtil, sceNpUtilBandwidthTestShutdown); diff --git a/rpcs3/Emu/SysCalls/Modules/sysPrxForUser.cpp b/rpcs3/Emu/SysCalls/Modules/sysPrxForUser.cpp index 94b59b2ce..effa8325e 100644 --- a/rpcs3/Emu/SysCalls/Modules/sysPrxForUser.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sysPrxForUser.cpp @@ -8,7 +8,7 @@ #include "Emu/SysCalls/lv2/sys_process.h" #include "sysPrxForUser.h" -extern Module sysPrxForUser; +extern Module<> sysPrxForUser; extern u64 get_system_time(); @@ -167,7 +167,7 @@ extern void sysPrxForUser_sys_spu_init(); extern void sysPrxForUser_sys_game_init(); extern void sysPrxForUser_sys_libc_init(); -Module sysPrxForUser("sysPrxForUser", []() +Module<> sysPrxForUser("sysPrxForUser", []() { g_tls_start = 0; for (auto& v : g_tls_owners) diff --git a/rpcs3/Emu/SysCalls/Modules/sys_game.cpp b/rpcs3/Emu/SysCalls/Modules/sys_game.cpp index aed67378f..e165e8e13 100644 --- a/rpcs3/Emu/SysCalls/Modules/sys_game.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sys_game.cpp @@ -6,7 +6,7 @@ #include "Emu/FS/VFS.h" #include "sysPrxForUser.h" -extern Module sysPrxForUser; +extern Module<> sysPrxForUser; void sys_game_process_exitspawn(vm::cptr path, u32 argv_addr, u32 envp_addr, u32 data_addr, u32 data_size, u32 prio, u64 flags) { diff --git a/rpcs3/Emu/SysCalls/Modules/sys_heap.cpp b/rpcs3/Emu/SysCalls/Modules/sys_heap.cpp index a9b6ddbbf..b3e0aafd3 100644 --- a/rpcs3/Emu/SysCalls/Modules/sys_heap.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sys_heap.cpp @@ -6,7 +6,7 @@ #include "sysPrxForUser.h" -extern Module sysPrxForUser; +extern Module<> sysPrxForUser; struct HeapInfo { diff --git a/rpcs3/Emu/SysCalls/Modules/sys_io.cpp b/rpcs3/Emu/SysCalls/Modules/sys_io.cpp index dd7f0afd0..eb7888f15 100644 --- a/rpcs3/Emu/SysCalls/Modules/sys_io.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sys_io.cpp @@ -1,7 +1,7 @@ #include "stdafx.h" #include "Emu/SysCalls/Modules.h" -extern Module sys_io; +extern Module<> sys_io; extern void cellPad_init(); extern void cellKb_init(); @@ -39,7 +39,7 @@ s32 sys_config_unregister_service() } -Module sys_io("sys_io", []() +Module<> sys_io("sys_io", []() { cellPad_init(); cellKb_init(); diff --git a/rpcs3/Emu/SysCalls/Modules/sys_libc.cpp b/rpcs3/Emu/SysCalls/Modules/sys_libc.cpp index 6264fc697..7911927c6 100644 --- a/rpcs3/Emu/SysCalls/Modules/sys_libc.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sys_libc.cpp @@ -5,7 +5,7 @@ #include "Emu/SysCalls/Modules.h" #include "Emu/Cell/PPUInstrTable.h" -extern Module sys_libc; +extern Module<> sys_libc; std::string ps3_fmt(PPUThread& context, vm::cptr fmt, u32 g_count, u32 f_count, u32 v_count) { @@ -160,7 +160,7 @@ namespace sys_libc_func } } -extern Module sysPrxForUser; +extern Module<> sysPrxForUser; vm::ptr _sys_memset(vm::ptr dst, s32 value, u32 size) { @@ -413,7 +413,7 @@ void sysPrxForUser_sys_libc_init() REG_FUNC(sysPrxForUser, _sys_qsort); } -Module sys_libc("sys_libc", []() +Module<> sys_libc("sys_libc", []() { using namespace PPU_instr; diff --git a/rpcs3/Emu/SysCalls/Modules/sys_lv2dbg.cpp b/rpcs3/Emu/SysCalls/Modules/sys_lv2dbg.cpp index 708d4e913..c2c0fbf4b 100644 --- a/rpcs3/Emu/SysCalls/Modules/sys_lv2dbg.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sys_lv2dbg.cpp @@ -6,7 +6,7 @@ #include "sys_lv2dbg.h" -extern Module sys_lv2dbg; +extern Module<> sys_lv2dbg; s32 sys_dbg_read_ppu_thread_context(u64 id, vm::ptr ppu_context) { @@ -190,7 +190,7 @@ s32 sys_dbg_set_mask_to_ppu_exception_handler(u64 mask, u64 flags) throw EXCEPTION(""); } -Module sys_lv2dbg("sys_lv2dbg", [] +Module<> sys_lv2dbg("sys_lv2dbg", [] { REG_FUNC(sys_lv2dbg, sys_dbg_read_ppu_thread_context); REG_FUNC(sys_lv2dbg, sys_dbg_read_spu_thread_context); diff --git a/rpcs3/Emu/SysCalls/Modules/sys_lwcond_.cpp b/rpcs3/Emu/SysCalls/Modules/sys_lwcond_.cpp index 3bf05a08a..79c30c6ed 100644 --- a/rpcs3/Emu/SysCalls/Modules/sys_lwcond_.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sys_lwcond_.cpp @@ -9,7 +9,7 @@ #include "Emu/SysCalls/lv2/sys_lwcond.h" #include "sysPrxForUser.h" -extern Module sysPrxForUser; +extern Module<> sysPrxForUser; s32 sys_lwcond_create(vm::ptr lwcond, vm::ptr lwmutex, vm::ptr attr) { diff --git a/rpcs3/Emu/SysCalls/Modules/sys_lwmutex_.cpp b/rpcs3/Emu/SysCalls/Modules/sys_lwmutex_.cpp index a9d9acf41..85ba7abeb 100644 --- a/rpcs3/Emu/SysCalls/Modules/sys_lwmutex_.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sys_lwmutex_.cpp @@ -8,7 +8,7 @@ #include "Emu/SysCalls/lv2/sys_lwmutex.h" #include "sysPrxForUser.h" -extern Module sysPrxForUser; +extern Module<> sysPrxForUser; s32 sys_lwmutex_create(vm::ptr lwmutex, vm::ptr attr) { diff --git a/rpcs3/Emu/SysCalls/Modules/sys_mempool.cpp b/rpcs3/Emu/SysCalls/Modules/sys_mempool.cpp index cb5c512a6..143df2f46 100644 --- a/rpcs3/Emu/SysCalls/Modules/sys_mempool.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sys_mempool.cpp @@ -6,7 +6,7 @@ #include "sysPrxForUser.h" -extern Module sysPrxForUser; +extern Module<> sysPrxForUser; using sys_mempool_t = u32; diff --git a/rpcs3/Emu/SysCalls/Modules/sys_mmapper_.cpp b/rpcs3/Emu/SysCalls/Modules/sys_mmapper_.cpp index 89c2fce1f..5a2c59c30 100644 --- a/rpcs3/Emu/SysCalls/Modules/sys_mmapper_.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sys_mmapper_.cpp @@ -6,7 +6,7 @@ #include "Emu/SysCalls/lv2/sys_mmapper.h" #include "sysPrxForUser.h" -extern Module sysPrxForUser; +extern Module<> sysPrxForUser; void sysPrxForUser_sys_mmapper_init() { diff --git a/rpcs3/Emu/SysCalls/Modules/sys_net.cpp b/rpcs3/Emu/SysCalls/Modules/sys_net.cpp index 0be717ad6..32dd47d4c 100644 --- a/rpcs3/Emu/SysCalls/Modules/sys_net.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sys_net.cpp @@ -15,7 +15,7 @@ #include #endif -extern Module libnet; +extern Module<> libnet; // We map host sockets to sequential IDs to return as FDs because syscalls using // socketselect(), etc. expect socket FDs to be under 1024. @@ -616,7 +616,7 @@ namespace sys_net // define additional macro for specific namespace #define REG_FUNC_(name) add_ppu_func(ModuleFunc(get_function_id(#name), 0, &libnet, #name, BIND_FUNC(sys_net::name))) -Module libnet("sys_net", []() +Module<> libnet("sys_net", []() { REG_FUNC_(accept); REG_FUNC_(bind); diff --git a/rpcs3/Emu/SysCalls/Modules/sys_ppu_thread_.cpp b/rpcs3/Emu/SysCalls/Modules/sys_ppu_thread_.cpp index 46cc660b7..2ac8abdac 100644 --- a/rpcs3/Emu/SysCalls/Modules/sys_ppu_thread_.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sys_ppu_thread_.cpp @@ -6,7 +6,7 @@ #include "Emu/SysCalls/lv2/sys_ppu_thread.h" #include "sysPrxForUser.h" -extern Module sysPrxForUser; +extern Module<> sysPrxForUser; s32 sys_ppu_thread_create(PPUThread& ppu, vm::ptr thread_id, u32 entry, u64 arg, s32 prio, u32 stacksize, u64 flags, vm::cptr threadname) { diff --git a/rpcs3/Emu/SysCalls/Modules/sys_prx_.cpp b/rpcs3/Emu/SysCalls/Modules/sys_prx_.cpp index 068264902..28b0ea046 100644 --- a/rpcs3/Emu/SysCalls/Modules/sys_prx_.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sys_prx_.cpp @@ -6,7 +6,7 @@ #include "Emu/SysCalls/lv2/sys_prx.h" #include "sysPrxForUser.h" -extern Module sysPrxForUser; +extern Module<> sysPrxForUser; s64 sys_prx_exitspawn_with_level() { diff --git a/rpcs3/Emu/SysCalls/Modules/sys_spinlock.cpp b/rpcs3/Emu/SysCalls/Modules/sys_spinlock.cpp index f1c7b8516..cc80543c9 100644 --- a/rpcs3/Emu/SysCalls/Modules/sys_spinlock.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sys_spinlock.cpp @@ -5,7 +5,7 @@ #include "sysPrxForUser.h" -extern Module sysPrxForUser; +extern Module<> sysPrxForUser; void sys_spinlock_initialize(vm::ptr> lock) { diff --git a/rpcs3/Emu/SysCalls/Modules/sys_spu_.cpp b/rpcs3/Emu/SysCalls/Modules/sys_spu_.cpp index 2521f38b3..fb6edbac4 100644 --- a/rpcs3/Emu/SysCalls/Modules/sys_spu_.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sys_spu_.cpp @@ -9,7 +9,7 @@ #include "Crypto/unself.h" #include "sysPrxForUser.h" -extern Module sysPrxForUser; +extern Module<> sysPrxForUser; extern u64 get_system_time(); diff --git a/rpcs3/Emu/SysCalls/lv2/sys_prx.cpp b/rpcs3/Emu/SysCalls/lv2/sys_prx.cpp index 085e9816c..72b8157e8 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_prx.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_prx.cpp @@ -53,7 +53,7 @@ s32 prx_load_module(std::string path, u64 flags, vm::ptr* module = Emu.GetModuleManager().GetModuleByName(module_.first.c_str()); if (!module) { diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index a4e67748e..544a227eb 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -129,8 +129,6 @@ void Emulator::Load() { m_status = Ready; - GetModuleManager().Init(); - if (!fs::is_file(m_path)) { m_status = Stopped; diff --git a/rpcs3/Loader/ELF64.cpp b/rpcs3/Loader/ELF64.cpp index dce872cdd..5d4661e96 100644 --- a/rpcs3/Loader/ELF64.cpp +++ b/rpcs3/Loader/ELF64.cpp @@ -309,6 +309,7 @@ namespace loader //store elf to memory vm::ps3::init(); + Emu.GetModuleManager().Init(); error_code res = alloc_memory(0); if (res != ok) @@ -418,7 +419,7 @@ namespace loader continue; } - Module* module = Emu.GetModuleManager().GetModuleByName(m.first.c_str()); + Module<>* module = Emu.GetModuleManager().GetModuleByName(m.first.c_str()); if (!module) { @@ -506,6 +507,8 @@ namespace loader ppu_thr_stop_data[1] = BLR(); Emu.SetCPUThreadStop(ppu_thr_stop_data.addr()); + Emu.GetModuleManager().Alloc(); + static const int branch_size = 8 * 4; auto make_branch = [](vm::ptr& ptr, u32 addr) @@ -687,7 +690,7 @@ namespace loader { const std::string module_name = stub->s_modulename.get_ptr(); - Module* module = Emu.GetModuleManager().GetModuleByName(module_name.c_str()); + Module<>* module = Emu.GetModuleManager().GetModuleByName(module_name.c_str()); if (!module) { From 4e62ec7458f10edda27ad15a08c316d79e200b6b Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Sun, 13 Sep 2015 01:37:57 +0300 Subject: [PATCH 3/6] PKG Installer fixed, u128 improved --- Utilities/BEType.h | 16 ++-- Utilities/GNU.h | 134 ++++++++++++++++++++++++++-- rpcs3/Crypto/unpkg.cpp | 163 +++++++++++++++++++--------------- rpcs3/Crypto/unpkg.h | 11 +-- rpcs3/Emu/System.cpp | 6 +- rpcs3/Emu/System.h | 2 +- rpcs3/Gui/MainFrame.cpp | 85 ++++++++++++++---- rpcs3/Loader/PKG.cpp | 49 ---------- rpcs3/Loader/PKG.h | 8 -- rpcs3/emucore.vcxproj | 2 - rpcs3/emucore.vcxproj.filters | 6 -- rpcs3/stdafx.h | 6 +- 12 files changed, 304 insertions(+), 184 deletions(-) delete mode 100644 rpcs3/Loader/PKG.cpp delete mode 100644 rpcs3/Loader/PKG.h diff --git a/Utilities/BEType.h b/Utilities/BEType.h index 4b34c7015..e96c6f849 100644 --- a/Utilities/BEType.h +++ b/Utilities/BEType.h @@ -545,13 +545,13 @@ public: type m_data; // don't access directly #endif - static_assert(!std::is_class::value, "be_t<> error: invalid type (class or structure)"); - static_assert(!std::is_union::value || std::is_same::value, "be_t<> error: invalid type (union)"); + static_assert(!std::is_class::value || std::is_same::value, "be_t<> error: invalid type (class or structure)"); + static_assert(!std::is_union::value || std::is_same::value || std::is_same::value, "be_t<> error: invalid type (union)"); static_assert(!std::is_pointer::value, "be_t<> error: invalid type (pointer)"); static_assert(!std::is_reference::value, "be_t<> error: invalid type (reference)"); static_assert(!std::is_array::value, "be_t<> error: invalid type (array)"); static_assert(!std::is_enum::value, "be_t<> error: invalid type (enumeration), use integral type instead"); - static_assert(__alignof(type) == __alignof(stype), "be_t<> error: unexpected alignment"); + static_assert(alignof(type) == alignof(stype), "be_t<> error: unexpected alignment"); be_t() = default; @@ -692,7 +692,7 @@ template struct is_be_t : public std::integral_constant< // to_be_t helper struct template struct to_be { - using type = std::conditional_t::value || std::is_enum::value || std::is_same::value, be_t, T>; + using type = std::conditional_t::value || std::is_enum::value || std::is_same::value || std::is_same::value, be_t, T>; }; // be_t if possible, T otherwise @@ -724,13 +724,13 @@ public: type m_data; // don't access directly - static_assert(!std::is_class::value, "le_t<> error: invalid type (class or structure)"); - static_assert(!std::is_union::value || std::is_same::value, "le_t<> error: invalid type (union)"); + static_assert(!std::is_class::value || std::is_same::value, "le_t<> error: invalid type (class or structure)"); + static_assert(!std::is_union::value || std::is_same::value || std::is_same::value, "le_t<> error: invalid type (union)"); static_assert(!std::is_pointer::value, "le_t<> error: invalid type (pointer)"); static_assert(!std::is_reference::value, "le_t<> error: invalid type (reference)"); static_assert(!std::is_array::value, "le_t<> error: invalid type (array)"); static_assert(!std::is_enum::value, "le_t<> error: invalid type (enumeration), use integral type instead"); - static_assert(__alignof(type) == __alignof(stype), "le_t<> error: unexpected alignment"); + static_assert(alignof(type) == alignof(stype), "le_t<> error: unexpected alignment"); le_t() = default; @@ -807,7 +807,7 @@ template struct is_le_t : public std::integral_constant< template struct to_le { - using type = std::conditional_t::value || std::is_enum::value || std::is_same::value, le_t, T>; + using type = std::conditional_t::value || std::is_enum::value || std::is_same::value || std::is_same::value, le_t, T>; }; // le_t if possible, T otherwise diff --git a/Utilities/GNU.h b/Utilities/GNU.h index d6e21fdf2..04bcbce45 100644 --- a/Utilities/GNU.h +++ b/Utilities/GNU.h @@ -86,31 +86,147 @@ struct alignas(16) uint128_t { uint64_t lo, hi; - uint128_t& operator ++() + uint128_t() = default; + + uint128_t(uint64_t l) + : lo(l) + , hi(0) + { + } + + [[deprecated("Not implemented")]] inline uint128_t operator +(const uint128_t& r) const + { + return{}; + } + + inline uint128_t operator +(uint64_t r) const + { + uint128_t value; + value.lo = lo + r; + value.hi = value.lo < r ? hi + 1 : hi; + return value; + } + + [[deprecated("Not implemented")]] inline uint128_t operator -(const uint128_t& r) const + { + return{}; + } + + inline uint128_t operator -(uint64_t r) const + { + uint128_t value; + value.lo = lo - r; + value.hi = lo < r ? hi - 1 : hi; + return value; + } + + inline uint128_t operator +() const + { + return *this; + } + + inline uint128_t operator -() const + { + uint128_t value; + value.lo = ~lo + 1; + value.hi = lo ? ~hi : ~hi + 1; + return value; + } + + inline uint128_t& operator ++() { if (!++lo) ++hi; return *this; } - uint128_t& operator --() - { - if (!lo--) hi--; - return *this; - } - - uint128_t operator ++(int) + inline uint128_t operator ++(int) { uint128_t value = *this; if (!++lo) ++hi; return value; } - uint128_t operator --(int) + inline uint128_t& operator --() + { + if (!lo--) hi--; + return *this; + } + + inline uint128_t operator --(int) { uint128_t value = *this; if (!lo--) hi--; return value; } + + inline uint128_t operator ~() const + { + uint128_t value; + value.lo = ~lo; + value.hi = ~hi; + return value; + } + + inline uint128_t operator &(const uint128_t& r) const + { + uint128_t value; + value.lo = lo & r.lo; + value.hi = hi & r.hi; + return value; + } + + inline uint128_t operator |(const uint128_t& r) const + { + uint128_t value; + value.lo = lo | r.lo; + value.hi = hi | r.hi; + return value; + } + + inline uint128_t operator ^(const uint128_t& r) const + { + uint128_t value; + value.lo = lo ^ r.lo; + value.hi = hi ^ r.hi; + return value; + } + + [[deprecated("Not implemented")]] inline uint128_t& operator +=(const uint128_t& r) + { + return *this; + } + + inline uint128_t& operator +=(uint64_t r) + { + hi = (lo += r) < r ? hi + 1 : hi; + return *this; + } + + [[deprecated("Not implemented")]] inline uint128_t& operator -=(const uint128_t& r) + { + return *this; + } + + inline uint128_t& operator &=(const uint128_t& r) + { + lo &= r.lo; + hi &= r.hi; + return *this; + } + + inline uint128_t& operator |=(const uint128_t& r) + { + lo |= r.lo; + hi |= r.hi; + return *this; + } + + inline uint128_t& operator ^=(const uint128_t& r) + { + lo ^= r.lo; + hi ^= r.hi; + return *this; + } }; using __uint128_t = uint128_t; diff --git a/rpcs3/Crypto/unpkg.cpp b/rpcs3/Crypto/unpkg.cpp index fe2ce0827..5a0dcd62a 100644 --- a/rpcs3/Crypto/unpkg.cpp +++ b/rpcs3/Crypto/unpkg.cpp @@ -6,13 +6,6 @@ #include "sha1.h" #include "key_vault.h" #include "unpkg.h" -#include "restore_new.h" -#pragma warning(push) -#pragma message("TODO: remove wx dependency: ") -#pragma warning(disable : 4996) -#include -#pragma warning(pop) -#include "define_new_memleakdetect.h" static bool CheckHeader(const fs::file& pkg_f, PKGHeader& header) { @@ -66,7 +59,7 @@ static bool CheckHeader(const fs::file& pkg_f, PKGHeader& header) } // PKG Decryption -bool Unpack(const fs::file& pkg_f, std::string dir) +bool UnpackPKG(const fs::file& pkg_f, const std::string& dir, volatile f64& progress) { // Save current file offset (probably zero) const u64 start_offset = pkg_f.seek(0, fsm::cur); @@ -85,75 +78,78 @@ bool Unpack(const fs::file& pkg_f, std::string dir) return false; } - aes_context c; - - u8 iv[HASH_LEN]; - be_t& hi = (be_t&)iv[0]; - be_t& lo = (be_t&)iv[8]; - - // Allocate buffers with BUF_SIZE size or more if required - const u64 buffer_size = std::max(BUF_SIZE, sizeof(PKGEntry) * header.file_count); - - const std::unique_ptr buf(new u8[buffer_size]), ctr(new u8[buffer_size]); - - // Debug key - u8 key[0x40] = {}; - memcpy(key + 0x00, &header.qa_digest[0], 8); // &data[0x60] - memcpy(key + 0x08, &header.qa_digest[0], 8); // &data[0x60] - memcpy(key + 0x10, &header.qa_digest[8], 8); // &data[0x68] - memcpy(key + 0x18, &header.qa_digest[8], 8); // &data[0x68] + // Allocate buffer with BUF_SIZE size or more if required + const std::unique_ptr buf(new u128[std::max(BUF_SIZE, sizeof(PKGEntry) * header.file_count) / sizeof(u128)]); // Define decryption subfunction (`psp` arg selects the key for specific block) - auto decrypt = [&](u64 offset, u64 size, bool psp) + auto decrypt = [&](u64 offset, u64 size, bool psp) -> u64 { - // Initialize buffer - std::memset(buf.get(), 0, size); - - // Read the data pkg_f.seek(start_offset + header.data_offset + offset); - size = pkg_f.read(buf.get(), size); - const u64 bits = (size + HASH_LEN - 1) / HASH_LEN; + + // Read the data and set available size + const u64 read = pkg_f.read(buf.get(), size); + + // Get block count + const u64 blocks = (read + 15) / 16; if (header.pkg_type == PKG_RELEASE_TYPE_DEBUG) { - for (u64 j = 0; j < bits; j++) + // Debug key + be_t input[8] = { - u8 hash[0x14]; - sha1(key, 0x40, hash); - *(u64*)&buf[j * HASH_LEN + 0] ^= *(u64*)&hash[0]; - *(u64*)&buf[j * HASH_LEN + 8] ^= *(u64*)&hash[8]; - *(be_t*)&key[0x38] += 1; + header.qa_digest[0], + header.qa_digest[0], + header.qa_digest[1], + header.qa_digest[1], + }; + + for (u64 i = 0; i < blocks; i++) + { + // Initialize "debug key" for current position + input[7] = offset / 16 + i; + + union + { + u8 _key[0x14]; + u128 key; + }; + + sha1(reinterpret_cast(input), sizeof(input), _key); + + buf[i] ^= key; } } if (header.pkg_type == PKG_RELEASE_TYPE_RELEASE) { + aes_context ctx; + // Set decryption key - aes_setkey_enc(&c, psp ? PKG_AES_KEY2 : PKG_AES_KEY, 128); + aes_setkey_enc(&ctx, psp ? PKG_AES_KEY2 : PKG_AES_KEY, 128); - // Initialize `iv` for the specific position - memcpy(iv, header.klicensee, sizeof(iv)); - if (lo + offset / HASH_LEN < lo) hi++; - lo += offset / HASH_LEN; + // Initialize "release key" for start position + be_t input = header.klicensee.value() + offset / 16; - for (u64 j = 0; j < bits; j++) + // Increment "release key" for every block + for (u64 i = 0; i < blocks; i++, input++) { - aes_crypt_ecb(&c, AES_ENCRYPT, iv, ctr.get() + j * HASH_LEN); - - if (!++lo) + union { - hi++; - } - } + u8 _key[16]; + u128 key; + }; - for (u64 j = 0; j < size; j++) - { - buf[j] ^= ctr[j]; + aes_crypt_ecb(&ctx, AES_ENCRYPT, reinterpret_cast(&input), _key); + + buf[i] ^= key; } } + + // Return the amount of data written in buf + return read; }; - wxProgressDialog pdlg("PKG Decrypter / Installer", "Please wait, decrypting...", header.file_count, 0, wxPD_AUTO_HIDE | wxPD_APP_MODAL); + LOG_SUCCESS(LOADER, "PKG: Installing in %s (%d entries)...", dir, header.file_count); decrypt(0, header.file_count * sizeof(PKGEntry), header.pkg_platform == PKG_PLATFORM_TYPE_PSP); @@ -161,12 +157,16 @@ bool Unpack(const fs::file& pkg_f, std::string dir) std::memcpy(entries.data(), buf.get(), entries.size() * sizeof(PKGEntry)); - for (s32 i = 0; i < entries.size(); i++) + for (const auto& entry : entries) { - const PKGEntry& entry = entries[i]; - const bool is_psp = (entry.type & PKG_FILE_ENTRY_PSP) != 0; + if (entry.name_size > 256) + { + LOG_ERROR(LOADER, "PKG: Name size is too big (0x%x)", entry.name_size); + continue; + } + decrypt(entry.name_offset, entry.name_size, is_psp); const std::string name(reinterpret_cast(buf.get()), entry.name_size); @@ -181,10 +181,7 @@ bool Unpack(const fs::file& pkg_f, std::string dir) { const std::string path = dir + name; - if (fs::is_file(path)) - { - LOG_WARNING(LOADER, "PKG Loader: '%s' is overwritten", path); - } + const bool did_overwrite = fs::is_file(path); if (fs::file out{ path, fom::write | fom::create | fom::trunc }) { @@ -192,15 +189,33 @@ bool Unpack(const fs::file& pkg_f, std::string dir) { const u64 block_size = std::min(BUF_SIZE, entry.file_size - pos); - decrypt(entry.file_offset + pos, block_size, is_psp); + if (decrypt(entry.file_offset + pos, block_size, is_psp) != block_size) + { + LOG_ERROR(LOADER, "PKG: Failed to extract file %s", path); + break; + } - out.write(buf.get(), block_size); + if (out.write(buf.get(), block_size) != block_size) + { + LOG_ERROR(LOADER, "PKG: Failed to write file %s", path); + break; + } + + progress += (block_size + 0.0) / header.data_size; + } + + if (did_overwrite) + { + LOG_SUCCESS(LOADER, "PKG: %s file overwritten", name); + } + else + { + LOG_SUCCESS(LOADER, "PKG: %s file created", name); } } else { - LOG_ERROR(LOADER, "PKG Loader: Could not create file '%s'", path); - return false; + LOG_ERROR(LOADER, "PKG: Could not create file %s", path); } break; @@ -210,10 +225,17 @@ bool Unpack(const fs::file& pkg_f, std::string dir) { const std::string path = dir + name; - if (!fs::is_dir(path) && !fs::create_dir(path)) + if (fs::create_dir(path)) { - LOG_ERROR(LOADER, "PKG Loader: Could not create directory: %s", path); - return false; + LOG_SUCCESS(LOADER, "PKG: %s directory created", name); + } + else if (fs::is_dir(path)) + { + LOG_SUCCESS(LOADER, "PKG: %s directory already exists", name); + } + else + { + LOG_ERROR(LOADER, "PKG: Could not create directory %s", path); } break; @@ -221,12 +243,9 @@ bool Unpack(const fs::file& pkg_f, std::string dir) default: { - LOG_ERROR(LOADER, "PKG Loader: unknown PKG file entry: 0x%x", entry.type); - return false; + LOG_ERROR(LOADER, "PKG: Unknown PKG entry type (0x%x) %s", entry.type, name); } } - - pdlg.Update(i + 1); } return true; diff --git a/rpcs3/Crypto/unpkg.h b/rpcs3/Crypto/unpkg.h index e973e892e..4983525eb 100644 --- a/rpcs3/Crypto/unpkg.h +++ b/rpcs3/Crypto/unpkg.h @@ -3,8 +3,7 @@ // Constants enum { - HASH_LEN = 16, - BUF_SIZE = 8192 * 1024, + BUF_SIZE = 8192 * 1024, // 8 MB PKG_HEADER_SIZE = 0xC0, //sizeof(pkg_header) + sizeof(pkg_unk_checksum) PKG_HEADER_SIZE2 = 0x280, }; @@ -45,8 +44,8 @@ struct PKGHeader be_t data_offset; // Encrypted data offset be_t data_size; // Encrypted data size in bytes char title_id[48]; // Title ID - u8 qa_digest[16]; // This should be the hash of "files + attribs" - u8 klicensee[16]; // Nonce + be_t qa_digest[2]; // This should be the hash of "files + attribs" + be_t klicensee; // Nonce }; struct PKGEntry @@ -59,6 +58,4 @@ struct PKGEntry be_t pad; // Padding (zeros) }; -namespace fs { struct file; } - -bool Unpack(const fs::file& pkg_f, std::string dir); +bool UnpackPKG(const struct fs::file& pkg_f, const std::string& dir, volatile f64& progress); diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index 544a227eb..2fed655a0 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -298,14 +298,14 @@ void Emulator::Run() SendDbgCommand(DID_STARTED_EMU); } -void Emulator::Pause() +bool Emulator::Pause() { const u64 start = get_system_time(); // try to set Paused status if (!sync_bool_compare_and_swap(&m_status, Running, Paused)) { - return; + return false; } // update pause start time @@ -322,6 +322,8 @@ void Emulator::Pause() } SendDbgCommand(DID_PAUSED_EMU); + + return true; } void Emulator::Resume() diff --git a/rpcs3/Emu/System.h b/rpcs3/Emu/System.h index 331efc0ea..b0a4c4379 100644 --- a/rpcs3/Emu/System.h +++ b/rpcs3/Emu/System.h @@ -186,7 +186,7 @@ public: void Load(); void Run(); - void Pause(); + bool Pause(); void Resume(); void Stop(); diff --git a/rpcs3/Gui/MainFrame.cpp b/rpcs3/Gui/MainFrame.cpp index 5e8889435..1c1928a49 100644 --- a/rpcs3/Gui/MainFrame.cpp +++ b/rpcs3/Gui/MainFrame.cpp @@ -22,8 +22,9 @@ #include "Gui/MemoryStringSearcher.h" #include "Gui/LLEModulesManager.h" #include "Gui/CgDisasm.h" -#include "Loader/PKG.h" +#include "Crypto/unpkg.h" #include +#include BEGIN_EVENT_TABLE(MainFrame, FrameBase) EVT_CLOSE(MainFrame::OnQuit) @@ -229,33 +230,81 @@ void MainFrame::BootGame(wxCommandEvent& WXUNUSED(event)) void MainFrame::InstallPkg(wxCommandEvent& WXUNUSED(event)) { - bool stopped = false; - - if(Emu.IsRunning()) - { - Emu.Pause(); - stopped = true; - } + const bool was_running = Emu.Pause(); wxFileDialog ctrl(this, L"Select PKG", wxEmptyString, wxEmptyString, "PKG files (*.pkg)|*.pkg|All files (*.*)|*.*", wxFD_OPEN | wxFD_FILE_MUST_EXIST); - if(ctrl.ShowModal() == wxID_CANCEL) + if (ctrl.ShowModal() == wxID_CANCEL) { - if(stopped) Emu.Resume(); + if (was_running) Emu.Resume(); return; } Emu.Stop(); - - // Open and install PKG file - fs::file pkg_f(ctrl.GetPath().ToStdString(), fom::read); - if (pkg_f) + Emu.GetVFS().Init("/"); + std::string local_path; + Emu.GetVFS().GetDevice("/dev_hdd0/game/", local_path); + + // Open PKG file + fs::file pkg_f{ ctrl.GetPath().ToStdString() }; + + if (!pkg_f) { - Emu.GetVFS().Init("/"); - std::string local_path; - Emu.GetVFS().GetDevice("/dev_hdd0/game/", local_path); - PKGLoader::Install(pkg_f, local_path + "/"); + LOG_ERROR(LOADER, "PKG: Failed to open %s", ctrl.GetPath().ToStdString()); + return; + } + + // Fetch title ID from the header + char title_id[10] = "?????????"; + pkg_f.seek(55); + pkg_f.read(title_id, 9); + pkg_f.seek(0); + + // Append title ID to the path + local_path += '/'; + local_path += title_id; + + if (!fs::create_dir(local_path)) + { + if (fs::is_dir(local_path)) + { + if (wxMessageDialog(this, "Another installation found. Do you want to overwrite it?", "PKG Decrypter / Installer", wxYES_NO | wxCENTRE).ShowModal() != wxID_YES) + { + LOG_ERROR(LOADER, "PKG: Cancelled installation to existing directory %s", local_path); + return; + } + } + else + { + LOG_ERROR(LOADER, "PKG: Could not create the installation directory %s", local_path); + return; + } + } + + wxProgressDialog pdlg("PKG Decrypter / Installer", "Please wait, unpacking...", 1000, this, wxPD_AUTO_HIDE | wxPD_APP_MODAL); + + volatile f64 progress = 0.0; + + // Run PKG unpacking asynchronously + auto result = std::async(WRAP_EXPR(UnpackPKG(pkg_f, local_path + "/", progress))); + + // Wait for the completion + while (result.wait_for(15ms) != std::future_status::ready) + { + // Update progress window + pdlg.Update(progress * pdlg.GetRange()); + + // Update main frame + Update(); + wxGetApp().ProcessPendingEvents(); + } + + pdlg.Close(); + + if (result.get()) + { + LOG_SUCCESS(LOADER, "PKG: Package successfully installed in %s", local_path); // Refresh game list m_game_viewer->Refresh(); diff --git a/rpcs3/Loader/PKG.cpp b/rpcs3/Loader/PKG.cpp deleted file mode 100644 index d45291723..000000000 --- a/rpcs3/Loader/PKG.cpp +++ /dev/null @@ -1,49 +0,0 @@ -#include "stdafx.h" -#include "Utilities/Log.h" -#include "Utilities/rMsgBox.h" -#include "Utilities/File.h" -#include "PKG.h" -#include "../Crypto/unpkg.h" - -bool PKGLoader::Install(const fs::file& pkg_f, std::string dest) -{ - // Initial checks - if (!pkg_f) - { - return false; - } - - // Fetch title ID from the header. - char title_id[48]; - pkg_f.seek(48); - pkg_f.read(title_id, 48); - pkg_f.seek(0); - - std::string titleID = std::string(title_id).substr(7, 9); - - if (fs::is_dir(dest + titleID)) - { - if (rMessageDialog(NULL, "Another installation found. Do you want to overwrite it?", "PKG Decrypter / Installer", rYES_NO | rCENTRE).ShowModal() != rID_YES) - { - LOG_ERROR(LOADER, "PKG Loader: Another installation found in: %s", titleID.c_str()); - return false; - } - } - else if (!fs::create_dir(dest + titleID)) - { - LOG_ERROR(LOADER, "PKG Loader: Could not create the installation directory: %s", titleID.c_str()); - return false; - } - - // Decrypt and unpack the PKG file. - if (!Unpack(pkg_f, dest + titleID + "/")) - { - LOG_ERROR(LOADER, "PKG Loader: Failed to install package!"); - return false; - } - else - { - LOG_NOTICE(LOADER, "PKG Loader: Package successfully installed in: /dev_hdd0/game/%s", titleID.c_str()); - return true; - } -} diff --git a/rpcs3/Loader/PKG.h b/rpcs3/Loader/PKG.h deleted file mode 100644 index 1a51c7119..000000000 --- a/rpcs3/Loader/PKG.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -namespace fs { struct file; } - -struct PKGLoader -{ - static bool Install(const fs::file& pkg_f, std::string dest); -}; diff --git a/rpcs3/emucore.vcxproj b/rpcs3/emucore.vcxproj index 3da301472..84ba49f03 100644 --- a/rpcs3/emucore.vcxproj +++ b/rpcs3/emucore.vcxproj @@ -349,7 +349,6 @@ - @@ -662,7 +661,6 @@ - diff --git a/rpcs3/emucore.vcxproj.filters b/rpcs3/emucore.vcxproj.filters index 95534f010..bb13a7ca4 100644 --- a/rpcs3/emucore.vcxproj.filters +++ b/rpcs3/emucore.vcxproj.filters @@ -386,9 +386,6 @@ Loader - - Loader - Loader @@ -1327,9 +1324,6 @@ Loader - - Loader - Loader diff --git a/rpcs3/stdafx.h b/rpcs3/stdafx.h index ee829d533..5bf3ddf6f 100644 --- a/rpcs3/stdafx.h +++ b/rpcs3/stdafx.h @@ -40,13 +40,15 @@ #include #include #include +#include using namespace std::string_literals; +using namespace std::chrono_literals; #include "Utilities/GNU.h" #define CHECK_SIZE(type, size) static_assert(sizeof(type) == size, "Invalid " #type " type size") -#define CHECK_ALIGN(type, align) static_assert(__alignof(type) == align, "Invalid " #type " type alignment") +#define CHECK_ALIGN(type, align) static_assert(alignof(type) == align, "Invalid " #type " type alignment") #define CHECK_MAX_SIZE(type, size) static_assert(sizeof(type) <= size, #type " type size is too big") #define CHECK_SIZE_ALIGN(type, size, align) CHECK_SIZE(type, size); CHECK_ALIGN(type, align) #define CHECK_ASCENDING(constexpr_array) static_assert(::is_ascending(constexpr_array), #constexpr_array " is not sorted in ascending order") @@ -154,7 +156,7 @@ template struct triplet_t #define sizeof32(type) static_cast(sizeof(type)) // return 32 bit alignof() to avoid widening/narrowing conversions with size_t -#define alignof32(type) static_cast(__alignof(type)) +#define alignof32(type) static_cast(alignof(type)) #define WRAP_EXPR(expr) [&]{ return expr; } #define COPY_EXPR(expr) [=]{ return expr; } From 59f1077a3675075e9d405ca97183a17c713e1540 Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Mon, 14 Sep 2015 19:32:35 +0300 Subject: [PATCH 4/6] Cleanup, be_t fixed Some functions renamed: get_ps3_function_name execute_syscall_by_index --- Utilities/BEType.h | 756 ++++++++++------------ rpcs3/Emu/Cell/PPUInterpreter.cpp | 6 +- rpcs3/Emu/Cell/PPUInterpreter.h | 109 ++-- rpcs3/Emu/Cell/PPULLVMRecompiler.cpp | 1 + rpcs3/Emu/Cell/PPULLVMRecompilerCore.cpp | 11 +- rpcs3/Emu/Cell/PPULLVMRecompilerTests.cpp | 4 +- rpcs3/Emu/Cell/PPUThread.cpp | 18 +- rpcs3/Emu/Cell/PPUThread.h | 17 + rpcs3/Emu/SysCalls/FuncList.cpp | 2 +- rpcs3/Emu/SysCalls/Modules.cpp | 46 +- rpcs3/Emu/SysCalls/Modules.h | 20 +- rpcs3/Emu/SysCalls/SysCalls.cpp | 16 +- rpcs3/Emu/SysCalls/SysCalls.h | 10 +- rpcs3/Emu/SysCalls/lv2/sys_prx.cpp | 6 +- rpcs3/Loader/ELF64.cpp | 18 +- 15 files changed, 476 insertions(+), 564 deletions(-) diff --git a/Utilities/BEType.h b/Utilities/BEType.h index e96c6f849..b9e1d542a 100644 --- a/Utilities/BEType.h +++ b/Utilities/BEType.h @@ -8,97 +8,74 @@ #define IS_LE_MACHINE // only draft +template class masked_array_t // array type accessed as (index ^ M) +{ + T m_data[N]; + +public: + T& operator [](std::size_t index) + { + return m_data[index ^ M]; + } + + const T& operator [](std::size_t index) const + { + return m_data[index ^ M]; + } + + T& at(std::size_t index) + { + return (index ^ M) < N ? m_data[index ^ M] : throw std::out_of_range("Masked array"); + } + + const T& at(std::size_t index) const + { + return (index ^ M) < N ? m_data[index ^ M] : throw std::out_of_range("Masked array"); + } +}; + union v128 { - u64 _u64[2]; - s64 _s64[2]; +#ifdef IS_LE_MACHINE + template using normal_array_t = masked_array_t; + template using reversed_array_t = masked_array_t; +#else + template using normal_array_t = masked_array_t; + template using reversed_array_t = masked_array_t; +#endif - class u64_reversed_array_2 - { - u64 data[2]; + normal_array_t _u64; + normal_array_t _s64; + reversed_array_t u64r; + reversed_array_t s64r; - public: - u64& operator [] (s32 index) - { - return data[1 - index]; - } + normal_array_t _u32; + normal_array_t _s32; + reversed_array_t u32r; + reversed_array_t s32r; - const u64& operator [] (s32 index) const - { - return data[1 - index]; - } + normal_array_t _u16; + normal_array_t _s16; + reversed_array_t u16r; + reversed_array_t s16r; - } u64r; + normal_array_t _u8; + normal_array_t _s8; + reversed_array_t u8r; + reversed_array_t s8r; - u32 _u32[4]; - s32 _s32[4]; + normal_array_t _f; + normal_array_t _d; + reversed_array_t fr; + reversed_array_t dr; - class u32_reversed_array_4 - { - u32 data[4]; - - public: - u32& operator [] (s32 index) - { - return data[3 - index]; - } - - const u32& operator [] (s32 index) const - { - return data[3 - index]; - } - - } u32r; - - u16 _u16[8]; - s16 _s16[8]; - - class u16_reversed_array_8 - { - u16 data[8]; - - public: - u16& operator [] (s32 index) - { - return data[7 - index]; - } - - const u16& operator [] (s32 index) const - { - return data[7 - index]; - } - - } u16r; - - u8 _u8[16]; - s8 _s8[16]; - - class u8_reversed_array_16 - { - u8 data[16]; - - public: - u8& operator [] (s32 index) - { - return data[15 - index]; - } - - const u8& operator [] (s32 index) const - { - return data[15 - index]; - } - - } u8r; - - float _f[4]; - double _d[2]; __m128 vf; __m128i vi; __m128d vd; class bit_array_128 { - u64 data[2]; + u64 m_data[2]; public: class bit_element @@ -113,12 +90,12 @@ union v128 { } - force_inline operator bool() const + inline operator bool() const { return (data & mask) != 0; } - force_inline bit_element& operator = (const bool right) + inline bit_element& operator =(const bool right) { if (right) { @@ -131,7 +108,7 @@ union v128 return *this; } - force_inline bit_element& operator = (const bit_element& right) + inline bit_element& operator =(const bit_element& right) { if (right) { @@ -146,30 +123,40 @@ union v128 }; // Index 0 returns the MSB and index 127 returns the LSB - bit_element operator [] (u32 index) + bit_element operator [](u32 index) { - assert(index < 128); - #ifdef IS_LE_MACHINE - return bit_element(data[1 - (index >> 6)], 0x8000000000000000ull >> (index & 0x3F)); + return bit_element(m_data[1 - (index >> 6)], 0x8000000000000000ull >> (index & 0x3F)); #else - return bit_element(data[index >> 6], 0x8000000000000000ull >> (index & 0x3F)); + return bit_element(m_data[index >> 6], 0x8000000000000000ull >> (index & 0x3F)); #endif } // Index 0 returns the MSB and index 127 returns the LSB - const bool operator [] (u32 index) const + bool operator [](u32 index) const { - assert(index < 128); - #ifdef IS_LE_MACHINE - return (data[1 - (index >> 6)] & (0x8000000000000000ull >> (index & 0x3F))) != 0; + return (m_data[1 - (index >> 6)] & (0x8000000000000000ull >> (index & 0x3F))) != 0; #else - return (data[index >> 6] & (0x8000000000000000ull >> (index & 0x3F))) != 0; + return (m_data[index >> 6] & (0x8000000000000000ull >> (index & 0x3F))) != 0; #endif } - } _bit; + bit_element at(u32 index) + { + if (index >= 128) throw std::out_of_range("Bit element"); + + return operator[](index); + } + + bool at(u32 index) const + { + if (index >= 128) throw std::out_of_range("Bit element"); + + return operator[](index); + } + } + _bit; static v128 from64(u64 _0, u64 _1 = 0) { @@ -248,117 +235,118 @@ union v128 return ret; } - static force_inline v128 add8(const v128& left, const v128& right) + static inline v128 add8(const v128& left, const v128& right) { return fromV(_mm_add_epi8(left.vi, right.vi)); } - static force_inline v128 add16(const v128& left, const v128& right) + static inline v128 add16(const v128& left, const v128& right) { return fromV(_mm_add_epi16(left.vi, right.vi)); } - static force_inline v128 add32(const v128& left, const v128& right) + static inline v128 add32(const v128& left, const v128& right) { return fromV(_mm_add_epi32(left.vi, right.vi)); } - static force_inline v128 addfs(const v128& left, const v128& right) + static inline v128 addfs(const v128& left, const v128& right) { return fromF(_mm_add_ps(left.vf, right.vf)); } - static force_inline v128 addfd(const v128& left, const v128& right) + static inline v128 addfd(const v128& left, const v128& right) { return fromD(_mm_add_pd(left.vd, right.vd)); } - static force_inline v128 sub8(const v128& left, const v128& right) + static inline v128 sub8(const v128& left, const v128& right) { return fromV(_mm_sub_epi8(left.vi, right.vi)); } - static force_inline v128 sub16(const v128& left, const v128& right) + static inline v128 sub16(const v128& left, const v128& right) { return fromV(_mm_sub_epi16(left.vi, right.vi)); } - static force_inline v128 sub32(const v128& left, const v128& right) + static inline v128 sub32(const v128& left, const v128& right) { return fromV(_mm_sub_epi32(left.vi, right.vi)); } - static force_inline v128 subfs(const v128& left, const v128& right) + static inline v128 subfs(const v128& left, const v128& right) { return fromF(_mm_sub_ps(left.vf, right.vf)); } - static force_inline v128 subfd(const v128& left, const v128& right) + static inline v128 subfd(const v128& left, const v128& right) { return fromD(_mm_sub_pd(left.vd, right.vd)); } - static force_inline v128 maxu8(const v128& left, const v128& right) + static inline v128 maxu8(const v128& left, const v128& right) { return fromV(_mm_max_epu8(left.vi, right.vi)); } - static force_inline v128 minu8(const v128& left, const v128& right) + static inline v128 minu8(const v128& left, const v128& right) { return fromV(_mm_min_epu8(left.vi, right.vi)); } - static force_inline v128 eq8(const v128& left, const v128& right) + static inline v128 eq8(const v128& left, const v128& right) { return fromV(_mm_cmpeq_epi8(left.vi, right.vi)); } - static force_inline v128 eq16(const v128& left, const v128& right) + static inline v128 eq16(const v128& left, const v128& right) { return fromV(_mm_cmpeq_epi16(left.vi, right.vi)); } - static force_inline v128 eq32(const v128& left, const v128& right) + static inline v128 eq32(const v128& left, const v128& right) { return fromV(_mm_cmpeq_epi32(left.vi, right.vi)); } - bool operator == (const v128& right) const + bool operator ==(const v128& right) const { - return (_u64[0] == right._u64[0]) && (_u64[1] == right._u64[1]); + return _u64[0] == right._u64[0] && _u64[1] == right._u64[1]; } - bool operator != (const v128& right) const + bool operator !=(const v128& right) const { - return (_u64[0] != right._u64[0]) || (_u64[1] != right._u64[1]); + return _u64[0] != right._u64[0] || _u64[1] != right._u64[1]; } - force_inline bool is_any_1() const // check if any bit is 1 + inline bool is_any_1() const // check if any bit is 1 { return _u64[0] || _u64[1]; } - force_inline bool is_any_0() const // check if any bit is 0 + inline bool is_any_0() const // check if any bit is 0 { return ~_u64[0] || ~_u64[1]; } // result = (~left) & (right) - static force_inline v128 andnot(const v128& left, const v128& right) + static inline v128 andnot(const v128& left, const v128& right) { return fromV(_mm_andnot_si128(left.vi, right.vi)); } void clear() { - _u64[1] = _u64[0] = 0; + _u64[0] = 0; + _u64[1] = 0; } std::string to_hex() const; std::string to_xyzw() const; - static force_inline v128 byteswap(const v128 val) + static inline v128 byteswap(const v128 val) { return fromV(_mm_shuffle_epi8(val.vi, _mm_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15))); } @@ -386,293 +374,301 @@ inline v128 operator ~(const v128& other) return v128::from64(~other._u64[0], ~other._u64[1]); } -template struct se_t; - -template struct se_t +template struct se_storage { - static force_inline u16 to(const T& src) - { - return _byteswap_ushort((u16&)src); - } - - static force_inline T from(const u16 src) - { - const u16 res = _byteswap_ushort(src); - return (T&)res; - } + static_assert(!Size, "Bad se_storage<> type"); }; -template struct se_t -{ - static force_inline u32 to(const T& src) - { - return _byteswap_ulong((u32&)src); - } - - static force_inline T from(const u32 src) - { - const u32 res = _byteswap_ulong(src); - return (T&)res; - } -}; - -template struct se_t -{ - static force_inline u64 to(const T& src) - { - return _byteswap_uint64((u64&)src); - } - - static force_inline T from(const u64 src) - { - const u64 res = _byteswap_uint64(src); - return (T&)res; - } -}; - -template struct se_t -{ - static force_inline v128 to(const T& src) - { - return v128::byteswap((v128&)src); - } - - static force_inline T from(const v128& src) - { - const v128 res = v128::byteswap(src); - return (T&)res; - } -}; - -template struct const_se_t; - -template struct const_se_t -{ - static const u16 value = - ((_value >> 8) & 0x00ff) | - ((_value << 8) & 0xff00); -}; - -template struct const_se_t -{ - static const u32 value = - ((_value >> 24) & 0x000000ff) | - ((_value >> 8) & 0x0000ff00) | - ((_value << 8) & 0x00ff0000) | - ((_value << 24) & 0xff000000); -}; - -template struct const_se_t -{ - static const u64 value = - ((_value >> 56) & 0x00000000000000ff) | - ((_value >> 40) & 0x000000000000ff00) | - ((_value >> 24) & 0x0000000000ff0000) | - ((_value >> 8) & 0x00000000ff000000) | - ((_value << 8) & 0x000000ff00000000) | - ((_value << 24) & 0x0000ff0000000000) | - ((_value << 40) & 0x00ff000000000000) | - ((_value << 56) & 0xff00000000000000); -}; - -template struct be_storage -{ - static_assert(!size, "Bad be_storage_t<> type"); -}; - -template struct be_storage +template struct se_storage { using type = u16; + + static inline u16 to(const T& src) + { + return _byteswap_ushort(reinterpret_cast(src)); + } + + static inline T from(u16 src) + { + const u16 result = _byteswap_ushort(src); + return reinterpret_cast(result); + } }; -template struct be_storage +template struct se_storage { using type = u32; + + static inline u32 to(const T& src) + { + return _byteswap_ulong(reinterpret_cast(src)); + } + + static inline T from(u32 src) + { + const u32 result = _byteswap_ulong(src); + return reinterpret_cast(result); + } }; -template struct be_storage +template struct se_storage { using type = u64; + + static inline u64 to(const T& src) + { + return _byteswap_uint64(reinterpret_cast(src)); + } + + static inline T from(u64 src) + { + const u64 result = _byteswap_uint64(src); + return reinterpret_cast(result); + } }; -template struct be_storage +template struct se_storage { using type = v128; + + static inline v128 to(const T& src) + { + return v128::byteswap(reinterpret_cast(src)); + } + + static inline T from(const v128& src) + { + const v128 result = v128::byteswap(src); + return reinterpret_cast(result); + } }; -template using be_storage_t = typename be_storage::type; +template using se_storage_t = typename se_storage::type; -template class be_t +template struct se_convert { - // TODO (complicated cases like int-float conversions are not handled correctly) - template - struct _convert - { - static force_inline be_t& func(Tfrom& be_value) - { - Tto res = be_value; - return (be_t&)res; - } - }; + using type_from = std::remove_cv_t; + using type_to = std::remove_cv_t; + using stype_from = se_storage_t>; + using stype_to = se_storage_t>; + using storage_from = se_storage>; + using storage_to = se_storage>; - template - struct _convert + static inline std::enable_if_t::value, stype_to> convert(const stype_from& data) { - static force_inline be_t& func(Tfrom& be_value) - { - Tto res = se_t::func(se_t::func(be_value)); - return (be_t&)res; - } - }; + return data; + } - template - struct _convert + static inline stype_to convert(const stype_from& data, ...) { - static force_inline be_t& func(Tfrom& be_value) - { - Tto res = be_value >> ((sizeof(Tfrom) - sizeof(Tto)) * 8); - return (be_t&)res; - } - }; + return storage_to::to(storage_from::from(data)); + } +}; + +template class se_t +{ + using type = std::remove_cv_t; + using stype = se_storage_t>; + using storage = se_storage>; + + stype m_data; + + static_assert(!std::is_class::value || std::is_same::value, "se_t<> error: invalid type (class or structure)"); + static_assert(!std::is_union::value || std::is_same::value || std::is_same::value, "se_t<> error: invalid type (union)"); + static_assert(!std::is_pointer::value, "se_t<> error: invalid type (pointer)"); + static_assert(!std::is_reference::value, "se_t<> error: invalid type (reference)"); + static_assert(!std::is_array::value, "se_t<> error: invalid type (array)"); + static_assert(!std::is_enum::value, "se_t<> error: invalid type (enumeration), use integral type instead"); + static_assert(alignof(type) == alignof(stype), "se_t<> error: unexpected alignment"); public: - using type = std::remove_cv_t; - using stype = be_storage_t>; + se_t() = default; -#ifdef IS_LE_MACHINE - stype m_data; // don't access directly -#else - type m_data; // don't access directly -#endif + se_t(const se_t&) = default; - static_assert(!std::is_class::value || std::is_same::value, "be_t<> error: invalid type (class or structure)"); - static_assert(!std::is_union::value || std::is_same::value || std::is_same::value, "be_t<> error: invalid type (union)"); - static_assert(!std::is_pointer::value, "be_t<> error: invalid type (pointer)"); - static_assert(!std::is_reference::value, "be_t<> error: invalid type (reference)"); - static_assert(!std::is_array::value, "be_t<> error: invalid type (array)"); - static_assert(!std::is_enum::value, "be_t<> error: invalid type (enumeration), use integral type instead"); - static_assert(alignof(type) == alignof(stype), "be_t<> error: unexpected alignment"); - - be_t() = default; - - be_t(const be_t&) = default; - - force_inline be_t(const type& value) -#ifdef IS_LE_MACHINE - : m_data(se_t::to(value)) -#else - : m_data(value) -#endif + inline se_t(const type& value) + : m_data(storage::to(value)) { } - // get value in current machine byte ordering - force_inline type value() const + inline type value() const { -#ifdef IS_LE_MACHINE - return se_t::from(m_data); -#else - return m_data; -#endif + return storage::from(m_data); } - // get underlying data without any byte order manipulation - const stype& data() const + inline const stype& data() const { -#ifdef IS_LE_MACHINE return m_data; -#else - return reinterpret_cast(m_data); -#endif } - be_t& operator =(const be_t&) = default; + se_t& operator =(const se_t&) = default; - template std::enable_if_t::value, be_t&> operator =(const CT& value) + template std::enable_if_t::value, se_t&> operator =(const CT& value) { -#ifdef IS_LE_MACHINE - m_data = se_t::to(value); -#else - m_data = value; -#endif - - return *this; + return m_data = storage::to(value), *this; } - //template::value>> operator CT() const - //{ - // return value(); - //} - operator type() const { return value(); } - - // conversion to another be_t type - //template operator be_t() const - //{ - // return value(); - // //return _convert sizeof(T)) ? 1 : (sizeof(T1) < sizeof(T) ? 2 : 0))>::func(m_data); - //} - - template be_t& operator +=(const T1& right) { return *this = value() + right; } - template be_t& operator -=(const T1& right) { return *this = value() - right; } - template be_t& operator *=(const T1& right) { return *this = value() * right; } - template be_t& operator /=(const T1& right) { return *this = value() / right; } - template be_t& operator %=(const T1& right) { return *this = value() % right; } - - template be_t& operator <<=(const T1& right) { return *this = value() << right; } - template be_t& operator >>=(const T1& right) { return *this = value() >> right; } - - template be_t& operator &=(const T1& right) { return m_data &= be_t(right).data(), *this; } - template be_t& operator |=(const T1& right) { return m_data |= be_t(right).data(), *this; } - template be_t& operator ^=(const T1& right) { return m_data ^= be_t(right).data(), *this; } - - be_t operator ++(int) { be_t res = *this; *this += 1; return res; } - be_t operator --(int) { be_t res = *this; *this -= 1; return res; } - be_t& operator ++() { *this += 1; return *this; } - be_t& operator --() { *this -= 1; return *this; } }; -template inline std::enable_if_t::value && std::is_integral::value, bool> operator ==(const be_t& left, const be_t& right) +template class se_t +{ + using type = std::remove_cv_t; + using stype = se_storage_t>; + using storage = se_storage>; + + type m_data; + + static_assert(!std::is_class::value || std::is_same::value, "se_t<> error: invalid type (class or structure)"); + static_assert(!std::is_union::value || std::is_same::value || std::is_same::value, "se_t<> error: invalid type (union)"); + static_assert(!std::is_pointer::value, "se_t<> error: invalid type (pointer)"); + static_assert(!std::is_reference::value, "se_t<> error: invalid type (reference)"); + static_assert(!std::is_array::value, "se_t<> error: invalid type (array)"); + static_assert(!std::is_enum::value, "se_t<> error: invalid type (enumeration), use integral type instead"); + static_assert(alignof(type) == alignof(stype), "se_t<> error: unexpected alignment"); + +public: + se_t() = default; + + se_t(const se_t&) = default; + + inline se_t(const type& value) + : m_data(value) + { + } + + inline type value() const + { + return m_data; + } + + inline const stype& data() const + { + return reinterpret_cast(m_data); + } + + se_t& operator =(const se_t& value) = default; + + template std::enable_if_t::value, se_t&> operator =(const CT& value) + { + return m_data = value, *this; + } + + operator type() const + { + return value(); + } +}; + +template inline std::enable_if_t::value && std::is_integral::value, bool> operator ==(const se_t& left, const se_t& right) { return left.data() == right.data(); } -template inline std::enable_if_t::value && std::is_integral::value, bool> operator !=(const be_t& left, const be_t& right) +template inline std::enable_if_t::value && std::is_integral::value, bool> operator !=(const se_t& left, const se_t& right) { return left.data() != right.data(); } -template inline std::enable_if_t::value && std::is_integral::value, be_t> operator &(const be_t& left, const be_t& right) +template inline se_t& operator +=(se_t& left, const T1& right) { - be_t result; - result.m_data = left.data() & right.data(); + auto value = left.value(); + return left = (value += right); +} + +template inline se_t& operator -=(se_t& left, const T1& right) +{ + auto value = left.value(); + return left = (value -= right); +} + +template inline se_t& operator *=(se_t& left, const T1& right) +{ + auto value = left.value(); + return left = (value *= right); +} + +template inline se_t& operator /=(se_t& left, const T1& right) +{ + auto value = left.value(); + return left = (value /= right); +} + +template inline se_t& operator %=(se_t& left, const T1& right) +{ + auto value = left.value(); + return left = (value %= right); +} + +template inline se_t& operator <<=(se_t& left, const T1& right) +{ + auto value = left.value(); + return left = (value <<= right); +} + +template inline se_t& operator >>=(se_t& left, const T1& right) +{ + auto value = left.value(); + return left = (value >>= right); +} + +template inline se_t& operator &=(se_t& left, const T1& right) +{ + auto value = left.value(); + return left = (value &= right); +} + +template inline se_t& operator |=(se_t& left, const T1& right) +{ + auto value = left.value(); + return left = (value |= right); +} + +template inline se_t& operator ^=(se_t& left, const T1& right) +{ + auto value = left.value(); + return left = (value ^= right); +} + +template inline se_t operator ++(se_t& left, int) +{ + auto value = left.value(); + auto result = value++; + left = value; return result; } -template inline std::enable_if_t::value && std::is_integral::value, be_t> operator |(const be_t& left, const be_t& right) +template inline se_t operator --(se_t& left, int) { - be_t result; - result.m_data = left.data() | right.data(); + auto value = left.value(); + auto result = value--; + left = value; return result; } -template inline std::enable_if_t::value && std::is_integral::value, be_t> operator ^(const be_t& left, const be_t& right) +template inline se_t& operator ++(se_t& right) { - be_t result; - result.m_data = left.data() ^ right.data(); - return result; + auto value = right.value(); + return right = ++value; } -template inline std::enable_if_t::value, be_t> operator ~(const be_t& arg) +template inline se_t& operator --(se_t& right) { - be_t result; - result.m_data = ~arg.data(); - return result; + auto value = right.value(); + return right = --value; } +#ifdef IS_LE_MACHINE +template using be_t = se_t; +template using le_t = se_t; +#else +template using be_t = se_t; +template using le_t = se_t; +#endif + template struct is_be_t : public std::integral_constant { }; @@ -698,15 +694,13 @@ template struct to_be // be_t if possible, T otherwise template using to_be_t = typename to_be::type; -template struct to_be +template struct to_be // move const qualifier { - // move const qualifier using type = const to_be_t; }; -template struct to_be +template struct to_be // move volatile qualifier { - // move volatile qualifier using type = volatile to_be_t; }; @@ -716,79 +710,6 @@ template<> struct to_be { using type = char; }; template<> struct to_be { using type = u8; }; template<> struct to_be { using type = s8; }; -template class le_t -{ -public: - using type = std::remove_cv_t; - using stype = be_storage_t>; - - type m_data; // don't access directly - - static_assert(!std::is_class::value || std::is_same::value, "le_t<> error: invalid type (class or structure)"); - static_assert(!std::is_union::value || std::is_same::value || std::is_same::value, "le_t<> error: invalid type (union)"); - static_assert(!std::is_pointer::value, "le_t<> error: invalid type (pointer)"); - static_assert(!std::is_reference::value, "le_t<> error: invalid type (reference)"); - static_assert(!std::is_array::value, "le_t<> error: invalid type (array)"); - static_assert(!std::is_enum::value, "le_t<> error: invalid type (enumeration), use integral type instead"); - static_assert(alignof(type) == alignof(stype), "le_t<> error: unexpected alignment"); - - le_t() = default; - - le_t(const le_t&) = default; - - le_t(const type& value) - : m_data(value) - { - } - - type value() const - { - return m_data; - } - - const stype& data() const - { - return reinterpret_cast(m_data); - } - - le_t& operator =(const le_t& value) = default; - - template std::enable_if_t::value, le_t&> operator =(const CT& value) - { - m_data = value; - return *this; - } - - operator type() const - { - return value(); - } - - // conversion to another le_t type - //template operator le_t() const - //{ - // return value(); - //} - - template le_t& operator +=(const T1& right) { return *this = value() + right; } - template le_t& operator -=(const T1& right) { return *this = value() - right; } - template le_t& operator *=(const T1& right) { return *this = value() * right; } - template le_t& operator /=(const T1& right) { return *this = value() / right; } - template le_t& operator %=(const T1& right) { return *this = value() % right; } - - template le_t& operator <<=(const T1& right) { return *this = value() << right; } - template le_t& operator >>=(const T1& right) { return *this = value() >> right; } - - template le_t& operator &=(const T1& right) { return m_data &= le_t(right).data(), *this; } - template le_t& operator |=(const T1& right) { return m_data |= le_t(right).data(), *this; } - template le_t& operator ^=(const T1& right) { return m_data ^= le_t(right).data(), *this; } - - le_t operator ++(int) { le_t res = *this; *this += 1; return res; } - le_t operator --(int) { le_t res = *this; *this -= 1; return res; } - le_t& operator ++() { *this += 1; return *this; } - le_t& operator --() { *this -= 1; return *this; } -}; - template struct is_le_t : public std::integral_constant { }; @@ -813,15 +734,13 @@ template struct to_le // le_t if possible, T otherwise template using to_le_t = typename to_le::type; -template struct to_le +template struct to_le // move const qualifier { - // move const qualifier using type = const to_le_t; }; -template struct to_le +template struct to_le // move volatile qualifier { - // move volatile qualifier using type = volatile to_le_t; }; @@ -837,12 +756,7 @@ template struct to_ne using type = T; }; -template struct to_ne> -{ - using type = T; -}; - -template struct to_ne> +template struct to_ne> { using type = T; }; @@ -850,14 +764,12 @@ template struct to_ne> // restore native endianness for T: returns T for be_t or le_t, T otherwise template using to_ne_t = typename to_ne::type; -template struct to_ne +template struct to_ne // move const qualifier { - // move const qualifier using type = const to_ne_t; }; -template struct to_ne +template struct to_ne // move volatile qualifier { - // move volatile qualifier using type = volatile to_ne_t; }; diff --git a/rpcs3/Emu/Cell/PPUInterpreter.cpp b/rpcs3/Emu/Cell/PPUInterpreter.cpp index d2e2d1552..5d94b04a3 100644 --- a/rpcs3/Emu/Cell/PPUInterpreter.cpp +++ b/rpcs3/Emu/Cell/PPUInterpreter.cpp @@ -970,8 +970,8 @@ void ppu_interpreter::VSLB(PPUThread& CPU, ppu_opcode_t op) void ppu_interpreter::VSLDOI(PPUThread& CPU, ppu_opcode_t op) { u8 tmpSRC[32]; - memcpy(tmpSRC, CPU.VPR[op.vb]._u8, 16); - memcpy(tmpSRC + 16, CPU.VPR[op.va]._u8, 16); + std::memcpy(tmpSRC, CPU.VPR + op.vb, 16); + std::memcpy(tmpSRC + 16, CPU.VPR + op.va, 16); for (uint b = 0; b<16; b++) { @@ -1475,7 +1475,7 @@ void ppu_interpreter::SC(PPUThread& CPU, ppu_opcode_t op) { switch (op.lev) { - case 0x0: SysCalls::DoSyscall(CPU, CPU.GPR[11]); break; + case 0x0: execute_syscall_by_index(CPU, CPU.GPR[11]); break; case 0x3: CPU.fast_stop(); break; default: throw EXCEPTION(""); } diff --git a/rpcs3/Emu/Cell/PPUInterpreter.h b/rpcs3/Emu/Cell/PPUInterpreter.h index 7e9ebc041..1692fb76e 100644 --- a/rpcs3/Emu/Cell/PPUInterpreter.h +++ b/rpcs3/Emu/Cell/PPUInterpreter.h @@ -1,9 +1,6 @@ #pragma once #include "Emu/Cell/PPUOpcodes.h" -#include "Emu/SysCalls/SysCalls.h" -#include "rpcs3/Ini.h" -#include "Emu/SysCalls/Modules.h" #include "Emu/Memory/Memory.h" #include @@ -16,7 +13,7 @@ #include -extern u64 rotate_mask[64][64]; // defined in PPUThread.cpp, static didn't work correctly in GCC 4.9 for some reason +extern u64 rotate_mask[64][64]; // defined in PPUThread.cpp extern u64 get_timebased_time(); inline void InitRotateMask() @@ -1327,8 +1324,8 @@ private: void VPERM(u32 vd, u32 va, u32 vb, u32 vc) { u8 tmpSRC[32]; - memcpy(tmpSRC, CPU.VPR[vb]._u8, 16); - memcpy(tmpSRC + 16, CPU.VPR[va]._u8, 16); + std::memcpy(tmpSRC, CPU.VPR + vb, 16); + std::memcpy(tmpSRC + 16, CPU.VPR + va, 16); for (uint b = 0; b < 16; b++) { @@ -1703,8 +1700,8 @@ private: void VSLDOI(u32 vd, u32 va, u32 vb, u32 sh) { u8 tmpSRC[32]; - memcpy(tmpSRC, CPU.VPR[vb]._u8, 16); - memcpy(tmpSRC + 16, CPU.VPR[va]._u8, 16); + std::memcpy(tmpSRC, CPU.VPR + vb, 16); + std::memcpy(tmpSRC + 16, CPU.VPR + va, 16); for(uint b=0; b<16; b++) { @@ -2232,13 +2229,17 @@ private: } void HACK(u32 index) { + extern void execute_ppu_func_by_index(PPUThread& ppu, u32 index); + execute_ppu_func_by_index(CPU, index); } void SC(u32 lev) { + extern void execute_syscall_by_index(PPUThread& ppu, u64 code); + switch (lev) { - case 0x0: SysCalls::DoSyscall(CPU, CPU.GPR[11]); break; + case 0x0: execute_syscall_by_index(CPU, CPU.GPR[11]); break; case 0x1: throw EXCEPTION("HyperCall LV1"); case 0x3: CPU.fast_stop(); break; default: throw EXCEPTION("Unknown level (0x%x)", lev); @@ -2487,12 +2488,12 @@ private: void LDX(u32 rd, u32 ra, u32 rb) { const u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb]; - CPU.GPR[rd] = vm::read64(VM_CAST(addr)); + CPU.GPR[rd] = vm::ps3::read64(VM_CAST(addr)); } void LWZX(u32 rd, u32 ra, u32 rb) { const u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb]; - CPU.GPR[rd] = vm::read32(VM_CAST(addr)); + CPU.GPR[rd] = vm::ps3::read32(VM_CAST(addr)); } void SLW(u32 ra, u32 rs, u32 rb, u32 rc) { @@ -2564,7 +2565,7 @@ private: void LVEHX(u32 vd, u32 ra, u32 rb) { const u64 addr = (ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb]) & ~1ULL; - CPU.VPR[vd]._u16[7 - ((addr >> 1) & 0x7)] = vm::read16(VM_CAST(addr)); + CPU.VPR[vd]._u16[7 - ((addr >> 1) & 0x7)] = vm::ps3::read16(VM_CAST(addr)); // check LVEWX comments } void SUBF(u32 rd, u32 ra, u32 rb, u32 oe, u32 rc) @@ -2578,7 +2579,7 @@ private: void LDUX(u32 rd, u32 ra, u32 rb) { const u64 addr = CPU.GPR[ra] + CPU.GPR[rb]; - CPU.GPR[rd] = vm::read64(VM_CAST(addr)); + CPU.GPR[rd] = vm::ps3::read64(VM_CAST(addr)); CPU.GPR[ra] = addr; } void DCBST(u32 ra, u32 rb) @@ -2587,7 +2588,7 @@ private: void LWZUX(u32 rd, u32 ra, u32 rb) { const u64 addr = CPU.GPR[ra] + CPU.GPR[rb]; - CPU.GPR[rd] = vm::read32(VM_CAST(addr)); + CPU.GPR[rd] = vm::ps3::read32(VM_CAST(addr)); CPU.GPR[ra] = addr; } void CNTLZD(u32 ra, u32 rs, u32 rc) @@ -2613,7 +2614,7 @@ private: void LVEWX(u32 vd, u32 ra, u32 rb) { const u64 addr = (ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb]) & ~3ULL; - CPU.VPR[vd]._u32[3 - ((addr >> 2) & 0x3)] = vm::read32(VM_CAST(addr)); + CPU.VPR[vd]._u32[3 - ((addr >> 2) & 0x3)] = vm::ps3::read32(VM_CAST(addr)); // It's not very good idea to implement it using read128(), // because it can theoretically read RawSPU 32-bit MMIO register (read128() will fail) //CPU.VPR[vd] = vm::read128((ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb]) & ~0xfULL); @@ -2650,7 +2651,7 @@ private: void LVX(u32 vd, u32 ra, u32 rb) { const u64 addr = (ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb]) & ~0xfull; - CPU.VPR[vd] = vm::read128(VM_CAST(addr)); + CPU.VPR[vd] = vm::ps3::read128(VM_CAST(addr)); } void NEG(u32 rd, u32 ra, u32 oe, u32 rc) { @@ -2746,7 +2747,7 @@ private: void STDX(u32 rs, u32 ra, u32 rb) { const u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb]; - vm::write64(VM_CAST(addr), CPU.GPR[rs]); + vm::ps3::write64(VM_CAST(addr), CPU.GPR[rs]); } void STWCX_(u32 rs, u32 ra, u32 rb) { @@ -2758,31 +2759,31 @@ private: void STWX(u32 rs, u32 ra, u32 rb) { const u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb]; - vm::write32(VM_CAST(addr), (u32)CPU.GPR[rs]); + vm::ps3::write32(VM_CAST(addr), (u32)CPU.GPR[rs]); } void STVEHX(u32 vs, u32 ra, u32 rb) { const u64 addr = (ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb]) & ~1ULL; const u8 eb = (addr & 0xf) >> 1; - vm::write16(VM_CAST(addr), CPU.VPR[vs]._u16[7 - eb]); + vm::ps3::write16(VM_CAST(addr), CPU.VPR[vs]._u16[7 - eb]); } void STDUX(u32 rs, u32 ra, u32 rb) { const u64 addr = CPU.GPR[ra] + CPU.GPR[rb]; - vm::write64(VM_CAST(addr), CPU.GPR[rs]); + vm::ps3::write64(VM_CAST(addr), CPU.GPR[rs]); CPU.GPR[ra] = addr; } void STWUX(u32 rs, u32 ra, u32 rb) { const u64 addr = CPU.GPR[ra] + CPU.GPR[rb]; - vm::write32(VM_CAST(addr), (u32)CPU.GPR[rs]); + vm::ps3::write32(VM_CAST(addr), (u32)CPU.GPR[rs]); CPU.GPR[ra] = addr; } void STVEWX(u32 vs, u32 ra, u32 rb) { const u64 addr = (ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb]) & ~3ULL; const u8 eb = (addr & 0xf) >> 2; - vm::write32(VM_CAST(addr), CPU.VPR[vs]._u32[3 - eb]); + vm::ps3::write32(VM_CAST(addr), CPU.VPR[vs]._u32[3 - eb]); } void SUBFZE(u32 rd, u32 ra, u32 oe, u32 rc) { @@ -2815,7 +2816,7 @@ private: void STVX(u32 vs, u32 ra, u32 rb) { const u64 addr = (ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb]) & ~0xfull; - vm::write128(VM_CAST(addr), CPU.VPR[vs]); + vm::ps3::write128(VM_CAST(addr), CPU.VPR[vs]); } void MULLD(u32 rd, u32 ra, u32 rb, u32 oe, u32 rc) { @@ -2875,7 +2876,7 @@ private: void LHZX(u32 rd, u32 ra, u32 rb) { const u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb]; - CPU.GPR[rd] = vm::read16(VM_CAST(addr)); + CPU.GPR[rd] = vm::ps3::read16(VM_CAST(addr)); } void EQV(u32 ra, u32 rs, u32 rb, u32 rc) { @@ -2889,7 +2890,7 @@ private: void LHZUX(u32 rd, u32 ra, u32 rb) { const u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb]; - CPU.GPR[rd] = vm::read16(VM_CAST(addr)); + CPU.GPR[rd] = vm::ps3::read16(VM_CAST(addr)); CPU.GPR[ra] = addr; } void XOR(u32 ra, u32 rs, u32 rb, u32 rc) @@ -2904,7 +2905,7 @@ private: void LWAX(u32 rd, u32 ra, u32 rb) { const u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb]; - CPU.GPR[rd] = (s64)(s32)vm::read32(VM_CAST(addr)); + CPU.GPR[rd] = (s64)(s32)vm::ps3::read32(VM_CAST(addr)); } void DST(u32 ra, u32 rb, u32 strm, u32 t) { @@ -2912,12 +2913,12 @@ private: void LHAX(u32 rd, u32 ra, u32 rb) { const u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb]; - CPU.GPR[rd] = (s64)(s16)vm::read16(VM_CAST(addr)); + CPU.GPR[rd] = (s64)(s16)vm::ps3::read16(VM_CAST(addr)); } void LVXL(u32 vd, u32 ra, u32 rb) { const u64 addr = (ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb]) & ~0xfull; - CPU.VPR[vd] = vm::read128(VM_CAST(addr)); + CPU.VPR[vd] = vm::ps3::read128(VM_CAST(addr)); } void MFTB(u32 rd, u32 spr) { @@ -2934,7 +2935,7 @@ private: void LWAUX(u32 rd, u32 ra, u32 rb) { const u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb]; - CPU.GPR[rd] = (s64)(s32)vm::read32(VM_CAST(addr)); + CPU.GPR[rd] = (s64)(s32)vm::ps3::read32(VM_CAST(addr)); CPU.GPR[ra] = addr; } void DSTST(u32 ra, u32 rb, u32 strm, u32 t) @@ -2943,13 +2944,13 @@ private: void LHAUX(u32 rd, u32 ra, u32 rb) { const u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb]; - CPU.GPR[rd] = (s64)(s16)vm::read16(VM_CAST(addr)); + CPU.GPR[rd] = (s64)(s16)vm::ps3::read16(VM_CAST(addr)); CPU.GPR[ra] = addr; } void STHX(u32 rs, u32 ra, u32 rb) { const u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb]; - vm::write16(VM_CAST(addr), (u16)CPU.GPR[rs]); + vm::ps3::write16(VM_CAST(addr), (u16)CPU.GPR[rs]); } void ORC(u32 ra, u32 rs, u32 rb, u32 rc) { @@ -2963,7 +2964,7 @@ private: void STHUX(u32 rs, u32 ra, u32 rb) { const u64 addr = CPU.GPR[ra] + CPU.GPR[rb]; - vm::write16(VM_CAST(addr), (u16)CPU.GPR[rs]); + vm::ps3::write16(VM_CAST(addr), (u16)CPU.GPR[rs]); CPU.GPR[ra] = addr; } void OR(u32 ra, u32 rs, u32 rb, u32 rc) @@ -3023,7 +3024,7 @@ private: void STVXL(u32 vs, u32 ra, u32 rb) { const u64 addr = (ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb]) & ~0xfull; - vm::write128(VM_CAST(addr), CPU.VPR[vs]); + vm::ps3::write128(VM_CAST(addr), CPU.VPR[vs]); } void DIVD(u32 rd, u32 ra, u32 rb, u32 oe, u32 rc) { @@ -3148,7 +3149,7 @@ private: { if (N > 3) { - CPU.GPR[reg] = vm::read32(VM_CAST(addr)); + CPU.GPR[reg] = vm::ps3::read32(VM_CAST(addr)); addr += 4; N -= 4; } @@ -3216,7 +3217,7 @@ private: u32 count = CPU.XER.XER & 0x7F; for (; count >= 4; count -= 4, addr += 4, rs = (rs+1) & 31) { - vm::write32(VM_CAST(addr), (u32)CPU.GPR[rs]); + vm::ps3::write32(VM_CAST(addr), (u32)CPU.GPR[rs]); } if (count) { @@ -3281,7 +3282,7 @@ private: { if (N > 3) { - vm::write32(VM_CAST(addr), (u32)CPU.GPR[reg]); + vm::ps3::write32(VM_CAST(addr), (u32)CPU.GPR[reg]); addr += 4; N -= 4; } @@ -3424,7 +3425,7 @@ private: void STFIWX(u32 frs, u32 ra, u32 rb) { const u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb]; - vm::write32(VM_CAST(addr), (u32&)CPU.FPR[frs]); + vm::ps3::write32(VM_CAST(addr), (u32&)CPU.FPR[frs]); } void EXTSW(u32 ra, u32 rs, u32 rc) { @@ -3444,12 +3445,12 @@ private: void LWZ(u32 rd, u32 ra, s32 d) { const u64 addr = ra ? CPU.GPR[ra] + d : d; - CPU.GPR[rd] = vm::read32(VM_CAST(addr)); + CPU.GPR[rd] = vm::ps3::read32(VM_CAST(addr)); } void LWZU(u32 rd, u32 ra, s32 d) { const u64 addr = CPU.GPR[ra] + d; - CPU.GPR[rd] = vm::read32(VM_CAST(addr)); + CPU.GPR[rd] = vm::ps3::read32(VM_CAST(addr)); CPU.GPR[ra] = addr; } void LBZ(u32 rd, u32 ra, s32 d) @@ -3466,12 +3467,12 @@ private: void STW(u32 rs, u32 ra, s32 d) { const u64 addr = ra ? CPU.GPR[ra] + d : d; - vm::write32(VM_CAST(addr), (u32)CPU.GPR[rs]); + vm::ps3::write32(VM_CAST(addr), (u32)CPU.GPR[rs]); } void STWU(u32 rs, u32 ra, s32 d) { const u64 addr = CPU.GPR[ra] + d; - vm::write32(VM_CAST(addr), (u32)CPU.GPR[rs]); + vm::ps3::write32(VM_CAST(addr), (u32)CPU.GPR[rs]); CPU.GPR[ra] = addr; } void STB(u32 rs, u32 ra, s32 d) @@ -3488,34 +3489,34 @@ private: void LHZ(u32 rd, u32 ra, s32 d) { const u64 addr = ra ? CPU.GPR[ra] + d : d; - CPU.GPR[rd] = vm::read16(VM_CAST(addr)); + CPU.GPR[rd] = vm::ps3::read16(VM_CAST(addr)); } void LHZU(u32 rd, u32 ra, s32 d) { const u64 addr = CPU.GPR[ra] + d; - CPU.GPR[rd] = vm::read16(VM_CAST(addr)); + CPU.GPR[rd] = vm::ps3::read16(VM_CAST(addr)); CPU.GPR[ra] = addr; } void LHA(u32 rd, u32 ra, s32 d) { const u64 addr = ra ? CPU.GPR[ra] + d : d; - CPU.GPR[rd] = (s64)(s16)vm::read16(VM_CAST(addr)); + CPU.GPR[rd] = (s64)(s16)vm::ps3::read16(VM_CAST(addr)); } void LHAU(u32 rd, u32 ra, s32 d) { const u64 addr = CPU.GPR[ra] + d; - CPU.GPR[rd] = (s64)(s16)vm::read16(VM_CAST(addr)); + CPU.GPR[rd] = (s64)(s16)vm::ps3::read16(VM_CAST(addr)); CPU.GPR[ra] = addr; } void STH(u32 rs, u32 ra, s32 d) { const u64 addr = ra ? CPU.GPR[ra] + d : d; - vm::write16(VM_CAST(addr), (u16)CPU.GPR[rs]); + vm::ps3::write16(VM_CAST(addr), (u16)CPU.GPR[rs]); } void STHU(u32 rs, u32 ra, s32 d) { const u64 addr = CPU.GPR[ra] + d; - vm::write16(VM_CAST(addr), (u16)CPU.GPR[rs]); + vm::ps3::write16(VM_CAST(addr), (u16)CPU.GPR[rs]); CPU.GPR[ra] = addr; } void LMW(u32 rd, u32 ra, s32 d) @@ -3523,7 +3524,7 @@ private: u64 addr = ra ? CPU.GPR[ra] + d : d; for(u32 i=rd; i<32; ++i, addr += 4) { - CPU.GPR[i] = vm::read32(VM_CAST(addr)); + CPU.GPR[i] = vm::ps3::read32(VM_CAST(addr)); } } void STMW(u32 rs, u32 ra, s32 d) @@ -3531,7 +3532,7 @@ private: u64 addr = ra ? CPU.GPR[ra] + d : d; for(u32 i=rs; i<32; ++i, addr += 4) { - vm::write32(VM_CAST(addr), (u32)CPU.GPR[i]); + vm::ps3::write32(VM_CAST(addr), (u32)CPU.GPR[i]); } } void LFS(u32 frd, u32 ra, s32 d) @@ -3619,18 +3620,18 @@ private: void LD(u32 rd, u32 ra, s32 ds) { const u64 addr = ra ? CPU.GPR[ra] + ds : ds; - CPU.GPR[rd] = vm::read64(VM_CAST(addr)); + CPU.GPR[rd] = vm::ps3::read64(VM_CAST(addr)); } void LDU(u32 rd, u32 ra, s32 ds) { const u64 addr = CPU.GPR[ra] + ds; - CPU.GPR[rd] = vm::read64(VM_CAST(addr)); + CPU.GPR[rd] = vm::ps3::read64(VM_CAST(addr)); CPU.GPR[ra] = addr; } void LWA(u32 rd, u32 ra, s32 ds) { const u64 addr = ra ? CPU.GPR[ra] + ds : ds; - CPU.GPR[rd] = (s64)(s32)vm::read32(VM_CAST(addr)); + CPU.GPR[rd] = (s64)(s32)vm::ps3::read32(VM_CAST(addr)); } void FDIVS(u32 frd, u32 fra, u32 frb, u32 rc) {FDIV(frd, fra, frb, rc, true);} void FSUBS(u32 frd, u32 fra, u32 frb, u32 rc) {FSUB(frd, fra, frb, rc, true);} @@ -3684,12 +3685,12 @@ private: void STD(u32 rs, u32 ra, s32 d) { const u64 addr = ra ? CPU.GPR[ra] + d : d; - vm::write64(VM_CAST(addr), CPU.GPR[rs]); + vm::ps3::write64(VM_CAST(addr), CPU.GPR[rs]); } void STDU(u32 rs, u32 ra, s32 ds) { const u64 addr = CPU.GPR[ra] + ds; - vm::write64(VM_CAST(addr), CPU.GPR[rs]); + vm::ps3::write64(VM_CAST(addr), CPU.GPR[rs]); CPU.GPR[ra] = addr; } void MTFSB1(u32 crbd, u32 rc) diff --git a/rpcs3/Emu/Cell/PPULLVMRecompiler.cpp b/rpcs3/Emu/Cell/PPULLVMRecompiler.cpp index 306b1a3ba..f0cf394d4 100644 --- a/rpcs3/Emu/Cell/PPULLVMRecompiler.cpp +++ b/rpcs3/Emu/Cell/PPULLVMRecompiler.cpp @@ -1,5 +1,6 @@ #include "stdafx.h" #ifdef LLVM_AVAILABLE +#include "rpcs3/Ini.h" #include "Utilities/Log.h" #include "Emu/System.h" #include "Emu/Cell/PPUDisAsm.h" diff --git a/rpcs3/Emu/Cell/PPULLVMRecompilerCore.cpp b/rpcs3/Emu/Cell/PPULLVMRecompilerCore.cpp index d3af52b2e..17c2c2231 100644 --- a/rpcs3/Emu/Cell/PPULLVMRecompilerCore.cpp +++ b/rpcs3/Emu/Cell/PPULLVMRecompilerCore.cpp @@ -29,6 +29,9 @@ #pragma warning(pop) #endif +extern void execute_ppu_func_by_index(PPUThread& ppu, u32 id); +extern void execute_syscall_by_index(PPUThread& ppu, u64 code); + using namespace llvm; using namespace ppu_recompiler_llvm; @@ -1787,7 +1790,7 @@ void Compiler::HACK(u32 index) { static u32 wrappedDoSyscall(PPUThread &CPU, u64 code) noexcept { try { - SysCalls::DoSyscall(CPU, code); + execute_syscall_by_index(CPU, code); return ExecutionStatus::ExecutionStatusBlockEnded; } catch (...) @@ -1812,7 +1815,7 @@ void Compiler::SC(u32 lev) { } break; case 3: - Call("PPUThread.FastStop", &PPUThread::fast_stop, m_state.args[CompileTaskState::Args::State]); + Call("PPUThread.fast_stop", &PPUThread::fast_stop, m_state.args[CompileTaskState::Args::State]); break; default: CompilationError(fmt::format("SC %u", lev)); @@ -2160,7 +2163,7 @@ void Compiler::TW(u32 to, u32 ra, u32 rb) { } void Compiler::LVSL(u32 vd, u32 ra, u32 rb) { - static const v128 s_lvsl_values[] = { + static const u64 s_lvsl_values[0x10][2] = { { 0x08090A0B0C0D0E0F, 0x0001020304050607 }, { 0x090A0B0C0D0E0F10, 0x0102030405060708 }, { 0x0A0B0C0D0E0F1011, 0x0203040506070809 }, @@ -2389,7 +2392,7 @@ void Compiler::CMPL(u32 crfd, u32 l, u32 ra, u32 rb) { } void Compiler::LVSR(u32 vd, u32 ra, u32 rb) { - static const v128 s_lvsr_values[] = { + static const u64 s_lvsr_values[0x10][2] = { { 0x18191A1B1C1D1E1F, 0x1011121314151617 }, { 0x1718191A1B1C1D1E, 0x0F10111213141516 }, { 0x161718191A1B1C1D, 0x0E0F101112131415 }, diff --git a/rpcs3/Emu/Cell/PPULLVMRecompilerTests.cpp b/rpcs3/Emu/Cell/PPULLVMRecompilerTests.cpp index c29569832..a55e33240 100644 --- a/rpcs3/Emu/Cell/PPULLVMRecompilerTests.cpp +++ b/rpcs3/Emu/Cell/PPULLVMRecompilerTests.cpp @@ -99,7 +99,7 @@ struct ppu_recompiler_llvm::PPUState { address = addr; for (int i = 0; i < (sizeof(mem_block) / 8); i++) { - mem_block[i] = vm::read64(address + (i * 8)); + mem_block[i] = vm::ps3::read64(address + (i * 8)); } } @@ -123,7 +123,7 @@ struct ppu_recompiler_llvm::PPUState { ppu.TB = TB; for (int i = 0; i < (sizeof(mem_block) / 8); i++) { - vm::write64(address + (i * 8), mem_block[i]); + vm::ps3::write64(address + (i * 8), mem_block[i]); } } diff --git a/rpcs3/Emu/Cell/PPUThread.cpp b/rpcs3/Emu/Cell/PPUThread.cpp index e9a5fa666..884f58c9f 100644 --- a/rpcs3/Emu/Cell/PPUThread.cpp +++ b/rpcs3/Emu/Cell/PPUThread.cpp @@ -5,8 +5,6 @@ #include "Emu/System.h" #include "Emu/IdManager.h" #include "Emu/Cell/PPUThread.h" -#include "Emu/SysCalls/SysCalls.h" -#include "Emu/SysCalls/Modules.h" #include "Emu/Cell/PPUDecoder.h" #include "Emu/Cell/PPUInterpreter.h" #include "Emu/Cell/PPUInterpreter2.h" @@ -51,7 +49,7 @@ void ppu_decoder_cache_t::initialize(u32 addr, u32 size) inter->func = ppu_interpreter::NULL_OP; // decode PPU opcode - dec.Decode(vm::read32(pos)); + dec.Decode(vm::ps3::read32(pos)); // store function address pointer[pos / 4] = inter->func; @@ -81,13 +79,15 @@ PPUThread::~PPUThread() void PPUThread::dump_info() const { + extern std::string get_ps3_function_name(u64 fid); + if (~hle_code < 1024) { - LOG_SUCCESS(HLE, "Last syscall: %lld (%s)", ~hle_code, SysCalls::GetFuncName(hle_code)); + LOG_SUCCESS(HLE, "Last syscall: %lld (%s)", ~hle_code, get_ps3_function_name(hle_code)); } else if (hle_code) { - LOG_SUCCESS(HLE, "Last function: %s (0x%llx)", SysCalls::GetFuncName(hle_code), hle_code); + LOG_SUCCESS(HLE, "Last function: %s (0x%llx)", get_ps3_function_name(hle_code), hle_code); } CPUThread::dump_info(); @@ -214,7 +214,7 @@ int FPRdouble::Cmp(PPCdouble a, PPCdouble b) u64 PPUThread::get_stack_arg(s32 i) { - return vm::read64(VM_CAST(GPR[1] + 0x70 + 0x8 * (i - 9))); + return vm::ps3::read64(VM_CAST(GPR[1] + 0x70 + 0x8 * (i - 9))); } void PPUThread::fast_call(u32 addr, u32 rtoc) @@ -313,7 +313,7 @@ void PPUThread::task() if (!m_state.load()) { // call interpreter function - func(*this, { vm::read32(PC) }); + func(*this, { vm::ps3::read32(PC) }); // next instruction PC += 4; @@ -335,8 +335,8 @@ ppu_thread::ppu_thread(u32 entry, const std::string& name, u32 stack_size, s32 p if (entry) { - ppu->PC = vm::read32(entry); - ppu->GPR[2] = vm::read32(entry + 4); // rtoc + ppu->PC = vm::ps3::read32(entry); + ppu->GPR[2] = vm::ps3::read32(entry + 4); // rtoc } ppu->stack_size = stack_size ? stack_size : Emu.GetPrimaryStackSize(); diff --git a/rpcs3/Emu/Cell/PPUThread.h b/rpcs3/Emu/Cell/PPUThread.h index 11a0e1047..bfad14532 100644 --- a/rpcs3/Emu/Cell/PPUThread.h +++ b/rpcs3/Emu/Cell/PPUThread.h @@ -1012,3 +1012,20 @@ force_inline T cast_from_ppu_gpr(const u64 reg) { return cast_ppu_gpr::from_gpr(reg); } + +// flags set in ModuleFunc +enum : u32 +{ + MFF_FORCED_HLE = (1 << 0), // always call HLE function + MFF_NO_RETURN = (1 << 1), // uses EIF_USE_BRANCH flag with LLE, ignored with MFF_FORCED_HLE +}; + +// flags passed with index +enum : u32 +{ + EIF_SAVE_RTOC = (1 << 25), // save RTOC in [SP+0x28] before calling HLE/LLE function + EIF_PERFORM_BLR = (1 << 24), // do BLR after calling HLE/LLE function + EIF_USE_BRANCH = (1 << 23), // do only branch, LLE must be set, last_syscall must be zero + + EIF_FLAGS = 0x3800000, // all flags +}; diff --git a/rpcs3/Emu/SysCalls/FuncList.cpp b/rpcs3/Emu/SysCalls/FuncList.cpp index 359ee6343..95705cb01 100644 --- a/rpcs3/Emu/SysCalls/FuncList.cpp +++ b/rpcs3/Emu/SysCalls/FuncList.cpp @@ -2,7 +2,7 @@ #include "Modules.h" #include "SysCalls.h" -std::string SysCalls::GetFuncName(const u64 fid) +std::string get_ps3_function_name(u64 fid) { // check syscalls switch (~fid) diff --git a/rpcs3/Emu/SysCalls/Modules.cpp b/rpcs3/Emu/SysCalls/Modules.cpp index 2e09e1a81..3788a03dc 100644 --- a/rpcs3/Emu/SysCalls/Modules.cpp +++ b/rpcs3/Emu/SysCalls/Modules.cpp @@ -112,18 +112,18 @@ ModuleFunc* get_ppu_func_by_index(u32 index) return &g_ppu_func_list[index]; } -void execute_ppu_func_by_index(PPUThread& CPU, u32 index) +void execute_ppu_func_by_index(PPUThread& ppu, u32 index) { if (auto func = get_ppu_func_by_index(index)) { // save RTOC if necessary if (index & EIF_SAVE_RTOC) { - vm::write64(VM_CAST(CPU.GPR[1] + 0x28), CPU.GPR[2]); + vm::write64(VM_CAST(ppu.GPR[1] + 0x28), ppu.GPR[2]); } // save old syscall/NID value - const auto last_code = CPU.hle_code; + const auto last_code = ppu.hle_code; // branch directly to the LLE function if (index & EIF_USE_BRANCH) @@ -132,39 +132,39 @@ void execute_ppu_func_by_index(PPUThread& CPU, u32 index) if (last_code) { - throw EXCEPTION("This function cannot be called from the callback: %s (0x%llx)", SysCalls::GetFuncName(func->id), func->id); + throw EXCEPTION("This function cannot be called from the callback: %s (0x%llx)", get_ps3_function_name(func->id), func->id); } if (!func->lle_func) { - throw EXCEPTION("LLE function not set: %s (0x%llx)", SysCalls::GetFuncName(func->id), func->id); + throw EXCEPTION("LLE function not set: %s (0x%llx)", get_ps3_function_name(func->id), func->id); } if (func->flags & MFF_FORCED_HLE) { - throw EXCEPTION("Forced HLE enabled: %s (0x%llx)", SysCalls::GetFuncName(func->id), func->id); + throw EXCEPTION("Forced HLE enabled: %s (0x%llx)", get_ps3_function_name(func->id), func->id); } if (Ini.HLELogging.GetValue()) { - LOG_NOTICE(HLE, "Branch to LLE function: %s (0x%llx)", SysCalls::GetFuncName(func->id), func->id); + LOG_NOTICE(HLE, "Branch to LLE function: %s (0x%llx)", get_ps3_function_name(func->id), func->id); } if (index & EIF_PERFORM_BLR) { - throw EXCEPTION("TODO: Branch with link: %s (0x%llx)", SysCalls::GetFuncName(func->id), func->id); + throw EXCEPTION("TODO: Branch with link: %s (0x%llx)", get_ps3_function_name(func->id), func->id); // CPU.LR = CPU.PC + 4; } const auto data = vm::get_ptr>(func->lle_func.addr()); - CPU.PC = data[0] - 4; - CPU.GPR[2] = data[1]; // set rtoc + ppu.PC = data[0] - 4; + ppu.GPR[2] = data[1]; // set rtoc return; } // change current syscall/NID value - CPU.hle_code = func->id; + ppu.hle_code = func->id; if (func->lle_func && !(func->flags & MFF_FORCED_HLE)) { @@ -176,49 +176,49 @@ void execute_ppu_func_by_index(PPUThread& CPU, u32 index) if (Ini.HLELogging.GetValue()) { - LOG_NOTICE(HLE, "LLE function called: %s", SysCalls::GetFuncName(func->id)); + LOG_NOTICE(HLE, "LLE function called: %s", get_ps3_function_name(func->id)); } - CPU.fast_call(pc, rtoc); + ppu.fast_call(pc, rtoc); if (Ini.HLELogging.GetValue()) { - LOG_NOTICE(HLE, "LLE function finished: %s -> 0x%llx", SysCalls::GetFuncName(func->id), CPU.GPR[3]); + LOG_NOTICE(HLE, "LLE function finished: %s -> 0x%llx", get_ps3_function_name(func->id), ppu.GPR[3]); } } else if (func->func) { if (Ini.HLELogging.GetValue()) { - LOG_NOTICE(HLE, "HLE function called: %s", SysCalls::GetFuncName(func->id)); + LOG_NOTICE(HLE, "HLE function called: %s", get_ps3_function_name(func->id)); } - func->func(CPU); + func->func(ppu); if (Ini.HLELogging.GetValue()) { - LOG_NOTICE(HLE, "HLE function finished: %s -> 0x%llx", SysCalls::GetFuncName(func->id), CPU.GPR[3]); + LOG_NOTICE(HLE, "HLE function finished: %s -> 0x%llx", get_ps3_function_name(func->id), ppu.GPR[3]); } } else { - LOG_ERROR(HLE, "Unimplemented function: %s -> CELL_OK", SysCalls::GetFuncName(func->id)); - CPU.GPR[3] = 0; + LOG_ERROR(HLE, "Unimplemented function: %s -> CELL_OK", get_ps3_function_name(func->id)); + ppu.GPR[3] = 0; } if (index & EIF_PERFORM_BLR) { // return if necessary - CPU.PC = VM_CAST(CPU.LR & ~3) - 4; + ppu.PC = VM_CAST(ppu.LR & ~3) - 4; } // execute module-specific error check - if ((s64)CPU.GPR[3] < 0 && func->module && func->module->on_error) + if ((s64)ppu.GPR[3] < 0 && func->module && func->module->on_error) { - func->module->on_error(CPU.GPR[3], func); + func->module->on_error(ppu.GPR[3], func); } - CPU.hle_code = last_code; + ppu.hle_code = last_code; } else { diff --git a/rpcs3/Emu/SysCalls/Modules.h b/rpcs3/Emu/SysCalls/Modules.h index 8c71731e6..c1f2d64ad 100644 --- a/rpcs3/Emu/SysCalls/Modules.h +++ b/rpcs3/Emu/SysCalls/Modules.h @@ -9,23 +9,6 @@ namespace vm { using namespace ps3; } template class Module; -// flags set in ModuleFunc -enum : u32 -{ - MFF_FORCED_HLE = (1 << 0), // always call HLE function - MFF_NO_RETURN = (1 << 1), // uses EIF_USE_BRANCH flag with LLE, ignored with MFF_FORCED_HLE -}; - -// flags passed with index -enum : u32 -{ - EIF_SAVE_RTOC = (1 << 25), // save RTOC in [SP+0x28] before calling HLE/LLE function - EIF_PERFORM_BLR = (1 << 24), // do BLR after calling HLE/LLE function - EIF_USE_BRANCH = (1 << 23), // do only branch, LLE must be set, last_syscall must be zero - - EIF_FLAGS = 0x3800000, // all flags -}; - struct ModuleFunc { u32 id; @@ -153,7 +136,8 @@ void add_variable(u32 nid, Module<>* module, const char* name, u32(*addr)()); ModuleFunc* get_ppu_func_by_nid(u32 nid, u32* out_index = nullptr); ModuleFunc* get_ppu_func_by_index(u32 index); ModuleVariable* get_variable_by_nid(u32 nid); -void execute_ppu_func_by_index(PPUThread& CPU, u32 id); +void execute_ppu_func_by_index(PPUThread& ppu, u32 id); +extern std::string get_ps3_function_name(u64 fid); void clear_ppu_functions(); u32 get_function_id(const char* name); diff --git a/rpcs3/Emu/SysCalls/SysCalls.cpp b/rpcs3/Emu/SysCalls/SysCalls.cpp index 4d765a46d..24b1b4e1d 100644 --- a/rpcs3/Emu/SysCalls/SysCalls.cpp +++ b/rpcs3/Emu/SysCalls/SysCalls.cpp @@ -37,7 +37,7 @@ void null_func(PPUThread& ppu) { const u64 code = ppu.GPR[11]; - LOG_ERROR(HLE, "Unimplemented syscall %lld: %s -> CELL_OK", code, SysCalls::GetFuncName(~code)); + LOG_ERROR(HLE, "Unimplemented syscall %lld: %s -> CELL_OK", code, get_ps3_function_name(~code)); ppu.GPR[3] = 0; } @@ -891,27 +891,27 @@ const ppu_func_caller g_sc_table[1024] = null_func, null_func, null_func, BIND_FUNC(cellGcmCallback), //1023 UNS }; -void SysCalls::DoSyscall(PPUThread& CPU, u64 code) +void execute_syscall_by_index(PPUThread& ppu, u64 code) { if (code >= 1024) { throw EXCEPTION("Invalid syscall number (0x%llx)", code); } - auto last_code = CPU.hle_code; - CPU.hle_code = ~code; + auto last_code = ppu.hle_code; + ppu.hle_code = ~code; if (Ini.HLELogging.GetValue()) { - LOG_NOTICE(PPU, "Syscall %lld called: %s", code, SysCalls::GetFuncName(~code)); + LOG_NOTICE(PPU, "Syscall %lld called: %s", code, get_ps3_function_name(~code)); } - g_sc_table[code](CPU); + g_sc_table[code](ppu); if (Ini.HLELogging.GetValue()) { - LOG_NOTICE(PPU, "Syscall %lld finished: %s -> 0x%llx", code, SysCalls::GetFuncName(~code), CPU.GPR[3]); + LOG_NOTICE(PPU, "Syscall %lld finished: %s -> 0x%llx", code, get_ps3_function_name(~code), ppu.GPR[3]); } - CPU.hle_code = last_code; + ppu.hle_code = last_code; } diff --git a/rpcs3/Emu/SysCalls/SysCalls.h b/rpcs3/Emu/SysCalls/SysCalls.h index 888f7aa61..a12fd14ae 100644 --- a/rpcs3/Emu/SysCalls/SysCalls.h +++ b/rpcs3/Emu/SysCalls/SysCalls.h @@ -19,11 +19,5 @@ public: } }; -class PPUThread; - -class SysCalls -{ -public: - static void DoSyscall(PPUThread& CPU, u64 code); - static std::string GetFuncName(const u64 fid); -}; +void execute_syscall_by_index(class PPUThread& ppu, u64 code); +std::string get_ps3_function_name(u64 fid); diff --git a/rpcs3/Emu/SysCalls/lv2/sys_prx.cpp b/rpcs3/Emu/SysCalls/lv2/sys_prx.cpp index 72b8157e8..06d984368 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_prx.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_prx.cpp @@ -83,7 +83,7 @@ s32 prx_load_module(std::string path, u64 flags, vm::ptrlle_func && !(func->flags & MFF_FORCED_HLE); - sys_prx.Error("Imported %sfunction '%s' in '%s' module (0x%x)", (is_lle ? "LLE " : ""), SysCalls::GetFuncName(nid), module_.first, addr); + sys_prx.Error("Imported %sfunction '%s' in '%s' module (0x%x)", (is_lle ? "LLE " : ""), get_ps3_function_name(nid), module_.first, addr); } if (!patch_ppu_import(addr, index)) diff --git a/rpcs3/Loader/ELF64.cpp b/rpcs3/Loader/ELF64.cpp index 5d4661e96..4166d27c1 100644 --- a/rpcs3/Loader/ELF64.cpp +++ b/rpcs3/Loader/ELF64.cpp @@ -167,8 +167,8 @@ namespace loader module.exports[fnid] = fstub; - //LOG_NOTICE(LOADER, "Exported function '%s' in '%s' module (LLE)", SysCalls::GetFuncName(fnid).c_str(), module_name.c_str()); - LOG_WARNING(LOADER, "**** %s: [%s] -> 0x%x", modulename.c_str(), SysCalls::GetFuncName(fnid).c_str(), (u32)fstub); + //LOG_NOTICE(LOADER, "Exported function '%s' in '%s' module (LLE)", get_ps3_function_name(fnid), module_name); + LOG_WARNING(LOADER, "**** %s: [%s] -> 0x%x", modulename, get_ps3_function_name(fnid), (u32)fstub); } } @@ -204,7 +204,7 @@ namespace loader module.imports[fnid] = fstub; - LOG_WARNING(LOADER, "**** %s: [%s] -> 0x%x", modulename.c_str(), SysCalls::GetFuncName(fnid).c_str(), (u32)fstub); + LOG_WARNING(LOADER, "**** %s: [%s] -> 0x%x", modulename, get_ps3_function_name(fnid), (u32)fstub); } } } @@ -449,7 +449,7 @@ namespace loader if (!vm::check_addr(addr, 8) || !vm::check_addr(i_addr = vm::read32(addr), 4)) { - LOG_ERROR(LOADER, "Failed to inject code for exported function '%s' (opd=0x%x, 0x%x)", SysCalls::GetFuncName(nid), addr, i_addr); + LOG_ERROR(LOADER, "Failed to inject code for exported function '%s' (opd=0x%x, 0x%x)", get_ps3_function_name(nid), addr, i_addr); } else { @@ -470,18 +470,18 @@ namespace loader if (!func) { - LOG_ERROR(LOADER, "Unknown function '%s' (0x%x)", SysCalls::GetFuncName(nid), addr); + LOG_ERROR(LOADER, "Unknown function '%s' (0x%x)", get_ps3_function_name(nid), addr); index = add_ppu_func(ModuleFunc(nid, 0, module, nullptr, nullptr)); } else { - LOG_NOTICE(LOADER, "Imported function '%s' (0x%x)", SysCalls::GetFuncName(nid), addr); + LOG_NOTICE(LOADER, "Imported function '%s' (0x%x)", get_ps3_function_name(nid), addr); } if (!patch_ppu_import(addr, index)) { - LOG_ERROR(LOADER, "Failed to inject code for function '%s' (0x%x)", SysCalls::GetFuncName(nid), addr); + LOG_ERROR(LOADER, "Failed to inject code for function '%s' (0x%x)", get_ps3_function_name(nid), addr); } } } @@ -708,7 +708,7 @@ namespace loader if (!func) { - LOG_ERROR(LOADER, "Unknown function '%s' in '%s' module (0x%x)", SysCalls::GetFuncName(nid), module_name, addr); + LOG_ERROR(LOADER, "Unknown function '%s' in '%s' module (0x%x)", get_ps3_function_name(nid), module_name, addr); index = add_ppu_func(ModuleFunc(nid, 0, module, nullptr, nullptr)); } @@ -716,7 +716,7 @@ namespace loader { const bool is_lle = func->lle_func && !(func->flags & MFF_FORCED_HLE); - LOG_NOTICE(LOADER, "Imported %sfunction '%s' in '%s' module (0x%x)", is_lle ? "LLE " : "", SysCalls::GetFuncName(nid), module_name, addr); + LOG_NOTICE(LOADER, "Imported %sfunction '%s' in '%s' module (0x%x)", is_lle ? "LLE " : "", get_ps3_function_name(nid), module_name, addr); } if (!patch_ppu_import(addr, index)) From 9d68c16c62a0ae4773c541a2b2116faaf5a496ad Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Tue, 15 Sep 2015 19:23:17 +0300 Subject: [PATCH 5/6] be_t (se_t) optimizations --- Utilities/BEType.h | 252 ++++++++++++++++---- rpcs3/Emu/SysCalls/Modules.cpp | 10 +- rpcs3/Emu/SysCalls/Modules/cellFs.cpp | 2 +- rpcs3/Emu/SysCalls/Modules/cellSpurs.cpp | 22 +- rpcs3/Emu/SysCalls/Modules/cellSync.cpp | 12 +- rpcs3/Emu/SysCalls/Modules/cellSync.h | 6 +- rpcs3/Emu/SysCalls/Modules/sys_lwmutex_.cpp | 10 +- rpcs3/Emu/SysCalls/Modules/sys_spinlock.cpp | 4 +- rpcs3/Emu/SysCalls/lv2/sys_cond.cpp | 2 +- rpcs3/Emu/SysCalls/lv2/sys_event_flag.cpp | 2 +- rpcs3/Emu/SysCalls/lv2/sys_mutex.cpp | 2 +- rpcs3/Emu/SysCalls/lv2/sys_rwlock.cpp | 2 +- rpcs3/Emu/SysCalls/lv2/sys_semaphore.cpp | 2 +- rpcs3/Emu/SysCalls/lv2/sys_spu.cpp | 2 +- 14 files changed, 240 insertions(+), 90 deletions(-) diff --git a/Utilities/BEType.h b/Utilities/BEType.h index b9e1d542a..e317bee22 100644 --- a/Utilities/BEType.h +++ b/Utilities/BEType.h @@ -374,6 +374,9 @@ inline v128 operator ~(const v128& other) return v128::from64(~other._u64[0], ~other._u64[1]); } +#define IS_INTEGER(t) (std::is_integral::value || std::is_enum::value) +#define IS_BINARY_COMPARABLE(t1, t2) (IS_INTEGER(t1) && IS_INTEGER(t2) && sizeof(t1) == sizeof(t2)) + template struct se_storage { static_assert(!Size, "Bad se_storage<> type"); @@ -383,6 +386,11 @@ template struct se_storage { using type = u16; + static constexpr u16 swap(u16 src) + { + return (src >> 8) | (src << 8); + } + static inline u16 to(const T& src) { return _byteswap_ushort(reinterpret_cast(src)); @@ -399,6 +407,11 @@ template struct se_storage { using type = u32; + static constexpr u32 swap(u32 src) + { + return (src >> 24) | (src << 24) | ((src >> 8) & 0x0000ff00) | ((src << 8) & 0x00ff0000); + } + static inline u32 to(const T& src) { return _byteswap_ulong(reinterpret_cast(src)); @@ -415,6 +428,17 @@ template struct se_storage { using type = u64; + static constexpr u64 swap(u64 src) + { + return (src >> 56) | (src << 56) | + ((src >> 40) & 0x000000000000ff00) | + ((src >> 24) & 0x0000000000ff0000) | + ((src >> 8) & 0x00000000ff000000) | + ((src << 8) & 0x000000ff00000000) | + ((src << 24) & 0x0000ff0000000000) | + ((src << 40) & 0x00ff000000000000); + } + static inline u64 to(const T& src) { return _byteswap_uint64(reinterpret_cast(src)); @@ -465,16 +489,17 @@ template struct se_convert } }; +static struct se_raw_tag_t {} const se_raw{}; + template class se_t { using type = std::remove_cv_t; - using stype = se_storage_t>; - using storage = se_storage>; + using stype = se_storage_t; + using storage = se_storage; stype m_data; - static_assert(!std::is_class::value || std::is_same::value, "se_t<> error: invalid type (class or structure)"); - static_assert(!std::is_union::value || std::is_same::value || std::is_same::value, "se_t<> error: invalid type (union)"); + static_assert(!std::is_union::value && !std::is_class::value || std::is_same::value || std::is_same::value, "se_t<> error: invalid type (struct or union)"); static_assert(!std::is_pointer::value, "se_t<> error: invalid type (pointer)"); static_assert(!std::is_reference::value, "se_t<> error: invalid type (reference)"); static_assert(!std::is_array::value, "se_t<> error: invalid type (array)"); @@ -484,59 +509,106 @@ template class se_t public: se_t() = default; - se_t(const se_t&) = default; + se_t(const se_t& right) = default; - inline se_t(const type& value) + template::value && !std::is_same, std::decay_t>::value>> inline se_t(const CT& value) : m_data(storage::to(value)) { } + // construct directly from raw data (don't use) + inline se_t(const stype& raw_value, const se_raw_tag_t&) + : m_data(raw_value) + { + } + inline type value() const { return storage::from(m_data); } - inline const stype& data() const + // access underlying raw data (don't use) + inline const stype& raw_data() const { return m_data; } se_t& operator =(const se_t&) = default; - template std::enable_if_t::value, se_t&> operator =(const CT& value) + template inline std::enable_if_t::value && !std::is_same, std::decay_t>::value, se_t&> operator =(const CT& value) { return m_data = storage::to(value), *this; } - operator type() const + inline operator type() const { return value(); } + + // optimization + explicit inline operator bool() const + { + static_assert(std::is_convertible::value, "Illegal conversion to bool"); + + return m_data != 0; + } + + // optimization + template inline std::enable_if_t operator &=(const se_t& right) + { + return m_data &= right.raw_data(), *this; + } + + // optimization + template inline std::enable_if_t::value && std::is_convertible::value, se_t&> operator &=(const CT& right) + { + return m_data &= storage::to(right), *this; + } + + // optimization + template inline std::enable_if_t operator |=(const se_t& right) + { + return m_data |= right.raw_data(), *this; + } + + // optimization + template inline std::enable_if_t::value && std::is_convertible::value, se_t&> operator |=(const CT& right) + { + return m_data |= storage::to(right), *this; + } + + // optimization + template inline std::enable_if_t operator ^=(const se_t& right) + { + return m_data ^= right.raw_data(), *this; + } + + // optimization + template inline std::enable_if_t::value && std::is_convertible::value, se_t&> operator ^=(const CT& right) + { + return m_data ^= storage::to(right), *this; + } }; template class se_t { using type = std::remove_cv_t; - using stype = se_storage_t>; - using storage = se_storage>; type m_data; - static_assert(!std::is_class::value || std::is_same::value, "se_t<> error: invalid type (class or structure)"); - static_assert(!std::is_union::value || std::is_same::value || std::is_same::value, "se_t<> error: invalid type (union)"); + static_assert(!std::is_union::value && !std::is_class::value || std::is_same::value || std::is_same::value, "se_t<> error: invalid type (struct or union)"); static_assert(!std::is_pointer::value, "se_t<> error: invalid type (pointer)"); static_assert(!std::is_reference::value, "se_t<> error: invalid type (reference)"); static_assert(!std::is_array::value, "se_t<> error: invalid type (array)"); static_assert(!std::is_enum::value, "se_t<> error: invalid type (enumeration), use integral type instead"); - static_assert(alignof(type) == alignof(stype), "se_t<> error: unexpected alignment"); public: se_t() = default; se_t(const se_t&) = default; - inline se_t(const type& value) - : m_data(value) + template::value && !std::is_same, std::decay_t>::value>> inline se_t(CT&& value) + : m_data(std::forward(value)) { } @@ -545,34 +617,34 @@ public: return m_data; } - inline const stype& data() const - { - return reinterpret_cast(m_data); - } - se_t& operator =(const se_t& value) = default; - template std::enable_if_t::value, se_t&> operator =(const CT& value) + template inline std::enable_if_t::value && !std::is_same, std::decay_t>::value, se_t&> operator =(const CT& value) { return m_data = value, *this; } - operator type() const + inline operator type() const { return value(); } + + template inline std::enable_if_t::value && std::is_convertible::value, se_t&> operator &=(const CT& right) + { + return m_data &= right, *this; + } + + template inline std::enable_if_t::value && std::is_convertible::value, se_t&> operator |=(const CT& right) + { + return m_data |= right, *this; + } + + template inline std::enable_if_t::value && std::is_convertible::value, se_t&> operator ^=(const CT& right) + { + return m_data ^= right, *this; + } }; -template inline std::enable_if_t::value && std::is_integral::value, bool> operator ==(const se_t& left, const se_t& right) -{ - return left.data() == right.data(); -} - -template inline std::enable_if_t::value && std::is_integral::value, bool> operator !=(const se_t& left, const se_t& right) -{ - return left.data() != right.data(); -} - template inline se_t& operator +=(se_t& left, const T1& right) { auto value = left.value(); @@ -615,24 +687,6 @@ template inline se_t& operator >>=(se_t return left = (value >>= right); } -template inline se_t& operator &=(se_t& left, const T1& right) -{ - auto value = left.value(); - return left = (value &= right); -} - -template inline se_t& operator |=(se_t& left, const T1& right) -{ - auto value = left.value(); - return left = (value |= right); -} - -template inline se_t& operator ^=(se_t& left, const T1& right) -{ - auto value = left.value(); - return left = (value ^= right); -} - template inline se_t operator ++(se_t& left, int) { auto value = left.value(); @@ -661,6 +715,102 @@ template inline se_t& operator --(se_t& right return right = --value; } +// optimization +template inline std::enable_if_t operator ==(const se_t& left, const se_t& right) +{ + return left.raw_data() == right.raw_data(); +} + +// optimization +template inline std::enable_if_t operator ==(const se_t& left, const T2& right) +{ + return left.raw_data() == se_storage::to(right); +} + +// optimization +template inline std::enable_if_t operator ==(const T1& left, const se_t& right) +{ + return se_storage::to(left) == right.raw_data(); +} + +// optimization +template inline std::enable_if_t operator !=(const se_t& left, const se_t& right) +{ + return left.raw_data() != right.raw_data(); +} + +// optimization +template inline std::enable_if_t operator !=(const se_t& left, const T2& right) +{ + return left.raw_data() != se_storage::to(right); +} + +// optimization +template inline std::enable_if_t operator !=(const T1& left, const se_t& right) +{ + return se_storage::to(left) != right.raw_data(); +} + +// optimization +template inline std::enable_if_t= 4, se_t> operator &(const se_t& left, const se_t& right) +{ + return{ static_cast>(left.raw_data() & right.raw_data()), se_raw }; +} + +// optimization +template inline std::enable_if_t= 4, se_t> operator &(const se_t& left, const T2& right) +{ + return{ static_cast>(left.raw_data() & se_storage::to(right)), se_raw }; +} + +// optimization +template inline std::enable_if_t= 4, se_t> operator &(const T1& left, const se_t& right) +{ + return{ static_cast>(se_storage::to(left) & right.raw_data()), se_raw }; +} + +// optimization +template inline std::enable_if_t= 4, se_t> operator |(const se_t& left, const se_t& right) +{ + return{ static_cast>(left.raw_data() | right.raw_data()), se_raw }; +} + +// optimization +template inline std::enable_if_t= 4, se_t> operator |(const se_t& left, const T2& right) +{ + return{ static_cast>(left.raw_data() | se_storage::to(right)), se_raw }; +} + +// optimization +template inline std::enable_if_t= 4, se_t> operator |(const T1& left, const se_t& right) +{ + return{ static_cast>(se_storage::to(left) | right.raw_data()), se_raw }; +} + +// optimization +template inline std::enable_if_t= 4, se_t> operator ^(const se_t& left, const se_t& right) +{ + return{ static_cast>(left.raw_data() ^ right.raw_data()), se_raw }; +} + +// optimization +template inline std::enable_if_t= 4, se_t> operator ^(const se_t& left, const T2& right) +{ + return{ static_cast>(left.raw_data() ^ se_storage::to(right)), se_raw }; +} + +// optimization +template inline std::enable_if_t= 4, se_t> operator ^(const T1& left, const se_t& right) +{ + return{ static_cast>(se_storage::to(left) ^ right.raw_data()), se_raw }; +} + +// optimization +template inline std::enable_if_t= 4, se_t> operator ~(const se_t& right) +{ + return{ static_cast>(~right.raw_data()), se_raw }; +} + #ifdef IS_LE_MACHINE template using be_t = se_t; template using le_t = se_t; diff --git a/rpcs3/Emu/SysCalls/Modules.cpp b/rpcs3/Emu/SysCalls/Modules.cpp index 3788a03dc..a6ab53bd6 100644 --- a/rpcs3/Emu/SysCalls/Modules.cpp +++ b/rpcs3/Emu/SysCalls/Modules.cpp @@ -272,10 +272,10 @@ void hook_ppu_func(vm::ptr base, u32 pos, u32 size) continue; } - const u32 data = sub.ops[x].data.data(); - const u32 mask = sub.ops[x].mask.data(); + const be_t data = sub.ops[x].data; + const be_t mask = sub.ops[x].mask; - const bool match = (base[k].data() & mask) == data; + const bool match = (base[k] & mask) == data; switch (sub.ops[x].type) { @@ -301,8 +301,8 @@ void hook_ppu_func(vm::ptr base, u32 pos, u32 size) } case SPET_LABEL: { - const auto addr = (base + k--).addr(); - const auto lnum = data; + const u32 addr = (base + k--).addr(); + const u32 lnum = data; const auto label = sub.labels.find(lnum); if (label == sub.labels.end()) // register the label diff --git a/rpcs3/Emu/SysCalls/Modules/cellFs.cpp b/rpcs3/Emu/SysCalls/Modules/cellFs.cpp index 83d96244d..773150f25 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellFs.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellFs.cpp @@ -631,7 +631,7 @@ s32 cellFsStReadGetCurrentAddr(u32 fd, vm::ptr addr, vm::ptr size) const u32 position = VM_CAST(file->st_buffer + copied % file->st_ringbuf_size); const u64 total_read = file->st_total_read.load(); - if ((*size = std::min(file->st_ringbuf_size - (position - file->st_buffer), total_read - copied)).data()) + if ((*size = std::min(file->st_ringbuf_size - (position - file->st_buffer), total_read - copied))) { *addr = position; } diff --git a/rpcs3/Emu/SysCalls/Modules/cellSpurs.cpp b/rpcs3/Emu/SysCalls/Modules/cellSpurs.cpp index b2a20633f..6aad17f86 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSpurs.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSpurs.cpp @@ -321,7 +321,7 @@ s32 spursAttachLv2EventQueue(PPUThread& ppu, vm::ptr spurs, u32 queue return CELL_SPURS_CORE_ERROR_ALIGN; } - if (spurs->exception.data()) + if (spurs->exception) { return CELL_SPURS_CORE_ERROR_STAT; } @@ -380,7 +380,7 @@ s32 spursDetachLv2EventQueue(vm::ptr spurs, u8 spuPort, bool spursCre return CELL_SPURS_CORE_ERROR_ALIGN; } - if (!spursCreated && spurs->exception.data()) + if (!spursCreated && spurs->exception) { return CELL_SPURS_CORE_ERROR_STAT; } @@ -555,7 +555,7 @@ s32 spursCreateHandler(vm::ptr spurs, u32 ppuPriority) /// Invoke event handlers s32 spursInvokeEventHandlers(PPUThread& ppu, vm::ptr eventPortMux) { - if (eventPortMux->reqPending.exchange(0).data()) + if (eventPortMux->reqPending.exchange(0)) { const vm::ptr handlerList = eventPortMux->handlerList.exchange(vm::null); @@ -1656,7 +1656,7 @@ s32 cellSpursSetMaxContention(vm::ptr spurs, u32 wid, u32 maxContenti return CELL_SPURS_CORE_ERROR_SRCH; } - if (spurs->exception.data()) + if (spurs->exception) { return CELL_SPURS_CORE_ERROR_STAT; } @@ -1700,7 +1700,7 @@ s32 cellSpursSetPriorities(vm::ptr spurs, u32 wid, vm::cptr prior return CELL_SPURS_CORE_ERROR_SRCH; } - if (spurs->exception.data()) + if (spurs->exception) { return CELL_SPURS_CORE_ERROR_STAT; } @@ -1810,7 +1810,7 @@ s32 cellSpursSetGlobalExceptionEventHandler(vm::ptr spurs, vm::ptrexception.data()) + if (spurs->exception) { return CELL_SPURS_CORE_ERROR_STAT; } @@ -2182,7 +2182,7 @@ s32 spursAddWorkload( return CELL_SPURS_POLICY_MODULE_ERROR_INVAL; } - if (spurs->exception.data()) + if (spurs->exception) { return CELL_SPURS_POLICY_MODULE_ERROR_STAT; } @@ -2398,7 +2398,7 @@ s32 cellSpursWakeUp(PPUThread& ppu, vm::ptr spurs) return CELL_SPURS_POLICY_MODULE_ERROR_ALIGN; } - if (spurs->exception.data()) + if (spurs->exception) { return CELL_SPURS_POLICY_MODULE_ERROR_STAT; } @@ -2433,7 +2433,7 @@ s32 cellSpursSendWorkloadSignal(vm::ptr spurs, u32 wid) return CELL_SPURS_POLICY_MODULE_ERROR_INVAL; } - if ((spurs->wklEnabled.load() & (0x80000000u >> wid)) == 0) + if (!(spurs->wklEnabled.load() & (0x80000000u >> wid))) { return CELL_SPURS_POLICY_MODULE_ERROR_SRCH; } @@ -2504,7 +2504,7 @@ s32 cellSpursReadyCountStore(vm::ptr spurs, u32 wid, u32 value) return CELL_SPURS_POLICY_MODULE_ERROR_SRCH; } - if (spurs->exception.data() || spurs->wklState(wid).load() != 2) + if (spurs->exception || spurs->wklState(wid).load() != 2) { return CELL_SPURS_POLICY_MODULE_ERROR_STAT; } @@ -2630,7 +2630,7 @@ s32 _cellSpursWorkloadFlagReceiver(vm::ptr spurs, u32 wid, u32 is_set return CELL_SPURS_POLICY_MODULE_ERROR_SRCH; } - if (spurs->exception.data()) + if (spurs->exception) { return CELL_SPURS_POLICY_MODULE_ERROR_STAT; } diff --git a/rpcs3/Emu/SysCalls/Modules/cellSync.cpp b/rpcs3/Emu/SysCalls/Modules/cellSync.cpp index 3faae111a..6b16ce479 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSync.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSync.cpp @@ -331,7 +331,7 @@ s32 cellSyncRwmWrite(PPUThread& ppu, vm::ptr rwm, vm::cptr bu vm::wait_op(ppu, rwm.addr(), 4, WRAP_EXPR(rwm->ctrl.atomic_op(&sync_rwm_t::try_write_begin))); // wait until `readers` is zero - vm::wait_op(ppu, rwm.addr(), 4, WRAP_EXPR(!rwm->ctrl.load().readers.data())); + vm::wait_op(ppu, rwm.addr(), 4, WRAP_EXPR(!rwm->ctrl.load().readers)); // copy data from buffer std::memcpy(rwm->buffer.get_ptr(), buffer.get_ptr(), rwm->size); @@ -746,7 +746,7 @@ s32 cellSyncLFQueueInitialize(vm::ptr queue, vm::cptr buf const auto old = queue->init.load(); auto init = old; - if (old.data()) + if (old) { if (sdk_ver > 0x17ffff && old != 2) { @@ -837,7 +837,7 @@ s32 _cellSyncLFQueueGetPushPointer(PPUThread& ppu, vm::ptr queu s32 var2 = (s16)push.m_h8; s32 res; - if (useEventQueue && ((s32)push.m_h5 != var2 || push.m_h7.data() != 0)) + if (useEventQueue && ((s32)push.m_h5 != var2 || push.m_h7)) { res = CELL_SYNC_ERROR_BUSY; } @@ -884,7 +884,7 @@ s32 _cellSyncLFQueueGetPushPointer(PPUThread& ppu, vm::ptr queu if (queue->push1.compare_and_swap_test(old, push)) { - if (!push.m_h7.data() || res) + if (!push.m_h7 || res) { return res; } @@ -1143,7 +1143,7 @@ s32 _cellSyncLFQueueGetPopPointer(PPUThread& ppu, vm::ptr queue s32 var2 = (s32)(s16)pop.m_h4; s32 res; - if (useEventQueue && ((s32)(u16)pop.m_h1 != var2 || pop.m_h3.data() != 0)) + if (useEventQueue && ((s32)(u16)pop.m_h1 != var2 || pop.m_h3)) { res = CELL_SYNC_ERROR_BUSY; } @@ -1190,7 +1190,7 @@ s32 _cellSyncLFQueueGetPopPointer(PPUThread& ppu, vm::ptr queue if (queue->pop1.compare_and_swap_test(old, pop)) { - if (!pop.m_h3.data() || res) + if (!pop.m_h3 || res) { return res; } diff --git a/rpcs3/Emu/SysCalls/Modules/cellSync.h b/rpcs3/Emu/SysCalls/Modules/cellSync.h index c6b006ff4..ef5a8c26a 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSync.h +++ b/rpcs3/Emu/SysCalls/Modules/cellSync.h @@ -111,7 +111,7 @@ struct sync_rwm_t // CellSyncRwm sync var bool try_read_begin() { - if (writers.data()) + if (writers) { return false; } @@ -122,7 +122,7 @@ struct sync_rwm_t // CellSyncRwm sync var bool try_read_end() { - if (!readers.data()) + if (!readers) { return false; } @@ -133,7 +133,7 @@ struct sync_rwm_t // CellSyncRwm sync var bool try_write_begin() { - if (writers.data()) + if (writers) { return false; } diff --git a/rpcs3/Emu/SysCalls/Modules/sys_lwmutex_.cpp b/rpcs3/Emu/SysCalls/Modules/sys_lwmutex_.cpp index 85ba7abeb..1549515d1 100644 --- a/rpcs3/Emu/SysCalls/Modules/sys_lwmutex_.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sys_lwmutex_.cpp @@ -86,7 +86,7 @@ s32 sys_lwmutex_lock(PPUThread& ppu, vm::ptr lwmutex, u64 timeout return CELL_OK; } - if (old_owner.data() == tid.data()) + if (old_owner == tid) { // recursive locking @@ -96,7 +96,7 @@ s32 sys_lwmutex_lock(PPUThread& ppu, vm::ptr lwmutex, u64 timeout return CELL_EDEADLK; } - if (lwmutex->recursive_count.data() == -1) + if (lwmutex->recursive_count == -1) { // if recursion limit reached return CELL_EKRESOURCE; @@ -180,7 +180,7 @@ s32 sys_lwmutex_trylock(PPUThread& ppu, vm::ptr lwmutex) return CELL_OK; } - if (old_owner.data() == tid.data()) + if (old_owner == tid) { // recursive locking @@ -190,7 +190,7 @@ s32 sys_lwmutex_trylock(PPUThread& ppu, vm::ptr lwmutex) return CELL_EDEADLK; } - if (lwmutex->recursive_count.data() == -1) + if (lwmutex->recursive_count == -1) { // if recursion limit reached return CELL_EKRESOURCE; @@ -244,7 +244,7 @@ s32 sys_lwmutex_unlock(PPUThread& ppu, vm::ptr lwmutex) return CELL_EPERM; } - if (lwmutex->recursive_count.data()) + if (lwmutex->recursive_count) { // recursive unlocking succeeded lwmutex->recursive_count--; diff --git a/rpcs3/Emu/SysCalls/Modules/sys_spinlock.cpp b/rpcs3/Emu/SysCalls/Modules/sys_spinlock.cpp index cc80543c9..e1744e31b 100644 --- a/rpcs3/Emu/SysCalls/Modules/sys_spinlock.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sys_spinlock.cpp @@ -19,14 +19,14 @@ void sys_spinlock_lock(PPUThread& ppu, vm::ptr> lock) sysPrxForUser.Log("sys_spinlock_lock(lock=*0x%x)", lock); // prx: exchange with 0xabadcafe, repeat until exchanged with 0 - vm::wait_op(ppu, lock.addr(), 4, WRAP_EXPR(!lock->exchange(0xabadcafe).data())); + vm::wait_op(ppu, lock.addr(), 4, WRAP_EXPR(!lock->exchange(0xabadcafe))); } s32 sys_spinlock_trylock(vm::ptr> lock) { sysPrxForUser.Log("sys_spinlock_trylock(lock=*0x%x)", lock); - if (lock->exchange(0xabadcafe).data()) + if (lock->exchange(0xabadcafe)) { return CELL_EBUSY; } diff --git a/rpcs3/Emu/SysCalls/lv2/sys_cond.cpp b/rpcs3/Emu/SysCalls/lv2/sys_cond.cpp index 5b5c8de7d..6a0ccc721 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_cond.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_cond.cpp @@ -46,7 +46,7 @@ s32 sys_cond_create(vm::ptr cond_id, u32 mutex_id, vm::ptrpshared != SYS_SYNC_NOT_PROCESS_SHARED || attr->ipc_key.data() || attr->flags.data()) + if (attr->pshared != SYS_SYNC_NOT_PROCESS_SHARED || attr->ipc_key || attr->flags) { sys_cond.Error("sys_cond_create(): unknown attributes (pshared=0x%x, ipc_key=0x%llx, flags=0x%x)", attr->pshared, attr->ipc_key, attr->flags); return CELL_EINVAL; diff --git a/rpcs3/Emu/SysCalls/lv2/sys_event_flag.cpp b/rpcs3/Emu/SysCalls/lv2/sys_event_flag.cpp index 1425a2d14..a788aacc3 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_event_flag.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_event_flag.cpp @@ -62,7 +62,7 @@ s32 sys_event_flag_create(vm::ptr id, vm::ptr a return CELL_EINVAL; } - if (attr->pshared != SYS_SYNC_NOT_PROCESS_SHARED || attr->ipc_key.data() || attr->flags.data()) + if (attr->pshared != SYS_SYNC_NOT_PROCESS_SHARED || attr->ipc_key || attr->flags) { sys_event_flag.Error("sys_event_flag_create(): unknown attributes (pshared=0x%x, ipc_key=0x%llx, flags=0x%x)", attr->pshared, attr->ipc_key, attr->flags); return CELL_EINVAL; diff --git a/rpcs3/Emu/SysCalls/lv2/sys_mutex.cpp b/rpcs3/Emu/SysCalls/lv2/sys_mutex.cpp index a34c81fde..0545db9b4 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_mutex.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_mutex.cpp @@ -56,7 +56,7 @@ s32 sys_mutex_create(vm::ptr mutex_id, vm::ptr attr) const bool recursive = attr->recursive == SYS_SYNC_RECURSIVE; - if ((!recursive && attr->recursive != SYS_SYNC_NOT_RECURSIVE) || attr->pshared != SYS_SYNC_NOT_PROCESS_SHARED || attr->adaptive != SYS_SYNC_NOT_ADAPTIVE || attr->ipc_key.data() || attr->flags.data()) + if ((!recursive && attr->recursive != SYS_SYNC_NOT_RECURSIVE) || attr->pshared != SYS_SYNC_NOT_PROCESS_SHARED || attr->adaptive != SYS_SYNC_NOT_ADAPTIVE || attr->ipc_key || attr->flags) { sys_mutex.Error("sys_mutex_create(): unknown attributes (recursive=0x%x, pshared=0x%x, adaptive=0x%x, ipc_key=0x%llx, flags=0x%x)", attr->recursive, attr->pshared, attr->adaptive, attr->ipc_key, attr->flags); diff --git a/rpcs3/Emu/SysCalls/lv2/sys_rwlock.cpp b/rpcs3/Emu/SysCalls/lv2/sys_rwlock.cpp index c0fcfd21a..b9ccab39e 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_rwlock.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_rwlock.cpp @@ -63,7 +63,7 @@ s32 sys_rwlock_create(vm::ptr rw_lock_id, vm::ptr a return CELL_EINVAL; } - if (attr->pshared != SYS_SYNC_NOT_PROCESS_SHARED || attr->ipc_key.data() || attr->flags.data()) + if (attr->pshared != SYS_SYNC_NOT_PROCESS_SHARED || attr->ipc_key || attr->flags) { sys_rwlock.Error("sys_rwlock_create(): unknown attributes (pshared=0x%x, ipc_key=0x%llx, flags=0x%x)", attr->pshared, attr->ipc_key, attr->flags); return CELL_EINVAL; diff --git a/rpcs3/Emu/SysCalls/lv2/sys_semaphore.cpp b/rpcs3/Emu/SysCalls/lv2/sys_semaphore.cpp index 99a4223dd..8865deaae 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_semaphore.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_semaphore.cpp @@ -35,7 +35,7 @@ s32 sys_semaphore_create(vm::ptr sem_id, vm::ptr return CELL_EINVAL; } - if (attr->pshared != SYS_SYNC_NOT_PROCESS_SHARED || attr->ipc_key.data() || attr->flags.data()) + if (attr->pshared != SYS_SYNC_NOT_PROCESS_SHARED || attr->ipc_key || attr->flags) { sys_semaphore.Error("sys_semaphore_create(): unknown attributes (pshared=0x%x, ipc_key=0x%x, flags=0x%x)", attr->pshared, attr->ipc_key, attr->flags); return CELL_EINVAL; diff --git a/rpcs3/Emu/SysCalls/lv2/sys_spu.cpp b/rpcs3/Emu/SysCalls/lv2/sys_spu.cpp index 2ca96f623..9bf572560 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_spu.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_spu.cpp @@ -230,7 +230,7 @@ s32 sys_spu_thread_group_create(vm::ptr id, u32 num, s32 prio, vm::ptrtype.data()) + if (attr->type) { sys_spu.Todo("Unsupported SPU Thread Group type (0x%x)", attr->type); } From 8ae3401ffadb436cedf0acfcf3cb552ae5685d5e Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Fri, 18 Sep 2015 01:41:14 +0300 Subject: [PATCH 6/6] Some things improved shared_mutex_t implemented GUI Emu Callbacks rewritten fxm::import, fxm::import_always implemented cellMsgDialog rewritten Emu.CallAfter improved (returns std::future) --- Utilities/Atomic.h | 717 +++++++++++++++++++ Utilities/BEType.h | 118 +-- Utilities/GNU.h | 328 --------- Utilities/Semaphore.h | 2 +- Utilities/SharedMutex.cpp | 152 ++++ Utilities/SharedMutex.h | 46 ++ Utilities/StrFmt.h | 45 +- Utilities/Thread.cpp | 9 +- Utilities/Thread.h | 6 +- rpcs3/Emu/ARMv7/ARMv7Thread.cpp | 12 +- rpcs3/Emu/ARMv7/Modules/sceLibKernel.cpp | 13 +- rpcs3/Emu/ARMv7/Modules/sceLibKernel.h | 8 +- rpcs3/Emu/ARMv7/Modules/sceLibc.cpp | 2 +- rpcs3/Emu/CPU/CPUThread.cpp | 36 +- rpcs3/Emu/CPU/CPUThread.h | 6 +- rpcs3/Emu/CPU/CPUThreadManager.cpp | 3 +- rpcs3/Emu/Cell/PPUThread.cpp | 4 +- rpcs3/Emu/Cell/RawSPUThread.cpp | 8 +- rpcs3/Emu/Cell/SPUASMJITRecompiler.cpp | 6 +- rpcs3/Emu/Cell/SPUAnalyser.cpp | 16 +- rpcs3/Emu/Cell/SPUAnalyser.h | 3 +- rpcs3/Emu/Cell/SPUThread.cpp | 52 +- rpcs3/Emu/Cell/SPUThread.h | 56 +- rpcs3/Emu/DbgCommand.cpp | 14 - rpcs3/Emu/DbgCommand.h | 8 - rpcs3/Emu/IdManager.cpp | 33 +- rpcs3/Emu/IdManager.h | 344 +++++---- rpcs3/Emu/Io/Keyboard.cpp | 55 +- rpcs3/Emu/Io/Keyboard.h | 15 +- rpcs3/Emu/Io/Mouse.cpp | 55 +- rpcs3/Emu/Io/Mouse.h | 15 +- rpcs3/Emu/Io/Pad.cpp | 57 +- rpcs3/Emu/Io/Pad.h | 15 +- rpcs3/Emu/Memory/atomic.h | 355 --------- rpcs3/Emu/Memory/vm.cpp | 27 +- rpcs3/Emu/Memory/vm.h | 14 +- rpcs3/Emu/RSX/GL/GLGSRender.cpp | 9 +- rpcs3/Emu/RSX/GL/GLGSRender.h | 4 - rpcs3/Emu/RSX/RSXThread.cpp | 4 +- rpcs3/Emu/SysCalls/LogBase.cpp | 2 +- rpcs3/Emu/SysCalls/LogBase.h | 9 +- rpcs3/Emu/SysCalls/Modules/cellAudio.cpp | 48 +- rpcs3/Emu/SysCalls/Modules/cellFs.cpp | 34 +- rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp | 6 +- rpcs3/Emu/SysCalls/Modules/cellMsgDialog.cpp | 190 +++-- rpcs3/Emu/SysCalls/Modules/cellMsgDialog.h | 32 +- rpcs3/Emu/SysCalls/Modules/cellSaveData.cpp | 13 +- rpcs3/Emu/SysCalls/Modules/cellSaveData.h | 8 +- rpcs3/Emu/SysCalls/Modules/cellSpurs.cpp | 90 +-- rpcs3/Emu/SysCalls/Modules/cellSpurs.h | 36 +- rpcs3/Emu/SysCalls/Modules/cellSpursSpu.cpp | 103 +-- rpcs3/Emu/SysCalls/Modules/cellSync.cpp | 28 +- rpcs3/Emu/SysCalls/Modules/cellSync.h | 20 +- rpcs3/Emu/SysCalls/Modules/libmixer.cpp | 6 +- rpcs3/Emu/SysCalls/Modules/sysPrxForUser.cpp | 3 +- rpcs3/Emu/SysCalls/Modules/sys_game.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/sys_lwcond_.cpp | 2 +- rpcs3/Emu/SysCalls/Modules/sys_lwmutex_.cpp | 4 +- rpcs3/Emu/SysCalls/lv2/sys_fs.h | 4 +- rpcs3/Emu/SysCalls/lv2/sys_lwmutex.h | 2 +- rpcs3/Emu/SysCalls/lv2/sys_memory.cpp | 9 +- rpcs3/Emu/SysCalls/lv2/sys_mmapper.cpp | 4 +- rpcs3/Emu/SysCalls/lv2/sys_ppu_thread.cpp | 3 +- rpcs3/Emu/SysCalls/lv2/sys_process.cpp | 2 +- rpcs3/Emu/SysCalls/lv2/sys_spu.cpp | 6 +- rpcs3/Emu/System.cpp | 21 +- rpcs3/Emu/System.h | 64 +- rpcs3/Gui/Debugger.cpp | 2 +- rpcs3/Gui/MainFrame.cpp | 2 +- rpcs3/Gui/MsgDialog.cpp | 60 +- rpcs3/Gui/MsgDialog.h | 6 +- rpcs3/Gui/SaveDataDialog.cpp | 2 +- rpcs3/Gui/SaveDataDialog.h | 3 +- rpcs3/emucore.vcxproj | 5 +- rpcs3/emucore.vcxproj.filters | 15 +- rpcs3/rpcs3.cpp | 120 ++-- rpcs3/stdafx.h | 5 +- 77 files changed, 1814 insertions(+), 1831 deletions(-) create mode 100644 Utilities/Atomic.h create mode 100644 Utilities/SharedMutex.cpp create mode 100644 Utilities/SharedMutex.h delete mode 100644 rpcs3/Emu/DbgCommand.cpp delete mode 100644 rpcs3/Emu/Memory/atomic.h diff --git a/Utilities/Atomic.h b/Utilities/Atomic.h new file mode 100644 index 000000000..e0656b674 --- /dev/null +++ b/Utilities/Atomic.h @@ -0,0 +1,717 @@ +#pragma once + +#if defined(__GNUG__) + +template inline std::enable_if_t sync_val_compare_and_swap(volatile T* dest, T2 comp, T2 exch) +{ + return __sync_val_compare_and_swap(dest, comp, exch); +} + +template inline std::enable_if_t sync_bool_compare_and_swap(volatile T* dest, T2 comp, T2 exch) +{ + return __sync_bool_compare_and_swap(dest, comp, exch); +} + +template inline std::enable_if_t sync_lock_test_and_set(volatile T* dest, T2 value) +{ + return __sync_lock_test_and_set(dest, value); +} + +template inline std::enable_if_t sync_fetch_and_add(volatile T* dest, T2 value) +{ + return __sync_fetch_and_add(dest, value); +} + +template inline std::enable_if_t sync_fetch_and_sub(volatile T* dest, T2 value) +{ + return __sync_fetch_and_sub(dest, value); +} + +template inline std::enable_if_t sync_fetch_and_or(volatile T* dest, T2 value) +{ + return __sync_fetch_and_or(dest, value); +} + +template inline std::enable_if_t sync_fetch_and_and(volatile T* dest, T2 value) +{ + return __sync_fetch_and_and(dest, value); +} + +template inline std::enable_if_t sync_fetch_and_xor(volatile T* dest, T2 value) +{ + return __sync_fetch_and_xor(dest, value); +} + +#elif defined(_MSC_VER) + +// atomic compare and swap functions + +inline u8 sync_val_compare_and_swap(volatile u8* dest, u8 comp, u8 exch) +{ + return _InterlockedCompareExchange8((volatile char*)dest, exch, comp); +} + +inline u16 sync_val_compare_and_swap(volatile u16* dest, u16 comp, u16 exch) +{ + return _InterlockedCompareExchange16((volatile short*)dest, exch, comp); +} + +inline u32 sync_val_compare_and_swap(volatile u32* dest, u32 comp, u32 exch) +{ + return _InterlockedCompareExchange((volatile long*)dest, exch, comp); +} + +inline u64 sync_val_compare_and_swap(volatile u64* dest, u64 comp, u64 exch) +{ + return _InterlockedCompareExchange64((volatile long long*)dest, exch, comp); +} + +inline u128 sync_val_compare_and_swap(volatile u128* dest, u128 comp, u128 exch) +{ + _InterlockedCompareExchange128((volatile long long*)dest, exch.hi, exch.lo, (long long*)&comp); + return comp; +} + +inline bool sync_bool_compare_and_swap(volatile u8* dest, u8 comp, u8 exch) +{ + return (u8)_InterlockedCompareExchange8((volatile char*)dest, exch, comp) == comp; +} + +inline bool sync_bool_compare_and_swap(volatile u16* dest, u16 comp, u16 exch) +{ + return (u16)_InterlockedCompareExchange16((volatile short*)dest, exch, comp) == comp; +} + +inline bool sync_bool_compare_and_swap(volatile u32* dest, u32 comp, u32 exch) +{ + return (u32)_InterlockedCompareExchange((volatile long*)dest, exch, comp) == comp; +} + +inline bool sync_bool_compare_and_swap(volatile u64* dest, u64 comp, u64 exch) +{ + return (u64)_InterlockedCompareExchange64((volatile long long*)dest, exch, comp) == comp; +} + +inline bool sync_bool_compare_and_swap(volatile u128* dest, u128 comp, u128 exch) +{ + return _InterlockedCompareExchange128((volatile long long*)dest, exch.hi, exch.lo, (long long*)&comp) != 0; +} + +// atomic exchange functions + +inline u8 sync_lock_test_and_set(volatile u8* dest, u8 value) +{ + return _InterlockedExchange8((volatile char*)dest, value); +} + +inline u16 sync_lock_test_and_set(volatile u16* dest, u16 value) +{ + return _InterlockedExchange16((volatile short*)dest, value); +} + +inline u32 sync_lock_test_and_set(volatile u32* dest, u32 value) +{ + return _InterlockedExchange((volatile long*)dest, value); +} + +inline u64 sync_lock_test_and_set(volatile u64* dest, u64 value) +{ + return _InterlockedExchange64((volatile long long*)dest, value); +} + +inline u128 sync_lock_test_and_set(volatile u128* dest, u128 value) +{ + while (true) + { + u128 old; + old.lo = dest->lo; + old.hi = dest->hi; + + if (sync_bool_compare_and_swap(dest, old, value)) return old; + } +} + +// atomic add functions + +inline u8 sync_fetch_and_add(volatile u8* dest, u8 value) +{ + return _InterlockedExchangeAdd8((volatile char*)dest, value); +} + +inline u16 sync_fetch_and_add(volatile u16* dest, u16 value) +{ + return _InterlockedExchangeAdd16((volatile short*)dest, value); +} + +inline u32 sync_fetch_and_add(volatile u32* dest, u32 value) +{ + return _InterlockedExchangeAdd((volatile long*)dest, value); +} + +inline u64 sync_fetch_and_add(volatile u64* dest, u64 value) +{ + return _InterlockedExchangeAdd64((volatile long long*)dest, value); +} + +inline u128 sync_fetch_and_add(volatile u128* dest, u128 value) +{ + while (true) + { + u128 old; + old.lo = dest->lo; + old.hi = dest->hi; + + u128 _new; + _new.lo = old.lo + value.lo; + _new.hi = old.hi + value.hi + (_new.lo < value.lo); + + if (sync_bool_compare_and_swap(dest, old, _new)) return old; + } +} + +// atomic sub functions + +inline u8 sync_fetch_and_sub(volatile u8* dest, u8 value) +{ + return _InterlockedExchangeAdd8((volatile char*)dest, -(char)value); +} + +inline u16 sync_fetch_and_sub(volatile u16* dest, u16 value) +{ + return _InterlockedExchangeAdd16((volatile short*)dest, -(short)value); +} + +inline u32 sync_fetch_and_sub(volatile u32* dest, u32 value) +{ + return _InterlockedExchangeAdd((volatile long*)dest, -(long)value); +} + +inline u64 sync_fetch_and_sub(volatile u64* dest, u64 value) +{ + return _InterlockedExchangeAdd64((volatile long long*)dest, -(long long)value); +} + +inline u128 sync_fetch_and_sub(volatile u128* dest, u128 value) +{ + while (true) + { + u128 old; + old.lo = dest->lo; + old.hi = dest->hi; + + u128 _new; + _new.lo = old.lo - value.lo; + _new.hi = old.hi - value.hi - (old.lo < value.lo); + + if (sync_bool_compare_and_swap(dest, old, _new)) return old; + } +} + +// atomic `bitwise or` functions + +inline u8 sync_fetch_and_or(volatile u8* dest, u8 value) +{ + return _InterlockedOr8((volatile char*)dest, value); +} + +inline u16 sync_fetch_and_or(volatile u16* dest, u16 value) +{ + return _InterlockedOr16((volatile short*)dest, value); +} + +inline u32 sync_fetch_and_or(volatile u32* dest, u32 value) +{ + return _InterlockedOr((volatile long*)dest, value); +} + +inline u64 sync_fetch_and_or(volatile u64* dest, u64 value) +{ + return _InterlockedOr64((volatile long long*)dest, value); +} + +inline u128 sync_fetch_and_or(volatile u128* dest, u128 value) +{ + while (true) + { + u128 old; + old.lo = dest->lo; + old.hi = dest->hi; + + u128 _new; + _new.lo = old.lo | value.lo; + _new.hi = old.hi | value.hi; + + if (sync_bool_compare_and_swap(dest, old, _new)) return old; + } +} + +// atomic `bitwise and` functions + +inline u8 sync_fetch_and_and(volatile u8* dest, u8 value) +{ + return _InterlockedAnd8((volatile char*)dest, value); +} + +inline u16 sync_fetch_and_and(volatile u16* dest, u16 value) +{ + return _InterlockedAnd16((volatile short*)dest, value); +} + +inline u32 sync_fetch_and_and(volatile u32* dest, u32 value) +{ + return _InterlockedAnd((volatile long*)dest, value); +} + +inline u64 sync_fetch_and_and(volatile u64* dest, u64 value) +{ + return _InterlockedAnd64((volatile long long*)dest, value); +} + +inline u128 sync_fetch_and_and(volatile u128* dest, u128 value) +{ + while (true) + { + u128 old; + old.lo = dest->lo; + old.hi = dest->hi; + + u128 _new; + _new.lo = old.lo & value.lo; + _new.hi = old.hi & value.hi; + + if (sync_bool_compare_and_swap(dest, old, _new)) return old; + } +} + +// atomic `bitwise xor` functions + +inline u8 sync_fetch_and_xor(volatile u8* dest, u8 value) +{ + return _InterlockedXor8((volatile char*)dest, value); +} + +inline u16 sync_fetch_and_xor(volatile u16* dest, u16 value) +{ + return _InterlockedXor16((volatile short*)dest, value); +} + +inline u32 sync_fetch_and_xor(volatile u32* dest, u32 value) +{ + return _InterlockedXor((volatile long*)dest, value); +} + +inline u64 sync_fetch_and_xor(volatile u64* dest, u64 value) +{ + return _InterlockedXor64((volatile long long*)dest, value); +} + +inline u128 sync_fetch_and_xor(volatile u128* dest, u128 value) +{ + while (true) + { + u128 old; + old.lo = dest->lo; + old.hi = dest->hi; + + u128 _new; + _new.lo = old.lo ^ value.lo; + _new.hi = old.hi ^ value.hi; + + if (sync_bool_compare_and_swap(dest, old, _new)) return old; + } +} + +#endif /* _MSC_VER */ + +template struct atomic_storage +{ + static_assert(!Size, "Invalid atomic type"); +}; + +template struct atomic_storage +{ + using type = u8; +}; + +template struct atomic_storage +{ + using type = u16; +}; + +template struct atomic_storage +{ + using type = u32; +}; + +template struct atomic_storage +{ + using type = u64; +}; + +template struct atomic_storage +{ + using type = u128; +}; + +template using atomic_storage_t = typename atomic_storage::type; + +// result wrapper to deal with void result type +template struct atomic_op_result_t +{ + RT result; + + template inline atomic_op_result_t(T func, VT& var, Args&&... args) + : result(std::move(func(var, std::forward(args)...))) + { + } + + inline RT move() + { + return std::move(result); + } +}; + +// void specialization: result is the initial value of the first arg +template struct atomic_op_result_t +{ + VT result; + + template inline atomic_op_result_t(T func, VT& var, Args&&... args) + : result(var) + { + func(var, std::forward(args)...); + } + + inline VT move() + { + return std::move(result); + } +}; + +// member function specialization +template struct atomic_op_result_t +{ + RT result; + + template inline atomic_op_result_t(RT(CT::*func)(FArgs...), VT& var, Args&&... args) + : result(std::move((var.*func)(std::forward(args)...))) + { + } + + inline RT move() + { + return std::move(result); + } +}; + +// member function void specialization +template struct atomic_op_result_t +{ + VT result; + + template inline atomic_op_result_t(void(CT::*func)(FArgs...), VT& var, Args&&... args) + : result(var) + { + (var.*func)(std::forward(args)...); + } + + inline VT move() + { + return std::move(result); + } +}; + +template class atomic_t +{ + using type = std::remove_cv_t; + using stype = atomic_storage_t; + using storage = atomic_storage; + + static_assert(alignof(type) <= alignof(stype), "atomic_t<> error: unexpected alignment"); + + stype m_data; + + template static inline void write_relaxed(volatile T2& data, const T2& value) + { + data = value; + } + + static inline void write_relaxed(volatile u128& data, const u128& value) + { + sync_lock_test_and_set(&data, value); + } + + template static inline T2 read_relaxed(const volatile T2& data) + { + return data; + } + + static inline u128 read_relaxed(const volatile u128& value) + { + return sync_val_compare_and_swap(const_cast(&value), u128{0}, u128{0}); + } + +public: + static inline const stype to_subtype(const type& value) + { + return reinterpret_cast(value); + } + + static inline const type from_subtype(const stype value) + { + return reinterpret_cast(value); + } + + atomic_t() = default; + + atomic_t(const atomic_t&) = delete; + + atomic_t(atomic_t&&) = delete; + + inline atomic_t(type value) + : m_data(to_subtype(value)) + { + } + + atomic_t& operator =(const atomic_t&) = delete; + + atomic_t& operator =(atomic_t&&) = delete; + + inline atomic_t& operator =(type value) + { + return write_relaxed(m_data, to_subtype(value)), *this; + } + + operator type() const volatile + { + return from_subtype(read_relaxed(m_data)); + } + + // Unsafe direct access + stype* raw_data() + { + return reinterpret_cast(&m_data); + } + + // Unsafe direct access + type& raw() + { + return reinterpret_cast(m_data); + } + + // Atomically compare data with cmp, replace with exch if equal, return previous data value anyway + inline const type compare_and_swap(const type& cmp, const type& exch) volatile + { + return from_subtype(sync_val_compare_and_swap(&m_data, to_subtype(cmp), to_subtype(exch))); + } + + // Atomically compare data with cmp, replace with exch if equal, return true if data was replaced + inline bool compare_and_swap_test(const type& cmp, const type& exch) volatile + { + return sync_bool_compare_and_swap(&m_data, to_subtype(cmp), to_subtype(exch)); + } + + // Atomically replace data with exch, return previous data value + inline const type exchange(const type& exch) volatile + { + return from_subtype(sync_lock_test_and_set(&m_data, to_subtype(exch))); + } + + // Atomically read data, possibly without memory barrier (not for 128 bit) + inline const type load() const volatile + { + return from_subtype(read_relaxed(m_data)); + } + + // Atomically write data, possibly without memory barrier (not for 128 bit) + inline void store(const type& value) volatile + { + write_relaxed(m_data, to_subtype(value)); + } + + // Perform an atomic operation on data (func is either pointer to member function or callable object with a T& first arg); + // Returns the result of the callable object call or previous (old) value of the atomic variable if the return type is void + template> auto atomic_op(F func, Args&&... args) volatile -> decltype(atomic_op_result_t::result) + { + while (true) + { + // Read the old value from memory + const stype old = read_relaxed(m_data); + + // Copy the old value + stype _new = old; + + // Call atomic op for the local copy of the old value and save the return value of the function + atomic_op_result_t result(func, reinterpret_cast(_new), args...); + + // Atomically compare value with `old`, replace with `_new` and return on success + if (sync_bool_compare_and_swap(&m_data, old, _new)) return result.move(); + } + } + + // Atomic bitwise OR, returns previous data + inline const type _or(const type& right) volatile + { + return from_subtype(sync_fetch_and_or(&m_data, to_subtype(right))); + } + + // Atomic bitwise AND, returns previous data + inline const type _and(const type& right) volatile + { + return from_subtype(sync_fetch_and_and(&m_data, to_subtype(right))); + } + + // Atomic bitwise AND NOT (inverts right argument), returns previous data + inline const type _and_not(const type& right) volatile + { + return from_subtype(sync_fetch_and_and(&m_data, ~to_subtype(right))); + } + + // Atomic bitwise XOR, returns previous data + inline const type _xor(const type& right) volatile + { + return from_subtype(sync_fetch_and_xor(&m_data, to_subtype(right))); + } + + inline const type operator |=(const type& right) volatile + { + return from_subtype(sync_fetch_and_or(&m_data, to_subtype(right)) | to_subtype(right)); + } + + inline const type operator &=(const type& right) volatile + { + return from_subtype(sync_fetch_and_and(&m_data, to_subtype(right)) & to_subtype(right)); + } + + inline const type operator ^=(const type& right) volatile + { + return from_subtype(sync_fetch_and_xor(&m_data, to_subtype(right)) ^ to_subtype(right)); + } +}; + +template inline std::enable_if_t operator ++(atomic_t& left) +{ + return left.from_subtype(sync_fetch_and_add(left.raw_data(), 1) + 1); +} + +template inline std::enable_if_t operator --(atomic_t& left) +{ + return left.from_subtype(sync_fetch_and_sub(left.raw_data(), 1) - 1); +} + +template inline std::enable_if_t operator ++(atomic_t& left, int) +{ + return left.from_subtype(sync_fetch_and_add(left.raw_data(), 1)); +} + +template inline std::enable_if_t operator --(atomic_t& left, int) +{ + return left.from_subtype(sync_fetch_and_sub(left.raw_data(), 1)); +} + +template inline std::enable_if_t::value, T> operator +=(atomic_t& left, const T2& right) +{ + return left.from_subtype(sync_fetch_and_add(left.raw_data(), right) + right); +} + +template inline std::enable_if_t::value, T> operator -=(atomic_t& left, const T2& right) +{ + return left.from_subtype(sync_fetch_and_sub(left.raw_data(), right) - right); +} + +template inline std::enable_if_t> operator ++(atomic_t>& left) +{ + return left.from_subtype(sync_fetch_and_add(left.raw_data(), 1) + 1); +} + +template inline std::enable_if_t> operator --(atomic_t>& left) +{ + return left.from_subtype(sync_fetch_and_sub(left.raw_data(), 1) - 1); +} + +template inline std::enable_if_t> operator ++(atomic_t>& left, int) +{ + return left.from_subtype(sync_fetch_and_add(left.raw_data(), 1)); +} + +template inline std::enable_if_t> operator --(atomic_t>& left, int) +{ + return left.from_subtype(sync_fetch_and_sub(left.raw_data(), 1)); +} + +template inline std::enable_if_t::value, nse_t> operator +=(atomic_t>& left, const T2& right) +{ + return left.from_subtype(sync_fetch_and_add(left.raw_data(), right) + right); +} + +template inline std::enable_if_t::value, nse_t> operator -=(atomic_t>& left, const T2& right) +{ + return left.from_subtype(sync_fetch_and_sub(left.raw_data(), right) - right); +} + +template inline std::enable_if_t> operator ++(atomic_t>& left) +{ + return left.atomic_op([](se_t& value) -> se_t + { + return ++value; + }); +} + +template inline std::enable_if_t> operator --(atomic_t>& left) +{ + return left.atomic_op([](se_t& value) -> se_t + { + return --value; + }); +} + +template inline std::enable_if_t> operator ++(atomic_t>& left, int) +{ + return left.atomic_op([](se_t& value) -> se_t + { + return value++; + }); +} + +template inline std::enable_if_t> operator --(atomic_t>& left, int) +{ + return left.atomic_op([](se_t& value) -> se_t + { + return value--; + }); +} + +template inline std::enable_if_t::value, se_t> operator +=(atomic_t>& left, const T2& right) +{ + return left.atomic_op([&](se_t& value) -> se_t + { + return value += right; + }); +} + +template inline std::enable_if_t::value, se_t> operator -=(atomic_t>& left, const T2& right) +{ + return left.atomic_op([&](se_t& value) -> se_t + { + return value -= right; + }); +} + +template using atomic_be_t = atomic_t>; // Atomic BE Type (for PS3 virtual memory) + +template using atomic_le_t = atomic_t>; // Atomic LE Type (for PSV virtual memory) + +// Algorithm for std::atomic; similar to atomic_t::atomic_op() +template> auto atomic_op(std::atomic& var, F func, Args&&... args) -> decltype(atomic_op_result_t::result) +{ + auto old = var.load(); + + while (true) + { + auto _new = old; + + atomic_op_result_t result(func, _new, args...); + + if (var.compare_exchange_strong(old, _new)) return result.move(); + } +} diff --git a/Utilities/BEType.h b/Utilities/BEType.h index e317bee22..916b52eb6 100644 --- a/Utilities/BEType.h +++ b/Utilities/BEType.h @@ -374,9 +374,6 @@ inline v128 operator ~(const v128& other) return v128::from64(~other._u64[0], ~other._u64[1]); } -#define IS_INTEGER(t) (std::is_integral::value || std::is_enum::value) -#define IS_BINARY_COMPARABLE(t1, t2) (IS_INTEGER(t1) && IS_INTEGER(t2) && sizeof(t1) == sizeof(t2)) - template struct se_storage { static_assert(!Size, "Bad se_storage<> type"); @@ -386,7 +383,7 @@ template struct se_storage { using type = u16; - static constexpr u16 swap(u16 src) + [[deprecated]] static constexpr u16 swap(u16 src) // for reference { return (src >> 8) | (src << 8); } @@ -407,7 +404,7 @@ template struct se_storage { using type = u32; - static constexpr u32 swap(u32 src) + [[deprecated]] static constexpr u32 swap(u32 src) // for reference { return (src >> 24) | (src << 24) | ((src >> 8) & 0x0000ff00) | ((src << 8) & 0x00ff0000); } @@ -428,7 +425,7 @@ template struct se_storage { using type = u64; - static constexpr u64 swap(u64 src) + [[deprecated]] static constexpr u64 swap(u64 src) // for reference { return (src >> 56) | (src << 56) | ((src >> 40) & 0x000000000000ff00) | @@ -491,7 +488,10 @@ template struct se_convert static struct se_raw_tag_t {} const se_raw{}; -template class se_t +template class se_t; + +// se_t with switched endianness +template class se_t { using type = std::remove_cv_t; using stype = se_storage_t; @@ -506,16 +506,32 @@ template class se_t static_assert(!std::is_enum::value, "se_t<> error: invalid type (enumeration), use integral type instead"); static_assert(alignof(type) == alignof(stype), "se_t<> error: unexpected alignment"); + template::value> struct bool_converter + { + static inline bool to_bool(const se_t& value) + { + return static_cast(value.value()); + } + }; + + template struct bool_converter + { + static inline bool to_bool(const se_t& value) + { + return value.m_data != 0; + } + }; + public: se_t() = default; se_t(const se_t& right) = default; - template::value && !std::is_same, std::decay_t>::value>> inline se_t(const CT& value) + inline se_t(type value) : m_data(storage::to(value)) { } - + // construct directly from raw data (don't use) inline se_t(const stype& raw_value, const se_raw_tag_t&) : m_data(raw_value) @@ -528,29 +544,27 @@ public: } // access underlying raw data (don't use) - inline const stype& raw_data() const + inline const stype& raw_data() const noexcept { return m_data; } se_t& operator =(const se_t&) = default; - template inline std::enable_if_t::value && !std::is_same, std::decay_t>::value, se_t&> operator =(const CT& value) + inline se_t& operator =(type value) { return m_data = storage::to(value), *this; } inline operator type() const { - return value(); + return storage::from(m_data); } // optimization explicit inline operator bool() const { - static_assert(std::is_convertible::value, "Illegal conversion to bool"); - - return m_data != 0; + return bool_converter::to_bool(*this); } // optimization @@ -560,7 +574,7 @@ public: } // optimization - template inline std::enable_if_t::value && std::is_convertible::value, se_t&> operator &=(const CT& right) + template inline std::enable_if_t::value, se_t&> operator &=(CT right) { return m_data &= storage::to(right), *this; } @@ -572,7 +586,7 @@ public: } // optimization - template inline std::enable_if_t::value && std::is_convertible::value, se_t&> operator |=(const CT& right) + template inline std::enable_if_t::value, se_t&> operator |=(CT right) { return m_data |= storage::to(right), *this; } @@ -584,12 +598,13 @@ public: } // optimization - template inline std::enable_if_t::value && std::is_convertible::value, se_t&> operator ^=(const CT& right) + template inline std::enable_if_t::value, se_t&> operator ^=(CT right) { return m_data ^= storage::to(right), *this; } }; +// se_t with native endianness template class se_t { using type = std::remove_cv_t; @@ -607,8 +622,8 @@ public: se_t(const se_t&) = default; - template::value && !std::is_same, std::decay_t>::value>> inline se_t(CT&& value) - : m_data(std::forward(value)) + inline se_t(type value) + : m_data(value) { } @@ -619,32 +634,35 @@ public: se_t& operator =(const se_t& value) = default; - template inline std::enable_if_t::value && !std::is_same, std::decay_t>::value, se_t&> operator =(const CT& value) + inline se_t& operator =(type value) { return m_data = value, *this; } inline operator type() const { - return value(); + return m_data; } - template inline std::enable_if_t::value && std::is_convertible::value, se_t&> operator &=(const CT& right) + template inline std::enable_if_t::value, se_t&> operator &=(const CT& right) { return m_data &= right, *this; } - template inline std::enable_if_t::value && std::is_convertible::value, se_t&> operator |=(const CT& right) + template inline std::enable_if_t::value, se_t&> operator |=(const CT& right) { return m_data |= right, *this; } - template inline std::enable_if_t::value && std::is_convertible::value, se_t&> operator ^=(const CT& right) + template inline std::enable_if_t::value, se_t&> operator ^=(const CT& right) { return m_data ^= right, *this; } }; +// se_t with native endianness (alias) +template using nse_t = se_t; + template inline se_t& operator +=(se_t& left, const T1& right) { auto value = left.value(); @@ -722,15 +740,15 @@ template inline std::enable_if_t inline std::enable_if_t operator ==(const se_t& left, const T2& right) +template inline std::enable_if_t= sizeof(T2), bool> operator ==(const se_t& left, T2 right) { - return left.raw_data() == se_storage::to(right); + return left.raw_data() == se_storage::to(right); } // optimization -template inline std::enable_if_t operator ==(const T1& left, const se_t& right) +template inline std::enable_if_t operator ==(T1 left, const se_t& right) { - return se_storage::to(left) == right.raw_data(); + return se_storage::to(left) == right.raw_data(); } // optimization @@ -740,75 +758,75 @@ template inline std::enable_if_t inline std::enable_if_t operator !=(const se_t& left, const T2& right) +template inline std::enable_if_t= sizeof(T2), bool> operator !=(const se_t& left, T2 right) { - return left.raw_data() != se_storage::to(right); + return left.raw_data() != se_storage::to(right); } // optimization -template inline std::enable_if_t operator !=(const T1& left, const se_t& right) +template inline std::enable_if_t operator !=(T1 left, const se_t& right) { - return se_storage::to(left) != right.raw_data(); + return se_storage::to(left) != right.raw_data(); } // optimization template inline std::enable_if_t= 4, se_t> operator &(const se_t& left, const se_t& right) { - return{ static_cast>(left.raw_data() & right.raw_data()), se_raw }; + return{ left.raw_data() & right.raw_data(), se_raw }; } // optimization -template inline std::enable_if_t= 4, se_t> operator &(const se_t& left, const T2& right) +template inline std::enable_if_t= sizeof(T2) && sizeof(T1) >= 4, se_t> operator &(const se_t& left, T2 right) { - return{ static_cast>(left.raw_data() & se_storage::to(right)), se_raw }; + return{ left.raw_data() & se_storage::to(right), se_raw }; } // optimization -template inline std::enable_if_t= 4, se_t> operator &(const T1& left, const se_t& right) +template inline std::enable_if_t= 4, se_t> operator &(T1 left, const se_t& right) { - return{ static_cast>(se_storage::to(left) & right.raw_data()), se_raw }; + return{ se_storage::to(left) & right.raw_data(), se_raw }; } // optimization template inline std::enable_if_t= 4, se_t> operator |(const se_t& left, const se_t& right) { - return{ static_cast>(left.raw_data() | right.raw_data()), se_raw }; + return{ left.raw_data() | right.raw_data(), se_raw }; } // optimization -template inline std::enable_if_t= 4, se_t> operator |(const se_t& left, const T2& right) +template inline std::enable_if_t= sizeof(T2) && sizeof(T1) >= 4, se_t> operator |(const se_t& left, T2 right) { - return{ static_cast>(left.raw_data() | se_storage::to(right)), se_raw }; + return{ left.raw_data() | se_storage::to(right), se_raw }; } // optimization -template inline std::enable_if_t= 4, se_t> operator |(const T1& left, const se_t& right) +template inline std::enable_if_t= 4, se_t> operator |(T1 left, const se_t& right) { - return{ static_cast>(se_storage::to(left) | right.raw_data()), se_raw }; + return{ se_storage::to(left) | right.raw_data(), se_raw }; } // optimization template inline std::enable_if_t= 4, se_t> operator ^(const se_t& left, const se_t& right) { - return{ static_cast>(left.raw_data() ^ right.raw_data()), se_raw }; + return{ left.raw_data() ^ right.raw_data(), se_raw }; } // optimization -template inline std::enable_if_t= 4, se_t> operator ^(const se_t& left, const T2& right) +template inline std::enable_if_t= sizeof(T2) && sizeof(T1) >= 4, se_t> operator ^(const se_t& left, T2 right) { - return{ static_cast>(left.raw_data() ^ se_storage::to(right)), se_raw }; + return{ left.raw_data() ^ se_storage::to(right), se_raw }; } // optimization -template inline std::enable_if_t= 4, se_t> operator ^(const T1& left, const se_t& right) +template inline std::enable_if_t= 4, se_t> operator ^(T1 left, const se_t& right) { - return{ static_cast>(se_storage::to(left) ^ right.raw_data()), se_raw }; + return{ se_storage::to(left) ^ right.raw_data(), se_raw }; } // optimization -template inline std::enable_if_t= 4, se_t> operator ~(const se_t& right) +template inline std::enable_if_t= 4, se_t> operator ~(const se_t& right) { - return{ static_cast>(~right.raw_data()), se_raw }; + return{ ~right.raw_data(), se_raw }; } #ifdef IS_LE_MACHINE diff --git a/Utilities/GNU.h b/Utilities/GNU.h index 04bcbce45..c8d5c74cb 100644 --- a/Utilities/GNU.h +++ b/Utilities/GNU.h @@ -232,334 +232,6 @@ struct alignas(16) uint128_t using __uint128_t = uint128_t; #endif -// SFINAE Helper type -template using if_integral_t = std::enable_if_t::value || std::is_same, __uint128_t>::value, TT>; - -#if defined(__GNUG__) - -template inline if_integral_t sync_val_compare_and_swap(volatile T* dest, T2 comp, T2 exch) -{ - return __sync_val_compare_and_swap(dest, comp, exch); -} - -template inline if_integral_t sync_bool_compare_and_swap(volatile T* dest, T2 comp, T2 exch) -{ - return __sync_bool_compare_and_swap(dest, comp, exch); -} - -template inline if_integral_t sync_lock_test_and_set(volatile T* dest, T2 value) -{ - return __sync_lock_test_and_set(dest, value); -} - -template inline if_integral_t sync_fetch_and_add(volatile T* dest, T2 value) -{ - return __sync_fetch_and_add(dest, value); -} - -template inline if_integral_t sync_fetch_and_sub(volatile T* dest, T2 value) -{ - return __sync_fetch_and_sub(dest, value); -} - -template inline if_integral_t sync_fetch_and_or(volatile T* dest, T2 value) -{ - return __sync_fetch_and_or(dest, value); -} - -template inline if_integral_t sync_fetch_and_and(volatile T* dest, T2 value) -{ - return __sync_fetch_and_and(dest, value); -} - -template inline if_integral_t sync_fetch_and_xor(volatile T* dest, T2 value) -{ - return __sync_fetch_and_xor(dest, value); -} - -#endif /* __GNUG__ */ - -#if defined(_MSC_VER) - -// atomic compare and swap functions - -inline uint8_t sync_val_compare_and_swap(volatile uint8_t* dest, uint8_t comp, uint8_t exch) -{ - return _InterlockedCompareExchange8((volatile char*)dest, exch, comp); -} - -inline uint16_t sync_val_compare_and_swap(volatile uint16_t* dest, uint16_t comp, uint16_t exch) -{ - return _InterlockedCompareExchange16((volatile short*)dest, exch, comp); -} - -inline uint32_t sync_val_compare_and_swap(volatile uint32_t* dest, uint32_t comp, uint32_t exch) -{ - return _InterlockedCompareExchange((volatile long*)dest, exch, comp); -} - -inline uint64_t sync_val_compare_and_swap(volatile uint64_t* dest, uint64_t comp, uint64_t exch) -{ - return _InterlockedCompareExchange64((volatile long long*)dest, exch, comp); -} - -inline uint128_t sync_val_compare_and_swap(volatile uint128_t* dest, uint128_t comp, uint128_t exch) -{ - _InterlockedCompareExchange128((volatile long long*)dest, exch.hi, exch.lo, (long long*)&comp); - return comp; -} - -inline bool sync_bool_compare_and_swap(volatile uint8_t* dest, uint8_t comp, uint8_t exch) -{ - return (uint8_t)_InterlockedCompareExchange8((volatile char*)dest, exch, comp) == comp; -} - -inline bool sync_bool_compare_and_swap(volatile uint16_t* dest, uint16_t comp, uint16_t exch) -{ - return (uint16_t)_InterlockedCompareExchange16((volatile short*)dest, exch, comp) == comp; -} - -inline bool sync_bool_compare_and_swap(volatile uint32_t* dest, uint32_t comp, uint32_t exch) -{ - return (uint32_t)_InterlockedCompareExchange((volatile long*)dest, exch, comp) == comp; -} - -inline bool sync_bool_compare_and_swap(volatile uint64_t* dest, uint64_t comp, uint64_t exch) -{ - return (uint64_t)_InterlockedCompareExchange64((volatile long long*)dest, exch, comp) == comp; -} - -inline bool sync_bool_compare_and_swap(volatile uint128_t* dest, uint128_t comp, uint128_t exch) -{ - return _InterlockedCompareExchange128((volatile long long*)dest, exch.hi, exch.lo, (long long*)&comp) != 0; -} - -// atomic exchange functions - -inline uint8_t sync_lock_test_and_set(volatile uint8_t* dest, uint8_t value) -{ - return _InterlockedExchange8((volatile char*)dest, value); -} - -inline uint16_t sync_lock_test_and_set(volatile uint16_t* dest, uint16_t value) -{ - return _InterlockedExchange16((volatile short*)dest, value); -} - -inline uint32_t sync_lock_test_and_set(volatile uint32_t* dest, uint32_t value) -{ - return _InterlockedExchange((volatile long*)dest, value); -} - -inline uint64_t sync_lock_test_and_set(volatile uint64_t* dest, uint64_t value) -{ - return _InterlockedExchange64((volatile long long*)dest, value); -} - -inline uint128_t sync_lock_test_and_set(volatile uint128_t* dest, uint128_t value) -{ - while (true) - { - uint128_t old; - old.lo = dest->lo; - old.hi = dest->hi; - - if (sync_bool_compare_and_swap(dest, old, value)) return old; - } -} - -// atomic add functions - -inline uint8_t sync_fetch_and_add(volatile uint8_t* dest, uint8_t value) -{ - return _InterlockedExchangeAdd8((volatile char*)dest, value); -} - -inline uint16_t sync_fetch_and_add(volatile uint16_t* dest, uint16_t value) -{ - return _InterlockedExchangeAdd16((volatile short*)dest, value); -} - -inline uint32_t sync_fetch_and_add(volatile uint32_t* dest, uint32_t value) -{ - return _InterlockedExchangeAdd((volatile long*)dest, value); -} - -inline uint64_t sync_fetch_and_add(volatile uint64_t* dest, uint64_t value) -{ - return _InterlockedExchangeAdd64((volatile long long*)dest, value); -} - -inline uint128_t sync_fetch_and_add(volatile uint128_t* dest, uint128_t value) -{ - while (true) - { - uint128_t old; - old.lo = dest->lo; - old.hi = dest->hi; - - uint128_t _new; - _new.lo = old.lo + value.lo; - _new.hi = old.hi + value.hi + (_new.lo < value.lo); - - if (sync_bool_compare_and_swap(dest, old, _new)) return old; - } -} - -// atomic sub functions - -inline uint8_t sync_fetch_and_sub(volatile uint8_t* dest, uint8_t value) -{ - return _InterlockedExchangeAdd8((volatile char*)dest, -(char)value); -} - -inline uint16_t sync_fetch_and_sub(volatile uint16_t* dest, uint16_t value) -{ - return _InterlockedExchangeAdd16((volatile short*)dest, -(short)value); -} - -inline uint32_t sync_fetch_and_sub(volatile uint32_t* dest, uint32_t value) -{ - return _InterlockedExchangeAdd((volatile long*)dest, -(long)value); -} - -inline uint64_t sync_fetch_and_sub(volatile uint64_t* dest, uint64_t value) -{ - return _InterlockedExchangeAdd64((volatile long long*)dest, -(long long)value); -} - -inline uint128_t sync_fetch_and_sub(volatile uint128_t* dest, uint128_t value) -{ - while (true) - { - uint128_t old; - old.lo = dest->lo; - old.hi = dest->hi; - - uint128_t _new; - _new.lo = old.lo - value.lo; - _new.hi = old.hi - value.hi - (old.lo < value.lo); - - if (sync_bool_compare_and_swap(dest, old, _new)) return old; - } -} - -// atomic `bitwise or` functions - -inline uint8_t sync_fetch_and_or(volatile uint8_t* dest, uint8_t value) -{ - return _InterlockedOr8((volatile char*)dest, value); -} - -inline uint16_t sync_fetch_and_or(volatile uint16_t* dest, uint16_t value) -{ - return _InterlockedOr16((volatile short*)dest, value); -} - -inline uint32_t sync_fetch_and_or(volatile uint32_t* dest, uint32_t value) -{ - return _InterlockedOr((volatile long*)dest, value); -} - -inline uint64_t sync_fetch_and_or(volatile uint64_t* dest, uint64_t value) -{ - return _InterlockedOr64((volatile long long*)dest, value); -} - -inline uint128_t sync_fetch_and_or(volatile uint128_t* dest, uint128_t value) -{ - while (true) - { - uint128_t old; - old.lo = dest->lo; - old.hi = dest->hi; - - uint128_t _new; - _new.lo = old.lo | value.lo; - _new.hi = old.hi | value.hi; - - if (sync_bool_compare_and_swap(dest, old, _new)) return old; - } -} - -// atomic `bitwise and` functions - -inline uint8_t sync_fetch_and_and(volatile uint8_t* dest, uint8_t value) -{ - return _InterlockedAnd8((volatile char*)dest, value); -} - -inline uint16_t sync_fetch_and_and(volatile uint16_t* dest, uint16_t value) -{ - return _InterlockedAnd16((volatile short*)dest, value); -} - -inline uint32_t sync_fetch_and_and(volatile uint32_t* dest, uint32_t value) -{ - return _InterlockedAnd((volatile long*)dest, value); -} - -inline uint64_t sync_fetch_and_and(volatile uint64_t* dest, uint64_t value) -{ - return _InterlockedAnd64((volatile long long*)dest, value); -} - -inline uint128_t sync_fetch_and_and(volatile uint128_t* dest, uint128_t value) -{ - while (true) - { - uint128_t old; - old.lo = dest->lo; - old.hi = dest->hi; - - uint128_t _new; - _new.lo = old.lo & value.lo; - _new.hi = old.hi & value.hi; - - if (sync_bool_compare_and_swap(dest, old, _new)) return old; - } -} - -// atomic `bitwise xor` functions - -inline uint8_t sync_fetch_and_xor(volatile uint8_t* dest, uint8_t value) -{ - return _InterlockedXor8((volatile char*)dest, value); -} - -inline uint16_t sync_fetch_and_xor(volatile uint16_t* dest, uint16_t value) -{ - return _InterlockedXor16((volatile short*)dest, value); -} - -inline uint32_t sync_fetch_and_xor(volatile uint32_t* dest, uint32_t value) -{ - return _InterlockedXor((volatile long*)dest, value); -} - -inline uint64_t sync_fetch_and_xor(volatile uint64_t* dest, uint64_t value) -{ - return _InterlockedXor64((volatile long long*)dest, value); -} - -inline uint128_t sync_fetch_and_xor(volatile uint128_t* dest, uint128_t value) -{ - while (true) - { - uint128_t old; - old.lo = dest->lo; - old.hi = dest->hi; - - uint128_t _new; - _new.lo = old.lo ^ value.lo; - _new.hi = old.hi ^ value.hi; - - if (sync_bool_compare_and_swap(dest, old, _new)) return old; - } -} - -#endif /* _MSC_VER */ - inline uint32_t cntlz32(uint32_t arg) { #if defined(_MSC_VER) diff --git a/Utilities/Semaphore.h b/Utilities/Semaphore.h index 03d3a7716..8ed96f427 100644 --- a/Utilities/Semaphore.h +++ b/Utilities/Semaphore.h @@ -22,7 +22,7 @@ public: const u32 max_value; semaphore_t(u32 max_value = 1, u32 value = 0) - : m_var({ value, 0 }) + : m_var(sync_var_t{ value, 0 }) , max_value(max_value) { } diff --git a/Utilities/SharedMutex.cpp b/Utilities/SharedMutex.cpp new file mode 100644 index 000000000..9394fde02 --- /dev/null +++ b/Utilities/SharedMutex.cpp @@ -0,0 +1,152 @@ +#include "stdafx.h" +#include "SharedMutex.h" + +static const u32 MAX_READERS = 0x7fffffff; // 2^31-1 + +inline bool shared_mutex_t::try_lock_shared() +{ + return m_info.atomic_op([](ownership_info_t& info) -> bool + { + if (info.readers < MAX_READERS && !info.writers && !info.waiting_readers && !info.waiting_writers) + { + info.readers++; + return true; + } + + return false; + }); +} + +void shared_mutex_t::lock_shared() +{ + if (!try_lock_shared()) + { + std::unique_lock lock(m_mutex); + + m_wrcv.wait(lock, WRAP_EXPR(m_info.atomic_op([](ownership_info_t& info) -> bool + { + if (info.waiting_readers < UINT16_MAX) + { + info.waiting_readers++; + return true; + } + + return false; + }))); + + m_rcv.wait(lock, WRAP_EXPR(m_info.atomic_op([](ownership_info_t& info) -> bool + { + if (!info.writers && !info.waiting_writers && info.readers < MAX_READERS) + { + info.readers++; + return true; + } + + return false; + }))); + + const auto info = m_info.atomic_op([](ownership_info_t& info) + { + if (!info.waiting_readers--) + { + throw EXCEPTION("Invalid value"); + } + }); + + if (info.waiting_readers == UINT16_MAX) + { + m_wrcv.notify_one(); + } + } +} + +void shared_mutex_t::unlock_shared() +{ + const auto info = m_info.atomic_op([](ownership_info_t& info) + { + if (!info.readers--) + { + throw EXCEPTION("Not locked"); + } + }); + + const bool notify_writers = info.readers == 1 && info.writers; + const bool notify_readers = info.readers == UINT32_MAX && info.waiting_readers; + + if (notify_writers || notify_readers) + { + std::lock_guard lock(m_mutex); + + if (notify_writers) m_wcv.notify_one(); + if (notify_readers) m_rcv.notify_one(); + } +} + +inline bool shared_mutex_t::try_lock() +{ + return m_info.compare_and_swap_test({ 0, 0, 0, 0 }, { 0, 1, 0, 0 }); +} + +void shared_mutex_t::lock() +{ + if (!try_lock()) + { + std::unique_lock lock(m_mutex); + + m_wwcv.wait(lock, WRAP_EXPR(m_info.atomic_op([](ownership_info_t& info) -> bool + { + if (info.waiting_writers < UINT16_MAX) + { + info.waiting_writers++; + return true; + } + + return false; + }))); + + m_wcv.wait(lock, WRAP_EXPR(m_info.atomic_op([](ownership_info_t& info) -> bool + { + if (!info.writers) + { + info.writers++; + return true; + } + + return false; + }))); + + m_wcv.wait(lock, WRAP_EXPR(m_info.load().readers == 0)); + + const auto info = m_info.atomic_op([](ownership_info_t& info) + { + if (!info.waiting_writers--) + { + throw EXCEPTION("Invalid value"); + } + }); + + if (info.waiting_writers == UINT16_MAX) + { + m_wwcv.notify_one(); + } + } +} + +void shared_mutex_t::unlock() +{ + const auto info = m_info.atomic_op([](ownership_info_t& info) + { + if (!info.writers--) + { + throw EXCEPTION("Not locked"); + } + }); + + if (info.waiting_writers || info.waiting_readers) + { + std::lock_guard lock(m_mutex); + + if (info.waiting_writers) m_wcv.notify_one(); + else if (info.waiting_readers) m_rcv.notify_all(); + } +} diff --git a/Utilities/SharedMutex.h b/Utilities/SharedMutex.h new file mode 100644 index 000000000..82d38c1ee --- /dev/null +++ b/Utilities/SharedMutex.h @@ -0,0 +1,46 @@ +#pragma once + +#include + +// An attempt to create lock-free (in optimistic case) implementation similar to std::shared_mutex; +// MSVC implementation of std::shared_timed_mutex is not lock-free and thus may be slow, and std::shared_mutex is not available. +class shared_mutex_t +{ + struct ownership_info_t + { + u32 readers : 31; + u32 writers : 1; + u16 waiting_readers; + u16 waiting_writers; + }; + + atomic_t m_info{}; + + std::mutex m_mutex; + + std::condition_variable m_rcv; + std::condition_variable m_wcv; + std::condition_variable m_wrcv; + std::condition_variable m_wwcv; + +public: + shared_mutex_t() = default; + + // Lock in shared mode + void lock_shared(); + + // Try to lock in shared mode + bool try_lock_shared(); + + // Unlock in shared mode + void unlock_shared(); + + // Lock exclusively + void lock(); + + // Try to lock exclusively + bool try_lock(); + + // Unlock exclusively + void unlock(); +}; diff --git a/Utilities/StrFmt.h b/Utilities/StrFmt.h index 8465ad061..02111b9db 100644 --- a/Utilities/StrFmt.h +++ b/Utilities/StrFmt.h @@ -145,8 +145,7 @@ namespace fmt std::string to_udec(u64 value); std::string to_sdec(s64 value); - template::value> - struct unveil + template::value> struct unveil { using result_type = T; @@ -156,8 +155,7 @@ namespace fmt } }; - template<> - struct unveil + template<> struct unveil { using result_type = const char*; @@ -167,8 +165,7 @@ namespace fmt } }; - template - struct unveil + template struct unveil { using result_type = const char*; @@ -178,8 +175,7 @@ namespace fmt } }; - template<> - struct unveil + template<> struct unveil { using result_type = const char*; @@ -189,8 +185,7 @@ namespace fmt } }; - template - struct unveil + template struct unveil { using result_type = std::underlying_type_t; @@ -200,25 +195,13 @@ namespace fmt } }; - template - struct unveil, false> + template struct unveil, false> { using result_type = typename unveil::result_type; - force_inline static result_type get_value(const be_t& arg) + force_inline static result_type get_value(const se_t& arg) { - return unveil::get_value(arg.value()); - } - }; - - template - struct unveil, false> - { - using result_type = typename unveil::result_type; - - force_inline static result_type get_value(const le_t& arg) - { - return unveil::get_value(arg.value()); + return unveil::get_value(arg); } }; @@ -270,11 +253,11 @@ namespace fmt } } - struct exception + struct exception : public std::exception { std::unique_ptr message; - template never_inline safe_buffers exception(const char* file, int line, const char* func, const char* text, Args... args) + template never_inline safe_buffers exception(const char* file, int line, const char* func, const char* text, Args... args) noexcept { const std::string data = format(text, args...) + format("\n(in file %s:%d, in function %s)", file, line, func); @@ -283,16 +266,16 @@ namespace fmt std::memcpy(message.get(), data.c_str(), data.size() + 1); } - exception(const exception& other) + exception(const exception& other) noexcept { - const std::size_t size = std::strlen(other); + const std::size_t size = std::strlen(other.message.get()); message.reset(new char[size + 1]); - std::memcpy(message.get(), other, size + 1); + std::memcpy(message.get(), other.message.get(), size + 1); } - operator const char*() const + virtual const char* what() const noexcept override { return message.get(); } diff --git a/Utilities/Thread.cpp b/Utilities/Thread.cpp index bdc740374..100bf3d7e 100644 --- a/Utilities/Thread.cpp +++ b/Utilities/Thread.cpp @@ -1121,6 +1121,8 @@ void _se_translator(unsigned int u, EXCEPTION_POINTERS* pExp) { throw EXCEPTION("Access violation %s location 0x%llx", is_writing ? "writing" : "reading", addr64); } + + //__int2c(); // if it crashed there, check the callstack for the actual source of the crash } const PVOID exception_handler = (atexit([]{ RemoveVectoredExceptionHandler(exception_handler); }), AddVectoredExceptionHandler(1, [](PEXCEPTION_POINTERS pExp) -> LONG @@ -1281,14 +1283,9 @@ void named_thread_t::start(std::function name, std::function& test_exit) diff --git a/rpcs3/Emu/ARMv7/ARMv7Thread.cpp b/rpcs3/Emu/ARMv7/ARMv7Thread.cpp index 3f72c08dc..fd9c4ba63 100644 --- a/rpcs3/Emu/ARMv7/ARMv7Thread.cpp +++ b/rpcs3/Emu/ARMv7/ARMv7Thread.cpp @@ -28,7 +28,7 @@ void armv7_init_tls() for (auto& v : g_armv7_tls_owners) { - v.store(0, std::memory_order_relaxed); + v = 0; } } @@ -53,8 +53,8 @@ u32 armv7_get_tls(u32 thread) if (g_armv7_tls_owners[i].compare_exchange_strong(old, thread)) { const u32 addr = g_armv7_tls_start + i * Emu.GetTLSMemsz(); // get TLS address - memcpy(vm::get_ptr(addr), vm::get_ptr(Emu.GetTLSAddr()), Emu.GetTLSFilesz()); // initialize from TLS image - memset(vm::get_ptr(addr + Emu.GetTLSFilesz()), 0, Emu.GetTLSMemsz() - Emu.GetTLSFilesz()); // fill the rest with zeros + std::memcpy(vm::get_ptr(addr), vm::get_ptr(Emu.GetTLSAddr()), Emu.GetTLSFilesz()); // initialize from TLS image + std::memset(vm::get_ptr(addr + Emu.GetTLSFilesz()), 0, Emu.GetTLSMemsz() - Emu.GetTLSFilesz()); // fill the rest with zeros return addr; } } @@ -195,15 +195,13 @@ void ARMv7Thread::task() { if (custom_task) { - if (m_state.load() && check_status()) return; + if (check_status()) return; return custom_task(*this); } - while (true) + while (!m_state || !check_status()) { - if (m_state.load() && check_status()) break; - // decode instruction using specified decoder PC += m_dec->DecodeMemory(PC); } diff --git a/rpcs3/Emu/ARMv7/Modules/sceLibKernel.cpp b/rpcs3/Emu/ARMv7/Modules/sceLibKernel.cpp index d97165b96..eb403ddf9 100644 --- a/rpcs3/Emu/ARMv7/Modules/sceLibKernel.cpp +++ b/rpcs3/Emu/ARMv7/Modules/sceLibKernel.cpp @@ -116,12 +116,7 @@ s32 sceKernelExitDeleteThread(ARMv7Thread& context, s32 exitStatus) context.stop(); // current thread should be deleted - const u32 id = context.get_id(); - - CallAfter([id]() - { - idm::remove(id); - }); + idm::remove(context.get_id()); return SCE_OK; } @@ -494,7 +489,7 @@ s32 sceKernelWaitEventFlag(ARMv7Thread& context, s32 evfId, u32 bitPattern, u32 if (passed >= timeout) { context.GPR[0] = SCE_KERNEL_ERROR_WAIT_TIMEOUT; - context.GPR[1] = evf->pattern.load(); + context.GPR[1] = evf->pattern; break; } @@ -629,7 +624,7 @@ s32 sceKernelCancelEventFlag(s32 evfId, u32 setPattern, vm::ptr pNumWaitThr *pNumWaitThreads = static_cast(evf->sq.size()); - evf->pattern.store(setPattern); + evf->pattern = setPattern; evf->sq.clear(); return SCE_OK; @@ -655,7 +650,7 @@ s32 sceKernelGetEventFlagInfo(s32 evfId, vm::ptr pInfo) pInfo->attr = evf->attr; pInfo->initPattern = evf->init; - pInfo->currentPattern = evf->pattern.load(); + pInfo->currentPattern = evf->pattern; pInfo->numWaitThreads = static_cast(evf->sq.size()); return SCE_OK; diff --git a/rpcs3/Emu/ARMv7/Modules/sceLibKernel.h b/rpcs3/Emu/ARMv7/Modules/sceLibKernel.h index 05e796885..1ba6f3a4c 100644 --- a/rpcs3/Emu/ARMv7/Modules/sceLibKernel.h +++ b/rpcs3/Emu/ARMv7/Modules/sceLibKernel.h @@ -464,8 +464,8 @@ struct psv_event_flag_t : name(name) , attr(attr) , init(pattern) + , pattern(pattern) { - this->pattern.store(pattern); } // Wakeup all waiters to return SCE_KERNEL_ERROR_WAIT_DELETE @@ -473,7 +473,7 @@ struct psv_event_flag_t { std::lock_guard lock(mutex); - const u32 pattern = this->pattern.load(); + const u32 pattern = this->pattern; for (auto& thread : sq) { @@ -550,8 +550,8 @@ struct psv_semaphore_t : name(name) , attr(attr) , max(max) + , count(count) { - this->count.store(count); } }; @@ -588,8 +588,8 @@ struct psv_mutex_t psv_mutex_t(const char* name, u32 attr, s32 count) : name(name) , attr(attr) + , count(count) { - this->count.store(count); } }; diff --git a/rpcs3/Emu/ARMv7/Modules/sceLibc.cpp b/rpcs3/Emu/ARMv7/Modules/sceLibc.cpp index 274824bba..bac157210 100644 --- a/rpcs3/Emu/ARMv7/Modules/sceLibc.cpp +++ b/rpcs3/Emu/ARMv7/Modules/sceLibc.cpp @@ -188,7 +188,7 @@ namespace sce_libc_func sceLibc.Success("Process finished"); - CallAfter([]() + Emu.CallAfter([]() { Emu.Stop(); }); diff --git a/rpcs3/Emu/CPU/CPUThread.cpp b/rpcs3/Emu/CPU/CPUThread.cpp index 035c91138..7cc5ba39e 100644 --- a/rpcs3/Emu/CPU/CPUThread.cpp +++ b/rpcs3/Emu/CPU/CPUThread.cpp @@ -4,20 +4,18 @@ #include "Emu/Memory/Memory.h" #include "Emu/System.h" #include "Emu/IdManager.h" -#include "Emu/DbgCommand.h" #include "CPUDecoder.h" #include "CPUThread.h" CPUThread::CPUThread(CPUThreadType type, const std::string& name, std::function thread_name) - : m_state({ CPU_STATE_STOPPED }) - , m_id(idm::get_last_id()) + : m_id(idm::get_last_id()) , m_type(type) , m_name(name) { start(std::move(thread_name), [this] { - SendDbgCommand(DID_CREATE_THREAD, this); + Emu.SendDbgCommand(DID_CREATE_THREAD, this); std::unique_lock lock(mutex); @@ -71,12 +69,12 @@ CPUThread::CPUThread(CPUThreadType type, const std::string& name, std::function< CPUThread::~CPUThread() { - SendDbgCommand(DID_REMOVE_THREAD, this); + Emu.SendDbgCommand(DID_REMOVE_THREAD, this); } bool CPUThread::is_paused() const { - return (m_state.load() & CPU_STATE_PAUSED) != 0 || Emu.IsPaused(); + return (m_state & CPU_STATE_PAUSED) != 0 || Emu.IsPaused(); } void CPUThread::dump_info() const @@ -89,27 +87,27 @@ void CPUThread::dump_info() const void CPUThread::run() { - SendDbgCommand(DID_START_THREAD, this); + Emu.SendDbgCommand(DID_START_THREAD, this); init_stack(); init_regs(); do_run(); - SendDbgCommand(DID_STARTED_THREAD, this); + Emu.SendDbgCommand(DID_STARTED_THREAD, this); } void CPUThread::pause() { - SendDbgCommand(DID_PAUSE_THREAD, this); + Emu.SendDbgCommand(DID_PAUSE_THREAD, this); m_state |= CPU_STATE_PAUSED; - SendDbgCommand(DID_PAUSED_THREAD, this); + Emu.SendDbgCommand(DID_PAUSED_THREAD, this); } void CPUThread::resume() { - SendDbgCommand(DID_RESUME_THREAD, this); + Emu.SendDbgCommand(DID_RESUME_THREAD, this); { // lock for reliable notification @@ -120,12 +118,12 @@ void CPUThread::resume() cv.notify_one(); } - SendDbgCommand(DID_RESUMED_THREAD, this); + Emu.SendDbgCommand(DID_RESUMED_THREAD, this); } void CPUThread::stop() { - SendDbgCommand(DID_STOP_THREAD, this); + Emu.SendDbgCommand(DID_STOP_THREAD, this); if (is_current()) { @@ -141,12 +139,12 @@ void CPUThread::stop() cv.notify_one(); } - SendDbgCommand(DID_STOPED_THREAD, this); + Emu.SendDbgCommand(DID_STOPED_THREAD, this); } void CPUThread::exec() { - SendDbgCommand(DID_EXEC_THREAD, this); + Emu.SendDbgCommand(DID_EXEC_THREAD, this); { // lock for reliable notification @@ -258,7 +256,7 @@ bool CPUThread::check_status() { CHECK_EMU_STATUS; // check at least once - if (!is_paused() && (m_state.load() & CPU_STATE_INTR) == 0) + if (!is_paused() && (m_state & CPU_STATE_INTR) == 0) { break; } @@ -269,7 +267,7 @@ bool CPUThread::check_status() continue; } - if (!is_paused() && (m_state.load() & CPU_STATE_INTR) != 0 && handle_interrupt()) + if (!is_paused() && (m_state & CPU_STATE_INTR) != 0 && handle_interrupt()) { continue; } @@ -277,12 +275,12 @@ bool CPUThread::check_status() cv.wait(lock); } - if (m_state.load() & CPU_STATE_RETURN || is_stopped()) + if (m_state & CPU_STATE_RETURN || is_stopped()) { return true; } - if (m_state.load() & CPU_STATE_STEP) + if (m_state & CPU_STATE_STEP) { // set PAUSE, but allow to execute once m_state |= CPU_STATE_PAUSED; diff --git a/rpcs3/Emu/CPU/CPUThread.h b/rpcs3/Emu/CPU/CPUThread.h index 57d821e01..079da43f1 100644 --- a/rpcs3/Emu/CPU/CPUThread.h +++ b/rpcs3/Emu/CPU/CPUThread.h @@ -45,7 +45,7 @@ protected: using named_thread_t::join; using named_thread_t::joinable; - atomic_t m_state; // thread state flags + atomic_t m_state{ CPU_STATE_STOPPED }; // thread state flags std::unique_ptr m_dec; @@ -62,8 +62,8 @@ public: CPUThreadType get_type() const { return m_type; } std::string get_name() const { return m_name; } - bool is_alive() const { return (m_state.load() & CPU_STATE_DEAD) == 0; } - bool is_stopped() const { return (m_state.load() & CPU_STATE_STOPPED) != 0; } + bool is_alive() const { return (m_state & CPU_STATE_DEAD) == 0; } + bool is_stopped() const { return (m_state & CPU_STATE_STOPPED) != 0; } virtual bool is_paused() const; virtual void dump_info() const; diff --git a/rpcs3/Emu/CPU/CPUThreadManager.cpp b/rpcs3/Emu/CPU/CPUThreadManager.cpp index efad193d1..e02f653c0 100644 --- a/rpcs3/Emu/CPU/CPUThreadManager.cpp +++ b/rpcs3/Emu/CPU/CPUThreadManager.cpp @@ -1,7 +1,6 @@ #include "stdafx.h" #include "Emu/Memory/Memory.h" #include "Emu/System.h" -#include "Emu/DbgCommand.h" #include "Emu/IdManager.h" #include "Emu/Cell/PPUThread.h" @@ -82,7 +81,7 @@ std::shared_ptr CPUThreadManager::NewRawSPUThread() break; } } - + return result; } diff --git a/rpcs3/Emu/Cell/PPUThread.cpp b/rpcs3/Emu/Cell/PPUThread.cpp index 884f58c9f..106f0bf92 100644 --- a/rpcs3/Emu/Cell/PPUThread.cpp +++ b/rpcs3/Emu/Cell/PPUThread.cpp @@ -293,7 +293,7 @@ void PPUThread::task() { while (true) { - if (m_state.load() && check_status()) break; + if (m_state && check_status()) break; // decode instruction using specified decoder m_dec->DecodeMemory(PC); @@ -310,7 +310,7 @@ void PPUThread::task() const auto func = exec_map[PC / 4]; // check status - if (!m_state.load()) + if (!m_state) { // call interpreter function func(*this, { vm::ps3::read32(PC) }); diff --git a/rpcs3/Emu/Cell/RawSPUThread.cpp b/rpcs3/Emu/Cell/RawSPUThread.cpp index 1ad595d2d..c7c844721 100644 --- a/rpcs3/Emu/Cell/RawSPUThread.cpp +++ b/rpcs3/Emu/Cell/RawSPUThread.cpp @@ -67,7 +67,7 @@ bool RawSPUThread::read_reg(const u32 addr, u32& value) case SPU_Status_offs: { - value = status.load(); + value = status; return true; } } @@ -201,7 +201,7 @@ bool RawSPUThread::write_reg(const u32 addr, const u32 value) break; } - run_ctrl.store(value); + run_ctrl = value; return true; } @@ -212,7 +212,7 @@ bool RawSPUThread::write_reg(const u32 addr, const u32 value) break; } - npc.store(value); + npc = value; return true; } @@ -245,5 +245,5 @@ void RawSPUThread::task() SPUThread::task(); // save next PC and current SPU Interrupt status - npc.store(pc | u32{ (ch_event_stat.load() & SPU_EVENT_INTR_ENABLED) != 0 }); + npc = pc | ((ch_event_stat & SPU_EVENT_INTR_ENABLED) != 0); } diff --git a/rpcs3/Emu/Cell/SPUASMJITRecompiler.cpp b/rpcs3/Emu/Cell/SPUASMJITRecompiler.cpp index c53ed3536..71d763158 100644 --- a/rpcs3/Emu/Cell/SPUASMJITRecompiler.cpp +++ b/rpcs3/Emu/Cell/SPUASMJITRecompiler.cpp @@ -272,7 +272,7 @@ void spu_recompiler::InterpreterCall(spu_opcode_t op) const u32 old_pc = _spu->pc; - if (_spu->m_state.load() && _spu->check_status()) + if (_spu->m_state && _spu->check_status()) { return 0x2000000 | _spu->pc; } @@ -343,12 +343,12 @@ void spu_recompiler::FunctionCall() LOG_ERROR(SPU, "Branch-to-self"); } - while (!_spu->m_state.load() || !_spu->check_status()) + while (!_spu->m_state || !_spu->check_status()) { // Call override function directly since the type is known static_cast(*_spu->m_dec).DecodeMemory(_spu->offset + _spu->pc); - if (_spu->m_state.load() & CPU_STATE_RETURN) + if (_spu->m_state & CPU_STATE_RETURN) { break; } diff --git a/rpcs3/Emu/Cell/SPUAnalyser.cpp b/rpcs3/Emu/Cell/SPUAnalyser.cpp index 27ab0954b..a6dcbb505 100644 --- a/rpcs3/Emu/Cell/SPUAnalyser.cpp +++ b/rpcs3/Emu/Cell/SPUAnalyser.cpp @@ -40,8 +40,6 @@ SPUDatabase::~SPUDatabase() std::shared_ptr SPUDatabase::analyse(const be_t* ls, u32 entry, u32 max_limit) { - std::lock_guard lock(m_mutex); - // Check arguments (bounds and alignment) if (max_limit > 0x40000 || entry >= max_limit || entry % 4 || max_limit % 4) { @@ -51,7 +49,19 @@ std::shared_ptr SPUDatabase::analyse(const be_t* ls, u32 en // Key for multimap const u64 key = entry | u64{ ls[entry / 4] } << 32; - // Try to find existing function in the database + { + std::shared_lock lock(m_mutex); + + // Try to find existing function in the database + if (auto func = find(ls + entry / 4, key, max_limit - entry)) + { + return func; + } + } + + std::lock_guard lock(m_mutex); + + // Double-check if (auto func = find(ls + entry / 4, key, max_limit - entry)) { return func; diff --git a/rpcs3/Emu/Cell/SPUAnalyser.h b/rpcs3/Emu/Cell/SPUAnalyser.h index b252911aa..eb695520f 100644 --- a/rpcs3/Emu/Cell/SPUAnalyser.h +++ b/rpcs3/Emu/Cell/SPUAnalyser.h @@ -1,6 +1,7 @@ #pragma once #include "Emu/Cell/SPUOpcodes.h" +#include "Utilities/SharedMutex.h" class SPUThread; @@ -258,7 +259,7 @@ struct spu_function_t // SPU Function Database (must be global or PS3 process-local) class SPUDatabase final { - std::mutex m_mutex; + shared_mutex_t m_mutex; // All registered functions (uses addr and first instruction as a key) std::unordered_multimap> m_db; diff --git a/rpcs3/Emu/Cell/SPUThread.cpp b/rpcs3/Emu/Cell/SPUThread.cpp index 48780b9dc..252e95cf0 100644 --- a/rpcs3/Emu/Cell/SPUThread.cpp +++ b/rpcs3/Emu/Cell/SPUThread.cpp @@ -29,7 +29,7 @@ thread_local bool spu_channel_t::notification_required; void spu_int_ctrl_t::set(u64 ints) { // leave only enabled interrupts - ints &= mask.load(); + ints &= mask; // notify if at least 1 bit was set if (ints && ~stat._or(ints) & ints && tag) @@ -118,7 +118,7 @@ void SPUThread::task() while (true) { - if (!m_state.load()) + if (!m_state) { // read opcode const u32 opcode = base[pc / 4]; @@ -146,7 +146,7 @@ void SPUThread::task() return custom_task(*this); } - while (!m_state.load() || !check_status()) + while (!m_state || !check_status()) { // decode instruction using specified decoder pc += m_dec->DecodeMemory(pc + offset); @@ -162,32 +162,34 @@ void SPUThread::init_regs() mfc_queue.clear(); ch_tag_mask = 0; - ch_tag_stat = {}; - ch_stall_stat = {}; - ch_atomic_stat = {}; + ch_tag_stat.data.store({}); + ch_stall_stat.data.store({}); + ch_atomic_stat.data.store({}); ch_in_mbox.clear(); - ch_out_mbox = {}; - ch_out_intr_mbox = {}; + ch_out_mbox.data.store({}); + ch_out_intr_mbox.data.store({}); snr_config = 0; - ch_snr1 = {}; - ch_snr2 = {}; + ch_snr1.data.store({}); + ch_snr2.data.store({}); - ch_event_mask = {}; - ch_event_stat = {}; + ch_event_mask = 0; + ch_event_stat = 0; last_raddr = 0; ch_dec_start_timestamp = get_timebased_time(); // ??? ch_dec_value = 0; - run_ctrl = {}; - status = {}; - npc = {}; + run_ctrl = 0; + status = 0; + npc = 0; - int_ctrl = {}; + int_ctrl[0].clear(); + int_ctrl[1].clear(); + int_ctrl[2].clear(); gpr[1]._u32[3] = 0x3FFF0; // initial stack frame pointer } @@ -511,7 +513,7 @@ u32 SPUThread::get_events(bool waiting) // polling with atomically set/removed SPU_EVENT_WAITING flag return ch_event_stat.atomic_op([this](u32& stat) -> u32 { - if (u32 res = stat & ch_event_mask.load()) + if (u32 res = stat & ch_event_mask) { stat &= ~SPU_EVENT_WAITING; return res; @@ -525,7 +527,7 @@ u32 SPUThread::get_events(bool waiting) } // simple polling - return ch_event_stat.load() & ch_event_mask.load(); + return ch_event_stat & ch_event_mask; } void SPUThread::set_events(u32 mask) @@ -543,7 +545,7 @@ void SPUThread::set_events(u32 mask) { std::lock_guard lock(mutex); - if (ch_event_stat.load() & SPU_EVENT_WAITING) + if (ch_event_stat & SPU_EVENT_WAITING) { cv.notify_one(); } @@ -555,7 +557,7 @@ void SPUThread::set_interrupt_status(bool enable) if (enable) { // detect enabling interrupts with events masked - if (u32 mask = ch_event_mask.load()) + if (u32 mask = ch_event_mask) { throw EXCEPTION("SPU Interrupts not implemented (mask=0x%x)", mask); } @@ -710,7 +712,7 @@ u32 SPUThread::get_ch_value(u32 ch) case SPU_RdEventMask: { - return ch_event_mask.load(); + return ch_event_mask; } case SPU_RdEventStat: @@ -723,7 +725,7 @@ u32 SPUThread::get_ch_value(u32 ch) return res; } - if (ch_event_mask.load() & SPU_EVENT_LR) + if (ch_event_mask & SPU_EVENT_LR) { // register waiter if polling reservation status is required vm::wait_op(*this, last_raddr, 128, WRAP_EXPR(get_events(true) || is_stopped())); @@ -752,7 +754,7 @@ u32 SPUThread::get_ch_value(u32 ch) { // HACK: "Not isolated" status // Return SPU Interrupt status in LSB - return (ch_event_stat.load() & SPU_EVENT_INTR_ENABLED) != 0; + return (ch_event_stat & SPU_EVENT_INTR_ENABLED) != 0; } } @@ -1120,7 +1122,7 @@ void SPUThread::set_ch_value(u32 ch, u32 value) case SPU_WrEventMask: { // detect masking events with enabled interrupt status - if (value && ch_event_stat.load() & SPU_EVENT_INTR_ENABLED) + if (value && ch_event_stat & SPU_EVENT_INTR_ENABLED) { throw EXCEPTION("SPU Interrupts not implemented (mask=0x%x)", value); } @@ -1131,7 +1133,7 @@ void SPUThread::set_ch_value(u32 ch, u32 value) break; } - ch_event_mask.store(value); + ch_event_mask = value; return; } diff --git a/rpcs3/Emu/Cell/SPUThread.h b/rpcs3/Emu/Cell/SPUThread.h index ced3748d7..726ad61ad 100644 --- a/rpcs3/Emu/Cell/SPUThread.h +++ b/rpcs3/Emu/Cell/SPUThread.h @@ -147,13 +147,13 @@ struct spu_channel_t u32 value; }; - atomic_t sync_var; + atomic_t data; public: // returns true on success bool try_push(u32 value) { - const auto old = sync_var.atomic_op([=](sync_var_t& data) + const auto old = data.atomic_op([=](sync_var_t& data) { if ((data.wait = data.count) == false) { @@ -168,7 +168,7 @@ public: // push performing bitwise OR with previous value, may require notification void push_or(u32 value) { - const auto old = sync_var.atomic_op([=](sync_var_t& data) + const auto old = data.atomic_op([=](sync_var_t& data) { data.count = true; data.wait = false; @@ -181,7 +181,7 @@ public: // push unconditionally (overwriting previous value), may require notification void push(u32 value) { - const auto old = sync_var.atomic_op([=](sync_var_t& data) + const auto old = data.atomic_op([=](sync_var_t& data) { data.count = true; data.wait = false; @@ -194,7 +194,7 @@ public: // returns true on success and loaded value std::tuple try_pop() { - const auto old = sync_var.atomic_op([](sync_var_t& data) + const auto old = data.atomic_op([](sync_var_t& data) { data.wait = !data.count; data.count = false; @@ -207,7 +207,7 @@ public: // pop unconditionally (loading last value), may require notification u32 pop() { - const auto old = sync_var.atomic_op([](sync_var_t& data) + const auto old = data.atomic_op([](sync_var_t& data) { data.wait = false; data.count = false; @@ -221,17 +221,17 @@ public: void set_value(u32 value, bool count = true) { - sync_var.store({ count, false, value }); + data.store({ count, false, value }); } - u32 get_value() volatile + u32 get_value() { - return sync_var.data.value; + return data.load().value; } - u32 get_count() volatile + u32 get_count() { - return sync_var.data.count; + return data.load().count; } }; @@ -250,22 +250,22 @@ struct spu_channel_4_t u32 value2; }; - atomic_t sync_var; + atomic_t values; atomic_t value3; public: void clear() { - sync_var = {}; - value3 = {}; + values = sync_var_t{}; + value3 = 0; } // push unconditionally (overwriting latest value), returns true if needs signaling bool push(u32 value) { - value3.exchange(value); + value3 = value; _mm_sfence(); - return sync_var.atomic_op([=](sync_var_t& data) -> bool + return values.atomic_op([=](sync_var_t& data) -> bool { switch (data.count++) { @@ -289,7 +289,7 @@ public: // returns true on success and two u32 values: data and count after removing the first element std::tuple try_pop() { - return sync_var.atomic_op([this](sync_var_t& data) + return values.atomic_op([this](sync_var_t& data) { const auto result = std::make_tuple(data.count != 0, u32{ data.value0 }, u32{ data.count - 1u }); @@ -300,7 +300,8 @@ public: data.value0 = data.value1; data.value1 = data.value2; - data.value2 = value3.load_sync(); + _mm_lfence(); + data.value2 = this->value3; } else { @@ -311,19 +312,15 @@ public: }); } - u32 get_count() volatile + u32 get_count() { - return sync_var.data.count; + return values.raw().count; } void set_values(u32 count, u32 value0, u32 value1 = 0, u32 value2 = 0, u32 value3 = 0) { - sync_var.data.waiting = 0; - sync_var.data.count = count; - sync_var.data.value0 = value0; - sync_var.data.value1 = value1; - sync_var.data.value2 = value2; - this->value3.store(value3); + this->values.raw() = { 0, count, value0, value1, value2 }; + this->value3 = value3; } }; @@ -337,6 +334,13 @@ struct spu_int_ctrl_t void set(u64 ints); void clear(u64 ints); + + void clear() + { + mask = 0; + stat = 0; + tag = nullptr; + } }; struct spu_imm_table_t diff --git a/rpcs3/Emu/DbgCommand.cpp b/rpcs3/Emu/DbgCommand.cpp deleted file mode 100644 index 8be005e73..000000000 --- a/rpcs3/Emu/DbgCommand.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include "stdafx.h" -#include "DbgCommand.h" - -SendDbgCommandCb SendDbgCommandFunc = nullptr; - -void SendDbgCommand(DbgCommand id, CPUThread* t) -{ - SendDbgCommandFunc(id, t); -} - -void SetSendDbgCommandCallback(SendDbgCommandCb cb) -{ - SendDbgCommandFunc = cb; -} \ No newline at end of file diff --git a/rpcs3/Emu/DbgCommand.h b/rpcs3/Emu/DbgCommand.h index 297307972..4009aaa98 100644 --- a/rpcs3/Emu/DbgCommand.h +++ b/rpcs3/Emu/DbgCommand.h @@ -1,7 +1,5 @@ #pragma once -class CPUThread; - enum DbgCommand { DID_FIRST_COMMAND = 0x500, @@ -35,9 +33,3 @@ enum DbgCommand DID_LAST_COMMAND, }; - -typedef void(*SendDbgCommandCb)(DbgCommand id, CPUThread* t); - -void SetSendDbgCommandCallback(SendDbgCommandCb value); - -void SendDbgCommand(DbgCommand id, CPUThread* thr = nullptr); \ No newline at end of file diff --git a/rpcs3/Emu/IdManager.cpp b/rpcs3/Emu/IdManager.cpp index 46b597d9e..d9e2d6720 100644 --- a/rpcs3/Emu/IdManager.cpp +++ b/rpcs3/Emu/IdManager.cpp @@ -1,35 +1,14 @@ #include "stdafx.h" #include "IdManager.h" -namespace idm -{ - std::mutex g_id_mutex; +std::mutex idm::g_mutex; - std::unordered_map g_id_map; +std::unordered_map idm::g_map; - thread_local u32 g_tls_last_id = 0xdeadbeef; +u32 idm::g_last_raw_id = 0; - u32 g_last_raw_id = 0; +thread_local u32 idm::g_tls_last_id = 0xdeadbeef; - void clear() - { - std::lock_guard lock(g_id_mutex); +std::mutex fxm::g_mutex; - g_id_map.clear(); - g_last_raw_id = 0; - } -} - -namespace fxm -{ - std::mutex g_fx_mutex; - - std::unordered_map> g_fx_map; - - void clear() - { - std::lock_guard lock(g_fx_mutex); - - g_fx_map.clear(); - } -} +std::unordered_map> fxm::g_map; diff --git a/rpcs3/Emu/IdManager.h b/rpcs3/Emu/IdManager.h index 3ee541c58..f35e01a7c 100644 --- a/rpcs3/Emu/IdManager.h +++ b/rpcs3/Emu/IdManager.h @@ -2,6 +2,15 @@ #define ID_MANAGER_INCLUDED +template struct type_info_t { static char value; }; + +template char type_info_t::value = 42; + +template constexpr inline const void* get_type_index() +{ + return &type_info_t::value; +} + // default traits for any arbitrary type template struct id_traits { @@ -15,24 +24,16 @@ template struct id_traits static u32 out_id(u32 raw_id) { return raw_id; } }; -class id_data_t final +struct id_data_t final { -public: - const std::shared_ptr data; - const std::type_info& info; - const std::size_t hash; + std::shared_ptr data; + const std::type_info* info; + const void* type_index; - template force_inline id_data_t(std::shared_ptr data) + template inline id_data_t(std::shared_ptr data) : data(std::move(data)) - , info(typeid(T)) - , hash(typeid(T).hash_code()) - { - } - - id_data_t(id_data_t&& right) - : data(std::move(const_cast&>(right.data))) - , info(right.info) - , hash(right.hash) + , info(&typeid(T)) + , type_index(get_type_index()) { } }; @@ -43,64 +44,63 @@ public: // 0x80000000+ : reserved (may be used through id_traits specializations) namespace idm { - // can be called from the constructor called through make() or make_ptr() to get the ID of currently created object - inline u32 get_last_id() - { - thread_local extern u32 g_tls_last_id; + extern std::mutex g_mutex; + extern std::unordered_map g_map; + + extern u32 g_last_raw_id; + + thread_local extern u32 g_tls_last_id; + + // can be called from the constructor called through make() or make_ptr() to get the ID of the object being created + inline static u32 get_last_id() + { return g_tls_last_id; } // reinitialize ID manager - void clear(); + static void clear() + { + std::lock_guard lock(g_mutex); + + g_map.clear(); + g_last_raw_id = 0; + } // check if ID of specified type exists - template bool check(u32 id) + template static bool check(u32 id) { - extern std::mutex g_id_mutex; - extern std::unordered_map g_id_map; + std::lock_guard lock(g_mutex); + + const auto found = g_map.find(id_traits::in_id(id)); - std::lock_guard lock(g_id_mutex); - - const auto found = g_id_map.find(id_traits::in_id(id)); - - return found != g_id_map.end() && found->second.info == typeid(T); + return found != g_map.end() && found->second.type_index == get_type_index(); } // check if ID exists and return its type or nullptr - inline const std::type_info* get_type(u32 raw_id) + inline static const std::type_info* get_type(u32 raw_id) { - extern std::mutex g_id_mutex; - extern std::unordered_map g_id_map; + std::lock_guard lock(g_mutex); - std::lock_guard lock(g_id_mutex); + const auto found = g_map.find(raw_id); - const auto found = g_id_map.find(raw_id); - - return found == g_id_map.end() ? nullptr : &found->second.info; + return found == g_map.end() ? nullptr : found->second.info; } // add new ID of specified type with specified constructor arguments (returns object or nullptr) - template std::enable_if_t::value, std::shared_ptr> make_ptr(Args&&... args) + template static std::enable_if_t::value, std::shared_ptr> make_ptr(Args&&... args) { - extern std::mutex g_id_mutex; - extern std::unordered_map g_id_map; - extern u32 g_last_raw_id; - thread_local extern u32 g_tls_last_id; + std::lock_guard lock(g_mutex); - std::lock_guard lock(g_id_mutex); - - u32 raw_id = g_last_raw_id; - - while ((raw_id = id_traits::next_id(raw_id))) + for (u32 raw_id = g_last_raw_id; (raw_id = id_traits::next_id(raw_id)); /**/) { - if (g_id_map.find(raw_id) != g_id_map.end()) continue; + if (g_map.find(raw_id) != g_map.end()) continue; g_tls_last_id = id_traits::out_id(raw_id); auto ptr = std::make_shared(std::forward(args)...); - g_id_map.emplace(raw_id, id_data_t(ptr)); + g_map.emplace(raw_id, id_data_t(ptr)); if (raw_id < 0x80000000) g_last_raw_id = raw_id; @@ -111,24 +111,17 @@ namespace idm } // add new ID of specified type with specified constructor arguments (returns id) - template std::enable_if_t::value, u32> make(Args&&... args) + template static std::enable_if_t::value, u32> make(Args&&... args) { - extern std::mutex g_id_mutex; - extern std::unordered_map g_id_map; - extern u32 g_last_raw_id; - thread_local extern u32 g_tls_last_id; + std::lock_guard lock(g_mutex); - std::lock_guard lock(g_id_mutex); - - u32 raw_id = g_last_raw_id; - - while ((raw_id = id_traits::next_id(raw_id))) + for (u32 raw_id = g_last_raw_id; (raw_id = id_traits::next_id(raw_id)); /**/) { - if (g_id_map.find(raw_id) != g_id_map.end()) continue; + if (g_map.find(raw_id) != g_map.end()) continue; g_tls_last_id = id_traits::out_id(raw_id); - g_id_map.emplace(raw_id, id_data_t(std::make_shared(std::forward(args)...))); + g_map.emplace(raw_id, id_data_t(std::make_shared(std::forward(args)...))); if (raw_id < 0x80000000) g_last_raw_id = raw_id; @@ -139,24 +132,17 @@ namespace idm } // add new ID for an existing object provided (don't use for initial object creation) - template u32 import(const std::shared_ptr& ptr) + template static u32 import(const std::shared_ptr& ptr) { - extern std::mutex g_id_mutex; - extern std::unordered_map g_id_map; - extern u32 g_last_raw_id; - thread_local extern u32 g_tls_last_id; + std::lock_guard lock(g_mutex); - std::lock_guard lock(g_id_mutex); - - u32 raw_id = g_last_raw_id; - - while ((raw_id = id_traits::next_id(raw_id))) + for (u32 raw_id = g_last_raw_id; (raw_id = id_traits::next_id(raw_id)); /**/) { - if (g_id_map.find(raw_id) != g_id_map.end()) continue; + if (g_map.find(raw_id) != g_map.end()) continue; g_tls_last_id = id_traits::out_id(raw_id); - g_id_map.emplace(raw_id, id_data_t(ptr)); + g_map.emplace(raw_id, id_data_t(ptr)); if (raw_id < 0x80000000) g_last_raw_id = raw_id; @@ -167,16 +153,13 @@ namespace idm } // get ID of specified type - template std::shared_ptr get(u32 id) + template static std::shared_ptr get(u32 id) { - extern std::mutex g_id_mutex; - extern std::unordered_map g_id_map; + std::lock_guard lock(g_mutex); - std::lock_guard lock(g_id_mutex); + const auto found = g_map.find(id_traits::in_id(id)); - const auto found = g_id_map.find(id_traits::in_id(id)); - - if (found == g_id_map.end() || found->second.info != typeid(T)) + if (found == g_map.end() || found->second.type_index != get_type_index()) { return nullptr; } @@ -185,20 +168,17 @@ namespace idm } // get all IDs of specified type T (unsorted) - template std::vector> get_all() + template static std::vector> get_all() { - extern std::mutex g_id_mutex; - extern std::unordered_map g_id_map; - - std::lock_guard lock(g_id_mutex); + std::lock_guard lock(g_mutex); std::vector> result; - const std::size_t hash = typeid(T).hash_code(); + const auto type = get_type_index(); - for (auto& v : g_id_map) + for (auto& v : g_map) { - if (v.second.hash == hash && v.second.info == typeid(T)) + if (v.second.type_index == type) { result.emplace_back(std::static_pointer_cast(v.second.data)); } @@ -208,61 +188,52 @@ namespace idm } // remove ID created with type T - template bool remove(u32 id) + template static bool remove(u32 id) { - extern std::mutex g_id_mutex; - extern std::unordered_map g_id_map; + std::lock_guard lock(g_mutex); - std::lock_guard lock(g_id_mutex); + const auto found = g_map.find(id_traits::in_id(id)); - const auto found = g_id_map.find(id_traits::in_id(id)); - - if (found == g_id_map.end() || found->second.info != typeid(T)) + if (found == g_map.end() || found->second.type_index != get_type_index()) { return false; } - g_id_map.erase(found); + g_map.erase(found); return true; } // remove ID created with type T and return the object - template std::shared_ptr withdraw(u32 id) + template static std::shared_ptr withdraw(u32 id) { - extern std::mutex g_id_mutex; - extern std::unordered_map g_id_map; + std::lock_guard lock(g_mutex); - std::lock_guard lock(g_id_mutex); + const auto found = g_map.find(id_traits::in_id(id)); - const auto found = g_id_map.find(id_traits::in_id(id)); - - if (found == g_id_map.end() || found->second.info != typeid(T)) + if (found == g_map.end() || found->second.type_index != get_type_index()) { return nullptr; } auto ptr = std::static_pointer_cast(found->second.data); - g_id_map.erase(found); + g_map.erase(found); return ptr; } - template u32 get_count() + template static u32 get_count() { - extern std::mutex g_id_mutex; - extern std::unordered_map g_id_map; - - std::lock_guard lock(g_id_mutex); + std::lock_guard lock(g_mutex); u32 result = 0; - const std::size_t hash = typeid(T).hash_code(); + const auto type = get_type_index(); - for (auto& v : g_id_map) + for (auto& v : g_map) { - if (v.second.hash == hash && v.second.info == typeid(T)) + if (v.second.type_index == type) { result++; } @@ -272,20 +243,17 @@ namespace idm } // get sorted ID list of specified type - template std::set get_set() + template static std::set get_set() { - extern std::mutex g_id_mutex; - extern std::unordered_map g_id_map; - - std::lock_guard lock(g_id_mutex); + std::lock_guard lock(g_mutex); std::set result; - const std::size_t hash = typeid(T).hash_code(); + const auto type = get_type_index(); - for (auto& v : g_id_map) + for (auto& v : g_map) { - if (v.second.hash == hash && v.second.info == typeid(T)) + if (v.second.type_index == type) { result.insert(id_traits::out_id(v.first)); } @@ -295,20 +263,17 @@ namespace idm } // get sorted ID map (ID value -> ID data) of specified type - template std::map> get_map() + template static std::map> get_map() { - extern std::mutex g_id_mutex; - extern std::unordered_map g_id_map; - - std::lock_guard lock(g_id_mutex); + std::lock_guard lock(g_mutex); std::map> result; - const std::size_t hash = typeid(T).hash_code(); + const auto type = get_type_index(); - for (auto& v : g_id_map) + for (auto& v : g_map) { - if (v.second.hash == hash && v.second.info == typeid(T)) + if (v.second.type_index == type) { result[id_traits::out_id(v.first)] = std::static_pointer_cast(v.second.data); } @@ -316,69 +281,102 @@ namespace idm return result; } -} +}; // Fixed Object Manager // allows to manage shared objects of any specified type, but only one object per type; // object are deleted when the emulation is stopped namespace fxm { + extern std::mutex g_mutex; + + extern std::unordered_map> g_map; + // reinitialize - void clear(); + static void clear() + { + std::lock_guard lock(g_mutex); + + g_map.clear(); + } // add fixed object of specified type only if it doesn't exist (one unique object per type may exist) - template std::enable_if_t::value, std::shared_ptr> make(Args&&... args) + template static std::enable_if_t::value, std::shared_ptr> make(Args&&... args) { - extern std::mutex g_fx_mutex; - extern std::unordered_map> g_fx_map; + std::lock_guard lock(g_mutex); - std::lock_guard lock(g_fx_mutex); + const auto index = get_type_index(); - const auto found = g_fx_map.find(typeid(T)); + const auto found = g_map.find(index); // only if object of this type doesn't exist - if (found == g_fx_map.end()) + if (found == g_map.end()) { auto ptr = std::make_shared(std::forward(args)...); - g_fx_map.emplace(typeid(T), ptr); + g_map.emplace(index, ptr); - return std::move(ptr); + return ptr; } return nullptr; } // add fixed object of specified type, replacing previous one if it exists - template std::enable_if_t::value, std::shared_ptr> make_always(Args&&... args) + template static std::enable_if_t::value, std::shared_ptr> make_always(Args&&... args) { - extern std::mutex g_fx_mutex; - extern std::unordered_map> g_fx_map; - - std::lock_guard lock(g_fx_mutex); + std::lock_guard lock(g_mutex); auto ptr = std::make_shared(std::forward(args)...); - g_fx_map[typeid(T)] = ptr; + g_map[get_type_index()] = ptr; + + return ptr; + } + + // import existing fixed object of specified type only if it doesn't exist (don't use) + template static std::shared_ptr import(std::shared_ptr&& ptr) + { + std::lock_guard lock(g_mutex); + + const auto index = get_type_index(); + + const auto found = g_map.find(index); + + if (found == g_map.end()) + { + g_map.emplace(index, ptr); + + return ptr; + } + + return nullptr; + } + + // import existing fixed object of specified type, replacing previous one if it exists (don't use) + template static std::shared_ptr import_always(std::shared_ptr&& ptr) + { + std::lock_guard lock(g_mutex); + + g_map[get_type_index()] = ptr; return ptr; } // get fixed object of specified type (always returns an object, it's created if it doesn't exist) - template std::enable_if_t::value, std::shared_ptr> get_always(Args&&... args) + template static std::enable_if_t::value, std::shared_ptr> get_always(Args&&... args) { - extern std::mutex g_fx_mutex; - extern std::unordered_map> g_fx_map; + std::lock_guard lock(g_mutex); - std::lock_guard lock(g_fx_mutex); + const auto index = get_type_index(); - const auto found = g_fx_map.find(typeid(T)); + const auto found = g_map.find(index); - if (found == g_fx_map.end()) + if (found == g_map.end()) { auto ptr = std::make_shared(std::forward(args)...); - g_fx_map[typeid(T)] = ptr; + g_map[index] = ptr; return ptr; } @@ -387,27 +385,21 @@ namespace fxm } // check whether the object exists - template bool check() + template static bool check() { - extern std::mutex g_fx_mutex; - extern std::unordered_map> g_fx_map; + std::lock_guard lock(g_mutex); - std::lock_guard lock(g_fx_mutex); - - return g_fx_map.find(typeid(T)) != g_fx_map.end(); + return g_map.find(get_type_index()) != g_map.end(); } // get fixed object of specified type (returns nullptr if it doesn't exist) - template std::shared_ptr get() + template static std::shared_ptr get() { - extern std::mutex g_fx_mutex; - extern std::unordered_map> g_fx_map; + std::lock_guard lock(g_mutex); - std::lock_guard lock(g_fx_mutex); + const auto found = g_map.find(get_type_index()); - const auto found = g_fx_map.find(typeid(T)); - - if (found == g_fx_map.end()) + if (found == g_map.end()) { return nullptr; } @@ -416,40 +408,34 @@ namespace fxm } // remove fixed object created with type T - template bool remove() + template static bool remove() { - extern std::mutex g_fx_mutex; - extern std::unordered_map> g_fx_map; + std::lock_guard lock(g_mutex); - std::lock_guard lock(g_fx_mutex); + const auto found = g_map.find(get_type_index()); - const auto found = g_fx_map.find(typeid(T)); - - if (found == g_fx_map.end()) + if (found == g_map.end()) { return false; } - return g_fx_map.erase(found), true; + return g_map.erase(found), true; } // remove fixed object created with type T and return it - template std::shared_ptr withdraw() + template static std::shared_ptr withdraw() { - extern std::mutex g_fx_mutex; - extern std::unordered_map> g_fx_map; + std::lock_guard lock(g_mutex); - std::lock_guard lock(g_fx_mutex); + const auto found = g_map.find(get_type_index()); - const auto found = g_fx_map.find(typeid(T)); - - if (found == g_fx_map.end()) + if (found == g_map.end()) { return nullptr; } auto ptr = std::static_pointer_cast(std::move(found->second)); - return g_fx_map.erase(found), ptr; + return g_map.erase(found), ptr; } -} +}; diff --git a/rpcs3/Emu/Io/Keyboard.cpp b/rpcs3/Emu/Io/Keyboard.cpp index e23f325b8..052cb2d84 100644 --- a/rpcs3/Emu/Io/Keyboard.cpp +++ b/rpcs3/Emu/Io/Keyboard.cpp @@ -1,60 +1,15 @@ #include "stdafx.h" -#include "rpcs3/Ini.h" -#include "Null/NullKeyboardHandler.h" +#include "Emu/System.h" + #include "Keyboard.h" -GetKeyboardHandlerCountCb GetKeyboardHandlerCount = []() +void KeyboardManager::Init(u32 max_connect) { - return 1; -}; - -GetKeyboardHandlerCb GetKeyboardHandler = [](int i) -> KeyboardHandlerBase* -{ - return new NullKeyboardHandler; -}; - -void SetGetKeyboardHandlerCountCallback(GetKeyboardHandlerCountCb cb) -{ - GetKeyboardHandlerCount = cb; -} - -void SetGetKeyboardHandlerCallback(GetKeyboardHandlerCb cb) -{ - GetKeyboardHandler = cb; -} - -KeyboardManager::KeyboardManager() - : m_keyboard_handler(nullptr) - , m_inited(false) -{ -} - -KeyboardManager::~KeyboardManager() -{ -} - -void KeyboardManager::Init(const u32 max_connect) -{ - if(m_inited) - return; - - // NOTE: Change these to std::make_unique assignments when C++14 comes out. - int numHandlers = GetKeyboardHandlerCount(); - int selectedHandler = Ini.KeyboardHandlerMode.GetValue(); - if (selectedHandler > numHandlers) - { - selectedHandler = 0; - } - m_keyboard_handler.reset(GetKeyboardHandler(selectedHandler)); - + m_keyboard_handler = Emu.GetCallbacks().get_kb_handler(); m_keyboard_handler->Init(max_connect); - m_inited = true; } void KeyboardManager::Close() { - if(m_keyboard_handler) m_keyboard_handler->Close(); - m_keyboard_handler = nullptr; - - m_inited = false; + m_keyboard_handler.reset(); } diff --git a/rpcs3/Emu/Io/Keyboard.h b/rpcs3/Emu/Io/Keyboard.h index 140c06ed4..c61916dc3 100644 --- a/rpcs3/Emu/Io/Keyboard.h +++ b/rpcs3/Emu/Io/Keyboard.h @@ -1,16 +1,13 @@ #pragma once + #include "KeyboardHandler.h" class KeyboardManager { - bool m_inited = false; std::unique_ptr m_keyboard_handler; public: - KeyboardManager(); - ~KeyboardManager(); - - void Init(const u32 max_connect); + void Init(u32 max_connect); void Close(); std::vector& GetKeyboards() { return m_keyboard_handler->GetKeyboards(); } @@ -19,11 +16,5 @@ public: KbData& GetData(const u32 keyboard) { return m_keyboard_handler->GetData(keyboard); } KbConfig& GetConfig(const u32 keyboard) { return m_keyboard_handler->GetConfig(keyboard); } - bool IsInited() const { return m_inited; } + bool IsInited() const { return m_keyboard_handler.operator bool(); } }; - -typedef int(*GetKeyboardHandlerCountCb)(); -typedef KeyboardHandlerBase*(*GetKeyboardHandlerCb)(int i); - -void SetGetKeyboardHandlerCountCallback(GetKeyboardHandlerCountCb cb); -void SetGetKeyboardHandlerCallback(GetKeyboardHandlerCb cb); \ No newline at end of file diff --git a/rpcs3/Emu/Io/Mouse.cpp b/rpcs3/Emu/Io/Mouse.cpp index 5a0f191da..e07534e3c 100644 --- a/rpcs3/Emu/Io/Mouse.cpp +++ b/rpcs3/Emu/Io/Mouse.cpp @@ -1,60 +1,15 @@ #include "stdafx.h" -#include "rpcs3/Ini.h" -#include "Null/NullMouseHandler.h" +#include "Emu/System.h" + #include "Mouse.h" -GetMouseHandlerCountCb GetMouseHandlerCount = []() +void MouseManager::Init(u32 max_connect) { - return 1; -}; - -GetMouseHandlerCb GetMouseHandler = [](int i) -> MouseHandlerBase* -{ - return new NullMouseHandler; -}; - -void SetGetMouseHandlerCountCallback(GetMouseHandlerCountCb cb) -{ - GetMouseHandlerCount = cb; -} - -void SetGetMouseHandlerCallback(GetMouseHandlerCb cb) -{ - GetMouseHandler = cb; -} - -MouseManager::MouseManager() - : m_mouse_handler(nullptr) - , m_inited(false) -{ -} - -MouseManager::~MouseManager() -{ -} - -void MouseManager::Init(const u32 max_connect) -{ - if(m_inited) - return; - - // NOTE: Change these to std::make_unique assignments when C++14 is available. - int numHandlers = GetMouseHandlerCount(); - int selectedHandler = Ini.MouseHandlerMode.GetValue(); - if (selectedHandler > numHandlers) - { - selectedHandler = 0; - } - m_mouse_handler.reset(GetMouseHandler(selectedHandler)); - + m_mouse_handler = Emu.GetCallbacks().get_mouse_handler(); m_mouse_handler->Init(max_connect); - m_inited = true; } void MouseManager::Close() { - if(m_mouse_handler) m_mouse_handler->Close(); - m_mouse_handler = nullptr; - - m_inited = false; + m_mouse_handler.reset(); } diff --git a/rpcs3/Emu/Io/Mouse.h b/rpcs3/Emu/Io/Mouse.h index c6dbdd61d..98d86185c 100644 --- a/rpcs3/Emu/Io/Mouse.h +++ b/rpcs3/Emu/Io/Mouse.h @@ -1,16 +1,13 @@ #pragma once + #include "MouseHandler.h" class MouseManager { - bool m_inited; std::unique_ptr m_mouse_handler; public: - MouseManager(); - ~MouseManager(); - - void Init(const u32 max_connect); + void Init(u32 max_connect); void Close(); std::vector& GetMice() { return m_mouse_handler->GetMice(); } @@ -18,11 +15,5 @@ public: MouseData& GetData(const u32 mouse) { return m_mouse_handler->GetData(mouse); } MouseRawData& GetRawData(const u32 mouse) { return m_mouse_handler->GetRawData(mouse); } - bool IsInited() const { return m_inited; } + bool IsInited() const { return m_mouse_handler.operator bool(); } }; - -typedef int(*GetMouseHandlerCountCb)(); -typedef MouseHandlerBase*(*GetMouseHandlerCb)(int i); - -void SetGetMouseHandlerCountCallback(GetMouseHandlerCountCb cb); -void SetGetMouseHandlerCallback(GetMouseHandlerCb cb); \ No newline at end of file diff --git a/rpcs3/Emu/Io/Pad.cpp b/rpcs3/Emu/Io/Pad.cpp index 72efc937b..5c3328337 100644 --- a/rpcs3/Emu/Io/Pad.cpp +++ b/rpcs3/Emu/Io/Pad.cpp @@ -1,60 +1,15 @@ #include "stdafx.h" -#include "rpcs3/Ini.h" -#include "Null/NullPadHandler.h" +#include "Emu/System.h" + #include "Pad.h" -GetPadHandlerCountCb GetPadHandlerCount = []() +void PadManager::Init(u32 max_connect) { - return 1; -}; - -GetPadHandlerCb GetPadHandler = [](int i) -> PadHandlerBase* -{ - return new NullPadHandler; -}; - -void SetGetPadHandlerCountCallback(GetPadHandlerCountCb cb) -{ - GetPadHandlerCount = cb; -} - -void SetGetPadHandlerCallback(GetPadHandlerCb cb) -{ - GetPadHandler = cb; -} - -PadManager::PadManager() - : m_pad_handler(nullptr) - , m_inited(false) -{ -} - -PadManager::~PadManager() -{ -} - -void PadManager::Init(const u32 max_connect) -{ - if(m_inited) - return; - - // NOTE: Change these to std::make_unique assignments when C++14 is available. - int numHandlers = GetPadHandlerCount(); - int selectedHandler = Ini.PadHandlerMode.GetValue(); - if (selectedHandler > numHandlers) - { - selectedHandler = 0; - } - m_pad_handler.reset(GetPadHandler(selectedHandler)); - + m_pad_handler = Emu.GetCallbacks().get_pad_handler(); m_pad_handler->Init(max_connect); - m_inited = true; } void PadManager::Close() { - if(m_pad_handler) m_pad_handler->Close(); - m_pad_handler = nullptr; - - m_inited = false; -} \ No newline at end of file + m_pad_handler.reset(); +} diff --git a/rpcs3/Emu/Io/Pad.h b/rpcs3/Emu/Io/Pad.h index e6a326046..8bbb3a01f 100644 --- a/rpcs3/Emu/Io/Pad.h +++ b/rpcs3/Emu/Io/Pad.h @@ -1,27 +1,18 @@ #pragma once + #include "PadHandler.h" class PadManager { - bool m_inited; std::unique_ptr m_pad_handler; public: - PadManager(); - ~PadManager(); - - void Init(const u32 max_connect); + void Init(u32 max_connect); void Close(); std::vector& GetPads() { return m_pad_handler->GetPads(); } PadInfo& GetInfo() { return m_pad_handler->GetInfo(); } std::vector