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
Wi-Fi: the phone's radio scans and hears the networks around it
vcvkk38e57648616c
diff --git a/prebuilt/SHA256SUMS b/prebuilt/SHA256SUMSindex 9309033..5041c50 100644--- a/prebuilt/SHA256SUMS+++ b/prebuilt/SHA256SUMS@@ -1,6 +1,6 @@-Built 2026-10-13 19:05 from this tree.+Built 2026-10-13 19:42 from this tree.-0638037a3ef004965c0f674a642d45c85a72782287ff472af1bcb188ddf78a8b prebuilt/mach.development.bcm2837+5844b4b77046b056af969644f3fcdd3caab1f02689ec12db6a58e41c0bebd7a0 prebuilt/mach.development.bcm28371332a598d2dec00a1d8e930044e4f00a12ad44c6e5e50eecf4b7fe7fae803bf2 prebuilt/loader.efid2a35a4a1d6658ffb3696914f727661b52c9333de8a3af8a31642b8023ce03ac prebuilt/userland/child1a413befd511384052e1962c1394adce20f718e1f2657ce63ab09828ebc4bd1b prebuilt/userland/cpu_testdiff --git a/prebuilt/mach.development.bcm2837 b/prebuilt/mach.development.bcm2837index cc5675c..8f90e25 100755Binary files a/prebuilt/mach.development.bcm2837 and b/prebuilt/mach.development.bcm2837 differdiff --git a/xnu/files/bsd/dev/redwood_lx.c b/xnu/files/bsd/dev/redwood_lx.cindex 4796579..5907680 100644--- a/xnu/files/bsd/dev/redwood_lx.c+++ b/xnu/files/bsd/dev/redwood_lx.c@@ -226,6 +226,12 @@ lx_os_rproc_boot(void)return redwood_wifi_dsp_is_up() ? 0 : ENXIO;}+int+lx_os_radio_address(unsigned char *address)+{+ return redwood_wifi_radio_address(address);+}+/* ---- the driver ---------------------------------------------------------------------------------------- *//* The object has its own; this is the one of a kernel built without it. */diff --git a/xnu/files/bsd/dev/redwood_wifi.c b/xnu/files/bsd/dev/redwood_wifi.cindex 92e2d64..d9795a7 100644--- a/xnu/files/bsd/dev/redwood_wifi.c+++ b/xnu/files/bsd/dev/redwood_wifi.c@@ -105,6 +105,14 @@* wifi_smmu=2 ... and give that stream a context of the SMMU with page tables of ours,* so that the radio can be shown memory (radio_space_on() below: THE* SMMU IS WRITTEN); taken back when the DSP is stopped+ * wifi_mac=A the radio's own address for the driver (redwood_wifi_radio_address()+ * below; xl takes it from a file that is not in the repository)+ * wifi_scan=1 with wifi_lx=2: once the driver is up, an interface in station mode is+ * made and the radio scans, listening only; what it heard goes to the log+ * (other people's networks by name and address: the log is not for+ * passing on)+ * wifi_lx_step=MS the driver's start says each stub it comes to and waits MS there: for+ * a run that ends without a word (follow it with XL_FOLLOW=2)* wifi_lx=1 step 15 is ath11k's own instead of the stand-in (redwood_lx.c), with* the radio's registers neither read nor written; 2: for real (which* wants wifi_smmu=2: the radio is given addresses of its rings)@@ -3141,6 +3149,26 @@ static void radio_space_faults(void);* for 6 GHz); the rules of the regulatory domain it starts in (CN: 2402..2482, 5170..5330,* 5735..5835 MHz); and no address of its own (all zeros: the tree's "use-nv-mac" has Android* give it one). Then the driver is taken down in order, mode "off" included.+ *+ * With mac.c, reg.c and peer.c built, and with wifi_scan=1 (the same day): the driver registers+ * its radio with what stands in for mac80211 (wifi/lx/src/lx_80211.c) -- 14 channels at+ * 2.4 GHz, 28 at 5, 60 at 6, of which the firmware's regulatory domain allows 13, 13 and none+ * --, takes the address it was given, starts the radio, makes an interface in station mode+ * and has the firmware scan those 26 channels, listening only. The scan takes 4.1 s (150 ms a+ * channel), and what the radio heard is in the log: 5 to 7 access points in three runs, at+ * 2.4 and at 5 GHz, the strongest at -40 dBm, the weakest at -84, noise at -108 to -111. The+ * firmware works a country out of what it hears and the driver sets it (after the scan). Then+ * the interface is removed, the radio stopped, and the driver's own removal runs to its end.+ * The data path is still stubs: the firmware scans without it.+ *+ * A PHONE THAT RESETS WITHOUT A WORD: twice on the way, two seconds after calibration. The+ * driver's registration failed (the hash table peer.c needs was a stub that fails), and where+ * its start fails that late core.c asks for the mode "off" before it stops the bus; our thread+ * was then still writing ring pointers into registers that had stopped answering. The read at+ * step 16 outside mission mode was a bus error and a panic; this was neither, and the loader+ * went with it. The cause was not seen in a log (there was none): it is what the code does,+ * and with a hash table that works and the copy engines let go of before any request for a+ * mode other than mission (lx_bus.c: lx_qmi_send_request()) it has not happened again.*/static boolstep_driver(uint32_t how)@@ -3752,6 +3780,53 @@ redwood_wifi_driver_file(const char *name, uint64_t *size)return NULL;}+/*+ * The radio's own address. Its firmware has none (it says zeros): Android keeps the phone's in+ * its storage and hands it to the radio's driver (dt: "use-nv-mac"). Here it is given to the+ * kernel when that is started -- boot-arg wifi_mac, six bytes in hexadecimal with colons+ * between -- and is nowhere in these sources. The log says that one was given and how long it+ * was, not which.+ */+bool+redwood_wifi_radio_address(uint8_t *address)+{+ char text[32] = "";+ uint8_t bytes[6];+ unsigned count = 0, digits = 0, value = 0;+ bool good;++ if (!PE_parse_boot_arg_str("wifi_mac", text, sizeof(text)) || text[0] == 0) {+ printf("wifi: %u: the driver asks for the radio's address: none was given (wifi_mac)\n", step);+ return false;+ }+ good = true;+ for (const char *c = text;; c++) {+ int digit = *c >= '0' && *c <= '9' ? *c - '0' : *c >= 'a' && *c <= 'f' ? *c - 'a' + 10 : *c >= 'A' && *c <= 'F' ?+ *c - 'A' + 10 : -1;++ if (digit >= 0 && digits < 2) {+ value = value << 4 | (unsigned)digit;+ digits++;+ } else if ((*c == ':' || *c == 0) && digits != 0 && count < 6) {+ bytes[count++] = (uint8_t)value;+ digits = value = 0;+ } else {+ good = false;+ }+ if (*c == 0 || !good) {+ break;+ }+ }+ good = good && count == 6 && !(bytes[0] & 1) && (bytes[0] | bytes[1] | bytes[2] | bytes[3] | bytes[4] | bytes[5]) != 0;+ printf("wifi: %u: the driver asks for the radio's address: one was given, %lu characters, %s\n", step,+ (unsigned long)strlen(text), good ? "six bytes: it is the radio's for this run" : "WHICH IS NOT A STATION'S ADDRESS: "+ "not used");+ if (good) {+ memcpy(address, bytes, sizeof(bytes));+ }+ return good;+}+/* ---- all of it together ---------------------------------------------------------------------------- */static bool(*const steps[])(void) = {diff --git a/xnu/files/bsd/sys/redwood_input.h b/xnu/files/bsd/sys/redwood_input.hindex 4f176ca..fc27bdf 100644--- a/xnu/files/bsd/sys/redwood_input.h+++ b/xnu/files/bsd/sys/redwood_input.h@@ -61,6 +61,7 @@ int redwood_lx_start(void); /* the driver brought up on the radio asbool redwood_wifi_dsp_is_up(void); /* the DSP that runs the radio's firmware has been started and has a link */const uint8_t *redwood_wifi_driver_file(const char *name, uint64_t *size); /* a file by the name Linux has for it */bool redwood_wifi_radio_map(uint64_t physical, uint64_t size, unsigned long long *address); /* memory shown to the radio */+bool redwood_wifi_radio_address(uint8_t *address); /* the radio's own address (boot-arg wifi_mac), if one was given *//** The GPU kept on (boot-arg adreno_keep=1), for iokit/Kernel/RedwoodGPU.cpp: see "the GPU kept on"diff --git a/xnu/files/bsd/sys/redwood_lx.h b/xnu/files/bsd/sys/redwood_lx.hindex b6d8798..3f8c83a 100644--- a/xnu/files/bsd/sys/redwood_lx.h+++ b/xnu/files/bsd/sys/redwood_lx.h@@ -52,6 +52,8 @@ unsigned lx_os_option(const char *name);int lx_os_firmware(const char *name, const void **data, unsigned long *size);/* the processor that runs the radio's firmware: started, and up when this returns; 0 or an errno */int lx_os_rproc_boot(void);+/* the radio's own address (six bytes), if the machine has one for it: 1, or 0 and nothing written */+int lx_os_radio_address(unsigned char *address);/** ---- the one name the object shows the kernel: bring the driver up on the radio and go as far