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: its log written under U-Boot too, and a download the host gave up on no longer hangs it
shimoku74b085b55e3fe7
diff --git a/prebuilt/SHA256SUMS b/prebuilt/SHA256SUMSindex 995c214..54d2f6f 100644--- a/prebuilt/SHA256SUMS+++ b/prebuilt/SHA256SUMS@@ -1,7 +1,7 @@Built 2026-10-25 22:53 from this tree.03e794e8e1d389a6abb9bcd2431eaccf9747271ff8c1234922225718c70441e9 prebuilt/hakios-kernel-fb856531febdc303af412c66e30921aaa2fd7158baad5986144eed922dd614a7 prebuilt/loader.efi+6a3c19abc1db01a367bf78863fea288f621683edf31059731a78a77040ffe034 prebuilt/loader.efi932c856c04e87611b16c872da37c461d572c6258da0202ecd875d91c29886e03 prebuilt/userland/HakiosAudio45bffe2da6b2484836bd29074b39bd5cc67b4cdaa253c2aa39561ce5188d6ddc prebuilt/userland/child35f3065e4602965911a20d0666a289cafba16644e611ea870d40bda81ea67546 prebuilt/userland/cpu_testdiff --git a/prebuilt/loader.efi b/prebuilt/loader.efiindex 843f979..1872eba 100755Binary files a/prebuilt/loader.efi and b/prebuilt/loader.efi differdiff --git a/xnuloader/loader.c b/xnuloader/loader.cindex 87ed0ff..2558e02 100644--- a/xnuloader/loader.c+++ b/xnuloader/loader.c@@ -295,7 +295,8 @@ find_log_partition(void)* last run. It is what gets written to the log partition and what the host* fetches over USB (fastboot get_staged).*/-static char out_buf[2 * 1024 * 1024];+/* aligned for any firmware's block I/O: U-Boot's wants a buffer aligned to the block size (media->io_align) */+static char out_buf[2 * 1024 * 1024] __attribute__((aligned(0x2000)));/* the storage's reads for the kernel land here (block_poll), and nothing else may be put in it */#define BLOCK_BUFFER_SIZE (4u << 20)static uint8_t block_buffer[BLOCK_BUFFER_SIZE] __attribute__((aligned(0x2000)));@@ -3645,6 +3646,13 @@ usb_start(void)* Returns the byte count, or -1 if the transfer was cancelled or the cable* state changed. Keeps the watchdog fed while idle.*/+/*+ * Seconds a download may go without a byte before it is given up (0: wait for ever). A host that is stopped half-way+ * through a download (a fastboot killed by its timeout) left the loader waiting for the rest for good: every command+ * after it was taken for data, and only the power button brought the phone back.+ */+static uint64_t usb_data_timeout;+static int64_tusb_wait(uint8_t endpoint){@@ -3666,6 +3674,10 @@ usb_wait(uint8_t endpoint)if (run_active && READ_SYSREG(CNTVCT_EL0) - began > 3 * freq) {return -1;}+ if (usb_data_timeout != 0 && READ_SYSREG(CNTVCT_EL0) - began > usb_data_timeout * freq) {+ USB->abort_xfer(endpoint);+ return -1;+ }if (msg == UsbDeviceEventTransferNotification && data.transfer.endpoint_index == endpoint) {return data.transfer.status == UsbDeviceTransferStatusCompleteOK ? (int64_t)data.transfer.bytes_completed : -1;}@@ -3826,6 +3838,7 @@ fb_command(char *cmd)uint32_t magic_held = 0;int magic_taken = 0;fb_reply_data(total);+ usb_data_timeout = 20;while (got < total) {uint64_t want = total - got > USB_CHUNK ? USB_CHUNK : total - got;int64_t r = usb_rx(usb_rx_buf, want);@@ -3844,6 +3857,7 @@ fb_command(char *cmd)}got += (uint64_t)r;}+ usb_data_timeout = 0;if (got == total) {if (magic_taken) {*(volatile uint32_t *)dest = magic_held;