Skip to content

Commit

Permalink
try to refactor MX4SIO alias to general BDM alias
Browse files Browse the repository at this point in the history
  • Loading branch information
israpps committed Feb 19, 2025
1 parent 59a29b0 commit db297b6
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 27 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ endif

ifeq ($(EXFAT),1)
EE_OBJS += bdm_irx.o bdmfs_fatfs_irx.o usbmass_bd_irx.o
EE_CFLAGS += -DEXFAT
EE_CFLAGS += -DEXFAT -DBDM
HAS_EXFAT = -EXFAT
else
EE_OBJS += usbhdfsd_irx.o
Expand Down
43 changes: 42 additions & 1 deletion include/launchelf.h
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,48 @@ extern int Check_ESR_Disc(void);

#define USB_MASS_MAX_DRIVES 10

extern char USB_mass_ix[10];
enum bdmtypes {
BD_UNKNOWN = 0,
BD_USB,
BD_MX4SIO,
BD_IEEE1394,
BD_UDPBD,
BD_ATAD,

BD_COUNT,
};

extern const char* bdmnames[BD_COUNT]
extern char* bdmpaths[BD_COUNT]
extern int bdmpathsindx[BD_COUNT]
const char* bdmnames[BD_COUNT] = {
"",
"usb",
"sdc",
"sd",
"udp",
"ata",
};

char* bdmpaths[BD_COUNT] = {
"mass?",
"usb?:",
"mx4sio?:",
"iLink?:",
"udpbd?:",
"bdm_hdd?",
};
int bdmpathsindx[BD_COUNT] = {
4,
3,
6,
5,
5,
7,
};

extern char USB_mass_ix[USB_MASS_MAX_DRIVES];
extern char USB_mass_bx[USB_MASS_MAX_DRIVES];
extern int USB_mass_max_drives;
extern u64 USB_mass_scan_time;
extern int USB_mass_scanned;
Expand Down
86 changes: 61 additions & 25 deletions src/filer.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,6 @@ char mountedDVRPParty[MOUNT_LIMIT][MAX_NAME];
int latestDVRPMount = -1;
#endif

#ifdef MX4SIO
int mx4sio_idx = -1; // To keep track of wich mass#:/ device represents MX4SIO
#endif

int file_show = 1; //dlanor: 0==name_only, 1==name+size+time, 2==title+size+time
int file_sort = 1; //dlanor: 0==none, 1==name, 2==title, 3==mtime
Expand Down Expand Up @@ -170,7 +167,35 @@ typedef struct
int PSU_content; //Used to count PSU content headers for the main header

//USB_mass definitions for multiple drive usage
char USB_mass_ix[10] = {'0', 0, 0, 0, 0, 0, 0, 0, 0, 0};
char USB_mass_ix[USB_MASS_MAX_DRIVES] = {'0', 0, 0, 0, 0, 0, 0, 0, 0, 0};
char USB_mass_bx[USB_MASS_MAX_DRIVES] = {BD_UNKNOWN, BD_UNKNOWN, BD_UNKNOWN, BD_UNKNOWN, BD_UNKNOWN, BD_UNKNOWN, BD_UNKNOWN, BD_UNKNOWN, BD_UNKNOWN, BD_UNKNOWN};

const char* bdmnames[BD_COUNT] = {
"",
"usb",
"sdc",
"sd",
"udp",
"ata",
};

char* bdmpaths[BD_COUNT] = {
"mass?",
"usb?:",
"mx4sio?:",
"iLink?:",
"udpbd?:",
"bdm_hdd?",
};
int bdmpathsindx[BD_COUNT] = {
4,
3,
6,
5,
5,
7,
};

int USB_mass_max_drives = USB_MASS_MAX_DRIVES;
u64 USB_mass_scan_time = 0;
int USB_mass_scanned = 0; //0==Not_found_OR_No_Multi 1==found_Multi_mass_once
Expand Down Expand Up @@ -1292,36 +1317,40 @@ int readXFROM(const char *path, FILEINFO *info, int max)
#endif
void scan_USB_mass(void)
{
#ifdef MX4SIO
#ifdef BDM
static char DEVID[5];
#endif
int i, dd;
int i, dd, x;
iox_stat_t chk_stat;
char mass_path[8] = "mass0:/";
if ((USB_mass_max_drives < 2) //No need for dynamic lists with only one drive
|| (USB_mass_scanned && ((Timer() - USB_mass_scan_time) < 5000)))
return;

#ifdef MX4SIO
mx4sio_idx = -1; //assume none is mx4sio // this MUST ALWAYS be after the USB_mass_scan_time check
#endif

for (i = 0; i < USB_mass_max_drives; i++) {
mass_path[4] = '0' + i;
#ifdef BDM
USB_mass_bx[i] = BD_UNKNOWN;
#endif
if (fileXioGetStat(mass_path, &chk_stat) < 0) {
USB_mass_ix[i] = 0;
continue;
}
#ifdef MX4SIO
#ifdef BDM
if ((dd = fileXioDopen(mass_path)) >= 0) {
int *intptr_ctl = (int *)DEVID;
*intptr_ctl = fileXioIoctl(dd, USBMASS_IOCTL_GET_DRIVERNAME, "");
fileXioDclose(dd);
if (!strncmp(DEVID, "sdc", 3))
{
mx4sio_idx = i;
DPRINTF("%s: Found MX4SIO device at mass%d:/\n", __func__, i);
}
for (x = BD_USB; x < BD_COUNT; x++)
{
if (!strcmp(DEVID, bdmnames[x]))
{
USB_mass_bx[x] = i;
DPRINTF("%s: Found %s device at mass%d:/\n", __func__, bdmnames[x], i);
break;
}
}

}
#endif
USB_mass_ix[i] = '0' + i;
Expand Down Expand Up @@ -4370,19 +4399,26 @@ int getFilePath(char *out, int cnfmode)
else if ((file_show == 2) && files[top + i].title[0] != 0) {
mcTitle = files[top + i].title;
} else { //Show normal file/folder names
#ifdef MX4SIO
#ifdef BDM
if (path[0] == 0) { // we are on root. apply the unique "alias" here
if ((!strncmp(files[top + i].name, "mass", 4)) //
&& (files[top + i].name[4] == ('0' + mx4sio_idx) || (mx4sio_idx == 0 && files[top + i].name[4] == ':')) //index corresponds to mx4sio index, also assume that if device path index 4 is equal to ':' then it is index 0
)
strcpy(tmp, "mx4sio:");
if ((!strncmp(files[top + i].name, "mass", 4))) {
int msindex = 0;
if (isdigit(files[top + i].name[4]))
msindex = files[top + i].name[4] - '0';

if (USB_mass_bx[msindex] > BD_UNKNOWN) {
bdmpaths[USB_mass_bx[msindex]][bdmpathsindx[USB_mass_bx[msindex]]] = '0'+msindex;
strcpy(tmp, bdmpaths[msindex]);
} else
strcpy(tmp, files[top + i].name);
}
else
strcpy(tmp, files[top + i].name);
} else {
strcpy(tmp, files[top + i].name);
}
} else {
strcpy(tmp, files[top + i].name);
}
#else
strcpy(tmp, files[top + i].name);
strcpy(tmp, files[top + i].name);
#endif
if (file_show > 0) { //Does display mode include file details ?
name_limit = 43 * 8;
Expand Down

0 comments on commit db297b6

Please sign in to comment.