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 / docs / BOOT_EVERYWHERE.md

142 lines · 10012 bytes Raw Blame History Rendered
1# The boot sequence everywhere (L266)
2
3What a person sees and hears when AienOS starts, on every machine: the night sky, two black holes circling and
4merging, a short rising chirp at the merger, then Allen. One module, the same timing, the same sound. This page
5says where it runs today, how fast, and what is still missing. Every number carries its command and exit code;
6claims are tagged OBSERVED (seen in a run), INFERRED (follows from code or a run, not seen directly) or UNKNOWN.
7
8## 1. One module
9
10| Part | File | Source |
11|---|---|---|
12| The night (stars, Milky Way, galaxies, the two black holes, the ripple) | `native/kernel/ui/night.c` | byte-identical to the iMac build `0930240` |
13| Allen's home on the screen (draws the night, then Allen) | `native/kernel/ui/allen_ui.c`, `mind.c`, `paint.c`, `allen_font.c` | same |
14| The chirp | `native/kernel/ui/chirp.c` | same |
15| Frame receipt and the night's clock for the sound | `native/kernel/ui/boot_show.c` | new (L266) |
16| aarch64 runner (Spark, Pi 5, the aarch64 VM) | `native/kernel/core/boot_screen.c` | new |
17| x86 runner (iMac, PC, the x86 VM) | `native/kernel/x86/boot_x86.c` | new |
18| VM screen (virtio-gpu 2D) | `native/kernel/dev/virtio_gpu.c` | new |
19| VM speakers (virtio-sound) | `native/kernel/dev/virtio_snd.c` | new, shared by both kernels |
20| Request core and the aarch64 PCI binding | `native/kernel/dev/virtio_q.c`, `virtio_bind.c` | new |
21
22Timing lives in two headers and nowhere else: `night.h` (`CK_NIGHT_*`: stars out by 6.8 s, holes at 2.6 s,
23spiral from 6.0 s, merger at 12.0 s, gone at 15.2 s) and `chirp.h` (`CK_CHIRP_*`: 600 ms sweep from 200 Hz to
241000 Hz ending at the merger, 300 ms ring).
25
26**The sound file and its licence.** There is no sound file. The chirp is computed at boot from the shape of a
27real gravitational-wave chirp (pitch rising as t^(-3/8), loudness as pitch^(2/3)), integer math, in
28`ui/chirp.c`. No recorded audio and no third-party material: its licence is this repository's. The same
29formula runs on every machine, so every machine plays the same samples (checked below: the sound a VM played
30matches the formula sample for sample).
31
32**How every image builds it in.** The ui files are compiled into every full aarch64 image and, with
33`CK_BOOT_SHOW=1`, into the x86 image. The night plays when the image is built with `CK_BOOT_SHOW=1`:
34`make -C native/kernel full CK_BOOT_SHOW=1` (aarch64, `$(OUT)/full-boot-show/BOOTAA64.EFI`) and
35`make -C native/kernel imac-kernel CK_BOOT_SHOW=1` (x86, `$(OUT)/IMACKERN-BOOT-SHOW.EFI`). The default stays
360 so the 32 emulator gates that use a screen keep their timing. The PC images (L260) and the aienos-run images
37(L261, L262, L265) should build with `CK_BOOT_SHOW=1` (ledger notes sent).
38
39**What the runner (aienos-run) must give the VM** so its window shows the real boot screen, not a web
40imitation:
41
42| | aarch64 VM | x86_64 VM |
43|---|---|---|
44| Screen | `-device virtio-gpu-pci,disable-legacy=on,iommu_platform=on` | `-device virtio-vga` |
45| Speakers | `-device virtio-sound-pci,audiodev=...,disable-legacy=on,iommu_platform=on` | `-device virtio-sound-pci,audiodev=...` |
46| IOMMU | `-M virt,iommu=smmuv3` (the kernel refuses device DMA it cannot confine) | none (that kernel has no IOMMU support yet; it says so) |
47| Window | QEMU's own display (`-display cocoa`/`gtk`/`sdl`) or VNC of that screen | same |
48
49A runner with its own virtual machine monitor (L262 KVM, L265 Virtualization.framework) needs a virtio-gpu and
50a virtio-sound device model with the same commands (section 3 lists exactly which).
51
52## 2. Measured
53
54How to read a receipt: the night lasts 15.2 s, which is 912 beats of a 60 Hz screen. A "dropped" beat is one
55where no new picture was ready. fps is frames drawn divided by 15.2 s.
56
57**Inside the VM (the aienos-run window).** `quiet-build bash scripts/qemu_ck_boot_show_test.sh <arch> <accel>`;
58kept files (serial log, mid-night screendump, captured WAV) in `target/boot-show/<arch>-<accel>/`.
59
60Three runs, each exit 0 and `AIENOS_CK_BOOT_SHOW: PASS` (OBSERVED, 2026-10-20, Spark, QEMU 8.2.2, 1280x800):
61
62| Image | Machine | Screen path | Frames in 15.2 s | Dropped of 912 | fps | Draw average | Slowest |
63|---|---|---|---|---|---|---|---|
64| aarch64 | virt, KVM (host speed) | virtio-gpu | 940 | 9 | 61.8 | 6.6 ms | 33.0 ms |
65| aarch64 | virt, TCG (every instruction emulated) | virtio-gpu | 419 | 501 | 27.5 | 33.2 ms | 257.2 ms |
66| x86_64 | q35 + OVMF, TCG | GOP framebuffer | 189 | 723 | 12.4 | 77.9 ms | 312.6 ms |
67
68Sound, same runs: the chirp starts at night 11.25 s (aarch64) and 11.31 s (x86_64); the virtio-sound device
69plays 11 to 12 periods of 100 ms with 0 starved and 0 refused, then stops cleanly. QEMU wrote what the guest
70played to a WAV file; 44936 of 44936 chirp frames are present, correlation with the host-made chirp 1.0000,
71largest sample difference 0 (all three runs). A mid-night screendump shows the sky drawn (0.30% of pixels lit,
72brightest 255).
73
74Reading it: with KVM the aarch64 image holds 60 Hz in the VM window. TCG emulates the CPU one instruction at a
75time, so its numbers say how slow emulation is, not how slow the code is; the x86_64 image can only run under TCG
76on this aarch64 host (no x86 KVM here), so x86_64 at 60 Hz in a VM is UNKNOWN until a run on an x86 host with
77WHPX, Hyper-V or KVM. The sound and picture are bit-identical in every run; only the pace differs. QEMU prints
78`audio: Could not create a backend for voice virtio-sound.in` in every run: the microphone side of the device has
79no backend in the gate, the playback side is the one measured, and nothing in the gate depends on capture.
80
81**The same drawing code on the Spark, no VM** (one core, real clock, memory instead of a screen):
82`BOOT_SHOW_SIZES="1280x800 1920x1080 3840x2160 5120x2880" quiet-build sh scripts/ck_boot_show_test.sh`,
83exit 0 (OBSERVED):
84
85| Screen | Frames | Dropped of 912 | fps | Draw average | Slowest |
86|---|---|---|---|---|---|
87| 1280x800 | 948 | 2 | 62.3 | 4.5 ms | 22.3 ms |
88| 1920x1080 | 947 | 3 | 62.3 | 5.8 ms | 15.6 ms |
89| 3840x2160 | 652 | 273 | 42.8 | 21.6 ms | 157.2 ms |
90| 5120x2880 | 422 | 490 | 27.7 | 35.1 ms | 97.0 ms |
91
92One Spark core keeps 60 Hz up to 1920x1080 and falls behind at 4K and 5K (OBSERVED). The VM runners cap the
93screen at 1920x1080 for that reason.
94
95**The iMac itself** (27-inch, 5K panel driven at 3840x2160, build `0930240`, the netboot report
96`imac-2d27001cbf587fae`, OBSERVED, not a run of this branch): "1126 frames by 20 s after Allen woke, average
9712.6 ms, slowest 46.8 ms (drawn by a secondary core)"; "the sky made in 476 ms (66 MiB drawing memory)"; the
98night on screen 15260 ms after power on. An average of 12.6 ms is inside one 60 Hz beat (16.7 ms), so on
99average the iMac holds 60 Hz at 3840x2160; the slowest frame (46.8 ms) missed about two beats (INFERRED from
100the report; that report does not count dropped beats, the receipt line on this branch does). The iMac
101splits each frame across its cores, the Spark fixture above uses one.
102
103UNKNOWN: the frame rate on the Spark's own screen, on a Pi 5 and on a PC; none has run this build yet.
104
105## 3. What the drivers use
106
107virtio-gpu (virtio 1.x 5.7): GET_DISPLAY_INFO, RESOURCE_CREATE_2D (B8G8R8X8), RESOURCE_ATTACH_BACKING (one
108entry), SET_SCANOUT, then per frame TRANSFER_TO_HOST_2D and RESOURCE_FLUSH of the whole picture. virtio-sound
109(5.14): PCM_INFO, PCM_SET_PARAMS (stereo, S16, 48 kHz, 100 ms periods, 400 ms buffer), PCM_PREPARE,
110PCM_START 150 ms before the chirp comes in, 100 ms transfers fed from the night's clock, PCM_STOP and
111PCM_RELEASE after 100 ms of quiet. Every command layout is checked against the virtio spec's Linux UAPI copy
112(`scripts/ck_virtio_av_test.sh`).
113
114## 4. The GPU path
115
116Today the night is drawn by the CPU: every pixel worked out from its position and the time, integer math,
117in strips (the iMac kernel splits a frame across its cores). What drawing it on a graphics chip would need:
118
1191. **A way to run work on the chip.** On the iMac's AMD Radeon Pro 580 the branch `feat/imac-gpu-shader`
120 (5b56323) has a GCN instruction encoder, PM4 command packets and four compute kernels (fill, blit, star
121 splat, and `bh_bend.c`, the black holes' light bending written to match `night.c` exactly), checked on a
122 host GCN interpreter only; nothing has run on the chip yet (INFERRED from its commit message and tests).
123 Missing: the ring buffer and doorbell bring-up, memory the chip can see, firmware loading for the compute
124 engine. On the Spark's GB10 the same work is the L198 to L207 driver lanes plus the GB10 launcher.
1252. **The split.** The stars, galaxies and Milky Way are the base layer and change slowly; the costly part per
126 frame is the light bending around the two holes (each pixel near a hole is moved by the deflection
127 formula) and the ripple ring. Those two map one pixel to one GPU thread with no communication between
128 pixels: the shape a GPU is built for. The CPU keeps the clock, the sound and the text.
1293. **The VM.** Inside aienos-run the guest has no real GPU. A virtio-gpu with 3D (virgl or Venus) would let
130 the guest hand shaders to the host's GPU; that is a separate driver (virtio-gpu 3D contexts) and is not
131 started.
1324. **Is it needed?** On the iMac the CPU path holds 60 Hz on average at 3840x2160 (section 2, INFERRED from a 12.6 ms average frame). A GPU path
133 is worth it for 5K panels, for doing more each frame, and for battery; it is not needed for the boot as it
134 is today.
135
136## 5. Open findings
137
138- **Dim hint text (from L282, OBSERVED there).** `ui/allen_ui.c` draws the hint line at alpha 150/256 and the faint
139 line at 110/256 over the night; measured contrast 3.26:1 and 1.98:1, under the 4.5:1 floor
140 (`docs/design/tokens/contrast.txt` on `feat/allen-design-system`). Drawing both at full alpha gives 7.73:1 and
141 6.02:1. Not changed here: `ui/` is kept byte-identical to the iMac build (`0930240`) so the iMac stack merges
142 cleanly; the one-line fix goes in once that stack has landed, or on the iMac lane if it moves first.