Apple's open-source XNU kernel on Android phones: its own loader and drivers, Metal on the Adreno. Runs from RAM; a reboot gives the phone back to Android.
C
xnuloader: the ramfb request is checked through a volatile, so a build cannot skip it (QEMU window stayed black)
shimoku50e5f38ed870
diff --git a/README.md b/README.mdindex ebf4199..d1dcd88 100644--- a/README.md+++ b/README.md@@ -85,8 +85,8 @@ qemu/run-ios.sh 1200 -display gtk > logs/qemu.log # a 20-minute session```**What you will see.** The CPU is emulated, so it is slow, and the window is **black at first**: that is normal.-Black for the first minute or two, then the Apple logo, then the lock screen after about 3 to 10 minutes, depending on-the machine. The mouse with the button held is a finger; `H` is Home, `L` is the power button, `↑`/`↓` are volume.+Black for the first minute, then the Apple logo, then the home screen after about 5 minutes on a fast desktop (measured on+one: the logo at 1 minute, the home screen at 5), longer on a slower machine. The mouse with the button held is a finger; `H` is Home, `L` is the power button, `↑`/`↓` are volume.**If it stays black** (check these in order):@@ -94,6 +94,9 @@ the machine. The mouse with the button held is a finger; `H` is Home, `L` is theiOS does not start: `qemu/run-ios.sh` now refuses to run without your own `xnuloader/loader.efi` and says so.1. `tail -f logs/qemu.log` in another terminal. It should print `== XNULOADER v3 ==` within seconds and kernel and launchdlines after that. If it prints nothing, QEMU did not start the loader: run `make doctor`.+ A log that runs, with the line `ramfb: control ... after the request` near its top, is a loader built before 27 October 2026+ (a compiler could skip the check of the display request): the window stays at 800x600 and iOS draws outside it. `make loader`+ again.2. `qemu/screendump.sh` saves what the guest's screen shows (`logs/qemu-screen.png`), whatever your window does.3. No window or a black one although the log runs: your QEMU may have no GTK window (a headless package, WSL without WSLg).Use `qemu/run-ios.sh 1200 -display vnc=127.0.0.1:0 > logs/qemu.log` and connect a VNC viewer to `127.0.0.1:5900`.diff --git a/README.uk.md b/README.uk.mdindex a6a2790..4c8d189 100644--- a/README.uk.md+++ b/README.uk.md@@ -83,8 +83,8 @@ make loader # завантажувач з ідентичністю iPhonemake qemu # сеанс на 20 хвилин```-**Що ви побачите.** Процесор емульований, тож повільно, а вікно спочатку **чорне**: це нормально. Перша-друга хвилина-чорного екрана, потім логотип Apple, потім екран блокування приблизно за 3–10 хвилин залежно від комп'ютера. Миша з+**Що ви побачите.** Процесор емульований, тож повільно, а вікно спочатку **чорне**: це нормально. Перша хвилина+чорного екрана, потім логотип Apple, потім домашній екран приблизно за 5 хвилин на швидкому ПК (виміряно: логотип на 1-й хвилині, домашній екран на 5-й), на повільнішому довше. Миша ззатиснутою кнопкою — палець; `H` — «Додому», `L` — кнопка живлення, `↑`/`↓` — гучність.**Якщо екран лишається чорним:** (0) чи ви виконали `make loader`? У `prebuilt/loader.efi` навмисно немає даних Apple (він запускає лише відкрите ядро), з ним iOS не стартує; `qemu/run-ios.sh` без вашого `xnuloader/loader.efi` відмовляється працювати й каже про це; (1) `tail -f logs/qemu.log` в іншому терміналі: за секунди має з'явитисьdiff --git a/README.zh.md b/README.zh.mdindex 50dd799..6674f2e 100644--- a/README.zh.md+++ b/README.zh.md@@ -75,8 +75,8 @@ make loader # 引导程序,iPhone 的标识取自你自己的 IPSW 副make qemu # 20 分钟的会话```-**你会看到什么。** CPU 是模拟的,所以很慢,窗口一开始是**黑的**,这是正常的:先黑一两分钟,然后出现 Apple 标志,-再过大约 3 到 10 分钟(取决于机器)出现锁屏。按住鼠标键就是手指;`H` 是主屏键,`L` 是电源键,`↑`/`↓` 是音量。+**你会看到什么。** CPU 是模拟的,所以很慢,窗口一开始是**黑的**,这是正常的:先黑一分钟左右,然后出现 Apple 标志,+在较快的台式机上约 5 分钟后出现主屏幕(实测:1 分钟出现标志,5 分钟出现主屏幕),较慢的机器更久。按住鼠标键就是手指;`H` 是主屏键,`L` 是电源键,`↑`/`↓` 是音量。**如果一直是黑屏:** (0) 你运行过 `make loader` 吗?`prebuilt/loader.efi` 里特意不含 Apple 的数据(它只能启动开放内核),用它 iOS 不会启动;没有你自己的 `xnuloader/loader.efi` 时 `qemu/run-ios.sh` 会拒绝运行并说明原因;(1) 在另一个终端运行 `tail -f logs/qemu.log`,几秒内应出现 `== XNULOADER v3 ==`,之后是内核和 launchd 的输出;没有输出就运行 `make doctor`。(2) `qemu/screendump.sh` 会保存虚拟机屏幕当前的内容(`logs/qemu-screen.png`)。diff --git a/prebuilt/SHA256SUMS b/prebuilt/SHA256SUMSindex ba1ca8e..25b00cb 100644--- a/prebuilt/SHA256SUMS+++ b/prebuilt/SHA256SUMS@@ -1,7 +1,7 @@Built 2026-10-25 22:53 from this tree.03e794e8e1d389a6abb9bcd2431eaccf9747271ff8c1234922225718c70441e9 prebuilt/mach.development.bcm2837-933ffdc460633b2d64bda82aab0ccdfb96feb6e27e69f9a70f3b805cb0573677 prebuilt/loader.efi+adb2f30c01ad7e6842ce6cec43b8d75bc0f76d68543ffb41c0d02c1d285e4b73 prebuilt/loader.efi932c856c04e87611b16c872da37c461d572c6258da0202ecd875d91c29886e03 prebuilt/userland/HakiosAudio45bffe2da6b2484836bd29074b39bd5cc67b4cdaa253c2aa39561ce5188d6ddc prebuilt/userland/child35f3065e4602965911a20d0666a289cafba16644e611ea870d40bda81ea67546 prebuilt/userland/cpu_testdiff --git a/prebuilt/loader.efi b/prebuilt/loader.efiindex 91a47c8..435de74 100755Binary files a/prebuilt/loader.efi and b/prebuilt/loader.efi differdiff --git a/xnuloader/loader.c b/xnuloader/loader.cindex 63c8d08..d120105 100644--- a/xnuloader/loader.c+++ b/xnuloader/loader.c@@ -4040,7 +4040,13 @@ ramfb_phone_screen(void)uint64_t addr;uint32_t fourcc, flags, width, height, stride;} __attribute__((packed)) cfg;- static struct {+ /*+ * volatile: QEMU writes `control' back (to 0) when it has done the request, behind the compiler's back. Without the+ * qualifier a build is free to keep the value written a few lines below and never look again, and the loader then+ * says the request failed, leaves ramfb at the firmware's 800x600 and iOS draws its 1125x2436 into a corner: a black window+ * (it did, with a newer build of this very file; the older one happened to reload).+ */+ static volatile struct {uint32_t control, length;uint64_t address;} dma;@@ -4074,7 +4080,12 @@ ramfb_phone_screen(void)dma.control = be32(select << 16 | FW_CFG_DMA_SELECT | FW_CFG_DMA_WRITE);dma.length = be32(sizeof(cfg));dma.address = __builtin_bswap64((uint64_t)(uintptr_t)&cfg);+ __asm__ volatile ("dsb sy" ::: "memory"); /* (cfg and dma are in memory before the device is told to read them) */*(volatile uint64_t *)(FW_CFG_BASE + 16) = __builtin_bswap64((uint64_t)(uintptr_t)&dma);+ /* the device does it at once; allow it some time all the same instead of reading once */+ for (uint32_t spin = 0; dma.control != 0 && spin < 1000000; spin++) {+ __asm__ volatile ("" ::: "memory");+ }if (dma.control != 0) {print("ramfb: control %x after the request\n", (uint64_t)be32(dma.control));return;