code wiki / (root) / nx_emu_arm64_main.nx

nx_emu_arm64_main.nx source

↩ module page · 23 lines · 842 B

1// nx_emu_arm64_main.nx -- CLI for NX-EMU aarch64: load + run a static A64 ELF. 2// 3// Usage: nx_emu_arm64 <prog.elf> (exit code = guest's exit status) 4// 5// Mirror of nx_emu_rv64_main: reads the ELF, loads PT_LOAD segments into a 6// flat guest image, and runs it on the sovereign aarch64 interpreter -- NO 7// qemu (qemu-aarch64 is only the differential BENCHMARK/oracle that must 8// agree). This is how Nishi CARRIES aarch64 execution. 9// 10// license_tier: ORIGINAL 11 12import "nx_emu_arm64.nx" 13import "nx_syscalls_x86_64.nx" 14 15func main(argc: i64, argv: *i64) -> i64 { 16 if argc < 2 { return 200 } 17 let path: *u8 = argv[1] as *u8 18 let lenbox: *i64 = sys_mmap(16) as *i64 19 let buf: *u8 = sys_read_file_x86_64(path, lenbox) 20 if (buf as i64) == 0 { return 201 } 21 let r: i64 = emu_arm64_load_elf(buf, lenbox[0]) 22 return r 23}