From 5fe49b23e9b801dd6fbcd4fd9dfbbdb5693b96fd Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 27 Jul 2014 21:53:46 -0700 Subject: [PATCH] Reschedule on module load/unload more correctly. --- Core/HLE/sceKernelModule.cpp | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/Core/HLE/sceKernelModule.cpp b/Core/HLE/sceKernelModule.cpp index cbdd4d9097..53ec2195b6 100644 --- a/Core/HLE/sceKernelModule.cpp +++ b/Core/HLE/sceKernelModule.cpp @@ -1653,12 +1653,12 @@ static u32 sceKernelLoadModule(const char *name, u32 flags, u32 optionAddr) if (!info.exists) { ERROR_LOG(LOADER, "sceKernelLoadModule(%s, %08x): File does not exist", name, flags); // ERRNO_FILE_NOT_FOUND - return 0x80010002; + return hleDelayResult(0x80010002, "module loaded", 500); } if (!size) { ERROR_LOG(LOADER, "sceKernelLoadModule(%s, %08x): Module file is size 0", name, flags); - return SCE_KERNEL_ERROR_FILEERR; + return hleDelayResult(SCE_KERNEL_ERROR_FILEERR, "module loaded", 500); } DEBUG_LOG(LOADER, "sceKernelLoadModule(%s, %08x)", name, flags); @@ -1671,15 +1671,15 @@ static u32 sceKernelLoadModule(const char *name, u32 flags, u32 optionAddr) lmoption = (SceKernelLMOption *)Memory::GetPointer(optionAddr); if (lmoption->position < PSP_SMEM_Low || lmoption->position > PSP_SMEM_HighAligned) { ERROR_LOG_REPORT(LOADER, "sceKernelLoadModule(%s): invalid position (%i)", name, (int)lmoption->position); - return SCE_KERNEL_ERROR_ILLEGAL_MEMBLOCKTYPE; + return hleDelayResult(SCE_KERNEL_ERROR_ILLEGAL_MEMBLOCKTYPE, "module loaded", 500); } if (lmoption->position == PSP_SMEM_LowAligned || lmoption->position == PSP_SMEM_HighAligned) { ERROR_LOG_REPORT(LOADER, "sceKernelLoadModule(%s): invalid position (aligned)", name); - return SCE_KERNEL_ERROR_ILLEGAL_ALIGNMENT_SIZE; + return hleDelayResult(SCE_KERNEL_ERROR_ILLEGAL_ALIGNMENT_SIZE, "module loaded", 500); } if (lmoption->position == PSP_SMEM_Addr) { ERROR_LOG_REPORT(LOADER, "sceKernelLoadModule(%s): invalid position (fixed)", name); - return SCE_KERNEL_ERROR_MEMBLOCK_ALLOC_FAILED; + return hleDelayResult(SCE_KERNEL_ERROR_MEMBLOCK_ALLOC_FAILED, "module loaded", 500); } WARN_LOG_REPORT(LOADER, "sceKernelLoadModule: unsupported options size=%08x, flags=%08x, pos=%d, access=%d, data=%d, text=%d", lmoption->size, lmoption->flags, lmoption->position, lmoption->access, lmoption->mpiddata, lmoption->mpidtext); } @@ -1697,7 +1697,9 @@ static u32 sceKernelLoadModule(const char *name, u32 flags, u32 optionAddr) if (!module) { if (magic == 0x46535000) { ERROR_LOG(LOADER, "Game tried to load an SFO as a module. Go figure? Magic = %08x", magic); - return -1; + // TODO: What's actually going on here? + error = -1; + return hleDelayResult(error, "module loaded", 500); } if (info.name == "BOOT.BIN") @@ -1711,13 +1713,14 @@ static u32 sceKernelLoadModule(const char *name, u32 flags, u32 optionAddr) { // Module was blacklisted or couldn't be decrypted, which means it's a kernel module we don't want to run.. // Let's just act as if it worked. + // TODO: Allocate an actual module? NOTICE_LOG(LOADER, "Module %s is blacklisted or undecryptable - we lie about success", name); - return 1; + return hleDelayResult(1, "module loaded", 500); } else { - NOTICE_LOG(LOADER, "Module %s failed to load: %08x", name, error); - return error; + ERROR_LOG(LOADER, "Module %s failed to load: %08x", name, error); + return hleDelayResult(error, "module loaded", 500); } } @@ -1924,11 +1927,11 @@ static u32 sceKernelUnloadModule(u32 moduleId) u32 error; Module *module = kernelObjects.Get(moduleId, error); if (!module) - return error; + return hleDelayResult(error, "module unloaded", 150); module->Cleanup(); kernelObjects.Destroy(moduleId); - return moduleId; + return hleDelayResult(moduleId, "module unloaded", 500); } u32 hleKernelStopUnloadSelfModuleWithOrWithoutStatus(u32 exitCode, u32 argSize, u32 argp, u32 statusAddr, u32 optionAddr, bool WithStatus) {