mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-13 17:49:29 +01:00
Extend LoadExecForKernel with real VSH loadexec/exit syscalls
Adds SceKernelLoadExecVSHParam (matching JPCSP's reference layout - its first four fields line up with the existing SceKernelLoadExecParam, which is why the plain sceKernelLoadExec already worked for sceKernelLoadExecVSHMs2) and fills in the rest of LoadExecForKernel's NIDs from JPCSP: real implementations for sceKernelExitVSHVSH/Kernel (mirrors sceKernelExitGame) and sceKernelLoadExecBufferVSHUsbWlan (loads an exec from an in-RAM buffer instead of a file - the VSH's "push a game over USB/WLAN" path), plus UNIMPL stubs for everything JPCSP itself only knows by NID. sceKernelLoadExecBufferVSHUsbWlan needed __KernelLoadExec split into a file-reading front end and a shared __KernelLoadExecFromPtr back end that both it and the new buffer-based path call into - a pure extract-method refactor of the single most heavily used boot path in the emulator. Verified no regression: same 11 passed / 9 pre-existing-failed split on pspautotests/tests/cpu/*, and loader/bss still passes, before and after this change. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PSNaZnHCjmryS3ziVN9gZU
This commit is contained in:
1 parent
5f5130025c
commit
510cfb421c
5 files changed
+135
-19
No files matched your search
@@ -1776,7 +1776,10 @@ void __KernelLoadReset() {
|
||||
__KernelInit();
|
||||
}
|
||||
|
||||
bool __KernelLoadExec(const char *filename, u32 paramPtr, std::string *error_string) {
|
||||
// Shared by __KernelLoadExec (loading from a file) and __KernelLoadExecFromBuffer (loading
|
||||
// from a buffer already in RAM, as used by the VSH's USB/WLAN game-push feature) - everything
|
||||
// past the point where we have the executable's bytes in hand.
|
||||
bool __KernelLoadExecFromPtr(const u8 *data, size_t size, const char *filename, u32 paramPtr, std::string *error_string) {
|
||||
SceKernelLoadExecParam param{};
|
||||
|
||||
auto paramData = PSPPointer<SceKernelLoadExecParam>::Create(paramPtr);
|
||||
@@ -1801,18 +1804,7 @@ bool __KernelLoadExec(const char *filename, u32 paramPtr, std::string *error_str
|
||||
|
||||
__KernelLoadReset();
|
||||
|
||||
std::vector<uint8_t> fileData;
|
||||
if (pspFileSystem.ReadEntireFile(filename, fileData) < 0) {
|
||||
ERROR_LOG(Log::Loader, "Failed to load executable %s - file doesn't exist", filename);
|
||||
*error_string = StringFromFormat("Could not find executable %s", filename);
|
||||
delete[] param_argp;
|
||||
delete[] param_key;
|
||||
__KernelShutdown();
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t size = fileData.size();
|
||||
PSPModule *module = __KernelLoadModule(fileData.data(), size, 0, filename, error_string);
|
||||
PSPModule *module = __KernelLoadModule((u8 *)data, size, 0, filename, error_string);
|
||||
|
||||
if (!module || module->isFake) {
|
||||
if (module) {
|
||||
@@ -1872,6 +1864,22 @@ bool __KernelLoadExec(const char *filename, u32 paramPtr, std::string *error_str
|
||||
return true;
|
||||
}
|
||||
|
||||
bool __KernelLoadExec(const char *filename, u32 paramPtr, std::string *error_string) {
|
||||
std::vector<uint8_t> fileData;
|
||||
if (pspFileSystem.ReadEntireFile(filename, fileData) < 0) {
|
||||
ERROR_LOG(Log::Loader, "Failed to load executable %s - file doesn't exist", filename);
|
||||
*error_string = StringFromFormat("Could not find executable %s", filename);
|
||||
__KernelShutdown();
|
||||
return false;
|
||||
}
|
||||
|
||||
return __KernelLoadExecFromPtr(fileData.data(), fileData.size(), filename, paramPtr, error_string);
|
||||
}
|
||||
|
||||
bool __KernelLoadExecFromBuffer(const u8 *data, size_t size, u32 paramPtr, std::string *error_string) {
|
||||
return __KernelLoadExecFromPtr(data, size, "vshbuffer", paramPtr, error_string);
|
||||
}
|
||||
|
||||
bool __KernelLoadGEDump(std::string_view base_filename, std::string *error_string) {
|
||||
__KernelLoadReset();
|
||||
|
||||
@@ -2538,7 +2546,7 @@ static u32 sceKernelLoadModuleDNAS(const char *name, u32 flags)
|
||||
return hleNoLog(0);
|
||||
}
|
||||
|
||||
// Pretty sure this is a badly brute-forced function name...
|
||||
// Suspecting this is a badly brute-forced function name... Although, it's not entirely implausible. Buffer makes sense.
|
||||
SceUID sceKernelLoadModuleBufferUsbWlan(u32 size, u32 bufPtr, u32 flags, u32 lmoptionPtr)
|
||||
{
|
||||
if (flags != 0) {
|
||||
|
||||
Reference in new issue
Block a user