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

GitHub aien-dev/aienux#342 (code only)

closed derived a855df43f3a3fd54 #342

Imported from GitHub aien-dev/aienux#342 (code only)

GitHub's metadata for this pull request is unavailable: its state is DERIVED from the commits (merged: the head is reachable from this project's main; open: GitHub kept a merge ref; else closed).

Base 4e88f651a4694332a62d1ce370545eed69c4a657 · Head 9d3ff2e1eb39e5824ab1fc021db99b4d628d735c

Apply it

git checkout -b patch-a855df43f3a3fd54 4e88f651a4694332a62d1ce370545eed69c4a657
curl -fsSL https://interplane.io/drakestapleton/aienux/patches/a855df43f3a3fd54.patch | git am

Raw patch (mbox) · Diff

Provenance

This proposal is imported from GitHub; it is not signed by its author. Its import statement and source record:

github-import 1
aien-dev/aienux
342
9d3ff2e1eb39e5824ab1fc021db99b4d628d735c
{"kind":"github-import","owner":"aien-dev","repo":"aienux","number":342,"url":"https://github.com/aien-dev/aienux/pull/342","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:36:14Z","metadata":"unavailable","state_derived":true}

Changes

diff --git a/.crumb b/.crumb
index fa67ac40..718be415 100644
--- a/.crumb
+++ b/.crumb
@@ -33,27 +33,27 @@
           "purpose": "Directory docs. Purpose not yet described by a human."
         },
         {
-          "digest": "51dcba9cad880466f1cf88a3335e6524319493b0336adef7a78c848b308dbfba",
-          "last_commit": "2cdd37f",
+          "digest": "6cc9d9e29fa3474d7c9223f2da8e3a245524880d8c69ded50e5af4bdfc96d6a8",
+          "last_commit": "1adbd4b",
           "name": "native",
           "purpose": "Directory native. Purpose not yet described by a human."
         },
         {
-          "digest": "28d270da3473f2714195a890c9119ca967eed7eadc9070e0ea06555477937d14",
-          "last_commit": "2cdd37f",
+          "digest": "789ab6f9dbc46868a4b3e1541d7e66381b8241f58501ba512ead25c3a40fd471",
+          "last_commit": "1adbd4b",
           "name": "scripts",
           "purpose": "Directory scripts. Purpose not yet described by a human."
         }
       ],
-      "children_root": "sha256:a4fd7ec8ea39da9007554ea5d4f58b9805b4d4fd44ad400d408a6d160e1c1333",
-      "compiled_at": "2026-10-13T03:08:54Z",
+      "children_root": "sha256:801dea0a1eca64203458df980107b1b8edc62bd51358b561377f0e41a7926fa0",
+      "compiled_at": "2026-10-13T03:39:20Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:b1a98524e252ebf3fd21e42c3ae76d9738d8f97f3a0acf954736710a666d02b6",
+      "digest": "sha256:fdd9dca042265294f0810e6b006e5dc19d5485f95f4ef053fe865ddfcb944f82",
       "evidence_files": 156,
       "evidence_root": "sha256:cd53ab119be9de6ce28c4f5949b106c9622f1fe105611de3de21c3bce7932694",
       "files": 3119,
