code wiki / (root) / nx_emu_sparc64.nx

nx_emu_sparc64.nx

buildroot/runtime/nx_emu_sparc64.nx

23914 B497 linesdepth 3pulls 3 transitivereach 2 importersview sourcekind librarytopic emu
docsdependenciesstructsconstsfunctions

about

nx_emu_sparc64.nx -- sovereign SPARC V9 (sparc64) interpreter (NX-EMU). Fourth architecture, the hardest: REGISTER WINDOWS + DELAY SLOTS + BIG-ENDIAN. Decode/execute is pure NishiLang per the SPARC V9 ISA (the spec is the oracle) -- NO qemu. qemu-sparc64 is only the differential BENCHMARK that must agree. This is how Nishi CARRIES sparc64 execution (operator: "nishi ecosystem must carry; externals = benchmarks only"). Register model: 8 globals g[0..7] (g0 == 0); a window file win[16*NWIN] with the standard overlap (%o of window W == %i of window W+1) selected by CWP. reg field 0..7=%g, 8..15=%o, 16..23=%l, 24..31=%i. save = CWP+1 (compute in old window, write rd in new), restore = CWP-1. Control transfers (CALL/JMPL) take effect after the delay-slot instruction via the PC/nPC model. Linux/SPARC syscalls: g1=number, o0..=args, `ta` traps. genealogy_id: sparc_v9_isa + linux_sparc64_abi lineage_id: nishi_nx_emu_sparc64_m1 license_tier: ORIGINAL

dependencies 1 imports · 2 importers

nx_syscalls_x86_64.nx nx_emu_sparc64.nx nx_emu_sparc64_main.nx nx_isa_sparc64_gate.nx

imports: nx_syscalls_x86_64.nx

imported by: nx_emu_sparc64_main.nxnx_isa_sparc64_gate.nx

structs

none

consts

21const SP_MAGIC_200000000: i64 = 200000000
23const SP_GUEST_SIZE: i64 = 16777216
24const SP_NWIN: i64 = 8
25const SP_SYS_EXIT: i64 = 1
26const SP_SYS_READ: i64 = 3
27const SP_SYS_WRITE: i64 = 4
28const SPE_UNSUPPORTED: i64 = -1
29const SPE_FAULT: i64 = -3
39const SP_OP2_BPCC: i64 = 1 // BPcc: disp19 plus a cc-field selector
40const SP_OP2_BICC: i64 = 2 // Bicc: disp22, always %icc
41const SP_OP2_SETHI: i64 = 4
48const SP_ICC_N: i64 = 0
49const SP_XCC_N: i64 = 4
50const SP_CC_SLOTS: i64 = 8
52const SP_IMM22_MASK: i64 = 4194303 // 0x3FFFFF: SETHI imm22 and Bicc disp22
53const SP_DISP22_SIGN: i64 = 2097152 // 0x200000
54const SP_DISP22_MOD: i64 = 4194304 // 0x400000
55const SP_DISP19_MASK: i64 = 524287 // 0x7FFFF: BPcc disp19
56const SP_DISP19_SIGN: i64 = 262144 // 0x40000
57const SP_DISP19_MOD: i64 = 524288 // 0x80000
58const SP_M32: i64 = 4294967295 // 0xFFFFFFFF
59const SP_M16: i64 = 65535
60const SP_B31: i64 = 2147483648 // 0x80000000
61const SP_2P32: i64 = 4294967296
62const SP_B15: i64 = 32768
63const SP_2P16: i64 = 65536
64const SP_B7: i64 = 128
65const SP_2P8: i64 = 256
66const SP_COND_BA: i64 = 8 // branch-always: the ONE cond whose
68const SP_CCSEL_ICC: i64 = 0 // BPcc cc1cc0: 00 = %icc, 10 = %xcc;
69const SP_CCSEL_XCC: i64 = 2 // 01 and 11 are RESERVED -> refuse

functions

76func sp_srl(v: i64, n: i64) -> i64
called by 1: emu_sparc64_run_mem
81func sp_not(v: i64) -> i64 { return (0 - v) - 1 }
called by 1: emu_sparc64_run_mem
82func sp_sx8(v: i64) -> i64 { let t: i64 = v & 0xff; if (t & SP_B7) != 0 { return t - SP_2P8 } return t }
called by 1: emu_sparc64_run_mem
83func sp_sx16(v: i64) -> i64 { let t: i64 = v & SP_M16; if (t & SP_B15) != 0 { return t - SP_2P16 } return t }
called by 1: emu_sparc64_run_mem
84func sp_sx32(v: i64) -> i64 { let t: i64 = v & SP_M32; if (t & SP_B31) != 0 { return t - SP_2P32 } return t }
called by 1: emu_sparc64_run_mem
85func sp_b31(v: i64) -> i64 { if (v & SP_B31) != 0 { return 1 } return 0 }
called by 2: sp_setccsp_setlog
86func sp_b63(v: i64) -> i64 { if v < 0 { return 1 } return 0 }
called by 2: sp_setccsp_setlog
91func sp_ltu(a: i64, b: i64) -> i64
called by 1: sp_setcc
108func sp_setcc(cc: *i64, a: i64, b: i64, r: i64, is_sub: i64) -> i64
146func sp_setlog(cc: *i64, r: i64) -> i64
called by 1: emu_sparc64_run_mem calls 2: sp_b31sp_b63
166func sp_cond(cc: *i64, cond: i64, base: i64) -> i64
called by 1: emu_sparc64_run_mem
197func sp_g_ld(mem: *u8, va: i64, width: i64) -> i64
203func sp_g_st(mem: *u8, va: i64, width: i64, val: i64) -> i64
called by 1: emu_sparc64_run_mem
211func sp_rd(g: *i64, win: *i64, cwp: i64, r: i64) -> i64
called by 1: emu_sparc64_run_mem
218func sp_wr(g: *i64, win: *i64, cwp: i64, r: i64, v: i64) -> i64
called by 1: emu_sparc64_run_mem
227func emu_sparc64_run_mem(mem: *u8, mem_size: i64, entry: i64, sp0: i64) -> i64
475func emu_sparc64_load_elf(buf: *u8, len: i64) -> i64
called by 1: main calls 2: sp_g_ldemu_sparc64_run_mem