mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-12-02 18:53:58 +01:00
PSP boot: Move more of the startup process into the loading thread. Simplifies the code a bit.
This commit is contained in:
1 parent
19c7d795a7
commit
ee90d2acc1
10 files changed
+92
-164
No files matched your search
+5
-92
@@ -15,10 +15,7 @@
|
||||
// Official git repository and contact information can be found at
|
||||
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
||||
|
||||
#include <thread>
|
||||
|
||||
#include "Core/Core.h"
|
||||
#include "Common/Thread/ThreadUtil.h"
|
||||
#include "Common/System/Request.h"
|
||||
|
||||
#include "Common/File/AndroidContentURI.h"
|
||||
@@ -49,8 +46,6 @@
|
||||
#include "Core/PSPLoaders.h"
|
||||
#include "Core/HLE/sceKernelModule.h"
|
||||
|
||||
static std::thread g_loadingThread;
|
||||
|
||||
static void UseLargeMem(int memsize) {
|
||||
if (memsize != 1) {
|
||||
// Nothing requested.
|
||||
@@ -252,7 +247,6 @@ bool Load_PSP_ISO(FileLoader *fileLoader, std::string *error_string) {
|
||||
} else {
|
||||
*error_string = "A PSP game couldn't be found on the disc.";
|
||||
}
|
||||
coreState = CORE_BOOT_ERROR;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -270,38 +264,11 @@ bool Load_PSP_ISO(FileLoader *fileLoader, std::string *error_string) {
|
||||
g_Config.loadGameConfig(id, g_paramSFO.GetValueString("TITLE"));
|
||||
System_PostUIMessage(UIMessage::CONFIG_LOADED);
|
||||
INFO_LOG(Log::Loader, "Loading %s...", bootpath.c_str());
|
||||
|
||||
PSPLoaders_Shutdown();
|
||||
// Note: this thread reads the game binary, loads caches, and links HLE while UI spins.
|
||||
// To do something deterministically when the game starts, disabling this thread won't be enough.
|
||||
// Instead: Use Core_ListenLifecycle() or watch coreState.
|
||||
g_loadingThread = std::thread([bootpath] {
|
||||
SetCurrentThreadName("ExecLoader");
|
||||
PSP_LoadingLock guard;
|
||||
if (coreState != CORE_POWERUP)
|
||||
return;
|
||||
|
||||
AndroidJNIThreadContext jniContext;
|
||||
|
||||
INFO_LOG(Log::System, "Loading executable...");
|
||||
// TODO: We can't use the initial error_string pointer.
|
||||
bool success = __KernelLoadExec(bootpath.c_str(), 0, &PSP_CoreParameter().errorString);
|
||||
if (success && coreState == CORE_POWERUP) {
|
||||
if (PSP_CoreParameter().startBreak) {
|
||||
coreState = CORE_STEPPING_CPU;
|
||||
System_Notify(SystemNotification::DEBUG_MODE_CHANGE);
|
||||
} else {
|
||||
coreState = CORE_RUNNING_CPU;
|
||||
}
|
||||
} else {
|
||||
coreState = CORE_BOOT_ERROR;
|
||||
// TODO: This is a crummy way to communicate the error...
|
||||
PSP_CoreParameter().fileToStart.clear();
|
||||
}
|
||||
});
|
||||
return true;
|
||||
// TODO: We can't use the initial error_string pointer.
|
||||
return __KernelLoadExec(bootpath.c_str(), 0, &PSP_CoreParameter().errorString);
|
||||
}
|
||||
|
||||
// TODO: Move this to common. Merge with ResolvePath?
|
||||
static Path NormalizePath(const Path &path) {
|
||||
if (path.Type() != PathType::NATIVE) {
|
||||
// Nothing to do - these can't be non-normalized.
|
||||
@@ -375,7 +342,6 @@ bool Load_PSP_ELF_PBP(FileLoader *fileLoader, std::string *error_string) {
|
||||
// If root is not a subpath of path, we can't boot the game.
|
||||
if (!pathNorm.StartsWith(rootNorm)) {
|
||||
*error_string = "Cannot boot ELF located outside mountRoot.";
|
||||
coreState = CORE_BOOT_ERROR;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -438,65 +404,12 @@ bool Load_PSP_ELF_PBP(FileLoader *fileLoader, std::string *error_string) {
|
||||
File::Rename(oldNamePrefix.WithExtraExtension(".jpg"), newPrefix.WithExtraExtension(".jpg"));
|
||||
}
|
||||
|
||||
PSPLoaders_Shutdown();
|
||||
// Note: See Load_PSP_ISO for notes about this thread.
|
||||
g_loadingThread = std::thread([finalName] {
|
||||
SetCurrentThreadName("ExecLoader");
|
||||
PSP_LoadingLock guard;
|
||||
if (coreState != CORE_POWERUP)
|
||||
return;
|
||||
|
||||
AndroidJNIThreadContext jniContext;
|
||||
|
||||
bool success = __KernelLoadExec(finalName.c_str(), 0, &PSP_CoreParameter().errorString);
|
||||
if (success && coreState == CORE_POWERUP) {
|
||||
if (PSP_CoreParameter().startBreak) {
|
||||
coreState = CORE_STEPPING_CPU;
|
||||
System_Notify(SystemNotification::DEBUG_MODE_CHANGE);
|
||||
} else {
|
||||
coreState = CORE_RUNNING_CPU;
|
||||
}
|
||||
} else {
|
||||
coreState = CORE_BOOT_ERROR;
|
||||
// TODO: This is a crummy way to communicate the error...
|
||||
PSP_CoreParameter().fileToStart.clear();
|
||||
}
|
||||
});
|
||||
return true;
|
||||
return __KernelLoadExec(finalName.c_str(), 0, error_string);
|
||||
}
|
||||
|
||||
bool Load_PSP_GE_Dump(FileLoader *fileLoader, std::string *error_string) {
|
||||
auto umd = std::make_shared<BlobFileSystem>(&pspFileSystem, fileLoader, "data.ppdmp");
|
||||
pspFileSystem.Mount("disc0:", umd);
|
||||
|
||||
PSPLoaders_Shutdown();
|
||||
// Note: See Load_PSP_ISO for notes about this thread.
|
||||
g_loadingThread = std::thread([] {
|
||||
SetCurrentThreadName("ExecLoader");
|
||||
PSP_LoadingLock guard;
|
||||
if (coreState != CORE_POWERUP)
|
||||
return;
|
||||
|
||||
AndroidJNIThreadContext jniContext;
|
||||
|
||||
bool success = __KernelLoadGEDump("disc0:/data.ppdmp", &PSP_CoreParameter().errorString);
|
||||
if (success && coreState == CORE_POWERUP) {
|
||||
if (PSP_CoreParameter().startBreak) {
|
||||
coreState = CORE_STEPPING_CPU;
|
||||
System_Notify(SystemNotification::DEBUG_MODE_CHANGE);
|
||||
} else {
|
||||
coreState = CORE_RUNNING_CPU;
|
||||
}
|
||||
} else {
|
||||
coreState = CORE_BOOT_ERROR;
|
||||
// TODO: This is a crummy way to communicate the error...
|
||||
PSP_CoreParameter().fileToStart.clear();
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
void PSPLoaders_Shutdown() {
|
||||
if (g_loadingThread.joinable())
|
||||
g_loadingThread.join();
|
||||
return __KernelLoadGEDump("disc0:/data.ppdmp", &PSP_CoreParameter().errorString);
|
||||
}
|
||||
Reference in new issue
Block a user