mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-01 14:58:14 +00:00
Run module_start of plugins before starting boot module
This commit is contained in:
1 parent
f832948f2d
commit
326448636b
6 files changed
+44
-7
No files matched your search
@@ -172,7 +172,7 @@ void Init() {
|
||||
}
|
||||
}
|
||||
|
||||
bool Load() {
|
||||
bool Load(PSPModule *pluginWaitingModule, SceUID threadID) {
|
||||
bool started = false;
|
||||
|
||||
auto sy = GetI18NCategory(I18NCat::SYSTEM);
|
||||
@@ -197,6 +197,10 @@ bool Load() {
|
||||
std::string shortName = Path(filename).GetFilename();
|
||||
g_OSD.Show(OSDType::MESSAGE_SUCCESS, ApplySafeSubstitutions(sy->T("Loaded plugin: %1"), shortName), 6.0f);
|
||||
started = true;
|
||||
pluginWaitingModule->startingPlugins.push_back(module);
|
||||
u32 error;
|
||||
PSPModule *plugin_module = kernelObjects.Get<PSPModule>(module, error);
|
||||
plugin_module->pluginWaitingThread = threadID;
|
||||
}
|
||||
|
||||
INFO_LOG(Log::System, "Loaded plugin: %s", filename.c_str());
|
||||
|
||||
+2
-1
@@ -20,6 +20,7 @@
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include "Common/Input/KeyCodes.h"
|
||||
#include "Core/HLE/sceKernelModule.h"
|
||||
|
||||
class PointerWrap;
|
||||
|
||||
@@ -28,7 +29,7 @@ namespace HLEPlugins {
|
||||
void Init();
|
||||
void Shutdown();
|
||||
|
||||
bool Load();
|
||||
bool Load(PSPModule *pluginWaitingModule, SceUID threadID);
|
||||
void Unload();
|
||||
|
||||
void DoState(PointerWrap &p);
|
||||
|
||||
@@ -1650,11 +1650,6 @@ 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);
|
||||
|
||||
if (HLEPlugins::Load()) {
|
||||
KernelRotateThreadReadyQueue(0);
|
||||
__KernelReSchedule("Started plugins");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1788,6 +1783,13 @@ bool __KernelLoadExec(const char *filename, u32 paramPtr, std::string *error_str
|
||||
|
||||
__KernelStartIdleThreads(module->GetUID());
|
||||
|
||||
// Wait until plugins are loaded
|
||||
module->startingPlugins.clear();
|
||||
if (HLEPlugins::Load(module, __KernelGetCurThread())) {
|
||||
__KernelWaitCurThread(WAITTYPE_PLUGIN, module->GetUID(), 1, 0, false, "started plugins");
|
||||
__KernelReSchedule("Started plugins");
|
||||
}
|
||||
|
||||
delete[] param_argp;
|
||||
delete[] param_key;
|
||||
|
||||
@@ -2302,6 +2304,29 @@ void __KernelReturnFromModuleFunc() {
|
||||
}
|
||||
module->waitingThreads.clear();
|
||||
|
||||
// Check if we need to wake up a plugin waiting thread
|
||||
if (module->pluginWaitingThread) {
|
||||
u32 error;
|
||||
PSPThread *plugin_waiting_thread = kernelObjects.Get<PSPThread>(module->pluginWaitingThread, error);
|
||||
if (plugin_waiting_thread) {
|
||||
PSPModule *plugin_waiting_module = kernelObjects.Get<PSPModule>(plugin_waiting_thread->moduleId, error);
|
||||
if (plugin_waiting_module) {
|
||||
for (auto it = plugin_waiting_module->startingPlugins.begin(), end = plugin_waiting_module->startingPlugins.end(); it < end; ++it) {
|
||||
if (*it == leftModuleID) {
|
||||
plugin_waiting_module->startingPlugins.erase(it);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (plugin_waiting_module->startingPlugins.empty()) {
|
||||
INFO_LOG(Log::sceModule, "Resuming LoadExec thread 0x%x", module->pluginWaitingThread);
|
||||
__KernelResumeThreadFromWait(module->pluginWaitingThread, 0);
|
||||
} else {
|
||||
INFO_LOG(Log::sceModule, "LoadExec thread 0x%x still waiting for %ld plugin(s)", module->pluginWaitingThread, plugin_waiting_module->startingPlugins.size());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (module->nm.status == MODULE_STATUS_UNLOADING) {
|
||||
// TODO: Delete the waiting thread?
|
||||
module->Cleanup();
|
||||
|
||||
@@ -191,6 +191,11 @@ public:
|
||||
NativeModule nm{};
|
||||
std::vector<ModuleWaitingThread> waitingThreads;
|
||||
|
||||
// From the plugin's perspective, this is the reference to the thread started by LoadExec
|
||||
SceUID pluginWaitingThread = 0;
|
||||
// Thread started by LoadExec is waiting for these plugins
|
||||
std::vector<SceUID> startingPlugins;
|
||||
|
||||
// TODO: Should we store these grouped by moduleName instead? Seems more reasonable.
|
||||
std::vector<FuncSymbolExport> exportedFuncs;
|
||||
std::vector<FuncSymbolImport> importedFuncs;
|
||||
|
||||
@@ -84,6 +84,7 @@ const WaitTypeNames waitTypeNames[] = {
|
||||
{ WAITTYPE_MICINPUT, "Microphone input"},
|
||||
{ WAITTYPE_NET, "Network"},
|
||||
{ WAITTYPE_USB, "USB" },
|
||||
{ WAITTYPE_PLUGIN, "Initial plugin load" },
|
||||
};
|
||||
|
||||
const char *WaitTypeToString(WaitType type) {
|
||||
|
||||
@@ -115,6 +115,7 @@ enum WaitType : int {
|
||||
WAITTYPE_MICINPUT = 24, // fake
|
||||
WAITTYPE_NET = 25, // fake
|
||||
WAITTYPE_USB = 26, // fake
|
||||
WAITTYPE_PLUGIN = 27, // this is fake, for when LoadExec thread is waiting for plugins to finish loading
|
||||
|
||||
NUM_WAITTYPES
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user