code wiki / _hdl_build / nx_gop_efi.nx

nx_gop_efi.nx

buildroot/runtime/_hdl_build/nx_gop_efi.nx

11133 B177 linesdepth 2pulls 2 transitivereach 1 importersview sourcekind librarytopic gop
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_gop_efi.nx nx_gop_efi_gate.nx

imports: nx_syscalls.nx

imported by: nx_gop_efi_gate.nx

structs

none

consts

23const PE_FILE_SIZE: i64 = 0x400
24const PE_MACHINE_AMD64: i64 = 0x8664
25const PE_OH_MAGIC_PEPLUS: i64 = 0x020B
26const PE_SUBSYSTEM_EFI_APP: i64 = 10
27const PE_CHAR_EXEC: i64 = 0x0002
28const PE_CHAR_LARGE_ADDR: i64 = 0x0020
29const PE_SECT_CODE_X_R: i64 = 0x60000020
30const FOFF_PE_SIG: i64 = 0x80
31const FOFF_COFF: i64 = 0x84
32const FOFF_OPT: i64 = 0x98
33const FOFF_SECT_TBL: i64 = 0x188
34const FOFF_TEXT: i64 = 0x200
35const RVA_TEXT: i64 = 0x1000
36const OPT_SUBSYS: i64 = 0x98 + 68
37const OPT_ENTRY: i64 = 0x98 + 16
38const IMG_BASE: i64 = 0x10000000
39const GOP_TEXT_VSIZE: i64 = 0x56 // 0x46 code (incl. the persist spin) + 16 GUID bytes
40const GOP_FILL_COLOR: i64 = 0x00AA8844 // a distinctive non-black solid (BGRX on metal)

functions

42func _w8(buf: *u8, off: i64, v: i64) -> i64 { buf[off] = (v & 0xff) as u8; return off + 1 }
43func _w16(buf: *u8, off: i64, v: i64) -> i64 { _w8(buf, off, v); _w8(buf, off + 1, v >> 8); return off + 2 }
called by 2: gop_efi_emitmain calls 1: _w8
44func _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 }
called by 2: _w64gop_efi_emit calls 1: _w8
45func _w64(buf: *u8, off: i64, v: i64) -> i64 { _w32(buf, off, v); _w32(buf, off + 4, v >> 32); return off + 8 }
called by 1: gop_efi_emit calls 1: _w32
46func _r16(buf: *u8, off: i64) -> i64 { return (buf[off] as i64) | ((buf[off + 1] as i64) << 8) }
called by 1: gop_efi_verify
47func _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
50func gop_guid_byte(i: i64) -> i64
60func gop_fill_mode(mode_ptr: i64, color: i64) -> i64
called by 1: main
77func gop_efi_emit(buf: *u8) -> i64
called by 1: main calls 5: _w16_w32_w8_w64gop_guid_byte
142func gop_efi_verify(buf: *u8) -> i64
called by 1: main calls 3: _r32_r16gop_guid_byte
161func gop_efi_never_brick(buf: *u8) -> i64
called by 1: main