Fix sceKernelExitThread

fix #13297 fix #9523
According from
https://github.com/jpcsp/jpcsp/blob/master/src/jpcsp/HLE/modules/ThreadManForUser.java#L3924
This commit is contained in:
sum2012
2020-08-17 23:16:15 +08:00
parent ea376ef886
commit df1f126715
3 changed files with 14 additions and 4 deletions
+2 -2
View File
@@ -744,7 +744,7 @@ const HLEFunction ThreadManForUser[] =
{0X1181E963, &WrapI_U<sceKernelDelaySysClockThreadCB>, "sceKernelDelaySysClockThreadCB", 'i', "P", HLE_NOT_IN_INTERRUPT | HLE_NOT_DISPATCH_SUSPENDED },
{0XCEADEB47, &WrapI_U<sceKernelDelayThread>, "sceKernelDelayThread", 'i', "x", HLE_NOT_IN_INTERRUPT | HLE_NOT_DISPATCH_SUSPENDED },
{0X68DA9E36, &WrapI_U<sceKernelDelayThreadCB>, "sceKernelDelayThreadCB", 'i', "x", HLE_NOT_IN_INTERRUPT | HLE_NOT_DISPATCH_SUSPENDED },
{0XAA73C935, &WrapV_I<sceKernelExitThread>, "sceKernelExitThread", 'v', "i" },
{0XAA73C935, &WrapI_I<sceKernelExitThread>, "sceKernelExitThread", 'i', "i" },
{0X809CE29B, &WrapV_I<sceKernelExitDeleteThread>, "sceKernelExitDeleteThread", 'v', "i" },
{0x94aa61ee, &WrapI_V<sceKernelGetThreadCurrentPriority>, "sceKernelGetThreadCurrentPriority", 'i', "" },
{0X293B45B8, &WrapI_V<sceKernelGetThreadId>, "sceKernelGetThreadId", 'i', "", HLE_NOT_IN_INTERRUPT },
@@ -887,7 +887,7 @@ const HLEFunction ThreadManForKernel[] =
{0x446D8DE6, &WrapI_CUUIUU<sceKernelCreateThread>, "sceKernelCreateThread", 'i', "sxxixx", HLE_NOT_IN_INTERRUPT | HLE_KERNEL_SYSCALL },
{0xF475845D, &WrapI_IIU<sceKernelStartThread>, "sceKernelStartThread", 'i', "iix", HLE_NOT_IN_INTERRUPT | HLE_KERNEL_SYSCALL },
{0X9FA03CD3, &WrapI_I<sceKernelDeleteThread>, "sceKernelDeleteThread", 'i', "i", HLE_KERNEL_SYSCALL },
{0XAA73C935, &WrapV_I<sceKernelExitThread>, "sceKernelExitThread", 'v', "i", HLE_KERNEL_SYSCALL },
{0XAA73C935, &WrapI_I<sceKernelExitThread>, "sceKernelExitThread", 'i', "i", HLE_KERNEL_SYSCALL },
{0X809CE29B, &WrapV_I<sceKernelExitDeleteThread>, "sceKernelExitDeleteThread", 'v', "i", HLE_KERNEL_SYSCALL },
{0X9944F31F, &WrapI_I<sceKernelSuspendThread>, "sceKernelSuspendThread", 'i', "i", HLE_KERNEL_SYSCALL },
{0X75156E8F, &WrapI_I<sceKernelResumeThread>, "sceKernelResumeThread", 'i', "i", HLE_KERNEL_SYSCALL },
+9 -1
View File
@@ -49,6 +49,8 @@
#include "Core/HLE/KernelWaitHelpers.h"
#include "Core/HLE/ThreadQueueList.h"
typedef struct
{
WaitType type;
@@ -2148,11 +2150,16 @@ void __KernelReturnFromThread()
// The stack will be deallocated when the thread is deleted.
}
void sceKernelExitThread(int exitStatus) {
int sceKernelExitThread(int exitStatus) {
if (!__KernelIsDispatchEnabled() && sceKernelGetCompiledSdkVersion() > 0x0307FFFF)
return ERROR_KERNEL_WAIT_CAN_NOT_WAIT;
PSPThread *thread = __GetCurrentThread();
_dbg_assert_msg_(thread != NULL, "Exited from a NULL thread.");
INFO_LOG(SCEKERNEL, "sceKernelExitThread(%d)", exitStatus);
if (exitStatus < 0) {
exitStatus = ERROR_KERNEL_ILLEGAL_ARGUMENT;
}
__KernelStopThread(currentThread, exitStatus, "thread exited");
hleReSchedule("thread exited");
@@ -2161,6 +2168,7 @@ void sceKernelExitThread(int exitStatus) {
__KernelThreadTriggerEvent((thread->nt.attr & PSP_THREAD_ATTR_KERNEL) != 0, thread->GetUID(), THREADEVENT_EXIT);
// The stack will be deallocated when the thread is deleted.
return 0;
}
void _sceKernelExitThread(int exitStatus) {
+3 -1
View File
@@ -41,7 +41,7 @@ void __KernelStopThread(SceUID threadID, int exitStatus, const char *reason);
u32 __KernelDeleteThread(SceUID threadID, int exitStatus, const char *reason);
int sceKernelDeleteThread(int threadHandle);
void sceKernelExitDeleteThread(int exitStatus);
void sceKernelExitThread(int exitStatus);
int sceKernelExitThread(int exitStatus);
void _sceKernelExitThread(int exitStatus);
SceUID sceKernelGetThreadId();
int sceKernelGetThreadCurrentPriority();
@@ -77,6 +77,8 @@ struct SceKernelSysClock {
u32_le hi;
};
static const int ERROR_KERNEL_WAIT_CAN_NOT_WAIT = 0x800201a7;
static const int ERROR_KERNEL_ILLEGAL_ARGUMENT = 0x800200d2;
// TODO: Map these to PSP wait types. Most of these are wrong.
// remember to update the waitTypeNames array in sceKernelThread.cpp when changing these