Skip to content

Commit 42f95be

Browse files
committed
try to refactor MX4SIO alias to general BDM alias
1 parent 59a29b0 commit 42f95be

File tree

3 files changed

+78
-27
lines changed

3 files changed

+78
-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: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,22 @@ 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+
extern const char* bdmnames[BD_COUNT];
486+
extern char* bdmpaths[BD_COUNT];
487+
extern int bdmpathsindx[BD_COUNT];
488+
extern char USB_mass_ix[USB_MASS_MAX_DRIVES];
489+
extern char USB_mass_bx[USB_MASS_MAX_DRIVES];
475490
extern int USB_mass_max_drives;
476491
extern u64 USB_mass_scan_time;
477492
extern int USB_mass_scanned;

src/filer.c

Lines changed: 61 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,35 @@ 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};
172+
173+
const char* bdmnames[BD_COUNT] = {
174+
"",
175+
"usb",
176+
"sdc",
177+
"sd",
178+
"udp",
179+
"ata",
180+
};
181+
182+
char* bdmpaths[BD_COUNT] = {
183+
"mass?",
184+
"usb?:",
185+
"mx4sio?:",
186+
"iLink?:",
187+
"udpbd?:",
188+
"bdm_hdd?",
189+
};
190+
int bdmpathsindx[BD_COUNT] = {
191+
4,
192+
3,
193+
6,
194+
5,
195+
5,
196+
7,
197+
};
198+
174199
int USB_mass_max_drives = USB_MASS_MAX_DRIVES;
175200
u64 USB_mass_scan_time = 0;
176201
int USB_mass_scanned = 0; //0==Not_found_OR_No_Multi 1==found_Multi_mass_once
@@ -1292,36 +1317,40 @@ int readXFROM(const char *path, FILEINFO *info, int max)
12921317
#endif
12931318
void scan_USB_mass(void)
12941319
{
1295-
#ifdef MX4SIO
1320+
#ifdef BDM
12961321
static char DEVID[5];
12971322
#endif
1298-
int i, dd;
1323+
int i, dd, x;
12991324
iox_stat_t chk_stat;
13001325
char mass_path[8] = "mass0:/";
13011326
if ((USB_mass_max_drives < 2) //No need for dynamic lists with only one drive
13021327
|| (USB_mass_scanned && ((Timer() - USB_mass_scan_time) < 5000)))
13031328
return;
13041329

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-
13091330
for (i = 0; i < USB_mass_max_drives; i++) {
13101331
mass_path[4] = '0' + i;
1332+
#ifdef BDM
1333+
USB_mass_bx[i] = BD_UNKNOWN;
1334+
#endif
13111335
if (fileXioGetStat(mass_path, &chk_stat) < 0) {
13121336
USB_mass_ix[i] = 0;
13131337
continue;
13141338
}
1315-
#ifdef MX4SIO
1339+
#ifdef BDM
13161340
if ((dd = fileXioDopen(mass_path)) >= 0) {
13171341
int *intptr_ctl = (int *)DEVID;
13181342
*intptr_ctl = fileXioIoctl(dd, USBMASS_IOCTL_GET_DRIVERNAME, "");
13191343
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-
}
1344+
for (x = BD_USB; x < BD_COUNT; x++)
1345+
{
1346+
if (!strcmp(DEVID, bdmnames[x]))
1347+
{
1348+
USB_mass_bx[x] = i;
1349+
DPRINTF("%s: Found %s device at mass%d:/\n", __func__, bdmnames[x], i);
1350+
break;
1351+
}
1352+
}
1353+
13251354
}
13261355
#endif
13271356
USB_mass_ix[i] = '0' + i;
@@ -4370,19 +4399,26 @@ int getFilePath(char *out, int cnfmode)
43704399
else if ((file_show == 2) && files[top + i].title[0] != 0) {
43714400
mcTitle = files[top + i].title;
43724401
} else { //Show normal file/folder names
4373-
#ifdef MX4SIO
4402+
#ifdef BDM
43744403
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:");
4404+
if ((!strncmp(files[top + i].name, "mass", 4))) {
4405+
int msindex = 0;
4406+
if (isdigit(files[top + i].name[4]))
4407+
msindex = files[top + i].name[4] - '0';
4408+
4409+
if (USB_mass_bx[msindex] > BD_UNKNOWN) {
4410+
bdmpaths[USB_mass_bx[msindex]][bdmpathsindx[USB_mass_bx[msindex]]] = '0'+msindex;
4411+
strcpy(tmp, bdmpaths[msindex]);
4412+
} else
4413+
strcpy(tmp, files[top + i].name);
4414+
}
43794415
else
43804416
strcpy(tmp, files[top + i].name);
4381-
} else {
4382-
strcpy(tmp, files[top + i].name);
4383-
}
4417+
} else {
4418+
strcpy(tmp, files[top + i].name);
4419+
}
43844420
#else
4385-
strcpy(tmp, files[top + i].name);
4421+
strcpy(tmp, files[top + i].name);
43864422
#endif
43874423
if (file_show > 0) { //Does display mode include file details ?
43884424
name_limit = 43 * 8;

0 commit comments

Comments
 (0)