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
nas: keep the last signal reading across a lost registration -- the modem answers the serving system and the signal in separate messages, and here they alternate ('registered, no reading' / 'not registered, -86 dBm', cycles 39-41), so clearing the reading on every 'not registered' left the kernel at 0 bars whenever it was registered; bars now come only while registered, from the last reading there is; tools/qmi-test: the NAS test updated to that and given a host <sys/systm.h>; prebuilt kernel
shimoku74d4ea9bfc2a29
diff --git a/prebuilt/SHA256SUMS b/prebuilt/SHA256SUMSindex b9030b7..e8f9cdc 100644--- a/prebuilt/SHA256SUMS+++ b/prebuilt/SHA256SUMS@@ -1,6 +1,6 @@-Built 2026-10-25 20:03 from this tree.+Built 2026-10-25 20:24 from this tree.-8f8697eca234b15a2588007e3226a2e9fd90a217fbe91b9ec2b7ac9b230d3ec0 prebuilt/mach.development.bcm2837+ab27940e41148fb8a9b64569033fa5cfb9078a8b24a265e43bfe7b304dbe08cb prebuilt/mach.development.bcm28373de0d8b2095989a9a8f9f9679b8bec01d80bad38eee535d934d29b7b76fee984 prebuilt/loader.efi932c856c04e87611b16c872da37c461d572c6258da0202ecd875d91c29886e03 prebuilt/userland/HakiosAudio45bffe2da6b2484836bd29074b39bd5cc67b4cdaa253c2aa39561ce5188d6ddc prebuilt/userland/childdiff --git a/prebuilt/mach.development.bcm2837 b/prebuilt/mach.development.bcm2837index e559466..6825caa 100755Binary files a/prebuilt/mach.development.bcm2837 and b/prebuilt/mach.development.bcm2837 differdiff --git a/tools/qmi-test/run-nas.sh b/tools/qmi-test/run-nas.shindex 4054ac9..7438719 100755--- a/tools/qmi-test/run-nas.sh+++ b/tools/qmi-test/run-nas.sh@@ -4,6 +4,6 @@ root=$(CDPATH= cd -- "$(dirname -- "$0")/../.." && pwd)out="$root/xnu-deps/build/qmi-test/nas-test"mkdir -p "$(dirname "$out")"${CC:-cc} -std=c11 -O1 -g -Wall -Wextra -Werror -fsanitize=address,undefined \- -I"$root/xnu/files/bsd" -o "$out" \+ -I"$root/xnu/files/bsd" -I"$root/tools/qmi-test/shim" -o "$out" \"$root/tools/qmi-test/test_nas.c" "$root/xnu/files/bsd/dev/hakios.nas.c""$out"diff --git a/tools/qmi-test/shim/sys/systm.h b/tools/qmi-test/shim/sys/systm.hnew file mode 100644index 0000000..c90ad02--- /dev/null+++ b/tools/qmi-test/shim/sys/systm.h@@ -0,0 +1,3 @@+/* For the host tests: what the kernel's <sys/systm.h> gives hakios.nas.c (printf, the string functions). */+#include <stdio.h>+#include <string.h>diff --git a/tools/qmi-test/test_nas.c b/tools/qmi-test/test_nas.cindex ed48b5b..4989226 100644--- a/tools/qmi-test/test_nas.c+++ b/tools/qmi-test/test_nas.c@@ -65,8 +65,8 @@ int main(void)assert(hakios_nas_apply(&state, lte_signal, sizeof(lte_signal)) == 1);assert(state.has_signal && !state.registered && state.bars == 0);assert(hakios_nas_apply(&state, registered, sizeof(registered)) == 1);- assert(state.registered && state.bars == 0);- assert(hakios_nas_apply(&state, lte_signal, sizeof(lte_signal)) == 1);+ assert(state.registered && state.bars == 4); /* the reading from before the registration counts */+ assert(hakios_nas_apply(&state, lte_signal, sizeof(lte_signal)) == 0); /* the same reading again: no change */assert(state.radio_interface == 8 && state.dbm == -95 && state.bars == 4);assert(hakios_nas_apply(&state, failed_signal, sizeof(failed_signal)) == 0);assert(state.bars == 4);@@ -75,7 +75,10 @@ int main(void)assert(state.bars == 4);}assert(hakios_nas_apply(&state, disconnected, sizeof(disconnected)) == 1);- assert(!state.registered && !state.has_signal && state.bars == 0);+ assert(!state.registered && state.has_signal && state.bars == 0); /* the last reading is kept, no bars */+ assert(hakios_nas_apply(&state, registered, sizeof(registered)) == 1);+ assert(state.registered && state.bars == 4); /* ... and they come back with the registration */+ assert(hakios_nas_apply(&state, disconnected, sizeof(disconnected)) == 1);struct hakios_nas_client client;assert(hakios_nas_client_open(&client, &transport, changed, &client) == 0);assert(requests == 2);@@ -87,6 +90,6 @@ int main(void)server(callback_context, false, 3, 1, 0, 7, 9);assert(!client.state.registered && client.state.bars == 0 && updates == 3);hakios_nas_client_close(&client);- puts("nas-test: registration gates bars; QRTR lookup, polling and disconnect verified");+ puts("nas-test: registration gates bars, the last reading kept across a lost registration; QRTR lookup, polling and disconnect verified");return 0;}diff --git a/xnu/files/bsd/dev/hakios.nas.c b/xnu/files/bsd/dev/hakios.nas.cindex 66c4f38..d15da28 100644--- a/xnu/files/bsd/dev/hakios.nas.c+++ b/xnu/files/bsd/dev/hakios.nas.c@@ -65,11 +65,15 @@ hakios_nas_apply(struct hakios_nas_state *state, const void *frame, size_t lengt"CS %u, PS %u, network %u, %u radios%s%u\n", value[0], value[1], value[2], value[3], value[4],value[4] ? ", the first " : "", value[4] ? value[5] : 0);}+ /*+ * The modem answers the serving system and the signal strength in separate messages, and+ * on this phone the two alternate ("registered, no reading" / "not registered, -86 dBm",+ * cycles 39 to 41). The last reading is kept across a "not registered" sample, so that+ * the bars come back with the registration instead of waiting for the next reading:+ * bars only while registered, from the last reading there is.+ */next.registered = value[0] == 1;- if (!next.registered) {- next.has_signal = false;- next.bars = 0;- }+ next.bars = next.registered && next.has_signal ? bars_for(next.dbm) : 0;serving = true;} else if (message == 0x24 && type == 0x10 && size >= 5 && size >= (size_t)5 + value[4]) {/* the current PLMN: MCC, MNC (16 bits each), the description's length and bytes */