-      "generated_at_commit": "49ff77679a128f591a4c486755af20960874a4ae",
-      "source_tree": "sha256:d445410a08014faba071bef45768a1ad32588de58259c15a17aade534a2c256c"
+      "generated_at_commit": "1adbd4b7707bd586c253296ab4ca9f1e57015a9d",
+      "source_tree": "sha256:27a1e423ddad05c5e50d69ec032ce37be23bc9bede61825540648379c8527b21"
     },
     "owner_lane": "",
     "provenance": {
diff --git a/native/.crumb b/native/.crumb
index f7e10ad4..d32ea7c9 100644
--- a/native/.crumb
+++ b/native/.crumb
@@ -50,74 +50,74 @@
       "children": [
         {
           "digest": "7a5972d5e7135c13af527ba7bc91f6532fcebc206df0686e742e98c1050c6c29",
-          "last_commit": "74f638c",
+          "last_commit": "130aa20",
           "name": "argus",
           "purpose": "Directory native/argus. Purpose not yet described by a human."
         },
         {
-          "digest": "90408bbd282360e0d5c548617cf2a406bf50c9aa90760a008962c246c81594be",
-          "last_commit": "555e6d1",
+          "digest": "75239007e38138a416cfa36166d3c95837b7f0f4c1daab6182cd1d9c034dab14",
+          "last_commit": "1adbd4b",
           "name": "boot",
           "purpose": "Directory native/boot. Purpose not yet described by a human."
         },
         {
           "digest": "aaee52694510c1aea1e16ffd54201ce8e900742974d538bbf4640ab01d239872",
-          "last_commit": "74f638c",
+          "last_commit": "51c05da",
           "name": "capability",
           "purpose": "Directory native/capability. Purpose not yet described by a human."
         },
         {
           "digest": "44513be407ed44a29feac97bfec222e968f9f6415631f0cd62dc65a522c420e4",
-          "last_commit": "74f638c",
+          "last_commit": "a4bba0c",
           "name": "crypto",
           "purpose": "Directory native/crypto. Purpose not yet described by a human."
         },
         {
           "digest": "31584482d53c2b82d89a44a8a12f67c7f808f740d95ad5ad050b58bcca6b47aa",
-          "last_commit": "74f638c",
+          "last_commit": "2f9b95a",
           "name": "disk",
           "purpose": "Directory native/disk. Purpose not yet described by a human."
         },
         {
-          "digest": "378c7c0c28b51193fbfaa4f52fa5477b8653296f0868f0978a4079fe264b53ae",
-          "last_commit": "555e6d1",
+          "digest": "17da0efd01cac3b85c8eff9cb5aa97cf910ec231f27cafecc76e98fe67207055",
+          "last_commit": "1adbd4b",
           "name": "kernel",
           "purpose": "Directory native/kernel. Purpose not yet described by a human."
         },
         {
           "digest": "3883ad91cdafdb9158b14c4d8b11d4dcbfe1205ad8071c988b8f7c4b959a4004",
-          "last_commit": "74f638c",
+          "last_commit": "1feaca1",
           "name": "m5",
           "purpose": "Directory native/m5. Purpose not yet described by a human."
         },
         {
           "digest": "c91e9201f6ce9cb909ce3fadfa60d4869fc661db8d4266cd2c15e0688d384cf7",
-          "last_commit": "74f638c",
+          "last_commit": "4a116e5",
           "name": "net",
           "purpose": "Directory native/net. Purpose not yet described by a human."
         },
         {
           "digest": "295150763e0b19f9f74a3b49d679213467075e9682f1f23d0e5ea838872d20e1",
-          "last_commit": "74f638c",
+          "last_commit": "cea54be",
           "name": "sig",
           "purpose": "Directory native/sig. Purpose not yet described by a human."
         },
         {
           "digest": "eeec17e754d15d5723d77d953711620c568c160f47e6c90a4c927c85ec5bb32d",
-          "last_commit": "74f638c",
+          "last_commit": "22eb360",
           "name": "store",
           "purpose": "Directory native/store. Purpose not yet described by a human."
         }
       ],
-      "children_root": "sha256:169d12bbb10d00df758e72ed9b819b68fd768bd11ccd46d79c031ac1c106aae4",
-      "compiled_at": "2026-10-13T01:55:27Z",
+      "children_root": "sha256:138b39a0443ea9ebfc8bdbc791d629bd0ddbeca661f8764892187cac7476579e",
+      "compiled_at": "2026-10-13T03:39:20Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:51dcba9cad880466f1cf88a3335e6524319493b0336adef7a78c848b308dbfba",
+      "digest": "sha256:6cc9d9e29fa3474d7c9223f2da8e3a245524880d8c69ded50e5af4bdfc96d6a8",
       "evidence_files": 4,
       "evidence_root": "sha256:e410b845507e00568e15b51a5797af32a97e0e4b8ab4e8487bb7c98e7e0cf335",
       "files": 489,
-      "generated_at_commit": "555e6d1214f7922f640873cd70a06a0a64fcaade",
-      "source_tree": "sha256:153900796c2fa29ff664ec8cc01f40deff76d2c4210d1d6d4574f0fa9ce11359"
+      "generated_at_commit": "1adbd4b7707bd586c253296ab4ca9f1e57015a9d",
+      "source_tree": "sha256:7db1e9ecbf2a2958b627a710cb6ecb8e163d4a90b22124f875d569a44b465e64"
     },
     "owner_lane": "",
     "provenance": {
diff --git a/native/boot/.crumb b/native/boot/.crumb
index fd4a1312..2da3f47e 100644
--- a/native/boot/.crumb
+++ b/native/boot/.crumb
@@ -7,14 +7,14 @@
     "generated": {
       "children": [],
       "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
-      "compiled_at": "2026-10-13T01:55:27Z",
+      "compiled_at": "2026-10-13T03:39:20Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:90408bbd282360e0d5c548617cf2a406bf50c9aa90760a008962c246c81594be",
+      "digest": "sha256:75239007e38138a416cfa36166d3c95837b7f0f4c1daab6182cd1d9c034dab14",
       "evidence_files": 0,
       "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
       "files": 17,
-      "generated_at_commit": "555e6d1214f7922f640873cd70a06a0a64fcaade",
-      "source_tree": "sha256:378c422ef8696e0fc855d356d4d1b1376f3f8cc7f6e91d9e8242ee97ef7bc54b"
+      "generated_at_commit": "1adbd4b7707bd586c253296ab4ca9f1e57015a9d",
+      "source_tree": "sha256:fc305978f6fd520ff798166b6f39f01b59b9cf79e55a5f36b0be7c63e967e7a0"
     },
     "owner_lane": "",
     "provenance": {
diff --git a/native/boot/README.md b/native/boot/README.md
index 7c005d69..5eb48064 100644
--- a/native/boot/README.md
+++ b/native/boot/README.md
@@ -36,8 +36,14 @@ kernel-free UEFI application for the first Raspberry Pi 5 firmware boot. It
 prints the firmware vendor and revisions, the exception level, a memory map
 summary and every ConfigurationTable GUID (ACPI 1.0/2.0, SMBIOS, SMBIOS3, Device
 Tree b1b621d5-f19c-41a5-830b-d9152c69aae0, per edk2 `Guid/Fdt.h`) to ConOut, writes
-the same text to `\EFI\AIENOS\PI5BOOT0.TXT` on the volume it was loaded from,
-waits about 10 s and returns `EFI_SUCCESS`. It never calls `ExitBootServices`.
+the same text to `\EFI\AIENOS\PI5BOOT0.TXT` on the volume it was loaded from.
+AIENOS-PI5-ACPI-0 added: every table the XSDT names, plus the DSDT from the FADT,
+is copied byte for byte to `\EFI\AIENOS\ACPI\<SIG>[n].BIN` (the k-th repeat of a
+signature gets the suffix k) with one `acpi_table:` report line each (length,
+address, checksum). It arms a 180 s firmware watchdog, waits about 5 s at the end
+and cold-resets through `ResetSystem`, the only runtime service it calls, so a
+one-shot tryboot run on the Pi falls back to the normal OS by itself. It never
+calls `ExitBootServices`.
 Build: `make -C native/kernel pi5-diag` (output `PI5DIAG.EFI`, copy to the card as
 `EFI/BOOT/BOOTAA64.EFI`); QEMU test: `scripts/qemu_ck_pi5_diag_test.sh`
 (`AIENOS_PI5_DIAG`; an emulator, nothing about a Pi 5 is qualified by it).
diff --git a/native/boot/diag_main.c b/native/boot/diag_main.c
index a95c712a..48c385fb 100644
--- a/native/boot/diag_main.c
+++ b/native/boot/diag_main.c
@@ -1,12 +1,15 @@
-/* diag_main.c -- AIENOS-PI5-BOOT-0: a minimal AArch64 UEFI diagnostic.
+/* diag_main.c -- AIENOS-PI5-BOOT-0 / PI5-ACPI-0: a minimal AArch64 UEFI diagnostic.
  *
  * Prints what the firmware tells an application (vendor, revisions, EL, memory
- * map summary, every ConfigurationTable GUID) to ConOut and to a buffer, writes
- * the buffer to \EFI\AIENOS\PI5BOOT0.TXT on the volume the image was loaded
- * from, waits ~10 s so a person can read the screen, and returns EFI_SUCCESS.
- * It links no kernel and never calls ExitBootServices. Built as PI5DIAG.EFI
- * (make -C native/kernel pi5-diag); on the card it is EFI/BOOT/BOOTAA64.EFI.
- * Test: scripts/qemu_ck_pi5_diag_test.sh. */
+ * map summary, every ConfigurationTable GUID) to ConOut and to a buffer, copies
+ * every ACPI table the XSDT (and the FADT DSDT pointer) names, byte for byte, to
+ * \EFI\AIENOS\ACPI\<SIG>[n].BIN, writes the buffer to \EFI\AIENOS\PI5BOOT0.TXT
+ * on the volume the image was loaded from, waits ~5 s so a person can read the
+ * screen, and cold-resets the machine through ResetSystem (on the Pi this ends a
+ * one-shot tryboot run: the next boot is the normal OS). A 180 s firmware watchdog
+ * covers a hang before that. It links no kernel and never calls ExitBootServices.
+ * Built as PI5DIAG.EFI (make -C native/kernel pi5-diag); on the card it is
+ * EFI/BOOT/BOOTAA64.EFI. Test: scripts/qemu_ck_pi5_diag_test.sh. */
 #include <stdarg.h>
 #include <string.h>
 #include "efi.h"
@@ -57,6 +60,21 @@ static void say(const char *fmt, ...)
         conout->OutputString(conout, w);
 }
 
