code wiki / _hdl_build / nx_hwtest_census.nx

nx_hwtest_census.nx source

↩ module page · 71 lines · 10505 B

1// nx_hwtest_census.nx -- the HARDWARE-TEST-READINESS census: can we test NishiOS across LOTS of hardware (real) and on 2// HYPOTHETICAL Nishi hardware? Grades each capability HAVE / PARTIAL / MISSING, grounded on a REAL organ (have_file -- 3// liar-killed: a capability counts only if its organ actually exists on disk). The PARTIAL+MISSING rows ARE the roadmap. 4// Grounded by: the SOTA critic (nx_ecosystem_maturity_rollup: kernel->composed-bootable-image-UEFI, silicon->PnR- 5// bitstream-ULX3S-boot) + the researcher (our FPGA-BOOT SIMULATOR grounded ladder + FPGA/HDL/watchdog/CI corpus). 6// expect_exit: 0 Sovereign: nx_syscalls. NEVER-BRICK: read-only census, writes 0 hardware state. 7import "nx_syscalls.nx" 8import "nx_g_puts_lib.nx" 9 10func g_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 } 11func ck(name: *u8, c: i64) -> i64 { if c==1 { g_puts(" PASS " as *u8) } else { g_puts(" FAIL " as *u8) } g_puts(name); g_puts("\n" as *u8); return c } 12func have(path: *u8) -> i64 { let fd: i64=sys_openat_rd(path); if fd<0 { return 0 } sys_close(fd); return 1 } 13func hw_row(cap: *u8, organ: *u8, grade: i64, note: *u8) -> i64 { 14 var eff: i64=0; if have(organ)==1 { eff=grade } 15 if eff==2 { g_puts(" [HAVE ] ") } else { if eff==1 { g_puts(" [PARTIAL] ") } else { g_puts(" [MISSING] ") } } 16 g_puts(cap); g_puts(" -- "); g_puts(note); g_puts("\n" as *u8); return eff 17} 18 19func main() -> i64 { 20 g_puts("nx_hwtest_census (can we test NishiOS across LOTS of real hardware + on HYPOTHETICAL Nishi hardware?)\n" as *u8) 21 var have_n: i64=0; var part_n: i64=0; var miss_n: i64=0 22 var g: i64=0 23 24 g_puts(" ==== A. SIMULATION FOUNDATION (test with ZERO brick risk -- a simulator writes no hardware state) ====\n" as *u8) 25 g=hw_row("EMULATOR-RV64IM " as *u8, "runtime/_hdl_build/rv64im_min_sim.nx" as *u8, 2, "sovereign RV64IM CPU emulator (behavioral sim + predecoded fast interp + JIT + TIERED engine); boots a kernel image; models UART/CLINT/virtio" as *u8); if g==2 {have_n=have_n+1} else { if g==1 {part_n=part_n+1} else {miss_n=miss_n+1} } 26 g=hw_row("EXTERNAL-ORACLE " as *u8, "runtime/_hdl_build/nx_rv64_qemu_fuzz.nx" as *u8, 2, "DIFFERENTIAL validation vs the WORLD REFERENCE: 180/180 random programs (straight+branch+memory) BIT-IDENTICAL to qemu-system-riscv64; assembler byte-identical to riscv64-linux-gnu-as; caught+fixed a real lui sign-ext bug" as *u8); if g==2 {have_n=have_n+1} else { if g==1 {part_n=part_n+1} else {miss_n=miss_n+1} } 27 g=hw_row("HYPOTHETICAL-HW " as *u8, "runtime/_hdl_build/nx_fpga_lut.nx" as *u8, 2, "SIMULATED FPGA FABRIC (nx_fpga_census, 9-rung R4..R10a): LUT4 atom -> fabric-executes-bitstream -> full RV64I ALU/CMP/SHIFT on fabric -> R-type DECODE+EXECUTE on fabric == behavioral CPU (1280 checks) -> clocked sequential fabric (DFF+PC). Design a Nishi CPU, run the OS's execute stage on it, in sim, never-brick-free" as *u8); if g==2 {have_n=have_n+1} else { if g==1 {part_n=part_n+1} else {miss_n=miss_n+1} } 28 g=hw_row("NEVER-BRICK-GATE " as *u8, "runtime/_hdl_build/nx_neverbrick_genesis.nx" as *u8, 2, "MECHANICAL cardinal-26 gate: every hardware-write-axis node must carry a never-brick guarantee (read-only/reversible/fail-safe BY CONSTRUCTION) or the genesis gate goes VERDICT RED. The proof-not-promise that gates the real-hardware path" as *u8); if g==2 {have_n=have_n+1} else { if g==1 {part_n=part_n+1} else {miss_n=miss_n+1} } 29 30 g_puts(" ==== B. HARDWARE ABSTRACTION (boot the SAME image across many machines by DESCRIBING the hardware) ====\n" as *u8) 31 g=hw_row("DEVICE-DISCOVERY " as *u8, "runtime/_hdl_build/nx_hw_discover.nx" as *u8, 2, "parses the REAL device tree (FDT/DTB): 8 virtio-mmio + UART/PLIC/CLINT/memory; a data-described machine boots without per-board code (the portability primitive -- KernelCI/device-tree model)" as *u8); if g==2 {have_n=have_n+1} else { if g==1 {part_n=part_n+1} else {miss_n=miss_n+1} } 32 g=hw_row("DRIVER-AUTOGEN " as *u8, "runtime/_hdl_build/nx_driver_gen.nx" as *u8, 2, "AUTO-GENERATES a virtio driver per discovered DeviceID + real-drives virtio-rng end-to-end (handshake->virtqueue->entropy). New hardware -> generated driver, no hand-porting" as *u8); if g==2 {have_n=have_n+1} else { if g==1 {part_n=part_n+1} else {miss_n=miss_n+1} } 33 g=hw_row("EXEC-LOADER " as *u8, "runtime/_hdl_build/nx_nxe_loader.nx" as *u8, 2, "native NXE loader: SHA-256 integrity + EXEC-cap + never-brick tag VERIFIED before a byte runs -> mmap+execute. The verify-before-execute boot primitive" as *u8); if g==2 {have_n=have_n+1} else { if g==1 {part_n=part_n+1} else {miss_n=miss_n+1} } 34 g=hw_row("BOOTABLE-IMAGE " as *u8, "runtime/_hdl_build/nx_spore_boot.nx" as *u8, 1, "the bootable spore boots POST->mount+journal-replay->verify+exec /sbin/init.nxe->userland IN THE EMULATOR/file-model. GAP: a COMPOSED image (kernel+init+fs) that a real firmware hands off to = the critic's kernel next-rung 'composed-bootable-image-UEFI'" as *u8); if g==2 {have_n=have_n+1} else { if g==1 {part_n=part_n+1} else {miss_n=miss_n+1} } 35 36 g_puts(" ==== C. REAL-HARDWARE PATH (guarded never-brick; each needs a physical device OR a software boot rung) ====\n" as *u8) 37 g=hw_row("UEFI-BOOT " as *u8, "runtime/_hdl_build/nx_gop_efi.nx" as *u8, 1, "UEFI GOP (Graphics Output Protocol) framebuffer present. GAP: a full UEFI application boot path (PE/COFF stub + ExitBootServices + memory-map handoff) so a real x86/ARM UEFI machine loads the NishiOS image. This is the bridge to 'lots of real PCs'" as *u8); if g==2 {have_n=have_n+1} else { if g==1 {part_n=part_n+1} else {miss_n=miss_n+1} } 38 g=hw_row("MMU-PAGING-HW " as *u8, "runtime/_hdl_build/nx_mmu_hw.nx" as *u8, 1, "faithful x86-64 4-level page-table walk MODEL (PML4/PDPT/PD/PT+CR3+TLB, 5/5). GAP: real ring0 CR3 load on silicon = the guarded never-brick step (modeled+activation-refused BY CONSTRUCTION)" as *u8); if g==2 {have_n=have_n+1} else { if g==1 {part_n=part_n+1} else {miss_n=miss_n+1} } 39 g=hw_row("GPU-BAR-HW " as *u8, "runtime/_hdl_build/nx_gpu_ring.nx" as *u8, 1, "BAR/MMIO command-ring submission MODEL (ring+doorbell+fence, 5/5; fw-write opcode HALTS the device). GAP: real PCIe BAR submission on a live GPU = the guarded never-brick step" as *u8); if g==2 {have_n=have_n+1} else { if g==1 {part_n=part_n+1} else {miss_n=miss_n+1} } 40 g=hw_row("REAL-SILICON-POST " as *u8, "runtime/_hdl_build/nx_does_not_exist_real_post.nx" as *u8, 2, "boot NishiOS from real firmware/POST on a physical machine (BIOS/UEFI). ABSENT: needs a physical target + the UEFI-boot rung; the operator's guarded move, gated by nx_neverbrick_genesis" as *u8); if g==2 {have_n=have_n+1} else { if g==1 {part_n=part_n+1} else {miss_n=miss_n+1} } 41 g=hw_row("FPGA-PHYSICAL " as *u8, "runtime/_hdl_build/nx_does_not_exist_ulx3s.nx" as *u8, 2, "place-and-route (nextpnr) -> bitstream (prjtrellis) -> JTAG load (OpenOCD) -> boot the sovereign Nishi CPU on a real ULX3S ECP5 board = the critic's silicon next-rung. ABSENT: needs the ~$175 board. NEVER-BRICK-FREE by construction (reflash the bitstream, no persistent brick)" as *u8); if g==2 {have_n=have_n+1} else { if g==1 {part_n=part_n+1} else {miss_n=miss_n+1} } 42 g=hw_row("HW-TEST-MATRIX-CI " as *u8, "runtime/_hdl_build/nx_does_not_exist_hwmatrix.nx" as *u8, 2, "an automated multi-target test FARM: boot+run the conformance suite on N hardware/emulator targets, collect pass/fail (the KernelCI/LAVA model). ABSENT: the orchestration organ that turns 1 target into a fleet" as *u8); if g==2 {have_n=have_n+1} else { if g==1 {part_n=part_n+1} else {miss_n=miss_n+1} } 43 44 // teeth: a fake organ MUST read MISSING (proves have_file grounding is real, not a rubber stamp) 45 let tg: i64 = hw_row("NEG-CONTROL " as *u8, "runtime/_hdl_build/nx_zzz_absent.nx" as *u8, 2, "(intentionally absent -- must read MISSING)" as *u8) 46 47 let total: i64 = have_n+part_n+miss_n 48 g_puts(" ==== TALLY: HAVE="); g_pn(have_n); g_puts(" PARTIAL="); g_pn(part_n); g_puts(" MISSING="); g_pn(miss_n); g_puts(" of "); g_pn(total); g_puts(" hardware-test capabilities ====\n" as *u8) 49 g_puts(" >> READ: the SIMULATION FOUNDATION is FULL -- we can test NishiOS on modelled + hypothetical hardware TODAY,\n" as *u8) 50 g_puts(" never-brick-free, cross-checked BIT-IDENTICAL to the world reference (QEMU). HARDWARE ABSTRACTION is\n" as *u8) 51 g_puts(" mostly HAVE (device-tree discovery + driver-autogen + verified loader). The REAL-HARDWARE PATH is the\n" as *u8) 52 g_puts(" frontier: 2 SOFTWARE rungs unblock it WITHOUT a purchase (UEFI-boot app, HW-test-matrix CI), and 2\n" as *u8) 53 g_puts(" PHYSICAL rungs need a device (a real UEFI PC; a ~$175 ULX3S FPGA) -- both guarded never-brick.\n" as *u8) 54 55 var pass: i64=0; var t: i64=0 56 var t1: i64=0; if have_n>=6 { t1=1 } 57 pass=pass+ck("T1: >=6 hardware-test capabilities HAVE a real grounding organ (the test foundation is substantially built)" as *u8, t1); t=t+1 58 var t2: i64=0; if miss_n>=1 { if part_n>=1 { t2=1 } } 59 pass=pass+ck("T2 (honest): real gaps remain (>=1 PARTIAL + >=1 MISSING) -- we do NOT claim hardware testing is complete" as *u8, t2); t=t+1 60 var t3: i64=0; if tg==0 { t3=1 } 61 pass=pass+ck("T3 (teeth): the neg-control absent organ reads MISSING -- grounding is real, not a rubber stamp" as *u8, t3); t=t+1 62 63 var okall: i64=0; if pass==t { okall=1 } 64 g_puts("---- nx_hwtest_census: passed "); g_pn(pass); g_puts(" / "); g_pn(t); g_puts(" ----\n" as *u8) 65 if okall==1 { 66 let logf: i64=sys_openat_append("knowledge/status/hwtest_census.log" as *u8, 420) 67 if logf>=0 { let z: i64=sys_write(logf,"HWTESTCENSUS GREEN: hardware-test-readiness measured -- SIMULATION FOUNDATION full (emulator QEMU-validated + hypothetical-HW FPGA sim + never-brick gate); HW-ABSTRACTION mostly HAVE; REAL-HW PATH frontier = 2 software rungs (UEFI-boot, HW-matrix-CI) + 2 physical (UEFI PC, ULX3S FPGA), all guarded never-brick\n" as *u8,340); sys_close(logf) } 68 g_puts("verdict=GREEN (measured hardware-test-readiness: sim foundation full + world-reference-validated; the real-hardware frontier mapped, every rung guarded never-brick)\n" as *u8); sys_exit(0); return 0 69 } 70 g_puts("verdict=RED\n" as *u8); sys_exit(1); return 1 71}