code wiki / _hdl_build / nx_hwmap.nx

nx_hwmap.nx

buildroot/runtime/_hdl_build/nx_hwmap.nx

8335 B196 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_hwmap.nx

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

main sys_now_realtime_sec sys_mmap sys_clock_gettime_real sys_openat_rd hw_emit sys_mmap ↻ hw_cat hw_catn sys_mmap ↻ sys_write sys_openat_append sys_close sys_mmap ↻ hw_cat ↻ sys_getdents64 dirent_reclen dirent_name hw_row hw_cat ↻ hw_path hw_read_trim sys_openat_rd ↻ sys_read sys_close ↻ sys_close ↻ sys_openat_wr sys_write ↻ hw_path ↻

structs

none

consts

18const HW_MAGIC_4096: i64 = 4096
19const HW_MAGIC_1048640: i64 = 1048640
20const HW_MAGIC_2000000: i64 = 2000000
21const HW_MAGIC_1048576: i64 = 1048576
23const HW_DIR: *u8 = "/sys/bus/pci/devices"
24const HW_OUT: *u8 = "knowledge/registry/hwmap.tsv"
25const HW_LOG: *u8 = "knowledge/status/hwmap.log"

functions

27func 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
30func 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 }
called by 3: hw_rowhw_emitmain
33func hw_catn(dst: *u8, off: i64, v: i64) -> i64
called by 1: hw_emit calls 1: sys_mmap
47func hw_path(out: *u8, dir: *u8, name: *u8, suffix: *u8) -> i64
called by 2: hw_rowmain
61func hw_read_trim(path: *u8, buf: *u8, cap: i64) -> i64
85func hw_row(root: *u8, ob: *u8, o0: i64, name: *u8, pathbuf: *u8, valbuf: *u8, vcnt: *i64) -> i64
called by 1: main calls 3: hw_cathw_pathhw_read_trim
106func hw_emit(logpath: *u8, root: *u8, out: *u8, devices: i64, with_vendor: i64, neg: i64, epoch: i64, ok: i64) -> i64
132func main(argc: i64, argv: *i64) -> i64