Skip to content

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

A Metal shader runs on iOS: the four floats are exact in QEMU, and only the Adreno is left

vcvkke7cfa7385c10
diff --git a/docs/air.md b/docs/air.md
index 17ba2ea..1d53265 100644
--- a/docs/air.md
+++ b/docs/air.md
@@ -455,12 +455,29 @@ got (`air_run: clearFragment01 on softpipe` here), and that line must be read be
below it is believed. `AIR_RUN_SOFTWARE=1` forces software even on the phone, for comparing the
two on the same device.
+**It runs on iOS, and the numbers are exact there.** In QEMU (`CMDLINE="cpus=4
+RC_JOBS=rc.jobs.air" qemu/run-ios.sh 420`, a clean boot: 72 `[ ok ]` lines, SpringBoard up),
+`air_run` translated `clearFragment01`, found no `msm` device, fell back to softpipe as designed,
+drew the quad and read back
+
+```
+2.10170319e-18 0.178894654 1.48687698e+16 1.21394141e+33
+```
+
+— the same four floats, bit for bit, that LLVM computes on a computer and that softpipe draws
+there. So the whole chain works on the target operating system: the container, the reader, the
+translation, Gallium, the draw and the readback. What is left is one substitution — softpipe for
+ir3 on the Adreno — and that needs the phone.
+
What is *not* known until it is tried is whether the kernel's GPU driver and the submit path
behave for a draw that does not come from CoreAnimation: the GLES path is that driver's only
consumer today. `rc.jobs.air` asks with the GPU idle; `rc.jobs.air2` asks again after SpringBoard
is up and holding it. A refusal is a finding the whole port needs, not just this frontend, so
either answer is worth the run.
+(Counting anything out of a QEMU log here: `qemu/run-ios.sh` prints every line twice, and
+`sort -u` does not catch it because the pairs are separated by other output.)
+
## 6. Running it
```
diff --git a/userland/build.sh b/userland/build.sh
index 27e1685..a84af61 100755
--- a/userland/build.sh
+++ b/userland/build.sh
@@ -331,6 +331,10 @@ if [ -n "$FLASHBOOT" ] && [ -f $CACHE/dyld_shared_cache_arm64 ]; then
rm -rf flashboot flashboot.os
mkdir -p flashboot/sbin flashboot/redwood flashboot/dev flashboot/flash flashboot/Cryptexes/OS flashboot/Cryptexes/App
cp obj/stage0 flashboot/sbin/launchd
+ # the OS cryptex, and the shared cache in it, only where this image will carry it:
+ # with CRYPTEXES=flash the cryptexes are read from the phone's flash and this tree is
+ # built and thrown away unused
+ if [ "$CRYPTEXES" != flash ]; then
if [ -d $IOS/cryptex ]; then cp -al $IOS/cryptex flashboot.os; else mkdir -p flashboot.os; fi
# the audio DSP's firmware and the speaker amplifiers' configuration, as in the system image's /fw: the kernel
# reads the firmware as soon as there is a root (this image, adsp=1), the configuration maybe later -- by then
@@ -347,8 +351,10 @@ if [ -n "$FLASHBOOT" ] && [ -f $CACHE/dyld_shared_cache_arm64 ]; then
mkdir -p $D
for f in $CACHE/dyld_shared_cache_arm64*; do
case "$f" in *.symbols) continue ;; esac
- ln "$f" $D/
+ # -f: a cryptex fetched with the cache already in it would otherwise stop the build
+ ln -f "$f" $D/
done
+ fi
python3 ../tools/apfs/mkapfs.py -z --plain fw -o flashboot.boot.apfs Boot=flashboot | tail -1
[ -z "$CHECK" ] || ../tools/apfs/check-image.sh flashboot.boot.apfs Boot=flashboot
# the third container: Apple's App cryptex as it is (10 MB; fetch.sh), for the boot volume's Cryptexes/App
@@ -422,7 +428,8 @@ if [ -f $IOS/system.manifest ] && [ -f $CACHE/dyld_shared_cache_arm64 ] &&
mkdir -p $D
for f in $CACHE/dyld_shared_cache_arm64*; do
case "$f" in *.symbols) continue ;; esac # symbolication data, never mapped
- ln "$f" $D/
+ # -f: a cryptex fetched with the cache already in it would otherwise stop the build
+ ln -f "$f" $D/
done
# zlib where it saves room, as Apple keeps the root (a small file whole in its attribute): 5.4 GB of
# files in 2.5 GB, what fits into the phone's RAM beside iOS