code wiki / _hdl_build / nx_boot_uefi_probe.nx
nx_boot_uefi_probe.nx
buildroot/runtime/_hdl_build/nx_boot_uefi_probe.nx
about
nx_boot_uefi_probe.nx -- NOS-R0.1 of the NISHI OS ladder: the UEFI auto-discovery seed.
Extends NOS-R0 (nx_boot_uefi): the emitted subsystem-10 EFI_APPLICATION now READS THE
MACHINE BACK TO US. Its position-independent entry walks the UEFI SystemTable and prints,
via ConOut->OutputString: (1) the "NISHI" banner, then (2) the firmware's OWN vendor
string (SystemTable->FirmwareVendor @ +0x18) -- real, unfakeable hardware identity read off
the unknown laptop. That readback is the seed of "auto-discover the machine, then install":
the OS interrogating firmware instead of being told the specs. GetMemoryMap (the RAM-layout
read an installer needs) is the next rung, NOS-R0.2.
Same sovereign PE32+ wrapper as nx_boot_uefi (subsystem 10, no imports, PIC entry); only the
.text logic grows. Entry ABI (MS x64): RCX=ImageHandle, RDX=SystemTable*. Nonvolatile regs
(RSI=SystemTable, RDI=ConOut) survive the firmware calls; pushed/popped per ABI.
SystemTable: +0x18 FirmwareVendor(CHAR16*), +0x40 ConOut(EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL*)
ConOut: +0x08 OutputString(This, CHAR16*)
Build (sovereign): ./_offc/nx_sov_build_run.elf nx_boot_uefi_probe (nx_cc->nxasm, no gcc)
Self-gate (no mocks): byte-reproducible + structural (machine=0x8664, subsystem=10, PE/MZ,
entry=0x1000, entry[0]=push rsi, and the ConOut-read opcodes `48 8B 7E 40` present =
proves the discovery read is wired) + tamper liar-kill (subsystem->3 must reject).
Scope (honest): EMIT-proven. BOOT/READ-proven (real firmware prints its vendor) = on the
laptop USB, after NOS-R0 boots clean. VERDICT log -> knowledge/status/nishi_os.log.
Sovereign: syscalls only, no gcc/.sh. license_tier: ORIGINAL
dependencies 1 imports · 0 importers
imports: nx_syscalls.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
| 25 | const PE_MAGIC_4096: i64 = 4096 |
| 28 | const PE_FILE_SIZE: i64 = 0x400 |
| 29 | const PE_MACHINE_AMD64: i64 = 0x8664 |
| 30 | const PE_OH_MAGIC_PEPLUS: i64 = 0x020B |
| 31 | const PE_SUBSYSTEM_EFI_APP: i64 = 10 |
| 32 | const PE_CHAR_EXEC: i64 = 0x0002 |
| 33 | const PE_CHAR_LARGE_ADDR: i64 = 0x0020 |
| 34 | const PE_SECT_CODE_X_R: i64 = 0x60000020 |
| 36 | const FOFF_PE_SIG: i64 = 0x80 |
| 37 | const FOFF_COFF: i64 = 0x84 |
| 38 | const FOFF_OPT: i64 = 0x98 |
| 39 | const FOFF_SECT_TBL: i64 = 0x188 |
| 40 | const FOFF_TEXT: i64 = 0x200 |
| 41 | const RVA_TEXT: i64 = 0x1000 |
| 42 | const OPT_SUBSYS: i64 = 0x98 + 68 |
| 43 | const OPT_ENTRY: i64 = 0x98 + 16 |
| 44 | const IMG_BASE: i64 = 0x10000000 |
| 45 | const TEXT_VSIZE: i64 = 0x67 // 71 bytes code (ends 0x46) + 3 UTF-16 strings (0x47..0x66) |
functions
| 48 | func _w8(buf: *u8, off: i64, v: i64) -> i64 { buf[off] = (v & 0xff) as u8; return off + 1 } |
| 49 | func _w16(buf: *u8, off: i64, v: i64) -> i64 { _w8(buf, off, v); _w8(buf, off + 1, v >> 8); return off + 2 } |
| 50 | func _w32(buf: *u8, off: i64, v: i64) -> i64 |
| 54 | func _w64(buf: *u8, off: i64, v: i64) -> i64 { _w32(buf, off, v); _w32(buf, off + 4, v >> 32); return off + 8 } |
| 55 | func _r16(buf: *u8, off: i64) -> i64 { return (buf[off] as i64) | ((buf[off + 1] as i64) << 8) } called by 1: uefi_verify |
| 56 | func _r32(buf: *u8, off: i64) -> i64 called by 1: uefi_verify |
| 61 | func uefi_emit(buf: *u8) -> i64 |
| 146 | func uefi_verify(buf: *u8) -> i64 |
| 170 | func u_p(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } |
| 171 | func u_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 } |
| 172 | func u_fn(fd: i64, v: i64) -> i64 |
| 180 | func u_log(sz: i64, repro: i64, structural: i64, tamper: i64, verdict: *u8) -> i64 |
| 191 | func main(argc: i64, argv: *i64) -> i64 |