Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/docs/A64-EFI.md # omega-mv Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance. Brought by drakestapleton Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / docs / A64-EFI.md` 132 lines · 10320 bytes Raw Blame History Rendered 1 # AArch64 UEFI backend (`target a64efi`) 2 3 Status (2026-11-12): **IMPLEMENTED; EXERCISED on one physical machine** (NVIDIA DGX Spark, American 4 Megatrends firmware, two recorded boots, see Evidence) and under virtualization (QEMU `virt` with KVM on a 5 Cortex-X925 host, EDK2 `QEMU_EFI.fd` 2024.02). One machine and one firmware are not a qualification. 6 7 The purpose is a program that runs on an Arm machine with nothing beneath it but the machine's own 8 firmware: no operating system and no driver. The first user is `ollm`, the Omega LLM of aien-train, 9 whose x86 UEFI image already boots an Intel iMac. 10 Omega LLM's `.om` sources now live in this repository at [`train/omega-llm/`](../train/omega-llm/) (unit 11 `ollm_a64efi` in `train/units.tsv`); the aien-train commits and paths cited below are the historical 12 record of the runs. 13 14 ## Selection 15 16 The exact first line `target a64efi` selects a PE32+ EFI application (machine 0xAA64) for a whole 17 program. Function mode is error 25. Without the line nothing changes: the default AArch64 Linux 18 output is byte for byte what it was (see Evidence). 19 20 ## What is different from the default AArch64 program 21 22 The instruction selection, register model and floats are the default backend's. Three things change. 23 24 1. **Addresses.** A Linux program is linked at fixed addresses (code at 0x400000, pools at 25 0x10000000). A UEFI image is loaded wherever the firmware has memory, so `mataddr` makes every 26 address relative: a global or stack-pool address is its offset plus X27, which the entry sets to 27 the base of the image's `.bss`; a `text` address is `ADRP` + `ADD` from the instruction that 28 needs it. Numbers are never relocated; only the address of a name is. 29 2. **Exit.** `ret` from `main`, `exit` and every trap branch to one return sequence at file offset 30 520 (`aefx`). It restores X19..X30, D8..D15 and the firmware's stack and returns `main`'s value as 31 the EFI_STATUS. A trap T returns `2^63 | (100 + T)`, as on x86efi. 32 3. **No host words.** Every Linux host word is error 25, `read` and `write` included, and so is a 33 run-time pool (`global NAME T *`). 34 35 Image layout, as x86efi's: headers in the first 512 bytes, `.text` from file offset 512 at RVA 36 4096 (its first 8 bytes are an empty base relocation block), `.bss` after it, zero filled by the 37 loader. The first 16 KiB of `.bss` are private (saved registers, ImageHandle, SystemTable), the 38 rest of the first 8 MiB is the Omega stack (X28 is its floor), the globals follow. 39 `DllCharacteristics` has NX_COMPAT: code is never written and data never executed. 40 41 ## Words 42 43 `efi OP ARG A OFF N` keeps x86efi's contract ([X86-EFI.md](X86-EFI.md)): OP a literal 0..14, A 44 writable `uchar` storage with `OFF + N` inside it (trap 3), result `ulong`, an error is 45 `2^63 | code`. On this target the operation itself is Omega code. The word compiles to a call of 46 the program's own `fn efirt op ulong arg ulong addr ulong n ulong to ulong`. A program that uses 47 `efi` without defining it is error 16 at the use; an `efirt` that does not take four `ulong` parameters 48 and give a `ulong` is error 9 at the use. It may be defined anywhere in the unit. `seed/a64efi/efirt.om` is that function: put it first in the 49 program. It implements 50 51 | OP | Operation | Status | 52 |---|---|---| 53 | 1 | key read (ConIn ReadKeyStroke) | EXERCISED (virtualized, no key pressed) | 54 | 2 | Boot Services Stall | EXERCISED (virtualized) | 55 | 10 | milliseconds since the first efi call (CNTVCT_EL0 / CNTFRQ_EL0) | EXERCISED (virtualized) | 56 | 12 | general file, x86efi's sub-operations and error codes | EXERCISED (virtualized) | 57 | 13 | console | EXERCISED (virtualized) | 58 | 14 | identity: FirmwareVendor, FirmwareRevision, SMBIOS as on x86efi; "leaf 0" is MIDR_EL1 | EXERCISED (virtualized); SMBIOS path NOT_RUN | 59 | 0, 3..9, 11 | info, Blt, time, entropy, network, pointer, boot file | not implemented: `2^63 | 3` | 60 61 `efirt.om` also defines `fn efiexit to void`. When a program has a function of that name, the return 62 sequence calls it once on every exit path, on a fresh stack; a function of that name with a 63 parameter or a result is error 9 (reported at the end of the unit, where the entry is emitted). `efirt.om` uses it to flush and close 64 a file left open, and then, when the boot volume holds `\OLLM\REBOOT.TXT`, to restart the machine 65 (ResetSystem, cold): a firmware that shows its menu after an application returns would otherwise 66 leave an unattended machine there. 67 68 The firmware words exist under `target a64efi` only; elsewhere the names are ordinary names. They 69 carry raw addresses, which no other Omega word does. That is deliberate: code with no operating 70 system under it has to call the firmware and, later, touch devices. 71 72 | Word | Meaning | 73 |---|---| 74 | `fwcall F A0 A1 A2 A3 A4 A5` | `BLR` F with A0..A5 in X0..X5 (AAPCS64), result X0. 64 KiB of the Omega stack must be free (trap 6) | 75 | `fwld ADDR W` | load W = 1, 2, 4 or 8 bytes at ADDR (any other W loads 1) | 76 | `fwst ADDR W V` | store the low W bytes of V at ADDR; result 0 | 77 | `fwsys K` | 0 ImageHandle, 1 SystemTable, 2 CNTVCT_EL0 (after ISB), 3 CNTFRQ_EL0, anything else MIDR_EL1 | 78 | `fwadr A OFF N` | the address of `A[OFF]`, with `OFF + N` inside A (trap 3); A may be a global | 79 | `fwop OP A B C` | one privileged AArch64 operation selected by OP, operands A B C, result X0. The OP table is the `FWOP_*` constants of `aienux/kernel/arm64/fwops.om` (DSB/ISB, TLBI VMALLE1IS, DC CIVAC/CVAC, IC IALLU, DAIF mask/unmask, WFE/SEV/WFI, system register read/write, SMC/HVC, EL2 to EL1, PSCI CPU_ON, LDAR/STLR, metadata, post-EBS guard) | 80 81 All are `ulong` in and out. Ids: efi 178, fwcall 250, fwld 251, fwst 252, fwsys 253, fwadr 254, fwop 255. They 82 are recognised by `fn kwa`, where a value starts, and are not in the keyword chain `fn kw`. Under this 83 target the seven names (`efi` and the six firmware words) are reserved: defining a variable, parameter, 84 global, constant, text or function with one of them is error 16, as for a keyword. Without the target 85 line they are ordinary names. 86 87 ## Limits known today 88 89 - A wrong address given to `fwld`, `fwst` or `fwcall` is not caught: there is no memory protection 90 beneath a UEFI application. 91 - `om2` may be the line after the target line (`om2` first is error 16 at line 2). The unit is then 92 OM-2 in language, without the AArch64 OM-2 code improvements: no global is pinned in a register, as 93 on the x86 targets. X18 is never touched, as UEFI asks: the OM-2 word `scrub` clears X19..X26 here and leaves X18 94 (on the Linux target it clears X18..X26). `efirt.om` compiles under both profiles. (At ``50485583`` 95 and before, the combination pinned globals in X18..X26, registers the entry never set, and `scrub` 96 cleared X18.) 97 - The firmware's interrupts run on the Omega stack while the program runs. 98 - The OM-2 word `dit` sets the processor's data-independent-timing bit, and the return to the firmware 99 does not put it back: a program that ends with `dit 1` in force returns with it set. The bit changes 100 how long some instructions take, never their results; clear it (`dit 0`) before returning if the 101 firmware should get the bit as it gave it. 102 103 ## Evidence (2026-11-12) 104 105 The compiler is `seed/out/omc` of the commit that carries this file, rebuilt from the seed chain by 106 `seed/omega-from-seed.sh` (self-rebuild fixpoint). 107 108 | Check | Result | 109 |---|---| 110 | Default output | gate17 (300 programs byte-identical to the pinned reference compiler) and the other `seed/host/check.sh` gates | 111 | `tests/a64efi/run.sh` | tests/x86efi's float, refusals, file, exit and ident programs compiled for this target and booted under QEMU virt + EDK2, an OM-2 program (`om2.om`), the compile-time refusals of this target and the default-target control: every check PASS, 1 NOT_RUN (efi 11 is x86efi only) | 112 | `ollm` acceptance job, virtualized | aien-train ``bb19fba9`` `native/omegallm` with `efirt.om` first, the 11 jobs of `tests/omegallm/efi-job.txt`: OUT.TXT body EQUAL to the AArch64 Linux reference (`efi-check.sh`), TR.BIN, HE.BIN and S.CK byte-identical, `fsck.vfat -n` clean; with `\OLLM\REBOOT.TXT` the machine restarts at exit | 113 | `ollm` with the 15.8M-parameter checkpoint, virtualized | two 120-token samples from the rung-10 checkpoint and its BPE merges complete | 114 | **Physical machine** | `evidence/a64efi-dgx-spark-`20261112`/`: the same `ollm` image plus `pciid.om`, started once by the firmware of a DGX Spark from its EFI system partition (`BootNext`), no operating system loaded. `OLLM DONE 11`; OUT.TXT body EQUAL to the Linux reference; TR.BIN, HE.BIN and S.CK byte-identical; the image then restarted the machine. `pciid.om` read, through the firmware's PCI I/O protocol and with no NVIDIA software, the display device `10de:2e12` at 000f:01:00.0 and two identity registers of its BAR 0 (offset 0: ``1bb000a1``, offset 0xA00: ``1bba1000``). The image (sha256 ``f2e31985`…ecaba`) was built by an earlier candidate of this branch; the committed `seed/out/omc` builds the same bytes from the same source | 115 116 Corrected on 2026-11-12, after an independent review of the guide written for this target: the 117 first landing (``d7fbd565``) compiled `read` and `write` under this target to a Linux system call 118 instead of refusing them, silently ignored a function the program named like one of the six words, 119 and did not check the shape of `efirt` (its parameter count, result and parameter types) or of 120 `efiexit`. The compiler of the commit that carries this sentence refuses 121 all of them (errors 25, 16 and 9; cases in `tests/a64efi/run.sh`). No program built so far used 122 them: the source of the image that ran on the DGX Spark (aien-train ``bb19fba9`` with `efirt.om` and 123 `evidence/a64efi-dgx-spark-`20261112`/pciid.om`) compiles to the same sha256, ``f2e31985`…ecaba`, with 124 this compiler. 125 126 A key press on the physical machine: EXERCISED once (2026-11-12, one session, two typed lines at 127 the DGX Spark's own keyboard, both answers equal to the Linux build's; aien-train 128 `evidence/OMEGALLM/a64efi/dgx-spark-ask/RESULT.txt` at main `7b4445ecaa2719cea458d591e4a90d9310bbdc17`). 129 130 NOT_RUN: any other machine or firmware; the 15.8M-parameter checkpoint on the physical machine (it 131 does not fit on that machine's 298 MiB EFI system partition); efi 14 SMBIOS on physical 132 firmware beyond the banner line; any device access other than the two register reads above.