code wiki / _hdl_build / nx_emu_testbed.nx
nx_emu_testbed.nx
buildroot/runtime/_hdl_build/nx_emu_testbed.nx
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
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
structs
| none |
consts
| 22 | const LP_MAGIC_1024: i64 = 1024 |
| 24 | const LP_FILE: *u8 = "knowledge/registry/laptop_profiles.tsv" |
| 25 | const TB_MEMINFO: *u8 = "/proc/meminfo" |
| 26 | const TB_CPUINFO: *u8 = "/proc/cpuinfo" |
| 27 | const EMU_RAM_BUDGET_PCT: i64 = 80 // a guest may use at most 80% of the host's available RAM |
functions
| 29 | func 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 } |
| 30 | func tb_putn(v: i64) -> i64 |
| 40 | func 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 |
| 41 | func tb_streq(a: *u8, b: *u8) -> i64 |
| 47 | func tb_atoi(s: *u8) -> i64 |
| 57 | func tb_field_dup(b: *u8, ls: i64, le: i64, f: i64) -> *u8 |
| 75 | func tb_match_at(buf: *u8, pos: i64, n: i64, key: *u8) -> i64 |
| 86 | func tb_find_int_after(buf: *u8, n: i64, key: *u8) -> i64 |
| 112 | func tb_count_line_prefix(buf: *u8, n: i64, key: *u8) -> i64 |
| 122 | func tb_arch_covered(arch: *u8) -> i64 |
| 132 | func tb_analyze(pfile: *u8, outs: *i64) -> i64 called by 2: mainmain calls 8: sys_mmapsys_read_filetb_find_int_aftertb_count_line_prefixtb_field_duptb_atoi+2 |
| 183 | func tb_print_profiles(pfile: *u8, budget_mb: i64, cores: i64) -> i64 |
| 221 | func main() -> i64 |