Skip to content

Commit

Permalink
add irx loader
Browse files Browse the repository at this point in the history
  • Loading branch information
israpps committed Feb 27, 2024
1 parent 1d9d89f commit 8ac99ed
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 13 deletions.
1 change: 1 addition & 0 deletions Lang/ENG.LNG
Original file line number Diff line number Diff line change
Expand Up @@ -330,3 +330,4 @@ lang(328, change_timestamp_of, "change timestamp of:")
lang(329, title_cfg, "create title.cfg")
lang(329, Build_Info, "BuildInfo")
lang(330, Loading_Flash_Modules, "Loading Flash Modules...")
lang(331, This_file_isnt_an_IRX, "This file isn't an IRX")
1 change: 1 addition & 0 deletions Lang/SPA.LNG
Original file line number Diff line number Diff line change
Expand Up @@ -331,3 +331,4 @@ lang(328, change_timestamp_of, "cambiar fecha de:")
lang(329, title_cfg, "crear title.cfg")
lang(329, Build_Info, "BuildInfo")
lang(330, Loading_Flash_Modules, "Cargando modulos flash...")
lang(331, This_file_isnt_an_IRX, "Esto no es un driver IRX")
2 changes: 1 addition & 1 deletion include/launchelf.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ int IsSupportedFileType(char *path);
void loadFlashModules(void);

/* elf.c */
int checkELFheader(char *filename);
int checkELFheader(char *filename, int is_irx);
void RunLoaderElf(char *filename, char *);

