HLE: Pass the MIPSState to syscalls and their implementations

HLEFunc and ReplaceFunc now take the MIPSState they run on. The dispatch
paths (both interpreters and every JIT backend) pass in the state they
belong to, and CallSyscall*, hleFinishSyscall and the HLE mips call
machinery use it instead of currentMIPS.

The wrappers in FunctionWrappers.h take the function as `auto` and call it
through HLECall, which also accepts an implementation with an extra leading
MIPSState * parameter and passes the state to it. Any other signature still
fails to compile, as before. PARAM/RETURN now refer to a local `mips`.

The HLE functions (and replacement functions) that used currentMIPS now take
the state that way. Callers outside a syscall's own frame - CoreTiming
events, the adhoc matching thread, dialogs, PPGe, the debugger UIs - pass
currentMIPS or &mipsr4k explicitly. The kernel's thread internals still use
currentMIPS.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Henrik RydgårdandClaude Opus 5.5 committed 2026-10-20 15:45:14 +02:00
1 parent 394c05f414
commit 7dd1475ed7
52 files changed
+1138 -1083

No files matched your search

+9 -9
View File
@@ -451,9 +451,9 @@ int __CancelRaisedInterrupts(PSPInterrupt intno) {
return count;
}
void __KernelReturnFromInterrupt()
void __KernelReturnFromInterrupt(MIPSState *mips)
{
VERBOSE_LOG(Log::sceIntc, "Left interrupt handler at %08x", currentMIPS->pc);
VERBOSE_LOG(Log::sceIntc, "Left interrupt handler at %08x", mips->pc);
hleSkipDeadbeef();
@@ -469,7 +469,7 @@ void __KernelReturnFromInterrupt()
moreOfThis = moreOfThis || other.intr == pend.intr;
}
if (!moreOfThis) {
currentMIPS->downcount -= intrHandlers[pend.intr]->exitCycles();
mips->downcount -= intrHandlers[pend.intr]->exitCycles();
}
} else {
_assert_msg_(false, "Bad pend.intr: %d", pend.intr);
@@ -854,9 +854,9 @@ static int sysclib_memcmp(u32 dst, u32 src, u32 size) {
}
}
static int sysclib_sprintf_impl(u32 dst, int limit, u32 fmt, int firstVarArg) {
static int sysclib_sprintf_impl(MIPSState *mips, u32 dst, int limit, u32 fmt, int firstVarArg) {
std::string result;
if (!HLEFormatPrintf(fmt, firstVarArg, &result)) {
if (!HLEFormatPrintf(mips, fmt, firstVarArg, &result)) {
return 0;
}
@@ -879,15 +879,15 @@ static int sysclib_sprintf_impl(u32 dst, int limit, u32 fmt, int firstVarArg) {
return (int)retval;
}
static int sysclib_sprintf(u32 dst, u32 fmt) {
static int sysclib_sprintf(MIPSState *mips, u32 dst, u32 fmt) {
DEBUG_LOG(Log::sceKernel, "Not fully implemented: sysclib_sprintf(dst=%08x, fmt=%08x)", dst, fmt);
// dst is a0 and fmt a1, so the varargs start at a2.
return hleLogDebug(Log::sceKernel, sysclib_sprintf_impl(dst, 0, fmt, 2));
return hleLogDebug(Log::sceKernel, sysclib_sprintf_impl(mips, dst, 0, fmt, 2));
}
static int sysclib_snprintf(u32 dst, int size, u32 fmt) {
static int sysclib_snprintf(MIPSState *mips, u32 dst, int size, u32 fmt) {
DEBUG_LOG(Log::sceKernel, "Not fully implemented: sysclib_snprintf(dst=%08x, fmt=%08x)", dst, fmt);
return hleLogDebug(Log::sceKernel, sysclib_sprintf_impl(dst, size, fmt, 3));
return hleLogDebug(Log::sceKernel, sysclib_sprintf_impl(mips, dst, size, fmt, 3));
}
static u32 sysclib_memset(u32 destAddr, int data, int size) {