Skip to content

Commit

Permalink
Initial xfrom0: support
Browse files Browse the repository at this point in the history
  • Loading branch information
uyjulian committed Dec 8, 2023
1 parent 97d4894 commit b17d3e4
Show file tree
Hide file tree
Showing 6 changed files with 118 additions and 11 deletions.
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,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 bdm_irx.o bdmfs_fatfs_irx.o usbmass_bd_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 @@ -78,6 +79,12 @@ $(EE_ASM_DIR)dvrdrv_irx.s: $(PS2SDK)/iop/irx/dvrdrv.irx | $(EE_ASM_DIR)
$(EE_ASM_DIR)dvrfile_irx.s: $(PS2SDK)/iop/irx/dvrfile.irx | $(EE_ASM_DIR)
$(BIN2S) $< $@ dvrfile_irx

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

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

$(EE_ASM_DIR)usbd_irx.s: $(PS2SDK)/iop/irx/usbd.irx | $(EE_ASM_DIR)
$(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 @@ -832,7 +832,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 @@ -1233,6 +1233,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;

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
memcpy((char *)info[i].stats.EntryName, info[i].name, 32);
info[i].stats.EntryName[sizeof(info[i].stats.EntryName) - 1] = 0;
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 @@ -1468,6 +1514,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 @@ -1656,7 +1704,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 @@ -1668,12 +1716,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 @@ -2640,10 +2688,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 @@ -3270,6 +3318,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 @@ -4430,7 +4480,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 @@ -4442,7 +4492,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 @@ -213,6 +213,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
49 changes: 48 additions & 1 deletion main.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,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 @@ -122,6 +126,7 @@ char netConfig[IPCONF_MAX_LEN + 128]; // 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 All @@ -139,6 +144,8 @@ static u8 have_ps2ip = 0;
static u8 have_ps2atad = 0;
static u8 have_ps2hdd = 0;
static u8 have_ps2fs = 0;
static u8 have_extflash = 0;
static u8 have_xfromman = 0;
static u8 have_ps2netfs = 0;
static u8 have_smbman = 0;
static u8 have_vmc_fs = 0;
Expand Down Expand Up @@ -757,6 +764,25 @@ static void load_ps2atad(void)
//------------------------------
// endfunc load_ps2atad
//---------------------------------------------------------------------------
static void load_pflash(void)
{
load_ps2dev9();
if (!is_early_init) // Do not draw any text before the UI is initialized.
drawMsg("Loading extflash");
if (!have_extflash) {
SifExecModuleBuffer(extflash_irx, size_extflash_irx, 0, NULL, NULL);
have_extflash = 1;
}
if (!is_early_init) // Do not draw any text before the UI is initialized.
drawMsg("Loading xfromman");
if (!have_xfromman) {
SifExecModuleBuffer(xfromman_irx, size_xfromman_irx, 0, NULL, NULL);
have_xfromman = 1;
}
}
//------------------------------
// endfunc load_pflash
//---------------------------------------------------------------------------
void load_ps2host(void)
{
int ret;
Expand Down Expand Up @@ -1308,6 +1334,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 @@ -1806,7 +1845,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 @@ -2124,9 +2168,12 @@ static void Reset()
have_ps2kbd = 0;
have_dvrdrv = 0;
have_dvrfile = 0;
have_extflash = 0;
have_xfromman = 0;
have_NetModules = 0;
have_HDD_modules = 0;
have_DVRP_HDD_modules = 0;
have_Flash_modules = 0;

loadBasicModules();
loadCdModules();
Expand Down

0 comments on commit b17d3e4

Please sign in to comment.