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 tooltopic 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)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main nx_wrap_log nx_wrap_read_file sys_read nx_wrap_logn nx_elf_parse_header nx_elf_get_u16_le nx_elf_get_u64_le nx_elf_get_u32_le nx_loader_load nx_elf_parse_header ↻ nx_loader_read_phdr nx_elf_get_u32_le ↻ nx_elf_get_u64_le ↻ nx_loader_memcpy nx_loader_memzero nx_rv64_cpu_new nx_rv64_cpu_set_sp nx_rv64_run nx_rv64_step nx_rv64c_decode nx_c_decode_q0 nx_c_field nx_c_enc_i nx_c_reg3 nx_c_enc_s nx_c_decode_q1 nx_c_field ↻ nx_c_sext nx_c_enc_i ↻ nx_c_enc_u nx_c_reg3 ↻ nx_c_enc_r nx_c_enc_j nx_c_enc_b nx_c_decode_q2 nx_c_field ↻ nx_c_enc_i ↻ nx_c_enc_r ↻ nx_c_enc_s ↻

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 {
called by 1: main calls 1: sys_read
64func nx_wrap_log(s: *u8) -> i64 {
called by 1: main
74func nx_wrap_logn(label: *u8, v: i64) -> i64 {
called by 1: main
112func main(argc: i64, argv: *i64) -> i64 {