code wiki / _hdl_build / rv64im_min_virtio.nx

rv64im_min_virtio.nx

buildroot/runtime/_hdl_build/rv64im_min_virtio.nx

29892 B522 linesdepth 3pulls 3 transitivereach 66 importersview sourcekind librarytopic rv64im
docsdependenciesstructsconstsfunctions

about

rv64im_min_virtio.nx -- legacy virtio-MMIO transport device model (K-R2-001a). Carves the legacy virtio-MMIO register block at base 0x10001000 into the sovereign sim's load32/store32 dispatch. This is the TRANSPORT layer: it exposes the device identity (MagicValue/Version/DeviceID/VendorID), the feature-negotiation registers (HostFeatures/GuestFeatures), and the Status register the driver uses to walk the virtio device-initialization handshake (spec virtio v1.2 sec 3.1 / legacy MMIO sec 4.2.2). The split-virtqueue + DMA + blk sector round-trip land in K-R2-001b; virtio-net loopback in K-R2-001c. This rung is the handshake only. Memory map (matches qemu virt machine with virtio-mmio.force-legacy=true; the spec knowledge/specs/virtio_blk_handshake_virt.spec is the single data source -- these consts mirror it, and the gate proves the device, the driver, and the spec all agree end-to-end on the SOVEREIGN emu): 0x10001000 MagicValue (RO) 0x74726976 ("virt", little-endian) 0x10001004 Version (RO) 1 (legacy) 0x10001008 DeviceID (RO) 2 (block device) 0x1000100C VendorID (RO) 0x554D4551 ("QEMU") 0x10001010 HostFeatures (RO) device-offered feature bits 0x10001020 GuestFeatures(WO) driver-accepted feature bits (latched) 0x10001070 Status (RW) driver writes OR-in ACK/DRIVER/FEATURES_OK/DRIVER_OK; a write of 0 = device reset (Status -> 0) Status: SEED. 2026-06-13. Register storage + identity reads + Status latch + reset. Synth target (Tier B+ MPW): identity ROM + 2 feature flops + 1 status flop + decoder.

dependencies 2 imports · 20 importers

nx_syscalls.nx nishi_hdl_primitives.nx rv64im_min_virtio.nx _gpu_run.nx _nvme_diag.nx nx_bootcap.nx nx_nishios_window.nx nx_nxc_baremetal.nx nx_nxc_run.nx nx_rv64_amo_gate.nx nx_rv64_csr_trap_oracle.nx nx_rv64_fast.nx nx_rv64_fast_dev_gate.nx

diagram shows first 10 each side; +0 more imports, +10 more importers in the complete lists below.

imports: nx_syscalls.nxnishi_hdl_primitives.nx

imported by: _gpu_run.nx_nvme_diag.nxnx_bootcap.nxnx_nishios_window.nxnx_nxc_baremetal.nxnx_nxc_run.nxnx_rv64_amo_gate.nxnx_rv64_csr_trap_oracle.nxnx_rv64_fast.nxnx_rv64_fast_dev_gate.nxnx_rv64_kernel_gate.nxnx_rv64_mmu_oracle.nxnx_rv64_qemu_fuzz.nxnx_rv64_qemu_oracle.nxnx_rv64_realc_gate.nxnx_rv64_run_bin.nxnx_rv64_sdeleg_oracle.nxnx_rv64_snapshot_gate.nxnx_rv64_timer_oracle.nxrv64im_min_sim.nx

structs

174struct NxVirtioMmio

consts

