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

+7 -7
View File
@@ -195,7 +195,7 @@ int PSPNetconfDialog::Update(int animSpeed) {
} else if (state == PSP_NET_APCTL_STATE_DISCONNECTED) {
// When connecting with infrastructure, simulate a connection using the first network configuration entry.
if (connResult < 0) {
connResult = hleCall(sceNetApctl, int, sceNetApctlConnect, 1);
connResult = hleCall(sceNetApctl, int, sceNetApctlConnect, currentMIPS, 1);
}
}
@@ -248,13 +248,13 @@ int PSPNetconfDialog::Update(int animSpeed) {
{
case NETCONF_CREATE_ADHOC:
if (connResult < 0) {
connResult = hleCall(sceNetAdhocctl, int, sceNetAdhocctlCreate, request.NetconfData->groupName);
connResult = hleCall(sceNetAdhocctl, int, sceNetAdhocctlCreate, currentMIPS, request.NetconfData->groupName);
}
break;
case NETCONF_JOIN_ADHOC:
// FIXME: Should we Scan for a matching group first before Joining a Group (like adhoc games normally do)? Or Is it really allowed to join non-existing group?
if (scanStep == 0) {
if (hleCall(sceNetAdhocctl, int, sceNetAdhocctlScan) >= 0) {
if (hleCall(sceNetAdhocctl, int, sceNetAdhocctlScan, currentMIPS) >= 0) {
u32 structsz = sizeof(ScanInfos);
if (Memory::IsValidAddress(scanInfosAddr))
userMemory.Free(scanInfosAddr);
@@ -267,7 +267,7 @@ int PSPNetconfDialog::Update(int animSpeed) {
else if (scanStep == 1) {
s32 sz = Memory::ReadOrException_U32(scanInfosAddr);
// Get required buffer size
if (hleCall(sceNetAdhocctl, int, sceNetAdhocctlGetScanInfo, scanInfosAddr, 0) >= 0) {
if (hleCall(sceNetAdhocctl, int, sceNetAdhocctlGetScanInfo, currentMIPS, scanInfosAddr, 0) >= 0) {
s32 reqsz = Memory::ReadOrException_U32(scanInfosAddr);
if (reqsz > sz) {
sz = reqsz;
@@ -278,7 +278,7 @@ int PSPNetconfDialog::Update(int animSpeed) {
Memory::WriteOrException_U32(sz, scanInfosAddr);
}
if (reqsz > 0) {
if (hleCall(sceNetAdhocctl, int, sceNetAdhocctlGetScanInfo, scanInfosAddr, scanInfosAddr + (u32)sizeof(s32)) >= 0) {
if (hleCall(sceNetAdhocctl, int, sceNetAdhocctlGetScanInfo, currentMIPS, scanInfosAddr, scanInfosAddr + (u32)sizeof(s32)) >= 0) {
ScanInfos* scanInfos = (ScanInfos*)Memory::GetPointerOrException(scanInfosAddr);
int n = scanInfos->sz / sizeof(SceNetAdhocctlScanInfoEmu);
// Assuming returned SceNetAdhocctlScanInfoEmu(s) are contiguous where next is pointing to current addr + sizeof(SceNetAdhocctlScanInfoEmu)
@@ -306,7 +306,7 @@ int PSPNetconfDialog::Update(int animSpeed) {
}
else if (scanStep == 2) {
if (connResult < 0) {
connResult = hleCall(sceNetAdhocctl, int, sceNetAdhocctlJoin, scanInfosAddr + (u32)sizeof(s32));
connResult = hleCall(sceNetAdhocctl, int, sceNetAdhocctlJoin, currentMIPS, scanInfosAddr + (u32)sizeof(s32));
if (connResult >= 0) {
// We are done!
if (Memory::IsValidAddress(scanInfosAddr))
@@ -318,7 +318,7 @@ int PSPNetconfDialog::Update(int animSpeed) {
break;
default:
if (connResult < 0) {
connResult = hleCall(sceNetAdhocctl, int, sceNetAdhocctlConnect, request.NetconfData->groupName);
connResult = hleCall(sceNetAdhocctl, int, sceNetAdhocctlConnect, currentMIPS, request.NetconfData->groupName);
}
break;
}