interplane.Get Omega
Read in your language

aienux

Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.

Brought by drakestapleton

branch main Branches Tags History

aienux / native / boot / README.md

84 lines · 5623 bytes Raw Blame History Rendered
1# native/boot: minimal UEFI entry stub for the C kernel core
2
3This is the C path's UEFI entry (Lane 18). It is deliberately small:
4
5- `image.ld` writes the PE32+ header (AArch64, EFI application, one empty
6 base-relocation block) as linker data, so plain `ld` + `objcopy -O binary`
7 produce `BOOTAA64.EFI`. No outside EFI libraries or objcopy EFI targets.
8- `efi_entry.S` applies the image's own `R_AARCH64_RELATIVE` relocations
9 (the image is linked position independent), clears BSS and calls `efi_main`.
10- `efi.h` holds the UEFI types the stub needs, written from the UEFI spec.
11- `efi_main.c` prints the pre-exit report on ConOut (`report_kind: pre_exit`,
12 `aienos_commit: <full commit>` from the build-time `AIENOS_COMMIT`), finds
13 the ACPI 2.0 RSDP and the SPCR UART, takes the final memory map and calls
14 `ExitBootServices`, retrying when the map key goes stale, then jumps to
15 `ck_kernel_entry` with a `struct ck_handoff` (`handoff.h`): memory-map
16 copy, RSDP, firmware EL, firmware TTBR0/SCTLR, counter, commit.
17
18**A/B slots live in a separate loader, `slot_loader.c` -> `SLOTLDR.EFI` (P11
19cut 2a, gate N7, QEMU only; owner decision 2026-10-12: narrowly scoped to
20signed A/B image selection, boot-success tracking and rollback).** It sits in
21front of this stub as the boot volume's `EFI/BOOT/BOOTAA64.EFI`, reads the
22slots partition (`slot_format.h`), verifies both slots against owner keys
23baked in at build time, applies `slot_select.c` (bounded candidate tries,
24generation floor, never a boot loop), commits a candidate try before the jump,
25and chain-loads the chosen image (this stub + kernel, unchanged and
26byte-identical) with `LoadImage` + `StartImage`. Both slots invalid: it prints
27`slot_loader: recovery_required (...)` and returns to the firmware. It never
28touches UEFI variables, runtime services or `ExitBootServices`. Build:
29`make -C native/kernel slot-loader CK_SLOT_KEYS=<file>` (or the TEST-ONLY
30`CK_TEST_SLOT_KEY=1`, refused with `CK_HARDWARE_STAGING`); gate
31`scripts/qemu_ck_slot_loader_test.sh`; `docs/NATIVE_IMAGE_SLOTS.md`. This stub
32itself still has no slot logic, so the paragraph below stays true for it.
33
34**AIENOS-PI5-BOOT-0 diagnostic, `diag_main.c` -> `PI5DIAG.EFI`:** a separate,
35kernel-free UEFI application for the first Raspberry Pi 5 firmware boot. It
36prints the firmware vendor and revisions, the exception level, a memory map
37summary and every ConfigurationTable GUID (ACPI 1.0/2.0, SMBIOS, SMBIOS3, Device
38Tree b1b621d5-f19c-41a5-830b-d9152c69aae0, per edk2 `Guid/Fdt.h`) to ConOut, writes
39the same text to `\EFI\AIENOS\PI5BOOT0.TXT` on the volume it was loaded from.
40AIENOS-PI5-ACPI-0 added: every table the XSDT names, plus the DSDT from the FADT,
41is copied byte for byte to `\EFI\AIENOS\ACPI\<SIG>[n].BIN` (the k-th repeat of a
42signature gets the suffix k) with one `acpi_table:` report line each (length,
43address, checksum). It arms a 180 s firmware watchdog, waits about 5 s at the end
44and cold-resets through `ResetSystem`, the only runtime service it calls, so a
45one-shot tryboot run on the Pi falls back to the normal OS by itself. It never
46calls `ExitBootServices`.
47Build: `make -C native/kernel pi5-diag` (output `PI5DIAG.EFI`, copy to the card as
48`EFI/BOOT/BOOTAA64.EFI`); QEMU test: `scripts/qemu_ck_pi5_diag_test.sh`
49(`AIENOS_PI5_DIAG`; an emulator, nothing about a Pi 5 is qualified by it).
50
51**AIENOS-IMAC-BOOT-0 diagnostic, the same `diag_main.c` built for x86_64 ->
52`IMACDIAG.EFI`:** the first AIENOS code for an x86_64 machine, a 2017 iMac (Intel
53Core i5-7500, AMD Radeon Pro, Fusion Drive, `evidence/imac_boot0_2026-10-16/`; no T2 chip
54(hardware-unverified), so its firmware starts unsigned
55images). Same report and ACPI copies as the Pi diagnostic, plus `diag_x86.c`:
56CPUID identity, features, topology and CPU mode; SMBIOS type 0/1/2 identity (no
57serial numbers); every PCI function through configuration ports 0xCF8/0xCFC (reads
58only); every GOP mode; every whole-disk Block I/O device. It selects text mode
59through Apple's console-control protocol first (ConOut is invisible on a Mac
60otherwise), writes `\EFI\AIENOS\IMACBOOT.TXT`, holds the screen ~30 s and powers off
61through `ResetSystem(EfiResetShutdown)`. x86_64 pieces: `efi_entry_x86_64.S`
62(R_X86_64_RELATIVE relocations, Microsoft x64 entry), `image_x86_64.ld` (Machine
630x8664), compiled `-mabi=ms` so `efi.h` stays unannotated. Build:
64`make -C native/kernel imac-diag` (output `IMACDIAG.EFI`, copy to a FAT stick as
65`EFI/BOOT/BOOTX64.EFI`); QEMU test: `scripts/qemu_ck_imac_diag_test.sh`
66(`AIENOS_IMAC_DIAG`, q35 + OVMF; an emulator, nothing about the iMac is qualified by it).
67
68**Parked, not here:** signature checks, BootNext staging, rollback and the
69boot-report file. The Rust `aienos-boot` crate has BootNext staging and a QEMU
70rollback test but no A/B slot selection (ADR 0024 Q3); it is frozen and
71parked for the C path; this stub boots the kernel linked into the same image
72and nothing else. Rollback needs no loader code: the firmware's one-time BootNext
73starts this image once and the unchanged BootOrder brings the Default back;
74`scripts/qemu_ck_rollback_test.sh` (CK gate M0_ROLLBACK) checks that in QEMU
75with this image as the candidate.
76
77Build and test from `native/kernel` (see its README). QEMU qualifies nothing
78physical.
79
80The handoff record (`handoff.h`) is specified, with what is
81frozen, what the kernel must refuse and how rollback works without A/B slots,
82in `docs/BOOT_HANDOFF_CONTRACT.md` (SPEC, NOT_RUN; ADR 0024 Q3). The
83current magic is `CHANDOF3` (it adds the boot-disk model and the screen
84framebuffer); a kernel built for it refuses `CHANDOF1` and `CHANDOF2`.