mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-19 01:10:39 +02:00
HLE: Correct helper thread arg handling.
This commit is contained in:
1 parent
aa13f5afb7
commit
fa320599dc
3 files changed
+12
-10
No files matched your search
@@ -2025,22 +2025,24 @@ int __KernelStartThread(SceUID threadToStartID, int argSize, u32 argBlockPtr, bo
|
||||
u32 &sp = startThread->context.r[MIPS_REG_SP];
|
||||
// Force args means just use those as a0/a1 without any special treatment.
|
||||
// This is a hack to avoid allocating memory for helper threads which take args.
|
||||
if ((argBlockPtr && argSize > 0) || forceArgs) {
|
||||
if (forceArgs) {
|
||||
startThread->context.r[MIPS_REG_A0] = argSize;
|
||||
startThread->context.r[MIPS_REG_A1] = argBlockPtr;
|
||||
} else if (argBlockPtr && argSize > 0) {
|
||||
// Make room for the arguments, always 0x10 aligned.
|
||||
if (!forceArgs)
|
||||
sp -= (argSize + 0xf) & ~0xf;
|
||||
sp -= (argSize + 0xf) & ~0xf;
|
||||
startThread->context.r[MIPS_REG_A0] = argSize;
|
||||
startThread->context.r[MIPS_REG_A1] = sp;
|
||||
|
||||
// Now copy argument to stack.
|
||||
if (Memory::IsValidAddress(argBlockPtr)) {
|
||||
Memory::Memcpy(sp, argBlockPtr, argSize, "ThreadStartArgs");
|
||||
}
|
||||
} else {
|
||||
startThread->context.r[MIPS_REG_A0] = 0;
|
||||
startThread->context.r[MIPS_REG_A1] = 0;
|
||||
}
|
||||
|
||||
// Now copy argument to stack.
|
||||
if (!forceArgs && Memory::IsValidAddress(argBlockPtr)) {
|
||||
Memory::Memcpy(sp, argBlockPtr, argSize, "ThreadStartArgs");
|
||||
}
|
||||
|
||||
// On the PSP, there's an extra 64 bytes of stack eaten after the args.
|
||||
// This could be stack overflow safety, or just stack eaten by the kernel entry func.
|
||||
sp -= 64;
|
||||
|
||||
Reference in new issue
Block a user