code wiki / _hdl_build / _nndev_gate.nx
_nndev_gate.nx
buildroot/runtime/_hdl_build/_nndev_gate.nx
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
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
structs
| none |
consts
| 22 | const N_EMIT: *u8 = "_offc/nx_drv_proto_emit.elf" |
| 23 | const N_SOV: *u8 = "_offc/nx_boot_run_sov.elf" |
| 24 | const N_NSPEC: *u8 = "knowledge/specs/drv_proto_nndp_virt.spec" |
| 25 | const N_VSPEC: *u8 = "knowledge/specs/drv_proto_blk_virt.spec" |
| 26 | const N_NBIN: *u8 = "runtime/_hdl_build/_drv_proto_nndp.bin" |
| 27 | const N_NGOLD: *u8 = "runtime/_hdl_build/_drv_proto_nndp.bin.gold" |
| 28 | const N_VBIN: *u8 = "runtime/_hdl_build/_drv_proto_blk.bin" |
functions
| 30 | func 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 } |
| 31 | func 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 } |
| 32 | func 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 } |
| 34 | func g_run(prog: *u8, a1: *u8, a2: *u8, a3: *u8, outpath: *u8) -> i64 called by 3: g_emit_rung_run_stepsg_tamper calls 7: sys_forksys_openat_wrsys_dup3sys_mmapsys_execvesys_exit+1 |
| 57 | func g_read(path: *u8, buf: *u8, cap: i64) -> i64 |
| 67 | func g_has(buf: *u8, n: i64, pat: *u8, pl: i64) -> i64 |
| 73 | func g_strlen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n } |
| 76 | func g_parse_steps(buf: *u8, n: i64) -> i64 |
| 96 | func g_emit_run(spec: *u8, bin: *u8, gold: *u8, serialpath: *u8, ok: *i64) -> i64 |
| 114 | func g_run_steps(bin: *u8, serialpath: *u8) -> i64 |
| 122 | func g_tamper(pos: i64, gold: *u8, gn: i64) -> i64 |
| 137 | func main() -> i64 |