Skip to content

Commit

Permalink
Device Emulator, with ATA support
Browse files Browse the repository at this point in the history
  • Loading branch information
rickgaiser committed Sep 7, 2023
1 parent 040d80b commit 563ceac
Show file tree
Hide file tree
Showing 78 changed files with 1,095 additions and 538 deletions.
46 changes: 24 additions & 22 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@ EESIO_DEBUG?=0
IOPCORE_DEBUG?=0

all:
$(MAKE) -C iop/cdvdfsv all DEBUG=$(IOPCORE_DEBUG)
$(MAKE) -C iop/cdvdman all DEBUG=$(IOPCORE_DEBUG) USE_BDM=1
$(MAKE) -C iop/fakemod all DEBUG=$(IOPCORE_DEBUG)
$(MAKE) -C iop/fhi_bdm all DEBUG=$(IOPCORE_DEBUG)
$(MAKE) -C iop/esr_cdvdv all DEBUG=$(IOPCORE_DEBUG)
$(MAKE) -C iop/esr_pcdvdv all DEBUG=$(IOPCORE_DEBUG)
$(MAKE) -C iop/smap all DEBUG=$(IOPCORE_DEBUG)
$(MAKE) -C iop/imgdrv all DEBUG=$(IOPCORE_DEBUG)
$(MAKE) -C iop/isofs all DEBUG=$(IOPCORE_DEBUG)
$(MAKE) -C ee/ee_core all EESIO_DEBUG=$(EESIO_DEBUG)
$(MAKE) -C ee/loader all DEBUG=0
$(MAKE) -C iop/atad_emu all DEBUG=$(IOPCORE_DEBUG)
$(MAKE) -C iop/cdvdfsv all DEBUG=$(IOPCORE_DEBUG)
$(MAKE) -C iop/cdvdman_emu all DEBUG=$(IOPCORE_DEBUG)
$(MAKE) -C iop/cdvdman_esr1 all DEBUG=$(IOPCORE_DEBUG)
$(MAKE) -C iop/cdvdman_esr2 all DEBUG=$(IOPCORE_DEBUG)
$(MAKE) -C iop/fakemod all DEBUG=$(IOPCORE_DEBUG)
$(MAKE) -C iop/fhi_bdm all DEBUG=$(IOPCORE_DEBUG)
$(MAKE) -C iop/imgdrv all DEBUG=$(IOPCORE_DEBUG)
$(MAKE) -C iop/isofs all DEBUG=$(IOPCORE_DEBUG)
$(MAKE) -C iop/smap_udpbd all DEBUG=$(IOPCORE_DEBUG)
$(MAKE) -C ee/ee_core all EESIO_DEBUG=$(EESIO_DEBUG)
$(MAKE) -C ee/loader all DEBUG=0

copy:
$(MAKE) -C ee/loader copy
Expand All @@ -21,17 +22,18 @@ format:
find . -type f -a \( -iname \*.h -o -iname \*.c \) | xargs clang-format -i

clean:
$(MAKE) -C iop/cdvdfsv clean
$(MAKE) -C iop/cdvdman clean USE_BDM=1
$(MAKE) -C iop/fakemod clean
$(MAKE) -C iop/fhi_bdm clean
$(MAKE) -C iop/esr_cdvdv clean
$(MAKE) -C iop/esr_pcdvdv clean
$(MAKE) -C iop/smap clean
$(MAKE) -C iop/imgdrv clean
$(MAKE) -C iop/isofs clean
$(MAKE) -C ee/ee_core clean
$(MAKE) -C ee/loader clean
$(MAKE) -C iop/atad_emu clean
$(MAKE) -C iop/cdvdfsv clean
$(MAKE) -C iop/cdvdman_emu clean
$(MAKE) -C iop/cdvdman_esr1 clean
$(MAKE) -C iop/cdvdman_esr2 clean
$(MAKE) -C iop/fakemod clean
$(MAKE) -C iop/fhi_bdm clean
$(MAKE) -C iop/imgdrv clean
$(MAKE) -C iop/isofs clean
$(MAKE) -C iop/smap_udpbd clean
$(MAKE) -C ee/ee_core clean
$(MAKE) -C ee/loader clean

# Start on PS2 (ps2link/ps2client)
run:
Expand Down
76 changes: 53 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,64 +1,94 @@
# neutrino
Small, Fast and Modular PS2 Game Loader
Small, Fast and Modular PS2 Device Emulator

## Design
A neutrino is a particle with almost zero mass, and that's what this game loaders primary goal is. To have almost 0 mass when running ingame to maximize game compatibility.
A neutrino is a particle with almost zero mass, and that's what this device emulator's primary goal is. To have almost 0 mass when emulating devices to maximize compatibility.