+
+/* Format into out (always NUL-terminated, truncated to cap - 1 bytes). */
+static void fmt_buf(char *out, size_t cap, const char *fmt, ...) __attribute__((format(printf, 3, 4)));
+static void fmt_buf(char *out, size_t cap, const char *fmt, ...)
+{
+    struct line l;
+    va_list ap;
+    l.n = 0;
+    va_start(ap, fmt);
+    ck_vformat(line_emit, &l, fmt, ap);
+    va_end(ap);
+    size_t n = l.n < cap - 1 ? l.n : cap - 1;
+    memcpy(out, l.b, n);
+    out[n] = 0;
+}
 struct named_guid {
     EFI_GUID g;
     const char *name;
@@ -115,15 +133,16 @@ static void memory_summary(EFI_BOOT_SERVICES *bs)
         (unsigned long long)(conv >> 8), (unsigned long long)key); /* 256 pages of 4 KiB per MiB */
 }
 
-static EFI_STATUS write_report(EFI_HANDLE image, EFI_SYSTEM_TABLE *st)
+/* Open (creating) a directory under the root of the volume the image came from. */
+static EFI_STATUS open_dir(EFI_HANDLE image, EFI_SYSTEM_TABLE *st, const char *path, EFI_FILE_PROTOCOL **dir)
 {
     static const EFI_GUID li_guid = EFI_LOADED_IMAGE_PROTOCOL_GUID_INIT;
     static const EFI_GUID fs_guid = EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID_INIT;
     EFI_BOOT_SERVICES *bs = st->BootServices;
     EFI_LOADED_IMAGE_PROTOCOL *li = 0;
     EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *fs = 0;
-    EFI_FILE_PROTOCOL *root = 0, *dir = 0, *f = 0;
-    CHAR16 w[32];
+    EFI_FILE_PROTOCOL *root = 0;
+    CHAR16 w[48];
     EFI_STATUS s = bs->HandleProtocol(image, &li_guid, (void **)&li);
     if (s != EFI_SUCCESS)
         return s;
@@ -133,41 +152,172 @@ static EFI_STATUS write_report(EFI_HANDLE image, EFI_SYSTEM_TABLE *st)
     s = fs->OpenVolume(fs, &root);
     if (s != EFI_SUCCESS)
         return s;
-    const uint64_t rw = EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE;
     /* Opening an existing directory with CREATE returns it. */
-    s = root->Open(root, &dir, wide(w, "\\EFI\\AIENOS"), rw | EFI_FILE_MODE_CREATE, EFI_FILE_DIRECTORY);
+    s = root->Open(root, dir, wide(w, path), EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE,
+                   EFI_FILE_DIRECTORY);
     root->Close(root);
-    if (s != EFI_SUCCESS)
-        return s;
-    /* A stale report is deleted first so the file holds exactly this run. */
-    if (dir->Open(dir, &f, wide(w, "PI5BOOT0.TXT"), rw, 0) == EFI_SUCCESS)
+    return s;
+}
+
+/* Replace dir\name with exactly len bytes of buf (a stale file is deleted first). */
+static EFI_STATUS write_file(EFI_FILE_PROTOCOL *dir, const char *name, const void *buf, uint64_t len)
+{
+    const uint64_t rw = EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE;
+    EFI_FILE_PROTOCOL *f = 0;
+    CHAR16 w[32];
+    if (dir->Open(dir, &f, wide(w, name), rw, 0) == EFI_SUCCESS)
         f->Delete(f);
     f = 0;
-    s = dir->Open(dir, &f, wide(w, "PI5BOOT0.TXT"), rw | EFI_FILE_MODE_CREATE, 0);
-    if (s == EFI_SUCCESS) {
-        uint64_t n = report_len;
-        s = f->Write(f, &n, report);
-        if (s == EFI_SUCCESS && n != report_len)
-            s = EFI_DEVICE_ERROR;
-        if (s == EFI_SUCCESS)
-            s = f->Flush(f);
-        f->Close(f);
-    }
+    EFI_STATUS s = dir->Open(dir, &f, wide(w, name), rw | EFI_FILE_MODE_CREATE, 0);
+    if (s != EFI_SUCCESS)
+        return s;
+    uint64_t n = len;
+    s = f->Write(f, &n, (void *)buf);
+    if (s == EFI_SUCCESS && n != len)
+        s = EFI_DEVICE_ERROR;
+    if (s == EFI_SUCCESS)
+        s = f->Flush(f);
+    f->Close(f);
+    return s;
+}
+
+static EFI_STATUS write_report(EFI_HANDLE image, EFI_SYSTEM_TABLE *st)
+{
+    EFI_FILE_PROTOCOL *dir = 0;
+    EFI_STATUS s = open_dir(image, st, "\\EFI\\AIENOS", &dir);
+    if (s != EFI_SUCCESS)
+        return s;
+    s = write_file(dir, "PI5BOOT0.TXT", report, report_len);
     dir->Close(dir);
     return s;
 }
 
