Expand description
The PI (Peripheral Interface) DMA engine + BSD domain timing registers. The PI (Peripheral Interface) DMA engine (T-14-001).
Moves bytes between RDRAM and the cartridge address space. Pulled forward from Phase 5 into Phase 1 because n64-systemtest loads the rest of its own ELF from cart through PI, so the Phase 1 exit criterion — and with it the v0.2.0 cut criterion — is unreachable without it.
§Register map
From n64brew_wiki/markdown/Peripheral Interface.md:
| Address | Register | Effect |
|---|---|---|
0x0460_0000 | PI_DRAM_ADDR | RDRAM side of the transfer |
0x0460_0004 | PI_CART_ADDR | cart side |
0x0460_0008 | PI_RD_LEN | write triggers RDRAM → cart |
0x0460_000C | PI_WR_LEN | write triggers cart → RDRAM |
0x0460_0010 | PI_STATUS | read: busy flags; write: reset / clear IRQ |
§The two rules that bite
- Length is
len + 1bytes. Writing 0 transfers one byte, not zero. An implementation that transferslenis short by one on every single DMA, which corrupts the last byte of every block — a failure that looks like memory corruption rather than a DMA bug. RDandWRare named from the cartridge’s point of view, soPI_WR_LEN— the one everything actually uses — moves data cart → RDRAM. Getting them the wrong way round makes the first ROM load write the ROM’s own image over itself with uninitialized RDRAM.
Structs§
Constants§
- PI_BASE
- Base of the PI register block.
- PI_
BSD_ DOM1_ LAT PI_BSD_DOM1_LAT— domain-1 latency. DOM2’s block follows at+0x10.- PI_
BSD_ DOM1_ PGS PI_BSD_DOM1_PGS— domain-1 page size (2^(PGS+2)bytes).- PI_
BSD_ DOM1_ PWD PI_BSD_DOM1_PWD— domain-1 pulse width.- PI_
BSD_ DOM1_ RLS PI_BSD_DOM1_RLS— domain-1 release.- PI_
BSD_ DOM2_ LAT PI_BSD_DOM2_LAT— domain-2 latency (the SRAM /FlashRAMbus).- PI_
BSD_ DOM2_ PGS PI_BSD_DOM2_PGS— domain-2 page size.- PI_
BSD_ DOM2_ PWD PI_BSD_DOM2_PWD— domain-2 pulse width.- PI_
BSD_ DOM2_ RLS PI_BSD_DOM2_RLS— domain-2 release (end of the register block).- PI_
CART_ ADDR PI_CART_ADDR.- PI_
DRAM_ ADDR PI_DRAM_ADDR.- PI_
RD_ LEN PI_RD_LEN— writing it starts an RDRAM → cart transfer.- PI_
STATUS PI_STATUS.- PI_
WR_ LEN PI_WR_LEN— writing it starts a cart → RDRAM transfer.- STATUS_
DMA_ BUSY PI_STATUSbit 0 — a DMA is in progress.- STATUS_
INTERRUPT PI_STATUSbit 3 — the PI interrupt is asserted.- STATUS_
IO_ BUSY PI_STATUSbit 1 — an I/O transfer is in progress.- STATUS_
W_ CLR_ INTR PI_STATUSwrite bit 1 — clear the PI interrupt.- STATUS_
W_ RESET PI_STATUSwrite bit 0 — reset the controller and abort any DMA.