code wiki / _hdl_build / nx_boot_uefi_ramsize.nx
nx_boot_uefi_ramsize.nx
buildroot/runtime/_hdl_build/nx_boot_uefi_ramsize.nx
about
nx_boot_uefi_ramsize.nx -- NOS-R0.3: DISPLAY a discovered hardware value (the RAM map size).
Extends R0.2 (the GetMemoryMap call): after calling BootServices->GetMemoryMap, the emitted
EFI app now READS the returned MapSize and PRINTS it as hex -- the first rung that shows a real
hardware value the OS discovered from the machine. This unlocks an installer UI ("this box has
N bytes of RAM, install here"). The hex render is a real LOOP in machine code (8 nibbles MSB
first, shr-by-CL + cmp + jcc), which is exactly why the exec-harness grew loop support.
Entry ABI (MS x64): RCX=ImageHandle, RDX=SystemTable*. RSI=SystemTable, RDI=ConOut, RBX=hex
write pointer (all callee-saved across the firmware call). Prints "RAM:0x" + 8 hex digits + CRLF.
GetMemoryMap writes the required map size into *MapSize; we load it and format it.
Scratch + hex buffer live in an RWX section (firmware writes MapSize; we write the hex chars).
Build (sovereign): ./_offc/nx_sov_build_run.elf nx_boot_uefi_ramsize (nx_cc->nxasm, no gcc)
Exec-proof: nx_emu_uefi runs it (GetMemoryMap hook returns 0x1800) -> expect "RAM:0x00001800".
Self-gate: byte-reproducible + structural (subsystem=10, entry, GetMemoryMap call opcodes, the
shr-by-CL hex-loop opcode present) + tamper (subsystem->3 rejects).
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
| 20 | const PE_MAGIC_4096: i64 = 4096 |
| 22 | const PE_FILE_SIZE: i64 = 0x400 |
| 23 | const PE_MACHINE_AMD64: i64 = 0x8664 |
| 24 | const PE_OH_MAGIC_PEPLUS: i64 = 0x020B |
| 25 | const PE_SUBSYSTEM_EFI_APP: i64 = 10 |
| 26 | const PE_CHAR_EXEC: i64 = 0x0002 |
| 27 | const PE_CHAR_LARGE_ADDR: i64 = 0x0020 |
| 28 | const PE_SECT_CODE_RWX: i64 = 0xE0000020 |
| 30 | const FOFF_PE_SIG: i64 = 0x80 |
| 31 | const FOFF_COFF: i64 = 0x84 |
| 32 | const FOFF_OPT: i64 = 0x98 |
| 33 | const FOFF_SECT_TBL: i64 = 0x188 |
| 34 | const FOFF_TEXT: i64 = 0x200 |
| 35 | const RVA_TEXT: i64 = 0x1000 |
| 36 | const OPT_SUBSYS: i64 = 0x98 + 68 |
| 37 | const OPT_ENTRY: i64 = 0x98 + 16 |
| 38 | const IMG_BASE: i64 = 0x10000000 |
| 39 | const TEXT_VSIZE: i64 = 0x100 |
functions
| 41 | func _w8(buf: *u8, off: i64, v: i64) -> i64 { buf[off] = (v & 0xff) as u8; return off + 1 } |
| 42 | func _w16(buf: *u8, off: i64, v: i64) -> i64 { _w8(buf, off, v); _w8(buf, off + 1, v >> 8); return off + 2 } |
| 43 | func _w32(buf: *u8, off: i64, v: i64) -> i64 |
| 47 | func _w64(buf: *u8, off: i64, v: i64) -> i64 { _w32(buf, off, v); _w32(buf, off + 4, v >> 32); return off + 8 } |
| 48 | func _r16(buf: *u8, off: i64) -> i64 { return (buf[off] as i64) | ((buf[off + 1] as i64) << 8) } called by 1: uefi_verify |
| 49 | func _r32(buf: *u8, off: i64) -> i64 called by 1: uefi_verify |
| 53 | func uefi_emit(buf: *u8) -> i64 |
| 129 | func uefi_verify(buf: *u8) -> i64 |
| 149 | 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 } |
| 150 | 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 } |
| 151 | func u_fn(fd: i64, v: i64) -> i64 |
| 159 | func u_log(sz: i64, repro: i64, structural: i64, tamper: i64, verdict: *u8) -> i64 |
| 170 | func main(argc: i64, argv: *i64) -> i64 |