Neutrino also does not have a user interface, instead it's meant to be integrated as a backend to a frontend (user interface). Possible user interfaces can be uLaunchELF, XEB+, OPL or any new user interface. This makes neutrino much more easy to maintain, and allows many more game loaders to be made using neutrino as the backend.
Neutrino also does not have a user interface, instead it's meant to be integrated as a backend to a frontend (user interface). Possible user interfaces can be uLaunchELF, XEB+, OPL or any new user interface. This makes neutrino much more easy to maintain, and allows many more applications to be made using neutrino as the backend.

With neutrino all modules are... modular. They are in a separate folder called `modules`. This allows the user to replace them with new and improved modules. For instance when there is an improved mx4sio driver: simply replace the mx4sio_bd.irx with the new version, and done. No need for a complete new backend or frontend.
With neutrino all modules are... modular. They are in a separate folder called `modules`. This allows the user add new and improved modules. What modules are loaded is fully configurable using TOML config files in the `config` folder.

## ISO file storage support
The following storage devices are supported:
## Environments
An environment in neutrino describes what IOP modules are loaded and defines what features the environment has. In neutrino there are 3 environments:
- Boot Environment (BE): environment neutrino is loaded from (by uLE / ps2link / ...), containing neutrino, configuration files and drivers
- Load Environment (LE): neutrino's loader.elf reboots into the LE, containing virtual disk images
- Emulation Environment (EE): neutrino's ee_core.elf reboots into the EE, emulating devices

## Backing Store Driver
A backing store driver provides a storage location for storing virtual disk images. For instance of DVD's, HDD's or MC's.
The following backing storage devices are supported:
- USB
- ATA (internal HDD)
- MX4SIO
- ATA (internal HDD)
- UDPBD
- iLink / IEEE1394

These are all BDM drivers, or "Block Devices". On all devices the following file systems are supported:
- exFat
- FAT32 (/16/12)

## File type support
Only .iso files are supported.
During the loading phase, the exFat driver will be loaded and all files are accessable as `mass0:<file>` or `mass1:<file>`.

## CD/DVD support
It is possible to use the following CD's / DVD's:
- Original CD's / DVD's (region free)
- ESR patched DVD's
## CD/DVD emulation
The following CD/DVD emulation drivers are supported:
- No: using original CD's / DVD's in the optical drive
- ESR: using ESR patched DVD's in the optical drive
- File: using an iso file from the backing store

## ATA HDD emulation
The following HDD emulation drivers are supported:
- No: using ATA HDD in the PS2
- File: using a virtual HDD image file from the backing store

## Usage instructions
When running neutrino using ps2link, the following usage instructions will be shown when an invalid argument is passed:
```
Usage: neutrino.elf -drv=<driver> -iso=<path>\n");
Usage: neutrino.elf options
Options:\n");
-drv=<driver> Select device driver, supported are:
Options:
-bsd=<driver> Backing store drivers, supported are:
- no (default)
- ata
- usb
- mx4sio
- udpbd
- ilink
- dvd
-dvd=<mode> DVD emulation mode, supported are:
- no (default)
- esr
-iso=<file> Select iso file (full path!)
-elf=<file> Select elf file inside iso to boot
- <file>
-ata0=<mode> ATA HDD 0 emulation mode, supported are:
- no (default)
- <file>
NOTE: only both emulated, or both real.
mixing not possible
-ata1=<mode> See -ata0=<mode>
-elf=<file> ELF file to boot, supported are:
- auto (elf file from cd/dvd) (default)
- <file>
-mt=<type> Select media type, supported are:
- cd
- dvd
Defaults to cd for size<=650MiB, and dvd for size>650MiB
-gc=<compat> Game compatibility modes, supported are:
- 0: Disable builtin compat flags
- 1: IOP: Accurate reads (sceCdRead)
- 2: IOP: Sync reads (sceCdRead)
- 3: EE : Unhook syscalls
- 5: IOP: Emulate DVD-DL
Multiple options possible, for example -gc=23
-eC Enable eecore debug colors
--b Break, all following parameters are passed to the ELF
Usage examples:
ps2client -h 192.168.1.10 execee host:neutrino.elf -drv=usb -iso=mass:path/to/filename.iso
ps2client -h 192.168.1.10 execee host:neutrino.elf -drv=dvd
ps2client -h 192.168.1.10 execee host:neutrino.elf -drv=esr
neutrino.elf -bsd=usb -dvd=mass:path/to/filename.iso
neutrino.elf
neutrino.elf -dvd=esr
neutrino.elf -elf=rom0:OSDSYS --b SkipMc SkipHdd BootBrowser
```
1 change: 1 addition & 0 deletions ee/ee_core/include/ee_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ extern int GameMode;
#define BDM_USB_MODE (1<<2)
#define BDM_UDP_MODE (1<<3)
#define BDM_ATA_MODE (1<<4)
#define BDM_NOP_MODE (1<<31)

