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
tools: a run sends only the soc_* values that differ from the kernel's defaults
shimokue2c68b8f0002
diff --git a/ci/github-check.yml b/ci/github-check.ymlindex d2611b6..a393d31 100644--- a/ci/github-check.yml+++ b/ci/github-check.yml@@ -25,6 +25,8 @@ jobs:python3 tools/provenance-check.py- name: The provenance check itself: what it lets through and what it stopsrun: python3 tools/provenance-test.py+ - name: A run sends only the soc_* values that differ from the kernel's defaults+ run: bash tools/soc-only-changes-test.sh- name: The kernel's version string is made as it should berun: python3 tools/kernel-version-test.py- name: The kernel patch applies to Apple's treediff --git a/tools/modem-cycle-win.sh b/tools/modem-cycle-win.shindex 260dda7..e6d1aa4 100644--- a/tools/modem-cycle-win.sh+++ b/tools/modem-cycle-win.sh@@ -13,7 +13,9 @@ ARGS=$1; SECS=${2:-300}# kernel command line so hakios.mpss.c / hakios.ipa.c map that phone's blocks. SOC_ARGS names the file;# default is the one device there is. The POCO's values equal the kernel defaults, so this is a no-op there.SOC_ARGS=${SOC_ARGS-$(ls devices/*/soc.args 2>/dev/null | head -1)}-SOC=""; [ -n "$SOC_ARGS" ] && [ -f "$SOC_ARGS" ] && SOC=$(tr -d '\r' < "$SOC_ARGS" | tr '\n' ' ')+# only what differs from the kernel's built-in defaults: the rest changes nothing, and the command line is short+. tools/soc-only-changes.sh+SOC=""; [ -n "$SOC_ARGS" ] && SOC=$(soc_only_changes "$SOC_ARGS" | tr '\n' ' ')for i in $(seq 1 2160); do s=$(./xl state); [ "$s" != absent ] && break; sleep 10; doneecho "$(date +%T) phone: $s"; [ "$s" = absent ] && { echo "NO PHONE"; exit 1; }./xl enter 2>&1 | tail -1diff --git a/tools/modem-cycle.sh b/tools/modem-cycle.shindex 9da74cb..8e817a0 100755--- a/tools/modem-cycle.sh+++ b/tools/modem-cycle.sh@@ -10,7 +10,9 @@ ARGS=$1; SECS=${2:-300}# kernel command line so hakios.mpss.c / hakios.ipa.c map that phone's blocks. SOC_ARGS names the file;# default is the one device there is. The POCO's values equal the kernel defaults, so this is a no-op there.SOC_ARGS=${SOC_ARGS-$(ls devices/*/soc.args 2>/dev/null | head -1)}-SOC=""; [ -n "$SOC_ARGS" ] && [ -f "$SOC_ARGS" ] && SOC=$(tr -d '\r' < "$SOC_ARGS" | tr '\n' ' ')+# only what differs from the kernel's built-in defaults: the rest changes nothing, and the command line is short+. tools/soc-only-changes.sh+SOC=""; [ -n "$SOC_ARGS" ] && SOC=$(soc_only_changes "$SOC_ARGS" | tr '\n' ' ')for i in $(seq 1 2160); do s=$(./xl state); [ "$s" != absent ] && break; sleep 10; doneecho "$(date +%T) phone: $s"; [ "$s" = absent ] && { echo "NO PHONE"; exit 1; }./xl enter 2>&1 | tail -1diff --git a/tools/soc-only-changes-test.sh b/tools/soc-only-changes-test.shnew file mode 100644index 0000000..2f44ba4--- /dev/null+++ b/tools/soc-only-changes-test.sh@@ -0,0 +1,36 @@+#!/bin/bash+# tools/soc-only-changes.sh: the reference's own values are not sent; a port's differences are; CRs do not matter.+cd "$(dirname "$0")/.." || exit 1+. tools/soc-only-changes.sh+fails=0+check() { # check LABEL WANT GOT+ if [ "$2" = "$3" ]; then echo "ok $1"; else echo "FAIL $1"; echo " want: [$2]"; echo " got: [$3]"; fails=$((fails + 1)); fi+}+ref=devices/poco-x5-pro/soc.args+tmp=$(mktemp -d); trap 'rm -rf "$tmp"' EXIT++check "the reference phone's own soc.args sends nothing" "" "$(soc_only_changes $ref | tr '\n' ' ')"++# a port: one value differs, one is new, the rest equal the defaults+{ cat $ref | sed 's/^soc_aoss=.*/soc_aoss=0x1000000/'; echo "soc_extra=0x5"; } > "$tmp/port.args"+check "a port sends only its differences" "soc_aoss=0x1000000 soc_extra=0x5 " "$(soc_only_changes "$tmp/port.args" | tr '\n' ' ')"++# the same file with Windows line endings+sed 's/$/\r/' "$tmp/port.args" > "$tmp/port-crlf.args"+got=$(soc_only_changes "$tmp/port-crlf.args" | tr '\n' ' ')+check "CRLF line endings: same result" "soc_aoss=0x1000000 soc_extra=0x5 " "$got"+check "CRLF line endings: no CR in what is sent" "0" "$(printf '%s' "$got" | tr -cd '\r' | wc -c | tr -d ' ')"++# the reference file itself with CRLF still sends nothing+sed 's/$/\r/' $ref > "$tmp/ref-crlf.args"+check "the reference with CRLF sends nothing" "" "$(soc_only_changes "$tmp/ref-crlf.args" | tr '\n' ' ')"++printf '# a comment\n\nsoc_x=0x1\n' > "$tmp/c.args"+check "comments and blank lines are dropped" "soc_x=0x1 " "$(soc_only_changes "$tmp/c.args" | tr '\n' ' ')"+check "a missing file sends nothing, and is not an error" "" "$(soc_only_changes "$tmp/none.args" | tr '\n' ' ')"+check "without a reference file everything is sent" "soc_x=0x1 " "$(SOC_DEFAULTS=$tmp/no-such-ref soc_only_changes "$tmp/c.args" | tr '\n' ' ')"++# what it buys: the command line of a run of the reference phone+all=$(tr -d '\r' < $ref | tr '\n' ' ' | wc -c | tr -d ' ')+echo "info: all 16 soc_* values are $all characters of the kernel's 607; for the reference phone $(soc_only_changes $ref | wc -c | tr -d ' ') are sent"+[ "$fails" -eq 0 ] && echo "soc-only-changes-test: all passed" || { echo "soc-only-changes-test: $fails FAILED"; exit 1; }diff --git a/tools/soc-only-changes.sh b/tools/soc-only-changes.shnew file mode 100644index 0000000..583e984--- /dev/null+++ b/tools/soc-only-changes.sh@@ -0,0 +1,20 @@+#!/bin/bash+# soc_only_changes FILE: the lines of a soc.args that DIFFER from the kernel's built-in defaults.+#+# Sourced by tools/modem-cycle.sh and tools/modem-cycle-win.sh, which add the soc_* arguments of a port to+# the kernel's command line. The kernel carries the reference phone's values as defaults+# (devices/poco-x5-pro/soc.args holds them): an argument equal to its default changes nothing, and the+# command line has room for 607 characters, of which sixteen soc_* values take about 340. A run with all of+# them lost the end of its command line without a word (the loader now says so). A port that differs from the+# reference in two values sends two.+#+# CRs are dropped (a file checked out on Windows may have them); lines that are blank or comments are dropped.+soc_only_changes() {+ local file=$1 ref=${SOC_DEFAULTS:-devices/poco-x5-pro/soc.args}+ [ -f "$file" ] || return 0+ if [ -f "$ref" ]; then+ tr -d '\r' < "$file" | grep -vE '^[[:space:]]*(#|$)' | grep -vxF -f <(tr -d '\r' < "$ref") || true+ else+ tr -d '\r' < "$file" | grep -vE '^[[:space:]]*(#|$)' || true+ fi+}