# System architecture: modes, paging, caches, MSRs, the bus contract Evidence tags as in the methodology; DOC citations to the pinned SDM vol. 3 (245472-012) unless said otherwise. ## Modes - **Real mode** at reset (Table 9-1): the MCPX ROM's first instructions load a GDT and an IDT from its own last bytes and enter protected mode (OBSERVED: MAME's trace, mame-oracle.md; DOC: xboxdevwiki `MCPX ROM` r5858, "setup the memory to consist of a 4GB continuous area, and then activates 32 bit mode"). The specification needs real mode only as far as that path goes, and the 16-bit operand and address forms that the 66h/67h prefixes reach in 32-bit code. - **Protected mode**: segment loads with descriptor checks (type, DPL/RPL/CPL, present, limit), the hidden descriptor caches, the GDT/LDT/IDT, interrupt and trap gates, privilege changes through the TSS's SS0:ESP0 on interrupts from ring 3, IRET. Task switches, call gates, V86 and SMM are out of the first scope (scope-and-size.md), each raising a "not modelled" stop so a board run finds out whether Xbox code reaches them. - **Paging**: CR3, two-level tables, 4 KB and 4 MB pages (CR4.PSE), global pages (CR4.PGE), WP, accessed and dirty bits written by the walker (which is a bus transaction, and a locked one for A/D updates: SDM 3 §7.1), #PF with CR2 and error code. PAE out of scope. The TLBs are **architecturally visible** through stale entries after a page-table write without INVLPG or a CR3 load, so the specification models them with Intel's P6 sizes (32 + 2 instruction, 64 + 8 data, 4-way: SDM 3 Table 10-1) and a replacement rule that is FITTED (U7). The Xbox kernel maps 4 MB pages for its own image and for contiguous memory (HYPOTHESIS; the board shows it). ## Caches and memory types - L1 I and D 16 KB each, L2 128 KB on the die (C1 for its associativity), 32-byte lines, write-back, MESI on the bus (SDM 3 ch. 10). The specification keeps tags and line states as state, because WBINVD, INVD, self-modifying code (the P6 snoops its own stores against the instruction cache and the prefetch queue: SDM 3 §10.6, "self- modifying code"; 245127-001) and DMA coherence make them visible. - **DMA coherence on the Xbox is unknown** (U8): on a PC, bus masters on PCI make the north bridge snoop the CPU's caches; on the Xbox the memory controller is in the NV2A, and whether the NV2A's own GPU reads and the MCPX's DMA engines snoop the CPU's caches is not documented. Software allocates GPU-shared memory write-combined or uncached (HYPOTHESIS from the XDK's model), which would hide the question. The specification provides a snoop hook in the bus contract and the board decides. - **MTRRs and PAT**: fixed and variable MTRRs, the default type, PAT entries selected by PAT/PCD/PWT; UC, WC, WT, WP, WB with their ordering rules. The MCPX ROM "initialises the MTRR, enables caching" (xboxdevwiki `MCPX ROM` r5858). - **Write-combining buffers**: four, drained on SFENCE, serialising instructions, interrupts, UC accesses, LOCK, and when all four are in use (SDM 3 §10.3.1). Their contents at a drain are bus transactions: the NV2A's view of the push buffer depends on them (timing.md). ## Interrupts and the APIC - The Xbox's interrupt controller is the MCPX's pair of 8259s (xboxdevwiki `Memory` I/O map: master PIC 20h-21h, slave A0h-A1h). The core sees INTR as a level and asks the board for the vector at acknowledge, like i8086-python's contract; NMI as an edge. - The local APIC exists in the core (SDM 3 ch. 8). Whether the Xbox kernel enables it is HYPOTHESIS: no (U9). It is modelled as disabled-at-reset state with its MSR, and a stop if software enables it. ## MSRs, CPUID, TSC - CPUID: vendor "GenuineIntel", family 6, model 8 (Coppermine); stepping and the leaf-2 cache descriptors of the Xbox's part are not documented (U1, and they settle C1). abaire/nxdk_check_cpuid prints them on hardware or under an emulator, but no hardware output is published (searched 2026-11-26). - TSC: increments at the core clock; RDTSC is not serialising (SDM 2). - MSRs the kernel touches: the MTRRs, the APIC base, SYSENTER (if used), the TSC, the machine-check registers (HYPOTHESIS; MAME's trace and the board will list them). ## The bus contract (proposal, to settle in the first commit) The board (xbox-python) owns memory, the NV2A's registers at FD000000h, the MCPX's devices, the flash at FF000000h and the MCPX ROM overlay at FFFFFE00h (xboxdevwiki `Memory` r7416), PCI configuration through ports CF8h/CFCh, and every I/O port. The core owns everything inside the package: caches, TLBs, store and WC buffers, the APIC. - `read(physical, size, kind) -> (value, cycles)` and `write(physical, size, value, kind) -> cycles`, where `size` is 1, 2, 4 or 32 (a line) and `kind` names the transaction: `FETCH_LINE`, `READ_LINE`, `WRITEBACK`, `UC_READ`, `UC_WRITE`, `WC_FLUSH` (one to four 32-byte buffers with byte enables), `LOCKED` (with the read-modify-write pair), `IO_READ`, `IO_WRITE`, `INTA`, `PAGE_WALK`. - `snoop(physical, length)`: the board's call when one of its DMA masters touches memory the core may cache; the core writes back or invalidates by the MESI rules (U8). - `run(until)` runs whole instructions until the model time reaches `until` or the core makes a transaction the board marked as a sync point; interrupts are sampled at instruction boundaries; `set_intr(level)`, `nmi()`, `acknowledge() -> vector`. - Time is the core clock in the board's common time base (xbox-python domains-and- speed.md). The board returns each transaction's cost from its own memory-controller model; the core charges it under the timing model of timing.md.