Skip to content

Commit

Permalink
added pspgo support, but it doesn't work yet
Browse files Browse the repository at this point in the history
  • Loading branch information
hrimfaxi committed Jun 25, 2011
1 parent 6e5ace8 commit 7ccc0de
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 17 deletions.
2 changes: 1 addition & 1 deletion popsloader/common/popsloader.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
21 changes: 14 additions & 7 deletions popsloader/core/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 0 additions & 3 deletions popsloader/core/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -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, }
Expand Down
29 changes: 23 additions & 6 deletions popsloader/loader/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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(&param, 0, sizeof(param));
param.size = sizeof(param);
param.args = strlen(path) + 1;
param.argp = (char *) path;
param.key = mode;

return sctrlKernelLoadExecVSHWithApitype(apitype, path, &param);
ret = sctrlKernelLoadExecVSHWithApitype(apitype, path, &param);

return ret;
}

static char g_initfile[256];
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 7ccc0de

Please sign in to comment.