diff --git a/boot/bin/ipl3_dev.z64 b/boot/bin/ipl3_dev.z64 index 9c015f553..34d958d20 100755 Binary files a/boot/bin/ipl3_dev.z64 and b/boot/bin/ipl3_dev.z64 differ diff --git a/boot/bin/ipl3_prod.z64 b/boot/bin/ipl3_prod.z64 index 48eeb3bb2..4b3a9ce9c 100755 Binary files a/boot/bin/ipl3_prod.z64 and b/boot/bin/ipl3_prod.z64 differ diff --git a/boot/ipl3.c b/boot/ipl3.c index 41e4d9773..083d93cf6 100644 --- a/boot/ipl3.c +++ b/boot/ipl3.c @@ -275,8 +275,18 @@ void stage1(void) int memsize; bool bbplayer = (*MI_VERSION & 0xF0) == 0xB0; + // If Homebrew ROM header indicates an unused Expansion Pak, limit RDRAM discovery + // to 4MiB, effectively simulating a console with Jumper Pak only. + uint32_t rom_version = io_read(0xB000003C) & 0xff; + bool ignoreExpansionPak = ((rom_version & 0x0C) >> 2) == 0x01; + int max_chips = ignoreExpansionPak ? 4 : 8; + if (ignoreExpansionPak) { + debugf("\nWARNING: ROM is configured to ignore Expansion Pak."); + debugf("No more than 2 2-MiB RDRAM chips will be initialized\n"); + } + if (!bbplayer && *RI_SELECT == 0) { - memsize = rdram_init(mem_bank_init); + memsize = rdram_init(mem_bank_init, max_chips); } else { if (bbplayer) { // iQue doesn't have a IPL2 and the OS provides boot flags already in lowmem. @@ -290,6 +300,10 @@ void stage1(void) // we should use and pass along. memsize = *(uint32_t*)0xA0000318; + if (ignoreExpansionPak) { + memsize = 0x400000; + } + // Notice that even if 8 MiB were allocated, the top of the memory is // in-use by save state emulation, so we shouldn't access it anyway. if (memsize == 0x800000) @@ -312,7 +326,7 @@ void stage1(void) // On warm boots, int chip_id = 0; memsize = 0; - for (chip_id=0; chip_id<8; chip_id+=2) { + for (chip_id=0; chip_id= max_chips); // The RI only supports up to 4 chips, so stop here. If we tried to // calibrate a 5th chip connected to the bus, we would confuse RI bank // tracking logic and cause all sorts of problems that would eventually // lead to a crash. We tried that. - if (chip_id >= 8) { - debugf("\nWARNING: more than 4 2-MiB RDRAM chips connected"); - debugf("RI does not support more than 4, skipping remaining\n"); + if (chip_id >= max_chips) { + // Turn off the chip (set DE=0) + rdram_reg_w(chip_id, RDRAM_REG_MODE, (1<<6) | (0<<1) | (1<<2)); + if (max_chips == 8) { + debugf("\nWARNING: more than 4 2-MiB RDRAM chips connected"); + debugf("RI does not support more than 4, skipping remaining\n"); + } break; } diff --git a/boot/rdram.h b/boot/rdram.h index 87606fcf3..56dc21746 100644 --- a/boot/rdram.h +++ b/boot/rdram.h @@ -5,6 +5,6 @@ #ifndef BOOT_RDRAM_H #define BOOT_RDRAM_H -int rdram_init(void (*bank_found)(int chip_id, bool last)); +int rdram_init(void (*bank_found)(int chip_id, bool last), int max_chips); #endif