# MMU, caches and the MPCore system: what the core owns Sources: ARM11 MPCore TRM r2p0 (DDI 0360F), the ARM ARM DDI 0100I part B (VMSAv6), and GBATEK's "ARM CP15" (ARM11 rows), "ARM11 MPCore ..." and "3DS Memory and I/O Map" sections. DOC unless marked. What the 3DS's own configuration is (cache sizes, revision) is an unknown wherever GBATEK does not state it: the TRM gives ranges, not Nintendo's choice. ## The boundary (proposal) **The core owns the whole ARM11 MPCore macrocell**: the MP11 CPUs, their VFP11s, their L1 caches and TLBs, the SCU, the private timers and watchdogs, and the Distributed Interrupt Controller, i.e. everything ARM sells as one block and everything the private memory region (17E00000h-17E01FFFh on the 3DS, GBATEK) exposes. The board owns everything past the AXI master ports: the 3DS's memories and I/O, its interrupt sources (wired into the distributor's interrupt lines 20h-7Fh, GBATEK "3DS ARM11 Interrupts"), CONFIG11's clock and CPU-start registers, and the New 3DS's **L2C-310** (an ARM CoreLink part outside the MPCore, at 17E10000h, board-side). This matches the charter's chip rule: one ARM product is one core. The alternative, one `MP11` core per CPU with the SCU and distributor in the board, splits a coherency protocol across a repository line. Not recommended; it is decision A3 in the brief. ## Configuration (the 3DS's row) | Item | TRM range | 3DS | Evidence | | --- | --- | --- | --- | | MP11 CPUs | 1-4 | 2 (Old 3DS); 4 (New 3DS), CPU2/3 started through CFG11_MPCORE_BOOTCNT_CPU2/3 | DOC: GBATEK CONFIG11 | | L1 I-cache, D-cache | 16, 32 or 64 KB each, 4-way | **unknown** (U1): read c0,c0,1 (Cache Type) on a console or from a payload's log | DDI 0360F 1.6 | | VFP | per CPU, optional | present; FPSID 410120B4h (New 3DS) | DOC: GBATEK "ARM VFP ... Control/Status Registers" | | Interrupt lines | 0-224 in steps of 32 | 80h sources in all (00h-0Fh software, 1Dh-1Fh private, 20h-7Fh hardware) | DOC: GBATEK "3DS ARM11 Interrupts" | | Revision | r0p0-r2p0 | **unknown** (U2): c0,c0,0 Main ID | | | Clock | | 268 MHz; New 3DS 268/536/804 MHz modes | DOC: GBATEK CFG11_MPCORE_CLKCNT | ## MMU (VMSAv6) - Two translation table bases (TTBR0, TTBR1) split by TTBCR.N; first-level descriptors for sections (1 MB), supersections (16 MB) and coarse tables; second-level small (4 KB) and large (64 KB) pages; the v6 descriptor format with XN, the global bit and ASIDs (8 bits), or the v5-compatible format with subpage permissions when c1.XP (bit 23) = 0 (DDI 0100I part B4; DDI 0360F 5.11-5.12; GBATEK "ARM CP15 Memory Management Unit (MMU)"). - **TLBs**: a MicroTLB of 8 entries on each side, fully associative, with ASID compare; a unified main TLB of 64 entries, 2-way set-associative, plus 8 lockable entries (DDI 0360F 5.2.1-5.2.2 and the TLB Type register's DLsize = 8). All main-TLB maintenance flushes both MicroTLBs. - **Is the TLB visible?** Architecturally software must maintain TLBs, so a stale entry after a page-table write without an invalidate is visible behaviour. The specification therefore models the TLB as state (MicroTLB and main TLB contents, replacement), not as a cache that is always coherent with memory. The MMU's replacement is "Round-Robin" (DDI 0360F 5.1's feature list); which structure that sentence covers (the MicroTLBs, the main TLB's ways, or both) and where the pointer starts after reset is unknown U4. - Faults: section/page translation, domain and permission faults, alignment, external aborts (precise or imprecise), with DFSR/IFSR/FAR/WFAR (DDI 0360F 5.8-5.10). ## L1 caches and coherency - 4-way set-associative instruction and data caches, 8-word (32-byte) lines, write-back, the data cache write-allocate, round-robin replacement (DDI 0360F 1.3's cache feature list); non-blocking: up to three outstanding data read misses and four write misses (same list; 7.2). - **MESI coherency through the SCU** for data marked shared (write-invalidate), with Direct Data Intervention, duplicated tag RAMs and migratory lines as optimisations (DDI 0360F 7.1). The instruction cache is not kept coherent with data writes: software cleans and invalidates (c7 operations), so self-modifying code without maintenance is visible behaviour, as is DMA into a region still cached. - **What the specification models** (proposal): tags and line state per CPU (so stale data after DMA and missing maintenance reproduce), the MESI transitions on shared lines, and the line fills and write-backs as AXI transactions with a duration. The round-robin replacement pointer is state. - Cost: a cache is the largest state in the core; the -fast tier can skip tag work on hits where no observer can tell. Unlike the VR4300 (direct-mapped, no replacement state: n64-python execution-architecture.md), a miss's victim here depends on the round-robin pointer, so the pointer must be kept exactly; whether anything but a line fill moves it is unknown U6. ## Exclusive monitors Each CPU has a local monitor; the SCU provides the global monitor for shared memory (DDI 0360F 8.3 "Synchronization operations"). LDREX/STREX semantics across two CPUs are specified by the ARM ARM's monitor state machine; which events clear a monitor (a context switch's CLREX, an interrupt, another CPU's store to the granule) and the reservation granule size are part of the core (U7: the granule; the TRM's value to be read and cited). ## The private memory region (17E00000h on the 3DS) | Offset | Block | Source | | --- | --- | --- | | 0000h | SCU registers (control, configuration, CPU power status, invalidate all) | DDI 0360F 9.1, table 9-1; GBATEK "ARM11 MPCore - Snoop Control Unit (SCU)" | | 0100h | CPU interrupt interface of the accessing CPU; 0200h-0500h CPU0-3 aliases | DDI 0360F 10.6 | | 0600h | timer and watchdog of the accessing CPU; 0700h-0A00h CPU0-3 aliases | DDI 0360F 9.2; GBATEK "ARM11 MPCore - Timer and Watchdog" | | 1000h | the Interrupt Distributor | DDI 0360F 10.5 | **Which CPU is accessing** is a property of the transaction (the CPU's ID), so the core's bus model carries a CPU number on every transaction: the board's map at 17E00000h is the core's, not the board's. - **Timers and watchdogs**: one per CPU, clocked from the CPU clock through a prescaler; on the New 3DS a clock-mode change changes their rate unless the prescaler is adjusted (GBATEK CFG11_MPCORE_CLKCNT). - **Distributor**: 32 private interrupts per CPU (16 software-generated, used by Horizon for scheduling and cross-CPU work; GBATEK lists 01h as the boot ROM's kick for core 1) and the shared hardware lines; priority, target CPU mask, edge/level, pending and active state; acknowledge returns 3FFh when spurious (GBATEK "3DS ARM11 Interrupts"). ## Multiprocessor time and the order of record The specification steps the CPUs serially in a defined interleaving (charter: the order of record) with one integer time base: **one ARM11 clock**, which is also the private timers' input. Proposal: round-robin by a quantum of one instruction per CPU in the reference (the most readable and the most exact interleaving the reference can define), with every access to shared state (memory marked shared, the SCU, the distributor, the exclusive monitors, the board's I/O) going through the bus in that order. `x-rust-fast` may run CPUs in larger quanta between synchronisation points only where the lockstep gate stays identical (n3ds-python docs/execution-architecture.md). The interleaving is a modelling choice, not hardware evidence: two real CPUs race. Software that depends on a race is rare in correct code (it uses LDREX/STREX and barriers), so the reference's interleaving is FITTED for determinism and recorded as such.