code wiki / (root) / nxc_native_wrap.nx

nxc_native_wrap.nx

buildroot/runtime/nxc_native_wrap.nx

5264 B173 linesdepth 5pulls 8 transitivereach 0 importersview sourcekind orphan librarytopic nxc
docsdependenciesstructsconstsfunctions

about

nxc_native_wrap.nx -- sovereign bootstrap-verification driver. One-shot main() that proves the off-C runtime path works: 1. Read an RV64 ELF from disk (built via stage 1's gcc-anchor OR via the in-NishiLang nxc.elf compiler). 2. Validate the ELF via nx_elf_read. 3. Allocate a 16 MB flat memory region. 4. Load segments into memory via nx_loader. 5. Set sp to the top of memory minus 64 bytes. 6. Run via nx_rv64_sim with a 100M-instruction budget. 7. Report exit code + instruction count to stderr. Usage: nxc_native_wrap path/to/program.elf Returns: 0 = program executed cleanly via simulator 1 = invalid ELF 2 = load failed (e.g. segment OOB) 3 = simulator hit illegal instruction 4 = budget expired N = the simulated program exited with code N (passed through) Pairs with bootstrap_native.sh. Once this lands + works, we have the full off-C verification: produce ELF in NishiLang, run ELF in NishiLang, compare exit code with stage 1. Sovereign stage 2 is achieved.

dependencies 4 imports · 0 importers

syscalls.nx nx_elf_read.nx nx_loader.nx nx_rv64_sim.nx nxc_native_wrap.nx

imports: syscalls.nxnx_elf_read.nxnx_loader.nxnx_rv64_sim.nx

imported by: nobody (leaf or entry point)

structs

none

consts

35const NX_WRAP_MEM_SIZE: i64 = 16777216 // 16 MB sim memory
36const NX_WRAP_BUDGET: i64 = 100000000 // 100M instructions

functions

40func nx_wrap_read_file(path: *u8, out_len: *i64) -> *u8 {
64func nx_wrap_log(s: *u8) -> i64 {
74func nx_wrap_logn(label: *u8, v: i64) -> i64 {
112func main(argc: i64, argv: *i64) -> i64 {