code wiki / _hdl_build / nx_nishios_kernel_gate.nx

nx_nishios_kernel_gate.nx

buildroot/runtime/_hdl_build/nx_nishios_kernel_gate.nx

10199 B215 linesdepth 6pulls 17 transitivereach 0 importersview sourcekind gate/prooftopic nishios
docsdependenciesstructsconstsfunctions

about

nx_nishios_kernel_gate.nx -- the TRANSCRIPT gate for the composed NishiOS kernel boot. WHY THIS EXISTS (a measured instrument defect, not a hypothetical): the BOOTSOV runner decides its verdict from `halted && halt_code==0` ALONE -- it never reads the serial transcript. Proven 2026-07-31: a kernel image deliberately tampered so the Sv39 walk faults printed "...TICK TX" instead of "...PAGE USER OK" and BOOTSOV still returned verdict=GREEN exit=0. A runner that returns GREEN on a broken boot is not a check. This gate reads what the kernel actually SAID and compares it to the table-computed golden transcript. TEETH (each independently able to fail; the two NEG teeth are the non-vacuity proof): T1 image present and not the 72-byte banner it replaced T2 boots to a clean finisher halt T3 transcript is EXACTLY the golden transcript T4 every phase marker present (banner/trap/sched/timer/paging/user) T5 NEG-comparator: the comparator must REJECT a mutated golden (proves it can say no) T6 NEG-subject: a corrupted kernel image must NOT reproduce the golden transcript T7 step count is far above the 17-step banner baseline (the boot does real work) Sovereign: the emulator IS the runtime. license_tier: ORIGINAL Boot-and-capture comes from the SHARED primitive, not a private copy: this gate, the census and nx_kernel_adoption must agree byte-for-byte about what "booting the image" means, and three hand-maintained copies is three chances for them to drift apart silently.

dependencies 1 imports · 0 importers

nx_bootcap.nx nx_nishios_kernel_gate.nx

imports: nx_bootcap.nx

imported by: nobody (leaf or entry point)

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

main nkg_p sys_read_file sys_openat_rd sys_lseek sys_mmap sys_read sys_close nkg_tooth nkg_p ↻ nkg_run bootcap_run nx_rv64im_rf_init nx_rv64im_csr_init nx_clint_init nx_uart_init nx_virtio_init nx_virtio_reset_storage nx_virtio_init_net nx_virtio_reset_storage ↻ nx_nvme_init nx_nvme_reset_storage nx_nndev_init nx_nndev_reset nx_mmu_init nx_mmu_reset nx_rv64im_sim_init nx_rv64im_sim_attach_virti nx_rv64im_sim_attach_virti nx_rv64im_sim_attach_nvme nx_rv64im_sim_attach_nndev nx_rv64im_sim_attach_mmu nx_rv64im_sim_run nx_rv64im_sim_step nx_clint_tick nx_clint_update_mtip nx_rv64im_csr_tick_mcycle nx_clint_mtip_get nx_rv64im_csr_read nx_csr_addr_to_slot

structs

none

consts

24const NKG_BIN: *u8 = "runtime/_hdl_build/_boot_nishi_virt.bin"
25const NKG_GOLD: *u8 = "runtime/_hdl_build/_boot_nishi_virt.bin.gold"
26const NKG_BIN_ALT: *u8 = "_boot_nishi_virt.bin"
27const NKG_GOLD_ALT: *u8 = "runtime/_hdl_build/_boot_nishi_virt.bin.gold"
28const NKG_LOG: *u8 = "knowledge/status/boot_stub.log"
30const NKG_MEM_BASE: i64 = 0x80000000
31const NKG_MEM_SIZE: i64 = 65536
32const NKG_TX_CAP: i64 = 4096
33const NKG_MAX_STEPS: i64 = 100000
34const NKG_BANNER_BYTES: i64 = 72
35const NKG_BANNER_STEPS: i64 = 17

functions

37func nkg_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 2: nkg_toothmain
38func nkg_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
39func nkg_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
44func nkg_run(img: *u8, ilen: i64, tx_buf: *u8, res: *i64) -> i64
called by 1: main calls 1: bootcap_run
49func nkg_eq(a: *u8, an: i64, b: *u8, bn: i64) -> i64
called by 1: main
56func nkg_has(hay: *u8, hn: i64, needle: *u8) -> i64
called by 1: main
72func nkg_tooth(name: *u8, ok: i64, pass: *i64, fail: *i64) -> i64
called by 1: main calls 1: nkg_p
81func main(argc: i64, argv: *i64) -> i64