As promised, I would do a write-up to share about how the PS2 is to be initialized, from within an memory-card update program.
However, I am still reverse-engineering and updating my code from FMCB, so that they'll be more usable for external projects... so I don't really have any code to show at the moment I am writing this. Over time, I will make new posts to elaborate on things that I don't elabore here.
I have decided to consoliate the OSD init stuff into a new library, named libosdinit. It may make things easier for new software to work with the OSD configuration.
Although we have various samples floating around the Internet in the form of the FreeVast and FMCB v1.7 source code, I found that FMCB v1.8 did not quite have an accurate method of initializing the PS2.
I won't get into the basics of initializing SIFRPC/SIFCMD services, as those are the basics required for each project.
Things that need to be done:
Other tips:
However, I am still reverse-engineering and updating my code from FMCB, so that they'll be more usable for external projects... so I don't really have any code to show at the moment I am writing this. Over time, I will make new posts to elaborate on things that I don't elabore here.
I have decided to consoliate the OSD init stuff into a new library, named libosdinit. It may make things easier for new software to work with the OSD configuration.
Although we have various samples floating around the Internet in the form of the FreeVast and FMCB v1.7 source code, I found that FMCB v1.8 did not quite have an accurate method of initializing the PS2.
I won't get into the basics of initializing SIFRPC/SIFCMD services, as those are the basics required for each project.
Things that need to be done:
- Initialize SIFCMD/SIFRPC.
- Reboot the IOP.
- While homebrew software generally use the ROM modules and things may work without this step, it does not result in uniform behaviour across all console models. Depending on the ROM version, most PlayStation 2 consoles have the modules listed in rom0:/EELOADCNF/IOPBTCONF loaded, when the update is loaded by EELOAD.
- Not rebooting the IOP may offer non-uniform behaviour across all consoles, as modules like NCDVDMAN are crippled.
- Hence it is better to reboot the IOP with no argument (empty string), to load the default IOP kernel modules instead.
- Initialize SIFRPC again after the IOP reboot completes.
- Initialize system paths with osdInitSystemPaths(), if it is desired to retrieve the system directory names from libosdinit.
- Perform boot certification to unlock the CD/DVD drive. Boot certification is done with the content of rom0:ROMVER.
- This may be to validate the binding between the MECHACON and the boot ROM.
- Do not check for the result of this operation because early PlayStation 2 models do not support boot certification (only B-chassis and later support it).
- I think this may not work on the DTL-H301xx consoles because they seem to have ROM v1.50, but boot certification within OSDSYS of these sets is hardcoded to boot certify with 1,10 as the version number... but we cannot quite cover all cases without additional bloat (and very few people use those sets).
- ROMVER strings have this format: VVVVRTYYYYMMDD (i.e. 0160HC20020426 for v1.60, Asia, CEX, 2002/04/26).
Code:
int fd;
char romver[16], RomName[4];
if((fd = open("rom0:ROMVER", O_RDONLY)) >= 0)
{
read(fd, romver, sizeof(romver));
close(fd);
// E.g. 0160HC = 1,60,'H','C'
RomName[0]=(romver[0]-'0')*10 + (romver[1]-'0');
RomName[1]=(romver[2]-'0')*10 + (romver[3]-'0');
RomName[2]=romver[4];
RomName[3]=romver[5];
sceCdBootCertify(RomName);
}
- This is optional because we are not Sony, but you can disable DVD Video playback here:
Code:
do{
sceCdForbidDVDP(&result);
}while(result&8);
- While not done in the ROM OSD, the HDD Browser update applies the full OSD kernel patch (for SCPH-10000 & SCPH-15000) here.
- This updates the SetOsdConfigParam, GetOsdConfigParam, SetOsdConfigParam2 and GetOsdConfigParam2 syscalls, as well as ExecPS2.
- By updating the OSD syscalls, the kernel is also marked as fully patched.
- This is probably only done by the HDD Browser itself (rather than the system driver update) because only a new browser can use the updated syscalls correctly. Updating the syscalls would prevent the old browser in ROM from changing the language setting (hence blocking the user), if the HDD browser update cannot be booted.
- We can do this with:
Code:
InitOsd();
- Load the OSD configuration from the EEPROM, parse it and set the settings into the EE kernel with SetOsdConfigParam and SetOsdConfigParam2.
- SetOsdConfigParam2 is not supported by the unpatched SCPH-10000 and SCPH-15000 kernel. Invoking this will cause an exception.
- I plan to move the code for loading the configuration from the EEPROM and parsing it into a new library (libosdinit), as how Sony probably had... but that is still a work in progress. I will elaborate on this part at a later date.
- How it is currently done in FMCB:
Code:
int result; ConfigParam config; Config2Param config2; <Load and parse configuration here. config.version is set to 2, as FMCB implements the configuration mechanism from a late ROM> SetOsdConfigParam(&config); GetOsdConfigParam(&config); //Unpatched Protokernels cannot retain values set in the version field, and don't support SetOsdConfigParam2(). if(config.version) SetOsdConfigParam2(&config2, 4, 0);
- Before the video mode is initalized with the graphics library, the GCONT (RGB/YPbPr) setting must be set:
Code:
SetGsVParam(config.videoOutput?1:0);
Other tips:
- Do not use the board-specific IRX modules. While some old homebrew software do that, it is bad practice because this will make your software not compatible with some (usually rarer) PlayStation 2 consoles like the early models, the PSX, and perhaps the system 246.
- All T* modules. T-modules like TSIO2MAN are used by TESTMODE.
- All X* modules. X-modules like XSIO2MAN are used by the new OSDSYS program.
- All P* modules. P-modules like PCDVDMAN are used by the PSX's OSDSYS program.
- All IOPRP images like EELOADCNF and OSDCNF. There is generally no need to reboot the IOP with any of these. To reboot the IOP with the default IOP kernel modules, specify an empty string.
- While the modules in rom0 are generally present, they aren't actually documented to be available. Even if they are present on all CEX consoles (i.e. rom0:MCMAN), this may cause problems on non-standard consoles like the TOOL (rom0:MCMAN is bounded to the SDK version!).
- After a cold boot, the controller ports seem to not be immediately powered-up on the DECKARD slim consoles (SCPH-75000 and later). Even if a controller is actutally connected, it appears to software as being disconnected.
- This was probably not a problem for Sony because they did not need to implement any sort of trigger/override button (i.e. hold R1 to boot LaunchELF).
- If necessary, wait until either a pad is detected or a timeout expires.
- As of the Dragon-series MECHACON (SCPH-50000 and later), issuing any blocking command will cause a lockup if the drive is not ready (i.e. no disc inserted), as the MECHACON no longer replies until the drive is ready.
- OSDSYS seems to avoid this by checking on the disc type first, with sceCdDiskType(). Further actions are only taken if a valid disc is recognized.
- When sceCdInit() is called, use the non-blocking mode to initialize the drive.
- sceCdDiskReady, sceCdSync and sceCdTrayReq cannot be used when no disc is inserted.
- While the browser does have options (i.e. disc speed, texture) for the PlayStation driver, these settings are always erased with every IOP reboot, when EECONF is loaded. Not being able to load them is not an issue with your code!
- EECONF opens that configuration block of the MECHACON EEPROM and zero-fills it.
- EECONF is responsible for initializing various peripherals. It also initializes the MAC address, SPEED capabilties and manipulates the ROM version data, by collaborating with the DECKARD emulator (SCPH-75000 and later).
- Part of EECONF's actions were previously implemented as part of FMCB v1.8's init.irx module, which is unnecessary.
