mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-02-21 18:39:57 +00:00
Remove CALL_FUNC, implement ppu_execute<>()
This commit is contained in:
parent
4ab777b429
commit
73d35b0236
@ -491,7 +491,7 @@ void _spurs::handler_wait_ready(ppu_thread& ppu, vm::ptr<CellSpurs> spurs)
|
|||||||
{
|
{
|
||||||
if (spurs->handlerExiting)
|
if (spurs->handlerExiting)
|
||||||
{
|
{
|
||||||
CHECK_SUCCESS(CALL_FUNC(ppu, sys_lwmutex_unlock, ppu, spurs.ptr(&CellSpurs::mutex)));
|
CHECK_SUCCESS(ppu_execute<&sys_lwmutex_unlock>(ppu, spurs.ptr(&CellSpurs::mutex)));
|
||||||
|
|
||||||
return sys_ppu_thread_exit(ppu, 0);
|
return sys_ppu_thread_exit(ppu, 0);
|
||||||
}
|
}
|
||||||
|
@ -451,7 +451,7 @@ s32 cellVdecOpen(ppu_thread& ppu, vm::cptr<CellVdecType> type, vm::cptr<CellVdec
|
|||||||
*handle = vdec->id;
|
*handle = vdec->id;
|
||||||
|
|
||||||
vm::var<u64> _tid;
|
vm::var<u64> _tid;
|
||||||
CALL_FUNC(ppu, sys_ppu_thread_create, ppu, +_tid, 1148, 0, 900, 0x4000, SYS_PPU_THREAD_CREATE_INTERRUPT, vm::null);
|
ppu_execute<&sys_ppu_thread_create>(ppu, +_tid, 1148, 0, 900, 0x4000, SYS_PPU_THREAD_CREATE_INTERRUPT, vm::null);
|
||||||
vdec->gpr[13] = idm::get<ppu_thread>(*_tid)->gpr[13];
|
vdec->gpr[13] = idm::get<ppu_thread>(*_tid)->gpr[13];
|
||||||
vdec->ppu_tid = *_tid;
|
vdec->ppu_tid = *_tid;
|
||||||
|
|
||||||
@ -471,7 +471,7 @@ s32 cellVdecOpenEx(ppu_thread& ppu, vm::cptr<CellVdecTypeEx> type, vm::cptr<Cell
|
|||||||
*handle = vdec->id;
|
*handle = vdec->id;
|
||||||
|
|
||||||
vm::var<u64> _tid;
|
vm::var<u64> _tid;
|
||||||
CALL_FUNC(ppu, sys_ppu_thread_create, ppu, +_tid, 1148, 0, 900, 0x4000, SYS_PPU_THREAD_CREATE_INTERRUPT, vm::null);
|
ppu_execute<&sys_ppu_thread_create>(ppu, +_tid, 1148, 0, 900, 0x4000, SYS_PPU_THREAD_CREATE_INTERRUPT, vm::null);
|
||||||
vdec->gpr[13] = idm::get<ppu_thread>(*_tid)->gpr[13];
|
vdec->gpr[13] = idm::get<ppu_thread>(*_tid)->gpr[13];
|
||||||
vdec->ppu_tid = *_tid;
|
vdec->ppu_tid = *_tid;
|
||||||
|
|
||||||
@ -501,8 +501,7 @@ s32 cellVdecClose(ppu_thread& ppu, u32 handle)
|
|||||||
|
|
||||||
vdec->notify();
|
vdec->notify();
|
||||||
vdec->join();
|
vdec->join();
|
||||||
CALL_FUNC(ppu, sys_interrupt_thread_disestablish, ppu, vdec->ppu_tid);
|
ppu_execute<&sys_interrupt_thread_disestablish>(ppu, vdec->ppu_tid);
|
||||||
idm::remove<ppu_thread>(handle);
|
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ class ppu_module_manager final
|
|||||||
static ppu_static_variable& access_static_variable(const char* module, u32 vnid);
|
static ppu_static_variable& access_static_variable(const char* module, u32 vnid);
|
||||||
|
|
||||||
// Global variable for each registered function
|
// Global variable for each registered function
|
||||||
template <typename T, T Func>
|
template <auto* Func>
|
||||||
struct registered
|
struct registered
|
||||||
{
|
{
|
||||||
static ppu_static_function* info;
|
static ppu_static_function* info;
|
||||||
@ -121,40 +121,42 @@ class ppu_module_manager final
|
|||||||
public:
|
public:
|
||||||
static const ppu_static_module* get_module(const std::string& name);
|
static const ppu_static_module* get_module(const std::string& name);
|
||||||
|
|
||||||
template <typename T, T Func>
|
template <auto* Func>
|
||||||
static auto& register_static_function(const char* module, const char* name, ppu_function_t func, u32 fnid)
|
static auto& register_static_function(const char* module, const char* name, ppu_function_t func, u32 fnid)
|
||||||
{
|
{
|
||||||
auto& info = access_static_function(module, fnid);
|
auto& info = access_static_function(module, fnid);
|
||||||
|
|
||||||
info.name = name;
|
info.name = name;
|
||||||
info.index = ppu_function_manager::register_function<T, Func>(func);
|
info.index = ppu_function_manager::register_function<decltype(Func), Func>(func);
|
||||||
info.flags = 0;
|
info.flags = 0;
|
||||||
info.type = typeid(T).name();
|
info.type = typeid(*Func).name();
|
||||||
|
|
||||||
registered<T, Func>::info = &info;
|
registered<Func>::info = &info;
|
||||||
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, T Func>
|
template <auto* Func>
|
||||||
static auto& find_static_function()
|
static auto& find_static_function()
|
||||||
{
|
{
|
||||||
return *registered<T, Func>::info;
|
return *registered<Func>::info;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, T* Var>
|
template <auto* Var>
|
||||||
static auto& register_static_variable(const char* module, const char* name, u32 vnid)
|
static auto& register_static_variable(const char* module, const char* name, u32 vnid)
|
||||||
{
|
{
|
||||||
static_assert(std::is_same<u32, std::decay_t<typename T::addr_type>>::value, "Static variable registration: vm::gvar<T> expected");
|
using gvar = std::decay_t<decltype(*Var)>;
|
||||||
|
|
||||||
|
static_assert(std::is_same<u32, typename gvar::addr_type>::value, "Static variable registration: vm::gvar<T> expected");
|
||||||
|
|
||||||
auto& info = access_static_variable(module, vnid);
|
auto& info = access_static_variable(module, vnid);
|
||||||
|
|
||||||
info.name = name;
|
info.name = name;
|
||||||
info.var = reinterpret_cast<vm::gvar<void>*>(Var);
|
info.var = reinterpret_cast<vm::gvar<void>*>(Var);
|
||||||
info.init = [] {};
|
info.init = [] {};
|
||||||
info.size = sizeof(typename T::type);
|
info.size = sizeof(typename gvar::type);
|
||||||
info.align = alignof(typename T::type);
|
info.align = alignof(typename gvar::type);
|
||||||
info.type = typeid(T).name();
|
info.type = typeid(*Var).name();
|
||||||
info.flags = 0;
|
info.flags = 0;
|
||||||
info.addr = 0;
|
info.addr = 0;
|
||||||
|
|
||||||
@ -267,24 +269,22 @@ public:
|
|||||||
static const ppu_static_module sys_lv2dbg;
|
static const ppu_static_module sys_lv2dbg;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T, T Func>
|
template <auto* Func>
|
||||||
ppu_static_function* ppu_module_manager::registered<T, Func>::info = nullptr;
|
ppu_static_function* ppu_module_manager::registered<Func>::info = nullptr;
|
||||||
|
|
||||||
// Call specified function directly if LLE is not available, call LLE equivalent in callback style otherwise
|
// Call specified function directly if LLE is not available, call LLE equivalent in callback style otherwise
|
||||||
template<typename T, T Func, typename... Args, typename RT = std::invoke_result_t<T, Args...>>
|
template <auto* Func, typename... Args, typename RT = std::invoke_result_t<decltype(Func), ppu_thread&, Args...>>
|
||||||
inline RT ppu_execute_function_or_callback(ppu_thread& ppu, Args&&... args)
|
inline RT ppu_execute(ppu_thread& ppu, Args... args)
|
||||||
{
|
{
|
||||||
vm::ptr<RT(Args...)> func = vm::cast(*ppu_module_manager::find_static_function<T, Func>().export_addr);
|
vm::ptr<RT(Args...)> func = vm::cast(*ppu_module_manager::find_static_function<Func>().export_addr);
|
||||||
return func(ppu, std::forward<Args>(args)...);
|
return func(ppu, args...);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CALL_FUNC(ppu, func, ...) ppu_execute_function_or_callback<decltype(&func), &func>(ppu, __VA_ARGS__)
|
#define REG_FNID(module, nid, func) ppu_module_manager::register_static_function<&func>(#module, ppu_select_name(#func, nid), BIND_FUNC(func, ppu.cia = (u32)ppu.lr & ~3), ppu_generate_id(nid))
|
||||||
|
|
||||||
#define REG_FNID(module, nid, func) ppu_module_manager::register_static_function<decltype(&func), &func>(#module, ppu_select_name(#func, nid), BIND_FUNC(func, ppu.cia = (u32)ppu.lr & ~3), ppu_generate_id(nid))
|
|
||||||
|
|
||||||
#define REG_FUNC(module, func) REG_FNID(module, #func, func)
|
#define REG_FUNC(module, func) REG_FNID(module, #func, func)
|
||||||
|
|
||||||
#define REG_VNID(module, nid, var) ppu_module_manager::register_static_variable<decltype(var), &var>(#module, ppu_select_name(#var, nid), ppu_generate_id(nid))
|
#define REG_VNID(module, nid, var) ppu_module_manager::register_static_variable<&var>(#module, ppu_select_name(#var, nid), ppu_generate_id(nid))
|
||||||
|
|
||||||
#define REG_VAR(module, var) REG_VNID(module, #var, var)
|
#define REG_VAR(module, var) REG_VNID(module, #var, var)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user