From 0068bcdb862ef53fcf54bd2d6d4f89f76f6e81bd Mon Sep 17 00:00:00 2001 From: israpps Date: Fri, 21 Jan 2022 00:03:15 -0300 Subject: [PATCH] make ethernet features modular --- Makefile | 13 ++++++++++--- filer.c | 56 +++++++++++++++++++++++++++++++++++++++++++++-------- launchelf.h | 4 ++++ main.c | 44 ++++++++++++++++++++++++++++++++++++----- 4 files changed, 101 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index 0a6585b..2754d55 100644 --- a/Makefile +++ b/Makefile @@ -6,15 +6,21 @@ SMB = 0 EE_BIN = ULE_ISR_HDD-UNC.ELF EE_BIN_PKD = ULE_ISR_HDD.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\ + poweroff_irx.o iomanx_irx.o filexio_irx.o ps2atad_irx.o ps2dev9_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\ 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\ font_uLE.o makeicon.o chkesr.o sior_irx.o allowdvdv_irx.o OSD/hddosd-headers.o + ifeq ($(SMB),1) EE_OBJS += smbman.o endif +ifeq ($(ETH),1) + EE_OBJS += ps2ip_irx.o + EE_CFLAGS += -DETH +endif + EE_INCS := -I$(PS2DEV)/gsKit/include -I$(PS2SDK)/ports/include EE_LDFLAGS := -L$(PS2DEV)/gsKit/lib -L$(PS2SDK)/ports/lib -s @@ -27,7 +33,7 @@ ifeq ($(SMB),1) endif ifeq ($(TMANIP),1) - EE_CFLAGS += -DTMANIP + EE_CFLAGS += -DTMANIP endif ifeq ($(TMANIP),2) @@ -90,9 +96,10 @@ filexio_irx.s: $(PS2SDK)/iop/irx/fileXio.irx ps2dev9_irx.s: $(PS2SDK)/iop/irx/ps2dev9.irx $(BIN2S) $< $@ ps2dev9_irx +ifeq ($(ETH),1) ps2ip_irx.s: $(PS2SDK)/iop/irx/ps2ip.irx $(BIN2S) $< $@ ps2ip_irx - +endif ps2smap_irx.s: $(PS2DEV)/ps2eth/smap/ps2smap.irx $(BIN2S) $< $@ ps2smap_irx diff --git a/filer.c b/filer.c index 75388c5..1c805e8 100644 --- a/filer.c +++ b/filer.c @@ -111,12 +111,12 @@ char cnfmode_extL[CNFMODE_CNT][4] = { "fnt", // cnfmode FONT_CNF "*" // cnfmode SAVE_CNF }; - +#ifdef ETH int host_ready = 0; int host_error = 0; int host_elflist = 0; int host_use_Bsl = 1; //By default assume that host paths use backslash - +#endif unsigned long written_size; //Used for pasting progress report u64 PasteTime; //Used for pasting progress report @@ -1076,6 +1076,7 @@ int readMASS(const char *path, FILEINFO *info, int max) //------------------------------ //endfunc readMASS //-------------------------------------------------------------- +#ifdef ETH char *makeHostPath(char *dp, char *sp) { int i; @@ -1095,6 +1096,7 @@ char *makeHostPath(char *dp, char *sp) } return dp; } +#endif //-------------------------------------------------------------- char *makeFslPath(char *dp, char *sp) { @@ -1113,6 +1115,7 @@ char *makeFslPath(char *dp, char *sp) return dp; } //-------------------------------------------------------------- +#ifdef ETH void initHOST(void) { int fd; @@ -1215,6 +1218,7 @@ int readHOST(const char *path, FILEINFO *info, int max) strcpy(info[hostcount].name, "\0"); return hostcount; } +#endif //------------------------------ //endfunc readHOST //-------------------------------------------------------------- @@ -1231,8 +1235,10 @@ int getDir(const char *path, FILEINFO *info) n = readMASS(path, info, max); else if (!strncmp(path, "cdfs", 4)) n = readCD(path, info, max); +#ifdef ETH else if (!strncmp(path, "host", 4)) n = readHOST(path, info, max); +#endif else if (!strncmp(path, "vmc", 3)) n = readVMC(path, info, max); else @@ -1379,10 +1385,13 @@ int menu(const char *path, FILEINFO *file) //identify cases where write access is illegal, and disable menu items accordingly if ((!strncmp(path, "cdfs", 4)) //Writing is always illegal for CDVD drive +#ifdef ETH || ((!strncmp(path, "host", 4)) //host: has special cases && ((!setting->HOSTwrite) //host: Writing is illegal if not enabled in CNF || (host_elflist && !strcmp(path, "host:/")) //it's also illegal in elflist.txt - ))) + )) +#endif + ) write_disabled = 1; if (!strcmp(path, "hdd0:/") || path[0] == 0) //No menu cmds in partition/device lists @@ -1721,9 +1730,10 @@ u64 getFileSize(const char *path, const FILEINFO *file) dir[3] = ret + '0'; } else sprintf(dir, "%s%s", path, file->name); +#ifdef ETH if (!strncmp(dir, "host:/", 6)) makeHostPath(dir + 5, dir + 6); - +#endif fileXioGetStat(dir, &stat); size = stat.size; } @@ -1790,9 +1800,10 @@ int delete (const char *path, const FILEINFO *file) } sprintf(dir, "%s%s", path, file->name); genLimObjName(dir, 0); +#ifdef ETH if (!strncmp(dir, "host:/", 6)) makeHostPath(dir + 5, dir + 6); - +#endif if (file->stats.AttrFile & sceMcFileAttrSubdir) { //Is the object to delete a folder ? strcat(dir, "/"); nfiles = getDir(dir, files); @@ -1878,6 +1889,7 @@ int Rename(const char *path, const FILEINFO *file, const char *name) ret = -EEXIST; } } +#ifdef ETH } else if (!strncmp(path, "host", 4)) { int temp_fd; @@ -1901,6 +1913,7 @@ int Rename(const char *path, const FILEINFO *file, const char *name) } } else //This was neither a folder nor a file !!! return -1; +#endif } else { //For all other devices sprintf(oldPath, "%s%s", path, file->name); sprintf(newPath, "%s%s", path, name); @@ -1947,8 +1960,10 @@ int newdir(const char *path, const char *name) strcpy(dir, path); strcat(dir, name); genLimObjName(dir, 0); +#ifdef ETH if (!strncmp(dir, "host:/", 6)) makeHostPath(dir + 5, dir + 6); +#endif if ((ret = fileXioDopen(dir)) >= 0) { fileXioDclose(ret); ret = -EEXIST; //return fileXio error code for pre-existing folder @@ -2074,10 +2089,10 @@ int copy(char *outPath, const char *inPath, FILEINFO file, int recurses) genLimObjName(tmp, 4); //Limit name to leave room for 4 characters more strcat(tmp, ".psu"); //add the PSU file extension - +#ifdef ETH if (!strncmp(tmp, "host:/", 6)) makeHostPath(tmp + 5, tmp + 6); - +#endif if (setting->PSU_DateNames && setting->PSU_NoOverwrite) { if (0 <= (out_fd = genOpen(tmp, O_RDONLY))) { //Name conflict ? genClose(out_fd); @@ -2167,9 +2182,10 @@ int copy(char *outPath, const char *inPath, FILEINFO file, int recurses) } } else if (PasteMode == PM_MC_RESTORE) { //MC Restore mode folder paste preparation sprintf(tmp, "%s/PS2_MC_Backup_Attributes.BUP.bin", in); - +#ifdef ETH if (!strncmp(tmp, "host:/", 6)) makeHostPath(tmp + 5, tmp + 6); +#endif in_fd = genOpen(tmp, O_RDONLY); if (in_fd >= 0) { @@ -2293,21 +2309,29 @@ int copy(char *outPath, const char *inPath, FILEINFO file, int recurses) ret = MC_SFI; //default request for changing entire mcTable if (strncmp(in, "mc", 2)) { //Handle file copied from non-MC to MC file.stats.AttrFile = MC_ATTR_norm_folder; //normalize MC folder attribute +#ifdef ETH if (!strncmp(in, "host", 4)) { //Handle folder copied from host: to MC ret = 4; //request change only of main attribute for host: } //ends host: source clause } //ends non-MC source clause +#endif mcSetFileInfo(out[2] - '0', 0, &out[4], &file.stats, ret); mcSync(0, NULL, &dummy); } else { //Handle folder copied to non-MC +#ifdef ETH if (!strncmp(out, "host", 4)) { //for files copied to host: we skip Chstat } else if (!strncmp(out, "mass", 4)) { //for files copied to mass: we skip Chstat +#else + if (!strncmp(out, "mass", 4)) { +#endif } else { //for other devices we use fileXio_ stuff memcpy(iox_stat.ctime, (void *)&file.stats._Create, 8); memcpy(iox_stat.mtime, (void *)&file.stats._Modify, 8); memcpy(iox_stat.atime, iox_stat.mtime, 8); ret = FIO_CST_CT | FIO_CST_AT | FIO_CST_MT; //Request timestamp stat change +#ifdef ETH if (!strncmp(in, "host", 4)) { //Handle folder copied from host: +#endif ret = 0; //Request NO stat change } dummy = fileXioChStat(out, &iox_stat, ret); @@ -2372,8 +2396,10 @@ int copy(char *outPath, const char *inPath, FILEINFO file, int recurses) in_fd = PM_file[recurses]; size = mcT_head_p->size; } else { //Any other mode than PM_PSU_RESTORE +#ifdef ETH if (!strncmp(in, "host:/", 6)) makeHostPath(in + 5, in + 6); +#endif in_fd = genOpen(in, O_RDONLY); if (in_fd < 0) goto copy_file_exit; @@ -2399,8 +2425,10 @@ int copy(char *outPath, const char *inPath, FILEINFO file, int recurses) psu_pad_size = 0; PSU_content++; //Increase PSU content header count } else { //Any other PasteMode than PM_PSU_BACKUP needs a new output file +#ifdef ETH if (!strncmp(out, "host:/", 6)) makeHostPath(out + 5, out + 6); +#endif genLimObjName(out, 0); //Limit dest file name genRemove(out); //Remove old file if present out_fd = genOpen(out, O_WRONLY | O_TRUNC | O_CREAT); //Create new file @@ -2420,8 +2448,10 @@ int copy(char *outPath, const char *inPath, FILEINFO file, int recurses) //VMC contents should use the same size, as VMCs will often be stored on USB else if (!strncmp(in, "mc", 2)) buffSize = 262144; //Use 256KB if reading from MC (still pretty slow) +#ifdef ETH else if (!strncmp(out, "host", 4)) buffSize = 393216; //Use 384KB if writing to HOST (acceptable) +#endif else if ((!strncmp(in, "mass", 4)) || (!strncmp(in, "host", 4))) buffSize = 524288; //Use 512KB reading from USB or HOST (acceptable) @@ -2575,9 +2605,11 @@ int copy(char *outPath, const char *inPath, FILEINFO file, int recurses) ret = MC_SFI; //default request for changing entire mcTable if (strncmp(in, "mc", 2)) { //Handle file copied from non-MC to MC file.stats.AttrFile = MC_ATTR_norm_file; //normalize MC file attribute +#ifdef ETH if (!strncmp(in, "host", 4)) { //Handle folder copied from host: to MC ret = 4; //request change only of main attribute for host: } //ends host: source clause +#endif } //ends non-MC source clause if (mctype_PSx == 2) { //if copying to a PS2 MC mcSetFileInfo(out[2] - '0', 0, &out[4], &file.stats, ret); @@ -2591,9 +2623,11 @@ int copy(char *outPath, const char *inPath, FILEINFO file, int recurses) memcpy(iox_stat.mtime, (void *)&file.stats._Modify, 8); memcpy(iox_stat.atime, iox_stat.mtime, 8); ret = FIO_CST_CT | FIO_CST_AT | FIO_CST_MT; //Request timestamp stat change +#ifdef ETH if (!strncmp(in, "host", 4)) { //Handle file copied from host: ret = 0; //Request NO stat change } +#endif dummy = fileXioChStat(out, &iox_stat, ret); } } @@ -3066,8 +3100,10 @@ int setFileList(const char *path, const char *ext, FILEINFO *files, int cnfmode) if (!cnfmode || (cnfmode == JPG_CNF)) { //This condition blocks selecting any CONFIG items on PC //or in a virtual memory card +#ifdef ETH strcpy(files[nfiles].name, "host:"); files[nfiles++].stats.AttrFile = sceMcFileAttrSubdir; +#endif if (vmcMounted[0]) { strcpy(files[nfiles].name, "vmc0:"); files[nfiles++].stats.AttrFile = sceMcFileAttrSubdir; @@ -3101,8 +3137,10 @@ int setFileList(const char *path, const char *ext, FILEINFO *files, int cnfmode) files[nfiles++].stats.AttrFile = sceMcFileAttrFile; strcpy(files[nfiles].name, LNG(PS2Disc)); files[nfiles++].stats.AttrFile = sceMcFileAttrFile; +#ifdef ETH strcpy(files[nfiles].name, LNG(PS2Net)); files[nfiles++].stats.AttrFile = sceMcFileAttrFile; +#endif strcpy(files[nfiles].name, LNG(PS2PowerOff)); files[nfiles++].stats.AttrFile = sceMcFileAttrFile; strcpy(files[nfiles].name, LNG(HddManager)); @@ -3686,9 +3724,11 @@ int getFilePath(char *out, int cnfmode) } j = genFixPath(path, tmp1); strcpy(tmp2, tmp1); +#ifdef ETH if (!strncmp(path, "host:", 5)) { makeHostPath(tmp2, tmp1); } +#endif strcat(tmp2, files[browser_sel].name); if ((x = fileXioMount(tmp, tmp2, FIO_MT_RDWR)) >= 0) { if ((j >= 0) && (j < MOUNT_LIMIT)) { diff --git a/launchelf.h b/launchelf.h index 916c86d..f9bb019 100644 --- a/launchelf.h +++ b/launchelf.h @@ -216,7 +216,9 @@ extern int GUI_active; // Skin and Main Skin switch extern int cdmode; //Last detected disc type void load_vmc_fs(void); +#ifdef ETH void load_ps2host(void); +#endif void loadHddModules(void); void loadHdlInfoModule(void); int uLE_related(char *pathout, const char *pathin); @@ -340,7 +342,9 @@ extern int nparties; //Clearing this causes FileBrowser to r extern unsigned char *elisaFnt; char *PathPad_menu(const char *path); int getFilePath(char *out, const int cnfmode); +#ifdef ETH void initHOST(void); +#endif char *makeHostPath(char *dp, char *sp); int ynDialog(const char *message); void nonDialog(char *message); diff --git a/main.c b/main.c index 4abd751..0afe5d5 100644 --- a/main.c +++ b/main.c @@ -13,12 +13,16 @@ extern u8 filexio_irx[]; extern int size_filexio_irx; extern u8 ps2dev9_irx[]; extern int size_ps2dev9_irx; +#ifdef ETH extern u8 ps2ip_irx[]; extern int size_ps2ip_irx; +#endif extern u8 ps2smap_irx[]; extern int size_ps2smap_irx; +#ifdef ETH extern u8 ps2host_irx[]; extern int size_ps2host_irx; +#endif #ifdef SMB extern u8 smbman_irx[]; extern int size_smbman_irx; @@ -37,8 +41,10 @@ extern u8 poweroff_irx[]; extern int size_poweroff_irx; extern u8 loader_elf; extern int size_loader_elf; +#ifdef ETH extern u8 ps2netfs_irx[]; extern int size_ps2netfs_irx; +#endif extern u8 iopmod_irx[]; extern int size_iopmod_irx; extern u8 usbd_irx[]; @@ -114,18 +120,24 @@ static u8 have_cdvd = 0; static u8 have_usbd = 0; static u8 have_usb_mass = 0; static u8 have_ps2smap = 0; +#ifdef ETH static u8 have_ps2host = 0; static u8 have_ps2ftpd = 0; +#endif static u8 have_ps2kbd = 0; static u8 have_hdl_info = 0; //State of Checkable Modules (valid header) static u8 have_poweroff = 0; static u8 have_ps2dev9 = 0; +#ifdef ETH static u8 have_ps2ip = 0; +#endif static u8 have_ps2atad = 0; static u8 have_ps2hdd = 0; static u8 have_ps2fs = 0; +#ifdef ETH static u8 have_ps2netfs = 0; +#endif static u8 have_smbman = 0; static u8 have_vmc_fs = 0; //State of whether DEV9 was successfully loaded or not. @@ -200,14 +212,18 @@ static int drawMainScreen2(int TV_mode); static void delay(int count); static void initsbv_patches(void); static void load_ps2dev9(void); +#ifdef ETH static void load_ps2ip(void); +#endif static void load_ps2atad(void); #ifdef SMB static void load_smbman(void); #endif static void ShowDebugInfo(void); +#ifdef ETH static void load_ps2ftpd(void); static void load_ps2netfs(void); +#endif static void loadBasicModules(void); static void loadCdModules(void); static int loadExternalFile(char *argPath, void **fileBaseP, int *fileSizeP); @@ -218,7 +234,9 @@ static void loadKbdModules(void); static void closeAllAndPoweroff(void); static void poweroffHandler(int i); static void setupPowerOff(void); +#ifdef ETH static void loadNetModules(void); +#endif static void startKbd(void); static int scanSystemCnf(char *name, char *value); static int readSystemCnf(void); @@ -672,6 +690,7 @@ static void load_ps2dev9(void) //------------------------------ //endfunc load_ps2dev9 //--------------------------------------------------------------------------- +#ifdef ETH static void load_ps2ip(void) { int ret; @@ -687,6 +706,7 @@ static void load_ps2ip(void) have_ps2smap = 1; } } +#endif //------------------------------ //endfunc load_ps2ip //--------------------------------------------------------------------------- @@ -729,6 +749,7 @@ static void load_ps2atad(void) //------------------------------ //endfunc load_ps2atad //--------------------------------------------------------------------------- +#ifdef ETH void load_ps2host(void) { int ret; @@ -740,6 +761,7 @@ void load_ps2host(void) have_ps2host = 1; } } +#endif //------------------------------ //endfunc load_ps2host //--------------------------------------------------------------------------- @@ -875,6 +897,7 @@ void load_vmc_fs(void) //------------------------------ //endfunc load_vmc_fs //--------------------------------------------------------------------------- +#ifdef ETH static void load_ps2ftpd(void) { int ret; @@ -890,6 +913,7 @@ static void load_ps2ftpd(void) have_ps2ftpd = 1; } } + //------------------------------ //endfunc load_ps2ftpd //--------------------------------------------------------------------------- @@ -903,6 +927,7 @@ static void load_ps2netfs(void) have_ps2netfs = 1; } } +#endif //------------------------------ //endfunc load_ps2netfs //--------------------------------------------------------------------------- @@ -1225,6 +1250,7 @@ void loadHddModules(void) //--------------------------------------------------------------------------- // Load Network modules by EP (modified by RA) //------------------------------ +#ifdef ETH static void loadNetModules(void) { if (!have_NetModules) { @@ -1243,6 +1269,7 @@ static void loadNetModules(void) loadSkin(BACKGROUND_PIC, 0, 0); } } +#endif //------------------------------ //endfunc loadNetModules //--------------------------------------------------------------------------- @@ -1719,7 +1746,7 @@ static void Execute(char *pathin) if (pathSep && (pathSep - path < 7) && pathSep[-1] == ':') strcpy(fullpath + (pathSep - path), pathSep + 1); goto ELFchecked; - +#ifdef ETH } else if (!strncmp(path, "host:", 5)) { initHOST(); party[0] = 0; @@ -1730,7 +1757,7 @@ static void Execute(char *pathin) strcat(fullpath, path + 5); makeHostPath(fullpath, fullpath); goto CheckELF_fullpath; - +#endif } else if (!strcasecmp(path, setting->Misc_OSDSYS)) { char arg0[20], arg1[20], arg2[20], arg3[40]; char *args[4] = {arg0, arg1, arg2, arg3}; @@ -1905,10 +1932,12 @@ static void Execute(char *pathin) //The method below was used earlier, but causes reset with new ELF loader //party[0]=0; //strcpy(fullpath,"rom0:OSDSYS"); +#ifdef ETH } else if (!strcasecmp(path, setting->Misc_PS2Net)) { mainMsg[0] = 0; loadNetModules(); return; +#endif } else if (!strcasecmp(path, setting->Misc_PS2PowerOff)) { mainMsg[0] = 0; drawMsg(LNG(Powering_Off_Console)); @@ -2020,10 +2049,14 @@ static void Reset() have_usbd = 0; have_usb_mass = 0; have_ps2smap = 0; +#ifdef ETH have_ps2host = 0; +#endif have_vmc_fs = 0; have_smbman = 0; +#ifdef ETH have_ps2ftpd = 0; +#endif have_ps2kbd = 0; have_NetModules = 0; have_HDD_modules = 0; @@ -2203,11 +2236,11 @@ int main(int argc, char *argv[]) boot = BOOT_DEVICE_HDD; } } - +#ifdef ETH if (!strncmp(LaunchElfDir, "host", 4)) { boot = BOOT_DEVICE_HOST; } - +#endif if (((p = strrchr(LaunchElfDir, '/')) == NULL) && ((p = strrchr(LaunchElfDir, '\\')) == NULL)) p = strrchr(LaunchElfDir, ':'); if (p != NULL) @@ -2222,12 +2255,13 @@ int main(int argc, char *argv[]) InitializeBootExecPath(); CNF_error = loadConfig(mainMsg, strcpy(CNF, "LAUNCHELF.CNF")); - +#ifdef ETH if (boot == BOOT_DEVICE_HOST) { //If booted from the host: device, bring up the host device at this point. getIpConfig(); initHOST(); } +#endif //Last chance to look at bootup screen, so allow braking here /* if(readpad() && (new_pad && PAD_UP))