code wiki / _hdl_build / nx_nxe_kernel0.nx
nx_nxe_kernel0.nx
buildroot/runtime/_hdl_build/nx_nxe_kernel0.nx
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
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
structs
| none |
consts
| 20 | const PCI_MAGIC_4096: i64 = 4096 |
| 21 | const PCI_MAGIC_8086: i64 = 8086 |
| 22 | const PCI_MAGIC_1237: i64 = 1237 |
| 23 | const PCI_CFG_ENABLE: i64 = 2147483648 // bit31 of CONFIG_ADDRESS |
| 24 | const DECODE_WALK_GUARD: i64 = 4096 // max instructions the never-brick walk will decode |
| 25 | const EMIT_BUF_BYTES: i64 = 65536 // emitter scratch |
| 27 | const FB_W: i64 = 1280 |
| 28 | const FB_H: i64 = 800 |
| 29 | const NXE_HDR: i64 = 0x40 |
| 30 | const COL_BG: i64 = 0x001B2430 // desktop background (no 0xFF bytes in any color -- see fence) |
| 31 | const COL_TOP: i64 = 0x002E3B4E // top bar |
| 32 | const COL_ACCENT: i64 = 0x00AA8844 // brand tan |
| 33 | const COL_TASK: i64 = 0x00232E3D // taskbar |
| 34 | const COL_WIN: i64 = 0x00E8E4DC // window panel |
| 35 | const COL_TITLE: i64 = 0x003A4A60 // window title bar |
| 36 | const COL_CLOSE: i64 = 0x00AA4444 // close button |
| 37 | const COL_TALLY: i64 = 0x0044CC88 // per-keystroke tally block (N3 input evidence, in pixels) |
| 44 | const AI_K: i64 = 32 // dot-product length |
| 45 | const AI_X: i64 = 1100 // KAT swatch position (top bar, clear of the scene) |
| 46 | const AI_Y: i64 = 8 |
| 47 | const AI_W: i64 = 24 |
| 48 | const AI_H: i64 = 20 |
| 96 | const FONT_GLYPHS: i64 = 96 // printable 0x20..0x7E, indexed (ch-0x20)*8 |
| 97 | const FONT_BYTES: i64 = 768 // FONT_GLYPHS * 8 |
| 98 | const TXT_X: i64 = 264 |
| 99 | const TXT_Y: i64 = 664 |
| 100 | const COL_TEXT: i64 = 0x00E0E6F0 |
| 101 | const STR_PAD: i64 = 8 // 8 zero bytes after the last string: the char fetch reads a |
| 103 | const AI_MAGIC: i64 = 0x3057584E // "NXW0" little-endian; the file stores it as a qword |
| 107 | const AIW_NAME: i64 = 0x20 // 64B NUL-terminated model name (rendered on screen) |
| 108 | const AIW_ORIGIN: i64 = 0x60 // 128B NUL-terminated origin URL (carried for the GUI installer) |
| 109 | const AIW_LICENSE: i64 = 0xE0 // 32B |
| 110 | const AIW_WEIGHTS: i64 = 0x100 // A[K] then B[K] |
| 112 | const AIW_SUMQ: i64 = 92 // (AIW_WEIGHTS - AIW_NAME)/8 + 2*AI_K = 28 + 64 |
| 113 | const COL_AI_OFF: i64 = 0x00566070 // slate -- no assistant file present (honest default) |
| 114 | const COL_AI_REFUSED: i64 = 0x00DD3355 // red -- present but did not validate; NOT executed |
| 115 | const COL_AI_ON: i64 = 0x0033DD66 // green -- validated; the MAC below ran on ITS weights |
| 116 | const AIST_X: i64 = 1064 |
| 117 | const AIST_Y: i64 = 8 |
| 118 | const AIST_W: i64 = 24 |
| 119 | const AIST_H: i64 = 20 |
| 120 | const TALLY_X: i64 = 160 |
| 121 | const TALLY_Y: i64 = 772 |
| 122 | const TALLY_W: i64 = 16 |
| 123 | const TALLY_H: i64 = 20 |
| 124 | const TALLY_GAP: i64 = 6 |
| 127 | const COL_OWNED: i64 = 0x00CC44AA |
| 128 | const OWN_X: i64 = 1140 |
| 129 | const OWN_Y: i64 = 8 |
| 130 | const MM_BUF_BYTES: i64 = 0x4000 |
| 135 | const PCI_ADDR_PORT: i64 = 0xCF8 |
| 136 | const PCI_DATA_PORT: i64 = 0xCFC |
| 137 | const PCI_SLOTS: i64 = 32 |
| 138 | const PCI_X: i64 = 300 |
| 139 | const PCI_Y: i64 = 44 // just under the accent line, clear of the desktop window |
| 140 | const PCI_W: i64 = 18 |
| 141 | const PCI_H: i64 = 14 |
| 142 | const PCI_GAP: i64 = 4 |
| 146 | const COL_BOUND: i64 = 0x0044CC88 // registry hit -> we know how to drive this |
| 147 | const COL_UNBOUND: i64 = 0x00CC7744 // no spec -> honestly not bound |
| 152 | const OP_END: i64 = 0 |
| 153 | const OP_READ: i64 = 1 // acc = pci config dword at (arg & 0xFC) |
| 154 | const OP_AND: i64 = 2 // acc = acc & arg |
| 155 | const OP_EXPECT: i64 = 3 // acc must equal arg, else the device is MISMATCHED |
| 156 | const OP_SHR: i64 = 4 // acc = acc >> arg (extract a field without a mask) |
| 157 | const OPS_MAX: i64 = 10 |
| 158 | const REG_N: i64 = 2 |
| 159 | const REG_STRIDE: i64 = 168 // id(8) + OPS_MAX * (op,arg)(16) |
| 200 | const COL_VERIFIED: i64 = 0x0033DD66 // spec matched AND the device answered as the spec says |
| 201 | const COL_MISMATCH: i64 = 0x00DD3355 // in the registry, but the device did NOT match its spec |
| 202 | const COL_PCI: i64 = 0x00DDAA33 |
| 206 | const PS2_STATUS: i64 = 0x64 |
| 207 | const PS2_DATA: i64 = 0x60 |
| 208 | const HB_X: i64 = 300 |
| 209 | const HB_Y: i64 = 772 |
| 210 | const HB_W: i64 = 700 |
| 211 | const HB_H: i64 = 20 |
| 212 | const COL_HB: i64 = 0x0066AACC |
functions
| 51 | func str_off(i: i64) -> i64 |
| 55 | func str_bad(i: i64) -> i64 |
| 59 | func str_on(i: i64) -> i64 |
| 63 | func str_len(which: i64) -> i64 |
| 73 | func ai_a(k: i64) -> i64 { return (k % 7) - 3 } // -3..3, crosses zero and goes negative |
| 74 | func ai_b(k: i64) -> i64 { return (k % 5) + 1 } // 1..5 |
| 160 | func reg_id(i: i64) -> i64 called by 1: build_payload |
| 164 | func reg_op(i: i64, k: i64) -> i64 called by 1: build_payload |
| 182 | func reg_arg(i: i64, k: i64) -> i64 called by 1: build_payload |
| 214 | func _w8(b: *u8, o: i64, v: i64) -> i64 { b[o] = (v & 0xff) as u8; return o + 1 } |
| 215 | func _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 } |
| 216 | func _w64(b: *u8, o: i64, v: i64) -> i64 { _w32(b, o, v); _w32(b, o + 4, v >> 32); return o + 8 } |
| 217 | func _r64(b: *u8, o: i64) -> i64 |
| 222 | func 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 } |
| 223 | func 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 } |
| 224 | func e_fn(fd: i64, v: i64) -> i64 |
| 234 | func glyph_row(l: i64, r: i64) -> i64 called by 1: build_payload |
| 256 | func emit_rect(b: *u8, o0: i64, x: i64, y: i64, w: i64, h: i64, color: i64) -> i64 |
| 279 | func build_payload(b: *u8, txtbytes: *i64) -> i64 |
| 926 | func ai_expect() -> i64 |
| 934 | func opc(b: *u8, o: i64, v: i64) -> i64 { if (b[o] as i64) == v { return 1 } return 0 } |
| 942 | func rel32(target: i64, end_ip: i64) -> i64 { return target - end_ip } called by 1: build_payload |
| 944 | func rel8(target: i64, next_ip: i64) -> i64 |
| 958 | func verify_payload(b: *u8, base: i64, plen: i64, dbg: *i64, txtbytes: *i64) -> i64 |
| 985 | func rect_at(b: *u8, o: i64, endp: i64) -> i64 |
| 1007 | func verify_tail(b: *u8, o0: i64, endp: i64, dbg: *i64, txtbytes: *i64) -> i64 |
| 1109 | func sum64(b: *u8, off: i64, len: i64) -> i64 |
| 1116 | func main(argc: i64, argv: *i64) -> i64 |