Skip to content

Commit 68e1f6b

Browse files
committed
try to refactor MX4SIO alias to general BDM alias
1 parent 59a29b0 commit 68e1f6b

File tree

3 files changed

+74
-27
lines changed

3 files changed

+74
-27
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ endif
161161

162162
ifeq ($(EXFAT),1)
163163
EE_OBJS += bdm_irx.o bdmfs_fatfs_irx.o usbmass_bd_irx.o
164-
EE_CFLAGS += -DEXFAT
164+
EE_CFLAGS += -DEXFAT -DBDM
165165
HAS_EXFAT = -EXFAT
166166
else
167167
EE_OBJS += usbhdfsd_irx.o

include/launchelf.h

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,45 @@ extern int Check_ESR_Disc(void);
471471

472472
#define USB_MASS_MAX_DRIVES 10
473473

474-
extern char USB_mass_ix[10];
474+
enum bdmtypes {
475+
BD_UNKNOWN = 0,
476+
BD_USB,
477+
BD_MX4SIO,
478+
BD_IEEE1394,
479+
BD_UDPBD,
480+
BD_ATAD,
481+
482+
BD_COUNT,
483+
};
484+
485+
const char* bdmnames[BD_COUNT] = {
486+
"",
487+
"usb",
488+
"sdc",
489+
"sd",
490+
"udp",
491+
"ata",
492+
};
493+
494+
char* bdmpaths[BD_COUNT] = {
495+
"mass?",
496+
"usb?:",
497+
"mx4sio?:",
498+
"iLink?:",
499+
"udpbd?:",
500+
"bdm_hdd?",
501+
};
502+
int bdmpathsindx[BD_COUNT] = {
503+
4,
504+
3,
505+
6,
506+
5,
507+
5,
508+
7,
509+
};
510+
511+
extern char USB_mass_ix[USB_MASS_MAX_DRIVES];
512+
extern char USB_mass_bx[USB_MASS_MAX_DRIVES];
475513
extern int USB_mass_max_drives;
476514
extern u64 USB_mass_scan_time;
477515
extern int USB_mass_scanned;

src/filer.c

Lines changed: 34 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,6 @@ char mountedDVRPParty[MOUNT_LIMIT][MAX_NAME];
7474
int latestDVRPMount = -1;
7575
#endif
7676

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

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

172169
//USB_mass definitions for multiple drive usage
173-
char USB_mass_ix[10] = {'0', 0, 0, 0, 0, 0, 0, 0, 0, 0};
170+
char USB_mass_ix[USB_MASS_MAX_DRIVES] = {'0', 0, 0, 0, 0, 0, 0, 0, 0, 0};
171+
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};
174172
int USB_mass_max_drives = USB_MASS_MAX_DRIVES;
175173
u64 USB_mass_scan_time = 0;
176174
int USB_mass_scanned = 0; //0==Not_found_OR_No_Multi 1==found_Multi_mass_once
@@ -1292,36 +1290,40 @@ int readXFROM(const char *path, FILEINFO *info, int max)
12921290
#endif
12931291
void scan_USB_mass(void)
12941292
{
1295-
#ifdef MX4SIO
1293+
#ifdef BDM
12961294
static char DEVID[5];
12971295
#endif
1298-
int i, dd;
1296+
int i, dd, x;
12991297
iox_stat_t chk_stat;
13001298
char mass_path[8] = "mass0:/";
13011299
if ((USB_mass_max_drives < 2) //No need for dynamic lists with only one drive
13021300
|| (USB_mass_scanned && ((Timer() - USB_mass_scan_time) < 5000)))
13031301
return;
13041302

1305-
#ifdef MX4SIO
1306-
mx4sio_idx = -1; //assume none is mx4sio // this MUST ALWAYS be after the USB_mass_scan_time check
1307-
#endif
1308-
13091303
for (i = 0; i < USB_mass_max_drives; i++) {
13101304
mass_path[4] = '0' + i;
1305+
#ifdef BDM
1306+
USB_mass_bx[i] = BD_UNKNOWN;
1307+
#endif
13111308
if (fileXioGetStat(mass_path, &chk_stat) < 0) {
13121309
USB_mass_ix[i] = 0;
13131310
continue;
13141311
}
1315-
#ifdef MX4SIO
1312+
#ifdef BDM
13161313
if ((dd = fileXioDopen(mass_path)) >= 0) {
13171314
int *intptr_ctl = (int *)DEVID;
13181315
*intptr_ctl = fileXioIoctl(dd, USBMASS_IOCTL_GET_DRIVERNAME, "");
13191316
fileXioDclose(dd);
1320-
if (!strncmp(DEVID, "sdc", 3))
1321-
{
1322-
mx4sio_idx = i;
1323-
DPRINTF("%s: Found MX4SIO device at mass%d:/\n", __func__, i);
1324-
}
1317+
for (x = BD_USB; x < BD_COUNT; x++)
1318+
{
1319+
if (!strcmp(DEVID, bdmnames[x]))
1320+
{
1321+
USB_mass_bx[x] = i;
1322+
DPRINTF("%s: Found %s device at mass%d:/\n", __func__, bdmnames[x], i);
1323+
break;
1324+
}
1325+
}
1326+
13251327
}
13261328
#endif
13271329
USB_mass_ix[i] = '0' + i;
@@ -4370,19 +4372,26 @@ int getFilePath(char *out, int cnfmode)
43704372
else if ((file_show == 2) && files[top + i].title[0] != 0) {
43714373
mcTitle = files[top + i].title;
43724374
} else { //Show normal file/folder names
4373-
#ifdef MX4SIO
4375+
#ifdef BDM
43744376
if (path[0] == 0) { // we are on root. apply the unique "alias" here
4375-
if ((!strncmp(files[top + i].name, "mass", 4)) //
4376-
&& (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
4377-
)
4378-
strcpy(tmp, "mx4sio:");
4377+
if ((!strncmp(files[top + i].name, "mass", 4))) {
4378+
int msindex = 0;
4379+
if (isdigit(files[top + i].name[4]))
4380+
msindex = files[top + i].name[4] - '0';
4381+
4382+
if (USB_mass_bx[msindex] > BD_UNKNOWN) {
4383+
bdmpaths[USB_mass_bx[msindex]][bdmpathsindx[USB_mass_bx[msindex]]] = '0'+msindex;
4384+
strcpy(tmp, bdmpaths[msindex]);
4385+
} else
4386+
strcpy(tmp, files[top + i].name);
4387+
}
43794388
else
43804389
strcpy(tmp, files[top + i].name);
4381-
} else {
4382-
strcpy(tmp, files[top + i].name);
4383-
}
4390+
} else {
4391+
strcpy(tmp, files[top + i].name);
4392+
}
43844393
#else
4385-
strcpy(tmp, files[top + i].name);
4394+
strcpy(tmp, files[top + i].name);
43864395
#endif
43874396
if (file_show > 0) { //Does display mode include file details ?
43884397
name_limit = 43 * 8;

0 commit comments

Comments
 (0)