+/* ---- ACPI table copy (ACPI 6.5: 5.2.5.3 RSDP, 5.2.6 header, 5.2.8 XSDT, 5.2.9 FADT) ---- */
+#define ACPI_MAX_TABLES 64
+#define ACPI_MAX_LEN (1u << 20)
+
+static uint32_t rd32(const uint8_t *p) { return (uint32_t)p[0] | (uint32_t)p[1] << 8 | (uint32_t)p[2] << 16 | (uint32_t)p[3] << 24; }
+static uint64_t rd64(const uint8_t *p) { return (uint64_t)rd32(p) | (uint64_t)rd32(p + 4) << 32; }
+
+static int acpi_sum_ok(const uint8_t *p, uint32_t len)
+{
+    uint8_t s = 0;
+    for (uint32_t i = 0; i < len; i++)
+        s += p[i];
+    return s == 0;
+}
+
+struct acpi_dump {
+    EFI_FILE_PROTOCOL *dir;
+    char seen[ACPI_MAX_TABLES][4];
+    unsigned nseen, copied, failed;
+};
+
+/* Copy one table to <SIG>.BIN, or <SIG><k>.BIN for the k-th repeat of a signature. */
+static void acpi_copy(struct acpi_dump *d, uint64_t addr, const char *via)
+{
+    const uint8_t *t = (const uint8_t *)(uintptr_t)addr;
+    char sig[5], name[16];
+    unsigned rep = 0;
+    if (!addr) {
+        say("acpi_table: NULL pointer via %s\n", via);
+        d->failed++;
+        return;
+    }
+    uint32_t len = rd32(t + 4);
+    for (int i = 0; i < 4; i++) {
+        char c = (char)t[i];
+        sig[i] = ((c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9')) ? c : '_';
+    }
+    sig[4] = 0;
+    if (len < 36 || len > ACPI_MAX_LEN) {
+        say("acpi_table: %s at 0x%llx bad length %u via %s\n", sig, (unsigned long long)addr, len, via);
+        d->failed++;
+        return;
+    }
+    for (unsigned i = 0; i < d->nseen; i++)
+        if (memcmp(d->seen[i], sig, 4) == 0)
+            rep++;
+    if (d->nseen < ACPI_MAX_TABLES)
+        memcpy(d->seen[d->nseen++], sig, 4);
+    if (rep)
+        fmt_buf(name, sizeof name, "%s%u.BIN", sig, rep);
+    else
+        fmt_buf(name, sizeof name, "%s.BIN", sig);
+    EFI_STATUS s = d->dir ? write_file(d->dir, name, t, len) : EFI_NOT_FOUND;
+    say("acpi_table: %s rev=%u len=%u at 0x%llx checksum=%s via %s file=%s %s\n", sig, t[8], len,
+        (unsigned long long)addr, acpi_sum_ok(t, len) ? "ok" : "BAD", via, name,
+        s == EFI_SUCCESS ? "written" : "WRITE_FAILED");
+    if (s == EFI_SUCCESS)
+        d->copied++;
+    else
+        d->failed++;
+}
+
+static void acpi_dump_all(EFI_HANDLE image, EFI_SYSTEM_TABLE *st)
+{
+    static const EFI_GUID acpi20 = EFI_ACPI_20_TABLE_GUID_INIT;
+    static struct acpi_dump d;
+    const uint8_t *rsdp = 0;
+    for (uint64_t i = 0; i < st->NumberOfTableEntries; i++)
+        if (memcmp(&st->ConfigurationTable[i].VendorGuid, &acpi20, sizeof acpi20) == 0)
+            rsdp = st->ConfigurationTable[i].VendorTable;
+    if (!rsdp || memcmp(rsdp, "RSD PTR ", 8) != 0 || rsdp[15] < 2) {
+        say("acpi: no ACPI 2.0 RSDP\n");
+        return;
+    }
+    uint64_t xsdt_addr = rd64(rsdp + 24);
+    say("acpi_rsdp: rev=%u oem=%c%c%c%c%c%c xsdt=0x%llx\n", rsdp[15], rsdp[9], rsdp[10], rsdp[11], rsdp[12],
+        rsdp[13], rsdp[14], (unsigned long long)xsdt_addr);
+    /* FAT creates one level per Open: make \EFI\AIENOS before \EFI\AIENOS\ACPI. */
+    EFI_FILE_PROTOCOL *parent = 0;
+    EFI_STATUS s = open_dir(image, st, "\\EFI\\AIENOS", &parent);
+    if (s == EFI_SUCCESS) {
+        parent->Close(parent);
+        s = open_dir(image, st, "\\EFI\\AIENOS\\ACPI", &d.dir);
+    }
+    if (s != EFI_SUCCESS) {
+        say("acpi: open \\EFI\\AIENOS\\ACPI FAILED status=0x%llx\n", (unsigned long long)s);
+        d.dir = 0;
+    }
+    acpi_copy(&d, xsdt_addr, "RSDP");
+    const uint8_t *x = (const uint8_t *)(uintptr_t)xsdt_addr;
+    uint32_t xlen = x ? rd32(x + 4) : 0;
+    if (!x || memcmp(x, "XSDT", 4) != 0 || xlen < 36 || xlen > ACPI_MAX_LEN) {
+        say("acpi: XSDT missing or malformed\n");
+    } else {
+        uint32_t n = (xlen - 36) / 8;
+        for (uint32_t i = 0; i < n && i < ACPI_MAX_TABLES; i++) {
+            uint64_t a = rd64(x + 36 + 8 * i);
+            acpi_copy(&d, a, "XSDT");
+            const uint8_t *t = (const uint8_t *)(uintptr_t)a;
+            if (a && memcmp(t, "FACP", 4) == 0) {
+                uint32_t flen = rd32(t + 4);
+                uint64_t dsdt = flen >= 148 ? rd64(t + 140) : 0; /* X_DSDT */
+                if (!dsdt && flen >= 44)
+                    dsdt = rd32(t + 40); /* DSDT */
+                acpi_copy(&d, dsdt, "FADT");
+            }
+        }
+    }
+    say("acpi_dump: copied=%u failed=%u\n", d.copied, d.failed);
+    if (d.dir)
+        d.dir->Close(d.dir);
+}
+
 EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *st)
 {
     EFI_BOOT_SERVICES *bs = st->BootServices;
     char vendor[80];
     uint64_t el;
     conout = st->ConOut;
+    /* 180 s: the firmware resets the machine if this app hangs (UEFI 2.x 7.5). */
     if (bs->SetWatchdogTimer)
-        bs->SetWatchdogTimer(0, 0, 0, 0);
+        bs->SetWatchdogTimer(180, 0x10000, 0, 0);
     __asm__ volatile("mrs %0, CurrentEL" : "=r"(el));
 
     say("AIENOS-PI5-BOOT-0\n");
+    say("milestone: AIENOS-PI5-ACPI-0\n");
     narrow(vendor, sizeof vendor, st->FirmwareVendor);
     say("firmware_vendor: %s\n", vendor);
     say("firmware_revision: 0x%x\n", st->FirmwareRevision);
@@ -182,6 +332,7 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *st)
             g->d4[4], g->d4[5], g->d4[6], g->d4[7], guid_name(g),
             (unsigned long long)(uintptr_t)st->ConfigurationTable[i].VendorTable);
     }
