code wiki / _hdl_build / nx_boot_uefi_memmap.nx
nx_boot_uefi_memmap.nx
buildroot/runtime/_hdl_build/nx_boot_uefi_memmap.nx
about
nx_boot_uefi_memmap.nx -- NOS-R0.2 of the NISHI OS ladder: the OS calls UEFI BootServices.
Extends the auto-discovery seed (R0.1): the emitted subsystem-10 EFI_APPLICATION now INVOKES a
real UEFI firmware FUNCTION -- BootServices->GetMemoryMap -- using the full MS-x64 ABI
(rcx/rdx/r8/r9 + a 5th argument on the stack at [rsp+0x20]). GetMemoryMap is THE call an
installer uses to read the machine's RAM layout ("where can I install"). This rung proves the
call MECHANISM (reaching BootServices, passing 5 args, the firmware function returning, and
continuing) by printing a fixed "RAM-MAP-READ" confirmation after the call. Reading + printing
the returned map size (number formatting) is the next rung, NOS-R0.3.
Entry ABI (MS x64): RCX=ImageHandle, RDX=SystemTable*. RSI=SystemTable, RDI=ConOut kept across
calls. GetMemoryMap(rcx=&MapSize, rdx=MapBuf(NULL), r8=&MapKey, r9=&DescSize, [rsp+0x20]=&DescVer).
SystemTable: +0x40 ConOut, +0x60 BootServices. BootServices: +0x38 GetMemoryMap.
Scratch arg buffers live in an RWX section (firmware writes the required size into *MapSize).
Build (sovereign): ./_offc/nx_sov_build_run.elf nx_boot_uefi_memmap (nx_cc->nxasm, no gcc)
Self-gate: byte-reproducible + structural (subsystem=10, entry, the `mov rax,[rsi+0x60]` +
`call [rax+0x38]` GetMemoryMap opcodes present) + tamper (subsystem->3 rejects).
Exec-proof: nx_emu_uefi models BootServices->GetMemoryMap as a hook -> confirms the call fires
and "RAM-MAP-READ" prints (sovereign, no qemu/laptop).
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
| 23 | const PE_MAGIC_4096: i64 = 4096 |
| 25 | const PE_FILE_SIZE: i64 = 0x400 |
| 26 | const PE_MACHINE_AMD64: i64 = 0x8664 |
| 27 | const PE_OH_MAGIC_PEPLUS: i64 = 0x020B |
| 28 | const PE_SUBSYSTEM_EFI_APP: i64 = 10 |
| 29 | const PE_CHAR_EXEC: i64 = 0x0002 |
| 30 | const PE_CHAR_LARGE_ADDR: i64 = 0x0020 |
| 31 | const PE_SECT_CODE_RWX: i64 = 0xE0000020 // CODE|EXECUTE|READ|WRITE (scratch is written by firmware) |
| 33 | const FOFF_PE_SIG: i64 = 0x80 |
| 34 | const FOFF_COFF: i64 = 0x84 |
| 35 | const FOFF_OPT: i64 = 0x98 |
| 36 | const FOFF_SECT_TBL: i64 = 0x188 |
| 37 | const FOFF_TEXT: i64 = 0x200 |
| 38 | const RVA_TEXT: i64 = 0x1000 |
| 39 | const OPT_SUBSYS: i64 = 0x98 + 68 |
| 40 | const OPT_ENTRY: i64 = 0x98 + 16 |
| 41 | const IMG_BASE: i64 = 0x10000000 |
| 42 | const TEXT_VSIZE: i64 = 0x90 |
functions
| 44 | func _w8(buf: *u8, off: i64, v: i64) -> i64 { buf[off] = (v & 0xff) as u8; return off + 1 } |
| 45 | func _w16(buf: *u8, off: i64, v: i64) -> i64 { _w8(buf, off, v); _w8(buf, off + 1, v >> 8); return off + 2 } |
| 46 | func _w32(buf: *u8, off: i64, v: i64) -> i64 |
| 50 | func _w64(buf: *u8, off: i64, v: i64) -> i64 { _w32(buf, off, v); _w32(buf, off + 4, v >> 32); return off + 8 } |
| 51 | func _r16(buf: *u8, off: i64) -> i64 { return (buf[off] as i64) | ((buf[off + 1] as i64) << 8) } called by 1: uefi_verify |
| 52 | func _r32(buf: *u8, off: i64) -> i64 called by 1: uefi_verify |
| 56 | func uefi_emit(buf: *u8) -> i64 |
| 130 | func uefi_verify(buf: *u8) -> i64 |
| 152 | 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 } |
| 153 | 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 } |
| 154 | func u_fn(fd: i64, v: i64) -> i64 |
| 162 | func u_log(sz: i64, repro: i64, structural: i64, tamper: i64, verdict: *u8) -> i64 |
| 173 | func main(argc: i64, argv: *i64) -> i64 |