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#363 (code only)

closed derived c7365ab406cf5410 #363

Imported from GitHub aien-dev/aienux#363 (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 477f9e55217ded62c158c6e0fb8c23dcb6b615a8 · Head 8806cdca00403060106d357fa2e125f03a2ff194

Apply it

git checkout -b patch-c7365ab406cf5410 477f9e55217ded62c158c6e0fb8c23dcb6b615a8
curl -fsSL https://interplane.io/drakestapleton/aienux/patches/c7365ab406cf5410.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
363
8806cdca00403060106d357fa2e125f03a2ff194
{"kind":"github-import","owner":"aien-dev","repo":"aienux","number":363,"url":"https://github.com/aien-dev/aienux/pull/363","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:36:16Z","metadata":"unavailable","state_derived":true}

Changes

diff --git a/.crumb b/.crumb
index 13b8e325..dca64463 100644
--- a/.crumb
+++ b/.crumb
@@ -22,7 +22,7 @@
       "children": [
         {
           "digest": "e04ed38306b5ade84b4d72cfef14db7d58ab3952031806b43c8132a985a3d403",
-          "last_commit": "7df4066",
+          "last_commit": "477f9e5",
           "name": "crates",
           "purpose": "Directory crates. Purpose not yet described by a human."
         },
@@ -33,27 +33,27 @@
           "purpose": "Directory docs. Purpose not yet described by a human."
         },
         {
-          "digest": "9ae0942a460fa8108c8087cb4c7e30944198fa6e405816490aad5b37754b99f4",
-          "last_commit": "e7de707",
+          "digest": "f701a744b7c12122017b706922a142709762ee7cf9cb8a2e96b320cdc746cda3",
+          "last_commit": "1afe086",
           "name": "native",
           "purpose": "Directory native. Purpose not yet described by a human."
         },
         {
-          "digest": "7db7f93211cc0ea2a7dab1657474188f3040f71d568d0e41bc21b931cd28e6b5",
-          "last_commit": "e059bfe",
+          "digest": "e9b11cddd1fb52cca8537d081d709de7ee0eeb782dee9f61d2e6668aaaa41f59",
+          "last_commit": "1afe086",
           "name": "scripts",
           "purpose": "Directory scripts. Purpose not yet described by a human."
         }
       ],
-      "children_root": "sha256:e383c1ef8d2eba26822b417e687d88011aebcd83cf429ffafb46caf19a0ab1d7",
-      "compiled_at": "2026-10-13T15:46:48Z",
+      "children_root": "sha256:4d0f8c484edbe1c5ae38fb90ca86baff05cb0920ef9467b57d6a33c6f8eae313",
+      "compiled_at": "2026-10-13T16:14:20Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:ad2e48b9868cc8482da606133b85bbdce6256d01ea36d94b631a4277cdcb9f65",
+      "digest": "sha256:22c26c74159bea1b34417c509dbfe5bfbd0280a7f195fc294afb203210ce0169",
       "evidence_files": 156,
       "evidence_root": "sha256:cd53ab119be9de6ce28c4f5949b106c9622f1fe105611de3de21c3bce7932694",
-      "files": 3154,
-      "generated_at_commit": "7df4066ad6dbe14a05fbfc4408bcf48399b2b010",
-      "source_tree": "sha256:5ab3a23d83a0133b3334141fd79ef5094c4d6807bd982f1fb11960b36b7ec435"
+      "files": 3157,
+      "generated_at_commit": "1afe0869482d2986626d6855dfc8cabc5635bd12",
+      "source_tree": "sha256:e85d68c1f6b3053e2a20d410c5f61c0c4aa4bfe24c9bf1f7a80133a7a92b5418"
     },
     "owner_lane": "",
     "provenance": {
diff --git a/native/.crumb b/native/.crumb
index 2c806ff0..35af3527 100644
--- a/native/.crumb
+++ b/native/.crumb
@@ -79,8 +79,8 @@
           "purpose": "Directory native/disk. Purpose not yet described by a human."
         },
         {
-          "digest": "b82ed23dcdd3dffd17f7eb14e3c0ffef3a555ef87b7ae853ce2608bfd49f2cb7",
-          "last_commit": "e7de707",
+          "digest": "3e4a3e776de5423de68d540ff2f7646a3d93fe63e60d6aaa5960be81619a5b1a",
+          "last_commit": "1afe086",
           "name": "kernel",
           "purpose": "Directory native/kernel. Purpose not yet described by a human."
         },
@@ -109,15 +109,15 @@
           "purpose": "Directory native/store. Purpose not yet described by a human."
         }
       ],
-      "children_root": "sha256:bc04e169e5fbea8687d587e936760a5daf31dbb43d11d9d9c99bb121e538ae8f",
-      "compiled_at": "2026-10-13T15:35:38Z",
+      "children_root": "sha256:9192f6cc9e28f95bee8bf0225beaa2ac217fb0dc8cc8e90f14d15cc8eaaed6ba",
+      "compiled_at": "2026-10-13T16:14:20Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:9ae0942a460fa8108c8087cb4c7e30944198fa6e405816490aad5b37754b99f4",
+      "digest": "sha256:f701a744b7c12122017b706922a142709762ee7cf9cb8a2e96b320cdc746cda3",
       "evidence_files": 4,
       "evidence_root": "sha256:e410b845507e00568e15b51a5797af32a97e0e4b8ab4e8487bb7c98e7e0cf335",
-      "files": 518,
-      "generated_at_commit": "e7de707d8b32e94e16bb88267b3844426fba6cc2",
-      "source_tree": "sha256:1a9615ff741b86dc16f7aa09c2d90f11f0dc4a691a6ab4e51f9a4c055ccf33be"
+      "files": 521,
+      "generated_at_commit": "1afe0869482d2986626d6855dfc8cabc5635bd12",
+      "source_tree": "sha256:085034bc63d1733bd6c2d5b11992cd393ea5ce2f99b6da761461c7b36a3c1947"
     },
     "owner_lane": "",
     "provenance": {
diff --git a/native/kernel/.crumb b/native/kernel/.crumb
index 49d400b4..f523512e 100644
--- a/native/kernel/.crumb
+++ b/native/kernel/.crumb
@@ -57,14 +57,14 @@
           "purpose": "Directory native/kernel/artifact. Purpose not yet described by a human."
         },
         {
-          "digest": "daf8d6a0ed9f9c461cb237680425ccb6a151a669b96917b1d94d01ddd6abbd27",
-          "last_commit": "e7de707",
+          "digest": "5380497463eceb987455a1263f7c495d2fe161444f15fa0e1bf982dfdd8a1cc6",
+          "last_commit": "1afe086",
           "name": "core",
           "purpose": "Directory native/kernel/core. Purpose not yet described by a human."
         },
         {
-          "digest": "f860bfc274faf7b2ae08dbd4c51bf71f57825ed15725c35ae549c20cb01b9489",
-          "last_commit": "72278a4",
+          "digest": "2d859d69ee349616196cf33ef89e1f45522e3390a1a1e831127cb27eb3484c51",
+          "last_commit": "1afe086",
           "name": "dev",
           "purpose": "Directory native/kernel/dev. Purpose not yet described by a human."
         },
@@ -87,8 +87,8 @@
           "purpose": "Directory native/kernel/svc. Purpose not yet described by a human."
         },
         {
-          "digest": "a292c04c07dffdabb96cd51efc5b51956246ce72d4c855db53e4183e999f879d",
-          "last_commit": "e7de707",
+          "digest": "38abf882dd1520cee00e5e108dcb7879b6ed3e54023d3cc681be756a180e6760",
+          "last_commit": "1afe086",
           "name": "tests",
           "purpose": "Directory native/kernel/tests. Purpose not yet described by a human."
         },
@@ -99,15 +99,15 @@
           "purpose": "Hosted (Linux-built) checkers for the native kernel, run by `make -C native/kernel test`; nothin"
         }
       ],
-      "children_root": "sha256:25256d9d4ed73cca40a18ec219274e3b630e0c02091bb53bac4b8bd7b2184d8f",
-      "compiled_at": "2026-10-13T15:35:38Z",
+      "children_root": "sha256:d9f79d226b6bae9caf6e0e53bfc5c62818554228e62193381b4f1cb6bafb9658",
+      "compiled_at": "2026-10-13T16:14:20Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:b82ed23dcdd3dffd17f7eb14e3c0ffef3a555ef87b7ae853ce2608bfd49f2cb7",
+      "digest": "sha256:3e4a3e776de5423de68d540ff2f7646a3d93fe63e60d6aaa5960be81619a5b1a",
       "evidence_files": 0,
       "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
