nx_hwprobe.nx
buildroot/runtime/nx_hwprobe.nx
about
nx_hwprobe.nx -- substrate-native hardware enumeration.
"Can NishiLang map the electronics it's on as it's installing, so it
can run on any device?" -- YES. This file is the substrate-side
surface. On Linux today: enumerates via /proc/cpuinfo +
/proc/meminfo + /sys/bus/pci/devices/* (which Linux exposes as text
files). On NishiOS tomorrow: the SAME functions, but the data
comes from direct hardware reads (CPUID, E820 memory map, PCI
configuration space at 0xCF8/0xCFC on x86 or ECAM MMIO on ARM/RV,
ACPI RSDP walk).
Cardinal-aligned design:
- feedback-self-aware-substrate-user-improvable: nx_self_audit
consumes nx_hwprobe_summary() to know what the substrate found
and what it still needs drivers for.
- feedback-scale-agnostic-substrate: same primitives serve a
T0 MCU (1 CPU, 1 region) through T5 HPC (1024 cores, NUMA).
Output tier classified into NX_HW_TIER_*.
- feedback-stop-and-build-upward: every driver later builds on
the device-id table produced here.
Sealed device-class enum. Used by nx_hwprobe_iter to tag each
discovered device. Drivers register against these IDs.
genealogy_id: linux_udev_2003 + acpi_rsdp_spec + pci_3_0_spec +
cpuid_intel_dev_guide + risc_v_sbi_2_0 + dtb_v17
lineage_id: substrate_hardware_self_map_q10
dependencies 1 imports · 2 importers
imports: nx_syscalls.nx
imported by: nx_voice_codec_tier.nxnx_voice_codec_v1_adapter.nx
structs
| 86 | struct HwDevice |
| 99 | struct HwSummary |
consts
| 39 | const NX_HW_CLASS_UNKNOWN: i64 = 0 |
| 40 | const NX_HW_CLASS_CPU: i64 = 1 |
| 41 | const NX_HW_CLASS_MEM_REGION: i64 = 2 |
| 42 | const NX_HW_CLASS_PCI_BRIDGE: i64 = 3 |
| 43 | const NX_HW_CLASS_PCI_DEVICE: i64 = 4 |
| 44 | const NX_HW_CLASS_NIC: i64 = 5 |
| 45 | const NX_HW_CLASS_STORAGE: i64 = 6 |
| 46 | const NX_HW_CLASS_GPU: i64 = 7 |
| 47 | const NX_HW_CLASS_USB_HOST: i64 = 8 |
| 48 | const NX_HW_CLASS_USB_DEVICE: i64 = 9 |
| 49 | const NX_HW_CLASS_SERIAL: i64 = 10 |
| 50 | const NX_HW_CLASS_TIMER: i64 = 11 |
| 51 | const NX_HW_CLASS_RTC: i64 = 12 |
| 52 | const NX_HW_CLASS_INTR_CTRL: i64 = 13 |
| 53 | const NX_HW_CLASS_BATTERY: i64 = 14 |
| 54 | const NX_HW_CLASS_THERMAL: i64 = 15 |
| 55 | const NX_HW_CLASS_N: i64 = 16 |
| 58 | const NX_HW_CPU_UNKNOWN: i64 = 0 |
| 59 | const NX_HW_CPU_X86_64: i64 = 1 |
| 60 | const NX_HW_CPU_RV64: i64 = 2 |
| 61 | const NX_HW_CPU_ARM64: i64 = 3 |
| 62 | const NX_HW_CPU_X86_32: i64 = 4 |
| 63 | const NX_HW_CPU_ARM32: i64 = 5 |
| 64 | const NX_HW_CPU_RV32: i64 = 6 |
| 65 | const NX_HW_CPU_N: i64 = 7 |
| 68 | const NX_HW_TIER_UNKNOWN: i64 = 0 |
| 69 | const NX_HW_TIER_MCU: i64 = 1 // < 256 KB RAM, no MMU |
| 70 | const NX_HW_TIER_SOVEREIGN: i64 = 2 // 256 KB .. 16 MB, MMU/MPU |
| 71 | const NX_HW_TIER_FAMILY: i64 = 3 // 16 MB .. 1 GB, full Linux capability |
| 72 | const NX_HW_TIER_WORKSTATION: i64 = 4 // 1 GB .. 64 GB, GPU optional |
| 73 | const NX_HW_TIER_SERVER: i64 = 5 // 64 GB .. 1 TB, NUMA likely |
| 74 | const NX_HW_TIER_HPC: i64 = 6 // > 1 TB, > 64 cores |
| 75 | const NX_HW_TIER_N: i64 = 7 |
| 78 | const NX_HWPROBE_UNKNOWN: i64 = 0 |
| 79 | const NX_HWPROBE_PARTIAL: i64 = 1 // some devices enumerated but not all |
| 80 | const NX_HWPROBE_FULL: i64 = 2 // every expected class enumerated |
| 81 | const NX_HWPROBE_BLOCKED: i64 = 3 // kernel denied access (need root) |
| 82 | const NX_HWPROBE_N: i64 = 4 |
functions
| 118 | func _path_cpuinfo(out: *u8) -> i64 called by 1: nx_hwprobe |
| 124 | func _path_meminfo(out: *u8) -> i64 called by 1: nx_hwprobe |
| 132 | func _slurp_file(path: *u8, buf: *u8, cap: i64) -> i64 |
| 152 | func _count_processors(buf: *u8, n: i64) -> i64 called by 1: nx_hwprobe |
| 188 | func _scan_decimal(buf: *u8, start: i64, n: i64) -> i64 called by 1: _find_memtotal |
| 220 | func _find_memtotal(buf: *u8, n: i64) -> i64 |
| 249 | func nx_hw_classify_tier(cpu_count: i64, ram_bytes: i64) -> i64 called by 1: nx_hwprobe |
| 262 | func nx_hwprobe(out_summary: *HwSummary) -> i64 called by 1: nx_voice_codec_init calls 7: sys_mmap_path_cpuinfo_slurp_file_count_processors_path_meminfo_find_memtotal+1 |
| 308 | func nx_hw_class_is_valid(c: i64) -> i64 |
| 313 | func nx_hw_tier_is_valid(t: i64) -> i64 |
| 318 | func nx_hwprobe_verdict_is_valid(v: i64) -> i64 |