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

The primary GW provisioning session is activated on the USIM of logical slot 1: after the slot switch it was none and the modem sat in power save

shimoku745bc87fdbeea3
diff --git a/docs/cellular.md b/docs/cellular.md
index 66c55a6..2eea9d0 100644
--- a/docs/cellular.md
+++ b/docs/cellular.md
@@ -254,3 +254,18 @@ Register = `UIM_UNINITIALIZED`: SIM ще ініціалізується післ
(селектори знайдені в кеші dyld). `inject_sb.c` тепер перехоплює цей метод: коли
`kern.redwood.cellular_registered`, виставляє палички через barsSetter і вмикає пункт; раз на 3 с
просить пункт оновитися, коли стан у ядрі змінюється; список методів агрегатора пишеться в лог.
+
+### Прогін 32 (25 жовтня): хук статус-бару живий; підписка ні до чого не прив'язана
+
+- Хук у SpringBoard працює: `_updateSignalStrengthItem:withData:SIMInfo:barsGetter:barsSetter:`
+ викликається для пунктів 4 (основна SIM) і 5 (друга), setter-и передаються, і за нашим
+ проханням пункт оновлюється; повний список методів агрегатора є в лозі
+ (`_postItem:withState:inList:`, `_updateBatteryItems`, …).
+- UIM після перемикання слота: USIM у логічному слоті 1 READY, PIN1 вимкнений, але **первинний
+ GW-додаток — 0xffff (немає)**, і NAS System Info показує service 4 (power save) по всіх радіо.
+ Тобто підписці не призначено USIM. Прогін 33: UIM Change Provisioning Session (0x38): primary GW,
+ activate, слот 1 + AID USIM, потім повторне Initiate Network Register.
+- Прогони з самим модемом не вмикали решту заліза: GPU (`gpu=1`), DSP/батарея (`adsp=1`),
+ вібро (`haptic=5`), Wi-Fi (`wifi=1`) — звідси «no GPU to draw with», `SOC=-1%`, без вібрації.
+ Прогін 33 — з усім разом. Тач працює, коли екран увімкнений (iOS гасить його через ~25 с
+ бездіяльності; кнопка живлення будить).
diff --git a/xnu/files/bsd/dev/redwood_mpss.c b/xnu/files/bsd/dev/redwood_mpss.c
index bb064d2..f7c21b1 100644
--- a/xnu/files/bsd/dev/redwood_mpss.c
+++ b/xnu/files/bsd/dev/redwood_mpss.c
@@ -5282,8 +5282,9 @@ dms_online(void)
#define QMI_UIM 0x0b
#define UIM_GET_CARD_STATUS 0x002f
#define UIM_SWITCH_SLOT 0x0046
+#define UIM_CHANGE_PROVISIONING_SESSION 0x0038
static volatile uint32_t sim_slot_ready; /* the physical slot whose card is READY, found by uim_receive(); 0: none yet */
-static volatile bool sim_slot_switched;
+static volatile bool sim_slot_switched, sim_provisioned, sim_register_again;
#define NAS_INITIATE_NETWORK_REGISTER 0x0022
#define NAS_GET_SYSTEM_SELECTION_PREFERENCE 0x0034
#define NAS_GET_SYSTEM_INFO 0x004d
@@ -5327,6 +5328,11 @@ uim_receive(__unused void *context, __unused uint32_t node, __unused uint32_t po
tell("mpss: uim: the modem answers the slot switch\n");
return;
}
+ if ((m[3] | m[4] << 8) == UIM_CHANGE_PROVISIONING_SESSION) {
+ tell("mpss: uim: the modem answers the provisioning change: registration will be asked for again\n");
+ sim_register_again = true;
+ return;
+ }
if ((m[3] | m[4] << 8) != UIM_GET_CARD_STATUS || (v = qmi_tlv(m, length, 0x10, &size)) == NULL || size < 9) {
return;
}
@@ -5338,7 +5344,8 @@ uim_receive(__unused void *context, __unused uint32_t node, __unused uint32_t po
static const char *const card_states[] = { "ABSENT", "PRESENT", "ERROR" };
static const char *const app_states[] = { "unknown", "detected", "PIN1 WANTED", "PUK1 wanted", "personalization", "PIN1 blocked",
"illegal", "READY" };
- unsigned at = 8, slots = v[8], first_card = ~0u;
+ unsigned at = 8, slots = v[8], first_card = ~0u, primary_gw = (unsigned)(v[0] | v[1] << 8);
+ uint8_t ready_aid[1 + 32] = { 0 }; /* the AID (a length, then the bytes) of a READY USIM in logical slot 1 */
tell("mpss: uim: the primary GW application is slot %u application %u (0xff: none)\n", v[1], v[0]);
at = 9;
@@ -5362,6 +5369,10 @@ uim_receive(__unused void *context, __unused uint32_t node, __unused uint32_t po
if (card == 1 && state == 7 && sim_slot_ready == 0) {
sim_slot_ready = slot + 1;
}
+ if (slot == 0 && card == 1 && state == 7 && (type == 2 || type == 1) && aid <= 32 && at + 7 + aid <= size) {
+ ready_aid[0] = (uint8_t)aid;
+ memcpy(ready_aid + 1, v + at + 7, aid);
+ }
at += 7 + aid + 7;
}
}
@@ -5371,6 +5382,30 @@ uim_receive(__unused void *context, __unused uint32_t node, __unused uint32_t po
* physical slot 2 (UIM Switch Slot: TLV 1 the logical slot, TLV 2 the physical one, both from 1), as
* Android's telephony does with its dual-SIM mapping (modem_sim_switch=0: not).
*/
+ /*
+ * The primary GW provisioning session: which application the subscription NAS registers with uses.
+ * After the slots are switched it is "none" (0xffff: cycle 32), and the modem sits in power save
+ * with no service: the READY USIM of logical slot 1 is made the primary GW application (UIM
+ * Change Provisioning Session: session type 0, activate 1, the slot and the AID).
+ */
+ if (primary_gw == 0xffff && ready_aid[0] != 0 && !sim_provisioned && uim_port != NULL) {
+ uint8_t pr[7 + 5 + 3 + 2 + 32];
+ unsigned n = 0;
+
+ pr[n++] = 0; pr[n++] = 0x37; pr[n++] = 0;
+ pr[n++] = UIM_CHANGE_PROVISIONING_SESSION & 0xff; pr[n++] = UIM_CHANGE_PROVISIONING_SESSION >> 8;
+ pr[n++] = 0; pr[n++] = 0; /* the length, below */
+ pr[n++] = 0x01; pr[n++] = 2; pr[n++] = 0; pr[n++] = 0; pr[n++] = 1; /* primary GW, activate */
+ pr[n++] = 0x10; pr[n++] = (uint8_t)(2 + ready_aid[0]); pr[n++] = 0;
+ pr[n++] = 1; /* logical slot 1 */
+ pr[n++] = ready_aid[0];
+ memcpy(pr + n, ready_aid + 1, ready_aid[0]);
+ n += ready_aid[0];
+ pr[5] = (uint8_t)(n - 7); pr[6] = (uint8_t)((n - 7) >> 8);
+ sim_provisioned = true;
+ tell("mpss: uim: THE USIM OF SLOT 1 IS MADE THE PRIMARY GW APPLICATION (AID of %u bytes)\n", ready_aid[0]);
+ qrtr_send(uim_port, uim_node, uim_port_number, pr, n);
+ }
if (first_card != 1 && sim_slot_ready > 1 && !sim_slot_switched && !option("modem_sim_switch_off") && uim_port != NULL) {
uint8_t sw[7 + 4 + 7] = { 0, 0x34, 0, UIM_SWITCH_SLOT & 0xff, UIM_SWITCH_SLOT >> 8, 11, 0,
1, 1, 0, 1, 2, 4, 0, (uint8_t)sim_slot_ready, 0, 0, 0 };
@@ -5520,7 +5555,7 @@ sim_probe_close(void)
}
uim_node = uim_port_number = nas2_node = nas2_port_number = 0;
sim_slot_ready = 0;
- sim_slot_switched = false;
+ sim_slot_switched = sim_provisioned = sim_register_again = false;
}
static bool
@@ -5569,6 +5604,14 @@ step_nas(void)
probed_again = true;
sim_probe();
}
+ if (sim_register_again && nas2_port_number != 0) {
+ uint8_t reg[11] = { 0, 0x38, 0, NAS_INITIATE_NETWORK_REGISTER & 0xff, NAS_INITIATE_NETWORK_REGISTER >> 8, 4, 0, 1, 1, 0, 1 };
+
+ sim_register_again = false;
+ sleep_ms(3000);
+ qrtr_send(nas2_port, nas2_node, nas2_port_number, reg, sizeof(reg));
+ printf("mpss: nas: automatic registration asked for again after the provisioning\n");
+ }
if (probed && now_us() - watched_at > 10000000ull && uim_port_number != 0 && nas2_port_number != 0) {
/* every ten seconds: the card's state as it initializes, and the system's service status */
uint8_t card[7] = { 0, 0x35, 0, UIM_GET_CARD_STATUS & 0xff, UIM_GET_CARD_STATUS >> 8, 0, 0 };