Skip to content

Commit

Permalink
Reschedule on module load/unload more correctly.
Browse files Browse the repository at this point in the history
  • Loading branch information
unknownbrackets committed Jan 16, 2015
1 parent 8a012a9 commit d38cfe4
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions Core/HLE/sceKernelModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
}
Expand All @@ -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")
Expand All @@ -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);
}
}

Expand Down Expand Up @@ -1924,11 +1927,11 @@ static u32 sceKernelUnloadModule(u32 moduleId)
u32 error;
Module *module = kernelObjects.Get<Module>(moduleId, error);
if (!module)
return error;
return hleDelayResult(error, "module unloaded", 150);

module->Cleanup();
kernelObjects.Destroy<Module>(moduleId);
return moduleId;
return hleDelayResult(moduleId, "module unloaded", 500);
}

u32 hleKernelStopUnloadSelfModuleWithOrWithoutStatus(u32 exitCode, u32 argSize, u32 argp, u32 statusAddr, u32 optionAddr, bool WithStatus) {
Expand Down

0 comments on commit d38cfe4

Please sign in to comment.