+    acpi_dump_all(image, st);
 
     say("AIENOS-PI5-BOOT-0 DONE\n"); /* last line of the file; the write result below is console only */
     EFI_STATUS s = write_report(image, st);
@@ -189,6 +340,11 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *st)
         say("report_file: written \\EFI\\AIENOS\\PI5BOOT0.TXT (%llu bytes)\n", (unsigned long long)report_len);
     else
         say("report_file: write FAILED status=0x%llx\n", (unsigned long long)s);
-    bs->Stall(10ull * 1000 * 1000);
+    bs->Stall(5ull * 1000 * 1000);
+    EFI_RUNTIME_SERVICES *rt = st->RuntimeServices;
+    say("reset: cold\n");
+    if (rt && rt->ResetSystem)
+        rt->ResetSystem(EfiResetCold, EFI_SUCCESS, 0, 0);
+    say("reset: ResetSystem returned\n");
     return EFI_SUCCESS;
 }
diff --git a/native/boot/efi.h b/native/boot/efi.h
index dbeb4d06..22a69a64 100644
--- a/native/boot/efi.h
+++ b/native/boot/efi.h
@@ -114,6 +114,18 @@ typedef struct {
     EFI_CONFIGURATION_TABLE *ConfigurationTable;
 } EFI_SYSTEM_TABLE;
 
