code wiki / _hdl_build / nx_emu_testbed.nx

nx_emu_testbed.nx

buildroot/runtime/_hdl_build/nx_emu_testbed.nx

11309 B244 linesdepth 2pulls 2 transitivereach 1 importersview sourcekind tooltopic emu
docsdependenciesstructsconstsfunctions

about

nx_emu_testbed.nx -- THE EMU TEST-MATRIX organ: which common laptop configs can the Nishi emu boot VIRTUALLY on THIS machine, right now, within its resources. module: nishi-core.genealogy.emu_testbed capability: CORE_COMPUTE (the safe S-class test bench: boot all-the-way-up + flash-a-BIOS in a disposable VM, never the host -- the never-brick law made concrete; see CLAUDE.md #26) THE MODEL (operator 2026-06-16): the emu exists so we can test the brickable boot chain (CMOS->POST->BIOS/UEFI flash->bootloader->NishiOS->spore germination) on models of the most common laptops -- VIRTUALLY, sized to whatever host the spore lands on. This organ: * PROBES the real host LIVE: MemAvailable (/proc/meminfo) + core count (/proc/cpuinfo), via sys_read_file (a read-until-EOF loop, so /proc's size-0 files read fine); * reads the laptop profiles (DATA) and computes, per profile, whether it FITS virtually here (guest RAM <= EMU_RAM_BUDGET_PCT% of host avail, vCPU <= host cores, arch emulatable); * enforces NEVER-BRICK: every profile's brickable test must run in the emu sandbox (test_mode=emu); a host-mode profile is a violation -> RED. The FIT list = the spore's build/test matrix on this machine. DYNAMIC/LIVING: run it on an 8GB box and fewer fit; on a 128GB workstation, all do. Sovereign: imports only nx_syscalls. license_tier: ORIGINAL

dependencies 1 imports · 1 importers

nx_syscalls.nx nx_emu_testbed.nx nx_emu_testbed_gate.nx

imports: nx_syscalls.nx

imported by: nx_emu_testbed_gate.nx

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

main tb_puts sys_write sys_mmap tb_analyze sys_mmap ↻ sys_read_file sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_close tb_find_int_after tb_strlen tb_match_at tb_count_line_prefix tb_match_at ↻ tb_field_dup sys_mmap ↻ tb_atoi tb_arch_covered tb_streq tb_streq ↻ tb_putn sys_write ↻ sys_mmap ↻ sys_exit tb_print_profiles sys_mmap ↻ sys_read_file ↻ tb_field_dup ↻ tb_atoi ↻ tb_arch_covered ↻ tb_puts ↻ tb_streq ↻ tb_putn ↻

structs

none

consts

22const LP_MAGIC_1024: i64 = 1024
24const LP_FILE: *u8 = "knowledge/registry/laptop_profiles.tsv"
25const TB_MEMINFO: *u8 = "/proc/meminfo"
26const TB_CPUINFO: *u8 = "/proc/cpuinfo"
27const EMU_RAM_BUDGET_PCT: i64 = 80 // a guest may use at most 80% of the host's available RAM

functions

29func tb_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 2: tb_print_profilesmain calls 1: sys_write
30func tb_putn(v: i64) -> i64
40func tb_strlen(s: *u8) -> i64 { var i: i64 = 0; while s[i] != 0 as u8 { i = i + 1 } return i }
called by 1: tb_find_int_after
41func tb_streq(a: *u8, b: *u8) -> i64
47func tb_atoi(s: *u8) -> i64
57func tb_field_dup(b: *u8, ls: i64, le: i64, f: i64) -> *u8
75func tb_match_at(buf: *u8, pos: i64, n: i64, key: *u8) -> i64
86func tb_find_int_after(buf: *u8, n: i64, key: *u8) -> i64
called by 1: tb_analyze calls 2: tb_strlentb_match_at
112func tb_count_line_prefix(buf: *u8, n: i64, key: *u8) -> i64
called by 1: tb_analyze calls 1: tb_match_at
122func tb_arch_covered(arch: *u8) -> i64
132func tb_analyze(pfile: *u8, outs: *i64) -> i64
183func tb_print_profiles(pfile: *u8, budget_mb: i64, cores: i64) -> i64
221func main() -> i64