PS3 OtherOS++ HDD Region Size
The region is created by patching emer_init.self in the CFW. emer_init.self runs when the console enters Safe Mode / Recovery Menu. You can restore the PS3 system through this menu, which recreates the GameOS region on the HDD. By default, the whole drive is used for GameOS. With the patch applied, a samller GameOS region is created, leaving some free space for OtherOS.
emer_init.self patch
From PS3 MFW Builder:
log "Patching [file tail $elf] to create GameOS HDD region of size $size smaller than default"
if {${::NEWMFW_VER} < "4.20"} {
set search "\xE9\x21\x00\xA0\x79\x4A\x00\x20\xE9\x1B\x00\x00\x38\x00\x00\x00"
append search "\x7D\x26\x48\x50\x7D\x49\x03\xA6\x39\x40\x00\x00\x38\xE9\xFF\xF8"
set replace "\x3C\xE9"
set offset 28
} else {
set search "\x7D\x26\x38\x50\xEB\x78\x00\x00\x3B\xA0\x00\x00\x3B\x49\xFF\xF8"
append search "\x38\x00\x00\x00"
set replace "\x3F\x49"
set offset 12
}
if {[string equal ${size} "22GB"] == 1} {
append replace "\xFD\x40"
} elseif {[string equal ${size} "10GB"] == 1} {
append replace "\xFE\xC0"
}
set mask 0
catch_die {::patch_elf $elf $search $offset $replace $mask} "Unable to patch self [file tail $elf]"
The code searches for a byte pattern and patches a 4 byte opcode, 0x38e9fff8 for firmware < 4.20 and 0x3b49fff8 for newer firmwares. These opcodes are disassembled by objdump to the following instructions:
FW < 4.20 | FW >= 4.20 |
---|---|
|
|
Register r9 contains the number of 512-byte sectors on the HDD, while r7/r26 will contain the number of sectors used for the GameOS region, i.e. HDD sectors - 4GB.
The instructions are patched with the following to reserve 22GB:
FW < 4.20 | FW >= 4.20 |
---|---|
|
|
addis RT, RA, SI -> RT = RA + (SI « 16)
Why 0xfd40 = -704 for 22GB?
(22GB / 512) » 16 = 704
If you want xGB for OtherOS++:
xGB = (x « 30) bytes
(xGB / 512) » 16 = ((x « 30) » 9) » 16 = x « 5 = x * 32
For 10GB: 10 * 32 = 320 (-320 = 0xfec0)
The value needs to fit on 16 bits, so the limit is the minimal two’s complement value on 16 bits, i.e. 0x8000. This will reserve (0x8000 « 16) 512-byte sectors, or 1TB.