nx_emu_sparc64.nx
buildroot/runtime/nx_emu_sparc64.nx
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
imports: nx_syscalls_x86_64.nx
imported by: nx_emu_sparc64_main.nxnx_isa_sparc64_gate.nx
structs
| none |
consts
| 21 | const SP_MAGIC_200000000: i64 = 200000000 |
| 23 | const SP_GUEST_SIZE: i64 = 16777216 |
| 24 | const SP_NWIN: i64 = 8 |
| 25 | const SP_SYS_EXIT: i64 = 1 |
| 26 | const SP_SYS_READ: i64 = 3 |
| 27 | const SP_SYS_WRITE: i64 = 4 |
| 28 | const SPE_UNSUPPORTED: i64 = -1 |
| 29 | const SPE_FAULT: i64 = -3 |
| 39 | const SP_OP2_BPCC: i64 = 1 // BPcc: disp19 plus a cc-field selector |
| 40 | const SP_OP2_BICC: i64 = 2 // Bicc: disp22, always %icc |
| 41 | const SP_OP2_SETHI: i64 = 4 |
| 48 | const SP_ICC_N: i64 = 0 |
| 49 | const SP_XCC_N: i64 = 4 |
| 50 | const SP_CC_SLOTS: i64 = 8 |
| 52 | const SP_IMM22_MASK: i64 = 4194303 // 0x3FFFFF: SETHI imm22 and Bicc disp22 |
| 53 | const SP_DISP22_SIGN: i64 = 2097152 // 0x200000 |
| 54 | const SP_DISP22_MOD: i64 = 4194304 // 0x400000 |
| 55 | const SP_DISP19_MASK: i64 = 524287 // 0x7FFFF: BPcc disp19 |
| 56 | const SP_DISP19_SIGN: i64 = 262144 // 0x40000 |
| 57 | const SP_DISP19_MOD: i64 = 524288 // 0x80000 |
| 58 | const SP_M32: i64 = 4294967295 // 0xFFFFFFFF |
| 59 | const SP_M16: i64 = 65535 |
| 60 | const SP_B31: i64 = 2147483648 // 0x80000000 |
| 61 | const SP_2P32: i64 = 4294967296 |
| 62 | const SP_B15: i64 = 32768 |
| 63 | const SP_2P16: i64 = 65536 |
| 64 | const SP_B7: i64 = 128 |
| 65 | const SP_2P8: i64 = 256 |
| 66 | const SP_COND_BA: i64 = 8 // branch-always: the ONE cond whose |
| 68 | const SP_CCSEL_ICC: i64 = 0 // BPcc cc1cc0: 00 = %icc, 10 = %xcc; |
| 69 | const SP_CCSEL_XCC: i64 = 2 // 01 and 11 are RESERVED -> refuse |
functions
| 76 | func sp_srl(v: i64, n: i64) -> i64 called by 1: emu_sparc64_run_mem |
| 81 | func sp_not(v: i64) -> i64 { return (0 - v) - 1 } called by 1: emu_sparc64_run_mem |
| 82 | func 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 |
| 83 | func 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 |
| 84 | func 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 |
| 85 | func sp_b31(v: i64) -> i64 { if (v & SP_B31) != 0 { return 1 } return 0 } |
| 86 | func sp_b63(v: i64) -> i64 { if v < 0 { return 1 } return 0 } |
| 91 | func sp_ltu(a: i64, b: i64) -> i64 called by 1: sp_setcc |
| 108 | func sp_setcc(cc: *i64, a: i64, b: i64, r: i64, is_sub: i64) -> i64 |
| 146 | func sp_setlog(cc: *i64, r: i64) -> i64 |
| 166 | func sp_cond(cc: *i64, cond: i64, base: i64) -> i64 called by 1: emu_sparc64_run_mem |
| 197 | func sp_g_ld(mem: *u8, va: i64, width: i64) -> i64 |
| 203 | func sp_g_st(mem: *u8, va: i64, width: i64, val: i64) -> i64 called by 1: emu_sparc64_run_mem |
| 211 | func sp_rd(g: *i64, win: *i64, cwp: i64, r: i64) -> i64 called by 1: emu_sparc64_run_mem |
| 218 | func sp_wr(g: *i64, win: *i64, cwp: i64, r: i64, v: i64) -> i64 called by 1: emu_sparc64_run_mem |
| 227 | func emu_sparc64_run_mem(mem: *u8, mem_size: i64, entry: i64, sp0: i64) -> i64 |
| 475 | func emu_sparc64_load_elf(buf: *u8, len: i64) -> i64 |