Architecture

The firmware is a freestanding GNU C23 + microMIPS32r2 program with no main loop and no threads. After bringing up the MIPS core, shared memory and GPU units, fw_main() enables interrupts and sleeps in WAIT; all runtime work runs in interrupt context, one interrupt at a time.

Source files (src/)

File

Role

src/bvnc/<bvnc>/boot.S

Per BVNC. Reset/NMI entry at 0xBFC00000. Configures CP0, wired TLB entries 0–4 and wrapper remaps, then jumps to fw_entry via ERET (Boot and runtime; the BXM-4-64 one jumps with JR after its own CP0/cache sequence, boot.S and vectors.S — Assembly).

src/bvnc/<bvnc>/vectors.S

Per BVNC. Exception page at 0x9FC02000: TLB refill, general exception handler, vectored interrupt entries (HW0–HW2), tlb_flush_dynamic, and fw_entry (clears .bss, calls fw_main).

src/main.c

fw_main(): shared-structure lookup, trace init, GPU bring-up, firmware_started handshake, and irq_dispatch().

src/gpu_init.c

GPU bring-up at every power-on (docsClean/BXE-2-32/boot-gpu-init): XPU/secure/fault page, MTS event routing and DM association, dust power, SLC bypass, PDS/USC exec bases, unit defaults and init-done handshakes.

src/kccb.c

Kernel CCB consumer, return slots, Firmware CCB producer (Host ↔ firmware protocol).

src/power.c

KCCB_POW handling and the power-sync word (Power, HWR, statistics and trace).

src/mmu.c

KCCB_MMUCACHE: SLC flush/inval, BIF invalidation, PM TLB and dynamic MIPS TLB flush.

src/sched.c

Context table (ctxs[64]), client CCB walk (fences, updates, tasks), retirement, cleanup and power-state tracking (Scheduler and kicks).

src/kick.c

BIF catalogue slots and rebuild, compute (CDM) kick, transfer (TQ_3D) kick, completion events, per-DM cache flush and MMU fault reporting.

src/geom.c

Geometry (TA) kick, on by default since E041 (E028–E041): PM context 0 load, geometry registers, context enable, VDM trigger and completion write-back.

src/frag.c

Fragment (3D) kick and partial render (E036–E041): PM context 1 load, ZLS/MSAA/ISP/PBE registers, render launch and PM_3D_MEM_FREE completion handling.

src/pm.c

Parameter Manager (E041): free-list and list loads/stores of both PM contexts, which HWRTData each context holds (store before evict, dirty flag), out-of-memory handling (ready pages, grow, partial render) and the HWR free-list reconstruction request.

src/stats.c

GPU utilisation (gpu_util_fwcb), time correlation, HWR log (hwrinfobuf) and FWCCB context-reset notification.

src/hwr.c

Hardware recovery: MMU fault or watchdog (max_deadline_ms) → SOFT_RESET pulse → GPU units re-init → discard guilty commands.

src/util.c

memset/memcpy, 64-bit unsigned division/modulo, GPU timer, delays and polls, write barrier, host notification and trace writer.

src/include/fwif.h

Firmware interface structures checked with static_assert against the public pvr_rogue_fwif_check.h offsets.

src/include/layout.h

Fixed addresses and sizes; also parsed by tools/mkfw.py.

src/include/regs.h

RGX register offsets used by the firmware.

src/include/sfid.h

Trace IDs generated by tools/gen_sfids.py from the public pvr_rogue_fwif_sf.h.

src/include/mips.h

CP0 access (mfc0()/mtc0()), interrupt masking and barriers for C.

src/include/fw.h, kick.h

Internal firmware state and kick interfaces.

src/fw.ld

Linker script: four PT_LOAD segments at fixed addresses with size assertions.

Execution model

              +--------------------------------------------------------+
HW0 timer --> | irq_dispatch(0): re-arm Compare (1 ms)                 |
(CP0 Compare) |   kccb_process(); sched_poll(); sched_run();           |
              +--------------------------------------------------------+
HW1 BG task > | irq_dispatch(1): kccb_process(); sched_poll();         |
(MTS)         |   sched_run(); MTS_TASK_END = 0                        |
              +--------------------------------------------------------+
HW2 IRQ task> | irq_dispatch(2): ev = EVENT_STATUS; EVENT_CLEAR = ev;  |
(MTS)         |   sched_irq(ev); MTS_TASK_END = 2                      |
              +--------------------------------------------------------+
  • BG task (HW1): the host writes ROGUE_CR_MTS_SCHEDULE after queuing a KCCB command; the MTS raises HW1 (E016).

  • IRQ task (HW2): the GPU raises a hardware event (data-master completion, MMU page fault, etc.); the MTS raises HW2 on every completion (E018).

  • Timer (HW0): CP0 Count/Compare every 1 ms. Acts as a watchdog tick and a backstop poll racing HW1/HW2; whichever path runs first handles the event.

All three interrupt vectors enter int_common in vectors.S, which saves caller-saved registers, EPC and Status on the wired stack and clears EXL / ERL / IE before calling C. Leaving EXL = 1 would send any TLB miss inside C code to the general exception vector instead of the TLB refill vector and clobber EPC (E002). On return, the original Status is restored with EXL re-set for ERET.

Interrupts are never nested. Boot-time code calling kccb_process() before entering WAIT guards itself with irq_save() / irq_restore().

Global state

All firmware state lives in .bss at 0xC0ED0000 and is zeroed on every boot (cold or warm; no firmware state persists across power cycles):

Object

Module

Contents

g (struct fw_state)

main.c

Pointers to sysinit, osinit, sysdata, osdata, runtime_cfg, trace buffer, KCCB and FWCCB; clocks, power state, config flags and interrupt counters.

ctxs[64]

sched.c

Contexts seen in KCCB_KICK: firmware address, DM, pending/dead flags, and a FIFO of up to 8 kicks’ cleanup control blocks.

dms[DM_MAX]

sched.c

Per-DM busy flag, running context, cCCB offset of running command, completion event mask, kick timestamp and bound BIF slot.

bif_pc[8]

kick.c

Page-catalogue physical address bound to each BIF_CAT_BASEn slot (slot 0 is never assigned to clients).

Address helper fwptr()

Host-supplied fw_addr fields are MIPS virtual addresses inside the 16 MiB firmware heap at 0xC0000000 that may carry flag bits (bit 0 = sync checkpoint; bits above bit 24 = meta-DMA/cached flags). fwptr() masks the address with 0xC0FFFFFC (preserving 0 as NULL), and the dynamic TLB refill handler maps the page on demand from the host MIPS page table.

Module dependencies

fw_main -> shared_init -> trace_init -> gpu_power_on -> gpu_units_init (dust_power)
        -> sched_init -> kick_init
irq_dispatch -> kccb_process -> {sched_kick, sched_cleanup, mmu_cache_op, pow_handle, ...}
             -> sched_poll / sched_irq -> kick_events -> sched_dm_done
             -> sched_run -> ctx_process -> kick_task -> {kick_cdm, kick_tq3d, kick_geom, kick_frag}
             -> (timer) hwr_watchdog -> hwr_recover;  kick_events(MMU fault) -> hwr_recover
everything -> util (TRACE, notify_host, write_barrier, cr_poll32, gpu_timer)