nx_vcore_a64_kat.nx source
↩ module page · 67 lines · 3031 B
1// nx_vcore_a64_kat.nx -- the video-core-on-ARM64 KAT wrapper. Compiled with nxc2 --target aarch64
2// and executed on the sovereign nx_emu_arm64 by nx_vcore_a64_runproof_gate. PURE COMPUTE: no syscalls,
3// no string literals (no data section) -- buffers are fixed guest addresses (the core's caller-supplied-
4// region contract), text is built by value. Exit codes: 42 = the REAL room protocol round-trips on ARM64
5// (vc_chat_pack -> vc_wire_pack -> vc_wire_parse -> vc_chat_parse byte-exact + the audio sample plane
6// f32<->i16 EXACT round-trip); 1..9 = the first failing stage (distinct codes, no false green).
7// license_tier: ORIGINAL
8import "nx_video_client_wasm.nx"
9
10func main() -> i64 {
11 // caller-supplied regions: fixed guest addresses, all < 0x210000 (code ~64KB, stack at 0x800000)
12 let name: *u8 = 2097152 as *u8 // 0x200000
13 let text: *u8 = 2097408 as *u8 // 0x200100
14 let chat: *u8 = 2098176 as *u8 // 0x200400
15 let id8: *u8 = 2099200 as *u8 // 0x200800
16 let wire: *u8 = 2100224 as *u8 // 0x200C00
17 let winfo: *i64 = 2102272 as *i64 // 0x201400
18 let cinfo: *i64 = 2103296 as *i64 // 0x201800
19 // name "NX", text "ARM64-RUNPROOF" -- by value
20 name[0] = 78 as u8
21 name[1] = 88 as u8
22 text[0] = 65 as u8
23 text[1] = 82 as u8
24 text[2] = 77 as u8
25 text[3] = 54 as u8
26 text[4] = 52 as u8
27 text[5] = 45 as u8
28 text[6] = 82 as u8
29 text[7] = 85 as u8
30 text[8] = 78 as u8
31 text[9] = 80 as u8
32 text[10] = 82 as u8
33 text[11] = 79 as u8
34 text[12] = 79 as u8
35 text[13] = 70 as u8
36 var i: i64 = 0
37 while i < 8 { id8[i] = (65 + i) as u8; i = i + 1 }
38
39 // ---- the real room protocol, the real core functions ----
40 let clen: i64 = vc_chat_pack(chat, name, 2, text, 14)
41 if clen != 17 { return 1 }
42 let wlen: i64 = vc_wire_pack(wire, 0x43, id8, 7, chat, clen)
43 if wlen != 30 { return 2 }
44 if vc_wire_parse(wire, wlen, winfo) != 0 { return 3 }
45 if winfo[0] != 0x43 { return 4 }
46 if winfo[1] != 7 { return 5 }
47 let pay: *u8 = ((wire as i64) + winfo[2]) as *u8
48 if vc_chat_parse(pay, winfo[3], cinfo) != 0 { return 6 }
49 if cinfo[3] != 14 { return 7 }
50 let toff: i64 = cinfo[2]
51 i = 0
52 while i < 14 { if (pay[toff + i] as i64) != (text[i] as i64) { return 8 } i = i + 1 }
53
54 // ---- audio sample plane: i16 -> f32 bits -> i16 must be EXACT (lossless doctrine) ----
55 // edges + a 257-stride sweep (kept small for the emulator's step budget)
56 if vc_f32_bits_to_i16(vc_i16_to_f32_bits(0 - 32768)) != (0 - 32768) { return 9 }
57 if vc_f32_bits_to_i16(vc_i16_to_f32_bits(0 - 1)) != (0 - 1) { return 9 }
58 if vc_f32_bits_to_i16(vc_i16_to_f32_bits(0)) != 0 { return 9 }
59 if vc_f32_bits_to_i16(vc_i16_to_f32_bits(1)) != 1 { return 9 }
60 if vc_f32_bits_to_i16(vc_i16_to_f32_bits(32767)) != 32767 { return 9 }
61 var v: i64 = 0 - 32768
62 while v < 32768 {
63 if vc_f32_bits_to_i16(vc_i16_to_f32_bits(v)) != v { return 9 }
64 v = v + 257
65 }
66 return 42
67}