code wiki / _hdl_build / nx_virtio_rng_emit.nx
nx_virtio_rng_emit.nx
buildroot/runtime/_hdl_build/nx_virtio_rng_emit.nx
about
nx_virtio_rng_emit.nx -- emit a COMPLETE legacy virtio-mmio virtio-rng DRIVER as a RV64 flat binary (via
nx_rv64_asm). The driver: (1) SCANS the 8 virtio-mmio slots for DeviceID==4 (rng); (2) does the legacy handshake
reset->ACK->DRIVER; (3) sets GuestPageSize, a virtqueue (desc/avail/used at 0x81000000), QueuePFN; (4) DRIVER_OK;
(5) posts a WRITE descriptor (16 bytes at 0x81002000), rings QueueNotify; (6) polls the used ring; (7) prints the
entropy the DEVICE wrote, as hex, over the UART; (8) halts PASS. Booted in qemu-system-riscv64 with a real
-device virtio-rng-device (force-legacy), the printed bytes are REAL entropy from the emulated device -- the
generated driver drove an ACTUAL device end-to-end. Writes knowledge/hw/virtio_rng.bin. expect_exit:0 ORIGINAL
dependencies 1 imports · 0 importers
imports: nx_rv64_asm.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 9 | const K_MAGIC_65536: i64 = 65536 |
functions
| 11 | func vr_puts(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } called by 1: main |
| 12 | func vr_pn(v: i64) -> i64 { let b: *u8=sys_mmap(28); var x: i64=v; if x==0{b[0]=48;sys_write(1,b,1);return 0} var d: i64=0; var y: i64=x; while y>0{d=d+1;y=y/10} var i: i64=d-1; y=x; while i>=0{b[i]=(48+(y%10)) as u8;y=y/10;i=i-1} sys_write(1,b,d); return 0 } called by 1: main |
| 14 | func main() -> i64 |