code wiki / _hdl_build / _nndev_gate.nx

_nndev_gate.nx

buildroot/runtime/_hdl_build/_nndev_gate.nx

9741 B178 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind gate/proof
docsdependenciesstructsconstsfunctions

about

_nndev_gate.nx -- gate for the SOVEREIGN-DEVICE-PROTOCOL exceed (Nishi-native device, NNDP). NO mocks. (1) NATIVE WORKS -- emits the native driver via the SAME nx_drv_proto_emit (the native device is just another op-list spec -> the emitter is protocol-general, not virtio-specific), runs it on the SOVEREIGN rv64 emu against the real NNDP device model, and asserts the serial CONTAINS the golden "NNDENACMDOKDAT" + a clean halt. "DAT" appears ONLY if the device DMA-read the data word the driver wrote (via the inline command descriptor's addr binding) and the driver read RESULT back == that word -- a real data round-trip, not faked. (2) MEASURED EXCEED (the no-wave head-to-head) -- runs the native driver AND the virtio-blk driver for the SAME block-I/O round-trip on the SAME emu and compares emu STEPS (instructions to complete one I/O). Asserts native_steps < virtio_steps -- the lean native protocol (self- describing identity + single-step enable + ONE inline descriptor + ONE doorbell, direct completion) genuinely beats legacy virtio-MMIO (4-stage handshake + split virtqueue + two kicks + used-ring walk). Apples-to-apples: same substrate, same workload. (3) TAMPER x2 on the native image -- bump the device-base lui imm (byte 7) and the magic-expected const (byte 15); each must drop the golden (proves the driver really talks to the device + the verify logic is real, not a rubber stamp). Evidence -> knowledge/status/nndev.log (NNDEVGATE row). Sovereign. license_tier: ORIGINAL

dependencies 1 imports · 0 importers

nx_syscalls.nx _nndev_gate.nx

imports: nx_syscalls.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main g_p sys_write sys_openat_append sys_mmap g_emit_run g_run sys_fork sys_openat_wr sys_dup3 sys_mmap ↻ sys_execve sys_exit sys_wait4 sys_mmap ↻ g_read sys_openat_rd sys_read sys_close g_has g_parse_steps g_read ↻ g_tamper sys_mmap ↻ g_read ↻ sys_openat_wr ↻ sys_write ↻ sys_close ↻ g_run ↻ g_has ↻ g_fn sys_mmap ↻ sys_write ↻ g_fp sys_write ↻ sys_now_realtime_sec sys_mmap ↻ sys_clock_gettime_real sys_close ↻ sys_exit ↻

structs

none

consts

22const N_EMIT: *u8 = "_offc/nx_drv_proto_emit.elf"
23const N_SOV: *u8 = "_offc/nx_boot_run_sov.elf"
24const N_NSPEC: *u8 = "knowledge/specs/drv_proto_nndp_virt.spec"
25const N_VSPEC: *u8 = "knowledge/specs/drv_proto_blk_virt.spec"
26const N_NBIN: *u8 = "runtime/_hdl_build/_drv_proto_nndp.bin"
27const N_NGOLD: *u8 = "runtime/_hdl_build/_drv_proto_nndp.bin.gold"
28const N_VBIN: *u8 = "runtime/_hdl_build/_drv_proto_blk.bin"

functions

30func g_p(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 calls 1: sys_write
31func g_fp(fd: i64, s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(fd,s,n); return 0 }
called by 1: main calls 1: sys_write
32func g_fn(fd: i64, v: i64) -> i64 { let bb: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0-m}; let t: *u8=sys_mmap(28); var k: i64=0; if m==0{t[0]=48;k=1}; while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1}; var i: i64=0; while i<k{bb[i]=t[k-1-i];i=i+1}; sys_write(fd,bb,k); return 0 }
called by 1: main calls 2: sys_mmapsys_write
34func g_run(prog: *u8, a1: *u8, a2: *u8, a3: *u8, outpath: *u8) -> i64
57func g_read(path: *u8, buf: *u8, cap: i64) -> i64
67func g_has(buf: *u8, n: i64, pat: *u8, pl: i64) -> i64
called by 2: g_emit_rung_tamper
73func g_strlen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
76func g_parse_steps(buf: *u8, n: i64) -> i64
96func g_emit_run(spec: *u8, bin: *u8, gold: *u8, serialpath: *u8, ok: *i64) -> i64
114func g_run_steps(bin: *u8, serialpath: *u8) -> i64
122func g_tamper(pos: i64, gold: *u8, gn: i64) -> i64
137func main() -> i64