31const NX_VIRTIO_BASE: i64 = 0x10001000
32const NX_VIRTIO_END: i64 = 0x10001100 // one device's 256-byte register window
40const NX_VIRTIO_NET_BASE: i64 = 0x10002000
41const NX_VIRTIO_NET_END: i64 = 0x10002100 // the net device's 256-byte register window
42const NX_VIRTIO_NET_DEVICEID: i64 = 1 // virtio-net
44const NX_VIRTIO_OFF_MAGIC: i64 = 0x000
45const NX_VIRTIO_OFF_VERSION: i64 = 0x004
46const NX_VIRTIO_OFF_DEVICEID: i64 = 0x008
47const NX_VIRTIO_OFF_VENDORID: i64 = 0x00C
48const NX_VIRTIO_OFF_HOSTFEAT: i64 = 0x010
49const NX_VIRTIO_OFF_GUESTFEAT: i64 = 0x020
57const NX_VIRTIO_OFF_QUEUESEL: i64 = 0x030
58const NX_VIRTIO_OFF_QUEUENUMMAX: i64 = 0x034
59const NX_VIRTIO_OFF_QUEUENUM: i64 = 0x038
60const NX_VIRTIO_OFF_QUEUEALIGN: i64 = 0x03C
61const NX_VIRTIO_OFF_QUEUEPFN: i64 = 0x040
62const NX_VIRTIO_OFF_QUEUENOTIFY: i64 = 0x050
67const NX_VIRTIO_OFF_QUEUEDESCPEEK: i64 = 0x060
73const NX_VIRTIO_OFF_QUEUEUSEDIDXPEEK: i64 = 0x064
79const NX_VIRTIO_OFF_QUEUESTATPEEK: i64 = 0x068
89const NX_VIRTIO_OFF_QUEUESECTPEEK: i64 = 0x06C
90const NX_VIRTIO_OFF_STATUS: i64 = 0x070
93const NX_VIRTIO_MAGIC: i64 = 0x74726976 // "virt"
94const NX_VIRTIO_VERSION: i64 = 1 // legacy MMIO
95const NX_VIRTIO_DEVICEID: i64 = 2 // virtio-blk
96const NX_VIRTIO_VENDORID: i64 = 0x554D4551 // "QEMU"
97const NX_VIRTIO_HOSTFEAT: i64 = 0x00000020 // offered feature bits (legacy blk subset)
98const NX_VIRTIO_QUEUENUMMAX: i64 = 8 // device-offered max ring size (legacy blk q0)
101const NX_VIRTIO_DESC_OFF_ADDR: i64 = 0 // desc.addr (8 bytes); low word is DMA-read
109const NX_VIRTIO_AVAIL_RING_OFF: i64 = 0x084
110const NX_VIRTIO_AVAIL_IDX_OFF: i64 = 0x082
111const NX_VIRTIO_USED_RING_OFF: i64 = 0x104 // used.ring[0].id; .len at +4
112const NX_VIRTIO_USED_IDX_OFF: i64 = 0x102
113const NX_VIRTIO_QUEUE_NUM: i64 = 8 // ring size (queuenum); head mask = num-1
121const NX_VIRTIO_STAT_BUF_PHYS: i64 = 0x80004000
122const NX_VIRTIO_BLK_S_OK: i64 = 0
125const NX_VIRTIO_STAT_ACK: i64 = 1 // ACKNOWLEDGE
126const NX_VIRTIO_STAT_DRIVER: i64 = 2 // DRIVER
127const NX_VIRTIO_STAT_DRIVER_OK: i64 = 4 // DRIVER_OK
128const NX_VIRTIO_STAT_FEATURES_OK: i64 = 8 // FEATURES_OK
131const NX_VIRTIO_OK: i64 = 0
132const NX_VIRTIO_ADDR_OUT_OF_RANGE: i64 = 1
147const NX_VIRTIO_SLOT_STATUS: i64 = 0
148const NX_VIRTIO_SLOT_GUESTFEAT: i64 = 1
149const NX_VIRTIO_SLOT_QSEL: i64 = 2
150const NX_VIRTIO_SLOT_QNUM: i64 = 3
151const NX_VIRTIO_SLOT_QPFN: i64 = 4
152const NX_VIRTIO_SLOT_QNOTIFY: i64 = 5
156const NX_VIRTIO_SLOT_DESCPEEK: i64 = 6
160const NX_VIRTIO_SLOT_USEDIDX: i64 = 7
167const NX_VIRTIO_SLOT_STATPEEK: i64 = 8
171const NX_VIRTIO_SLOT_SECTPEEK: i64 = 9
172const NX_VIRTIO_SLOT_N: i64 = 10

functions

183func nx_virtio_reset_storage(storage: *i64) -> i64
199func nx_virtio_init(v: *NxVirtioMmio, storage: *i64) -> i64
213func nx_virtio_init_net(v: *NxVirtioMmio, storage: *i64) -> i64
227func nx_virtio_addr_in_range(v: *NxVirtioMmio, addr: i64) -> i64
239func nx_virtio_read32(v: *NxVirtioMmio, addr: i64, value_out: *i64) -> i64
329func nx_virtio_write32(v: *NxVirtioMmio, addr: i64, value: i64) -> i64
401func nx_virtio_dma_rd16(mem_buf: *u8, off: i64) -> i64
406func nx_virtio_dma_rd32(mem_buf: *u8, off: i64) -> i64
413func nx_virtio_dma_wr16(mem_buf: *u8, off: i64, val: i64) -> i64
418func nx_virtio_dma_wr32(mem_buf: *u8, off: i64, val: i64) -> i64
426func nx_virtio_dma_inrange(off: i64, w: i64, mem_size: i64) -> i64
432func nx_virtio_notify_dma(v: *NxVirtioMmio, mem_buf: *u8, mem_base: i64, mem_size: i64) -> i64
519func nx_virtio_status(v: *NxVirtioMmio) -> i64