code wiki / (root) / nx_hal.nx

nx_hal.nx

buildroot/runtime/nx_hal.nx

25006 B554 linesdepth 2pulls 2 transitivereach 58 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_hal.nx -- substrate Hardware Abstraction Layer. Cardinal 2026-05-21 ("bits up eliminate and for the rest we want to be hardware agnostic as in the future nishi silicon will run all of this"): every substrate primitive above this layer expresses hardware-level operations in HAL terms, NOT Linux-syscall terms. The HAL is the substrate-defined contract that ANY backing implementation (Linux today, bare-metal Nishi kernel tomorrow, future Nishi silicon eventually) must provide. Substrate's bottom-up sovereignty story: - Top of stack: Elder AI services + UI -- can run on whatever OS the substrate currently runs on (Win-native + bash-launched today; future substrate-hosted on a NishiLang container) - Middle: substrate primitives (HAL clients) -- hardware-agnostic; compile + run unchanged on any HAL implementation - Bottom: HAL implementation (per-target shim) -- the thin adapter that turns hardware-level HAL ops into actual machine behavior. Today: Linux syscall ABI. Tomorrow: bare-metal MMIO + page-table walks. Eventually: future Nishi silicon. The win: as we eliminate third parties layer by layer (Docker, Linux, Win32, NVIDIA), the substrate primitives DO NOT CHANGE. Only the HAL shim changes. The investment in shipped substrate is preserved. V1 operations (the hardware-level concepts any silicon must provide; bare-metal Nishi kernel + future Nishi silicon both implement these): nx_hal_clock_now_ns monotonic nanosecond timestamp nx_hal_alloc_pages contiguous page allocation nx_hal_release_pages return pages to substrate nx_hal_console_write debug-channel byte output nx_hal_random_bytes hardware-quality entropy nx_hal_yield cooperative scheduling hint nx_hal_exit process termination nx_hal_spawn fork + exec; substrate becomes parent nx_hal_wait reap child + read exit code nx_hal_kill send signal to child

dependencies 1 imports · 25 importers

nx_syscalls.nx nx_hal.nx nx_camera_q14.nx nx_checkers_test.nx nx_crater_field.nx nx_elder_supervisor_main.nx nx_forest_layout.nx nx_hal_test.nx nx_pe_container_datachar.nx nx_pe_container_gen.nx nx_pe_container_httpd.nx nx_pe_container_sdserver.nx

diagram shows first 10 each side; +0 more imports, +15 more importers in the complete lists below.

imports: nx_syscalls.nx

imported by: nx_camera_q14.nxnx_checkers_test.nxnx_crater_field.nxnx_elder_supervisor_main.nxnx_forest_layout.nxnx_hal_test.nxnx_pe_container_datachar.nxnx_pe_container_gen.nxnx_pe_container_httpd.nxnx_pe_container_sdserver.nxnx_pe_container_uiserve.nxnx_pe_container_win.nxnx_pe_container_win_io.nxnx_pe_container_win_ping.nxnx_pe_container_win_sup.nxnx_pe_hello_test.nxnx_pe_job_limit_test.nxnx_pe_job_run_test.nxnx_pe_job_self_test.nxnx_pe_spawn_test.nxnx_pe_writer.nxnx_pe_writer_test.nxnx_solar_system_catalog.nxnx_substrate_python_spawn_test.nxnx_world_event.nx

structs

none

consts

94const NX_MAGIC_1000000000: i64 = 1000000000
101const NX_HAL_OP_CLOCK_NOW_NS: i64 = 0
102const NX_HAL_OP_ALLOC_PAGES: i64 = 1
103const NX_HAL_OP_RELEASE_PAGES: i64 = 2
104const NX_HAL_OP_CONSOLE_WRITE: i64 = 3
105const NX_HAL_OP_RANDOM_BYTES: i64 = 4
106const NX_HAL_OP_YIELD: i64 = 5
107const NX_HAL_OP_EXIT: i64 = 6
108const NX_HAL_OP_SPAWN: i64 = 7 // fork+exec; substrate becomes parent
109const NX_HAL_OP_WAIT: i64 = 8 // reap child + read exit code
110const NX_HAL_OP_KILL: i64 = 9 // send signal to child
111const NX_HAL_OP_N_KINDS: i64 = 10
120const NX_HAL_SHIM_LINUX: i64 = 0
121const NX_HAL_SHIM_BARE_METAL: i64 = 1 // future: substrate kernel on bare hw
122const NX_HAL_SHIM_NISHI_SILICON: i64 = 2 // future: custom Nishi ASIC
123const NX_HAL_SHIM_N_KINDS: i64 = 3
132const NX_HAL_OK: i64 = 0
133const NX_HAL_BAD_INPUT: i64 = 1
134const NX_HAL_NO_BACKING: i64 = 2 // shim not implemented for this op
135const NX_HAL_FAULT: i64 = 3 // hardware/syscall returned error
136const NX_HAL_N_VERDICTS: i64 = 4
157const NX_HAL_ACTIVE_SHIM_KIND: i64 = NX_HAL_SHIM_LINUX
168const NX_HAL_SYS_GETRANDOM: i64 = 318
169const NX_HAL_SYS_SCHED_YIELD: i64 = 24
170const NX_HAL_SYS_KILL: i64 = 62
174const NX_HAL_SYS_GETRANDOM: i64 = 278
175const NX_HAL_SYS_SCHED_YIELD: i64 = 124
176const NX_HAL_SYS_KILL: i64 = 129

