.fw Container FormatThis document specifies the addressing domains of the SpacemiT K3 (36.56.104.183) GPU, the MIPS wrapper remapping (including the BRN 63553 workaround), the 3-level GPU MMU, and the .fw v3 firmware file format.
[P])| Domain | Width | Used By | Description |
|---|---|---|---|
Physical Address (phys_addr / dma_addr) |
36 bits | DRAM / SLC / AXI-ACELite Bus | SoC physical space visible to the GPU (up to 64 GiB) |
GPU Virtual Address (dev_addr) |
40 bits | GPU blocks (VDM, TE, ISP, PBE, CDM, PM, USC, PDS) | Translated by the 3-level GPU MMU (PC→PD→PT) using BIF banks 0..7 |
MIPS Virtual Address (fw_addr) |
32 bits | Firmware MIPS core | Translated by the MIPS TLB (16 entries, host page table) or fixed kseg0/kseg1 segments |
| Host Virtual Address (RISC-V) | 64 bits | Linux drm/imagination driver |
CPU mapping of shared GEM objects |
[P][O])The firmware executes with the MMU enabled and CP0.Config.K0 = 3. Per MIPS32 encoding, K0 = 2 is uncached and K0 = 3 is cacheable (write-back): therefore kseg0 (0x80000000–0x9FFFFFFF, including the exception code at 0x9FC02000) executes cached, whereas kseg1 (0xBFC00000, boot/NMI) is uncached by architectural definition. This is consistent with the firmware invalidating/priming the exception code I$ at boot.
| MIPS Virtual Range | Segment / Mechanism | Policy | Purpose |
|---|---|---|---|
0x80000000 – 0x800007FF |
kseg0 (index addresses) |
Cache ops | Base for index-based I$/D$ maintenance (2 KiB, 128 lines × 16 B) |
0xBFC00000 – 0xBFC0_0FFF |
kseg1 via REMAP1 |
Uncached | Boot/reset/NMI vector and CP0/cache initialization routines (MIPS_BOOT_CODE section, max 4 KiB) |
0xBFC01000 – 0xBFC0_1FFF |
kseg1 via REMAP2 |
Uncached | Uncached mirror of MIPS_BOOT_DATA |
0x9FC01000 – 0x9FC0_1FFF |
kseg0 via REMAP2 |
Cacheable (K0=3) |
MIPS_BOOT_DATA (the only window used by the firmware; see §2.3) |
0x9FC02000 – 0x9FC0_3FFF |
kseg0 via REMAP3 |
Cacheable (K0=3) |
Exception code (MIPS_EXCEPTIONS_CODE, max 8 KiB): TLB Refill vector (+0x000), general vector (+0x180), and interrupt vectors (+0x200..+0x600) |
0xBFC01800 |
MIPS wrapper | Uncached | MIPS wrapper fence / write-buffer drain register (write 1 + ehb + sync) |
kseg2)The first TLB entries are fixed (Wired): Wired = 4 in the K3 vendor configuration and Wired = 5 when the host uses pt_num_pages = 4 (mainline). The remainder (Wired..15) are dynamic and serviced by the TLB Refill vector. Each entry covers a pair of pages (EntryLo0 = VA, EntryLo1 = VA + page_size).
| TLB Index | Virtual Range | PageMask / Size |
EntryLo.C |
Purpose |
|---|---|---|---|---|
0 |
0xCF800000 – 0xCFFFFFFF |
0x7FF800 (4 MiB/page) |
2 (uncached) + XI |
Unicast CR bank (0xCF800000) and broadcast BCAST[...] bank (0xCFA00000), since both fall within the same 4 MiB page. EntryLo1 maps 0xCFC00000 (window used to write the exception dump) |
1 |
0xCF000000 + n × pt_log2_page_size |
PT page PageMask |
3 (write-back) |
MIPS page table window. One entry covers pt_num_pages × page_size when pt_num_pages = 2 (K3 vendor config: 16 KiB page → 32 KiB); with pt_num_pages = 4 it takes two entries (4 KiB page, 8 KiB each) |
2 |
config-dependent | per PT | 3 |
With pt_num_pages = 4: second half of PT window (0xCF002000). With pt_num_pages = 2: stack |
3 |
config-dependent | 0x1800 (4 KiB) |
3 |
With pt_num_pages = 4: stack (0xCF600000). With pt_num_pages = 2: first page of MIPS_PRIVATE_DATA |
4 |
config-dependent | 0x1800 (4 KiB) |
3 |
Only with pt_num_pages = 4: first page of MIPS_PRIVATE_DATA |
Wired..15 |
0xC0000000 + FW Heap |
per PTE | per PTE | FW Heap code/data (demand-paged) |
Wireddepends onpt_num_pages:4in K3 vendor (log2 = 14, 2 pages) and5in mainline (log2 = 12, 4 pages). Both are observed/derived; the firmware accepts both configurations (validates even12 ≤ log2 ≤ 18andpt_num_pages < 5).
Note (
[O]): the firmware usesC = 3(write-back) for the page table, stack, and private data, whereas the host maps FW Heap pages inpvr_vm_mips.cwithC = 1(write-through) becausephys_bus_width = 36. A reimplementation may use write-through everywhere without changing the ABI.
MIPS_BOOT_DATA ([P][O])64-byte structure populated by the host before releasing reset (layout confirmed in pvr_rogue_mips.h and by reads at offsets 0x00, 0x08, 0x10, 0x18, 0x30, 0x34 in the 0x9FC01000 window):
| Offset | Field | Contents |
|---|---|---|
0x00 |
stack_phys_addr (u64) |
Physical address of the stack (MIPS_STACK, 1 page) |
0x08 |
reg_base (u64) |
Physical base of the GPU register bank |
0x10 |
pt_phys_addr[0..3] (4 × u64) |
Physical addresses of the 4 MIPS page table pages |
0x30 |
pt_log2_page_size (u32) |
12 (4 KiB); accepts 12..18 with parity constraint |
0x34 |
pt_num_pages (u32) |
4 (ROGUE_MIPSFW_MAX_NUM_PAGETABLE_PAGES) |
0x38 |
reserved1 (u32) |
0 |
0x3C |
reserved2 (u32) |
0 |
Rules observed during K3 boot:
pt_num_pages must be < 5 and pt_log2_page_size must be in 12..18; otherwise the firmware executes break (fatal trap) — there is no recovery path.1 << (log2_heap_size - 12 + 2) bytes, so 4 pages × 4 KiB correspond to a 16 MiB FW Heap.Note on unicast vs. broadcast accesses (
[D]): On K3 MC1 there is only 1 physical core (ROGUE_CR_MULTICORE_SYSTEM= 1), but the silicon implementsXPU_REGISTER_BROADCAST = 1. The firmware must respectBCAST[off](0xCFA00000 + off) addressing for per-core replicated registers andCR[off](0xCF800000 + off) for core/global control registers, exactly as indicated in the tables of boot-gpu-init.md, kick-geometry-ta.md, and kick-compute-and-3d.md.
MIPS_ADDR_REMAP1..5 Registers and BRN 63553 Workaround ([P][O])Before releasing MIPS from reset, the host driver (pvr_fw_mips.c) configures 5 physical address remapping windows in the MIPS wrapper:
| Window | CONFIG1 (Input) |
CONFIG2 (Output + Size) |
Purpose in Mainline |
|---|---|---|---|
| REMAP1 | 0x1820 (0x1FC00000 | VALID) |
0x1828 (boot/exception DMA | 64KB) |
Maps boot/exception vector 0xBFC00000 → boot DRAM |
| REMAP2 | 0x1838 (data VA | VALID) |
0x1840 (data DMA | 4KB..256KB) |
Maps private data / MIPS table when outside TLB |
| REMAP3 | 0x1850 (code VA | VALID) |
0x1858 (code DMA | size) |
Firmware code window |
| REMAP4 | 0x1868 (trampoline / MMIO) |
0x1870 (0x0 or MMIO base | size) |
GPU CR register window mapping |
| REMAP5 | 0x1880 (0x00000000 | VALID) |
0x1888 (boot code DMA | 64KB) |
Mandatory BRN 63553 workaround (K3 36-bit bus) |
[P])On the 36.56.104.183 silicon (36-bit physical bus with BRN 63553 present), spurious transactions to physical address 0x0 during MIPS startup/execution cause a bus fault if not redirected. The host programs REMAP5 pointing input address 0x0 to the boot code DMA buffer (64 KiB). The firmware must not disable or overwrite REMAP5 during boot or normal operation.
EntryLo, and TLB ([P][O])pt_num_pages pages of 2^pt_log2_page_size bytes, physical addresses in MIPS_BOOT_DATA.pt_phys_addr[0..3], mapped in the 0xCF000000 window (wired index 1, and 2 when pt_num_pages = 4).
pt_num_pages = 2, 16 KiB page → 32 KiB PT.pt_num_pages = 4, 4 KiB page → 16 KiB PT.PTE0 (= EntryLo0) followed by PTE1 (= EntryLo1).0xCF000000 + ((EntryHi >> 10) & 0x3FFFF). Since EntryHi[31:13] = VPN2, EntryHi >> 10 = VPN2 × 8 — the offset is already the entry’s byte offset.PT_bytes / 8 pairs × 8 KiB → 32 KiB PT ⇒ 8192 pairs ⇒ 32 MiB; 16 KiB PT ⇒ 4096 pairs ⇒ 16 MiB.EntryLo Format (32-bit, 36-bit Physical)| Bits | Field | Semantics |
|---|---|---|
[31] |
RI — Read Inhibit |
Copied from PTE to EntryLo |
[30] |
XI — Execute Inhibit |
Copied from PTE to EntryLo |
[29:6] |
PFN (24 bits) |
phys_addr >> 12 → covers 2^(24+12) = 36 bits (64 GiB) |
[5:3] |
C — Coherency/cache |
0 = ?; 1 = write-through; 2 = uncached; 3 = write-back (ROGUE_MIPSFW_*_CACHE_POLICY) |
[2] |
D — Dirty (writable) |
|
[1] |
V — Valid |
|
[0] |
G — Global (no ASID) |
Public masks: ROGUE_MIPSFW_ENTRYLO_PFN_MASK_ABOVE_32BIT = 0x3FFFFFC0, ..._CACHE_POLICY_SHIFT = 3, ..._DIRTY_EN = 4, ..._VALID_EN = 2, ..._GLOBAL_EN = 1.
The host writes PTE = ((dma >> 12) << 6) & PFN_MASK | C << 3 | D | V | G.
PageMask EncodingThe firmware uses the public macro ROGUE_MIPSFW_TLB_GET_PAGE_MASK(page_size_KiB):
PageMask = (((page_size_KiB << 11) - 1) & ~0x7FF)
| Page Size | PageMask Written |
|---|---|
| 4 KiB | 0x00001800 |
| 4 MiB | 0x007FF800 |
Bits
[12:11]of the written value are the vendor macro’s bias; the effective mask field is[28:13](0→ 4 KiB,0x3FF→ 4 MiB).
[O])For the missing page, with VPN2 = EntryHi[31:13] read from the PTE pair:
EntryLo0 = (PTE0 & 0xC000003F) | (((EntryHi >> 12) + 0) << 6) // PFN = even VPN
EntryLo1 = (PTE1 & 0xC000003F) | (((EntryHi >> 12) + 1) << 6) // PFN = odd VPN
In other words: the PFN placed in the TLB is the VPN itself (VA & 0x0FFFFFFF), not the actual physical address. The actual physical translation happens in the MIPS wrapper range-remap table (§4.5), which is programmed with the PTE’s PFN. Practical consequences:
EntryLo with V = 0 (PTE cleared by the host in pvr_vm_mips_unmap()) forces a new exception — that is how the firmware detects an unmapped page.[31:30] and [5:0] come from the PTE; C, D, V, G are therefore host-controlled.MIPS_ADDR_REMAP_RANGE Coupling (32 Entries)The wrapper exposes 32 range-remap entries, two per TLB entry (ROGUE_MIPSFW_NUMBER_OF_REMAP_ENTRIES = 2 × 16). There are three registers, and confusing them is a common source of error:
| Register | Offset | Width | Role |
|---|---|---|---|
ROGUE_CR_MIPS_ADDR_REMAP_RANGE_CONFIG |
0x0878 (+ 0x087C = high word) |
64 b | entry programming |
ROGUE_CR_MIPS_ADDR_REMAP_RANGE_READ |
0x0880 |
32 b | read trigger (W1) |
ROGUE_CR_MIPS_ADDR_REMAP_RANGE_DATA |
0x0888 (+ 0x088C) |
64 b | read result (RO) |
Bitfields of CONFIG (64-bit, effective address = 0x0878 with high word at 0x087C):
| Bits | Field | Semantics |
|---|---|---|
0 |
MODE_ENABLE |
1 = entry active |
[5:1] |
ENTRY |
entry index (0..31); value written is index << 1 |
[9:7] |
REGION_SIZE |
region size (encoding: 4 KB = 0, 16 KB = 1 … 4 MB = 5) |
11 |
TRUSTED |
privileged access |
[31:12] |
BASE_ADDR_IN |
input page (VA/PA depending on mode) |
[34:32] |
OS_ID |
associated OSID |
[59:36] |
ADDR_OUT |
output page → lives in the high word (0x087C): ADDR_OUT = phys >> 12, and the firmware writes 0x087C = phys >> 8 |
DATA (0x0888/0x088C) is only used to read back the entry (which the state dump does), never to program it.
Allocation of the 32 entries:
| Entries | Usage |
|---|---|
0..15 |
Temporary translation for the missing page, paired with the dynamic TLB entry of the same index |
16..31 |
Permanent translation for wired entries: 16 + i ↔ TLB index i |
Programming sequence (per page): CONFIG = (ENTRY = index) | (REGION_SIZE) | (BASE_ADDR_IN = page) | MODE_ENABLE, then 0x087C = phys >> 8 (ADDR_OUT). For this reason, the TLB Refill vector cannot use the page table window itself to resolve the fault: it reprograms a remap entry and only then reads PTE0/PTE1. Initialization zeroes all 32 entries (0x0878 = i << 1, 0x087C = 0).
Wired..15): rewrite unique EntryHi/EntryLo0/EntryLo1 via tlbwi (use a unique synthetic EntryHi per index to avoid VPN conflicts).0x0878 = (index << 1); 0x087C = 0.[O]): two TLB entries with the same EntryHi (VPN2) — or a conflict between REMAP and TLB — trigger Machine Check (Cause = 0x00800060).[P])The GPU execution blocks (VDM, TE, ISP, PBE, CDM, PM, USC, PDS) translate 40-bit virtual addresses through a 3-level hierarchical MMU managed by the host driver (pvr_mmu.c, pvr_rogue_mmu_defs.h):
| Level | Acronym | VA Bits ([39:0]) |
Entries per Table | Entry Size | Table Size | Coverage per Entry |
|---|---|---|---|---|---|---|
| Level 1 | PC (Page Catalogue) | [39:30] (10 bits) |
1024 | 4 bytes (u32) |
4 KiB | 1 GiB |
| Level 2 | PD (Page Directory) | [29:21] (9 bits) |
512 | 8 bytes (u64) |
4 KiB | 2 MiB |
| Level 3 | PT (Page Table) | [20:12] (9 bits) |
512 | 8 bytes (u64) |
4 KiB | 4 KiB (page) |
| Offset | — | [11:0] (12 bits) |
— | — | — | 4 KiB |
[P])u32):
0: VALID[31:4]: 4 KiB-aligned PD physical address (pd_phys >> 8, supports 36-bit physical)u64):
0: VALID[3:1]: PAGE_SIZE (0 = 4 KiB, 1 = 16 KiB, 2 = 64 KiB, 3 = 256 KiB, 4 = 1 MiB, 5 = 2 MiB)[39:12]: physical base of the PT (or large page)u64):
0: VALID1: READ_ONLY2: PM_META_PROTECT3: SLC_BYPASS6: SLC_NOALLOC[35:12]: physical page address (24 bits → 36 physical bits)[D])The firmware does not build or edit user-context PC/PD/PT tables (that is exclusively the host’s job). The firmware’s responsibilities are:
BIF_CAT_BASE1..7 (BCAST[0x1208..0x1238]) with pc_dev_paddr from struct rogue_fwif_fwmemcontext when activating a memory context for a DM (see data-masters.md).KCCB_CMD_MMUCACHE) and during BIF bank switches or HWR.EVENT_STATUS bit 9 = 0x200).[P])Per pvr_rogue_heap_config.h, the GPU’s 40-bit space is partitioned into well-defined heaps (most relevant to the firmware):
| Heap | Role for the Firmware |
|---|---|
| Firmware Main / Config / Raw | Shared between host and MIPS (mapped in OSID 0 FW Heap; OSID 0..7 supported by hardware) |
| General | Vertex buffers, textures, framebuffers, cCCB payloads, VDM/CDM control streams |
| PDS Code/Data | PDS state programs and data — base programmed in BCAST[0x0610/0x0614] (sysinit.pds_exec_base) |
| USC Code | USC shaders — base programmed in BCAST[0x4008/0x4010/0x4028] (sysinit.usc_exec_base) |
| Transfer Frag / RGNHDR / MMU | Auxiliary rendering structures |
.fw Container Format (Mainline v3) ([P][O])The mainline driver loads powervr/rogue_36.56.104.183_v1.fw by validating a structured footer/header defined in pvr_fw_info.h.
┌────────────────────────────────────────────────────────┐
│ Binary payload of firmware sections │
│ (MIPS code, boot/exceptions, data, etc.) │
├────────────────────────────────────────────────────────┤
│ struct pvr_fw_device_info_header + 29 × u64 params │ (referenced by device_info_size)
├────────────────────────────────────────────────────────┤
│ struct pvr_fw_layout_entry[layout_entry_num] (6 items) │
├────────────────────────────────────────────────────────┤
│ struct pvr_fw_info_header (at the end of the file) │
└────────────────────────────────────────────────────────┘
pvr_fw_info_header ([P])info_version: 3 (format with device_info block)header_len: size of struct pvr_fw_info_headerlayout_entry_num: number of pvr_fw_layout_entry entries (6 entries in the MIPS image)layout_entry_size: sizeof(struct pvr_fw_layout_entry) (24 bytes)bvnc: PVR_PACKED_BVNC(36, 56, 104, 183) = 0x00240038006800B7fw_page_size: 12 (4096 bytes)flags: indicates MIPS processor (PVR_FW_INFO_FLAG_MIPS)fw_version_major / fw_version_minor: 1.1 (compatible with drm/imagination)device_info_size: size of the device_info block in bytes (sizeof(header) + 29 * 8)pvr_fw_layout_entry) ([P][O])| # | Type (type) |
Purpose | Critical Rule in Mainline |
|---|---|---|---|
| 0 | MIPS_PRIVATE_DATA |
MIPS private data (.data/.bss) |
Mapped in the private data window |
| 1 | MIPS_EXCEPTIONS |
Boot/reset/NMI vector (0xBFC00000) |
Mapped by REMAP1 (64 KiB) |
| 2 | MIPS_CODE |
Main code (.text/.rodata) |
Mandatory invariant ([O]): alloc_size must remain fixed at the budget expected by the layout (page-aligned) and satisfy pvr_fw_mips.c validation (used in REMAP3 and REMAP5 BRN 63553). Increasing alloc_size shifts the shared FWIF allocations placed immediately after base + alloc_size and breaks the boot handshake (firmware_started) |
| 3 | MIPS_STACK |
Execution stack (4 KiB) |
alloc_size = 0x1000, no payload in file (base_size = 0) |
| 4 | MIPS_BOOT_DATA |
Initial handshake area filled by the host | Host writes sysinit addresses, MIPS page table, and config before releasing reset |
| 5 | MIPS_CORE_MEM / auxiliary |
Exception state data / reserved area per v3 layout | Per pvr_fw_validate() in pvr_fw.c |
device_info Block (29 Parameters Consumed by Mainline) ([P][O])The mainline driver validates and consumes 29 parameters (u64) from the device_info block embedded in .fw for BVNC 36.56.104.183:
num_clusters=1, num_raster_pipes=1, num_isp_ipp_pipes=6, isp_max_tiles_in_flight=6, isp_samples_per_pixel=1, tile_size_x=16, tile_size_y=16, max_partitions=12, common_store_size_in_dwords=19456, usc_min_output_registers_per_pix=2.phys_bus_width=36, virtual_address_space_bits=40, slc_banks=1, slc_cache_line_size_bits=512, slc_size_in_kilobytes=16 (with SLC_SIZE_CONFIGURABLE flag; real HW = 128 KiB), num_osids=8, xpu_max_regbanks_addr_width=19, xpu_max_slaves=3, xpu_register_broadcast=1.xe_architecture=1, layout_mars=1, simple_parameter_format_version=2, cdm_control_stream_format=1, fbcdc=50, fbcdc_algorithm=50, fbcdc_architecture=7, fbc_max_default_descriptors=0, fbc_max_large_descriptors=0, tfbc_version=10.44079, 63553), and ERNs (35421, 38748, 42290, 42606, 47025, 57596) in overview.md.