Imagination_BXE-2-32

Memory model

The firmware’s MIPS core sees a 32-bit address space; the GPU hardware addresses a 36-bit bus. The bridge between them is the MIPS TLB (always identity) plus the RGX wrapper’s remap registers. The whole firmware VA→physical translation is set up by the host (the driver manages the page tables).

MIPS core address space

VA Contents
0xBFC00000 Boot ROM / reset+NMI vector (KSEG1, uncached). Boot/NMI code.
0xBFC01000 BOOT_DATA (also visible cached at 0x9FC01000). Filled by the host at boot. See layout below.
0x9FC02000 EBase (exception/interrupt vectors). +0x000 TLB refill, +0x180 general exception, +0x400 HW0 timer, +0x500 HW1 BG, +0x600 HW2 IRQ.
0xC0000000 Firmware code and private data (the internal layout is chosen by the image and exported to the host through the layout table, below). Also the firmware heap window: structures shared with the host are addressed as 0xC0xxxxxx.
0xCF000000 MIPS page table (EntryLo format, written by the host).
0xCF600000 Firmware stack page (wired TLB entry; physical address comes from BOOT_DATA).
0xCF800000 RGX register bank of core 0 (4 MiB, uncached). Core n at 0xCF800000 + n·0x80000.
0xCFA00000 XPU broadcast bank: a write here goes to every core enabled in ROGUE_CR_XPU_BROADCAST.

BOOT_DATA (0xBFC01000)

The host writes the start of the page before releasing the MIPS from reset. That part is public ABI (P, struct rogue_mipsfw_boot_data in pvr_rogue_mips.h): physical addresses of the page-table pages, the stack and the register bank, the page size and the number of page-table pages (see the end of this document).

The rest of the page is the firmware’s private area, with a free layout. The firmware must reserve room for:

Translation contract (MIPS wrapper)

Fault page

TLB faults (Mod/TLBL/TLBS) on pages without permission are redirected to the host’s fault page (rogue_fwif_sysinit.fault_phys_addr):

This makes the firmware robust to invalid pointers: instead of hanging, it diverts to the fault page and triggers recovery. (See hardware-recovery.)

Heap window and per-OS virtualisation

Structures shared with the host live in the 0xC0xxxxxx window. The firmware supports virtualisation: several “OS” (guests) with their own CCBs and control blocks, isolated by a fixed VA offset.

Item Value
Window size per OSID 16 MiB
VA mask VA & 0xC0FFFFFC
osinit of OS n 0xC0FE0000 + n·16 MiB
Connection page of OS n 0xC0FD0000 + n·16 MiB
sysinit 0xC0FF0000
Valid address (a & 0x3F000003) == 0

MIPS page table (managed by the host)

.fw container format (read by the host at boot)

The host needs to know where each firmware section goes in memory. The format is public (P, pvr_fw_info.h and the validation in pvr_fw.c):

[ firmware ELF (code, data, boot/NMI, exception vectors…) ]
[ device info block (device_info_size bytes) ]
[ struct pvr_fw_info_header          @ (file size − 4096) ]
[ struct pvr_fw_layout_entry × layout_entry_num ]

For a reimplementation, the essential point is to export a correct layout table so that the host remaps each section. MIPS_BOOT_CODE, MIPS_BOOT_DATA and MIPS_EXCEPTIONS_CODE have dedicated remaps.

Device information block

The device-info block (between the ELF and the info header) carries the BRN/ERN masks and the feature mask + feature values for this specific GPU. The host (and the firmware, via sysinit) uses these to size structures and gate behaviour. The format is public (pvr_fw_info.h, consumed in pvr_fw.c); the values below are the ones carried by the redistributable open firmware image for BVNC 36.29.52.182 (P — read from the open image’s own device-info block, not from the closed firmware). This answers the clean team’s Q2 and corrects several of its assumptions.

Feature Value
VIRTUAL_ADDRESS_SPACE_BITS 40
PHYS_BUS_WIDTH 36
SLC_SIZE_IN_KILOBYTES 16 (not 0 — affects the SLC-bypass decision at boot, see boot-gpu-init)
SLC_BANKS 1; SLC_CACHE_LINE_SIZE_BITS 512; SLC_SIZE_CONFIGURABLE present
NUM_ISP_IPP_PIPES 2
NUM_CLUSTERS 1; NUM_RASTER_PIPES 1; MAX_PARTITIONS 8
ISP_MAX_TILES_IN_FLIGHT 2; ISP_SAMPLES_PER_PIXEL 1; TILE_SIZE_X/Y 16
COMMON_STORE_SIZE_IN_DWORDS 13312; USC_MIN_OUTPUT_REGISTERS_PER_PIX 2
NUM_OSIDS 8
FBCDC / FBCDC_ALGORITHM 50; FBCDC_ARCHITECTURE 7
SIMPLE_PARAMETER_FORMAT_VERSION 2 (SIMPLE_INTERNAL_PARAMETER_FORMAT + _V2)
XE_ARCHITECTURE 1
XPU_MAX_SLAVES 3; XPU_MAX_REGBANKS_ADDR_WIDTH 19; XPU_REGISTER_BROADCAST 1

SYS_BUS_SECURE_RESET is required (the clean team found this by experiment): without it in the device info, the host leaves ROGUE_CR_SYS_BUS_SECURE at its reset value and the MIPS cannot fetch from the reset vector 0xBFC00000. The firmware also writes ROGUE_CR_SYS_BUS_SECURE = 0 during power-on (see boot-gpu-init).

Page-table entry format (host side — public ABI)

The MIPS page table is written by the host in EntryLo format. The rule is in the public mainline driver (pvr_vm_mips.c) and is quoted here because the firmware depends on it (the TLB refill handler reads these entries). For the virtual page with index pfn inside the heap (pfn = (VA − ROGUE_FW_HEAP_BASE) >> 12, 4 KiB pages):

PTE = ((dma_addr >> 12) << ENTRYLO_PFN_SHIFT) & pfn_mask
PTE |= pte_flags                      // read/write + cache policy

For the firmware reimplementation, what matters is that the TLB refill handler (0x9FC02000) reads the EntryLo from this table and puts it into the remap entry; the host takes care of the write format.