Multiple smaller HLE improvements

This commit is contained in:
Exzap 2024-12-07 09:23:11 +01:00
parent e2d0871ca3
commit 356cf0e5e0
6 changed files with 28 additions and 11 deletions

View File

@ -116,7 +116,7 @@ typedef struct
/* +0x34 */ uint32be ukn34; /* +0x34 */ uint32be ukn34;
/* +0x38 */ uint32be ukn38; /* +0x38 */ uint32be ukn38;
/* +0x3C */ uint32be ukn3C; /* +0x3C */ uint32be ukn3C;
/* +0x40 */ uint32be toolkitVersion; /* +0x40 */ uint32be minimumToolkitVersion;
/* +0x44 */ uint32be ukn44; /* +0x44 */ uint32be ukn44;
/* +0x48 */ uint32be ukn48; /* +0x48 */ uint32be ukn48;
/* +0x4C */ uint32be ukn4C; /* +0x4C */ uint32be ukn4C;

View File

@ -156,12 +156,22 @@ namespace coreinit
return &currentThread->crt.eh_mem_manage; return &currentThread->crt.eh_mem_manage;
} }
void* __gh_errno_ptr() sint32be* __gh_errno_ptr()
{ {
OSThread_t* currentThread = coreinit::OSGetCurrentThread(); OSThread_t* currentThread = coreinit::OSGetCurrentThread();
return &currentThread->context.ghs_errno; return &currentThread->context.ghs_errno;
} }
void __gh_set_errno(sint32 errNo)
{
*__gh_errno_ptr() = errNo;
}
sint32 __gh_get_errno()
{
return *__gh_errno_ptr();
}
void* __get_eh_store_globals() void* __get_eh_store_globals()
{ {
OSThread_t* currentThread = coreinit::OSGetCurrentThread(); OSThread_t* currentThread = coreinit::OSGetCurrentThread();
@ -272,6 +282,8 @@ namespace coreinit
cafeExportRegister("coreinit", __get_eh_globals, LogType::Placeholder); cafeExportRegister("coreinit", __get_eh_globals, LogType::Placeholder);
cafeExportRegister("coreinit", __get_eh_mem_manage, LogType::Placeholder); cafeExportRegister("coreinit", __get_eh_mem_manage, LogType::Placeholder);
cafeExportRegister("coreinit", __gh_errno_ptr, LogType::Placeholder); cafeExportRegister("coreinit", __gh_errno_ptr, LogType::Placeholder);
cafeExportRegister("coreinit", __gh_set_errno, LogType::Placeholder);
cafeExportRegister("coreinit", __gh_get_errno, LogType::Placeholder);
cafeExportRegister("coreinit", __get_eh_store_globals, LogType::Placeholder); cafeExportRegister("coreinit", __get_eh_store_globals, LogType::Placeholder);
cafeExportRegister("coreinit", __get_eh_store_globals_tdeh, LogType::Placeholder); cafeExportRegister("coreinit", __get_eh_store_globals_tdeh, LogType::Placeholder);

View File

@ -4,5 +4,9 @@ namespace coreinit
{ {
void PrepareGHSRuntime(); void PrepareGHSRuntime();
sint32be* __gh_errno_ptr();
void __gh_set_errno(sint32 errNo);
sint32 __gh_get_errno();
void InitializeGHS(); void InitializeGHS();
}; };

View File

@ -38,7 +38,7 @@ struct OSContext_t
/* +0x1E0 */ uint64be fp_ps1[32]; /* +0x1E0 */ uint64be fp_ps1[32];
/* +0x2E0 */ uint64be coretime[3]; /* +0x2E0 */ uint64be coretime[3];
/* +0x2F8 */ uint64be starttime; /* +0x2F8 */ uint64be starttime;
/* +0x300 */ uint32be ghs_errno; // returned by __gh_errno_ptr() (used by socketlasterr) /* +0x300 */ sint32be ghs_errno; // returned by __gh_errno_ptr() (used by socketlasterr)
/* +0x304 */ uint32be affinity; /* +0x304 */ uint32be affinity;
/* +0x308 */ uint32be upmc1; /* +0x308 */ uint32be upmc1;
/* +0x30C */ uint32be upmc2; /* +0x30C */ uint32be upmc2;

View File

@ -87,6 +87,11 @@ namespace GX2
return true; return true;
} }
void GX2RSetBufferName(GX2RBuffer* buffer, const char* name)
{
// no-op in production builds
}
void* GX2RLockBufferEx(GX2RBuffer* buffer, uint32 resFlags) void* GX2RLockBufferEx(GX2RBuffer* buffer, uint32 resFlags)
{ {
return buffer->GetPtr(); return buffer->GetPtr();
@ -226,6 +231,7 @@ namespace GX2
cafeExportRegister("gx2", GX2RCreateBufferUserMemory, LogType::GX2); cafeExportRegister("gx2", GX2RCreateBufferUserMemory, LogType::GX2);
cafeExportRegister("gx2", GX2RDestroyBufferEx, LogType::GX2); cafeExportRegister("gx2", GX2RDestroyBufferEx, LogType::GX2);
cafeExportRegister("gx2", GX2RBufferExists, LogType::GX2); cafeExportRegister("gx2", GX2RBufferExists, LogType::GX2);
cafeExportRegister("gx2", GX2RSetBufferName, LogType::GX2);
cafeExportRegister("gx2", GX2RLockBufferEx, LogType::GX2); cafeExportRegister("gx2", GX2RLockBufferEx, LogType::GX2);
cafeExportRegister("gx2", GX2RUnlockBufferEx, LogType::GX2); cafeExportRegister("gx2", GX2RUnlockBufferEx, LogType::GX2);
cafeExportRegister("gx2", GX2RInvalidateBuffer, LogType::GX2); cafeExportRegister("gx2", GX2RInvalidateBuffer, LogType::GX2);

View File

@ -3,6 +3,7 @@
#include "Cafe/OS/libs/coreinit/coreinit_Thread.h" #include "Cafe/OS/libs/coreinit/coreinit_Thread.h"
#include "Cafe/IOSU/legacy/iosu_crypto.h" #include "Cafe/IOSU/legacy/iosu_crypto.h"
#include "Cafe/OS/libs/coreinit/coreinit_Time.h" #include "Cafe/OS/libs/coreinit/coreinit_Time.h"
#include "Cafe/OS/libs/coreinit/coreinit_GHS.h"
#include "Common/socket.h" #include "Common/socket.h"
@ -117,20 +118,14 @@ void nsysnetExport_socket_lib_finish(PPCInterpreter_t* hCPU)
osLib_returnFromFunction(hCPU, 0); // 0 -> Success osLib_returnFromFunction(hCPU, 0); // 0 -> Success
} }
static uint32be* __gh_errno_ptr()
{
OSThread_t* osThread = coreinit::OSGetCurrentThread();
return &osThread->context.ghs_errno;
}
void _setSockError(sint32 errCode) void _setSockError(sint32 errCode)
{ {
*(uint32be*)__gh_errno_ptr() = (uint32)errCode; coreinit::__gh_set_errno(errCode);
} }
sint32 _getSockError() sint32 _getSockError()
{ {
return (sint32)*(uint32be*)__gh_errno_ptr(); return coreinit::__gh_get_errno();
} }
// error translation modes for _translateError // error translation modes for _translateError