code wiki / _hdl_build / nx_hwmap.nx
nx_hwmap.nx
buildroot/runtime/_hdl_build/nx_hwmap.nx
about
nx_hwmap.nx -- X-DRV-W0 HWMAP (SOVEREIGN-DRIVER-WORLD law, operator 2026-06-12).
The spore's FIRST act on any iron: enumerate the hardware BEFORE binding drivers.
The team's hardware-map capability -- "the spore knows what hardware exists".
Reads /sys/bus/pci/devices via sys_getdents64 (the real kernel enumeration, NOT a
tutor-asserted list); for each device dir READS vendor/device/class straight from
sysfs; AUTHORS knowledge/registry/hwmap.tsv itself via sys_openat_wr; emits a
HWMAPGATE evidence line to stdout AND appends it to knowledge/status/hwmap.log
(the evidence nx_reconcile grades from -- the organ does NOT flip its own row).
SELF-VALIDATING (no-cheat): GREEN requires devices>=1 (real iron found) AND
with_vendor==devices (every enumerated device had a 0x-prefixed vendor actually
read from sysfs -- a fabricated map can't satisfy this) AND control_neg<0 (a
deliberately bogus device path MUST fail to open -- proves it is hitting the real
filesystem, not synthesizing). A driver SPEC built atop this map is X-DRV-W1.
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
| 18 | const HW_MAGIC_4096: i64 = 4096 |
| 19 | const HW_MAGIC_1048640: i64 = 1048640 |
| 20 | const HW_MAGIC_2000000: i64 = 2000000 |
| 21 | const HW_MAGIC_1048576: i64 = 1048576 |
| 23 | const HW_DIR: *u8 = "/sys/bus/pci/devices" |
| 24 | const HW_OUT: *u8 = "knowledge/registry/hwmap.tsv" |
| 25 | const HW_LOG: *u8 = "knowledge/status/hwmap.log" |
functions
| 27 | func hw_msg(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } calls 1: sys_write |
| 30 | func hw_cat(dst: *u8, off: i64, s: *u8) -> i64 { var i: i64 = 0; while s[i] != (0 as u8) { dst[off+i] = s[i]; i = i + 1 } return off + i } |
| 33 | func hw_catn(dst: *u8, off: i64, v: i64) -> i64 |
| 47 | func hw_path(out: *u8, dir: *u8, name: *u8, suffix: *u8) -> i64 |
| 61 | func hw_read_trim(path: *u8, buf: *u8, cap: i64) -> i64 |
| 85 | func hw_row(root: *u8, ob: *u8, o0: i64, name: *u8, pathbuf: *u8, valbuf: *u8, vcnt: *i64) -> i64 |
| 106 | func hw_emit(logpath: *u8, root: *u8, out: *u8, devices: i64, with_vendor: i64, neg: i64, epoch: i64, ok: i64) -> i64 |
| 132 | func main(argc: i64, argv: *i64) -> i64 |