code wiki / _hdl_build / nx_gop_efi.nx
nx_gop_efi.nx
buildroot/runtime/_hdl_build/nx_gop_efi.nx
about
nx_gop_efi.nx -- GX2: emit a real bootable UEFI app that draws the games' pixels on a real x86 screen via
the Graphics Output Protocol. The x86-on-metal companion to the silicon display rungs (SF1/SF2/SF4) and the
proven GOP blit logic (GX1, nx_gop_present). Mirrors nx_boot_uefi (subsystem-10 PE32+, hand-emitted PIC
x86-64, structural self-gate) -- its accepted scope is EMIT-proven here, BOOT-proven on OVMF/metal next rung.
THE EFI APP (.text, MS x64 ABI; on entry RCX=ImageHandle, RDX=SystemTable):
BootServices = [SystemTable + 0x60]
LocateProtocol(&GOP_GUID, NULL, &gop) -- LocateProtocol = [BootServices + 0x140] (read-only discovery)
Mode = [gop + 0x18]; FrameBufferBase = [Mode + 0x18]; FrameBufferSize = [Mode + 0x20]
rep stosd: fill FrameBufferSize/4 dwords at FrameBufferBase with a solid color -- the canonical first
GOP app; a non-black screen on metal proves: valid EFI image + SystemTable/BootServices/GOP navigated +
the linear framebuffer written. (Richer gradient/game-frame blit = GX1's nx_gop_present, proven; a later
rung emits its loop.)
NEVER-BRICK (#26): the app's ONLY persistent-relevant action is a VOLATILE-VRAM write (rep stosd to the GOP
FrameBufferBase). It calls LocateProtocol (read-only protocol discovery) and NOTHING ELSE -- no SetMode, no
Blt, no Set-Variable, no firmware/flash. So it cannot corrupt firmware/CMOS/NVRAM BY CONSTRUCTION, asserted
mechanically by gop_efi_verify (exactly one `call rax`, the FB-write present, no gop->SetMode/Blt call).
license_tier: ORIGINAL
dependencies 1 imports · 1 importers
imports: nx_syscalls.nx
imported by: nx_gop_efi_gate.nx
structs
| none |
consts
| 23 | const PE_FILE_SIZE: i64 = 0x400 |
| 24 | const PE_MACHINE_AMD64: i64 = 0x8664 |
| 25 | const PE_OH_MAGIC_PEPLUS: i64 = 0x020B |
| 26 | const PE_SUBSYSTEM_EFI_APP: i64 = 10 |
| 27 | const PE_CHAR_EXEC: i64 = 0x0002 |
| 28 | const PE_CHAR_LARGE_ADDR: i64 = 0x0020 |
| 29 | const PE_SECT_CODE_X_R: i64 = 0x60000020 |
| 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 GOP_TEXT_VSIZE: i64 = 0x56 // 0x46 code (incl. the persist spin) + 16 GUID bytes |
| 40 | const GOP_FILL_COLOR: i64 = 0x00AA8844 // a distinctive non-black solid (BGRX on metal) |
functions
| 42 | func _w8(buf: *u8, off: i64, v: i64) -> i64 { buf[off] = (v & 0xff) as u8; return off + 1 } |
| 43 | func _w16(buf: *u8, off: i64, v: i64) -> i64 { _w8(buf, off, v); _w8(buf, off + 1, v >> 8); return off + 2 } |
| 44 | func _w32(buf: *u8, off: i64, v: i64) -> i64 { _w8(buf, off, v); _w8(buf, off+1, v>>8); _w8(buf, off+2, v>>16); _w8(buf, off+3, v>>24); return off + 4 } |
| 45 | func _w64(buf: *u8, off: i64, v: i64) -> i64 { _w32(buf, off, v); _w32(buf, off + 4, v >> 32); return off + 8 } |
| 46 | func _r16(buf: *u8, off: i64) -> i64 { return (buf[off] as i64) | ((buf[off + 1] as i64) << 8) } called by 1: gop_efi_verify |
| 47 | func _r32(buf: *u8, off: i64) -> i64 { return (buf[off] as i64) | ((buf[off+1] as i64)<<8) | ((buf[off+2] as i64)<<16) | ((buf[off+3] as i64)<<24) } called by 1: gop_efi_verify |
| 50 | func gop_guid_byte(i: i64) -> i64 |
| 60 | func gop_fill_mode(mode_ptr: i64, color: i64) -> i64 called by 1: main |
| 77 | func gop_efi_emit(buf: *u8) -> i64 |
| 142 | func gop_efi_verify(buf: *u8) -> i64 |
| 161 | func gop_efi_never_brick(buf: *u8) -> i64 called by 1: main |