diff --git a/Core/HLE/Plugins.cpp b/Core/HLE/Plugins.cpp index b3e01f4bde..5f22e9fc37 100644 --- a/Core/HLE/Plugins.cpp +++ b/Core/HLE/Plugins.cpp @@ -41,7 +41,7 @@ struct PluginInfo { PluginType type; std::string filename; int version; - int memory; + uint32_t memory; }; static PluginInfo ReadPluginIni(const std::string &subdir, IniFile &ini) { @@ -162,17 +162,18 @@ void Init() { } } -void Load() { +bool Load() { + bool started = false; for (const std::string &filename : prxPlugins) { std::string error_string = ""; SceUID module = KernelLoadModule(filename, &error_string); if (!error_string.empty()) { ERROR_LOG(SYSTEM, "Unable to load plugin %s: %s", filename.c_str(), error_string.c_str()); - return; + continue; } if (module < 0) { ERROR_LOG(SYSTEM, "Unable to load plugin %s: %08x", filename.c_str(), module); - return; + continue; } int ret = KernelStartModule(module, 0, 0, 0, nullptr, nullptr); @@ -181,7 +182,10 @@ void Load() { } INFO_LOG(SYSTEM, "Loaded plugin: %s", filename.c_str()); + started = true; } + + return started; } void Unload() { diff --git a/Core/HLE/Plugins.h b/Core/HLE/Plugins.h index 8626fea9e8..6db2966d98 100644 --- a/Core/HLE/Plugins.h +++ b/Core/HLE/Plugins.h @@ -24,7 +24,7 @@ namespace HLEPlugins { void Init(); void Shutdown(); -void Load(); +bool Load(); void Unload(); void DoState(PointerWrap &p); diff --git a/Core/HLE/sceKernelModule.cpp b/Core/HLE/sceKernelModule.cpp index 4e67207967..e31e0f93e3 100644 --- a/Core/HLE/sceKernelModule.cpp +++ b/Core/HLE/sceKernelModule.cpp @@ -1626,7 +1626,10 @@ static void __KernelStartModule(PSPModule *m, int args, const char *argp, SceKer SceUID threadID = __KernelSetupRootThread(m->GetUID(), args, argp, options->priority, options->stacksize, options->attribute); __KernelSetThreadRA(threadID, NID_MODULERETURN); - HLEPlugins::Load(); + if (HLEPlugins::Load()) { + KernelRotateThreadReadyQueue(0); + __KernelReSchedule("Started plugins"); + } } diff --git a/Core/HLE/sceKernelThread.cpp b/Core/HLE/sceKernelThread.cpp index cade794e08..6bd3d2d434 100644 --- a/Core/HLE/sceKernelThread.cpp +++ b/Core/HLE/sceKernelThread.cpp @@ -2246,10 +2246,7 @@ bool __KernelIsDispatchEnabled() return dispatchEnabled && __InterruptsEnabled(); } -int sceKernelRotateThreadReadyQueue(int priority) -{ - VERBOSE_LOG(SCEKERNEL, "sceKernelRotateThreadReadyQueue(%x)", priority); - +int KernelRotateThreadReadyQueue(int priority) { PSPThread *cur = __GetCurrentThread(); // 0 is special, it means "my current priority." @@ -2259,11 +2256,9 @@ int sceKernelRotateThreadReadyQueue(int priority) if (priority <= 0x07 || priority > 0x77) return SCE_KERNEL_ERROR_ILLEGAL_PRIORITY; - if (!threadReadyQueue.empty(priority)) - { + if (!threadReadyQueue.empty(priority)) { // In other words, yield to everyone else. - if (cur->nt.currentPriority == priority) - { + if (cur->nt.currentPriority == priority) { threadReadyQueue.push_back(priority, currentThread); cur->nt.status = (cur->nt.status & ~THREADSTATUS_RUNNING) | THREADSTATUS_READY; } @@ -2272,11 +2267,18 @@ int sceKernelRotateThreadReadyQueue(int priority) threadReadyQueue.rotate(priority); } - hleReSchedule("rotatethreadreadyqueue"); - hleEatCycles(250); return 0; } +int sceKernelRotateThreadReadyQueue(int priority) { + int result = KernelRotateThreadReadyQueue(priority); + if (result == 0) { + hleReSchedule("rotatethreadreadyqueue"); + hleEatCycles(250); + } + return hleLogSuccessVerboseI(SCEKERNEL, result); +} + int sceKernelDeleteThread(int threadID) { if (threadID == 0 || threadID == currentThread) { ERROR_LOG(SCEKERNEL, "sceKernelDeleteThread(%i): cannot delete current thread", threadID); diff --git a/Core/HLE/sceKernelThread.h b/Core/HLE/sceKernelThread.h index bb08bb3b66..65dce5ff54 100644 --- a/Core/HLE/sceKernelThread.h +++ b/Core/HLE/sceKernelThread.h @@ -57,6 +57,7 @@ u32 sceKernelReferThreadRunStatus(u32 uid, u32 statusPtr); int sceKernelReleaseWaitThread(SceUID threadID); int sceKernelChangeCurrentThreadAttr(u32 clearAttr, u32 setAttr); int sceKernelRotateThreadReadyQueue(int priority); +int KernelRotateThreadReadyQueue(int priority); int sceKernelCheckThreadStack(); int sceKernelSuspendThread(SceUID threadID); int sceKernelResumeThread(SceUID threadID);