code wiki / _hdl_build / nx_virtio_rng_emit.nx

nx_virtio_rng_emit.nx

buildroot/runtime/_hdl_build/nx_virtio_rng_emit.nx

3727 B25 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

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

nx_rv64_asm.nx nx_virtio_rng_emit.nx

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

main vr_puts rvasm_assemble_str rvasm_assemble sys_mmap ra_isws ra_encode sys_mmap ↻ ra_afterword ra_isws ↻ ra_word_is ra_isws ↻ ra_reg ra_skipsep ra_isws ↻ ra_num ra_isdig ra_imm ra_skipsep ↻ ra_ishex ra_isdig ↻ ra_hexval ra_isdig ↻ ra_u ra_imm12 ra_i ra_sh6 ra_r ra_past ra_s ra_label_target ra_skipsep ↻ ra_afterword ↻ ra_find_label ra_b ra_j ra_put vr_pn sys_openat_wr

structs

none

consts

9const K_MAGIC_65536: i64 = 65536

functions

11func 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
12func 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
14func main() -> i64