code wiki / (root) / nx_smoke_sim.nx

nx_smoke_sim.nx

buildroot/runtime/nx_smoke_sim.nx

3573 B97 linesdepth 5pulls 8 transitivereach 0 importersview sourcekind smoketopic smoke
docsdependenciesstructsconstsfunctions

about

nx_smoke_sim.nx -- end-to-end smoke test of the off-C run-loop. Hand-builds a minimal RV64 Linux ELF that exits with code 42, loads it via nx_loader, runs it via nx_rv64_sim, asserts the exit code matches. Proves the OFF-C verification path works without docker / qemu. This is the smallest possible end-to-end demonstration of the sovereign run-loop: 1. Bytes shaped like an ELF -> nx_loader places PT_LOAD segment at vaddr 0x10000. 2. Entry pc = 0x10000 + 120; PC walks 3 instructions: addi a0, zero, 42 -- a0 = 42 addi a7, zero, 93 -- a7 = sys_exit ecall -- syscall(93, 42, ...) 3. nx_rv64_sim's syscall handler sees nr=93, halts cpu, records exit_code = 42. 4. We assert cpu.halted=1 + cpu.exit_code=42. Run: produces a 0 exit code on success, non-zero on any failure. Pairs with bootstrap_native.sh as the proof-of-concept that the in-NishiLang sim is a viable qemu replacement.

dependencies 3 imports · 0 importers

syscalls.nx nx_loader.nx nx_rv64_sim.nx nx_smoke_sim.nx

imports: syscalls.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_loader_load nx_elf_parse_header nx_elf_get_u16_le nx_elf_get_u64_le nx_elf_get_u32_le 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 ↻ nx_dis_word_at nx_dis_opcode nx_dis_rd nx_dis_rs1 nx_dis_rs2

structs

none

consts

none

functions

37func main() -> i64