From f9ba0d7321598b597bf20610fc83946c0afb71a3 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Mon, 18 Apr 2016 20:08:07 -0700 Subject: [PATCH 1/3] Correct dependency handling when loading modules. Should help #8700. --- Core/HLE/sceUtility.cpp | 86 ++++++++++++++++++++++------------------- 1 file changed, 46 insertions(+), 40 deletions(-) diff --git a/Core/HLE/sceUtility.cpp b/Core/HLE/sceUtility.cpp index 80464b4778..c683273b31 100644 --- a/Core/HLE/sceUtility.cpp +++ b/Core/HLE/sceUtility.cpp @@ -63,51 +63,57 @@ const int SCE_ERROR_MODULE_NOT_LOADED = 0x80111103; const int SCE_ERROR_AV_MODULE_BAD_ID = 0x80110F01; int oldStatus = 100; //random value +static const int noDeps[] = {0}; +static const int httpModuleDeps[] = {0x0102, 0x0103, 0x0104, 0}; +static const int sslModuleDeps[] = {0x0102, 0}; +static const int httpStorageModuleDeps[] = {0x00100, 0x0102, 0x0103, 0x0104, 0x0105, 0}; +static const int atrac3PlusModuleDeps[] = {0x0300, 0}; +static const int mpegBaseModuleDeps[] = {0x0300, 0}; +static const int mp4ModuleDeps[] = {0x0300, 0x0303, 0}; + struct ModuleLoadInfo { + ModuleLoadInfo(int m, u32 s) : mod(m), size(s), dependencies(noDeps) { + } + ModuleLoadInfo(int m, u32 s, const int *d) : mod(m), size(s), dependencies(d) { + } + const int mod; const u32 size; - const int *dependencies; + const int *const dependencies; }; -static const int httpModuleDeps[] = {0x0102, 0x0103, 0x0104}; -static const int sslModuleDeps[] = {0x0102}; -static const int httpStorageModuleDeps[] = {0x00100, 0x0102, 0x0103, 0x0104, 0x0105}; -static const int atrac3PlusModuleDeps[] = {0x0300}; -static const int mpegBaseModuleDeps[] = {0x0300}; -static const int mp4ModuleDeps[] = {0x0300, 0x0303}; - static const ModuleLoadInfo moduleLoadInfo[] = { - {0x0100, 0x00014000}, - {0x0101, 0x00020000}, - {0x0102, 0x00058000}, - {0x0103, 0x00006000}, - {0x0104, 0x00002000}, - {0x0105, 0x00028000, httpModuleDeps}, - {0x0106, 0x00044000, sslModuleDeps}, - {0x0107, 0x00010000}, - {0x0108, 0x00008000, httpStorageModuleDeps}, - {0x0200, 0x00000000}, - {0x0201, 0x00000000}, - {0x0202, 0x00000000}, - {0x0203, 0x00000000}, - {0x02ff, 0x00000000}, - {0x0300, 0x00000000}, - {0x0301, 0x00000000}, - {0x0302, 0x00008000, atrac3PlusModuleDeps}, - {0x0303, 0x0000c000, mpegBaseModuleDeps}, - {0x0304, 0x00004000}, - {0x0305, 0x0000a300}, - {0x0306, 0x00004000}, - {0x0307, 0x00000000}, - {0x0308, 0x0003c000, mp4ModuleDeps}, - {0x03ff, 0x00000000}, - {0x0400, 0x0000c000}, - {0x0401, 0x00018000}, - {0x0402, 0x00048000}, - {0x0403, 0x0000e000}, - {0x0500, 0x00000000}, - {0x0600, 0x00000000}, - {0x0601, 0x00000000}, + ModuleLoadInfo(0x0100, 0x00014000), + ModuleLoadInfo(0x0101, 0x00020000), + ModuleLoadInfo(0x0102, 0x00058000), + ModuleLoadInfo(0x0103, 0x00006000), + ModuleLoadInfo(0x0104, 0x00002000), + ModuleLoadInfo(0x0105, 0x00028000, httpModuleDeps), + ModuleLoadInfo(0x0106, 0x00044000, sslModuleDeps), + ModuleLoadInfo(0x0107, 0x00010000), + ModuleLoadInfo(0x0108, 0x00008000, httpStorageModuleDeps), + ModuleLoadInfo(0x0200, 0x00000000), + ModuleLoadInfo(0x0201, 0x00000000), + ModuleLoadInfo(0x0202, 0x00000000), + ModuleLoadInfo(0x0203, 0x00000000), + ModuleLoadInfo(0x02ff, 0x00000000), + ModuleLoadInfo(0x0300, 0x00000000), + ModuleLoadInfo(0x0301, 0x00000000), + ModuleLoadInfo(0x0302, 0x00008000, atrac3PlusModuleDeps), + ModuleLoadInfo(0x0303, 0x0000c000, mpegBaseModuleDeps), + ModuleLoadInfo(0x0304, 0x00004000), + ModuleLoadInfo(0x0305, 0x0000a300), + ModuleLoadInfo(0x0306, 0x00004000), + ModuleLoadInfo(0x0307, 0x00000000), + ModuleLoadInfo(0x0308, 0x0003c000, mp4ModuleDeps), + ModuleLoadInfo(0x03ff, 0x00000000), + ModuleLoadInfo(0x0400, 0x0000c000), + ModuleLoadInfo(0x0401, 0x00018000), + ModuleLoadInfo(0x0402, 0x00048000), + ModuleLoadInfo(0x0403, 0x0000e000), + ModuleLoadInfo(0x0500, 0x00000000), + ModuleLoadInfo(0x0600, 0x00000000), + ModuleLoadInfo(0x0601, 0x00000000), }; enum UtilityDialogType { @@ -279,7 +285,7 @@ static u32 sceUtilityLoadModule(u32 module) { } // Some games, like Kamen Rider Climax Heroes OOO, require an error if dependencies aren't loaded yet. - for (const int *dep = info->dependencies; dep && *dep == 0; ++dep) { + for (const int *dep = info->dependencies; *dep != 0; ++dep) { if (currentlyLoadedModules.find(*dep) == currentlyLoadedModules.end()) { ERROR_LOG(SCEUTILITY, "sceUtilityLoadModule(%i): dependent module %i not loaded", module, *dep); return hleDelayResult(SCE_KERNEL_ERROR_LIBRARY_NOTFOUND, "utility module load attempt", 25000); From 5a748263728c36470f6041a8894838266f279a73 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Mon, 18 Apr 2016 20:17:49 -0700 Subject: [PATCH 2/3] Use new logging in utility module load/unload. --- Core/HLE/sceUtility.cpp | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/Core/HLE/sceUtility.cpp b/Core/HLE/sceUtility.cpp index c683273b31..73a10c5529 100644 --- a/Core/HLE/sceUtility.cpp +++ b/Core/HLE/sceUtility.cpp @@ -262,7 +262,7 @@ static u32 sceUtilityUnloadAvModule(u32 module) return hleDelayResult(0, "utility av module unloaded", 800); } -const ModuleLoadInfo *__UtilityModuleInfo(int module) { +static const ModuleLoadInfo *__UtilityModuleInfo(int module) { const ModuleLoadInfo *info = 0; for (size_t i = 0; i < ARRAY_SIZE(moduleLoadInfo); ++i) { if (moduleLoadInfo[i].mod == module) { @@ -276,24 +276,20 @@ const ModuleLoadInfo *__UtilityModuleInfo(int module) { static u32 sceUtilityLoadModule(u32 module) { const ModuleLoadInfo *info = __UtilityModuleInfo(module); if (!info) { - ERROR_LOG_REPORT(SCEUTILITY, "sceUtilityLoadModule(%i): invalid module id", module); - return SCE_ERROR_MODULE_BAD_ID; + return hleReportError(SCEUTILITY, SCE_ERROR_MODULE_BAD_ID, "invalid module id"); } if (currentlyLoadedModules.find(module) != currentlyLoadedModules.end()) { - ERROR_LOG(SCEUTILITY, "sceUtilityLoadModule(%i): already loaded", module); - return SCE_ERROR_MODULE_ALREADY_LOADED; + return hleLogError(SCEUTILITY, SCE_ERROR_MODULE_ALREADY_LOADED, "already loaded"); } // Some games, like Kamen Rider Climax Heroes OOO, require an error if dependencies aren't loaded yet. for (const int *dep = info->dependencies; *dep != 0; ++dep) { if (currentlyLoadedModules.find(*dep) == currentlyLoadedModules.end()) { - ERROR_LOG(SCEUTILITY, "sceUtilityLoadModule(%i): dependent module %i not loaded", module, *dep); - return hleDelayResult(SCE_KERNEL_ERROR_LIBRARY_NOTFOUND, "utility module load attempt", 25000); + u32 result = hleLogError(SCEUTILITY, SCE_KERNEL_ERROR_LIBRARY_NOTFOUND, "dependent module %i not loaded", *dep); + return hleDelayResult(result, "utility module load attempt", 25000); } } - INFO_LOG(SCEUTILITY, "sceUtilityLoadModule(%i)", module); - u32 allocSize = info->size; char name[64]; snprintf(name, sizeof(name), "UtilityModule/%x", module); @@ -305,33 +301,30 @@ static u32 sceUtilityLoadModule(u32 module) { // TODO: Each module has its own timing, technically, but this is a low-end. if (module == 0x3FF) - return hleDelayResult(0, "utility module loaded", 130); + return hleDelayResult(hleLogSuccessInfoI(SCEUTILITY, 0), "utility module loaded", 130); else - return hleDelayResult(0, "utility module loaded", 25000); + return hleDelayResult(hleLogSuccessInfoI(SCEUTILITY, 0), "utility module loaded", 25000); } static u32 sceUtilityUnloadModule(u32 module) { const ModuleLoadInfo *info = __UtilityModuleInfo(module); if (!info) { - ERROR_LOG_REPORT(SCEUTILITY, "sceUtilityUnloadModule(%i): invalid module id", module); - return SCE_ERROR_MODULE_BAD_ID; + return hleReportError(SCEUTILITY, SCE_ERROR_MODULE_BAD_ID, "invalid module id"); } if (currentlyLoadedModules.find(module) == currentlyLoadedModules.end()) { - WARN_LOG(SCEUTILITY, "sceUtilityUnloadModule(%i): not yet loaded", module); - return SCE_ERROR_MODULE_NOT_LOADED; + return hleLogWarning(SCEUTILITY, SCE_ERROR_MODULE_NOT_LOADED, "not yet loaded"); } if (currentlyLoadedModules[module] != 0) { userMemory.Free(currentlyLoadedModules[module]); } currentlyLoadedModules.erase(module); - INFO_LOG(SCEUTILITY, "sceUtilityUnloadModule(%i)", module); // TODO: Each module has its own timing, technically, but this is a low-end. if (module == 0x3FF) - return hleDelayResult(0, "utility module unloaded", 110); + return hleDelayResult(hleLogSuccessInfoI(SCEUTILITY, 0), "utility module unloaded", 110); else - return hleDelayResult(0, "utility module unloaded", 400); + return hleDelayResult(hleLogSuccessInfoI(SCEUTILITY, 0), "utility module unloaded", 400); } static int sceUtilityMsgDialogInitStart(u32 paramAddr) From bc03aa11f21bd86bc0e9a5f50a2aa60faca9b61f Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Mon, 18 Apr 2016 20:19:27 -0700 Subject: [PATCH 3/3] Log module id as hex, clearer. --- Core/HLE/sceUtility.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/HLE/sceUtility.cpp b/Core/HLE/sceUtility.cpp index 73a10c5529..e1c9cb52eb 100644 --- a/Core/HLE/sceUtility.cpp +++ b/Core/HLE/sceUtility.cpp @@ -285,7 +285,7 @@ static u32 sceUtilityLoadModule(u32 module) { // Some games, like Kamen Rider Climax Heroes OOO, require an error if dependencies aren't loaded yet. for (const int *dep = info->dependencies; *dep != 0; ++dep) { if (currentlyLoadedModules.find(*dep) == currentlyLoadedModules.end()) { - u32 result = hleLogError(SCEUTILITY, SCE_KERNEL_ERROR_LIBRARY_NOTFOUND, "dependent module %i not loaded", *dep); + u32 result = hleLogError(SCEUTILITY, SCE_KERNEL_ERROR_LIBRARY_NOTFOUND, "dependent module %04x not loaded", *dep); return hleDelayResult(result, "utility module load attempt", 25000); } }