code wiki / _hdl_build / nx_nxe_kernel0.nx

nx_nxe_kernel0.nx

buildroot/runtime/_hdl_build/nx_nxe_kernel0.nx

83024 B1195 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind tooltopic nxe
docsdependenciesstructsconstsfunctions

about

nx_nxe_kernel0.nx -- N2: emit KERNEL.NXE, the FIRST Nishi-native-format executable (constitution A2: NXE not ELF -- SSOT knowledge/nishi_os_constitution.txt). The payload is PIC x86-64 that receives rbx=&bootinfo from the boot shim ({fb_base,fb_size,...}) and paints the Nishi desktop scene v0: background, top bar, brand accent line, taskbar + start block, centered window with title bar and close button, and the NISHI wordmark in 16px block cells -- then parks holding the screen (EB FE), which is what a kernel owning the display does. Judged by the sovereign emulator's MEASURED SCENE-PAINTED-AND-HOLDING verdict (every pixel written, many transitions) and by OVMF as oracle. NXE v0 HEADER (little-endian, spec = the constitution): 0x00 magic "NXE0" | 0x04 ver=1 | 0x08 arch=1 (x86_64) | 0x0C flags=3 (kernel|needs-fb) 0x10 entry_off | 0x18 text_off (0x40) | 0x20 text_size (8-padded) | 0x28 bss | 0x30 stack 0x38 payload_sum64 (wrapping sum of payload LE u64s; the loader verifies or REFUSES loud) NEVER-BRICK (#26): the payload writes ONLY the framebuffer whose base the loader hands it; it makes ZERO calls of any kind (structurally: the payload contains NO 0xFF byte at all -- colors and offsets are chosen so the scan is exact), touches no firmware, no ports, no Set-Variable-class services. license_tier: ORIGINAL

dependencies 2 imports · 0 importers

nx_syscalls.nx nx_font8x8.nx nx_nxe_kernel0.nx

imports: nx_syscalls.nxnx_font8x8.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main sys_mmap build_payload _w8 emit_rect e_p sys_write sys_exit _w8 ↻ _w32 _w8 ↻ glyph_row _w32 ↻ rel8 e_p ↻ e_fn sys_mmap ↻ sys_write ↻ sys_exit ↻ rel32 _w64 _w32 ↻ ai_a ai_b reg_id reg_op reg_arg e_p ↻ sys_exit ↻ font8x8_table sys_mmap ↻ fg str_len str_off str_bad str_on str_off ↻ str_bad ↻ str_on ↻ _w8 ↻

structs

none

consts

20const PCI_MAGIC_4096: i64 = 4096
21const PCI_MAGIC_8086: i64 = 8086
22const PCI_MAGIC_1237: i64 = 1237
23const PCI_CFG_ENABLE: i64 = 2147483648 // bit31 of CONFIG_ADDRESS
24const DECODE_WALK_GUARD: i64 = 4096 // max instructions the never-brick walk will decode
25const EMIT_BUF_BYTES: i64 = 65536 // emitter scratch
27const FB_W: i64 = 1280
28const FB_H: i64 = 800
29const NXE_HDR: i64 = 0x40
30const COL_BG: i64 = 0x001B2430 // desktop background (no 0xFF bytes in any color -- see fence)
31const COL_TOP: i64 = 0x002E3B4E // top bar
32const COL_ACCENT: i64 = 0x00AA8844 // brand tan
33const COL_TASK: i64 = 0x00232E3D // taskbar
34const COL_WIN: i64 = 0x00E8E4DC // window panel
35const COL_TITLE: i64 = 0x003A4A60 // window title bar
36const COL_CLOSE: i64 = 0x00AA4444 // close button
37const COL_TALLY: i64 = 0x0044CC88 // per-keystroke tally block (N3 input evidence, in pixels)
44const AI_K: i64 = 32 // dot-product length
45const AI_X: i64 = 1100 // KAT swatch position (top bar, clear of the scene)
46const AI_Y: i64 = 8
47const AI_W: i64 = 24
48const AI_H: i64 = 20
96const FONT_GLYPHS: i64 = 96 // printable 0x20..0x7E, indexed (ch-0x20)*8
97const FONT_BYTES: i64 = 768 // FONT_GLYPHS * 8
98const TXT_X: i64 = 264
99const TXT_Y: i64 = 664
100const COL_TEXT: i64 = 0x00E0E6F0
101const STR_PAD: i64 = 8 // 8 zero bytes after the last string: the char fetch reads a
103const AI_MAGIC: i64 = 0x3057584E // "NXW0" little-endian; the file stores it as a qword
107const AIW_NAME: i64 = 0x20 // 64B NUL-terminated model name (rendered on screen)
108const AIW_ORIGIN: i64 = 0x60 // 128B NUL-terminated origin URL (carried for the GUI installer)
109const AIW_LICENSE: i64 = 0xE0 // 32B
110const AIW_WEIGHTS: i64 = 0x100 // A[K] then B[K]
112const AIW_SUMQ: i64 = 92 // (AIW_WEIGHTS - AIW_NAME)/8 + 2*AI_K = 28 + 64
113const COL_AI_OFF: i64 = 0x00566070 // slate -- no assistant file present (honest default)
114const COL_AI_REFUSED: i64 = 0x00DD3355 // red -- present but did not validate; NOT executed
115const COL_AI_ON: i64 = 0x0033DD66 // green -- validated; the MAC below ran on ITS weights
116const AIST_X: i64 = 1064
117const AIST_Y: i64 = 8
118const AIST_W: i64 = 24
119const AIST_H: i64 = 20
120const TALLY_X: i64 = 160
121const TALLY_Y: i64 = 772
122const TALLY_W: i64 = 16
123const TALLY_H: i64 = 20
124const TALLY_GAP: i64 = 6
127const COL_OWNED: i64 = 0x00CC44AA
128const OWN_X: i64 = 1140
129const OWN_Y: i64 = 8
130const MM_BUF_BYTES: i64 = 0x4000
135const PCI_ADDR_PORT: i64 = 0xCF8
136const PCI_DATA_PORT: i64 = 0xCFC
137const PCI_SLOTS: i64 = 32
138const PCI_X: i64 = 300
139const PCI_Y: i64 = 44 // just under the accent line, clear of the desktop window
140const PCI_W: i64 = 18
141const PCI_H: i64 = 14
142const PCI_GAP: i64 = 4
146const COL_BOUND: i64 = 0x0044CC88 // registry hit -> we know how to drive this
147const COL_UNBOUND: i64 = 0x00CC7744 // no spec -> honestly not bound
152const OP_END: i64 = 0
153const OP_READ: i64 = 1 // acc = pci config dword at (arg & 0xFC)
154const OP_AND: i64 = 2 // acc = acc & arg
155const OP_EXPECT: i64 = 3 // acc must equal arg, else the device is MISMATCHED
156const OP_SHR: i64 = 4 // acc = acc >> arg (extract a field without a mask)
157const OPS_MAX: i64 = 10
158const REG_N: i64 = 2
159const REG_STRIDE: i64 = 168 // id(8) + OPS_MAX * (op,arg)(16)
200const COL_VERIFIED: i64 = 0x0033DD66 // spec matched AND the device answered as the spec says
201const COL_MISMATCH: i64 = 0x00DD3355 // in the registry, but the device did NOT match its spec
202const COL_PCI: i64 = 0x00DDAA33
206const PS2_STATUS: i64 = 0x64
207const PS2_DATA: i64 = 0x60
208const HB_X: i64 = 300
209const HB_Y: i64 = 772
210const HB_W: i64 = 700
211const HB_H: i64 = 20
212const COL_HB: i64 = 0x0066AACC

