From cdbc7176d87634717ebe37b4bc1ac4a28ee493d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 19 Jan 2025 11:38:46 +0100 Subject: [PATCH] Refactor logging in sceKernelStartModule --- Core/HLE/Plugins.cpp | 2 +- Core/HLE/sceKernelModule.cpp | 47 +++++++++++------------------------- Core/HLE/sceKernelModule.h | 2 +- 3 files changed, 16 insertions(+), 35 deletions(-) diff --git a/Core/HLE/Plugins.cpp b/Core/HLE/Plugins.cpp index acc57d48fa..2373596d65 100644 --- a/Core/HLE/Plugins.cpp +++ b/Core/HLE/Plugins.cpp @@ -190,7 +190,7 @@ bool Load() { continue; } - int ret = KernelStartModule(module, 0, 0, 0, nullptr, nullptr); + int ret = __KernelStartModule(module, 0, 0, 0, nullptr, nullptr); if (ret < 0) { ERROR_LOG(Log::System, "Unable to start plugin %s: %08x", filename.c_str(), ret); } else { diff --git a/Core/HLE/sceKernelModule.cpp b/Core/HLE/sceKernelModule.cpp index 97d8b6f513..88f2a127e6 100644 --- a/Core/HLE/sceKernelModule.cpp +++ b/Core/HLE/sceKernelModule.cpp @@ -2187,7 +2187,7 @@ static u32 sceKernelLoadModuleNpDrm(const char *name, u32 flags, u32 optionAddr) return sceKernelLoadModule(name, flags, optionAddr); } -int KernelStartModule(SceUID moduleId, u32 argsize, u32 argAddr, u32 returnValueAddr, SceKernelSMOption *smoption, bool *needsWait) { +int __KernelStartModule(SceUID moduleId, u32 argsize, u32 argAddr, u32 returnValueAddr, SceKernelSMOption *smoption, bool *needsWait) { if (needsWait) { *needsWait = false; } @@ -2242,36 +2242,23 @@ int KernelStartModule(SceUID moduleId, u32 argsize, u32 argAddr, u32 returnValue return moduleId; } -static void sceKernelStartModule(u32 moduleId, u32 argsize, u32 argAddr, u32 returnValueAddr, u32 optionAddr) -{ +static u32 sceKernelStartModule(u32 moduleId, u32 argsize, u32 argAddr, u32 returnValueAddr, u32 optionAddr) { u32 error; PSPModule *module = kernelObjects.Get(moduleId, error); if (!module) { - INFO_LOG(Log::sceModule, "sceKernelStartModule(%d,asize=%08x,aptr=%08x,retptr=%08x,%08x): error %08x", moduleId, argsize, argAddr, returnValueAddr, optionAddr, error); - RETURN(error); - return; + return hleLogWarning(Log::sceModule, error, "error %08x", error); } else if (module->isFake) { - INFO_LOG(Log::sceModule, "sceKernelStartModule(%d,asize=%08x,aptr=%08x,retptr=%08x,%08x): faked (undecryptable module)", - moduleId,argsize,argAddr,returnValueAddr,optionAddr); if (returnValueAddr) Memory::Write_U32(0, returnValueAddr); - RETURN(moduleId); - return; + return hleLogSuccessInfoI(Log::sceModule, moduleId, "Faked (undecryptable module)"); } else if (module->nm.status == MODULE_STATUS_STARTED) { - ERROR_LOG(Log::sceModule, "sceKernelStartModule(%d,asize=%08x,aptr=%08x,retptr=%08x,%08x) : already started", - moduleId,argsize,argAddr,returnValueAddr,optionAddr); // TODO: Maybe should be SCE_KERNEL_ERROR_ALREADY_STARTED, but I get SCE_KERNEL_ERROR_ERROR. // But I also get crashes... - RETURN(SCE_KERNEL_ERROR_ERROR); - return; + return hleLogError(Log::sceModule, SCE_KERNEL_ERROR_ERROR); } else { - INFO_LOG(Log::sceModule, "sceKernelStartModule(%d,asize=%08x,aptr=%08x,retptr=%08x,%08x)", - moduleId,argsize,argAddr,returnValueAddr,optionAddr); - bool needsWait; auto smoption = PSPPointer::Create(optionAddr); - int ret = KernelStartModule(moduleId, argsize, argAddr, returnValueAddr, smoption.PtrOrNull(), &needsWait); - + int ret = __KernelStartModule(moduleId, argsize, argAddr, returnValueAddr, smoption.PtrOrNull(), &needsWait); if (needsWait) { __KernelWaitCurThread(WAITTYPE_MODULE, moduleId, 1, 0, false, "started module"); @@ -2279,8 +2266,7 @@ static void sceKernelStartModule(u32 moduleId, u32 argsize, u32 argAddr, u32 ret module->nm.status = MODULE_STATUS_STARTING; module->waitingThreads.push_back(mwt); } - - RETURN(ret); + return hleLogSuccessInfoI(Log::sceModule, ret); } } @@ -2765,11 +2751,10 @@ static u32 sceKernelLoadModuleForLoadExecVSHDisc(const char *name, u32 flags, u3 return sceKernelLoadModule(name, flags, optionAddr); } -const HLEFunction ModuleMgrForUser[] = -{ +const HLEFunction ModuleMgrForUser[] = { {0X977DE386, &WrapU_CUU, "sceKernelLoadModule", 'x', "sxx" }, {0XB7F46618, &WrapU_UUU, "sceKernelLoadModuleByID", 'x', "xxx" }, - {0X50F0C1EC, &WrapV_UUUUU, "sceKernelStartModule", 'v', "xxxxx", HLE_NOT_IN_INTERRUPT | HLE_NOT_DISPATCH_SUSPENDED }, + {0X50F0C1EC, &WrapU_UUUUU, "sceKernelStartModule", 'v', "xxxxx", HLE_NOT_IN_INTERRUPT | HLE_NOT_DISPATCH_SUSPENDED }, {0XD675EBB8, &WrapU_UUU, "sceKernelSelfStopUnloadModule", 'x', "xxx" }, {0XD1FF982A, &WrapU_UUUUU, "sceKernelStopModule", 'x', "xxxxx", HLE_NOT_IN_INTERRUPT | HLE_NOT_DISPATCH_SUSPENDED }, {0X2E0911AA, &WrapU_U, "sceKernelUnloadModule", 'x', "x" }, @@ -2788,9 +2773,8 @@ const HLEFunction ModuleMgrForUser[] = }; -const HLEFunction ModuleMgrForKernel[] = -{ - {0x50F0C1EC, &WrapV_UUUUU, "sceKernelStartModule", 'v', "xxxxx", HLE_NOT_IN_INTERRUPT | HLE_NOT_DISPATCH_SUSPENDED | HLE_KERNEL_SYSCALL }, +const HLEFunction ModuleMgrForKernel[] = { + {0x50F0C1EC, &WrapU_UUUUU, "sceKernelStartModule", 'v', "xxxxx", HLE_NOT_IN_INTERRUPT | HLE_NOT_DISPATCH_SUSPENDED | HLE_KERNEL_SYSCALL }, {0x977DE386, &WrapU_CUU, "sceKernelLoadModule", 'x', "sxx", HLE_KERNEL_SYSCALL }, {0xA1A78C58, &WrapU_CUU, "sceKernelLoadModuleForLoadExecVSHDisc", 'x', "sxx", HLE_KERNEL_SYSCALL }, //fix for tiger x dragon {0xCC1D3699, &WrapU_UUU, "sceKernelStopUnloadSelfModule", 'x', "xxx", HLE_KERNEL_SYSCALL }, // used in Dissidia final fantasy chinese patch @@ -2800,13 +2784,10 @@ const HLEFunction ModuleMgrForKernel[] = {0X2E0911AA, &WrapU_U, "sceKernelUnloadModule", 'x', "x" , HLE_KERNEL_SYSCALL }, }; -void Register_ModuleMgrForUser() -{ +void Register_ModuleMgrForUser() { RegisterModule("ModuleMgrForUser", ARRAY_SIZE(ModuleMgrForUser), ModuleMgrForUser); } -void Register_ModuleMgrForKernel() -{ +void Register_ModuleMgrForKernel() { RegisterModule("ModuleMgrForKernel", ARRAY_SIZE(ModuleMgrForKernel), ModuleMgrForKernel); - -}; +} diff --git a/Core/HLE/sceKernelModule.h b/Core/HLE/sceKernelModule.h index 4e76a3f008..6d358a60f2 100644 --- a/Core/HLE/sceKernelModule.h +++ b/Core/HLE/sceKernelModule.h @@ -46,7 +46,7 @@ bool __KernelLoadExec(const char *filename, u32 paramPtr, std::string *error_str int __KernelGPUReplay(); void __KernelReturnFromModuleFunc(); SceUID KernelLoadModule(const std::string &filename, std::string *error_string); -int KernelStartModule(SceUID moduleId, u32 argsize, u32 argAddr, u32 returnValueAddr, SceKernelSMOption *smoption, bool *needsWait); +int __KernelStartModule(SceUID moduleId, u32 argsize, u32 argAddr, u32 returnValueAddr, SceKernelSMOption *smoption, bool *needsWait); u32 hleKernelStopUnloadSelfModuleWithOrWithoutStatus(u32 exitCode, u32 argSize, u32 argp, u32 statusAddr, u32 optionAddr, bool WithStatus); u32 sceKernelFindModuleByUID(u32 uid);