This commit is contained in:
Henrik Rydgård
2025-01-20 12:20:21 +01:00
parent 26547e2629
commit 16dcb9ee8a
5 changed files with 28 additions and 13 deletions
+20 -9
View File
@@ -2093,19 +2093,29 @@ int __KernelStartThread(SceUID threadToStartID, int argSize, u32 argBlockPtr, bo
return 0;
}
// This gets called from other places, so we don't use the hleLog* here.
int __KernelStartThreadValidate(SceUID threadToStartID, int argSize, u32 argBlockPtr, bool forceArgs) {
if (threadToStartID == 0)
return hleLogError(Log::sceKernel, SCE_KERNEL_ERROR_ILLEGAL_THID, "thread id is 0");
if (argSize < 0 || argBlockPtr & 0x80000000)
return hleReportError(Log::sceKernel, SCE_KERNEL_ERROR_ILLEGAL_ADDR, "bad thread argument pointer/length %08x / %08x", argSize, argBlockPtr);
if (threadToStartID == 0) {
ERROR_LOG(Log::sceKernel, "thread id is 0");
return SCE_KERNEL_ERROR_ILLEGAL_THID;
}
if (argSize < 0 || argBlockPtr & 0x80000000) {
ERROR_LOG(Log::sceKernel, "bad thread argument pointer/length %08x / %08x", argSize, argBlockPtr);
return SCE_KERNEL_ERROR_ILLEGAL_ADDR;
}
u32 error = 0;
PSPThread *startThread = kernelObjects.Get<PSPThread>(threadToStartID, error);
if (startThread == 0)
return hleLogError(Log::sceKernel, error, "thread does not exist");
if (startThread == 0) {
ERROR_LOG(Log::sceKernel, "thread does not exist: %08x", error);
return error;
}
if (startThread->nt.status != THREADSTATUS_DORMANT)
return hleLogWarning(Log::sceKernel, SCE_KERNEL_ERROR_NOT_DORMANT, "thread already running");
if (startThread->nt.status != THREADSTATUS_DORMANT) {
WARN_LOG(Log::sceKernel, "thread already running");
return SCE_KERNEL_ERROR_NOT_DORMANT;
}
hleEatCycles(3400);
return __KernelStartThread(threadToStartID, argSize, argBlockPtr, forceArgs);
@@ -2113,7 +2123,8 @@ int __KernelStartThreadValidate(SceUID threadToStartID, int argSize, u32 argBloc
// int sceKernelStartThread(SceUID threadToStartID, SceSize argSize, void *argBlock)
int sceKernelStartThread(SceUID threadToStartID, int argSize, u32 argBlockPtr) {
return hleLogSuccessInfoI(Log::sceKernel, __KernelStartThreadValidate(threadToStartID, argSize, argBlockPtr));
int retval = __KernelStartThreadValidate(threadToStartID, argSize, argBlockPtr);
return hleLogSuccessOrError(Log::sceKernel, retval);
}
int sceKernelGetThreadStackFreeSize(SceUID threadID)