functions

113func nx_hal_op_is_valid(op: i64) -> i64
called by 1: main
125func nx_hal_shim_is_valid(s: i64) -> i64
called by 1: main
138func nx_hal_verdict_is_valid(v: i64) -> i64
called by 1: main
159func nx_hal_active_shim() -> i64
183func nx_hal_clock_now_ns_linux() -> i64
called by 1: nx_hal_clock_now_ns calls 1: sys_mmap
193func nx_hal_clock_now_ns_bare_metal() -> i64
called by 1: nx_hal_clock_now_ns
201func nx_hal_clock_now_ns_nishi_silicon() -> i64
called by 1: nx_hal_clock_now_ns
209func nx_hal_clock_now_ns() -> i64
221func nx_hal_alloc_pages_linux(n_bytes: i64) -> *u8
called by 1: nx_hal_alloc_pages calls 1: sys_mmap
225func nx_hal_alloc_pages_bare_metal(n_bytes: i64) -> *u8
called by 1: nx_hal_alloc_pages
233func nx_hal_alloc_pages_nishi_silicon(n_bytes: i64) -> *u8
called by 1: nx_hal_alloc_pages
242func nx_hal_alloc_pages(n_bytes: i64) -> *u8
256func nx_hal_release_pages_linux(ptr: *u8, n_bytes: i64) -> i64
262func nx_hal_release_pages_bare_metal(ptr: *u8, n_bytes: i64) -> i64
268func nx_hal_release_pages_nishi_silicon(ptr: *u8, n_bytes: i64) -> i64
274func nx_hal_release_pages(ptr: *u8, n_bytes: i64) -> i64
288func nx_hal_console_write_linux(buf: *u8, len: i64) -> i64
called by 1: nx_hal_console_write calls 1: sys_write
292func nx_hal_console_write_bare_metal(buf: *u8, len: i64) -> i64
300func nx_hal_console_write_nishi_silicon(buf: *u8, len: i64) -> i64
308func nx_hal_console_write(buf: *u8, len: i64) -> i64
323func nx_hal_random_bytes_linux(buf: *u8, len: i64) -> i64
called by 1: nx_hal_random_bytes
330func nx_hal_random_bytes_bare_metal(buf: *u8, len: i64) -> i64
called by 1: nx_hal_random_bytes
339func nx_hal_random_bytes_nishi_silicon(buf: *u8, len: i64) -> i64
called by 1: nx_hal_random_bytes
348func nx_hal_random_bytes(buf: *u8, len: i64) -> i64
362func nx_hal_yield_linux() -> i64
called by 1: nx_hal_yield
368func nx_hal_yield_bare_metal() -> i64
called by 1: nx_hal_yield
375func nx_hal_yield_nishi_silicon() -> i64
called by 1: nx_hal_yield
383func nx_hal_yield() -> i64
395func nx_hal_exit_linux(code: i64) -> i64
called by 1: nx_hal_exit
400func nx_hal_exit_bare_metal(code: i64) -> i64
called by 1: nx_hal_exit
408func nx_hal_exit_nishi_silicon(code: i64) -> i64
called by 1: nx_hal_exit
416func nx_hal_exit(code: i64) -> i64
440func nx_hal_spawn_linux(exec_path: *u8, argv: *i64, envp: *i64) -> i64
455func nx_hal_spawn_bare_metal(exec_path: *u8, argv: *i64, envp: *i64) -> i64
called by 1: nx_hal_spawn
464func nx_hal_spawn_nishi_silicon(exec_path: *u8, argv: *i64, envp: *i64) -> i64
called by 1: nx_hal_spawn
471func nx_hal_spawn(exec_path: *u8, argv: *i64, envp: *i64) -> i64
487func nx_hal_wait_linux(pid: i64, exit_code_out: *i64) -> i64
496func nx_hal_wait_bare_metal(pid: i64, exit_code_out: *i64) -> i64
called by 1: nx_hal_wait
503func nx_hal_wait_nishi_silicon(pid: i64, exit_code_out: *i64) -> i64
called by 1: nx_hal_wait
509func nx_hal_wait(pid: i64, exit_code_out: *i64) -> i64
524func nx_hal_kill_linux(pid: i64, signal: i64) -> i64
called by 1: nx_hal_kill
530func nx_hal_kill_bare_metal(pid: i64, signal: i64) -> i64
called by 1: nx_hal_kill
539func nx_hal_kill_nishi_silicon(pid: i64, signal: i64) -> i64
called by 1: nx_hal_kill
545func nx_hal_kill(pid: i64, signal: i64) -> i64