

P2MESAC = PS2MAdd Emulator for the SPEED ATA Controller

by Wisi

2017.01.07


The models of PS2 after SCPH-75000 (included) lack the Dev9 interface and the ATA Controller of the SPEED chip. For this reason, a PATA HDD cannot be directly connected to them. However, it is possible to use a simple logic circuit that functions as a very simple ATA Controller, to conect a PATA HDD to the SSBUS. This roughly is what HDpro does.
PS2MAdd is a project, started with the idea to clone HDpro, but was later developed to support DMA transfer modes up to MDMA 2, and the register interface was changed, so that it no longer functions as an HDpro clone (mainly in order to optimize the logic circuitry to fit in the chosen CPLD).

Starting with the SCPH-75000 PS2 models, the IOP was changed to a Power PC CPU, that runs an emulator (called DECKARD), which emulates the original MIPS IOP. Another 2MB of RAM were added for the needs of the emulator.

Because the emulator executes from RAM and all the PPC-IOP memory is accessible from the side of the EE CPU, it's code can be altered. This enables emulating the SPEED ATA Controller registers, and redirecting the interface to the PS2MAdd hardware, which is what this program does.

When this program is executed, it loads the code that emulates the ATA Controller, and once it exits, any program started afterwards would (should) detect the presence of the ATA Controller and connect to the HDD as if it were run on a "fat" PS2.



This program works (almost) correctly with the current versions of uLaunchElf, Simple Media System, Open PS2 Loader and other homebrew software. There are some incompatibilities with the OPL HDL Server, and other software.  
The emulation is far from complete, and the code relies heavily on the way the ps2atad and ps2dev9 drivers function.

The maximum transfer speed of a transfer of a file on the HDD, from one directory to another, varies betwen 3.5MB/s and 4MB/s, depending on the time it takes for the HDD to seek between the two files. This should mean that the actual speed is ~8MB/s. The significant decrease in speed (from the theoratical maximum of 16MB/s for MDMA 2) is in part caused by the slow mechanism for pooling interrupts used and the non-optimized emulation.



The code at this point is experimental, but given that it is highly unlikely for anybody to use it, it is presented as is. 
It can serve as an (not entirely good :D ) example for changing the code of the emulator running on the PPC-IOP.

The poweroff.irx and ps2dev9.irx are included from the PS2SDK without modification. Initialization code for the emulation program is added to atad_p2m_init.irx. The initial idea was to add a configuration and testing program to atad_p2m_init.irx.

The PPC-IOP is reset on warm reset of the console (pushing the power button for a short period of time), which clears this program. The PPC-IOP is not reset in "IOP Reset" when the IOP is reloaded with new modules.



Special thanks to:

	- SP193 - for suspecting the presence of DECKARD (which I didn't believe in) and helping with information and explainations on many occasions.

	- Maximus32 - for setting-up the compiler for PPC code and making the first sample program, compiled from C-code to run of the PPC-IOP.

	- noca$h and all the sources of the psx-spx document, that helped a lot in understanding and using the IOP hardware.

	- the many contributors to the PS2SDK and many sources of information on the net.

