Skip to content

Commit

Permalink
Initial xfrom0: support
Browse files Browse the repository at this point in the history
  • Loading branch information
uyjulian committed May 5, 2022
1 parent 4ba8506 commit dbf1f6e
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 11 deletions.
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ EE_BIN_PKD = BOOT.ELF
EE_OBJS = main.o pad.o config.o elf.o draw.o loader_elf.o filer.o \
poweroff_irx.o iomanx_irx.o filexio_irx.o ps2atad_irx.o ps2dev9_irx.o ps2ip_irx.o netman_irx.o \
ps2smap_irx.o ps2hdd_irx.o ps2fs_irx.o ps2netfs_irx.o usbd_irx.o usbhdfsd_irx.o mcman_irx.o mcserv_irx.o\
extflash_irx.o xfromman_irx.o \
dvrdrv_irx.o dvrfile_irx.o \
cdfs_irx.o ps2ftpd_irx.o ps2host_irx.o vmc_fs_irx.o ps2kbd_irx.o\
hdd.o hdl_rpc.o hdl_info_irx.o editor.o timer.o jpgviewer.o icon.o lang.o\
Expand Down Expand Up @@ -67,6 +68,12 @@ dvrdrv_irx.s: $(PS2SDK)/iop/irx/dvrdrv.irx
dvrfile_irx.s: $(PS2SDK)/iop/irx/dvrfile.irx
$(BIN2S) $< $@ dvrfile_irx

extflash_irx.s: $(PS2SDK)/iop/irx/extflash.irx
$(BIN2S) $< $@ extflash_irx

xfromman_irx.s: $(PS2SDK)/iop/irx/xfromman.irx
$(BIN2S) $< $@ xfromman_irx

usbd_irx.s: $(PS2SDK)/iop/irx/usbd.irx
$(BIN2S) $< $@ usbd_irx

Expand Down
2 changes: 1 addition & 1 deletion elf.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ int checkELFheader(char *path)
char fullpath[MAX_PATH], tmp[MAX_PATH], *p;

