From b600cba180b58c63483ed5929cee85413963cfa3 Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Tue, 16 Sep 2014 17:56:27 +0400 Subject: [PATCH] CB_FUNC / SC_FUNC small update --- Utilities/Log.h | 1 - rpcs3/Emu/SysCalls/CB_FUNC.h | 53 +++++++++---------- rpcs3/Emu/SysCalls/Modules/cellSpurs.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/cellSync.cpp | 8 +-- rpcs3/Emu/SysCalls/SC_FUNC.h | 66 ++++++++++++------------ rpcs3/Emu/SysCalls/SysCalls.cpp | 17 +++--- rpcs3/stdafx.h | 1 + 7 files changed, 73 insertions(+), 77 deletions(-) diff --git a/Utilities/Log.h b/Utilities/Log.h index c1826ef727..32c0f18e81 100644 --- a/Utilities/Log.h +++ b/Utilities/Log.h @@ -1,5 +1,4 @@ #pragma once -#include #include "Utilities/MTRingbuffer.h" //#define BUFFERED_LOGGING 1 diff --git a/rpcs3/Emu/SysCalls/CB_FUNC.h b/rpcs3/Emu/SysCalls/CB_FUNC.h index 8a5eda1dc1..d989d13e2f 100644 --- a/rpcs3/Emu/SysCalls/CB_FUNC.h +++ b/rpcs3/Emu/SysCalls/CB_FUNC.h @@ -95,49 +95,37 @@ namespace cb_detail return _bind_func_args(CPU, args...) || (t == ARG_STACK); } - template + template struct _func_res { - static_assert(sizeof(RT) <= 8, "Invalid callback result type"); - static_assert(!std::is_pointer::value, "Invalid callback result type (pointer)"); - static_assert(!std::is_reference::value, "Invalid callback result type (reference)"); + static_assert(type == ARG_GENERAL, "Wrong use of _func_res template"); + static_assert(sizeof(T) <= 8, "Invalid callback result type for ARG_GENERAL"); - __forceinline static RT get_value(const PPUThread& CPU) + __forceinline static T get_value(const PPUThread& CPU) { - if (std::is_floating_point::value) - { - return (RT)CPU.FPR[1]; - } - else - { - return (RT&)CPU.GPR[3]; - } + return (T&)CPU.GPR[3]; } }; - template<> - struct _func_res + template + struct _func_res { - __forceinline static const u128 get_value(const PPUThread& CPU) + static_assert(sizeof(T) <= 8, "Invalid callback result type for ARG_FLOAT"); + + __forceinline static T get_value(const PPUThread& CPU) { - return CPU.VPR[2]; + return (T)CPU.FPR[1]; } }; - template<> - struct _func_res + template + struct _func_res { - __forceinline static const u128 get_value(const PPUThread& CPU) - { - return CPU.VPR[2]; - } - }; + static_assert(sizeof(T) == 16, "Invalid callback result type for ARG_VECTOR"); - template<> - struct _func_res - { - __forceinline static void get_value(const PPUThread& CPU) + __forceinline static T get_value(const PPUThread& CPU) { + return (T&)CPU.VPR[2]; } }; @@ -150,7 +138,14 @@ namespace cb_detail if (stack) CPU.GPR[1] -= FIXED_STACK_FRAME_SIZE; CPU.FastCall2(pc, rtoc); if (stack) CPU.GPR[1] += FIXED_STACK_FRAME_SIZE; - return _func_res::get_value(CPU); + + static_assert(!std::is_pointer::value, "Invalid callback result type (pointer)"); + static_assert(!std::is_reference::value, "Invalid callback result type (reference)"); + const bool is_float = std::is_floating_point::value; + const bool is_vector = std::is_same::value; + const _func_arg_type t = is_float ? ARG_FLOAT : (is_vector ? ARG_VECTOR : ARG_GENERAL); + + return _func_res::get_value(CPU); } }; diff --git a/rpcs3/Emu/SysCalls/Modules/cellSpurs.cpp b/rpcs3/Emu/SysCalls/Modules/cellSpurs.cpp index d008d86a97..7d6a2d4721 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSpurs.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSpurs.cpp @@ -31,7 +31,7 @@ s64 spursInit( { // internal function #ifdef PRX_DEBUG - return cb_caller, u32, u32, s32, s32, s32, u32, u32, u32, u32, u32, u32, u32>::call(GetCurrentPPUThread(), libsre + 0x74E4, libsre_rtoc, + return cb_call, u32, u32, s32, s32, s32, u32, u32, u32, u32, u32, u32, u32>(GetCurrentPPUThread(), libsre + 0x74E4, libsre_rtoc, spurs, revision, sdkVersion, nSpus, spuPriority, ppuPriority, flags, Memory.RealToVirtualAddr(prefix), prefixSize, container, Memory.RealToVirtualAddr(swlPriority), swlMaxSpu, swlIsPreem); #else //spurs->spurs = new SPURSManager(attr); @@ -294,7 +294,7 @@ s64 cellSpursAttributeEnableSystemWorkload(vm::ptr attr, vm: return CELL_SPURS_CORE_ERROR_ALIGN; } - const u32 nSpus = attr->m.nSpus; + const u32 nSpus = attr->_u32[2]; if (!nSpus) { return CELL_SPURS_CORE_ERROR_INVAL; diff --git a/rpcs3/Emu/SysCalls/Modules/cellSync.cpp b/rpcs3/Emu/SysCalls/Modules/cellSync.cpp index 482805a90a..43df317feb 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSync.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSync.cpp @@ -1535,7 +1535,7 @@ s32 _cellSyncLFQueuePushBody(vm::ptr queue, vm::ptr else { #ifdef PRX_DEBUG - res = cb_caller, u32, u32, u64>::call(GetCurrentPPUThread(), libsre + 0x3050, libsre_rtoc, + res = cb_call, u32, u32, u64>(GetCurrentPPUThread(), libsre + 0x3050, libsre_rtoc, queue, position_v.addr(), isBlocking, 0); position = position_v->ToLE(); #else @@ -1580,7 +1580,7 @@ s32 _cellSyncLFQueuePushBody(vm::ptr queue, vm::ptr else { #ifdef PRX_DEBUG - res = cb_caller, s32, u64>::call(GetCurrentPPUThread(), libsre + 0x355C, libsre_rtoc, + res = cb_call, s32, u64>(GetCurrentPPUThread(), libsre + 0x355C, libsre_rtoc, queue, position, 0); #else res = syncLFQueueCompletePushPointer2(queue, position, nullptr); @@ -1930,7 +1930,7 @@ s32 _cellSyncLFQueuePopBody(vm::ptr queue, vm::ptr buffer else { #ifdef PRX_DEBUG - res = cb_caller, u32, u32, u64>::call(GetCurrentPPUThread(), libsre + 0x39AC, libsre_rtoc, + res = cb_call, u32, u32, u64>(GetCurrentPPUThread(), libsre + 0x39AC, libsre_rtoc, queue, position_v.addr(), isBlocking, 0); position = position_v->ToLE(); #else @@ -1972,7 +1972,7 @@ s32 _cellSyncLFQueuePopBody(vm::ptr queue, vm::ptr buffer else { #ifdef PRX_DEBUG - res = cb_caller, s32, u64, u64>::call(GetCurrentPPUThread(), libsre + 0x3EB8, libsre_rtoc, + res = cb_call, s32, u64, u64>(GetCurrentPPUThread(), libsre + 0x3EB8, libsre_rtoc, queue, position, 0, 0); #else res = syncLFQueueCompletePopPointer2(queue, position, nullptr, 0); diff --git a/rpcs3/Emu/SysCalls/SC_FUNC.h b/rpcs3/Emu/SysCalls/SC_FUNC.h index 4a5b1da3e2..146a44131c 100644 --- a/rpcs3/Emu/SysCalls/SC_FUNC.h +++ b/rpcs3/Emu/SysCalls/SC_FUNC.h @@ -46,7 +46,7 @@ namespace detail template struct bind_arg { - static_assert(std::is_same::value, "Invalid function argument type for ARG_VECTOR"); + static_assert(sizeof(T) == 16, "Invalid function argument type for ARG_VECTOR"); static __forceinline T func(PPUThread& CPU) { @@ -69,41 +69,37 @@ namespace detail } }; - template + template struct bind_result { - static_assert(sizeof(T) <= 8, "Invalid function result type"); - static_assert(!std::is_pointer::value, "Invalid function result type (pointer)"); - static_assert(!std::is_reference::value, "Invalid function result type (reference)"); + static_assert(type == ARG_GENERAL, "Wrong use of bind_result template"); + static_assert(sizeof(T) <= 8, "Invalid function result type for ARG_GENERAL"); static __forceinline void func(PPUThread& CPU, T result) { - if (std::is_floating_point::value) - { - CPU.FPR[1] = (double)result; - } - else - { - (T&)CPU.GPR[3] = result; - } + (T&)CPU.GPR[3] = result; } }; - template<> - struct bind_result + template + struct bind_result { - static __forceinline void func(PPUThread& CPU, const u128 result) + static_assert(sizeof(T) <= 8, "Invalid function result type for ARG_FLOAT"); + + static __forceinline void func(PPUThread& CPU, T result) { - CPU.VPR[2] = result; + CPU.FPR[1] = (double)result; } }; - template<> - struct bind_result + template + struct bind_result { - static __forceinline void func(PPUThread& CPU, const u128 result) + static_assert(sizeof(T) == 16, "Invalid function result type for ARG_VECTOR"); + + static __forceinline void func(PPUThread& CPU, const T result) { - CPU.VPR[2] = result; + (T&)CPU.VPR[2] = result; } }; @@ -157,13 +153,13 @@ namespace detail return std::tuple_cat(std::tuple(bind_arg::func(CPU)), iterate(CPU)); } - template + template class func_binder; - template - class func_binder : public func_caller + template + class func_binder : public func_caller { - typedef void(*func_t)(TA...); + typedef void(*func_t)(T...); const func_t m_call; public: @@ -176,14 +172,14 @@ namespace detail virtual void operator()() { declCPU(); - call(m_call, iterate<0, 0, 0, TA...>(CPU)); + call(m_call, iterate<0, 0, 0, T...>(CPU)); } }; - template + template class func_binder : public func_caller { - typedef TR(*func_t)(TA...); + typedef RT(*func_t)(T...); const func_t m_call; public: @@ -196,13 +192,19 @@ namespace detail virtual void operator()() { declCPU(); - bind_result::func(CPU, call(m_call, iterate<0, 0, 0, TA...>(CPU))); + static_assert(!std::is_pointer::value, "Invalid function result type (pointer)"); + static_assert(!std::is_reference::value, "Invalid function result type (reference)"); + const bool is_float = std::is_floating_point::value; + const bool is_vector = std::is_same::value; + const bind_arg_type t = is_float ? ARG_FLOAT : (is_vector ? ARG_VECTOR : ARG_GENERAL); + + bind_result::func(CPU, call(m_call, iterate<0, 0, 0, T...>(CPU))); } }; } -template -func_caller* bind_func(TR(*call)(TA...)) +template +func_caller* bind_func(RT(*call)(T...)) { - return new detail::func_binder(call); + return new detail::func_binder(call); } \ No newline at end of file diff --git a/rpcs3/Emu/SysCalls/SysCalls.cpp b/rpcs3/Emu/SysCalls/SysCalls.cpp index ce1a858983..2019e4c34b 100644 --- a/rpcs3/Emu/SysCalls/SysCalls.cpp +++ b/rpcs3/Emu/SysCalls/SysCalls.cpp @@ -11,8 +11,8 @@ #include "lv2/sys_event.h" #include "lv2/sys_event_flag.h" #include "lv2/sys_interrupt.h" -#include "lv2/sys_lwcond.h" -#include "lv2/sys_lwmutex.h" +//#include "lv2/sys_lwcond.h" +//#include "lv2/sys_lwmutex.h" #include "lv2/sys_memory.h" #include "lv2/sys_mmapper.h" #include "lv2/sys_ppu_thread.h" @@ -21,7 +21,6 @@ #include "lv2/sys_rsx.h" #include "lv2/sys_rwlock.h" #include "lv2/sys_semaphore.h" -#include "lv2/sys_spinlock.h" #include "lv2/sys_spu.h" #include "lv2/sys_time.h" #include "lv2/sys_timer.h" @@ -138,11 +137,11 @@ static func_caller* sc_table[kSyscallTableLength] = bind_func(sys_semaphore_wait), //92 (0x05C) bind_func(sys_semaphore_trywait), //93 (0x05D) bind_func(sys_semaphore_post), //94 (0x05E) - null_func,//bind_func(sys_lwmutex_create), //95 (0x05F) - null_func,//bind_func(sys_lwmutex_destroy), //96 (0x060) - null_func,//bind_func(sys_lwmutex_lock), //97 (0x061) - null_func,//bind_func(sys_lwmutex_trylock), //98 (0x062) - null_func,//bind_func(sys_lwmutex_unlock), //99 (0x063) + null_func,//bind_func(sys_lwmutex_create), //95 (0x05F) // internal, used by sys_lwmutex_create + null_func,//bind_func(sys_lwmutex_destroy), //96 (0x060) // internal, used by sys_lwmutex_destroy + null_func,//bind_func(sys_lwmutex_lock), //97 (0x061) // internal, used by sys_lwmutex_lock + null_func,//bind_func(sys_lwmutex_trylock), //98 (0x062) // internal, used by sys_lwmutex_unlock + null_func,//bind_func(sys_lwmutex_unlock), //99 (0x063) // internal, used by sys_lwmutex_trylock bind_func(sys_mutex_create), //100 (0x064) bind_func(sys_mutex_destroy), //101 (0x065) bind_func(sys_mutex_lock), //102 (0x066) @@ -160,7 +159,7 @@ static func_caller* sc_table[kSyscallTableLength] = bind_func(sys_semaphore_get_value), //114 (0x072) null_func,//bind_func(sys_semaphore_...) //115 (0x073) null_func,//bind_func(sys_semaphore_...) //116 (0x074) - null_func,//bind_func(sys_semaphore_...) //117 (0x075) + 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) diff --git a/rpcs3/stdafx.h b/rpcs3/stdafx.h index 42ea227704..e1c4825f87 100644 --- a/rpcs3/stdafx.h +++ b/rpcs3/stdafx.h @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include