code wiki / (root) / nx_hwprobe.nx

nx_hwprobe.nx

buildroot/runtime/nx_hwprobe.nx

11642 B322 linesdepth 2pulls 2 transitivereach 3 importersview sourcekind library
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_hwprobe.nx nx_voice_codec_tier.nx nx_voice_codec_v1_adapter.nx

imports: nx_syscalls.nx

imported by: nx_voice_codec_tier.nxnx_voice_codec_v1_adapter.nx

structs

86struct HwDevice
99struct HwSummary

consts

39const NX_HW_CLASS_UNKNOWN: i64 = 0
40const NX_HW_CLASS_CPU: i64 = 1
41const NX_HW_CLASS_MEM_REGION: i64 = 2
42const NX_HW_CLASS_PCI_BRIDGE: i64 = 3
43const NX_HW_CLASS_PCI_DEVICE: i64 = 4
44const NX_HW_CLASS_NIC: i64 = 5
45const NX_HW_CLASS_STORAGE: i64 = 6
46const NX_HW_CLASS_GPU: i64 = 7
47const NX_HW_CLASS_USB_HOST: i64 = 8
48const NX_HW_CLASS_USB_DEVICE: i64 = 9
49const NX_HW_CLASS_SERIAL: i64 = 10
50const NX_HW_CLASS_TIMER: i64 = 11
51const NX_HW_CLASS_RTC: i64 = 12
52const NX_HW_CLASS_INTR_CTRL: i64 = 13
53const NX_HW_CLASS_BATTERY: i64 = 14
54const NX_HW_CLASS_THERMAL: i64 = 15
55const NX_HW_CLASS_N: i64 = 16
58const NX_HW_CPU_UNKNOWN: i64 = 0
59const NX_HW_CPU_X86_64: i64 = 1
60const NX_HW_CPU_RV64: i64 = 2
61const NX_HW_CPU_ARM64: i64 = 3
62const NX_HW_CPU_X86_32: i64 = 4
63const NX_HW_CPU_ARM32: i64 = 5
64const NX_HW_CPU_RV32: i64 = 6
65const NX_HW_CPU_N: i64 = 7
68const NX_HW_TIER_UNKNOWN: i64 = 0
69const NX_HW_TIER_MCU: i64 = 1 // < 256 KB RAM, no MMU
70const NX_HW_TIER_SOVEREIGN: i64 = 2 // 256 KB .. 16 MB, MMU/MPU
71const NX_HW_TIER_FAMILY: i64 = 3 // 16 MB .. 1 GB, full Linux capability
72const NX_HW_TIER_WORKSTATION: i64 = 4 // 1 GB .. 64 GB, GPU optional
73const NX_HW_TIER_SERVER: i64 = 5 // 64 GB .. 1 TB, NUMA likely
74const NX_HW_TIER_HPC: i64 = 6 // > 1 TB, > 64 cores
75const NX_HW_TIER_N: i64 = 7
78const NX_HWPROBE_UNKNOWN: i64 = 0
79const NX_HWPROBE_PARTIAL: i64 = 1 // some devices enumerated but not all
80const NX_HWPROBE_FULL: i64 = 2 // every expected class enumerated
81const NX_HWPROBE_BLOCKED: i64 = 3 // kernel denied access (need root)
82const NX_HWPROBE_N: i64 = 4

functions

118func _path_cpuinfo(out: *u8) -> i64
called by 1: nx_hwprobe
124func _path_meminfo(out: *u8) -> i64
called by 1: nx_hwprobe
132func _slurp_file(path: *u8, buf: *u8, cap: i64) -> i64
152func _count_processors(buf: *u8, n: i64) -> i64
called by 1: nx_hwprobe
188func _scan_decimal(buf: *u8, start: i64, n: i64) -> i64
called by 1: _find_memtotal
220func _find_memtotal(buf: *u8, n: i64) -> i64
called by 1: nx_hwprobe calls 1: _scan_decimal
249func nx_hw_classify_tier(cpu_count: i64, ram_bytes: i64) -> i64
called by 1: nx_hwprobe
262func nx_hwprobe(out_summary: *HwSummary) -> i64
308func nx_hw_class_is_valid(c: i64) -> i64
313func nx_hw_tier_is_valid(t: i64) -> i64
318func nx_hwprobe_verdict_is_valid(v: i64) -> i64