From 7ccc0def4db18e34bcbd686e169db6040bd53dfc Mon Sep 17 00:00:00 2001 From: hrimfaxi Date: Sat, 25 Jun 2011 12:51:23 +0800 Subject: [PATCH] added pspgo support, but it doesn't work yet --- popsloader/common/popsloader.h | 2 +- popsloader/core/main.c | 21 ++++++++++++++------- popsloader/core/main.h | 3 --- popsloader/loader/main.c | 29 +++++++++++++++++++++++------ 4 files changed, 38 insertions(+), 17 deletions(-) diff --git a/popsloader/common/popsloader.h b/popsloader/common/popsloader.h index f377220..abd5400 100644 --- a/popsloader/common/popsloader.h +++ b/popsloader/common/popsloader.h @@ -13,7 +13,7 @@ enum { TARGET_639, }; -#define BASE_PATH "ms0:/seplugins/popsloader/" +#define BASE_PATH "0:/seplugins/popsloader/" #define MODULE_PATH BASE_PATH "modules/" #define CFG_PATH BASE_PATH "pops.cfg" diff --git a/popsloader/core/main.c b/popsloader/core/main.c index 9d5b77a..884dbee 100644 --- a/popsloader/core/main.c +++ b/popsloader/core/main.c @@ -44,17 +44,22 @@ u32 pops_fw_version; static STMOD_HANDLER g_previous = NULL; +static inline int is_ef0(void) +{ + return psp_model == PSP_GO && sctrlKernelBootFrom() == 0x50 ? 1 : 0; +} + void mount_memory_stick(void) { int dfd; char *devname = "ms0:/"; - if(psp_model == PSP_GO && sctrlKernelBootFrom() == 0x50) { + if(is_ef0()) { devname = "ef0:/"; } do { - dfd = sceIoDopen("ms0:/"); + dfd = sceIoDopen(devname); if(dfd >= 0) break; @@ -98,13 +103,13 @@ static inline const char *get_module_prefix(void) static char buf[80]; if(pops_fw_version == FW_639) { - sprintf(buf, "%s%s/", MODULE_PATH, "639"); + sprintf(buf, "%s%s%s/", is_ef0() ? "ef" : "ms", MODULE_PATH, "639"); } else if(pops_fw_version == FW_635) { - sprintf(buf, "%s%s/", MODULE_PATH, "635"); + sprintf(buf, "%s%s%s/", is_ef0() ? "ef" : "ms", MODULE_PATH, "635"); } else if(pops_fw_version == FW_620) { - sprintf(buf, "%s%s/", MODULE_PATH, "620"); + sprintf(buf, "%s%s%s/", is_ef0() ? "ef" : "ms", MODULE_PATH, "620"); } else if(pops_fw_version == FW_500) { - sprintf(buf, "%s%s/", MODULE_PATH, "500"); + sprintf(buf, "%s%s%s/", is_ef0() ? "ef" : "ms", MODULE_PATH, "500"); } else { printk("%s: Unknown version: 0x%08X\n", __func__, pops_fw_version); asm("break"); @@ -266,8 +271,10 @@ int load_config(void) { SceUID fd; int type; + char path[256]; - fd = sceIoOpen(CFG_PATH, PSP_O_RDONLY, 0777); + sprintf(path, "%s%s", is_ef0() ? "ef" : "ms", CFG_PATH); + fd = sceIoOpen(path, PSP_O_RDONLY, 0777); if(fd < 0) { return fd; diff --git a/popsloader/core/main.h b/popsloader/core/main.h index 094ee0e..bf0930f 100644 --- a/popsloader/core/main.h +++ b/popsloader/core/main.h @@ -26,9 +26,6 @@ #define printk_init(...) #endif -#define BASE_PATH "ms0:/seplugins/popsloader/" -#define MODULE_PATH BASE_PATH "modules/" - #define UNKNOWNNID 0xDEADBEEF #define NID_ENTRY(libname) \ { #libname, NELEMS(libname##_nid), libname##_nid, } diff --git a/popsloader/loader/main.c b/popsloader/loader/main.c index 4f485cf..9e80ec1 100644 --- a/popsloader/loader/main.c +++ b/popsloader/loader/main.c @@ -41,6 +41,11 @@ void *module_buffer = NULL; u32 module_size = 0; STMOD_HANDLER g_previous = NULL; +static inline int is_ef0(void) +{ + return psp_model == PSP_GO && sctrlKernelBootFrom() == 0x50 ? 1 : 0; +} + void mount_memory_stick(void) { int dfd; @@ -101,8 +106,10 @@ static void reboot_vsh_with_error(u32 error) int load_popsloader(void) { int fd; + char path[256]; - fd = sceIoOpen(BASE_PATH "popscore.prx", PSP_O_RDONLY, 0); + sprintf(path, "%s%s", is_ef0() ? "ef" : "ms", BASE_PATH "popscore.prx"); + fd = sceIoOpen(path, PSP_O_RDONLY, 0); if (fd < 0) { printk("%s: sceIoOpen@0x%08X\n", __func__, fd); @@ -131,20 +138,23 @@ int load_popsloader(void) int launch_pops(char *path) { struct SceKernelLoadExecVSHParam param; - int apitype; + int apitype, ret; const char *mode; - // TODO get PSPgo apitype (maybe 0x153) - apitype = 0x144; + apitype = is_ef0() ? 0x155: 0x144; mode = "pops"; + printk("%s: apitype 0x%X\n", __func__, apitype); + memset(¶m, 0, sizeof(param)); param.size = sizeof(param); param.args = strlen(path) + 1; param.argp = (char *) path; param.key = mode; - return sctrlKernelLoadExecVSHWithApitype(apitype, path, ¶m); + ret = sctrlKernelLoadExecVSHWithApitype(apitype, path, ¶m); + + return ret; } static char g_initfile[256]; @@ -199,8 +209,10 @@ static void get_target(int *type) int save_config(int type) { SceUID fd; + char path[256]; - fd = sceIoOpen(CFG_PATH, PSP_O_WRONLY | PSP_O_CREAT | PSP_O_TRUNC, 0777); + sprintf(path, "%s%s", is_ef0() ? "ef" : "ms", CFG_PATH); + fd = sceIoOpen(path, PSP_O_WRONLY | PSP_O_CREAT | PSP_O_TRUNC, 0777); if(fd < 0) { return fd; @@ -232,6 +244,11 @@ int loadexec_thread(SceSize args, void *argp) printk("init_file = %s\n", g_initfile); ret = launch_pops(g_initfile); printk("launch_pops -> 0x%08X\n", ret); + + if(ret < 0) { + reboot_vsh_with_error(ret); + } + ret = sceKernelStopUnloadSelfModule(0, NULL, &status, NULL); return 0;