extern int EnableDebug;
#define GS_BGCOLOUR *((volatile unsigned long int *)0x120000E0)
Expand Down
2 changes: 1 addition & 1 deletion ee/ee_core/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ int isInit = 0;
// Global data
u32 g_compat_mask = 0;
char GameID[16];
int GameMode;
int GameMode = BDM_NOP_MODE;
int EnableDebug = 0;
int *gCheatList = NULL; // Store hooks/codes addr+val pairs

Expand Down
2 changes: 2 additions & 0 deletions ee/ee_core/src/syshook.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ void sysLoadElf(char *filename, int argc, char **argv)

DPRINTF("t_loadElf()\n");

#if 1
DPRINTF("t_loadElf: Resetting IOP...\n");

set_reg_disabled = 0;
Expand All @@ -66,6 +67,7 @@ void sysLoadElf(char *filename, int argc, char **argv)
iop_reboot_count = 1;

SifInitRpc(0);
#endif
LoadFileInit();

DPRINTF("t_loadElf: elf path = '%s'\n", filename);
Expand Down
51 changes: 26 additions & 25 deletions ee/loader/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ all: $(EE_BIN_PACKED)

# Games that use the HDD in one way or another
#GAME = 'DVD/The Sims 2 (U).iso'
GAME = 'DVD/Metal Saga (U).iso'
#GAME = 'DVD/Metal Saga (U).iso'

# These games allocate ALL IOP RAM as an anti-piracy method
# Special IOP code is needed (in cdvdman?) to counter this
Expand Down Expand Up @@ -63,7 +63,7 @@ GAME = 'DVD/Metal Saga (U).iso'
# Tested, working offline
# ONLINE this game uses a huge amount of IOP RAM. This causes IRX modules to fail to load
# causing random crashes such as black screen or network adapter not detected.
#GAME = 'DVD/Ratchet Clank - Up Your Arsenal (U).iso'
GAME = 'DVD/Ratchet Clank - Up Your Arsenal (U).iso'
#GAME = 'DVD/Ratchet Clank 3 (E).iso'

# Tested, working
Expand Down Expand Up @@ -97,7 +97,7 @@ GAME = 'DVD/Metal Saga (U).iso'


run: all copy
ps2client -h 192.168.1.10 execee host:$(EE_BIN_PACKED) -drv=udpbd -iso=mass:$(GAME)
ps2client -h 192.168.1.10 execee host:$(EE_BIN_PACKED) -bsd=udpbd -dvd=mass:$(GAME)

sim: all copy
flatpak --filesystem=host run net.pcsx2.PCSX2 $(PWD)/ee/loader/$(EE_BIN_PACKED)
Expand All @@ -110,28 +110,29 @@ clean:
copy:
rm -rf modules
mkdir -p modules
cp ../../iop/cdvdfsv/irx/cdvdfsv.irx modules
cp ../../iop/cdvdman/irx/cdvdman.irx modules
cp ../../iop/fakemod/irx/fakemod.irx modules
cp ../../iop/fhi_bdm/irx/fhi_bdm.irx modules
cp ../../iop/esr_cdvdv/irx/esr_cdvdv.irx modules
cp ../../iop/esr_pcdvdv/irx/esr_pcdvdv.irx modules
cp ../../iop/smap/irx/smap.irx modules
cp ../../iop/imgdrv/irx/imgdrv.irx modules
cp ../../iop/isofs/irx/isofs.irx modules
cp ../ee_core/ee_core.elf modules
cp $(PS2SDK)/iop/irx/eesync.irx modules
cp $(PS2SDK)/iop/irx/iomanX.irx modules
cp $(PS2SDK)/iop/irx/fileXio.irx modules
cp $(PS2SDK)/iop/irx/bdm.irx modules
cp $(PS2SDK)/iop/irx/bdmfs_fatfs.irx modules
cp $(PS2SDK)/iop/irx/ata_bd.irx modules
cp $(PS2SDK)/iop/irx/usbd_mini.irx modules
cp $(PS2SDK)/iop/irx/usbmass_bd_mini.irx modules
cp $(PS2SDK)/iop/irx/mx4sio_bd_mini.irx modules
cp $(PS2SDK)/iop/irx/ps2dev9.irx modules
cp $(PS2SDK)/iop/irx/iLinkman.irx modules
cp $(PS2SDK)/iop/irx/IEEE1394_bd_mini.irx modules
cp ../../iop/atad_emu/irx/atad_emu.irx modules
cp ../../iop/cdvdfsv/irx/cdvdfsv.irx modules
cp ../../iop/cdvdman_emu/irx/cdvdman_emu.irx modules
cp ../../iop/cdvdman_esr1/irx/cdvdman_esr1.irx modules
cp ../../iop/cdvdman_esr2/irx/cdvdman_esr2.irx modules
cp ../../iop/fakemod/irx/fakemod.irx modules
cp ../../iop/fhi_bdm/irx/fhi_bdm.irx modules
cp ../../iop/imgdrv/irx/imgdrv.irx modules
cp ../../iop/isofs/irx/isofs.irx modules
cp ../../iop/smap_udpbd/irx/smap_udpbd.irx modules
cp ../ee_core/ee_core.elf modules
cp $(PS2SDK)/iop/irx/eesync.irx modules
cp $(PS2SDK)/iop/irx/iomanX.irx modules
cp $(PS2SDK)/iop/irx/fileXio.irx modules
cp $(PS2SDK)/iop/irx/bdm.irx modules
cp $(PS2SDK)/iop/irx/bdmfs_fatfs.irx modules
cp $(PS2SDK)/iop/irx/ata_bd.irx modules
cp $(PS2SDK)/iop/irx/usbd_mini.irx modules
cp $(PS2SDK)/iop/irx/usbmass_bd_mini.irx modules
cp $(PS2SDK)/iop/irx/mx4sio_bd_mini.irx modules
cp $(PS2SDK)/iop/irx/ps2dev9.irx modules
cp $(PS2SDK)/iop/irx/iLinkman.irx modules
cp $(PS2SDK)/iop/irx/IEEE1394_bd_mini.irx modules

