mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-06-06 10:43:16 +00:00
core: Add wrapper for calling into guest code. (#967)
This commit is contained in:
parent
ad9f1370d5
commit
4ba19a02b0
8 changed files with 57 additions and 35 deletions
|
@ -98,7 +98,6 @@ public:
|
|||
}
|
||||
|
||||
void* TlsGetAddr(u64 module_index, u64 offset);
|
||||
void InitTlsForThread(bool is_primary = false);
|
||||
|
||||
s32 LoadModule(const std::filesystem::path& elf_name, bool is_dynamic = false);
|
||||
Module* FindByAddress(VAddr address);
|
||||
|
@ -109,8 +108,17 @@ public:
|
|||
void Execute();
|
||||
void DebugDump();
|
||||
|
||||
template <class ReturnType, class... FuncArgs, class... CallArgs>
|
||||
ReturnType ExecuteGuest(PS4_SYSV_ABI ReturnType (*func)(FuncArgs...), CallArgs&&... args) {
|
||||
// Make sure TLS is initialized for the thread before entering guest.
|
||||
EnsureThreadInitialized();
|
||||
return func(std::forward<CallArgs>(args)...);
|
||||
}
|
||||
|
||||
private:
|
||||
const Module* FindExportedModule(const ModuleInfo& m, const LibraryInfo& l);
|
||||
void EnsureThreadInitialized(bool is_primary = false);
|
||||
void InitTlsForThread(bool is_primary);
|
||||
|
||||
MemoryManager* memory;
|
||||
std::mutex mutex;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue