The PowerVR BXM-4-64 (36.56.104.183) GPU firmware executes on an embedded MIPS32 Release 2 core supporting compact microMIPS encoding, operating in little-endian mode, single-threaded, inside the GPU’s MIPS_WRAPPER subsystem.
[P][O])| Property | Value | Source |
|---|---|---|
| ISA Architecture | MIPS32 Release 2 + microMIPS (little-endian) | [P] |
| Hardware Threads | 1 (ROGUE_FW_THREAD_MAX = 1 for MIPS) |
[P] |
| Instruction Cache (L1 I$) | 2 KiB, 16-byte lines (128 lines) | [P][D] |
| Data Cache (L1 D$) | 2 KiB, 16-byte lines (128 lines), Write-Through policy | [P][D] |
| TLB | 16 paired entries (32 mappable pages; ROGUE_MIPSFW_NUMBER_OF_TLB_ENTRIES = 16) |
[P] |
Fixed Entries (Wired) |
Wired = 4 (K3 vendor: 0 = CR/BCAST 4 MiB, 1 = PT 16 KiB, 2 = stack, 3 = private data) or Wired = 5 (mainline, pt_num_pages = 4). Entries Wired..15 are dynamic (TLB Refill). Details in memory-model.md §2.2 |
[O] |
| Stack Budget | 4 KiB (ROGUE_MIPSFW_STACK_SIZE = 0x1000, 1 page); top 0xCF600FF8 |
[P] |
$gp |
Base of firmware private data (MIPS_PRIVATE_DATA, $gp-relative access, ±32 KiB window) |
[P][O] |
EBase |
0x9FC02000 (ROGUE_MIPSFW_EXCEPTIONS_VIRTUAL_BASE); Cause.IV = 1 |
[P][O] |
Config.K0 |
3 = cacheable (write-back) for kseg0 — MIPS32 encoding is 2 = uncached, 3 = cacheable (also confirmed by consistency with the firmware’s own cache maintenance, which invalidates/primes the I$ for the exception code at 0x9FC02xxx) |
[P][O] |
| Exception Vectors | EBase+0x000 TLB Refill, EBase+0x180 general exception, EBase+0x200 interrupt (IV=1) |
[P][O] |
[P][O])The host configures REMAP1/2/3 and MIPS_WRAPPER_CONFIG (REGBANK_ADDR_ALIGN = 16, BOOT_ISA_MODE = microMIPS) before releasing reset. The core PC starts at 0xBFC00000 (kseg1 → physical 0x1FC00000, redirected by REMAP1 to the boot buffer).
0xBFC00000)Per the MIPS32r2 architecture, the reset vector (0xBFC00000) distinguishes cold initialization from NMI via the CP0.Status.NMI (bit 19) bit (temporarily preserving a scratch register in CP0.DESAVE for the eret return case):
Status.NMI = 0 → cold path (executed on K3 power-up [O]): initializes the boot stack, clears working GPRs, and executes CP0, cache, and TLB initialization (§2.2–§2.3).Status.NMI = 1 → NMI/dump path: preserves CPU context, writes the state dump consumed by the host (CP0 + 16 TLB entries + 32 remap entries, see struct rogue_mips_state in data-structures.md), clears BEV/ERL/EXL in Status, drains the wrapper (0xBFC01800 = 1, ehb, sync, read of 0xCF800020), and returns via eret.Executed before any access to kseg2; all values below were observed in the boot vector:
| Order | Register | Value | Effect |
|---|---|---|---|
| 1 | Status |
0x00001C00 |
IE=0, EXL=0, ERL=0, BEV=0; IM2/IM3/IM4 enabled |
| 2 | Cause |
0 |
clears pending flags |
| 3 | Count |
0 |
|
| 4 | Compare |
0xFFFFFFFF |
timer “never” fires before being armed |
| 5 | Config |
(Config & ~7) \| 3 |
K0 = 3 → kseg0 cacheable (write-back); kseg1 remains uncached |
| 6 | EBase |
0x9FC02000 |
exception vector base ([31:12]) |
| 7 | Cause |
(Cause \| 0x00800000) |
IV = 1 → interrupt vector at EBase+0x200 |
| 8 | IntCtl |
(IntCtl & ~0x3E0) \| 0x100 |
VS = 8 (bits [9:5] = vector spacing: 256 B per IP line); not IPTI (which is in [31:29]) |
| 9 | TagLo |
0 |
|
| 10 | — | — | index-based cache maintenance: cache 8 + cache 9 over all 128 lines (0x80000000–0x800007FF) and boot code prime |
| 11 | PageMask + Index/EntryHi/EntryLo0/1 |
see §2.3 | wired entries loading |
| 12 | Wired |
4 (K3 vendor) / 5 (mainline, pt_num_pages = 4) |
see §2.3 |
| 13 | Status |
Status & ~1 … \| (Status & 1) |
IE disabled during TLB load and restored at the end |
| 14 | — | — | invalidates D$ (2 KiB) |
Context is not used: the firmware does not use “Context”-mode page walking; the table index is derived from EntryHi (§4 of memory-model.md).
Wired Entries (Exact Order)PageMask = 0x1800 (4 KiB), followed by 0x7FF800 (4 MiB).0xCF800000, EntryHi = 0xCF800000, EntryLo0/1 derived from 0xCF800000/0xCFC00000, flags 0x40000017 (XI, C=2 uncached, D|V|G), 4 MiB page → covers 0xCF800000–0xCFFFFFFF (CR and BCAST).MIPS_BOOT_DATA (0x9FC01000 window) and validates pt_log2_page_size (12..18) and pt_num_pages (< 5). Outside this range → break (fatal trap).PageMask = ((page_KiB << 11) - 1) & ~0x7FF (with page = 1 << pt_log2_page_size); Index 1 ← 0xCF000000, flags 0x1F (C=3 write-back, D|V|G), phys = pt_phys_addr[0] / pt_phys_addr[1] (page pair).pt_num_pages = 2 (K3 vendor): Index 2 ← stack 0xCF600000, phys = stack_phys_addr; Index 3 ← first page of MIPS_PRIVATE_DATA (.bss+.data); Wired = 4.
If pt_num_pages = 4 (mainline): Index 2 ← 0xCF000000 + 2 × page (second half of PT, phys = pt_phys_addr[1]); Index 3 ← stack; Index 4 ← private data; Wired = 5.Wired..15 are invalidated (synthetic EntryHi/EntryLo, tlbwi) and remap entries 0..31 are cleared.Each tlbwi is accompanied by programming the corresponding range-remap entry (16 + index for wired entries), as described in memory-model.md §4.5.
Upon returning from initialization: $sp = 0xCF600FF8 (top of stack − 8), $gp = base of MIPS_PRIVATE_DATA, $a0..$a3 = 0, sync, and jump to the firmware code entry point (MIPS_CODE). The initial sequence at that entry point is:
struct rogue_fwif_sysinit block (mainline 1.1 ABI, sizeof = 0x220, see data-structures.md);CR[0x0890] = 1 (broadcast core selection);CR[0x0890] back (confirming the write landed);PerfCtl0/PerfCnt0/PerfCtl1/PerfCnt1 according to sysinit.hw_perf_filter (+0x30);CR[0x08A0] = 1 (MIPS_WRAPPER_IRQ_ENABLE) — enables the wrapper interrupt line;firmware_started = 1 with visibility barrier), enables Status.IE, and enters the idle loop (wait).ABI Scope (
sysinit): an implementation compatible with the Linux mainline 1.1 driver must use only the fields defined instruct rogue_fwif_sysinit(sizeof = 0x220, data-structures.md). Additional fields present in the larger DDK 24.2 block fall outside the mainline structure.
[P][D])The firmware operates under an event-driven model controlled by the MTS (Meta/MIPS Task Scheduler) and the internal CP0 timer. The hardware interrupt lines in CP0.Cause / CP0.Status map directly to three logical contexts:
| CP0 Line | Cause.IP Mask |
Hardware Source | Role in Firmware |
|---|---|---|---|
HW0 (IP2) |
Bit 10 | Timer (CP0.Count/Compare) |
Vector EBase+0x400: saves sp/Status/EPC, executes the timer ISR, and rewrites Compare (ack). Basis for the HWR deadline and APM latency timer (active_pm_latency_ms) |
HW1 (IP3) |
Bit 11 | MTS Background Task (BG) | Vector EBase+0x500: same frame, calls the BG task (KCCB, cCCB scheduling, UFOs/fences, MemCtx, DM2/DM3/DM4 kicks). Runs with ei in the call’s delay slot, allowing IP4 to preempt it |
HW2 (IP4) |
Bit 12 | MTS Interrupt Task (IRQ) | Vector EBase+0x600: saves the full context (all GPRs + Status/EPC) and calls the IRQ task (EVENT_STATUS: TA/3D/CDM completion, PM OOM, MMU fault, CSW store, HWR, APM/Idle) |
Correction (2026-11-28): the
IP ↔ taskmapping was inverted in earlier versions (IP2= BG was incorrect). The actual order, confirmed in the vector code, isIP2= timer,IP3= BG,IP4= IRQ. TheStatussaved by the BG vector masksIM2|IM3(bits 10–11), leaving onlyIM4enabled, which confirms BG preemption by IRQ.
[D])IP4 / HW2) has higher priority than BG Context (IP3 / HW1).IP4 / HW2) interrupts can preempt it to service critical GPU events (e.g., render completion or PM OOM).WAIT instruction, reducing MIPS core power consumption until the next interrupt (IP2, IP3, or IP4).IP4 / HW2) processing, if the firmware is not powering off the GPU, it writes CR[0x0B08] = 2 (interrupt task acknowledgement in MTS) before returning from the exception.ROGUE_CR_MTS_SCHEDULE (CR[0x0B00]) (e.g., 0 for general BG rescheduling, or 0x20 after HWR recovery).[P][O])EBase = 0x9FC02000 with Cause.IV = 1:
| Offset | Vector | Contents on K3 |
|---|---|---|
+0x000 |
TLB Refill | Missing-page resolution (§4.1) |
+0x180 |
General Exception | Dispatch by Cause.ExcCode (§4.2) |
+0x200 |
vector 0 (software interrupt) | Not used by the firmware |
+0x400 |
vector 2 = IP2 (timer) |
Frame + timer ISR call + Compare ack (§4.3) |
+0x500 |
vector 3 = IP3 (BG) |
Frame + BG task call, with ei/di (§4.3) |
+0x600 |
vector 4 = IP4 (IRQ) |
Full context save + IRQ task call (§4.3) |
The +0x000, +0x180, and +0x200..+0x600 vectors all reside in the MIPS_EXCEPTIONS_CODE section (EBase = 0x9FC02000, maximum budget 8 KiB).
EBase+0x000)The FW Heap (16 MiB) exceeds the 16 TLB entries, so every page outside the wired entries triggers a refill. Functional sequence:
sync.VPN2 = EntryHi[31:13]; Index = Random (free entry between Wired..15).Random & 0x1F with the missing virtual page (BASE_ADDR_IN = EntryHi[31:12]) and MODE_ENABLE = 1.PTE0 = *(u32 *)(0xCF000000 + (EntryHi >> 10 & 0x3FFFF)), PTE1 = PTE0 + 4; writes ADDR_OUT = PTE[29:6] << 12 (actual physical address) to the remap entry.EntryLo0 = (PTE0 & 0xC000003F) | ((EntryHi >> 12) << 6) and EntryLo1 with PFN+1 (see memory-model.md §4.4). The PFN comes from the VPN, not from the PTE.Index = Random, PageMask = 0x1800, tlbwi, ehb, and eret.There is no “unmapped page” path in this vector: if
PTE = 0, the resultingEntryLohasV = 0and the faulting instruction triggers a new exception (now TLB Invalid,ExcCode = 2/3), handled by the general exception vector.
EBase+0x180)Cause and extracts ExcCode = Cause[6:2].ExcCode ∈ {1, 2, 3} (TLB Modified / TLB Load / TLB Store — entry present but V/D insufficient):
Index = Wired .. 15 with tlbr until EntryHi[31:13] == BadVAddr[31:13];ExcCode = 1 (TLB Modified), tests D; if ExcCode = 2/3 (TLB Invalid), tests V; if the bit is missing, rewrites EntryLo0/1 = (EntryHi >> 6) | 0x3F (PFN from VPN, C = 7, D|V|G) and executes tlbwi;MMU_PAGE_FAULT event in software (CR[0x0130] |= 0x200 — EVENT_STATUS accepts software set, even though the header describes it as RO/W1C);Status and returns via eret, re-executing the instruction.ExcCode (Address Error, Reserved Instruction, Trap, Machine Check, …) → publishes the state dump (struct rogue_mips_state, §4.4) and enters a permanent halt: di; wait; in an infinite loop. There is no software recovery; the host detects the halt via timeout/MIPS_WRAPPER_STATUS.Index reaches 15 without matching the VPN → also permanent halt (di; wait;).EBase+0x200+n*0x100)Boot writes Cause.IV = 1 and IntCtl with VS = 8 (IntCtl = (IntCtl & ~0x3E0) | 0x100), enabling vectored interrupts. The resulting architectural layout is EBase + 0x200 + (n << 8), i.e., 256 bytes (0x100) per IP line — with three distinct vectors:
| Vector | Address | Behavior |
|---|---|---|
IP2 (timer) |
EBase+0x400 |
Saves sp/Status/EPC on the stack (8-byte aligned), clears IE\|EXL, runs the timer ISR, rewrites Compare (ack), restores Status/EPC, and returns via eret |
IP3 (BG) |
EBase+0x500 |
Saves Status & ~0xC03 (masks IM2\|IM3, leaving IM4 active), calls the BG task (KCCB/CCCB) with ei enabled (and di on return) to allow preemption by IP4; restores and returns via eret |
IP4 (IRQ) |
EBase+0x600 |
Saves all GPRs + sp/gp/Status/EPC, calls the IRQ task (EVENT_STATUS/HWR/CSW), and restores full context before eret |
Implementation consequences:
+0x180 vector handles only ExcCode ∈ {1,2,3}; interrupts do not pass through it (§4.2).ei in the delay slot of the BG call (BG runs with IE = 1 and IM4 unmasked), while IRQ runs with IE/EXL = 0.CP0.Compare. The MTS IRQ task ack is writing to CR[0x0B08] (§3).+0x200 (software interrupt, vector 0) is not used.The dump (executed in the NMI path and the general exception vector) writes EntryHi/EntryLo0/EntryLo1/Index/PageMask and all 16 TLB entries (tlbr) into shared boot RAM, as well as publishing the state of all 32 remap entries — the layout consumed by the driver is in data-structures.md (struct rogue_mips_state). After the dump, the code performs a D-cache flush, drains the wrapper (0xBFC01800 = 1, ehb, sync), and performs a confirming CR read (0xCF800020) before returning.
[P][D])The MIPS core uses a 2 KiB Write-Through D-cache with 16-byte lines, but there are write buffers in the MIPS wrapper and explicit coherency is required between the MIPS core, the GPU (BIF/SLC), and the host (RISC-V CPU):
| Operation | Mechanism on K3 | When to Use |
|---|---|---|
| Full D-cache Flush/Invalidate | cache loop from 0x80000000 to 0x800007F0, stride 0x10 (16 B) (128 lines = 2 KiB) |
Before final shutdown (POW_OFF), during HWR reset sequence, and before global MMU/TLB invalidations |
| Range D-cache Flush/Invalidate | cache Hit_Writeback_Invalidate_D loop aligned to 16 B over [addr, addr + len) |
After updating sysinit (firmware_started), FWCCB headers, UFOs, or structures read by the host |
| MIPS Wrapper Write Barrier (Fence Flush) | Write 1 to uncached register 0xBFC01800 + ehb + sync |
Mandatory after D-cache flush to drain the MIPS wrapper write buffer to DRAM before signaling the host (boot handshake, KCCB MMU inval, HWR, power-off) |
| CR Register Synchronization | Dummy read of a safe register (e.g., ROGUE_CR_CORE_ID__PBVNC at 0x0020) after an MMIO write sequence |
Guarantees previous CR writes have reached their destination before exposing status to the host |
| Dynamic TLB Invalidation | Sweep entries Wired .. 15 invalidating EntryHi/EntryLo via tlbwi |
Upon receiving KCCB_CMD_MMUCACHE (MMU/FW cache invalidation) |
Critical K3 note: Writing
sysinit.firmware_started = 1without first executing the D-cache flush, the write to0xBFC01800 = 1,ehb+sync, and a confirming CR read can cause the RISC-V host to observefirmware_started = 0until the boot timeout expires (or read partialsysinitdata).
[P][D])0x1000), shared between the BG flow, the IRQ (HW1) preemption frame, and the TLB Refill exception.3 KiB).MIPS_CODE alloc_size) and make better use of the 2 KiB I-cache.[O]):
EntryHi (VPN2) — or a conflict between REMAP and TLB — immediately trigger a Machine Check exception (CP0.Cause = 0x00800060). Always populate invalid entries with unique, unused VPNs during TLB initialization/invalidation.jals (16-bit) delay slot: in microMIPS encoding, the jals instruction requires a 16-bit instruction in its delay slot; placing a 32-bit instruction in a jals delay slot causes a Reserved Instruction exception on return.gcc + -Os + microMIPS): legacy microMIPS GCC versions at -Os can emit incorrect beqz16/bnez16 sequences under jump CSE; when compiling with microMIPS GCC toolchains, pass -fno-cse-follow-jumps or validate with a recent GCC/LLVM.