include ../../Defs.make
include ../Rules.make
26 changes: 26 additions & 0 deletions ee/loader/config/bdm.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Name of loaded config, to show to user
name = "Block Device Manager (with exFat and FHI)"

# Modules to load in load environment
# the end result of these drivers (in combination with the BDM BD drivers) must
# result in the "mass:" path being available to the load environment
[[module-load]]
file = "bdm.irx"
[[module-load]]
file = "bdmfs_fatfs.irx"
# These 3 drivers are needed for isofs
# it would be nice if we could remove that dependency
[[module-load]]
file = "iomanX.irx"
[[module-load]]
file = "fileXio.irx"
[[module-load]]
file = "isofs.irx"

# Modules to load in emulation environment
# the end result of these drivers (in combination with the BDM BD drivers) must
# result in the file handle interface (fhi) to be available to the emulation
# environment
[[module-emu]]
file = "fhi_bdm.irx"
ioprp = "FHI" # ID used by loader
11 changes: 3 additions & 8 deletions ee/loader/config/drv-ata.toml → ee/loader/config/bsd-ata.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
# Name of device driver, to show to user
# Name of loaded config, to show to user
name = "ATA via DEV9 BDM driver"

# Type of device driver, support for this type must exist in
# type-<type>-load.toml for the load environment
# type-<type>-ingame.toml for the ingame environment
type = "bdm"

# Device mode as used by the EECORE (used for patches), support for this type must exist in the EECORE
mode = "BDM_ATA_MODE"
# Drivers this driver depends on (config file must exist)
depends = "bdm"

# Modules to load
[[module]]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
# Name of device driver, to show to user
# Name of loaded config, to show to user
name = "iLink/FireWire/IEEE1394 BDM driver"

# Type of device driver, support for this type must exist in
# type-<type>-load.toml for the load environment
# type-<type>-ingame.toml for the ingame environment
type = "bdm"

# Device mode as used by the EECORE (used for patches), support for this type must exist in the EECORE
mode = "BDM_ILK_MODE"
# Drivers this driver depends on (config file must exist)
depends = "bdm"

# Modules to load
[[module]]
Expand Down
9 changes: 9 additions & 0 deletions ee/loader/config/bsd-mx4sio.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Name of loaded config, to show to user
name = "MX4SIO in MC2 BDM driver"

# Drivers this driver depends on (config file must exist)
depends = "bdm"

# Modules to load
[[module]]
file = "mx4sio_bd_mini.irx"
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
# Name of device driver, to show to user
# Name of loaded config, to show to user
name = "UDPBD - UDP Block Device BDM driver"

# Type of device driver, support for this type must exist in
# type-<type>-load.toml for the load environment
# type-<type>-ingame.toml for the ingame environment
type = "bdm"

# Device mode as used by the EECORE (used for patches), support for this type must exist in the EECORE
mode = "BDM_UDP_MODE"
# Drivers this driver depends on (config file must exist)
depends = "bdm"

# Modules to load
[[module]]
file = "ps2dev9.irx"
[[module]]
file = "smap.irx"
file = "smap_udpbd.irx"
args = "ip=192.168.1.10"

# Modules of the game that are faked/blocked
Expand Down
Loading

0 comments on commit 563ceac

Please sign in to comment.