-      "files": 341,
-      "generated_at_commit": "e7de707d8b32e94e16bb88267b3844426fba6cc2",
-      "source_tree": "sha256:02fb92bb55f28f964c8a6f2aa9687427c98e9b7ad84dbd053d679351b648ddab"
+      "files": 344,
+      "generated_at_commit": "1afe0869482d2986626d6855dfc8cabc5635bd12",
+      "source_tree": "sha256:56c48fdf532b45ae3cfcaf681ba269946407647db2231bbdbbd696574b9c6e62"
     },
     "owner_lane": "",
     "provenance": {
diff --git a/native/kernel/Makefile b/native/kernel/Makefile
index 69915867..c68c3100 100644
--- a/native/kernel/Makefile
+++ b/native/kernel/Makefile
@@ -169,6 +169,22 @@ CK_PI5 := 1
 OUT ?= $(REPO)/target/native-kernel-pi5-infer
 CK_EXTRA_CFLAGS += -DCK_PI5_INFER=1 -DCK_INFER_DISK_ONLY=1
 endif
+# Pi 5 PCIe/RP1 enumerator image (CK_PI5_PCIE=1, "make pi5-pcie", AIENOS-PI5 network lane step 1): the plain Pi
+# image plus dev/pi5_pcie.c (read-only look at the BCM2712 PCIe2 root complex, RP1's config space and BARs, and
+# the inbound DMA window judged against the ADR 0020 bounce region) and dev/dma_window.c. Own OUT; the plain
+# pi5, pi5-store and pi5-infer images and the default image carry none of this code.
+CK_PI5_PCIE ?=
+ifneq ($(strip $(CK_PI5_PCIE)),)
+ifneq ($(strip $(CK_PI5_PCIE)),1)
+$(error CK_PI5_PCIE must be empty or 1)
+endif
+ifneq ($(strip $(CK_PI5_STORE)$(CK_PI5_INFER)$(CK_SERVICE)$(CK_HARDWARE_STAGING)),)
+$(error CK_PI5_PCIE is the Pi PCIe/RP1 enumerator image: it cannot be combined with CK_PI5_STORE, CK_PI5_INFER, CK_SERVICE or CK_HARDWARE_STAGING)
+endif
+CK_PI5 := 1
+OUT ?= $(REPO)/target/native-kernel-pi5-pcie
+CK_EXTRA_CFLAGS += -DCK_PI5_PCIE=1
+endif
 CK_PI5 ?=
 ifneq ($(strip $(CK_PI5)),)
 ifneq ($(strip $(CK_PI5)),1)
@@ -687,6 +703,9 @@ ifeq ($(strip $(CK_PI5)),1)
 CORE_C += $(BOOT)/efi_klog.c $(KDIR)/core/pi5.c $(KDIR)/core/pi5_marker.c $(KDIR)/dev/disk_part.c $(KDIR)/core/klog.c $(KDIR)/core/klog_slot.c \
 	$(KDIR)/dev/pi5_wdt.c $(KDIR)/dev/pi5_rng.c $(NATIVE)/disk/disk.c $(NATIVE)/disk/disk_sdhci.c
 endif
+ifeq ($(strip $(CK_PI5_PCIE)),1)
+CORE_C += $(KDIR)/dev/pi5_pcie.c $(KDIR)/dev/dma_window.c
+endif
 # P2 sealed-artifact loader: format/admission/receipt (artifact/), SHA-256
 # (argus), Ed25519/SHA-512 (sig). Built into the core so every image carries
 # the loader; the TEST-anchor qualification build is CK_SEED0B_TEST_ANCHOR=1.
@@ -1101,7 +1120,7 @@ HOST_SRCS := $(KDIR)/core/fmt.c $(KDIR)/core/acpi.c $(KDIR)/core/smmu.c $(KDIR)/
 	$(KDIR)/core/line_rx.c $(KDIR)/core/klog.c $(KDIR)/core/klog_slot.c $(KDIR)/core/cpufeat.c
 TESTS := test_fmt test_frames test_pt test_acpi test_acpi_dev test_heap test_smmu test_sched test_ipc test_artifact test_osc_unit test_osc_launch test_osc_admit test_entropy test_handoff test_fbcon test_osh_op \
 	test_continuity_codec test_continuity_resolve test_continuity_commit test_continuity_recovery test_continuity_geometry \
-	test_continuity_subject test_continuity_subject_provision test_lifecycle test_console_rx test_klog test_klog_slot test_pi5 test_pi5_marker test_pi5_rng test_cpufeat test_dma_window
+	test_continuity_subject test_continuity_subject_provision test_lifecycle test_console_rx test_klog test_klog_slot test_pi5 test_pi5_marker test_pi5_rng test_cpufeat test_dma_window test_pi5_pcie
 HCFLAGS := -std=gnu11 -O1 -g -Wall -Wextra -Werror -I$(KDIR)/core -I$(KDIR)/mm -I$(KDIR)/tests -I$(BOOT)
 SANFLAGS := -fsanitize=address,undefined -fno-sanitize-recover=all -fno-omit-frame-pointer
 
@@ -1841,6 +1860,10 @@ pi5-infer:
 pi5:
 	$(MAKE) CK_PI5=1 all
 
+# Raspberry Pi 5 PCIe/RP1 enumerator image (see CK_PI5_PCIE above): target/native-kernel-pi5-pcie/BOOTAA64.EFI
+pi5-pcie:
+	$(MAKE) CK_PI5_PCIE=1 all
+
 # ---- host checker for the AIENOS_CK_SCREEN gate (scripts/qemu_ck_screen_test.sh) ----
 FB_CHECK_TOOL := $(OUT)/host/ck_fb_check
 $(FB_CHECK_TOOL): $(KDIR)/tools/ck_fb_check.c $(KDIR)/core/fbcon.c $(KDIR)/core/fbcon.h $(KDIR)/core/font8x8.h
@@ -1924,3 +1947,24 @@ dma-window-mutants:
 	  if $(OUT)/host/test_dma_window_mut_$$m >/dev/null; then echo "MUTANT SURVIVED: $$m"; fail=1; else echo "mutant killed: $$m"; fi; \
 	done; test $$fail -eq 0
 .PHONY: test-dma-window dma-window-mutants
+
+# AIENOS-PI5 PCIe root complex / RP1 enumerator logic over a fake register file. Not the hardware.
+PI5PCIE_SRCS := $(KDIR)/dev/pi5_pcie.c
+PI5PCIE_DEPS := $(KDIR)/tests/test_pi5_pcie.c $(PI5PCIE_SRCS) $(KDIR)/tests/ck_test.h $(KDIR)/dev/pi5_pcie.h
+$(OUT)/host/test_pi5_pcie: $(PI5PCIE_DEPS)
+	@mkdir -p $(dir $@)
+	$(HOSTCC) $(HCFLAGS) -I$(KDIR)/dev -o $@ $< $(PI5PCIE_SRCS)
+$(OUT)/host-san/test_pi5_pcie: $(PI5PCIE_DEPS)
+	@mkdir -p $(dir $@)
+	$(HOSTCC) $(HCFLAGS) $(SANFLAGS) -I$(KDIR)/dev -o $@ $< $(PI5PCIE_SRCS)
+test-pi5-pcie: $(OUT)/host/test_pi5_pcie
+	$<
+# Each mutant removes one decision; the test must FAIL for every one.
+PI5PCIE_MUTANTS := NO_OUTSIDE NO_FULLCOVER NO_REMAP NO_INDEX NO_ALIGN NO_MERGE
+pi5-pcie-mutants:
+	@mkdir -p $(OUT)/host
+	@fail=0; for m in $(PI5PCIE_MUTANTS); do \
+	  $(HOSTCC) $(HCFLAGS) -DCK_PCIE_MUTANT_$$m -I$(KDIR)/dev -o $(OUT)/host/test_pi5_pcie_mut_$$m $(KDIR)/tests/test_pi5_pcie.c $(PI5PCIE_SRCS) || exit 1; \
+	  if $(OUT)/host/test_pi5_pcie_mut_$$m >/dev/null; then echo "MUTANT SURVIVED: $$m"; fail=1; else echo "mutant killed: $$m"; fi; \
+	done; test $$fail -eq 0
+.PHONY: test-pi5-pcie pi5-pcie-mutants pi5-pcie
diff --git a/native/kernel/core/.crumb b/native/kernel/core/.crumb
index 07b47883..aa331a3e 100644
--- a/native/kernel/core/.crumb
+++ b/native/kernel/core/.crumb
@@ -7,14 +7,14 @@
     "generated": {
       "children": [],
       "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
-      "compiled_at": "2026-10-13T15:35:38Z",
+      "compiled_at": "2026-10-13T16:14:20Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:daf8d6a0ed9f9c461cb237680425ccb6a151a669b96917b1d94d01ddd6abbd27",
+      "digest": "sha256:5380497463eceb987455a1263f7c495d2fe161444f15fa0e1bf982dfdd8a1cc6",
       "evidence_files": 0,
       "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
       "files": 55,
-      "generated_at_commit": "e7de707d8b32e94e16bb88267b3844426fba6cc2",
-      "source_tree": "sha256:2ec59e1cb98a38dadbcc6da840dff70d61ca4267b1eb066c7c194e963262254d"
+      "generated_at_commit": "1afe0869482d2986626d6855dfc8cabc5635bd12",
+      "source_tree": "sha256:43b8abcb55f6aa5786c7e53c1df1aa7707ee872288942fb7e1592de39669fe5c"
     },
     "owner_lane": "",
     "provenance": {
diff --git a/native/kernel/core/kmain.c b/native/kernel/core/kmain.c
index 9b0a69cb..90d53b18 100644
--- a/native/kernel/core/kmain.c
+++ b/native/kernel/core/kmain.c
@@ -14,6 +14,9 @@
 #include "cpufeat.h"
 #include "handoff_check.h"
 #include "frames.h"
+#ifdef CK_PI5_PCIE
+#include "../dev/pi5_pcie.h"
+#endif
 
 #define TTBR_BADDR_MASK 0x0000fffffffffffeull
 
@@ -240,6 +243,12 @@ static __attribute__((noreturn)) void ck_el1_main(void *arg)
                   : ent == CK_RNG_STUCK ? "RNDR repeated a 64-bit word"
                                         : "probe error");
 
+#ifdef CK_PI5_PCIE
+    /* Pi 5 PCIe2 root complex / RP1 enumerator (dev/pi5_pcie.c): read-only boot report, CK_PI5_PCIE image only. */
+    ck_set_stage("pi5_pcie");
+    ck_pi5pcie_report();
+#endif
+
 #ifdef CK_B7B_PROBE
     /* B7b preparation probe (core/smmu_svc.c), probe build only. */
     ck_b7b_probe();
diff --git a/native/kernel/dev/.crumb b/native/kernel/dev/.crumb
index 332b67cc..5b666c74 100644
--- a/native/kernel/dev/.crumb
+++ b/native/kernel/dev/.crumb
@@ -7,14 +7,14 @@
     "generated": {
       "children": [],
       "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
-      "compiled_at": "2026-10-13T15:00:51Z",
+      "compiled_at": "2026-10-13T16:14:20Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:f860bfc274faf7b2ae08dbd4c51bf71f57825ed15725c35ae549c20cb01b9489",
+      "digest": "sha256:2d859d69ee349616196cf33ef89e1f45522e3390a1a1e831127cb27eb3484c51",
       "evidence_files": 0,
       "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
-      "files": 34,
-      "generated_at_commit": "4b74ebf18be00aa0ae3cf512ff1368f1590ddc8a",
-      "source_tree": "sha256:db5a9017708120b2a57784caac8fef5f910e560f700fa1f7e4099beec6731b9c"
+      "files": 36,
+      "generated_at_commit": "1afe0869482d2986626d6855dfc8cabc5635bd12",
+      "source_tree": "sha256:195d1be27db135b904655d3d751d3ee080918bb3000ab1644e3bab19ce17e56d"
     },
     "owner_lane": "",
     "provenance": {
diff --git a/native/kernel/dev/pi5_pcie.c b/native/kernel/dev/pi5_pcie.c
new file mode 100644
index 00000000..d1a29eff
--- /dev/null
+++ b/native/kernel/dev/pi5_pcie.c
@@ -0,0 +1,413 @@
+/* pi5_pcie.c -- see pi5_pcie.h. The decision and parsing logic is hosted-testable
+ * (tests/test_pi5_pcie.c); the MMIO glue at the bottom is the CK_PI5_PCIE image only. */
+#include "pi5_pcie.h"
+
+/* TEST-only mutants (make pi5-pcie-mutants): each removes one decision and
+ * must make test_pi5_pcie FAIL. Host builds only; never part of an image. */
+#if defined(CK_PCIE_MUTANT_NO_OUTSIDE) || defined(CK_PCIE_MUTANT_NO_FULLCOVER) || \
+    defined(CK_PCIE_MUTANT_NO_REMAP) || defined(CK_PCIE_MUTANT_NO_INDEX) || defined(CK_PCIE_MUTANT_NO_ALIGN) || \
+    defined(CK_PCIE_MUTANT_NO_MERGE)
+#if !__STDC_HOSTED__
+#error "CK_PCIE_MUTANT_* are host test mutants only"
+#endif
+#endif
+
+static uint32_t le32(const uint8_t *p)
+{
+    return (uint32_t)p[0] | (uint32_t)p[1] << 8 | (uint32_t)p[2] << 16 | (uint32_t)p[3] << 24;
+}
+
+int ck_pi5pcie_cfg_read32(const struct ck_pi5pcie_io *io, uint8_t bus, uint8_t dev, uint8_t fn, uint32_t reg,
+                          uint32_t *out)
+{
+    if (!io || !io->rd || !io->wr || !out)
+        return CK_PI5PCIE_E_ARG;
+    if (reg >= 4096u || (reg & 3u) != 0 || fn > 7u)
+        return CK_PI5PCIE_E_ADDR;
+    if (bus == 0) { /* the root port only (PciSegmentLib.c:96-98) */
+        if (dev != 0 || fn != 0)
+            return CK_PI5PCIE_E_ADDR;
+        *out = io->rd(io->ctx, reg);
+        return CK_PI5PCIE_OK;
+    }
+    if (bus != 1 || dev != 0) /* one device on bus 1 (PciSegmentLib.c:101-104) */
+        return CK_PI5PCIE_E_ADDR;
+#ifndef CK_PCIE_MUTANT_NO_INDEX
+    io->wr(io->ctx, CK_PI5PCIE_EXT_CFG_INDEX, ((uint32_t)bus << 20) | ((uint32_t)dev << 15) | ((uint32_t)fn << 12));
+#endif
+    *out = io->rd(io->ctx, CK_PI5PCIE_EXT_CFG_DATA + reg);
+    return CK_PI5PCIE_OK;
+}
+
+int ck_pi5pcie_read_func(const struct ck_pi5pcie_io *io, uint8_t bus, uint8_t dev, uint8_t fn,
+                         struct ck_pi5pcie_func *f)
+{
+    uint32_t v, i;
+    int rc;
+    if (!f)
+        return CK_PI5PCIE_E_ARG;
+    *f = (struct ck_pi5pcie_func){0};
+    f->bus = bus;
+    f->dev = dev;
+    f->fn = fn;
+    rc = ck_pi5pcie_cfg_read32(io, bus, dev, fn, 0, &v);
+    if (rc)
+        return rc;
+    f->vendor = (uint16_t)(v & 0xffffu);
+    f->device = (uint16_t)(v >> 16);
+    if (f->vendor == 0xffffu || f->vendor == 0)
+        return 1;
+    if (ck_pi5pcie_cfg_read32(io, bus, dev, fn, 4, &v))
+        return CK_PI5PCIE_E_ADDR;
+    f->command = (uint16_t)(v & 0xffffu);
+    if (ck_pi5pcie_cfg_read32(io, bus, dev, fn, 8, &v))
+        return CK_PI5PCIE_E_ADDR;
+    f->class_code = v >> 8;
+    f->revision = (uint8_t)(v & 0xffu);
+    if (ck_pi5pcie_cfg_read32(io, bus, dev, fn, 0xc, &v))
+        return CK_PI5PCIE_E_ADDR;
+    f->header_type = (uint8_t)((v >> 16) & 0x7fu);
+    f->nbars = f->header_type == 0 ? 6 : f->header_type == 1 ? 2 : 0;
+    for (i = 0; i < f->nbars; i++)
+        if (ck_pi5pcie_cfg_read32(io, bus, dev, fn, 0x10 + 4 * i, &f->bar_raw[i]))
+            return CK_PI5PCIE_E_ADDR;
+    if (f->header_type == 1 && !ck_pi5pcie_cfg_read32(io, bus, dev, fn, 0x18, &v)) {
+        f->primary = (uint8_t)(v & 0xffu);
+        f->secondary = (uint8_t)((v >> 8) & 0xffu);
+        f->subordinate = (uint8_t)((v >> 16) & 0xffu);
+    }
+    return 0;
+}
+
+int ck_pi5pcie_rp1_check(int read_rc, const struct ck_pi5pcie_func *f)
+{
+    if (read_rc != 0 || !f)
+        return CK_PI5PCIE_RP1_ABSENT;
+    if (f->vendor != CK_PI5PCIE_RP1_VENDOR || f->device != CK_PI5PCIE_RP1_DEVICE)
+        return CK_PI5PCIE_RP1_MISMATCH;
+    return CK_PI5PCIE_RP1_OK;
+}
+
+uint32_t ck_pi5pcie_bar_decode(const uint32_t *raw, uint32_t idx, uint32_t nbars, struct ck_pi5pcie_bar *b)
+{
+    uint32_t r;
+    b->kind = CK_PI5PCIE_BAR_BAD;
+    b->prefetch = 0;
+    b->addr = 0;
+    if (!raw || idx >= nbars)
+        return 1;
+    r = raw[idx];
+    if (r == 0) {
+        b->kind = CK_PI5PCIE_BAR_EMPTY;
+        return 1;
+    }
+    if (r & 1u) {
+        b->kind = CK_PI5PCIE_BAR_IO;
+        b->addr = r & ~3u;
+        return 1;
+    }
+    b->prefetch = (uint8_t)((r >> 3) & 1u);
+    switch ((r >> 1) & 3u) {
+    case 0:
+        b->kind = CK_PI5PCIE_BAR_MEM32;
+        b->addr = r & ~0xfu;
+        return 1;
+    case 2:
+        if (idx + 1 >= nbars)
+            return 1; /* a 64-bit BAR needs its upper half: BAD */
+        b->kind = CK_PI5PCIE_BAR_MEM64;
+        b->addr = (uint64_t)(r & ~0xfu) | ((uint64_t)raw[idx + 1] << 32);
+        return 2;
+    default:
+        return 1; /* 1 = below-1MiB legacy, 3 = reserved */
+    }
+}
+
+int ck_pi5pcie_ib_size_decode(uint32_t code, uint64_t *size)
+{
+    if (code == 0)
+        return 0;
+    if (code >= 1 && code <= 21) {
+        *size = 1ull << (code + 15);
+        return 1;
+    }
+    if (code >= 0x1c && code <= 0x1f) {
+        *size = 1ull << (code - 0x1c + 12);
+        return 1;
+    }
+    return -1;
+}
+
+/* Register offsets: Bcm2712Pcie.h:161-185 (PCIE_IB_WIN_LO/HI, PCIE_IB_WIN_REMAP_LO/HI). */
+static uint32_t ib_lo(uint32_t i) { return i == 0 ? 0x4034u : 0x40d4u + (i - 1) * 8u; }
+static uint32_t ib_remap_lo(uint32_t i) { return i == 0 ? 0x40b4u : 0x410cu + (i - 1) * 8u; }
+
+int ck_pi5pcie_ib_read(const struct ck_pi5pcie_io *io, uint32_t idx, struct ck_pi5pcie_ibwin *w)
+{
+    uint32_t lo, hi, rlo, rhi;
+    uint64_t size = 0;
+    int sd;
+    if (!io || !io->rd || !w || idx >= CK_PI5PCIE_IB_WINDOWS)
+        return CK_PI5PCIE_E_ARG;
+    *w = (struct ck_pi5pcie_ibwin){0};
+    w->idx = idx;
+    lo = io->rd(io->ctx, ib_lo(idx));
+    hi = io->rd(io->ctx, ib_lo(idx) + 4);
+    rlo = io->rd(io->ctx, ib_remap_lo(idx));
+    rhi = io->rd(io->ctx, ib_remap_lo(idx) + 4);
+    sd = ck_pi5pcie_ib_size_decode(lo & CK_PI5PCIE_BAR_SIZE_MASK, &size);
+    w->enabled = sd != 0;
+    w->bus_base = ((uint64_t)hi << 32) | (lo & ~CK_PI5PCIE_BAR_SIZE_MASK);
+    w->remap_en = (uint8_t)(rlo & 1u);
+    w->cpu_base = (uint64_t)(rlo & 0xfffff000u) | ((uint64_t)(rhi & 0xffu) << 32);
+    if (sd > 0) {
+        w->size = size;
+        w->size_valid = 1;
+#ifndef CK_PCIE_MUTANT_NO_ALIGN
+        if ((w->bus_base & (size - 1)) != 0)
+            w->size_valid = 0; /* base not aligned to size: not a window the model understands */
+#endif
+    }
+    return 0;
+}
+
+struct iv {
+    uint64_t s, e; /* [s, e) */
+};
+
+int ck_pi5pcie_ib_verdict(const struct ck_pi5pcie_ibwin *w, uint32_t n, uint32_t unmodelled, uint64_t b_cpu,
+                          uint64_t b_size, struct ck_pi5pcie_dmav *out)
+{
+    struct iv v[CK_PI5PCIE_IB_WINDOWS];
+    uint32_t cnt = 0, i, j;
+    uint64_t b_end, reach = 0, inside = 0;
+    if (!out)
+        return CK_PI5PCIE_E_ARG;
+    *out = (struct ck_pi5pcie_dmav){0};
+    out->verdict = CK_PI5PCIE_DMA_UNKNOWN;
+    if ((n && !w) || n > CK_PI5PCIE_IB_WINDOWS || b_size == 0 || b_cpu > UINT64_MAX - b_size)
+        return CK_PI5PCIE_E_ARG;
+    b_end = b_cpu + b_size;
+    for (i = 0; i < n; i++) {
+        if (!w[i].enabled)
+            continue;
+        out->windows++;
+        if (!w[i].size_valid)
+            return 0; /* UNKNOWN */
+#ifndef CK_PCIE_MUTANT_NO_REMAP
+        if (!w[i].remap_en)
+            return 0; /* where the window lands in memory is not known: UNKNOWN */
+#endif
+        if (w[i].cpu_base > UINT64_MAX - w[i].size)
+            return 0;
+        v[cnt].s = w[i].cpu_base;
+        v[cnt].e = w[i].cpu_base + w[i].size;
+        cnt++;
+    }
+    if (cnt == 0) {
+        out->verdict = CK_PI5PCIE_DMA_NO_WINDOW;
+        return 0;
+    }
+    for (i = 1; i < cnt; i++) { /* insertion sort by start */
+        struct iv t = v[i];
+        for (j = i; j > 0 && v[j - 1].s > t.s; j--)
+            v[j] = v[j - 1];
+        v[j] = t;
+    }
+#ifndef CK_PCIE_MUTANT_NO_MERGE
+    for (i = 0, j = 0; i < cnt; i++) { /* union: overlapping or touching ranges merge */
+        if (j > 0 && v[i].s <= v[j - 1].e) {
+            if (v[i].e > v[j - 1].e)
+                v[j - 1].e = v[i].e;
+        } else {
+            v[j++] = v[i];
+        }
+    }
+    cnt = j;
+#endif
+    for (i = 0; i < cnt; i++) {
+        uint64_t lo = v[i].s > b_cpu ? v[i].s : b_cpu;
+        uint64_t hi = v[i].e < b_end ? v[i].e : b_end;
+        reach += v[i].e - v[i].s;
+        if (hi > lo)
+            inside += hi - lo;
+    }
+    out->reach_bytes = reach;
+    out->inside_bytes = inside;
+    out->outside_bytes = reach - inside;
+    if (inside == 0) {
+        out->verdict = CK_PI5PCIE_DMA_MISS;
+        return 0;
+    }
+#ifndef CK_PCIE_MUTANT_NO_FULLCOVER
+    if (inside < b_size) {
+        out->verdict = CK_PI5PCIE_DMA_PARTIAL;
+        return 0;
+    }
+#endif
+#ifndef CK_PCIE_MUTANT_NO_OUTSIDE
+    if (out->outside_bytes != 0) {
+        out->verdict = CK_PI5PCIE_DMA_WIDER;
+        return 0;
+    }
+#endif
+    out->verdict = unmodelled ? CK_PI5PCIE_DMA_UNKNOWN : CK_PI5PCIE_DMA_CONFINED;
+    return 0;
+}
+
+const char *ck_pi5pcie_verdict_name(int v)
+{
+    switch (v) {
+    case CK_PI5PCIE_DMA_NO_WINDOW: return "NO_WINDOW";
+    case CK_PI5PCIE_DMA_MISS: return "MISS";
+    case CK_PI5PCIE_DMA_PARTIAL: return "PARTIAL_COVER";
+    case CK_PI5PCIE_DMA_WIDER: return "NOT_CONFINED";
+    case CK_PI5PCIE_DMA_CONFINED: return "CONFINED";
+    default: return "UNKNOWN";
+    }
+}
+
+void ck_pi5pcie_door_decide(const uint8_t *t, size_t len, uint16_t segment, uint64_t rc_phys,
+                            struct ck_pi5pcie_door *out)
+{
+    size_t off;
+    out->why = CK_PI5PCIE_WHY_NO_MCFG;
+    out->base = 0;
+    out->bus_min = out->bus_max = 0;
+    if (!t)
+        return;
+    out->why = CK_PI5PCIE_WHY_MALFORMED;
+    if (len < 44u + 16u || t[0] != 'M' || t[1] != 'C' || t[2] != 'F' || t[3] != 'G' || le32(t + 4) != len ||
+        (len - 44u) % 16u != 0)
+        return;
+    out->why = CK_PI5PCIE_WHY_NO_SEGMENT;
+    for (off = 44; off + 16u <= len; off += 16u) {
+        const uint8_t *e = t + off;
+        uint64_t base = (uint64_t)le32(e) | ((uint64_t)le32(e + 4) << 32);
+        if ((uint16_t)(e[8] | (e[9] << 8)) != segment)
+            continue;
+        out->base = base;
+        out->bus_min = e[10];
+        out->bus_max = e[11];
+        if (base == rc_phys + CK_PI5PCIE_EXT_CFG_DATA)
+            out->why = CK_PI5PCIE_WHY_DATA_WINDOW;
+        else if (e[11] < 1 || e[10] > 1)
+            out->why = CK_PI5PCIE_WHY_NARROW;
+        else
+            out->why = CK_PI5PCIE_WHY_ECAM_CANDIDATE;
+        return;
+    }
+}
+
+const char *ck_pi5pcie_why_name(int why)
+{
+    switch (why) {
+    case CK_PI5PCIE_WHY_NO_MCFG: return "no_mcfg";
+    case CK_PI5PCIE_WHY_MALFORMED: return "mcfg_malformed";
+    case CK_PI5PCIE_WHY_NO_SEGMENT: return "no_segment_2_entry";
+    case CK_PI5PCIE_WHY_DATA_WINDOW: return "entry_is_the_4k_data_window";
+    case CK_PI5PCIE_WHY_NARROW: return "entry_bus_range_excludes_bus_1";
+    case CK_PI5PCIE_WHY_ECAM_CANDIDATE: return "ecam_candidate_unverified_not_used";
+    default: return "?";
+    }
+}
+
+#ifdef CK_PI5_PCIE
+#include "ck.h"
+#include "dma_window.h"
+
+static volatile uint8_t *rc;
+
+static uint32_t mm_rd(void *c, uint32_t off) { (void)c; return *(volatile uint32_t *)(rc + off); }
+static void mm_wr(void *c, uint32_t off, uint32_t v) { (void)c; *(volatile uint32_t *)(rc + off) = v; }
+
+static void print_bar(const struct ck_pi5pcie_func *f, uint32_t i, struct ck_pi5pcie_bar *b)
+{
+    static const char *const k[] = {"empty", "mem32", "mem64", "io", "bad"};
+    ck_printf("pi5_pcie: rp1 bar%u raw=0x%08x kind=%s%s addr=0x%llx size=unsized (read-only)\n", i, f->bar_raw[i],
+              k[b->kind], b->prefetch ? " prefetch" : "", (unsigned long long)b->addr);
+}
+
+void ck_pi5pcie_report(void)
+{
+    static const struct ck_pi5pcie_io io = {mm_rd, mm_wr, 0};
+    struct ck_pi5pcie_func root, rp1;
+    struct ck_pi5pcie_door door;
+    struct ck_pi5pcie_ibwin win[CK_PI5PCIE_IB_WINDOWS];
+    struct ck_pi5pcie_dmav dv;
+    struct ck_dmaw dw;
+    int rrc, rrp1, ver, n_en = 0;
+    uint32_t i, unmodelled = 0, idx_before;
+    uint64_t b_phys = 0;
+    void *bounce;
+    const uint8_t *mcfg = (const uint8_t *)ck_acpi_find("MCFG");
+
+    ck_printf("pi5_pcie: PCIe2 root complex 0x%llx (RP1 host), software-only DMA confinement (Pi 5, weaker than the Spark)\n",
+              (unsigned long long)CK_PI5PCIE_RC2_PHYS);
+    ck_pi5pcie_door_decide(mcfg, mcfg ? (size_t)le32(mcfg + 4) : 0, CK_PI5PCIE_SEGMENT, CK_PI5PCIE_RC2_PHYS, &door);
+    ck_printf("pi5_pcie: door=rc_window (index 0x%x, data 0x%x); ecam not used: %s mcfg_seg2_base=0x%llx bus=%u-%u\n",
+              CK_PI5PCIE_EXT_CFG_INDEX, CK_PI5PCIE_EXT_CFG_DATA, ck_pi5pcie_why_name(door.why),
+              (unsigned long long)door.base, door.bus_min, door.bus_max);
+    rc = (volatile uint8_t *)ck_mmio_try_map(CK_PI5PCIE_RC2_PHYS, CK_PI5PCIE_RC_BYTES);
+    if (!rc) {
+        ck_printf("pi5_pcie: FAIL map 0x%llx (refused); nothing read\n", (unsigned long long)CK_PI5PCIE_RC2_PHYS);
+        return;
+    }
+    idx_before = mm_rd(0, CK_PI5PCIE_EXT_CFG_INDEX);
+    rrc = ck_pi5pcie_read_func(&io, 0, 0, 0, &root);
+    if (rrc == 0)
+        ck_printf("pi5_pcie: root 00:00.0 %04x:%04x class=%06x rev=%02x type=%u sec=%u sub=%u cmd=0x%04x\n", root.vendor,
+                  root.device, root.class_code, root.revision, root.header_type, root.secondary, root.subordinate,
+                  root.command);
+    else
+        ck_printf("pi5_pcie: root 00:00.0 read rc=%d\n", rrc);
+    rrp1 = ck_pi5pcie_read_func(&io, 1, 0, 0, &rp1);
+    ver = ck_pi5pcie_rp1_check(rrp1, &rp1);
+    ck_printf("pi5_pcie: index_before=0x%08x index_now=0x%08x (selected 01:00.0)\n", idx_before,
+              mm_rd(0, CK_PI5PCIE_EXT_CFG_INDEX));
+    if (ver == CK_PI5PCIE_RP1_ABSENT)
+        ck_printf("pi5_pcie: rp1 01:00.0 ABSENT (read rc=%d vendor=%04x)\n", rrp1, rp1.vendor);
+    else {
+        ck_printf("pi5_pcie: rp1 01:00.0 %04x:%04x %s (expected %04x:%04x) class=%06x rev=%02x type=%u cmd=0x%04x\n",
+                  rp1.vendor, rp1.device, ver == CK_PI5PCIE_RP1_OK ? "MATCH" : "MISMATCH", CK_PI5PCIE_RP1_VENDOR,
+                  CK_PI5PCIE_RP1_DEVICE, rp1.class_code, rp1.revision, rp1.header_type, rp1.command);
+        for (i = 0; i < rp1.nbars;) {
+            struct ck_pi5pcie_bar b;
+            uint32_t used = ck_pi5pcie_bar_decode(rp1.bar_raw, i, rp1.nbars, &b);
+            print_bar(&rp1, i, &b);
+            i += used;
+        }
+    }
+    for (i = 0; i < CK_PI5PCIE_IB_WINDOWS; i++) {
+        if (ck_pi5pcie_ib_read(&io, i, &win[i]))
+            continue;
+        if (win[i].enabled) {
+            n_en++;
+            ck_printf("pi5_pcie: inbound win%u bus=0x%llx size=0x%llx cpu=0x%llx remap=%u valid=%u\n", i,
+                      (unsigned long long)win[i].bus_base, (unsigned long long)win[i].size,
+                      (unsigned long long)win[i].cpu_base, win[i].remap_en, win[i].size_valid);
+        }
+    }
+    if (mm_rd(0, CK_PI5PCIE_RC_BAR1_LO) & CK_PI5PCIE_BAR_SIZE_MASK)
+        unmodelled++;
+    if (mm_rd(0, CK_PI5PCIE_RC_BAR3_LO) & CK_PI5PCIE_BAR_SIZE_MASK)
+        unmodelled++;
+    ck_printf("pi5_pcie: inbound enabled=%d other_bar_windows=%u (gisb/scb; 0 = disabled)\n", n_en, unmodelled);
+    bounce = ck_dma_alloc(CK_DMAW_MAX_BYTES, CK_DMAW_MAX_BYTES, &b_phys);
+    if (!bounce || ck_dmaw_init(&dw, bounce, b_phys, CK_DMAW_MAX_BYTES) != CK_DMAW_OK) {
+        ck_printf("pi5_dma: FAIL no bounce window (alloc/init); verdict not computed\n");
+        return;
+    }
+    ck_pi5pcie_ib_verdict(win, CK_PI5PCIE_IB_WINDOWS, unmodelled, b_phys, CK_DMAW_MAX_BYTES, &dv);
+    ck_printf("pi5_dma: bounce cpu=0x%llx size=0x%llx (ADR 0020 rule 1, zeroed, bus==cpu per ck_dma_alloc)\n",
+              (unsigned long long)b_phys, (unsigned long long)dw.size);
+    ck_printf("pi5_dma: hw_window=%s reach=0x%llx inside=0x%llx outside=0x%llx\n", ck_pi5pcie_verdict_name(dv.verdict),
+              (unsigned long long)dv.reach_bytes, (unsigned long long)dv.inside_bytes,
+              (unsigned long long)dv.outside_bytes);
+    if (dv.verdict == CK_PI5PCIE_DMA_CONFINED)
+        ck_printf("pi5_dma: hardware window confines DMA to the bounce region\n");
+    else
+        ck_printf("pi5_dma: hardware window does NOT confine DMA to the bounce region (%s): software checks only\n",
+                  ck_pi5pcie_verdict_name(dv.verdict));
+}
+#endif
diff --git a/native/kernel/dev/pi5_pcie.h b/native/kernel/dev/pi5_pcie.h
new file mode 100644
index 00000000..f918240b
--- /dev/null
+++ b/native/kernel/dev/pi5_pcie.h
@@ -0,0 +1,179 @@
+/* pi5_pcie.h -- Raspberry Pi 5: how the kernel reaches the BCM2712 PCIe root
+ * complex that hosts the RP1 south bridge, plus a read-only enumerator.
+ * AIENOS-PI5 network lane, GEM-first plan step 1. NO GEM register code here.
+ *
+ * Everything below is READ-ONLY toward the hardware except one write: the
+ * root complex's config window index (CK_PI5PCIE_EXT_CFG_INDEX), which only
+ * selects which function the 4 KiB config window shows. No BAR sizing, no
+ * COMMAND change, no inbound window change.
+ *
+ * WHY THE ROOT COMPLEX'S OWN CONFIG WINDOW, NOT ECAM (decision, cited):
+ *  - RP1 sits behind PCIe controller 2 (segment 2, RC registers at
+ *    0x1000120000). Frozen firmware = aien-dev/rpi5-uefi tag v0.3 (c1ca184), which
+ *    pins worproject/edk2-platforms 8e1779b. In that tree:
+ *      Platform/RaspberryPi/RPi5/AcpiTables/Mcfg.aslc:26-48  the MCFG entry for
+ *        each segment has base = RC base + PCIE_EXT_CFG_DATA (0x8000) and bus
+ *        range 0..0: a 4 KiB window, not an ECAM that can address bus 1.
+ *      Platform/RaspberryPi/RPi5/Drivers/RpiPlatformDxe/ConfigTable.c:350-354
+ *        in the default (DEN0115) mode the MCFG signature is zeroed ("MCFG
+ *        must be hidden"); ConfigTable.h:23 makes NXPMX6_DEN0115 the default
+ *        and ConfigTable.c:301-308 clears the NXPMX6 half for non-Windows OSes.
+ *      Silicon/Broadcom/Bcm27xx/Library/Bcm2712PciSegmentLib/PciSegmentLib.c:
+ *        89-115 is the firmware's own access rule: bus 0 = the root port at the
+ *        RC base; bus > 0 = write bus/dev/fn to RC+0x9000 (INDEX), read the
+ *        function at RC+0x8000+reg (DATA). 96-104: only dev 0 fn 0 exists on
+ *        bus 0 and only dev 0 on bus 1.
+ *      Platform/RaspberryPi/RPi5/AcpiTables/PcieCommon.asi:30-38 (_INI) points
+ *        INDEX at 01:00.0 for OSes that cannot do more. The kernel does not
+ *        run AML (core/pi5.c:15-21), so it writes INDEX itself.
+ *  - So ECAM via MCFG is unusable here and the RC window is used always. The
+ *    decision function reports WHY, from the actual MCFG if the firmware
+ *    exposes one. Which MCFG the running firmware shows is UNVERIFIED until
+ *    the hardware run (the stored UEFI variable AcpiPcieEcamCompatMode can
+ *    change it).
+ *  - Linux reference reading only: drivers/pci/controller/pcie-brcmstb.c uses
+ *    the same INDEX/DATA pair; drivers/misc/rp1 is the RP1 platform driver.
+ *    Not re-read in this cut (UNVERIFIED against the Linux tree).
+ *
+ * Inbound window registers: edk2-platforms
+ * Silicon/Broadcom/Bcm27xx/Include/IndustryStandard/Bcm2712Pcie.h:97-104,
+ * 133-170, 196-201; encode rules in Bcm2712PciHostBridge.c:113-170 (size code
+ * and remap). The firmware programs one window per enabled RC: bus 0 -> CPU 0,
+ * 64 GiB (Bcm2712PciHostBridgeLib.c:157-159). That is the whole of RAM, so the
+ * hardware backstop of ADR 0020 rule 6 is NOT in place unless a later cut
+ * reprograms it. This file only reports; it never programs. */
+#ifndef AIENOS_CK_PI5_PCIE_H
+#define AIENOS_CK_PI5_PCIE_H
+#include <stddef.h>
+#include <stdint.h>
+
+#define CK_PI5PCIE_RC2_PHYS 0x1000120000ull /* BCM2712_BRCMSTB_PCIE2_BASE */
+#define CK_PI5PCIE_RC_BYTES 0xa000u         /* through INDEX (0x9000) + 0x1000 */
+#define CK_PI5PCIE_SEGMENT 2u
+#define CK_PI5PCIE_EXT_CFG_DATA 0x8000u
+#define CK_PI5PCIE_EXT_CFG_INDEX 0x9000u
+
+#define CK_PI5PCIE_RP1_VENDOR 0x1de4u /* Rp1.h:12 */
+#define CK_PI5PCIE_RP1_DEVICE 0x0001u /* Rp1.h:13 */
+
+enum {
+    CK_PI5PCIE_OK = 0,
+    CK_PI5PCIE_E_ADDR = -1, /* bus/dev/fn/reg the root complex cannot address */
+    CK_PI5PCIE_E_ARG = -2
+};
+
+/* Register access to the root complex block (offset from the RC base). A
+ * host test stands a fake register file behind it. */
+struct ck_pi5pcie_io {
+    uint32_t (*rd)(void *ctx, uint32_t off);
+    void (*wr)(void *ctx, uint32_t off, uint32_t v);
+    void *ctx;
+};
+
+/* One 32-bit config read. Addressable: bus 0 dev 0 fn 0 (the root port, at the
+ * RC base) and bus 1 dev 0 fn 0..7 (through INDEX/DATA). reg is dword aligned
+ * and < 4096. Anything else is E_ADDR and touches no register. */
+int ck_pi5pcie_cfg_read32(const struct ck_pi5pcie_io *io, uint8_t bus, uint8_t dev, uint8_t fn, uint32_t reg,
+                          uint32_t *out);
+
+struct ck_pi5pcie_func {
+    uint8_t bus, dev, fn;
+    uint16_t vendor, device;
+    uint32_t class_code; /* class << 16 | subclass << 8 | progif */
+    uint8_t revision, header_type, nbars;
+    uint16_t command;
+    uint32_t bar_raw[6];            /* as read, never sized */
+    uint8_t primary, secondary, subordinate; /* header type 1 only */
+};
+
+/* 0 = present, 1 = absent (vendor 0xffff or 0), < 0 = E_ADDR. */
+int ck_pi5pcie_read_func(const struct ck_pi5pcie_io *io, uint8_t bus, uint8_t dev, uint8_t fn,
+                         struct ck_pi5pcie_func *f);
+
+enum { CK_PI5PCIE_RP1_OK = 0, CK_PI5PCIE_RP1_ABSENT = 1, CK_PI5PCIE_RP1_MISMATCH = 2 };
+/* rc = return of ck_pi5pcie_read_func for 01:00.0. */
+int ck_pi5pcie_rp1_check(int read_rc, const struct ck_pi5pcie_func *f);
+
+enum { CK_PI5PCIE_BAR_EMPTY = 0, CK_PI5PCIE_BAR_MEM32 = 1, CK_PI5PCIE_BAR_MEM64 = 2, CK_PI5PCIE_BAR_IO = 3,
+       CK_PI5PCIE_BAR_BAD = 4 };
+struct ck_pi5pcie_bar {
+    uint8_t kind, prefetch;
+    uint64_t addr; /* as firmware left it; size unknown (not sized) */
+};
+/* Decode BAR register `idx` of `nbars`. Returns how many registers it used
+ * (1, or 2 for a 64-bit memory BAR). EMPTY = raw 0: unimplemented or
+ * unassigned, which unsized reading cannot tell apart. */
+uint32_t ck_pi5pcie_bar_decode(const uint32_t *raw, uint32_t idx, uint32_t nbars, struct ck_pi5pcie_bar *b);
+
+/* ---- inbound windows (PCIe -> memory) ---- */
+#define CK_PI5PCIE_IB_WINDOWS 8u /* PCIE_NUM_INBOUND_WINDOWS */
+#define CK_PI5PCIE_MISC_CTRL 0x4008u
+#define CK_PI5PCIE_RC_BAR1_LO 0x402cu /* GISB window: firmware disables it */
+#define CK_PI5PCIE_RC_BAR3_LO 0x403cu /* SCB window: firmware disables it */
+#define CK_PI5PCIE_BAR_SIZE_MASK 0x1fu
+
+struct ck_pi5pcie_ibwin {
+    uint32_t idx;
+    uint8_t enabled;    /* size code != 0 */
+    uint8_t size_valid; /* code decodes, base aligned to size */
+    uint8_t remap_en;   /* UBUS remap enable (bit 0) */
+    uint64_t bus_base, size, cpu_base;
+};
+/* Size code -> bytes. 1 = valid (*size set), 0 = disabled (code 0), -1 = a
+ * code the firmware never writes. 1..21 = 64 KiB..64 GiB, 0x1c..0x1f =
+ * 4 KiB..32 KiB (Bcm2712PciHostBridge.c:119-127). */
+int ck_pi5pcie_ib_size_decode(uint32_t code, uint64_t *size);
+int ck_pi5pcie_ib_read(const struct ck_pi5pcie_io *io, uint32_t idx, struct ck_pi5pcie_ibwin *w);
+
+enum {
+    CK_PI5PCIE_DMA_UNKNOWN = 0,   /* cannot tell (bad window, no remap, extra BAR windows) */
+    CK_PI5PCIE_DMA_NO_WINDOW = 1, /* no inbound window enabled: DMA cannot reach memory at all */
+    CK_PI5PCIE_DMA_MISS = 2,      /* windows exist but none reaches the bounce region */
+    CK_PI5PCIE_DMA_PARTIAL = 3,   /* only part of the bounce region is reachable */
+    CK_PI5PCIE_DMA_WIDER = 4,     /* bounce region reachable AND memory outside it: NOT confined */
+    CK_PI5PCIE_DMA_CONFINED = 5   /* reach == bounce region exactly */
+};
+struct ck_pi5pcie_dmav {
+    int verdict;
+    uint32_t windows;       /* enabled windows */
+    uint64_t reach_bytes;   /* union of CPU ranges the windows reach */
+    uint64_t inside_bytes;  /* of which inside the bounce region */
+    uint64_t outside_bytes; /* of which outside it */
+};
+/* ADR 0020 rule 6: does the hardware window confine inbound DMA to the bounce
+ * region [b_cpu, b_cpu+b_size)? Works in CPU address space (bus -> CPU through
+ * each window's remap). `unmodelled` = enabled windows this model does not
+ * cover (RC_BAR1/BAR3); they can only turn CONFINED into UNKNOWN. */
+int ck_pi5pcie_ib_verdict(const struct ck_pi5pcie_ibwin *w, uint32_t n, uint32_t unmodelled, uint64_t b_cpu,
+                          uint64_t b_size, struct ck_pi5pcie_dmav *out);
+const char *ck_pi5pcie_verdict_name(int v);
+
+/* ---- which door: ECAM via MCFG, or the RC's own window ---- */
+enum {
+    CK_PI5PCIE_WHY_NO_MCFG = 0,       /* firmware exposes no MCFG (hidden or absent) */
+    CK_PI5PCIE_WHY_MALFORMED = 1,
+    CK_PI5PCIE_WHY_NO_SEGMENT = 2,    /* MCFG has no entry for segment 2 */
+    CK_PI5PCIE_WHY_DATA_WINDOW = 3,   /* entry base is RC+0x8000: the 4 KiB window, not an ECAM */
+    CK_PI5PCIE_WHY_NARROW = 4,        /* entry bus range stops before bus 1 */
+    CK_PI5PCIE_WHY_ECAM_CANDIDATE = 5 /* looks like a real ECAM: still NOT used here (UNVERIFIED) */
+};
+struct ck_pi5pcie_door {
+    int why;
+    uint64_t base;
+    uint8_t bus_min, bus_max;
+};
+/* The kernel always uses the RC window (the only door implemented and
+ * proven by the firmware source); this explains why ECAM is not used. `mcfg`
+ * may be NULL; `len` is the table length field. */
+void ck_pi5pcie_door_decide(const uint8_t *mcfg, size_t len, uint16_t segment, uint64_t rc_phys,
+                            struct ck_pi5pcie_door *out);
+const char *ck_pi5pcie_why_name(int why);
+
+/* Boot report (CK_PI5_PCIE image only): maps RC2, prints one line per fact,
+ * allocates and zeroes the ADR 0020 bounce window and judges the hardware
+ * inbound window against it. Read-only apart from the INDEX select. */
+#ifdef CK_PI5_PCIE
+void ck_pi5pcie_report(void);
+#endif
+
+#endif
diff --git a/native/kernel/tests/.crumb b/native/kernel/tests/.crumb
index 8b941583..6d3f6be3 100644
--- a/native/kernel/tests/.crumb
+++ b/native/kernel/tests/.crumb
@@ -7,14 +7,14 @@
     "generated": {
       "children": [],
       "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
-      "compiled_at": "2026-10-13T15:35:38Z",
+      "compiled_at": "2026-10-13T16:14:20Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:a292c04c07dffdabb96cd51efc5b51956246ce72d4c855db53e4183e999f879d",
+      "digest": "sha256:38abf882dd1520cee00e5e108dcb7879b6ed3e54023d3cc681be756a180e6760",
       "evidence_files": 0,
       "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
-      "files": 158,
-      "generated_at_commit": "e7de707d8b32e94e16bb88267b3844426fba6cc2",
-      "source_tree": "sha256:c5fd8fd244860df29ffd1af7fdc7afe94a309a6594c6c8ff9aad8c42bb797ac2"
+      "files": 159,
+      "generated_at_commit": "1afe0869482d2986626d6855dfc8cabc5635bd12",
+      "source_tree": "sha256:b3759cb3eb229b32b32e8145f0acf3522be09ea711587a7979382b3b14764463"
     },
     "owner_lane": "",
     "provenance": {
diff --git a/native/kernel/tests/test_pi5_pcie.c b/native/kernel/tests/test_pi5_pcie.c
new file mode 100644
index 00000000..d3b1568b
--- /dev/null
+++ b/native/kernel/tests/test_pi5_pcie.c
@@ -0,0 +1,352 @@
+/* test_pi5_pcie.c -- Pi 5 PCIe root complex access, RP1 enumerator and inbound
+ * window verdict (dev/pi5_pcie.c) over a FAKE register file. Hosted: this
+ * proves the decisions, NOT the hardware. Run under ASan/UBSan and with each
+ * CK_PCIE_MUTANT_* (make pi5-pcie-mutants); every mutant must make it FAIL. */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "ck_test.h"
+#include "pi5_pcie.h"
+
+#define MiB (1ull << 20)
+#define GiB (1ull << 30)
+
+/* The fake root complex: one register page, a root-port config space at the
+ * base, and a 4 KiB data window that shows RP1 only while INDEX selects 01:00.0. */
+struct fake {
+    uint32_t regs[0xa000 / 4];
+    uint32_t rp1[1024];
+    uint32_t reads, writes, last_write_off, last_write_val;
+};
+
+static uint32_t f_rd(void *c, uint32_t off)
+{
+    struct fake *f = c;
+    f->reads++;
+    if (off >= 0x8000 && off < 0x9000) {
+        if (f->regs[0x9000 / 4] == 0x00100000u)
+            return f->rp1[(off - 0x8000) / 4];
+        return 0xffffffffu; /* nothing at the selected function */
+    }
+    return f->regs[off / 4];
+}
+
+static void f_wr(void *c, uint32_t off, uint32_t v)
+{
+    struct fake *f = c;
+    f->writes++;
+    f->last_write_off = off;
+    f->last_write_val = v;
+    f->regs[off / 4] = v;
+}
+
+static struct fake fk;
+static struct ck_pi5pcie_io io = {f_rd, f_wr, &fk};
+
+static void fresh(void)
+{
+    memset(&fk, 0, sizeof fk);
+    fk.regs[0] = 0x271214e4u;     /* root port: vendor 14e4 device 2712 */
+    fk.regs[1] = 0x00100006u;
+    fk.regs[2] = 0x06040001u;     /* class 060400 rev 01 */
+    fk.regs[3] = 0x00010000u;     /* header type 1 */
+    fk.regs[6] = 0x00010100u;     /* primary 0, secondary 1, subordinate 1 */
+    fk.rp1[0] = 0x00011de4u;      /* vendor 1de4 device 0001 */
+    fk.rp1[1] = 0x00000000u;
+    fk.rp1[2] = 0x02000000u | 0x1u; /* class 020000 rev 01 */
+    fk.rp1[3] = 0x00800000u;      /* header type 0, multifunction bit set */
+    fk.rp1[4] = 0;                /* BAR0: empty */
+    fk.rp1[5] = 0x1f000000u | 0x4u;          /* BAR1: mem64 */
+    fk.rp1[6] = 0x1u;                         /* BAR1 upper = 1 */
+}
+
+static void t_cfg_access(void)
+{
+    uint32_t v = 0;
+    fresh();
+    CHECK(ck_pi5pcie_cfg_read32(&io, 0, 0, 0, 0, &v) == 0 && v == 0x271214e4u);
+    CHECK(fk.writes == 0); /* bus 0 is the RC page: no INDEX write */
+    CHECK(ck_pi5pcie_cfg_read32(&io, 1, 0, 0, 0, &v) == 0 && v == 0x00011de4u);
+    CHECK(fk.writes == 1 && fk.last_write_off == 0x9000 && fk.last_write_val == 0x00100000u);
+    /* fn 1 selects a different function: INDEX is bus<<20 | fn<<12, shows nothing */
+    CHECK(ck_pi5pcie_cfg_read32(&io, 1, 0, 1, 0, &v) == 0 && v == 0xffffffffu);
+    CHECK(fk.last_write_val == 0x00101000u);
+    /* addresses the root complex cannot reach touch nothing */
+    fresh();
+    CHECK(ck_pi5pcie_cfg_read32(&io, 0, 1, 0, 0, &v) == CK_PI5PCIE_E_ADDR);
+    CHECK(ck_pi5pcie_cfg_read32(&io, 0, 0, 1, 0, &v) == CK_PI5PCIE_E_ADDR);
+    CHECK(ck_pi5pcie_cfg_read32(&io, 1, 1, 0, 0, &v) == CK_PI5PCIE_E_ADDR);
+    CHECK(ck_pi5pcie_cfg_read32(&io, 2, 0, 0, 0, &v) == CK_PI5PCIE_E_ADDR);
+    CHECK(ck_pi5pcie_cfg_read32(&io, 1, 0, 8, 0, &v) == CK_PI5PCIE_E_ADDR);
+    CHECK(ck_pi5pcie_cfg_read32(&io, 1, 0, 0, 4096, &v) == CK_PI5PCIE_E_ADDR);
+    CHECK(ck_pi5pcie_cfg_read32(&io, 1, 0, 0, 2, &v) == CK_PI5PCIE_E_ADDR);
+    CHECK(ck_pi5pcie_cfg_read32(&io, 1, 0, 0, 0, NULL) == CK_PI5PCIE_E_ARG);
+    CHECK(fk.reads == 0 && fk.writes == 0);
+}
+
+static void t_probe_rp1(void)
+{
+    struct ck_pi5pcie_func root, rp1;
+    int rc;
+    fresh();
+    rc = ck_pi5pcie_read_func(&io, 0, 0, 0, &root);
+    CHECK(rc == 0 && root.vendor == 0x14e4 && root.device == 0x2712 && root.class_code == 0x060400 &&
+          root.header_type == 1 && root.nbars == 2 && root.primary == 0 && root.secondary == 1 && root.subordinate == 1);
+    rc = ck_pi5pcie_read_func(&io, 1, 0, 0, &rp1);
+    CHECK(rc == 0 && rp1.vendor == 0x1de4 && rp1.device == 0x0001 && rp1.class_code == 0x020000 && rp1.revision == 1);
+    CHECK(rp1.header_type == 0 && rp1.nbars == 6); /* multifunction bit masked out of the type */
+    CHECK(ck_pi5pcie_rp1_check(rc, &rp1) == CK_PI5PCIE_RP1_OK);
+    /* wrong ID */
+    fk.rp1[0] = 0x00011de5u;
+    rc = ck_pi5pcie_read_func(&io, 1, 0, 0, &rp1);
+    CHECK(ck_pi5pcie_rp1_check(rc, &rp1) == CK_PI5PCIE_RP1_MISMATCH);
+    fk.rp1[0] = 0x00021de4u;
+    rc = ck_pi5pcie_read_func(&io, 1, 0, 0, &rp1);
+    CHECK(ck_pi5pcie_rp1_check(rc, &rp1) == CK_PI5PCIE_RP1_MISMATCH);
+    /* absent: all ones, then vendor 0 */
+    fk.rp1[0] = 0xffffffffu;
+    rc = ck_pi5pcie_read_func(&io, 1, 0, 0, &rp1);
+    CHECK(rc == 1 && ck_pi5pcie_rp1_check(rc, &rp1) == CK_PI5PCIE_RP1_ABSENT);
+    fk.rp1[0] = 0;
+    rc = ck_pi5pcie_read_func(&io, 1, 0, 0, &rp1);
+    CHECK(rc == 1 && ck_pi5pcie_rp1_check(rc, &rp1) == CK_PI5PCIE_RP1_ABSENT);
+    /* an address error is also "absent", never a match */
+    rc = ck_pi5pcie_read_func(&io, 3, 0, 0, &rp1);
+    CHECK(rc == CK_PI5PCIE_E_ADDR && ck_pi5pcie_rp1_check(rc, &rp1) == CK_PI5PCIE_RP1_ABSENT);
+}
+
+static void t_probe_needs_index(void)
+{
+    /* If INDEX points elsewhere first (firmware left it at another function),
+     * the probe must still land on 01:00.0 by writing INDEX itself. */
+    struct ck_pi5pcie_func rp1;
+    fresh();
+    fk.regs[0x9000 / 4] = 0x00000000u;
+    CHECK(ck_pi5pcie_read_func(&io, 1, 0, 0, &rp1) == 0 && rp1.vendor == 0x1de4);
+}
+
+static void t_bar(void)
+{
+    struct ck_pi5pcie_bar b;
+    uint32_t raw[6];
+    memset(raw, 0, sizeof raw);
+    CHECK(ck_pi5pcie_bar_decode(raw, 0, 6, &b) == 1 && b.kind == CK_PI5PCIE_BAR_EMPTY);
+    raw[0] = 0xe0000008u; /* mem32 prefetch */
+    CHECK(ck_pi5pcie_bar_decode(raw, 0, 6, &b) == 1 && b.kind == CK_PI5PCIE_BAR_MEM32 && b.prefetch && b.addr == 0xe0000000u);
+    raw[1] = 0x1f000000u | 0x4u; /* mem64, upper in raw[2] */
+    raw[2] = 0x1u;
+    CHECK(ck_pi5pcie_bar_decode(raw, 1, 6, &b) == 2 && b.kind == CK_PI5PCIE_BAR_MEM64 && !b.prefetch &&
+          b.addr == 0x11f000000ull);
+    raw[3] = 0xc001u; /* io */
+    CHECK(ck_pi5pcie_bar_decode(raw, 3, 6, &b) == 1 && b.kind == CK_PI5PCIE_BAR_IO && b.addr == 0xc000u);
+    raw[4] = 0x2u; /* legacy below-1MiB type: refused */
+    CHECK(ck_pi5pcie_bar_decode(raw, 4, 6, &b) == 1 && b.kind == CK_PI5PCIE_BAR_BAD);
+    raw[5] = 0x4u | 0x1000u; /* 64-bit at the last register has no upper half */
+    CHECK(ck_pi5pcie_bar_decode(raw, 5, 6, &b) == 1 && b.kind == CK_PI5PCIE_BAR_BAD);
+    CHECK(ck_pi5pcie_bar_decode(raw, 6, 6, &b) == 1 && b.kind == CK_PI5PCIE_BAR_BAD);
+    raw[1] = 0x4u | 0x1000u; /* type-1 header has two BARs: a 64-bit BAR at 1 is BAD */
+    CHECK(ck_pi5pcie_bar_decode(raw, 1, 2, &b) == 1 && b.kind == CK_PI5PCIE_BAR_BAD);
+}
+
+static void t_ib_size(void)
+{
+    uint64_t s = 0;
+    CHECK(ck_pi5pcie_ib_size_decode(0, &s) == 0);
+    CHECK(ck_pi5pcie_ib_size_decode(1, &s) == 1 && s == 64 * 1024);
+    CHECK(ck_pi5pcie_ib_size_decode(6, &s) == 1 && s == 2 * MiB);
+    CHECK(ck_pi5pcie_ib_size_decode(21, &s) == 1 && s == 64 * GiB);
+    CHECK(ck_pi5pcie_ib_size_decode(0x1c, &s) == 1 && s == 4096);
+    CHECK(ck_pi5pcie_ib_size_decode(0x1f, &s) == 1 && s == 32768);
+    CHECK(ck_pi5pcie_ib_size_decode(22, &s) == -1);
+    CHECK(ck_pi5pcie_ib_size_decode(0x1b, &s) == -1);
+    CHECK(ck_pi5pcie_ib_size_decode(0x20, &s) == -1);
+}
+
+static void t_ib_read(void)
+{
+    struct ck_pi5pcie_ibwin w;
+    /* what the frozen firmware programs: bus 0 -> CPU 0, 64 GiB, remap on */
+    fresh();
+    fk.regs[0x4034 / 4] = 21;
+    fk.regs[0x4038 / 4] = 0;
+    fk.regs[0x40b4 / 4] = 1;
+    fk.regs[0x40b8 / 4] = 0;
+    CHECK(ck_pi5pcie_ib_read(&io, 0, &w) == 0 && w.enabled && w.size_valid && w.remap_en && w.size == 64 * GiB &&
+          w.bus_base == 0 && w.cpu_base == 0);
+    /* a 2 MiB window at bus 0x40200000 mapped to CPU 0x1_4020_0000 */
+    fk.regs[0x40d4 / 4] = 0x40200000u | 6;
+    fk.regs[0x40d8 / 4] = 0;
+    fk.regs[0x410c / 4] = 0x40200000u | 1;
+    fk.regs[0x4110 / 4] = 1;
+    CHECK(ck_pi5pcie_ib_read(&io, 1, &w) == 0 && w.enabled && w.size_valid && w.size == 2 * MiB &&
+          w.bus_base == 0x40200000u && w.cpu_base == 0x140200000ull);
+    /* window 7 lives at its own offsets and does not alias window 6 */
+    fk.regs[0x4104 / 4] = 0x80000000u | 16; /* code 16 = 2 GiB */
+    fk.regs[0x413c / 4] = 1;
+    CHECK(ck_pi5pcie_ib_read(&io, 7, &w) == 0 && w.enabled && w.size == 2 * GiB && w.bus_base == 0x80000000u && w.remap_en);
+    CHECK(ck_pi5pcie_ib_read(&io, 6, &w) == 0 && !w.enabled);
+    /* disabled, misaligned, bad code, remap off */
+    CHECK(ck_pi5pcie_ib_read(&io, 2, &w) == 0 && !w.enabled && !w.size_valid);
+    fk.regs[0x40dc / 4] = 0x00010000u | 6; /* 2 MiB window at a 64 KiB aligned base */
+    CHECK(ck_pi5pcie_ib_read(&io, 2, &w) == 0 && w.enabled && !w.size_valid);
+    fk.regs[0x40e4 / 4] = 22;
+    CHECK(ck_pi5pcie_ib_read(&io, 3, &w) == 0 && w.enabled && !w.size_valid);
+    CHECK(ck_pi5pcie_ib_read(&io, 8, &w) == CK_PI5PCIE_E_ARG);
+}
+
+static struct ck_pi5pcie_ibwin mk(uint64_t bus, uint64_t size, uint64_t cpu, int remap)
+{
+    struct ck_pi5pcie_ibwin w = {0};
+    w.enabled = 1;
+    w.size_valid = 1;
+    w.remap_en = (uint8_t)remap;
+    w.bus_base = bus;
+    w.size = size;
+    w.cpu_base = cpu;
+    return w;
+}
+
+#define B 0x4600000ull /* bounce region used below: 2 MiB at 0x4600000 */
+#define BS (2 * MiB)
+
+static void t_verdict(void)
+{
+    struct ck_pi5pcie_ibwin w[8];
+    struct ck_pi5pcie_dmav d;
+    memset(w, 0, sizeof w);
+    /* what the firmware programs today: all of RAM */
+    w[0] = mk(0, 64 * GiB, 0, 1);
+    CHECK(ck_pi5pcie_ib_verdict(w, 8, 0, B, BS, &d) == 0);
+    CHECK(d.verdict == CK_PI5PCIE_DMA_WIDER && d.reach_bytes == 64 * GiB && d.inside_bytes == BS &&
+          d.outside_bytes == 64 * GiB - BS && d.windows == 1);
+    /* exactly the bounce block: confined */
+    w[0] = mk(B, BS, B, 1);
+    ck_pi5pcie_ib_verdict(w, 8, 0, B, BS, &d);
+    CHECK(d.verdict == CK_PI5PCIE_DMA_CONFINED && d.outside_bytes == 0 && d.inside_bytes == BS);
+    /* confined by remap: bus 0 -> CPU B */
+    w[0] = mk(0, BS, B, 1);
+    ck_pi5pcie_ib_verdict(w, 8, 0, B, BS, &d);
+    CHECK(d.verdict == CK_PI5PCIE_DMA_CONFINED);
+    /* two windows that together are exactly the block, and an overlapping duplicate: still confined */
+    w[0] = mk(B, MiB, B, 1);
+    w[1] = mk(B + MiB, MiB, B + MiB, 1);
+    ck_pi5pcie_ib_verdict(w, 8, 0, B, BS, &d);
+    CHECK(d.verdict == CK_PI5PCIE_DMA_CONFINED && d.reach_bytes == BS && d.windows == 2);
+    w[2] = mk(B, MiB, B, 1);
+    ck_pi5pcie_ib_verdict(w, 8, 0, B, BS, &d);
+    CHECK(d.verdict == CK_PI5PCIE_DMA_CONFINED && d.reach_bytes == BS); /* union, not a sum */
+    memset(w, 0, sizeof w);
+    /* only half the block reachable: partial, the driver must not use the rest */
+    w[0] = mk(B, MiB, B, 1);
+    ck_pi5pcie_ib_verdict(w, 8, 0, B, BS, &d);
+    CHECK(d.verdict == CK_PI5PCIE_DMA_PARTIAL && d.inside_bytes == MiB && d.outside_bytes == 0);
+    /* partial cover plus reach elsewhere is still partial (cover is the first problem) */
+    w[1] = mk(0, 64 * 1024, 0, 1);
+    ck_pi5pcie_ib_verdict(w, 8, 0, B, BS, &d);
+    CHECK(d.verdict == CK_PI5PCIE_DMA_PARTIAL && d.outside_bytes == 64 * 1024);
+    memset(w, 0, sizeof w);
+    /* disjoint window: miss */
+    w[0] = mk(0x10000000u, 2 * MiB, 0x10000000u, 1);
+    ck_pi5pcie_ib_verdict(w, 8, 0, B, BS, &d);
+    CHECK(d.verdict == CK_PI5PCIE_DMA_MISS);
+    /* a window that ends exactly where the block starts does not touch it */
+    w[0] = mk(B - BS, BS, B - BS, 1);
+    ck_pi5pcie_ib_verdict(w, 8, 0, B, BS, &d);
+    CHECK(d.verdict == CK_PI5PCIE_DMA_MISS);
+    /* no window enabled: DMA cannot reach memory */
+    memset(w, 0, sizeof w);
+    ck_pi5pcie_ib_verdict(w, 8, 0, B, BS, &d);
+    CHECK(d.verdict == CK_PI5PCIE_DMA_NO_WINDOW && d.windows == 0);
+    /* remap off: where it lands is not known */
+    w[0] = mk(B, BS, B, 0);
+    ck_pi5pcie_ib_verdict(w, 8, 0, B, BS, &d);
+    CHECK(d.verdict == CK_PI5PCIE_DMA_UNKNOWN);
+    /* invalid window */
+    w[0] = mk(B, BS, B, 1);
+    w[0].size_valid = 0;
+    ck_pi5pcie_ib_verdict(w, 8, 0, B, BS, &d);
+    CHECK(d.verdict == CK_PI5PCIE_DMA_UNKNOWN);
+    /* an enabled window outside the model (GISB/SCB) cannot be called confined */
+    w[0] = mk(B, BS, B, 1);
+    ck_pi5pcie_ib_verdict(w, 8, 1, B, BS, &d);
+    CHECK(d.verdict == CK_PI5PCIE_DMA_UNKNOWN);
+    w[0] = mk(0, 64 * GiB, 0, 1);
+    ck_pi5pcie_ib_verdict(w, 8, 1, B, BS, &d);
+    CHECK(d.verdict == CK_PI5PCIE_DMA_WIDER); /* already known to be wider */
+    /* wrap: a window whose end passes 2^64 is refused, not folded */
+    w[0] = mk(0, 64 * GiB, 0xfffffffff0000000ull, 1);
+    ck_pi5pcie_ib_verdict(w, 8, 0, B, BS, &d);
+    CHECK(d.verdict == CK_PI5PCIE_DMA_UNKNOWN);
+    /* bad arguments */
+    CHECK(ck_pi5pcie_ib_verdict(w, 8, 0, B, 0, &d) == CK_PI5PCIE_E_ARG);
+    CHECK(ck_pi5pcie_ib_verdict(w, 8, 0, 0xfffffffffff00000ull, 2 * MiB, &d) == CK_PI5PCIE_E_ARG);
+    CHECK(ck_pi5pcie_ib_verdict(w, 9, 0, B, BS, &d) == CK_PI5PCIE_E_ARG);
+    CHECK(!strcmp(ck_pi5pcie_verdict_name(CK_PI5PCIE_DMA_WIDER), "NOT_CONFINED"));
+}
+
+static void put32(uint8_t *p, uint32_t v) { p[0] = (uint8_t)v; p[1] = (uint8_t)(v >> 8); p[2] = (uint8_t)(v >> 16); p[3] = (uint8_t)(v >> 24); }
+
+static size_t mcfg(uint8_t *t, int n, const uint64_t *base, const uint16_t *seg, const uint8_t *bmax)
+{
+    size_t len = 44 + 16u * (size_t)n;
+    memset(t, 0, len);
+    memcpy(t, "MCFG", 4);
+    put32(t + 4, (uint32_t)len);
+    for (int i = 0; i < n; i++) {
+        uint8_t *e = t + 44 + 16 * i;
+        put32(e, (uint32_t)base[i]);
+        put32(e + 4, (uint32_t)(base[i] >> 32));
+        e[8] = (uint8_t)seg[i];
+        e[9] = (uint8_t)(seg[i] >> 8);
+        e[10] = 0;
+        e[11] = bmax[i];
+    }
+    return len;
+}
+
+static void t_door(void)
+{
+    uint8_t t[44 + 16 * 3];
+    struct ck_pi5pcie_door d;
+    /* exactly what Mcfg.aslc:26-48 declares for the three controllers */
+    uint64_t base[3] = {0x1000100000ull + 0x8000, 0x1000110000ull + 0x8000, 0x1000120000ull + 0x8000};
+    uint16_t seg[3] = {0, 1, 2};
+    uint8_t bmax[3] = {0, 0, 0};
+    size_t len = mcfg(t, 3, base, seg, bmax);
+    ck_pi5pcie_door_decide(NULL, 0, 2, 0x1000120000ull, &d);
+    CHECK(d.why == CK_PI5PCIE_WHY_NO_MCFG);
+    ck_pi5pcie_door_decide(t, len, 2, 0x1000120000ull, &d);
+    CHECK(d.why == CK_PI5PCIE_WHY_DATA_WINDOW && d.base == 0x1000128000ull && d.bus_max == 0);
+    ck_pi5pcie_door_decide(t, len, 7, 0x1000120000ull, &d);
+    CHECK(d.why == CK_PI5PCIE_WHY_NO_SEGMENT);
+    ck_pi5pcie_door_decide(t, len - 1, 2, 0x1000120000ull, &d);
+    CHECK(d.why == CK_PI5PCIE_WHY_MALFORMED);
+    t[0] = 0; /* hidden: signature zeroed, as the default firmware mode does */
+    ck_pi5pcie_door_decide(t, len, 2, 0x1000120000ull, &d);
+    CHECK(d.why == CK_PI5PCIE_WHY_MALFORMED);
+    t[0] = 'M';
+    /* a narrow bus range that is not the data window */
+    base[2] = 0x2000000000ull;
+    len = mcfg(t, 3, base, seg, bmax);
+    ck_pi5pcie_door_decide(t, len, 2, 0x1000120000ull, &d);
+    CHECK(d.why == CK_PI5PCIE_WHY_NARROW);
+    /* a real-looking ECAM: still reported as a candidate, never silently chosen */
+    bmax[2] = 1;
+    len = mcfg(t, 3, base, seg, bmax);
+    ck_pi5pcie_door_decide(t, len, 2, 0x1000120000ull, &d);
+    CHECK(d.why == CK_PI5PCIE_WHY_ECAM_CANDIDATE && d.base == 0x2000000000ull);
+    CHECK(strcmp(ck_pi5pcie_why_name(d.why), "?") != 0);
+}
+
+int main(void)
+{
+    t_cfg_access();
+    t_probe_rp1();
+    t_probe_needs_index();
+    t_bar();
+    t_ib_size();
+    t_ib_read();
+    t_verdict();
+    t_door();
+    return ck_t_verdict("test_pi5_pcie");
+}
diff --git a/scripts/.crumb b/scripts/.crumb
index e5af2d57..d4ca7d33 100644
--- a/scripts/.crumb
+++ b/scripts/.crumb
@@ -7,14 +7,14 @@
     "generated": {
       "children": [],
       "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
-      "compiled_at": "2026-10-13T14:40:44Z",
+      "compiled_at": "2026-10-13T16:14:20Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:7db7f93211cc0ea2a7dab1657474188f3040f71d568d0e41bc21b931cd28e6b5",
+      "digest": "sha256:e9b11cddd1fb52cca8537d081d709de7ee0eeb782dee9f61d2e6668aaaa41f59",
       "evidence_files": 0,
       "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
       "files": 93,
-      "generated_at_commit": "1fd895aef29f2163f075e7b35bb13fa2c9389192",
-      "source_tree": "sha256:96cf1e7ad952f6e5d156f1289fd580f2765997d8f2650244abb64330609a0ee1"
+      "generated_at_commit": "1afe0869482d2986626d6855dfc8cabc5635bd12",
+      "source_tree": "sha256:26cddf09b38ce65e0f30cbbaeebdd56dc3efd60b4337bf7b24ccff4ddc3ae178"
     },
     "owner_lane": "",
     "provenance": {
diff --git a/scripts/ck_pi5_build_check.sh b/scripts/ck_pi5_build_check.sh
index 81715e55..2e93d58d 100755
--- a/scripts/ck_pi5_build_check.sh
+++ b/scripts/ck_pi5_build_check.sh
@@ -54,4 +54,17 @@ if grep -qE "opt/aienos/model|TEST-ONLY QEMU fw_cfg|fw_cfg" <<<"${pinf_strings}"
 if defined "${pinf}" ck_stage_store; then echo "FAIL pi5-infer image defines ck_stage_store"; fail=1; else echo "PASS pi5-infer image has no Store stage"; fi
 test -s "${root}/target/native-kernel-pi5-infer/BOOTAA64.EFI" || { echo "FAIL no pi5-infer BOOTAA64.EFI"; fail=1; }
 
+# AIENOS-PI5 network lane step 1: the Pi image with the PCIe2 / RP1 enumerator (make pi5-pcie). Read-only boot
+# report; the plain pi5, pi5-store, pi5-infer and default images must carry none of it.
+make -C "${root}/native/kernel" pi5-pcie >/dev/null
+ppc="${root}/target/native-kernel-pi5-pcie/aienos-ck.elf"
+for s in ck_pi5pcie_report ck_pi5pcie_cfg_read32 ck_pi5pcie_ib_verdict ck_dmaw_init ck_pi5_start; do
+    if defined "${ppc}" "${s}"; then echo "PASS pi5-pcie image defines ${s}"; else echo "FAIL pi5-pcie image lacks ${s}"; fail=1; fi
+done
+for s in ck_pi5pcie_report ck_pi5pcie_cfg_read32 ck_pi5pcie_ib_verdict ck_dmaw_init; do
+    if defined "${pi5}" "${s}" || defined "${ps}" "${s}" || defined "${pinf}" "${s}" || defined "${def}" "${s}"; then echo "FAIL a non-pcie image defines ${s}"; fail=1; else echo "PASS plain pi5, pi5-store, pi5-infer and default images have no ${s}"; fi
+done
+if grep -q "software-only DMA confinement (Pi 5, weaker than the Spark)" <<<"$(strings -a "${ppc}")"; then echo "PASS pi5-pcie image carries the ADR 0020 label"; else echo "FAIL pi5-pcie image lacks the ADR 0020 label"; fail=1; fi
+test -s "${root}/target/native-kernel-pi5-pcie/BOOTAA64.EFI" || { echo "FAIL no pi5-pcie BOOTAA64.EFI"; fail=1; }
+
 if [[ ${fail} == 0 ]]; then echo "CK_PI5_BUILD: PASS"; else echo "CK_PI5_BUILD: FAIL"; exit 1; fi