From 26547e2629395732ddf8fdaf361aa66332a6a61a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 20 Jan 2025 00:04:00 +0100 Subject: [PATCH] More fixes --- Core/HLE/sceIo.cpp | 5 +++-- Core/HLE/sceKernelInterrupt.cpp | 4 +++- Core/HLE/sceKernelModule.cpp | 12 +++++++----- Core/HLE/sceKernelThread.cpp | 5 ++--- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/Core/HLE/sceIo.cpp b/Core/HLE/sceIo.cpp index 46790ccbf0..2e07a2f254 100644 --- a/Core/HLE/sceIo.cpp +++ b/Core/HLE/sceIo.cpp @@ -2189,8 +2189,9 @@ static u32 sceIoOpenAsync(const char *filename, int flags, int mode) { // TODO: Use an internal method so as not to pollute the log? // Intentionally does not work when interrupts disabled. - if (!__KernelIsDispatchEnabled()) - sceKernelResumeDispatchThread(1); + if (!__KernelIsDispatchEnabled()) { + hleCall(ThreadManForUser, u32, sceKernelResumeDispatchThread, 1); + } int error; FileNode *f = __IoOpen(error, filename, flags, mode); diff --git a/Core/HLE/sceKernelInterrupt.cpp b/Core/HLE/sceKernelInterrupt.cpp index 5a882a752f..352e59ab12 100644 --- a/Core/HLE/sceKernelInterrupt.cpp +++ b/Core/HLE/sceKernelInterrupt.cpp @@ -91,7 +91,7 @@ static int sceKernelCpuSuspendIntr() returnValue = 0; } hleEatCycles(15); - return returnValue; + return hleNoLog(returnValue); } static void sceKernelCpuResumeIntr(u32 enable) @@ -108,6 +108,7 @@ static void sceKernelCpuResumeIntr(u32 enable) __DisableInterrupts(); } hleEatCycles(15); + hleNoLogVoid(); } static int sceKernelIsCpuIntrEnable() { @@ -123,6 +124,7 @@ static int sceKernelIsCpuIntrSuspended(int flag) static void sceKernelCpuResumeIntrWithSync(u32 enable) { + // Just a forward, don't bother with hleCall. sceKernelCpuResumeIntr(enable); } diff --git a/Core/HLE/sceKernelModule.cpp b/Core/HLE/sceKernelModule.cpp index 19f2ca2073..c634316109 100644 --- a/Core/HLE/sceKernelModule.cpp +++ b/Core/HLE/sceKernelModule.cpp @@ -2409,7 +2409,7 @@ u32 __KernelStopUnloadSelfModuleWithOrWithoutStatus(u32 exitCode, u32 argSize, u INFO_LOG(Log::sceModule, "sceKernelStopUnloadSelfModuleWithStatus(%08x, %08x, %08x, %08x, %08x): no stop func", exitCode, argSize, argp, statusAddr, optionAddr); else INFO_LOG(Log::sceModule, "sceKernelSelfStopUnloadModule(%08x, %08x, %08x): no stop func", exitCode, argSize, argp); - sceKernelExitDeleteThread(exitCode); + hleCall(ThreadManForKernel, int, sceKernelExitDeleteThread, exitCode); module->Cleanup(); kernelObjects.Destroy(moduleID); } else { @@ -2417,7 +2417,7 @@ u32 __KernelStopUnloadSelfModuleWithOrWithoutStatus(u32 exitCode, u32 argSize, u ERROR_LOG_REPORT(Log::sceModule, "sceKernelStopUnloadSelfModuleWithStatus(%08x, %08x, %08x, %08x, %08x): bad stop func address", exitCode, argSize, argp, statusAddr, optionAddr); else ERROR_LOG_REPORT(Log::sceModule, "sceKernelSelfStopUnloadModule(%08x, %08x, %08x): bad stop func address", exitCode, argSize, argp); - sceKernelExitDeleteThread(exitCode); + hleCall(ThreadManForKernel, int, sceKernelExitDeleteThread, exitCode); module->Cleanup(); kernelObjects.Destroy(moduleID); } @@ -2428,7 +2428,7 @@ u32 __KernelStopUnloadSelfModuleWithOrWithoutStatus(u32 exitCode, u32 argSize, u ERROR_LOG_REPORT(Log::sceModule, "UNIMPL sceKernelSelfStopUnloadModule(%08x, %08x, %08x): game has likely crashed", exitCode, argSize, argp); } - return 0; + return hleNoLog(0); } static u32 sceKernelSelfStopUnloadModule(u32 exitCode, u32 argSize, u32 argp) { @@ -2452,12 +2452,13 @@ void __KernelReturnFromModuleFunc() // Reschedule immediately (to leave the thread) and delete it and its stack. __KernelReSchedule("returned from module"); - sceKernelDeleteThread(leftThreadID); + hleCall(ThreadManForKernel, int, sceKernelDeleteThread, leftThreadID); u32 error; PSPModule *module = kernelObjects.Get(leftModuleID, error); if (!module) { ERROR_LOG_REPORT(Log::sceModule, "Returned from deleted module start/stop func"); + hleNoLogVoid(); return; } @@ -2472,7 +2473,7 @@ void __KernelReturnFromModuleFunc() { if (module->nm.status == MODULE_STATUS_UNLOADING) { // TODO: Maybe should maintain the exitCode? - sceKernelTerminateDeleteThread(it->threadID); + hleCall(ThreadManForKernel, int, sceKernelTerminateDeleteThread, it->threadID); } else { if (it->statusPtr != 0) Memory::Write_U32(exitStatus, it->statusPtr); @@ -2487,6 +2488,7 @@ void __KernelReturnFromModuleFunc() module->Cleanup(); kernelObjects.Destroy(leftModuleID); } + hleNoLogVoid(); } struct GetModuleIdByAddressArg diff --git a/Core/HLE/sceKernelThread.cpp b/Core/HLE/sceKernelThread.cpp index c37b4a15ad..6814a29718 100644 --- a/Core/HLE/sceKernelThread.cpp +++ b/Core/HLE/sceKernelThread.cpp @@ -2202,8 +2202,7 @@ int sceKernelExitDeleteThread(int exitStatus) { if (!__KernelIsDispatchEnabled() && sceKernelGetCompiledSdkVersion() >= 0x03080000) return hleLogError(Log::sceKernel, SCE_KERNEL_ERROR_CAN_NOT_WAIT); PSPThread *thread = __GetCurrentThread(); - if (thread) - { + if (thread) { INFO_LOG(Log::sceKernel,"sceKernelExitDeleteThread(%d)", exitStatus); uint32_t thread_attr = thread->nt.attr; uint32_t uid = thread->GetUID(); @@ -2218,7 +2217,7 @@ int sceKernelExitDeleteThread(int exitStatus) { } else ERROR_LOG_REPORT(Log::sceKernel, "sceKernelExitDeleteThread(%d) ERROR - could not find myself!", exitStatus); - return 0; + return hleNoLog(0); } u32 sceKernelSuspendDispatchThread()