# The EE's DMAC, INTC and timers Sources: EEUM ch. 3-5 (Sony, DOC, facts only, cited by section); ps2tek "DMA Controller", "Interrupt Controller", "EE Timers" (tier 3); judges: ps2autotests `dma/dmac/*`, `dma/spr/*`, `kernel/ee/interrupt/*` (ISC, TEST ROM). ## DMAC (EEUM ch. 5) Ten channels (EEUM §5.1 table): | ID | Channel | Direction | Priority group | Physical mode | Stall | MFIFO | Chain | Interleave | Address stack | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | 0 | VIF0 | to | A | slice | | | source | | 2 | | 1 | VIF1 | both (from: GS readback via BUSDIR) | C | slice | drain | drain | source | | 2 | | 2 | GIF (PATH3) | to | C | slice | drain | drain | source | | 2 | | 3 | fromIPU | from | C | slice | source | | | | | | 4 | toIPU | to | C | slice | | | source | | | | 5 | SIF0 (IOP to EE) | from | C | slice | source | | destination | | | | 6 | SIF1 (EE to IOP) | to | C | slice | drain | | source | | | | 7 | SIF2 | both | B | slice | | | | | | | 8 | fromSPR | from | C | burst | source | source | destination | yes | | | 9 | toSPR | to | C | burst | | | source | yes | | - **Physical modes**: burst (all at once; with cycle stealing on, suspended at each 128-byte boundary for the EE Core) for the scratchpad channels; slice (8-qword slices with arbitration at each boundary) for the rest. Cycle stealing is D_CTRL.RELE; after giving the bus back the DMAC waits RCYC bus cycles (EEUM §5.2.1). - **Logical modes**: normal, source chain and destination chain (DMAtag-driven: refe/cnt/next/ref/refs/call/ret/end in source chain; cnt/cnts/end in destination chain: EEUM §5.6; ps2tek "DMAC Chain Mode"), interleave (rectangles between RAM and the scratchpad, D_SQWC's TQWC/SQWC). - **Stall control**: a source channel (SIF0, fromIPU, fromSPR) updates D_STADR as it writes memory, and a drain channel (VIF1, GIF, SIF1) stops at that address, so two channels pipeline through memory (EEUM §5.3.2). **MFIFO**: fromSPR fills a ring buffer in memory (D_RBOR, D_RBSR) that VIF1 or GIF drains (EEUM §5.5). - **Arbitration**: by priority group and D_PCR; tags may carry priority bits (EEUM §5.3). - **Interrupts**: per-channel and stall/MFIFO-empty/bus-error bits in D_STAT, raised on the **separate INT1 line** to the EE Core, not through the INTC (EEUM §3.1, §5.4). - **The scratchpad as a memory**: any channel whose memory side is "main memory" may use the scratchpad instead (bit 31 of the address, as homebrew headers name it: ps2sdk `ee/dma/include`; EEUM §5.1 says "can select"). DMA to the scratchpad goes through the EE Core's SPRAM port (ee-python cop0-tlb-caches.md), alternating with the core. - The channels' throughput: one qword per bus cycle on the 128-bit main bus at best (2.36 GB/s; arithmetic: 16 bytes x 147.456 MHz). Real rates depend on the peripheral's FIFO and RDRAM; **U5**. ## INTC (EEUM ch. 3) INT0 to the EE Core is `I_STAT & I_MASK != 0`. I_STAT latches the **edge** of each source (EEUM §3.1: "taken into the I_STAT register at the edge"); while a bit is set, a further edge of that source is not detected (EEUM §3.2). Writing 1 clears a bit of I_STAT; writing 1 to I_MASK toggles the mask bit (ps2tek "Interrupt Controller"; EEUM §3.2). | Bit | Source | Edge | | --- | --- | --- | | 0 | GS | falling | | 1 | SBUS (the IOP side) | falling | | 2 | V-blank start | rising | | 3 | V-blank end | falling | | 4, 5 | VIF0, VIF1 (interrupt-bit VIFcode or error; the VIF stalls) | | | 6, 7 | VU0, VU1 (microinstruction with the interrupt bit; the VU stalls) | | | 8 | IPU | | | 9-12 | timers 0-3 | | | 13 | SFIFO error | | | 14 | VU0 watchdog (VU0 in RUN too long: ForceBreak) | | (EEUM §3.1 tables.) Order of interrupts when several fire together is what `kernel/ee/interrupt/intc_order` and `dmac_order` print (TEST ROM): the judge for the board's ordering of INT0 against INT1. ## Timers (EEUM ch. 4; ps2tek "EE Timers") Four 16-bit timers at 10000000h + n x 800h: COUNT, MODE, COMP, and HOLD for timers 0 and 1 (latched when an SBUS interrupt occurs). Clock BUSCLK, /16, /256 or H-blank; gating on H- or V-blank with four gate modes; clear on compare; compare and overflow interrupts. **Timer interrupts are edge-triggered on the flag bits**: a new interrupt is sent only when a flag goes from 0 to 1 (ps2tek, which names a game that depends on it; tier 3, tagged OBSERVED until a test shows it). Timer 3 is the BIOS's alarm timer (ps2tek). ## Unknowns U5 DMA rates per channel and the RDRAM's contribution; U6 the cycle at which a slice boundary's arbitration takes effect; U7 D_STAT's interaction with INT1 when a channel completes while CIS is already set (the same "edge" question as the INTC's); U8 the counter behaviour of H-blank-clocked timers in interlaced modes.