mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-23 13:30:02 +00:00
Plugins: Schedule plugins before game thread.
This commit is contained in:
parent
2f4945aad8
commit
ac7522b0dd
@ -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() {
|
||||
|
@ -24,7 +24,7 @@ namespace HLEPlugins {
|
||||
void Init();
|
||||
void Shutdown();
|
||||
|
||||
void Load();
|
||||
bool Load();
|
||||
void Unload();
|
||||
|
||||
void DoState(PointerWrap &p);
|
||||
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user