mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-09 15:28:21 -04:00
PS2: Maybe working USB mass storage device support
This commit is contained in:
parent
410fcf438f
commit
bc9b97aeba
@ -4,8 +4,8 @@ CFILES := $(wildcard src/*.c)
|
|||||||
OBJS :=$(patsubst %.c, %.o, $(CFILES))
|
OBJS :=$(patsubst %.c, %.o, $(CFILES))
|
||||||
|
|
||||||
EE_BIN = ClassiCube-ps2.elf
|
EE_BIN = ClassiCube-ps2.elf
|
||||||
EE_OBJS = $(OBJS) DEV9_irx.o NETMAN_irx.o SMAP_irx.o
|
EE_OBJS = $(OBJS) DEV9_irx.o NETMAN_irx.o SMAP_irx.o USBD_irx.o BDM_irx.o BDMFS_FATFS_irx.o USBMASS_BD_irx.o USBHDFSD_irx.o
|
||||||
EE_LIBS = -lpatches -lpad -lpacket -ldma -lgraph -ldraw -lc -lps2ip -lnetman
|
EE_LIBS = -lpatches -lpad -lpacket -ldma -lgraph -ldraw -lc -lps2ip -lnetman -lmc
|
||||||
EE_CFLAGS = -DPLAT_PS2
|
EE_CFLAGS = -DPLAT_PS2
|
||||||
|
|
||||||
all: $(EE_BIN)
|
all: $(EE_BIN)
|
||||||
@ -13,6 +13,7 @@ all: $(EE_BIN)
|
|||||||
clean:
|
clean:
|
||||||
rm -f $(EE_BIN) $(EE_OBJS)
|
rm -f $(EE_BIN) $(EE_OBJS)
|
||||||
|
|
||||||
|
# Networking IRX modules
|
||||||
DEV9_irx.c: $(PS2SDK)/iop/irx/ps2dev9.irx
|
DEV9_irx.c: $(PS2SDK)/iop/irx/ps2dev9.irx
|
||||||
bin2c $< DEV9_irx.c DEV9_irx
|
bin2c $< DEV9_irx.c DEV9_irx
|
||||||
|
|
||||||
@ -21,6 +22,23 @@ NETMAN_irx.c: $(PS2SDK)/iop/irx/netman.irx
|
|||||||
|
|
||||||
SMAP_irx.c: $(PS2SDK)/iop/irx/smap.irx
|
SMAP_irx.c: $(PS2SDK)/iop/irx/smap.irx
|
||||||
bin2c $< SMAP_irx.c SMAP_irx
|
bin2c $< SMAP_irx.c SMAP_irx
|
||||||
|
|
||||||
|
# USB storage IRX modules
|
||||||
|
USBD_irx.c: $(PS2SDK)/iop/irx/usbd.irx
|
||||||
|
bin2c $< USBD_irx.c USBD_irx
|
||||||
|
|
||||||
|
BDM_irx.c: $(PS2SDK)/iop/irx/bdm.irx
|
||||||
|
bin2c $< BDM_irx.c BDM_irx
|
||||||
|
|
||||||
|
BDMFS_FATFS_irx.c: $(PS2SDK)/iop/irx/bdmfs_fatfs.irx
|
||||||
|
bin2c $< BDMFS_FATFS_irx.c BDMFS_FATFS_irx
|
||||||
|
|
||||||
|
USBMASS_BD_irx.c: $(PS2SDK)/iop/irx/usbmass_bd.irx
|
||||||
|
bin2c $< USBMASS_BD_irx.c USBMASS_BD_irx
|
||||||
|
|
||||||
|
USBHDFSD_irx.c: $(PS2SDK)/iop/irx/usbhdfsd.irx
|
||||||
|
bin2c $< USBHDFSD_irx.c USBHDFSD_irx
|
||||||
|
|
||||||
|
|
||||||
include $(PS2SDK)/samples/Makefile.pref
|
include $(PS2SDK)/samples/Makefile.pref
|
||||||
include $(PS2SDK)/samples/Makefile.eeglobal
|
include $(PS2SDK)/samples/Makefile.eeglobal
|
||||||
|
@ -96,7 +96,7 @@ cc_uint64 Stopwatch_ElapsedMicroseconds(cc_uint64 beg, cc_uint64 end) {
|
|||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*-----------------------------------------------------Directory/File------------------------------------------------------*
|
*-----------------------------------------------------Directory/File------------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
static const cc_string root_path = String_FromConst("mc0:/ClassiCube/");
|
static const cc_string root_path = String_FromConst("mass:/ClassiCube/");
|
||||||
|
|
||||||
static void GetNativePath(char* str, const cc_string* path) {
|
static void GetNativePath(char* str, const cc_string* path) {
|
||||||
Mem_Copy(str, root_path.buffer, root_path.length);
|
Mem_Copy(str, root_path.buffer, root_path.length);
|
||||||
@ -421,7 +421,7 @@ static int ethEnableDHCP(void) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SetupNetworking(void) {
|
static void Networking_Setup(void) {
|
||||||
struct ip4_addr IP = { 0 }, NM = { 0 }, GW = { 0 };
|
struct ip4_addr IP = { 0 }, NM = { 0 }, GW = { 0 };
|
||||||
ps2ipInit(&IP, &NM, &GW);
|
ps2ipInit(&IP, &NM, &GW);
|
||||||
ethEnableDHCP();
|
ethEnableDHCP();
|
||||||
@ -440,13 +440,23 @@ static void SetupNetworking(void) {
|
|||||||
Platform_LogConst("Network setup done");
|
Platform_LogConst("Network setup done");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void InitNetworking(void) {
|
static void Networking_Init(void) {
|
||||||
SifExecModuleBuffer(DEV9_irx, size_DEV9_irx, 0, NULL, NULL);
|
|
||||||
SifExecModuleBuffer(NETMAN_irx, size_NETMAN_irx, 0, NULL, NULL);
|
|
||||||
SifExecModuleBuffer(SMAP_irx, size_SMAP_irx, 0, NULL, NULL);
|
|
||||||
NetManInit();
|
NetManInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void Networking_LoadIOPModules(void) {
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = SifExecModuleBuffer(DEV9_irx, size_DEV9_irx, 0, NULL, NULL);
|
||||||
|
if (ret < 0) Platform_Log1("SifExecModuleBuffer DEV9_irx failed: %i", &ret);
|
||||||
|
|
||||||
|
ret = SifExecModuleBuffer(NETMAN_irx, size_NETMAN_irx, 0, NULL, NULL);
|
||||||
|
if (ret < 0) Platform_Log1("SifExecModuleBuffer NETMAN_irx failed: %i", &ret);
|
||||||
|
|
||||||
|
ret = SifExecModuleBuffer(SMAP_irx, size_SMAP_irx, 0, NULL, NULL);
|
||||||
|
if (ret < 0) Platform_Log1("SifExecModuleBuffer SMAP_irx failed: %i", &ret);
|
||||||
|
}
|
||||||
|
|
||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*---------------------------------------------------------Socket----------------------------------------------------------*
|
*---------------------------------------------------------Socket----------------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
@ -590,6 +600,62 @@ cc_result Socket_CheckWritable(cc_socket s, cc_bool* writable) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*########################################################################################################################*
|
||||||
|
*----------------------------------------------------USB mass storage-----------------------------------------------------*
|
||||||
|
*#########################################################################################################################*/
|
||||||
|
extern unsigned char USBD_irx[];
|
||||||
|
extern unsigned int size_USBD_irx;
|
||||||
|
|
||||||
|
extern unsigned char BDM_irx[];
|
||||||
|
extern unsigned int size_BDM_irx;
|
||||||
|
|
||||||
|
extern unsigned char BDMFS_FATFS_irx[];
|
||||||
|
extern unsigned int size_BDMFS_FATFS_irx;
|
||||||
|
|
||||||
|
extern unsigned char USBMASS_BD_irx[];
|
||||||
|
extern unsigned int size_USBMASS_BD_irx;
|
||||||
|
|
||||||
|
extern unsigned char USBHDFSD_irx[];
|
||||||
|
extern unsigned int size_USBHDFSD_irx;
|
||||||
|
|
||||||
|
static void USBStorage_LoadIOPModules(void) {
|
||||||
|
int ret;
|
||||||
|
// TODO: Seems that
|
||||||
|
// BDM, BDMFS_FATFS, USBMASS_BD - newer ?
|
||||||
|
// USBHDFSD - older ?
|
||||||
|
|
||||||
|
ret = SifExecModuleBuffer(USBD_irx, size_USBD_irx, 0, NULL, NULL);
|
||||||
|
if (ret < 0) Platform_Log1("SifExecModuleBuffer USBD_irx failed: %i", &ret);
|
||||||
|
|
||||||
|
//ret = SifExecModuleBuffer(USBHDFSD_irx, size_USBHDFSD_irx, 0, NULL, NULL);
|
||||||
|
//if (ret < 0) Platform_Log1("SifExecModuleBuffer USBHDFSD_irx failed: %i", &ret);
|
||||||
|
|
||||||
|
ret = SifExecModuleBuffer(BDM_irx, size_BDM_irx, 0, NULL, NULL);
|
||||||
|
if (ret < 0) Platform_Log1("SifExecModuleBuffer BDM_irx failed: %i", &ret);
|
||||||
|
|
||||||
|
ret = SifExecModuleBuffer(BDMFS_FATFS_irx, size_BDMFS_FATFS_irx, 0, NULL, NULL);
|
||||||
|
if (ret < 0) Platform_Log1("SifExecModuleBuffer BDMFS_FATFS_irx failed: %i", &ret);
|
||||||
|
|
||||||
|
ret = SifExecModuleBuffer(USBMASS_BD_irx, size_USBMASS_BD_irx, 0, NULL, NULL);
|
||||||
|
if (ret < 0) Platform_Log1("SifExecModuleBuffer USBMASS_BD_irx failed: %i", &ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO Maybe needed ???
|
||||||
|
/*
|
||||||
|
static void USBStorage_WaitUntilDeviceReady() {
|
||||||
|
io_stat_t sb;
|
||||||
|
Thread_Sleep(50);
|
||||||
|
|
||||||
|
for (int retry = 0; retry < 50; retry++)
|
||||||
|
{
|
||||||
|
if (fioGetstat("mass:/", &sb) >= 0) return;
|
||||||
|
|
||||||
|
nopdelay();
|
||||||
|
}
|
||||||
|
Platform_LogConst("USB device still not ready ??");
|
||||||
|
}*/
|
||||||
|
|
||||||
|
|
||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*--------------------------------------------------------Platform---------------------------------------------------------*
|
*--------------------------------------------------------Platform---------------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
@ -607,24 +673,27 @@ static void LoadIOPModules(void) {
|
|||||||
|
|
||||||
// file I/O module
|
// file I/O module
|
||||||
ret = SifLoadModule("rom0:FILEIO", 0, NULL);
|
ret = SifLoadModule("rom0:FILEIO", 0, NULL);
|
||||||
if (ret < 0) Platform_Log1("sifLoadModule FILEIO failed: %i", &ret);
|
if (ret < 0) Platform_Log1("SifLoadModule FILEIO failed: %i", &ret);
|
||||||
sbv_patch_fileio();
|
sbv_patch_fileio();
|
||||||
|
|
||||||
// serial I/O module (needed for memory card & input pad modules)
|
// serial I/O module (needed for memory card & input pad modules)
|
||||||
ret = SifLoadModule("rom0:SIO2MAN", 0, NULL);
|
ret = SifLoadModule("rom0:SIO2MAN", 0, NULL);
|
||||||
if (ret < 0) Platform_Log1("sifLoadModule SIO2MAN failed: %i", &ret);
|
if (ret < 0) Platform_Log1("SifLoadModule SIO2MAN failed: %i", &ret);
|
||||||
|
|
||||||
|
|
||||||
// memory card module
|
// memory card module
|
||||||
ret = SifLoadModule("rom0:MCMAN", 0, NULL);
|
ret = SifLoadModule("rom0:MCMAN", 0, NULL);
|
||||||
if (ret < 0) Platform_Log1("sifLoadModule MCMAN failed: %i", &ret);
|
if (ret < 0) Platform_Log1("SifLoadModule MCMAN failed: %i", &ret);
|
||||||
|
|
||||||
// memory card module
|
// memory card server module
|
||||||
ret = SifLoadModule("rom0:MCSERV", 0, NULL);
|
ret = SifLoadModule("rom0:MCSERV", 0, NULL);
|
||||||
if (ret < 0) Platform_Log1("sifLoadModule MCSERV failed: %i", &ret);
|
if (ret < 0) Platform_Log1("SifLoadModule MCSERV failed: %i", &ret);
|
||||||
|
|
||||||
|
|
||||||
// Input pad module
|
// Input pad module
|
||||||
ret = SifLoadModule("rom0:PADMAN", 0, NULL);
|
ret = SifLoadModule("rom0:PADMAN", 0, NULL);
|
||||||
if (ret < 0) Platform_Log1("sifLoadModule PADMAN failed: %i", &ret);
|
if (ret < 0) Platform_Log1("SifLoadModule PADMAN failed: %i", &ret);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Platform_Init(void) {
|
void Platform_Init(void) {
|
||||||
@ -633,13 +702,18 @@ void Platform_Init(void) {
|
|||||||
SifInitRpc(0);
|
SifInitRpc(0);
|
||||||
SifLoadFileInit();
|
SifLoadFileInit();
|
||||||
SifInitIopHeap();
|
SifInitIopHeap();
|
||||||
sbv_patch_enable_lmb();
|
sbv_patch_enable_lmb(); // Allows loading IRX modules from a buffer in EE RAM
|
||||||
|
|
||||||
LoadIOPModules();
|
LoadIOPModules();
|
||||||
InitNetworking();
|
USBStorage_LoadIOPModules();
|
||||||
SetupNetworking();
|
//USBStorage_WaitUntilDeviceReady();
|
||||||
|
|
||||||
|
Networking_LoadIOPModules();
|
||||||
|
Networking_Init();
|
||||||
|
Networking_Setup();
|
||||||
|
|
||||||
// Create root directory
|
// Create root directory
|
||||||
int res = fioMkdir("mc0:/ClassiCube");
|
int res = fioMkdir("mass:/ClassiCube");
|
||||||
Platform_Log1("ROOT CREATE %i", &res);
|
Platform_Log1("ROOT CREATE %i", &res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user