mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-14 10:09:32 +01:00
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:
1 parent
394c05f414
commit
7dd1475ed7
52 files changed
+1138
-1083
No files matched your search
+16
-16
@@ -1002,7 +1002,7 @@ Parameters:
|
||||
netintrprio - Priority of the SceNetNetintr thread.
|
||||
netintrstack - Stack size of the SceNetNetintr thread (defaults to 4096 on non 1.5 firmware regardless of what value is passed).
|
||||
*/
|
||||
static int sceNetInit(u32 poolSize, u32 calloutPri, u32 calloutStack, u32 netinitPri, u32 netinitStack) {
|
||||
static int sceNetInit(MIPSState *mips, u32 poolSize, u32 calloutPri, u32 calloutStack, u32 netinitPri, u32 netinitStack) {
|
||||
// TODO: Create Network Threads using given priority & stack
|
||||
// TODO: The correct behavior is actually to allocate more and leak the other threads/pool.
|
||||
// But we reset here for historic reasons (GTA:VCS potentially triggers this.)
|
||||
@@ -1040,7 +1040,7 @@ static int sceNetInit(u32 poolSize, u32 calloutPri, u32 calloutStack, u32 netini
|
||||
return hleLogError(Log::sceNet, SCE_KERNEL_ERROR_NO_MEMORY, "unable to allocate pool");
|
||||
}
|
||||
|
||||
INFO_LOG(Log::sceNet, "sceNetInit(poolsize=%d, calloutpri=%i, calloutstack=%d, netintrpri=%i, netintrstack=%d) at %08x", poolSize, calloutPri, calloutStack, netinitPri, netinitStack, currentMIPS->pc);
|
||||
INFO_LOG(Log::sceNet, "sceNetInit(poolsize=%d, calloutpri=%i, calloutstack=%d, netintrpri=%i, netintrstack=%d) at %08x", poolSize, calloutPri, calloutStack, netinitPri, netinitStack, mips->pc);
|
||||
|
||||
netMallocStat.pool = poolSize - 0x20; // On Vantage Master Portable this is slightly (32 bytes) smaller than the poolSize arg when tested with JPCSP + prx files
|
||||
netMallocStat.maximum = 0x4050; // Dummy maximum foot print
|
||||
@@ -1107,8 +1107,8 @@ static u32 sceWlanGetSwitchState() {
|
||||
}
|
||||
|
||||
// Probably a void function, but often returns a useful value.
|
||||
static void sceNetEtherNtostr(u32 macPtr, u32 bufferPtr) {
|
||||
DEBUG_LOG(Log::sceNet, "sceNetEtherNtostr(%08x, %08x) at %08x", macPtr, bufferPtr, currentMIPS->pc);
|
||||
static void sceNetEtherNtostr(MIPSState *mips, u32 macPtr, u32 bufferPtr) {
|
||||
DEBUG_LOG(Log::sceNet, "sceNetEtherNtostr(%08x, %08x) at %08x", macPtr, bufferPtr, mips->pc);
|
||||
|
||||
if (Memory::IsValidAddress(bufferPtr) && Memory::IsValidAddress(macPtr)) {
|
||||
char *buffer = (char *)Memory::GetPointerWriteUnchecked(bufferPtr);
|
||||
@@ -1240,7 +1240,7 @@ void NetApctl_InitInfo(int confId) {
|
||||
truncate_cpy(netApctlInfo.subNetMask, sizeof(netApctlInfo.subNetMask), "255.255.255.0");
|
||||
}
|
||||
|
||||
static int sceNetApctlInit(int stackSize, int initPriority) {
|
||||
static int sceNetApctlInit(MIPSState *mips, int stackSize, int initPriority) {
|
||||
if (g_netApctlInited) {
|
||||
return hleLogError(Log::sceNet, SCE_NET_APCTL_ERROR_ALREADY_INITIALIZED);
|
||||
}
|
||||
@@ -1275,7 +1275,7 @@ static int sceNetApctlInit(int stackSize, int initPriority) {
|
||||
|
||||
// Actually connect sceNetAdhocctl. TODO: Can we move this to sceNetApctlConnect? Would be good because a lot of games call Init but not Connect on startup.
|
||||
if (g_infraDNSConfig.connectAdHocForGrouping) {
|
||||
hleCall(sceNetAdhocctl, int, sceNetAdhocctlInit, stackSize, initPriority, apctlProdCodeAddr);
|
||||
hleCall(sceNetAdhocctl, int, sceNetAdhocctlInit, mips, stackSize, initPriority, apctlProdCodeAddr);
|
||||
}
|
||||
|
||||
g_netApctlInited = true;
|
||||
@@ -1316,8 +1316,8 @@ static int sceNetApctlTerm() {
|
||||
return hleLogInfo(Log::sceNet, retval);
|
||||
}
|
||||
|
||||
static int sceNetApctlGetInfo(int code, u32 pInfoAddr) {
|
||||
DEBUG_LOG(Log::sceNet, "sceNetApctlGetInfo(%i, %08x) at %08x", code, pInfoAddr, currentMIPS->pc);
|
||||
static int sceNetApctlGetInfo(MIPSState *mips, int code, u32 pInfoAddr) {
|
||||
DEBUG_LOG(Log::sceNet, "sceNetApctlGetInfo(%i, %08x) at %08x", code, pInfoAddr, mips->pc);
|
||||
|
||||
switch (code) {
|
||||
case PSP_NET_APCTL_INFO_PROFILE_NAME:
|
||||
@@ -1509,7 +1509,7 @@ static int sceNetApctlDelHandler(u32 handlerID) {
|
||||
return NetApctl_DelHandler(handlerID);
|
||||
}
|
||||
|
||||
int sceNetApctlConnect(int confId) {
|
||||
int sceNetApctlConnect(MIPSState *mips, int confId) {
|
||||
if (!g_Config.bEnableWlan)
|
||||
return hleLogError(Log::sceNet, SCE_NET_APCTL_ERROR_WLAN_SWITCH_OFF);
|
||||
|
||||
@@ -1522,7 +1522,7 @@ int sceNetApctlConnect(int confId) {
|
||||
// Note: We're borrowing AdhocServer for Grouping purpose, so we can simulate Broadcast over the internet just like Adhoc's pro-online implementation
|
||||
int ret = 0;
|
||||
if (g_infraDNSConfig.connectAdHocForGrouping) {
|
||||
ret = hleCall(sceNetAdhocctl, int, sceNetAdhocctlConnect, "INFRA");
|
||||
ret = hleCall(sceNetAdhocctl, int, sceNetAdhocctlConnect, mips, "INFRA");
|
||||
}
|
||||
|
||||
if (netApctlState == PSP_NET_APCTL_STATE_DISCONNECTED) {
|
||||
@@ -1722,8 +1722,8 @@ static int sceNetApctlGetBSSDescIDList2(u32 Arg1, u32 Arg2, u32 Arg3, u32 Arg4)
|
||||
* Arg2 = input field type within the entry desc (ie. PSP_NET_APCTL_DESC_SSID_NAME ?)
|
||||
* Arg3 = output buffer for retrieved entry data? (max size = 32 bytes? ie. APCTL_SSID_MAXLEN ? or similar to SceNetApctlInfoInternal union ?)
|
||||
***************/
|
||||
static int sceNetApctlGetBSSDescEntry2(int entryId, int infoId, u32 resultAddr) {
|
||||
WARN_LOG(Log::sceNet, "UNTESTED %s(%i, %i, %08x) at %08x", __FUNCTION__, entryId, infoId, resultAddr, currentMIPS->pc);
|
||||
static int sceNetApctlGetBSSDescEntry2(MIPSState *mips, int entryId, int infoId, u32 resultAddr) {
|
||||
WARN_LOG(Log::sceNet, "UNTESTED %s(%i, %i, %08x) at %08x", __FUNCTION__, entryId, infoId, resultAddr, mips->pc);
|
||||
return NetApctl_GetBSSDescEntryUser(entryId, infoId, resultAddr);
|
||||
}
|
||||
|
||||
@@ -1757,10 +1757,10 @@ static int sceNetApctl_lib2_69745F0A(int handlerId) {
|
||||
return hleLogError(Log::sceNet, 0, "unimplemented");
|
||||
}
|
||||
|
||||
static int sceNetApctl_lib2_4C19731F(int code, u32 pInfoAddr) {
|
||||
static int sceNetApctl_lib2_4C19731F(MIPSState *mips, int code, u32 pInfoAddr) {
|
||||
ERROR_LOG(Log::sceNet, "UNIMPL %s(%i, %08x)", __FUNCTION__, code, pInfoAddr);
|
||||
// Simple forward, don't need to use hleCall
|
||||
return sceNetApctlGetInfo(code, pInfoAddr);
|
||||
return sceNetApctlGetInfo(mips, code, pInfoAddr);
|
||||
}
|
||||
|
||||
static int sceNetApctlScan() {
|
||||
@@ -1777,10 +1777,10 @@ static int sceNetApctlGetBSSDescEntry(int entryId, int infoId, u32 resultAddr) {
|
||||
return sceNetApctlGetBSSDescEntryUser(entryId, infoId, resultAddr);
|
||||
}
|
||||
|
||||
static int sceNetApctl_lib2_C20A144C(int connIndex, u32 ps3MacAddressPtr) {
|
||||
static int sceNetApctl_lib2_C20A144C(MIPSState *mips, int connIndex, u32 ps3MacAddressPtr) {
|
||||
ERROR_LOG(Log::sceNet, "UNIMPL %s(%i, %08x)", __FUNCTION__, connIndex, ps3MacAddressPtr);
|
||||
// Simple forward, don't need to use hleCall
|
||||
return sceNetApctlConnect(connIndex);
|
||||
return sceNetApctlConnect(mips, connIndex);
|
||||
}
|
||||
|
||||
static int sceNetUpnpInit(int unknown1,int unknown2) {
|
||||
|
||||
Reference in new issue
Block a user