strcpy(fullpath, path);
if (!strncmp(fullpath, "mc", 2) || !strncmp(fullpath, "vmc", 3) || !strncmp(fullpath, "rom", 3) || !strncmp(fullpath, "cdrom", 5) || !strncmp(fullpath, "cdfs", 4)) {
if (!strncmp(fullpath, "mc", 2) || !strncmp(fullpath, "vmc", 3) || !strncmp(fullpath, "rom", 3) || !strncmp(fullpath, "cdrom", 5) || !strncmp(fullpath, "cdfs", 4) || !strncmp(fullpath, "xfrom", 5)) {
; // fullpath is already correct
} else if (!strncmp(fullpath, "hdd0:", 5)) {
p = &path[5];
Expand Down
68 changes: 59 additions & 9 deletions filer.c
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,7 @@ void genLimObjName(char *uLE_path, int reserve)
int folder_flag = (uLE_path[strlen(uLE_path) - 1] == '/'); // flag folder object
int overflow;

if (!strncmp(uLE_path, "mc", 2) || !strncmp(uLE_path, "vmc", 3))
if (!strncmp(uLE_path, "mc", 2) || !strncmp(uLE_path, "vmc", 3) || !strncmp(uLE_path, "xfrom", 5))
limit = 32; // enforce MC limit of 32 characters

if (folder_flag) // if path ends with path separator
Expand Down Expand Up @@ -1211,6 +1211,52 @@ int readHDDDVRP(const char *path, FILEINFO *info, int max)
//------------------------------
// endfunc readHDDDVRP
//--------------------------------------------------------------
int readXFROM(const char *path, FILEINFO *info, int max)
{
iox_dirent_t dirbuf;
char dir[MAX_PATH];
int i = 0, fd;
volatile int j;

loadFlashModules();

strcpy(dir, path);
if ((fd = fileXioDopen(path)) < 0)
return 0;

while (fileXioDread(fd, &dirbuf) > 0) {
if (dirbuf.stat.mode & FIO_S_IFDIR &&
(!strcmp(dirbuf.name, ".") || !strcmp(dirbuf.name, "..")))
continue; // Skip pseudopaths "." and ".."

strcpy(info[i].name, dirbuf.name);
clear_mcTable(&info[i].stats);
if (dirbuf.stat.mode & FIO_S_IFDIR) {
info[i].stats.AttrFile = MC_ATTR_norm_folder;
} else if (dirbuf.stat.mode & FIO_S_IFREG) {
info[i].stats.AttrFile = MC_ATTR_norm_file;
info[i].stats.FileSizeByte = dirbuf.stat.size;
info[i].stats.Reserve2 = dirbuf.stat.hisize;
} else
continue; // Skip entry which is neither a file nor a folder
strncpy((char *)info[i].stats.EntryName, info[i].name, 32);
memcpy((void *)&info[i].stats._Create, dirbuf.stat.ctime, 8);
memcpy((void *)&info[i].stats._Modify, dirbuf.stat.mtime, 8);
i++;
if (i == max)
break;
}

fileXioDclose(fd);

size_valid = 1;
time_valid = 1;

return i;
}
//------------------------------
// endfunc readXFROM
//--------------------------------------------------------------
void scan_USB_mass(void)
{
int i;
Expand Down Expand Up @@ -1438,6 +1484,8 @@ int getDir(const char *path, FILEINFO *info)
n = readHOST(path, info, max);
else if (!strncmp(path, "vmc", 3))
n = readVMC(path, info, max);
else if (!strncmp(path, "xfrom", 5))
n = readXFROM(path, info, max);
else
return 0;

Expand Down Expand Up @@ -1626,7 +1674,7 @@ int menu(const char *path, FILEINFO *file)
enable[RENAME] = FALSE;
}

if ((file->stats.AttrFile & sceMcFileAttrSubdir) || !strncmp(path, "vmc", 3) || !strncmp(path, "mc", 2)) {
if ((file->stats.AttrFile & sceMcFileAttrSubdir) || !strncmp(path, "vmc", 3) || !strncmp(path, "mc", 2) || !strncmp(path, "xfrom", 5)) {
enable[MOUNTVMC0] = FALSE; // forbid insane VMC mounting
enable[MOUNTVMC1] = FALSE; // forbid insane VMC mounting
}
Expand All @@ -1638,12 +1686,12 @@ int menu(const char *path, FILEINFO *file)
enable[PSUPASTE] = FALSE;
} else {
// Something in clipboard
if (!strncmp(path, "mc", 2) || !strncmp(path, "vmc", 3)) {
if (!strncmp(clipPath, "mc", 2) || !strncmp(clipPath, "vmc", 3)) {
if (!strncmp(path, "mc", 2) || !strncmp(path, "vmc", 3) || !strncmp(path, "xfrom", 5)) {
if (!strncmp(clipPath, "mc", 2) || !strncmp(clipPath, "vmc", 3) || !strncmp(clipPath, "xfrom", 5)) {
enable[MCPASTE] = FALSE; // No mcPaste if both src and dest are MC
enable[PSUPASTE] = FALSE;
}
} else if (strncmp(clipPath, "mc", 2) && strncmp(clipPath, "vmc", 3)) {
} else if (strncmp(clipPath, "mc", 2) && strncmp(clipPath, "vmc", 3) && strncmp(clipPath, "xfrom", 5)) {
enable[MCPASTE] = FALSE; // No mcPaste if both src and dest non-MC
enable[PSUPASTE] = FALSE;
}
Expand Down Expand Up @@ -2608,10 +2656,10 @@ int copy(char *outPath, const char *inPath, FILEINFO file, int recurses)
To prevent a loss in performance, these values must each be in a multiple of the device's sector/page size.
They must also be in multiples of 64, to prevent FILEIO from doing alignment correction in software. */
buffSize = 0x100000; // First assume buffer size = 1MB (good for HDD)
if (!strncmp(out, "mc", 2) || !strncmp(out, "mass", 4) || !strncmp(out, "vmc", 3))
if (!strncmp(out, "mc", 2) || !strncmp(out, "mass", 4) || !strncmp(out, "vmc", 3) || !strncmp(out, "xfrom", 5))
buffSize = 131072; // Use 128KB if writing to USB (Flash RAM writes) or MC (pretty slow).
// VMC contents should use the same size, as VMCs will often be stored on USB
else if (!strncmp(in, "mc", 2))
else if (!strncmp(in, "mc", 2) || !strncmp(in, "xfrom", 5))
buffSize = 262144; // Use 256KB if reading from MC (still pretty slow)
else if (!strncmp(out, "host", 4))
buffSize = 393216; // Use 384KB if writing to HOST (acceptable)
Expand Down Expand Up @@ -3238,6 +3286,8 @@ int setFileList(const char *path, const char *ext, FILEINFO *files, int cnfmode)
files[nfiles++].stats.AttrFile = sceMcFileAttrSubdir;
strcpy(files[nfiles].name, "mc1:");
files[nfiles++].stats.AttrFile = sceMcFileAttrSubdir;
strcpy(files[nfiles].name, "xfrom0:");
files[nfiles++].stats.AttrFile = sceMcFileAttrSubdir;
strcpy(files[nfiles].name, "hdd0:");
files[nfiles++].stats.AttrFile = sceMcFileAttrSubdir;
strcpy(files[nfiles].name, "dvr_hdd0:");
Expand Down Expand Up @@ -4395,7 +4445,7 @@ void submenu_func_Paste(char *mess, char *path)
//--------------------------------------------------------------
void submenu_func_mcPaste(char *mess, char *path)
{
if (!strncmp(path, "mc", 2) || !strncmp(path, "vmc", 3)) {
if (!strncmp(path, "mc", 2) || !strncmp(path, "vmc", 3) || !strncmp(path, "xfrom", 5)) {
PasteMode = PM_MC_RESTORE;
} else {
PasteMode = PM_MC_BACKUP;
Expand All @@ -4407,7 +4457,7 @@ void submenu_func_mcPaste(char *mess, char *path)
//--------------------------------------------------------------
void submenu_func_psuPaste(char *mess, char *path)
{
if (!strncmp(path, "mc", 2) || !strncmp(path, "vmc", 3)) {
if (!strncmp(path, "mc", 2) || !strncmp(path, "vmc", 3) || !strncmp(path, "xfrom", 5)) {
PasteMode = PM_PSU_RESTORE;
} else {
PasteMode = PM_PSU_BACKUP;
Expand Down
2 changes: 2 additions & 0 deletions lang.h
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,8 @@ lang(325, Unload_HDL_Game_Info, "Unload HDL Game Info")
//---------------------------------------------------------------------------
// New status message for HDD information read, when there are too many partitions.
lang(326, HDD_Information_Read_Overflow, "HDD Information Read (truncated)")
//---------------------------------------------------------------------------
lang(327, Loading_Flash_Modules, "Loading Flash Modules...")

// clang-format on
//---------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions launchelf.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ void load_vmc_fs(void);
void load_ps2host(void);
void loadHddModules(void);
void loadDVRPHddModules(void);
void loadFlashModules(void);
void loadHdlInfoModule(void);
int uLE_related(char *pathout, const char *pathin);
int uLE_InitializeRegion(void);
Expand Down
34 changes: 33 additions & 1 deletion main.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ extern u8 dvrdrv_irx[];
extern int size_dvrdrv_irx;
extern u8 dvrfile_irx[];
extern int size_dvrfile_irx;
extern u8 extflash_irx[];
extern int size_extflash_irx;
extern u8 xfromman_irx[];
extern int size_xfromman_irx;

//#define DEBUG
#ifdef DEBUG
Expand Down Expand Up @@ -116,6 +120,7 @@ char netConfig[IPCONF_MAX_LEN + 64]; // Adjust size as needed
static u8 have_NetModules = 0;
static u8 have_HDD_modules = 0;
static u8 have_DVRP_HDD_modules = 0;
static u8 have_Flash_modules = 0;
// State of Uncheckable Modules (invalid header)
static u8 have_cdvd = 0;
static u8 have_usbd = 0;
Expand Down Expand Up @@ -743,6 +748,14 @@ static void load_ps2atad(void)
//------------------------------
// endfunc load_ps2atad
//---------------------------------------------------------------------------
static void load_pflash(void)
{
SifExecModuleBuffer(extflash_irx, size_extflash_irx, 0, NULL, NULL);
SifExecModuleBuffer(xfromman_irx, size_xfromman_irx, 0, NULL, NULL);
}
//------------------------------
// endfunc load_pflash
//---------------------------------------------------------------------------
void load_ps2host(void)
{
int ret;
Expand Down Expand Up @@ -1285,6 +1298,19 @@ void loadDVRPHddModules(void)
//------------------------------
// endfunc loadDVRPHddModules
//---------------------------------------------------------------------------
void loadFlashModules(void)
{
if (!have_Flash_modules) {
if (!is_early_init) // Do not draw any text before the UI is initialized.
drawMsg(LNG(Loading_Flash_Modules));
setupPowerOff();
load_pflash();
have_Flash_modules = TRUE;
}
}
//------------------------------
// endfunc loadFlashModules
//---------------------------------------------------------------------------
// Load Network modules by EP (modified by RA)
//------------------------------
static void loadNetModules(void)
Expand Down Expand Up @@ -1781,7 +1807,12 @@ static void Execute(char *pathin)
sprintf(fullpath, "dvr_pfs0:%s", p);
*p = 0;
goto ELFchecked;

} else if (!strncmp(path, "xfrom", 5)) {
loadFlashModules();
if ((t = checkELFheader(path)) <= 0)
goto ELFnotFound;
strcpy(fullpath, path);
goto ELFchecked;
} else if (!strncmp(path, "mass", 4)) {
if ((t = checkELFheader(path)) <= 0)
goto ELFnotFound;
Expand Down Expand Up @@ -2104,6 +2135,7 @@ static void Reset()
have_NetModules = 0;
have_HDD_modules = 0;
have_DVRP_HDD_modules = 0;
have_Flash_modules = 0;

loadBasicModules();
loadCdModules();
Expand Down

0 comments on commit dbf1f6e

Please sign in to comment.