+/* Runtime services: only ResetSystem is typed (UEFI 2.x section 8.5.1). */
+typedef enum { EfiResetCold, EfiResetWarm, EfiResetShutdown, EfiResetPlatformSpecific } EFI_RESET_TYPE;
+typedef struct {
+    EFI_TABLE_HEADER Hdr;
+    void *GetTime, *SetTime, *GetWakeupTime, *SetWakeupTime;
+    void *SetVirtualAddressMap, *ConvertPointer;
+    void *GetVariable, *GetNextVariableName, *SetVariable;
+    void *GetNextHighMonotonicCount;
+    void (*ResetSystem)(EFI_RESET_TYPE ResetType, EFI_STATUS ResetStatus, uint64_t DataSize, void *ResetData);
+} EFI_RUNTIME_SERVICES;
+_Static_assert(offsetof(EFI_RUNTIME_SERVICES, ResetSystem) == 0x68, "ResetSystem");
+
 /* Offsets fixed by the specification (LP64). */
 _Static_assert(offsetof(EFI_BOOT_SERVICES, AllocatePages) == 0x28, "AllocatePages");
 _Static_assert(offsetof(EFI_BOOT_SERVICES, GetMemoryMap) == 0x38, "GetMemoryMap");
diff --git a/native/kernel/.crumb b/native/kernel/.crumb
index 9ed3c3d5..51e26f82 100644
--- a/native/kernel/.crumb
+++ b/native/kernel/.crumb
@@ -46,68 +46,68 @@
       "children": [
         {
           "digest": "4c9da3fdaf762c784403ae3281c3a7e49b891596ed52ab27aaf62f2ea66c5502",
-          "last_commit": "74f638c",
+          "last_commit": "2ee61b4",
           "name": "arch",
           "purpose": "Directory native/kernel/arch. Purpose not yet described by a human."
         },
         {
           "digest": "90a737e620d9c654ae347aae26b4635b55477d4ef45c68ac10e983019f6af11c",
-          "last_commit": "74f638c",
+          "last_commit": "827e20f",
           "name": "artifact",
           "purpose": "Directory native/kernel/artifact. Purpose not yet described by a human."
         },
         {
           "digest": "5f5def88e2ef4bbd425e833cecb75d7cc805e7516a5128a88a7dea4e9b87cdd9",
-          "last_commit": "74f638c",
+          "last_commit": "2cdd37f",
           "name": "core",
           "purpose": "Directory native/kernel/core. Purpose not yet described by a human."
         },
         {
           "digest": "d7b81a8f888e7b4ca5337a5c9279671c33e1f4a70a7318ed20e1c5367c8a289b",
-          "last_commit": "74f638c",
+          "last_commit": "2cdd37f",
           "name": "dev",
           "purpose": "Directory native/kernel/dev. Purpose not yet described by a human."
         },
         {
           "digest": "283a167327166bcfd270869cc04a1a03ea21366248471464db7ef1cf37058ada",
-          "last_commit": "74f638c",
+          "last_commit": "3647654",
           "name": "include",
           "purpose": "Directory native/kernel/include. Purpose not yet described by a human."
         },
         {
           "digest": "8252fab960e4a3bb686f2e864b0d9a0571f43381d5006de2ff6c134c132ef092",
-          "last_commit": "74f638c",
+          "last_commit": "2bc7146",
           "name": "mm",
           "purpose": "Directory native/kernel/mm. Purpose not yet described by a human."
         },
         {
           "digest": "f2ef5ffe9eae8f9119dd302b55989b8b50f68def6ad03a2db227e28dbd270ddd",
-          "last_commit": "74f638c",
+          "last_commit": "2cdd37f",
           "name": "svc",
           "purpose": "Directory native/kernel/svc. Purpose not yet described by a human."
         },
         {
           "digest": "515f5d05394be70d66a845c3d5f2aecdd11e5402c189aefeb817577857ad0118",
-          "last_commit": "74f638c",
+          "last_commit": "2cdd37f",
           "name": "tests",
           "purpose": "Directory native/kernel/tests. Purpose not yet described by a human."
         },
         {
           "digest": "e17d2e0716b7121a785c5db6d437ecce7061b40741c97b4859cdc3021878646e",
-          "last_commit": "74f638c",
+          "last_commit": "2cdd37f",
           "name": "tools",
           "purpose": "Hosted (Linux-built) checkers for the native kernel, run by `make -C native/kernel test`; nothin"
         }
       ],
       "children_root": "sha256:6e029b6ca56fd468865463b2676ec83380dc39ac2541d45078cfb2e1e35f0669",
