Patches/PPU: Implement HLE/LLE/With-TOC function call patches

Example patches:
  [ jumpf, 0x12340, "cellGcmSys:cellGcmSetFlip"] // Places a call to cellGcmSetFlip at 0x12340
  [ jumpf, 0x12340, "cellGcmSys:0xDC09357E"] // Same, using FNID
  [ jumpf, 0x12340, 0x2345678 ] # Function OPD based call eading OPD at 0x2345678
This commit is contained in:
Eladash 2021-09-06 10:33:44 +03:00 committed by Ivan
parent b217e8384c
commit 65c9cd99cd
9 changed files with 246 additions and 31 deletions

View file

@ -18,7 +18,7 @@ constexpr const char* ppu_select_name(const char* /*name*/, const char* orig_nam
}
// Generate FNID or VNID for given name
extern u32 ppu_generate_id(const char* name);
extern u32 ppu_generate_id(std::string_view name);
// Overload for REG_FNID, REG_VNID macro
constexpr u32 ppu_generate_id(u32 id)
@ -31,7 +31,7 @@ enum ppu_static_module_flags : u32
{
MFF_FORCED_HLE = (1 << 0), // Always call HLE function
MFF_PERFECT = (1 << 1), // Indicates complete implementation and LLE interchangeability
MFF_HIDDEN = (1 << 2), // Invisible function for internal use (TODO)
MFF_HIDDEN = (1 << 2), // Invisible variable for internal use (TODO)
};
// HLE function information
@ -293,7 +293,9 @@ inline RT ppu_execute(ppu_thread& ppu, Args... args)
return func(ppu, 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 = static_cast<u32>(ppu.lr) & ~3), ppu_generate_id(nid))
#define BIND_FUNC_WITH_BLR(func) BIND_FUNC(func, ppu.cia = static_cast<u32>(ppu.lr) & ~3)
#define REG_FNID(_module, nid, func) ppu_module_manager::register_static_function<&func>(#_module, ppu_select_name(#func, nid), BIND_FUNC_WITH_BLR(func), ppu_generate_id(nid))
#define REG_FUNC(_module, func) REG_FNID(_module, #func, func)
@ -301,6 +303,10 @@ inline RT ppu_execute(ppu_thread& ppu, Args... args)
#define REG_VAR(_module, var) REG_VNID(_module, #var, var)
#define REG_HIDDEN_FUNC(func) ppu_function_manager::register_function<decltype(&func), &func>(BIND_FUNC_WITH_BLR(func))
#define REG_HIDDEN_FUNC_PURE(func) ppu_function_manager::register_function<decltype(&func), &func>(func)
#define REINIT_FUNC(func) (ppu_module_manager::find_static_function<&func>().flags = 0, ppu_module_manager::find_static_function<&func>())
#define UNIMPLEMENTED_FUNC(_module) _module.todo("%s()", __func__)