/* draw.c */
Expand Down
11 changes: 9 additions & 2 deletions src/elf.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,15 @@ typedef struct
// Modified version of loader from Independence
// (C) 2003 Marcus R. Brown <mrbrown@0xd6.org>
//--------------------------------------------------------------
int checkELFheader(char *path)
/**
* @brief checks if path corresponds to an ELF file
* @param path path to the ELF file
* @param is_irx if we are looking for an IRX driver or EE ELF
* @return larger than 0 if success
*/
int checkELFheader(char *path, int is_irx)
{
u16 elftype = (is_irx)? 0xFF80 : 0x2;
elf_header_t elf_head;
u8 *boot_elf = (u8 *)&elf_head;
elf_header_t *eh = (elf_header_t *)boot_elf;
Expand Down Expand Up @@ -109,7 +116,7 @@ int checkELFheader(char *path)
genRead(fd, boot_elf, sizeof(elf_header_t));
genClose(fd);

if ((_lw((u32)&eh->ident) != ELF_MAGIC) || eh->type != 2)
if ((_lw((u32)&eh->ident) != ELF_MAGIC) || eh->type != elftype)
goto error;

return 1; //return 1 for successful check
Expand Down
10 changes: 8 additions & 2 deletions src/filer.c
Original file line number Diff line number Diff line change
Expand Up @@ -3611,6 +3611,8 @@ int setFileList(const char *path, const char *ext, FILEINFO *files, int cnfmode)
files[nfiles++].stats.AttrFile = sceMcFileAttrFile;
strcpy(files[nfiles].name, LNG(Load_CNF));
files[nfiles++].stats.AttrFile = sceMcFileAttrFile;
strcpy(files[nfiles].name, "Load_IRX");
files[nfiles++].stats.AttrFile = sceMcFileAttrFile;
//Next 2 lines add an optional font test routine
strcpy(files[nfiles].name, LNG(ShowFont));
files[nfiles++].stats.AttrFile = sceMcFileAttrFile;
Expand Down Expand Up @@ -3943,6 +3945,10 @@ int getFilePath(char *out, int cnfmode)
browser_pushed = FALSE;
sprintf(msg0, "%s.", LNG(This_file_isnt_an_ELF));
out[0] = 0;
} else if ( ((cnfmode == USBD_IRX_CNF) || (cnfmode == USBKBD_IRX_CNF) || (cnfmode == USBMASS_IRX_CNF))&&(checkELFheader(out, TRUE) < 0) ) {
browser_pushed = FALSE;
sprintf(msg0, "%s.", LNG(This_file_isnt_an_IRX));
out[0] = 0;
} else {
strcpy(LastDir, path);
rv = 1; //flag pathname selected
Expand All @@ -3964,7 +3970,7 @@ int getFilePath(char *out, int cnfmode)
//pushed R3 for a file (treat as uLE-related)
sprintf(out, "%s%s", path, files[browser_sel].name);
// Must to include a function for check IRX Header
if (((cnfmode == LK_ELF_CNF) || (cnfmode == NON_CNF)) && (checkELFheader(out) < 0)) {
if (((cnfmode == LK_ELF_CNF) || (cnfmode == NON_CNF)) && (checkELFheader(out, FALSE) < 0)) {
browser_pushed = FALSE;
sprintf(msg0, "%s.", LNG(This_file_isnt_an_ELF));
out[0] = 0;
Expand Down Expand Up @@ -4469,7 +4475,7 @@ int getFilePath(char *out, int cnfmode)
iconcolr = COLOR_GRAPH1;
} else {
iconbase = ICON_FILE;
if (genCmpFileExt(files[top + i].name, "ELF"))
if (genCmpFileExt(files[top + i].name, "ELF") || genCmpFileExt(files[top + i].name, "IRX"))
iconcolr = COLOR_GRAPH2;
else if (
genCmpFileExt(files[top + i].name, "TXT") ||
Expand Down
39 changes: 31 additions & 8 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1864,6 +1864,26 @@ static void Set_CNF_Path(void)
sprintf(mainMsg, "%s ", LNG(Bogus));
sprintf(mainMsg + 6, "%s = \"%s\"", LNG(CNF_Path), setting->CNF_Path);
}

static void load_irx_manual(void)
{
int id, ret;
char IRX_path[MAX_PATH] = "";
char *tmp;

if (getFilePath(IRX_path, USBKBD_IRX_CNF)>0)
return;
if (exists(IRX_path)) {
tmp = strrchr(IRX_path, '/');
if (tmp == NULL)
tmp = "IRX LOAD";
else
tmp++;
id = SifLoadStartModule(IRX_path, 0, NULL, &ret);
sprintf(mainMsg, "%s: id:%d, ret:%d (%s)", tmp, id, ret, (id>0 && ret != 1) ? LNG(OK) : LNG(Failed));
DPRINTF(mainMsg);
}
}
//------------------------------
//endfunc Set_CNF_Path
//---------------------------------------------------------------------------
Expand Down Expand Up @@ -2031,13 +2051,13 @@ int IsSupportedFileType(char *path)
if(strchr(path, ':') != NULL) {
if ((genCmpFileExt(path, "TXT") || genCmpFileExt(path, "CHT") || genCmpFileExt(path, "CFG") || genCmpFileExt(path, "INI") || genCmpFileExt(path, "CNF") ) || (genCmpFileExt(path, "JPG") || genCmpFileExt(path, "JPEG"))) return 1;
else if(genCmpFileExt(path, "IRX")) return 0;
else return(checkELFheader(path) >= 0);
else return(checkELFheader(path, FALSE) >= 0);
} else //No ':', hence no device name in path, which means it is a special action (e.g. MISC/*).
return 1;
#else
if (strchr(path, ':') != NULL) {
if (genCmpFileExt(path, "ELF")) {
return (checkELFheader(path) >= 0);
return (checkELFheader(path, FALSE) >= 0);
} else if ((genCmpFileExt(path, "TXT") || genCmpFileExt(path, "CHT") || genCmpFileExt(path, "CFG") || genCmpFileExt(path, "INI") || genCmpFileExt(path, "CNF") ) || (genCmpFileExt(path, "JPG") || genCmpFileExt(path, "JPEG"))) {
return 1;
} else
Expand Down Expand Up @@ -2080,7 +2100,7 @@ static void Execute(char *pathin)
goto CheckELF_path;
strcpy(fullpath, "mc0:");
strcat(fullpath, path + 3);
if (checkELFheader(fullpath) > 0)
if (checkELFheader(fullpath, FALSE) > 0)
goto ELFchecked;
fullpath[2] = '1';
goto CheckELF_fullpath;
Expand All @@ -2092,7 +2112,7 @@ static void Execute(char *pathin)
goto CheckELF_path;
} else if (!strncmp(path, "hdd0:/", 6)) {
loadHddModules();
if ((t = checkELFheader(path)) <= 0)
if ((t = checkELFheader(path, FALSE)) <= 0)
goto ELFnotFound;
//coming here means the ELF is fine
sprintf(party, "hdd0:%s", path + 6);
Expand All @@ -2103,7 +2123,7 @@ static void Execute(char *pathin)
#ifdef DVRP
} else if (!strncmp(path, "dvr_hdd0:/", 10)) {
loadDVRPHddModules();
if ((t = checkELFheader(path)) <= 0)
if ((t = checkELFheader(path, FALSE)) <= 0)
goto ELFnotFound;
//coming here means the ELF is fine
sprintf(party, "dvr_hdd0:%s", path + 10);
Expand All @@ -2115,13 +2135,13 @@ static void Execute(char *pathin)
#ifdef XFROM
} else if (!strncmp(path, "xfrom:/", 7)) {
loadFlashModules();
if ((t = checkELFheader(path)) <= 0)
if ((t = checkELFheader(path, FALSE)) <= 0)
goto ELFnotFound;
strcpy(fullpath, path);
goto ELFchecked;
#endif
} else if (!strncmp(path, "mass", 4)) {
if ((t = checkELFheader(path)) <= 0)
if ((t = checkELFheader(path, FALSE)) <= 0)
goto ELFnotFound;
//coming here means the ELF is fine
party[0] = 0;
Expand Down Expand Up @@ -2395,6 +2415,9 @@ static void Execute(char *pathin)
}
Show_build_info();
return;
} else if (!stricmp(path, "Load_IRX")) {
load_irx_manual();
return;
#ifndef SUPPORT_SYSTEM_2X6
} else if (!strncmp(path, "cdfs", 4)) {
CDVD_FlushCache();
Expand All @@ -2407,7 +2430,7 @@ static void Execute(char *pathin)
CheckELF_path:
strcpy(fullpath, path);
CheckELF_fullpath:
if ((t = checkELFheader(fullpath)) <= 0)
if ((t = checkELFheader(fullpath, FALSE)) <= 0)
goto ELFnotFound;
ELFchecked:
CleanUp();
Expand Down

0 comments on commit 8ac99ed

Please sign in to comment.