-      "compiled_at": "2026-10-13T01:55:27Z",
+      "compiled_at": "2026-10-13T03:39:20Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:378c7c0c28b51193fbfaa4f52fa5477b8653296f0868f0978a4079fe264b53ae",
+      "digest": "sha256:17da0efd01cac3b85c8eff9cb5aa97cf910ec231f27cafecc76e98fe67207055",
       "evidence_files": 0,
       "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
       "files": 317,
-      "generated_at_commit": "555e6d1214f7922f640873cd70a06a0a64fcaade",
-      "source_tree": "sha256:1a08e5fa84f1588acb5955ac65d6fbdfb2a2e1fe2c40eb5d2b0ce43207adb149"
+      "generated_at_commit": "1adbd4b7707bd586c253296ab4ca9f1e57015a9d",
+      "source_tree": "sha256:5fa209d14d2d416fc07a3afc91759bdf850729cc019687447e2aad73cbff9466"
     },
     "owner_lane": "",
     "provenance": {
diff --git a/native/kernel/Makefile b/native/kernel/Makefile
index af8d1a91..96c24375 100644
--- a/native/kernel/Makefile
+++ b/native/kernel/Makefile
@@ -1750,8 +1750,8 @@ $(PI5DIAG_DIR)/libc_min.o: $(KDIR)/core/libc_min.c
 	@mkdir -p $(dir $@)
 	$(KCC) $(KCFLAGS) -c -o $@ $<
 $(PI5DIAG_ELF): $(PI5DIAG_OBJS) $(BOOT)/image.ld
-	@if grep -nE -- '->(ExitBootServices|RuntimeServices)' $(BOOT)/diag_main.c; then \
-	  echo "diag_main.c calls a service the diagnostic must never call"; exit 1; fi
+	@if grep -nE -- '->ExitBootServices' $(BOOT)/diag_main.c || grep -nE -- 'rt->' $(BOOT)/diag_main.c | grep -vE -- 'rt->ResetSystem'; then \
+	  echo "diag_main.c calls a service the diagnostic must never call (only ResetSystem is allowed)"; exit 1; fi
 	$(call link_image,$@,$(PI5DIAG_OBJS))
 	@k=$$($(KNM) $@ | grep -E ' [TtDdBbRr] (ck_kernel_entry|kmain|ck_boot_model_load|ck_printf)$$' || true); \
 	if [ -n "$$k" ]; then echo "PI5DIAG links kernel objects: $$k"; rm -f $@; exit 1; fi
diff --git a/scripts/.crumb b/scripts/.crumb
index 9f0aea9d..4b201d9e 100644
--- a/scripts/.crumb
+++ b/scripts/.crumb
@@ -7,14 +7,14 @@
     "generated": {
       "children": [],
       "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
-      "compiled_at": "2026-10-13T01:55:27Z",
+      "compiled_at": "2026-10-13T03:39:20Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:28d270da3473f2714195a890c9119ca967eed7eadc9070e0ea06555477937d14",
+      "digest": "sha256:789ab6f9dbc46868a4b3e1541d7e66381b8241f58501ba512ead25c3a40fd471",
       "evidence_files": 0,
       "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
       "files": 90,
-      "generated_at_commit": "555e6d1214f7922f640873cd70a06a0a64fcaade",
-      "source_tree": "sha256:ef703dfd9de89381c148434f2e2826c9fc15f703e800297a9edd660e086371a0"
+      "generated_at_commit": "1adbd4b7707bd586c253296ab4ca9f1e57015a9d",
+      "source_tree": "sha256:8bd83b793ebfc69249908e7d6bd2c15733d4f7e85f62132d63bd33d7d61a0c48"
     },
     "owner_lane": "",
     "provenance": {
diff --git a/scripts/qemu_ck_pi5_diag_test.sh b/scripts/qemu_ck_pi5_diag_test.sh
index cd01da92..1c0bdc0b 100755
--- a/scripts/qemu_ck_pi5_diag_test.sh
+++ b/scripts/qemu_ck_pi5_diag_test.sh
@@ -4,8 +4,8 @@
 # about a Raspberry Pi 5.
 #
 # Builds PI5DIAG.EFI, puts it on a FAT image as EFI/BOOT/BOOTAA64.EFI, boots it in
-# QEMU AArch64 with AAVMF, waits for "AIENOS-PI5-BOOT-0 DONE" on the serial log,
-# stops QEMU, reads \EFI\AIENOS\PI5BOOT0.TXT back out of the image with mtools and
+# QEMU AArch64 with AAVMF (-no-reboot), waits for the app to cold-reset QEMU,
+# reads \EFI\AIENOS\PI5BOOT0.TXT and every \EFI\AIENOS\ACPI\*.BIN back with mtools and
 # checks: the title and vendor lines, a firmware table line (ACPI or Device Tree),
 # the memory summary, "DONE", and that the app wrote the file (serial says so).
 # Needs qemu-system-aarch64, AAVMF, mtools. Final line:
@@ -51,9 +51,10 @@ qemu-system-aarch64 -M virt -accel tcg -cpu max -m 1024 \
     -display none -nic none -serial file:"${work}/serial.log" -no-reboot &
 qpid=$!
 done_seen=0
+self_exit=0
 for _ in $(seq 1 ${AIENOS_PI5_DIAG_WAIT:-240}); do
-    if grep -aq "AIENOS-PI5-BOOT-0 DONE" "${work}/serial.log" 2>/dev/null; then done_seen=1; break; fi
-    kill -0 "${qpid}" 2>/dev/null || break
+    grep -aq "AIENOS-PI5-BOOT-0 DONE" "${work}/serial.log" 2>/dev/null && done_seen=1
+    if ! kill -0 "${qpid}" 2>/dev/null; then self_exit=1; break; fi
     sleep 1
 done
 kill "${qpid}" 2>/dev/null || true
@@ -67,6 +68,8 @@ chk() { # description, file, pattern
 tr -d '\r' <"${work}/serial.log" >"${work}/serial.txt" 2>/dev/null || : >"${work}/serial.txt"
 [[ ${done_seen} == 1 ]] || { echo "FAIL  serial never showed DONE"; fails=$((fails + 1)); }
 chk "serial: report_file written" "${work}/serial.txt" '^report_file: written '
+chk "serial: cold reset requested" "${work}/serial.txt" "^reset: cold\$"
+[[ ${self_exit} == 1 ]] && echo "PASS  QEMU stopped by itself after the reset (-no-reboot)" || { echo "FAIL  QEMU still running: ResetSystem did not reset"; fails=$((fails + 1)); }
 if mcopy -i "${img}" ::/EFI/AIENOS/PI5BOOT0.TXT "${work}/PI5BOOT0.TXT" 2>/dev/null; then
     echo "PASS  PI5BOOT0.TXT read back from the image"
     chk "file: title" "${work}/PI5BOOT0.TXT" '^AIENOS-PI5-BOOT-0$'
@@ -76,6 +79,23 @@ if mcopy -i "${img}" ::/EFI/AIENOS/PI5BOOT0.TXT "${work}/PI5BOOT0.TXT" 2>/dev/nu
     chk "file: memory summary" "${work}/PI5BOOT0.TXT" '^memory_map: entries=[0-9]+ conventional_mib=[0-9]+ map_key=0x[0-9a-f]+$'
     chk "file: ACPI or Device Tree table line" "${work}/PI5BOOT0.TXT" '^table [0-9]+: .* (ACPI 1\.0|ACPI 2\.0|Device Tree) at 0x'
     chk "file: DONE" "${work}/PI5BOOT0.TXT" '^AIENOS-PI5-BOOT-0 DONE$'
+    chk "file: milestone line" "${work}/PI5BOOT0.TXT" "^milestone: AIENOS-PI5-ACPI-0\$"
+    chk "file: RSDP line" "${work}/PI5BOOT0.TXT" "^acpi_rsdp: rev=[0-9]+ .* xsdt=0x[0-9a-f]+\$"
+    chk "file: MADT copied" "${work}/PI5BOOT0.TXT" "^acpi_table: APIC .* checksum=ok via XSDT file=APIC.BIN written\$"
+    chk "file: DSDT copied via FADT" "${work}/PI5BOOT0.TXT" "^acpi_table: DSDT .* checksum=ok via FADT file=DSDT.BIN written\$"
+    chk "file: no table failed" "${work}/PI5BOOT0.TXT" "^acpi_dump: copied=[0-9]+ failed=0\$"
+    # Every table file named in the report is on the image, starts with its
+    # signature and is exactly the length the report and its own header give.
+    while read -r sig len file; do
+        if mcopy -n -i "${img}" "::/EFI/AIENOS/ACPI/${file}" "${work}/${file}" 2>/dev/null \
+            && [[ "$(head -c 4 "${work}/${file}")" == "${sig}" ]] \
+            && [[ "$(stat -c %s "${work}/${file}")" == "${len}" ]] \
+            && [[ "$(od -An -tu4 -j4 -N4 "${work}/${file}" | tr -d " ")" == "${len}" ]]; then
+            echo "PASS  ACPI/${file}: signature ${sig}, ${len} bytes"
+        else
+            echo "FAIL  ACPI/${file}: missing, wrong signature or wrong length"; fails=$((fails + 1))
+        fi
+    done < <(sed -nE "s/^acpi_table: ([A-Z0-9_]{4}) rev=[0-9]+ len=([0-9]+) .* file=([A-Z0-9_]+\.BIN) written\$/\1 \2 \3/p" "${work}/PI5BOOT0.TXT")
     echo "---- PI5BOOT0.TXT ----"; cat "${work}/PI5BOOT0.TXT"; echo "----"
 else
     echo "FAIL  PI5BOOT0.TXT not found in the image"; fails=$((fails + 1))