diff options
author | Max Lingua | 2014-01-12 20:08:50 -0500 |
---|---|---|
committer | Max Lingua | 2014-01-18 13:48:37 -0500 |
commit | 1cbb90d8ea82e728fa8ead8a4004dc53f3a75764 (patch) | |
tree | 5d04f7f09c482a8cd2215146bce47fee66b8d278 /backends/platform | |
parent | fb69d8eddcb2a29bace9a2fa7723068e2eb1b6fe (diff) | |
download | scummvm-rg350-1cbb90d8ea82e728fa8ead8a4004dc53f3a75764.tar.gz scummvm-rg350-1cbb90d8ea82e728fa8ead8a4004dc53f3a75764.tar.bz2 scummvm-rg350-1cbb90d8ea82e728fa8ead8a4004dc53f3a75764.zip |
PS2: modular IRX drivers loading
Diffstat (limited to 'backends/platform')
-rw-r--r-- | backends/platform/ps2/irxboot.cpp | 81 | ||||
-rw-r--r-- | backends/platform/ps2/irxboot.h | 13 | ||||
-rw-r--r-- | backends/platform/ps2/systemps2.cpp | 133 | ||||
-rw-r--r-- | backends/platform/ps2/systemps2.h | 5 |
4 files changed, 158 insertions, 74 deletions
diff --git a/backends/platform/ps2/irxboot.cpp b/backends/platform/ps2/irxboot.cpp index aa904d4f5b..ee52687d95 100644 --- a/backends/platform/ps2/irxboot.cpp +++ b/backends/platform/ps2/irxboot.cpp @@ -34,37 +34,65 @@ static const char hddArg[] = "-o" "\0" "8" "\0" "-n" "\0" "20"; static const char pfsArg[] = "-m" "\0" "2" "\0" "-o" "\0" "32" "\0" "-n" "\0" "72"; // "\0" "-debug"; -static const char netArg[] = "192.168.0.10" "\0" "255.255.255.0" "\0" "192.168.0.1"; - -IrxFile irxFiles[] = { - { "SIO2MAN", BIOS, NOTHING, NULL, 0 }, - { "MCMAN", BIOS, NOTHING, NULL, 0 }, - { "MCSERV", BIOS, NOTHING, NULL, 0 }, - { "PADMAN", BIOS, NOTHING, NULL, 0 }, - { "LIBSD", BIOS, NOTHING, NULL, 0 }, - - { "IOMANX.IRX", SYSTEM, NOTHING, NULL, 0 }, - { "FILEXIO.IRX", SYSTEM, NOTHING, NULL, 0 }, - { "CODYVDFS.IRX", SYSTEM, NOTHING, NULL, 0 }, +static const char netArg[] = "192.168.1.20" "\0" "255.255.255.0" "\0" "192.168.1.1"; // TODO: set in ScummVM.ini + +IrxFile irxCore[] = { // core modules + // Memory Card + { "SIO2MAN", BIOS, NOTHING, NULL, 0 }, + { "MCMAN", BIOS, NOTHING, NULL, 0 }, + { "MCSERV", BIOS, NOTHING, NULL, 0 }, + // Joypad + { "PADMAN", BIOS, NOTHING, NULL, 0 }, + // Sound + { "LIBSD", BIOS, NOTHING, NULL, 0 }, { "SJPCM.IRX", SYSTEM, NOTHING, NULL, 0 }, + // Files I/O + { "IOMANX.IRX", SYSTEM, NOTHING, NULL, 0 }, + { "FILEXIO.IRX", SYSTEM, NOTHING, NULL, 0 } +}; + +IrxFile irxCdrom[] = { // cdrom modules + // CD-Rom FS + { "CODYVDFS.IRX", SYSTEM, CD_DRIVER, NULL, 0 } +}; +IrxFile irxUSB[] = { // USB mass + // USB drv & key { "USBD.IRX", USB | OPTIONAL | DEPENDANCY, USB_DRIVER, NULL, 0 }, - { "USB_MASS.IRX", USB | OPTIONAL, MASS_DRIVER, NULL, 0 }, + { "USB_MASS.IRX", USB | OPTIONAL, MASS_DRIVER, NULL, 0 } +}; + +IrxFile irxInput[] = { // USB input + // USB mouse & kbd { "PS2MOUSE.IRX", USB | OPTIONAL, MOUSE_DRIVER, NULL, 0 }, - { "RPCKBD.IRX", USB | OPTIONAL, KBD_DRIVER, NULL, 0 }, -#ifndef NO_ADAPTOR + { "RPCKBD.IRX", USB | OPTIONAL, KBD_DRIVER, NULL, 0 } +}; + +IrxFile irxHDD[] = { // modules to support HDD + // hdd modules { "POWEROFF.IRX", HDD | OPTIONAL | NOT_HOST | DEPENDANCY, HDD_DRIVER, NULL, 0 }, { "PS2DEV9.IRX", HDD | OPTIONAL | NOT_HOST | DEPENDANCY, HDD_DRIVER, NULL, 0 }, { "PS2ATAD.IRX", HDD | OPTIONAL | DEPENDANCY, HDD_DRIVER, NULL, 0 }, { "PS2HDD.IRX", HDD | OPTIONAL | DEPENDANCY, HDD_DRIVER, hddArg, sizeof(hddArg) }, - { "PS2FS.IRX", HDD | OPTIONAL | DEPENDANCY, HDD_DRIVER, pfsArg, sizeof(pfsArg) }, + { "PS2FS.IRX", HDD | OPTIONAL | DEPENDANCY, HDD_DRIVER, pfsArg, sizeof(pfsArg) } +}; + +IrxFile irxNet[] = { // modules to support NET + // net modules { "PS2IP.IRX", NET | OPTIONAL | NOT_HOST | DEPENDANCY, NET_DRIVER, NULL, 0 }, { "PS2SMAP.IRX", NET | OPTIONAL | NOT_HOST | DEPENDANCY, NET_DRIVER, netArg, sizeof(netArg) }, { "PS2HOST.IRX", NET | OPTIONAL | NOT_HOST | DEPENDANCY, NET_DRIVER, NULL, 0 } -#endif }; -static const int numIrxFiles = sizeof(irxFiles) / sizeof(irxFiles[0]); +IrxFile *irxType[IRX_MAX] = { irxCore, irxCdrom, irxUSB, irxInput, irxHDD, irxNet }; + +static const int numIrx[IRX_MAX] = { sizeof(irxCore) / sizeof(IrxFile), + sizeof(irxCdrom) / sizeof(IrxFile), + sizeof(irxUSB) / sizeof(IrxFile), + sizeof(irxInput) / sizeof(IrxFile), + sizeof(irxHDD) / sizeof(IrxFile), + sizeof(irxNet) / sizeof(IrxFile) +}; PS2Device detectBootPath(const char *elfPath, char *bootPath) { @@ -113,12 +141,19 @@ PS2Device detectBootPath(const char *elfPath, char *bootPath) { return device; } -int loadIrxModules(int device, const char *irxPath, IrxReference **modules) { +int loadIrxModules(int device, const char *irxPath, IrxReference **modules, IrxType type) { + + IrxReference *resModules; + IrxReference *curModule; + IrxFile *irxFiles; + int numFiles; - IrxReference *resModules = (IrxReference *)malloc(numIrxFiles * sizeof(IrxReference)); - IrxReference *curModule = resModules; + irxFiles = irxType[type]; + numFiles = numIrx[type]; + resModules = (IrxReference *)malloc(numFiles * sizeof(IrxReference)); + curModule = resModules; - for (int i = 0; i < numIrxFiles; i++) { + for (int i = 0; i < numFiles; i++) { curModule->fileRef = irxFiles + i; if ((device == HOST_DEV) && (irxFiles[i].flags & NOT_HOST)) continue; @@ -191,7 +226,7 @@ int loadIrxModules(int device, const char *irxPath, IrxReference **modules) { pos++; } // and skip any remaining modules that depend on the missing one, too. - while ((i < numIrxFiles - 1) && ((irxFiles[i + 1].flags & TYPEMASK) == (curModule->fileRef->flags & TYPEMASK))) + while ((i < numFiles - 1) && ((irxFiles[i + 1].flags & TYPEMASK) == (curModule->fileRef->flags & TYPEMASK))) i++; // the module that actually failed (curModule) is kept in the array for displaying an error message } diff --git a/backends/platform/ps2/irxboot.h b/backends/platform/ps2/irxboot.h index 81b47a37c6..f8b451f6d2 100644 --- a/backends/platform/ps2/irxboot.h +++ b/backends/platform/ps2/irxboot.h @@ -25,6 +25,16 @@ #include "common/scummsys.h" +enum IrxType { + IRX_CORE = 0, + IRX_CDROM, + IRX_USB, + IRX_INPUT, + IRX_HDD, + IRX_NET, + IRX_MAX +}; + enum IrxFlags { BIOS = 0, SYSTEM = 1, @@ -40,6 +50,7 @@ enum IrxFlags { enum IrxPurpose { NOTHING, + CD_DRIVER, HDD_DRIVER, USB_DRIVER, MOUSE_DRIVER, @@ -81,6 +92,6 @@ struct IrxReference { int errorCode; }; -int loadIrxModules(int device, const char *irxPath, IrxReference **modules); +int loadIrxModules(int device, const char *irxPath, IrxReference **modules, IrxType type); #endif // __IRXBOOT_H__ diff --git a/backends/platform/ps2/systemps2.cpp b/backends/platform/ps2/systemps2.cpp index abea69604b..2f6130cf4f 100644 --- a/backends/platform/ps2/systemps2.cpp +++ b/backends/platform/ps2/systemps2.cpp @@ -50,7 +50,6 @@ #include "backends/platform/ps2/cd.h" #include "backends/platform/ps2/fileio.h" #include "backends/platform/ps2/Gs2dScreen.h" -#include "backends/platform/ps2/irxboot.h" #include "backends/platform/ps2/ps2debug.h" #include "backends/platform/ps2/ps2input.h" #include "backends/platform/ps2/savefilemgr.h" @@ -189,8 +188,6 @@ void gluePowerOffCallback(void *system) { void OSystem_PS2::startIrxModules(int numModules, IrxReference *modules) { - _usbMassLoaded = _useMouse = _useKbd = _useHdd = _useNet = false; - int res = 0, rv = 0; for (int i = 0; i < numModules; i++) { if (modules[i].loc == IRX_FILE) { @@ -216,6 +213,9 @@ void OSystem_PS2::startIrxModules(int numModules, IrxReference *modules) { case KBD_DRIVER: _useKbd = true; break; + case CD_DRIVER: + _useCd = true; + break; case HDD_DRIVER: _useHdd = true; break; @@ -252,9 +252,67 @@ void OSystem_PS2::startIrxModules(int numModules, IrxReference *modules) { sioprintf("UsbMass: %sloaded\n", _usbMassLoaded ? "" : "not "); sioprintf("Mouse: %sloaded\n", _useMouse ? "" : "not "); sioprintf("Kbd: %sloaded\n", _useKbd ? "" : "not "); + sioprintf("Cd: %sloaded\n", _useCd ? "" : "not "); sioprintf("Hdd: %sloaded\n", _useHdd ? "" : "not "); } +bool OSystem_PS2::loadDrivers(IrxType type) +{ + IrxReference *modules; + int numModules; + int res; + + numModules = loadIrxModules(_bootDevice, _bootPath, &modules, type); + startIrxModules(numModules, modules); + + switch (type) { + case IRX_CORE: + /* Init I/O */ + if ((res = fileXioInit()) < 0) { + msgPrintf(FOREVER, "FXIO init failed: %d", res); + quit(); + } + /* Init sound */ + if ((res = SjPCM_Init(0)) < 0) { + msgPrintf(FOREVER, "SjPCM bind failed: %d\n", res); + quit(); + } + break; + + case IRX_CDROM: + /* Init CDROM & RTC Clock */ + if ((res = initCdvdFs()) < 0) { + msgPrintf(FOREVER, "CoDyVDfs bind failed: %d", res); + quit(); + } + sioprintf("Reading RTC\n"); + readRtcTime(); /* depends on CDROM driver! */ + break; + + case IRX_HDD: + /* Check HD is available and formatted */ + if ((hddCheckPresent() < 0) || (hddCheckFormatted() < 0)) { + _useHdd = false; + } + else { + poweroffInit(); + poweroffSetCallback(gluePowerOffCallback, this); + + if (fio.mount("pfs0:", "hdd0:+ScummVM", 0) >= 0) + printf("Successfully mounted!\n"); + else + _useHdd = false; + } + break; + + default: + /* zzz */ + break; + } + + return true; +} + OSystem_PS2::OSystem_PS2(const char *elfPath) { _soundStack = _timerStack = NULL; _printY = 0; @@ -262,6 +320,7 @@ OSystem_PS2::OSystem_PS2(const char *elfPath) { _systemQuit = false; _modeChanged = false; _screenChangeCount = 0; + _mouseVisible = false; _screen = new Gs2dScreen(320, 200, TV_DONT_CARE); @@ -272,10 +331,8 @@ OSystem_PS2::OSystem_PS2(const char *elfPath) { _bootPath = (char *)malloc(128); _bootDevice = detectBootPath(elfPath, _bootPath); - IrxReference *modules; - int numModules = loadIrxModules(_bootDevice, _bootPath, &modules); - if (_bootDevice != HOST_DEV) { + // TODO: reset funx sioprintf("Resetting IOP.\n"); cdvdInit(CDVD_EXIT); cdvdExit(); @@ -298,50 +355,20 @@ OSystem_PS2::OSystem_PS2(const char *elfPath) { // TODO: ps2link 1.46 will stall on "poweroff" init / cb } - startIrxModules(numModules, modules); + _usbMassLoaded = _useMouse = _useKbd = _useCd = _useHdd = _useNet = false; - int res; - if ((res = fileXioInit()) < 0) { - msgPrintf(FOREVER, "FXIO Init failed: %d", res); - quit(); - } - - if ((res = initCdvdFs()) < 0) { - msgPrintf(FOREVER, "CoDyVDfs bind failed: %d", res); - quit(); - } - - if ((res = SjPCM_Init(0)) < 0) { - msgPrintf(FOREVER, "SjPCM Bind failed: %d\n", res); - quit(); - } - - if (_useHdd) { - if ((hddCheckPresent() < 0) || (hddCheckFormatted() < 0)) - _useHdd = false; - - //hddPreparePoweroff(); - poweroffInit(); - - //hddSetUserPoweroffCallback(gluePowerOffCallback, this); - poweroffSetCallback(gluePowerOffCallback, this); - } + loadDrivers(IRX_CORE); + loadDrivers(IRX_CDROM); + // loadDrivers(IRX_USB); // why they only load correctly post HDD ? + // loadDrivers(IRX_INPUT); + #ifndef NO_ADAPTOR + loadDrivers(IRX_HDD); + loadDrivers(IRX_NET); + #endif + loadDrivers(IRX_USB); + loadDrivers(IRX_INPUT); fileXioSetBlockMode(FXIO_NOWAIT); - - _mouseVisible = false; - - sioprintf("reading RTC\n"); - readRtcTime(); - - if (_useHdd) { - // TODO : make partition path configurable - if (fio.mount("pfs0:", "hdd0:+ScummVM", 0) >= 0) - printf("Successfully mounted!\n"); - else - _useHdd = false; - } - initMutexes(); } @@ -510,6 +537,10 @@ bool OSystem_PS2::mcPresent(void) { return false; } +bool OSystem_PS2::cdPresent(void) { + return _useCd; +} + bool OSystem_PS2::hddPresent(void) { return _useHdd; } @@ -528,7 +559,11 @@ bool OSystem_PS2::usbMassPresent(void) { } bool OSystem_PS2::netPresent(void) { - return _useNet; + if (_bootDevice == HOST_DEV || _useNet) { + return true; + } + + return false; } void OSystem_PS2::initSize(uint width, uint height, const Graphics::PixelFormat *format) { @@ -829,7 +864,7 @@ void OSystem_PS2::quit(void) { " li $3, 0x04;" " syscall;" " nop;" - ); + ); */ /* diff --git a/backends/platform/ps2/systemps2.h b/backends/platform/ps2/systemps2.h index 0ae6b2da57..773068bdef 100644 --- a/backends/platform/ps2/systemps2.h +++ b/backends/platform/ps2/systemps2.h @@ -25,6 +25,7 @@ #include "common/system.h" #include "backends/base-backend.h" +#include "backends/platform/ps2/irxboot.h" #include "graphics/palette.h" class Gs2dScreen; @@ -119,6 +120,7 @@ public: void powerOffCallback(void); bool mcPresent(void); + bool cdPresent(void); bool hddPresent(void); bool usbMassPresent(void); bool netPresent(void); @@ -127,6 +129,7 @@ public: int getBootDevice() { return _bootDevice; } private: + bool loadDrivers(IrxType type); void startIrxModules(int numModules, IrxReference *modules); void initMutexes(void); @@ -136,7 +139,7 @@ private: Audio::MixerImpl *_scummMixer; bool _mouseVisible; - bool _useMouse, _useKbd, _useHdd, _usbMassLoaded, _useNet; + bool _useMouse, _useKbd, _useCd, _useHdd, _usbMassLoaded, _useNet; Gs2dScreen *_screen; Ps2Input *_input; |