Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified boot/bin/ipl3_dev.z64
Binary file not shown.
Binary file modified boot/bin/ipl3_prod.z64
Binary file not shown.
18 changes: 16 additions & 2 deletions boot/ipl3.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)
Expand All @@ -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; chip_id+=2) {
volatile uint32_t *ptr = (void*)0xA0000000 + chip_id * 1024 * 1024;
ptr[0]=0;
ptr[0]=0x12345678;
Expand Down
14 changes: 9 additions & 5 deletions boot/rdram.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ static int rdram_calibrate_current(uint16_t chip_id)
return autocc;
}

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)
{
// Configure RI/RAC output current (towards RDRAM). This is necessary to
// allow communication with the chips.
Expand Down Expand Up @@ -386,15 +386,19 @@ int rdram_init(void (*bank_found)(int chip_id, bool last))
// Call the callback on the previous chip (if this is not the first),
// now that we know if it's the last one or not.
if (chip_id)
bank_found(chip_id-2, false);
bank_found(chip_id-2, 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;
}

Expand Down
2 changes: 1 addition & 1 deletion boot/rdram.h
Original file line number Diff line number Diff line change
Expand Up @@ -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