functions

51func str_off(i: i64) -> i64
55func str_bad(i: i64) -> i64
59func str_on(i: i64) -> i64
63func str_len(which: i64) -> i64
called by 1: build_payload calls 3: str_offstr_badstr_on
73func ai_a(k: i64) -> i64 { return (k % 7) - 3 } // -3..3, crosses zero and goes negative
74func ai_b(k: i64) -> i64 { return (k % 5) + 1 } // 1..5
160func reg_id(i: i64) -> i64
called by 1: build_payload
164func reg_op(i: i64, k: i64) -> i64
called by 1: build_payload
182func reg_arg(i: i64, k: i64) -> i64
called by 1: build_payload
214func _w8(b: *u8, o: i64, v: i64) -> i64 { b[o] = (v & 0xff) as u8; return o + 1 }
215func _w32(b: *u8, o: i64, v: i64) -> i64 { _w8(b,o,v); _w8(b,o+1,v>>8); _w8(b,o+2,v>>16); _w8(b,o+3,v>>24); return o + 4 }
called by 4: _w64emit_rectbuild_payloadmain calls 1: _w8
216func _w64(b: *u8, o: i64, v: i64) -> i64 { _w32(b, o, v); _w32(b, o + 4, v >> 32); return o + 8 }
called by 2: build_payloadmain calls 1: _w32
217func _r64(b: *u8, o: i64) -> i64
called by 2: sum64main
222func e_p(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
223func e_fp(fd: i64, s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(fd, s, n); return 0 }
called by 1: main calls 1: sys_write
224func e_fn(fd: i64, v: i64) -> i64
called by 2: rel8main calls 2: sys_mmapsys_write
234func glyph_row(l: i64, r: i64) -> i64
called by 1: build_payload
256func emit_rect(b: *u8, o0: i64, x: i64, y: i64, w: i64, h: i64, color: i64) -> i64
called by 1: build_payload calls 4: e_psys_exit_w8_w32
279func build_payload(b: *u8, txtbytes: *i64) -> i64
called by 1: main calls 19: _w8emit_rectglyph_row_w32rel8rel32+13
926func ai_expect() -> i64
called by 1: main calls 2: ai_aai_b
934func opc(b: *u8, o: i64, v: i64) -> i64 { if (b[o] as i64) == v { return 1 } return 0 }
942func rel32(target: i64, end_ip: i64) -> i64 { return target - end_ip }
called by 1: build_payload
944func rel8(target: i64, next_ip: i64) -> i64
called by 1: build_payload calls 3: e_pe_fnsys_exit
958func verify_payload(b: *u8, base: i64, plen: i64, dbg: *i64, txtbytes: *i64) -> i64
985func rect_at(b: *u8, o: i64, endp: i64) -> i64
1007func verify_tail(b: *u8, o0: i64, endp: i64, dbg: *i64, txtbytes: *i64) -> i64
1109func sum64(b: *u8, off: i64, len: i64) -> i64
1116func main(argc: i64, argv: *i64) -> i64