code wiki / _hdl_build / rv64im_min_gpu.nx
rv64im_min_gpu.nx
buildroot/runtime/_hdl_build/rv64im_min_gpu.nx
about
rv64im_min_gpu.nx -- a SOVEREIGN GPU-class command-submission controller device model (the 4th
device class for the driver-from-spec arc, toward the GPU/CUDA/DirectX trajectory). Twin of
rv64im_min_nvme.nx but for the GPU SUBMISSION model: a command RING in guest RAM, a write-to-
submit DOORBELL, a monotonic FENCE/seqno the driver polls for completion, and a RESULTPEEK
binding-proof register. It COMPOSES with the sovereign SPIR-V lane: a command packet MUST carry
the SPIR-V magic 0x07230203 (a compute-shader dispatch) or the device refuses to execute -- so a
GPU driver authored from an op-list spec drives a real SPIR-V-validated dispatch.
The device models ONE controller window [0x10007000, 0x10008000) -- free of the virtio (0x10001/
0x10002), nvme (0x10003-0x10005), nndev (0x10005), and mmu (0x10006) windows (additive). KEY
behaviour: on a DOORBELL write the device fetches the command packet from RING_BASE (STRUCT_WALK:
opcode + spirv_magic + operand + seqno), validates the SPIR-V magic, "executes" the dispatch, bumps
FENCE to the submitted seqno, and latches RESULTPEEK = (operand<<16)|seqno.
GPU/Vulkan/SPIR-V here is the last-mile interop PROBE + a measuring stick to EXCEED -- the emitted
driver + the op-list shapes are Nishi-native (the device identity lives ENTIRELY in the spec; the
canonical op-list emitter nx_drv_proto_emit knows zero GPU).
Status: SEED. 2026-06-13. Enable + command-ring doorbell dispatch + SPIR-V-magic-gated fence/result.
license_tier: ORIGINAL
dependencies 2 imports · 2 importers
imports: nx_syscalls.nxnishi_hdl_primitives.nx
imported by: _gpu_run.nxrv64im_min_sim.nx
structs
| 83 | struct NxGpu |
consts
| 25 | const NX_GPU_BASE: i64 = 0x10007000 |
| 26 | const NX_GPU_END: i64 = 0x10008000 |
| 36 | const NX_GPU_OFF_ID: i64 = 0x00 |
| 37 | const NX_GPU_OFF_CTRL: i64 = 0x04 |
| 38 | const NX_GPU_OFF_STATUS: i64 = 0x08 |
| 39 | const NX_GPU_OFF_RING_LO: i64 = 0x10 |
| 40 | const NX_GPU_OFF_RING_HI: i64 = 0x14 |
| 41 | const NX_GPU_OFF_DOORBELL: i64 = 0x20 |
| 42 | const NX_GPU_OFF_FENCE: i64 = 0x24 |
| 43 | const NX_GPU_OFF_RESULTPEEK: i64 = 0x28 |
| 46 | const NX_GPU_ID: i64 = 0x00475055 // RO identity const |
| 47 | const NX_GPU_CTRL_EN: i64 = 1 // CTRL.EN = bit0 |
| 48 | const NX_GPU_STATUS_READY: i64 = 1 // STATUS.READY = bit0 |
| 49 | const NX_GPU_SPIRV_MAGIC: i64 = 0x07230203 // SPIR-V module magic -- the dispatch must carry it |
| 56 | const NX_GPU_PKT_OFF_OPCODE: i64 = 0 |
| 57 | const NX_GPU_PKT_OFF_MAGIC: i64 = 4 |
| 58 | const NX_GPU_PKT_OFF_OPERAND:i64 = 8 |
| 59 | const NX_GPU_PKT_OFF_SEQNO: i64 = 12 |
| 62 | const NX_GPU_OPCODE_ECHO: i64 = 1 // (operand<<16)|seqno binding echo (the base round-trip) |
| 63 | const NX_GPU_OPCODE_DOT8: i64 = 2 // int8 4-elem dot product -> RESULTPEEK |
| 64 | const NX_GPU_OPCODE_MATMUL2: i64 = 3 // 2x2 int8 matmul tile (the V-RAM-005 primitive) -> packed RESULTPEEK |
| 65 | const NX_GPU_PKT_OFF_CSEQ: i64 = 8 // DOT8: seqno @+8 (operand slot reused for the compute opcode) |
| 66 | const NX_GPU_PKT_OFF_A: i64 = 16 // DOT8: 4 int8 a-values @+16..19 |
| 67 | const NX_GPU_PKT_OFF_B: i64 = 20 // DOT8: 4 int8 b-values @+20..23 |
| 70 | const NX_GPU_OK: i64 = 0 |
| 71 | const NX_GPU_ADDR_OUT_OF_RANGE: i64 = 1 |
| 74 | const NX_GPU_SLOT_CTRL: i64 = 0 |
| 75 | const NX_GPU_SLOT_STATUS: i64 = 1 |
| 76 | const NX_GPU_SLOT_RING_LO: i64 = 2 |
| 77 | const NX_GPU_SLOT_RING_HI: i64 = 3 |
| 78 | const NX_GPU_SLOT_FENCE: i64 = 4 |
| 79 | const NX_GPU_SLOT_RESULTPEEK: i64 = 5 |
| 80 | const NX_GPU_SLOT_DBELL: i64 = 6 |
| 81 | const NX_GPU_SLOT_N: i64 = 7 |
functions
| 89 | func nx_gpu_reset_storage(storage: *i64) -> i64 |
| 100 | func nx_gpu_init(c: *NxGpu, storage: *i64) -> i64 |
| 110 | func nx_gpu_addr_in_range(c: *NxGpu, addr: i64) -> i64 |
| 117 | func nx_gpu_dma_rd16(mem_buf: *u8, off: i64) -> i64 called by 1: nx_gpu_doorbell_dma |
| 122 | func nx_gpu_dma_rd32(mem_buf: *u8, off: i64) -> i64 called by 1: nx_gpu_doorbell_dma |
| 129 | func nx_gpu_dma_inrange(off: i64, w: i64, mem_size: i64) -> i64 called by 1: nx_gpu_doorbell_dma |
| 134 | func nx_gpu_dma_rd8(mem_buf: *u8, off: i64) -> i64 { return mem_buf[off] as i64 } called by 1: nx_gpu_doorbell_dma |
| 136 | func nx_gpu_sext8(v: i64) -> i64 { let low: i64 = v & 0xff; if (low & 0x80) != 0 { return low | (0 - 256) } return low } called by 1: nx_gpu_doorbell_dma |
| 139 | func nx_gpu_read32(c: *NxGpu, addr: i64, value_out: *i64) -> i64 |
| 183 | func nx_gpu_doorbell_dma(c: *NxGpu, mem_buf: *u8, mem_base: i64, mem_size: i64) -> i64 |
| 251 | func nx_gpu_write32(c: *NxGpu, addr: i64, value: i64) -> i64 |
| 277 | func nx_gpu_fence(c: *NxGpu) -> i64 |