# 0xsojalsec/ios-sweet architecture

> Architecture diagram of the GitHub repository 0xsojalsec/ios-sweet, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/0xsojalsec/ios-sweet
- Repository: https://github.com/0xsojalsec/ios-sweet

## Overview

ios-sweet ports the iOS 16-era XNU kernel to the Redmi Note 10 Pro and boots an unmodified iPhone X iOS userland. The main path is the stock bootloader launching the shim, which loads an XNU payload and generated Apple Device Tree; XNU then mounts the writable HFS+ root and starts launchd and the graphical userland. The README also documents device-specific CPU, display, input, identity, and activation support. Kernel behavior is represented by the relevant patch files; unsampled XNU internals and wiring are not inferred beyond documented relationships.

Main entry points: [`shim/shim.c`](https://github.com/0xsojalsec/ios-sweet/blob/main/shim/shim.c) (Shim entry), [`xnu/patches`](https://github.com/0xsojalsec/ios-sweet/tree/main/xnu/patches) (Patched XNU), [`tools/mkadt.py`](https://github.com/0xsojalsec/ios-sweet/blob/main/tools/mkadt.py) (ADT builder), [`shim/loader.c`](https://github.com/0xsojalsec/ios-sweet/blob/main/shim/loader.c) (Payload loader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_boot["Boot shim"]
  node_shim["Shim entry<br/>[shim.c]"]
  node_console["Framebuffer console<br/>[console.c]"]
  node_mmu["MMU setup<br/>[mmu.c]"]
  node_fdt["FDT reader<br/>[fdt.c]"]
  node_loader["Payload loader<br/>[loader.c]"]
  node_ufsprobe["UFS probe<br/>[ufs.c]"]
end

subgraph group_prep["Boot data"]
  node_adtlib["ADT parser<br/>[adt.py]"]
  node_adtbuild["ADT builder<br/>[mkadt.py]"]
  node_payload["Kernel packer<br/>[mkpayload.py]"]
end

subgraph group_kernel["XNU port"]
  node_xnu["Patched XNU"]
  node_ufsdriver["UFS root driver"]
  node_hfs["HFS+ root support"]
  node_display["Software display"]
  node_touch["Touch and keys"]
  node_identity["Device identity"]
  node_activation["Native activation<br/>[mkadt.py]"]
end

subgraph group_runtime["iOS runtime"]
  node_root[("HFS+ userdata")]
  node_userland["iOS userland"]
  node_gui["SpringBoard GUI"]
end

node_abl(("Xiaomi bootloader"))
node_hardware(("Phone hardware"))

node_abl -->|"boots"| node_shim
node_shim -->|"writes status"| node_console
node_shim -->|"sets up"| node_mmu
node_shim -->|"loads payload"| node_loader
node_loader -->|"reads chosen"| node_fdt
node_shim -.->|"runs probe"| node_ufsprobe
node_adtbuild -->|"uses parser"| node_adtlib
node_payload -->|"parses ADT"| node_adtlib
node_adtbuild -->|"supplies ADT"| node_payload
node_payload -->|"packages boot data"| node_loader
node_loader -->|"jumps to"| node_xnu
node_xnu -.->|"includes port"| node_ufsdriver
node_ufsdriver -->|"mounts root"| node_hfs
node_hfs -->|"reads and writes"| node_root
node_root -->|"provides root image"| node_userland
node_userland -->|"starts GUI"| node_gui
node_xnu -->|"provides services"| node_display
node_display -->|"presents frames"| node_hardware
node_xnu -->|"delivers input"| node_touch
node_touch -->|"reads input"| node_hardware
node_adtbuild -->|"sets device tree"| node_identity
node_adtbuild -->|"sets security status"| node_activation
node_activation -->|"selects activation path"| node_userland
node_xnu -.->|"reports identity"| node_identity

click node_shim "https://github.com/0xsojalsec/ios-sweet/blob/main/shim/shim.c"
click node_console "https://github.com/0xsojalsec/ios-sweet/blob/main/shim/console.c"
click node_mmu "https://github.com/0xsojalsec/ios-sweet/blob/main/shim/mmu.c"
click node_fdt "https://github.com/0xsojalsec/ios-sweet/blob/main/shim/fdt.c"
click node_loader "https://github.com/0xsojalsec/ios-sweet/blob/main/shim/loader.c"
click node_ufsprobe "https://github.com/0xsojalsec/ios-sweet/blob/main/shim/ufs.c"
click node_adtlib "https://github.com/0xsojalsec/ios-sweet/blob/main/tools/adt.py"
click node_adtbuild "https://github.com/0xsojalsec/ios-sweet/blob/main/tools/mkadt.py"
click node_payload "https://github.com/0xsojalsec/ios-sweet/blob/main/tools/mkpayload.py"
click node_xnu "https://github.com/0xsojalsec/ios-sweet/tree/main/xnu/patches"
click node_ufsdriver "https://github.com/0xsojalsec/ios-sweet/blob/main/xnu/patches/0028-sweet-ufs-root-device.patch"
click node_hfs "https://github.com/0xsojalsec/ios-sweet/blob/main/xnu/patches/0026-sweet-builtin-hfs.patch"
click node_display "https://github.com/0xsojalsec/ios-sweet/blob/main/xnu/patches/0046-sweet-iosurface-iomfb.patch"
click node_touch "https://github.com/0xsojalsec/ios-sweet/blob/main/xnu/patches/0060-sweet-keys-touch-drivers.patch"
click node_identity "https://github.com/0xsojalsec/ios-sweet/blob/main/xnu/patches/0059-sweet-iphone-identity.patch"
click node_activation "https://github.com/0xsojalsec/ios-sweet/blob/main/tools/mkadt.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_shim,node_console,node_mmu,node_fdt,node_loader,node_ufsprobe toneBlue
class node_adtlib,node_adtbuild,node_payload toneAmber
class node_xnu,node_ufsdriver,node_hfs,node_display,node_touch,node_identity,node_activation toneMint
class node_root,node_userland,node_gui toneRose
class node_abl,node_hardware toneIndigo
```

## Components

### Boot shim

- [Shim entry](https://github.com/0xsojalsec/ios-sweet/blob/main/shim/shim.c): `shim/shim.c`
- [Framebuffer console](https://github.com/0xsojalsec/ios-sweet/blob/main/shim/console.c): `shim/console.c`
- [MMU setup](https://github.com/0xsojalsec/ios-sweet/blob/main/shim/mmu.c): `shim/mmu.c`
- [FDT reader](https://github.com/0xsojalsec/ios-sweet/blob/main/shim/fdt.c): `shim/fdt.c`
- [Payload loader](https://github.com/0xsojalsec/ios-sweet/blob/main/shim/loader.c): `shim/loader.c`
- [UFS probe](https://github.com/0xsojalsec/ios-sweet/blob/main/shim/ufs.c): `shim/ufs.c`

### Boot data

- [ADT parser](https://github.com/0xsojalsec/ios-sweet/blob/main/tools/adt.py): `tools/adt.py`
- [ADT builder](https://github.com/0xsojalsec/ios-sweet/blob/main/tools/mkadt.py): `tools/mkadt.py`
- [Kernel packer](https://github.com/0xsojalsec/ios-sweet/blob/main/tools/mkpayload.py): `tools/mkpayload.py`

### XNU port

- [Patched XNU](https://github.com/0xsojalsec/ios-sweet/tree/main/xnu/patches): `xnu/patches`
- [UFS root driver](https://github.com/0xsojalsec/ios-sweet/blob/main/xnu/patches/0028-sweet-ufs-root-device.patch): `xnu/patches/0028-sweet-ufs-root-device.patch`
- [HFS+ root support](https://github.com/0xsojalsec/ios-sweet/blob/main/xnu/patches/0026-sweet-builtin-hfs.patch): `xnu/patches/0026-sweet-builtin-hfs.patch`
- [Software display](https://github.com/0xsojalsec/ios-sweet/blob/main/xnu/patches/0046-sweet-iosurface-iomfb.patch): `xnu/patches/0046-sweet-iosurface-iomfb.patch`
- [Touch and keys](https://github.com/0xsojalsec/ios-sweet/blob/main/xnu/patches/0060-sweet-keys-touch-drivers.patch): `xnu/patches/0060-sweet-keys-touch-drivers.patch`
- [Device identity](https://github.com/0xsojalsec/ios-sweet/blob/main/xnu/patches/0059-sweet-iphone-identity.patch): `xnu/patches/0059-sweet-iphone-identity.patch`
- [Native activation](https://github.com/0xsojalsec/ios-sweet/blob/main/tools/mkadt.py): `tools/mkadt.py`

### iOS runtime

- **HFS+ userdata**
- **iOS userland**
- **SpringBoard GUI**

### Other components

- **Xiaomi bootloader**
- **Phone hardware**

## Connections

- Xiaomi bootloader → Shim entry: boots (evidence: `README.md`)
- Shim entry → Framebuffer console: writes status (evidence: `shim/shim.c`)
- Shim entry → MMU setup: sets up (evidence: `shim/shim.c`)
- Shim entry → Payload loader: loads payload (evidence: `shim/shim.c`)
- Payload loader → FDT reader: reads chosen (evidence: `shim/loader.c`)
- Shim entry → UFS probe: runs probe
- ADT builder → ADT parser: uses parser (evidence: `tools/mkadt.py`)
- Kernel packer → ADT parser: parses ADT (evidence: `tools/mkpayload.py`)
- ADT builder → Kernel packer: supplies ADT (evidence: `README.md`)
- Kernel packer → Payload loader: packages boot data (evidence: `README.md`)
- Payload loader → Patched XNU: jumps to (evidence: `shim/loader.c`)
- Patched XNU → UFS root driver: includes port
- UFS root driver → HFS+ root support: mounts root (evidence: `README.md`)
- HFS+ root support → HFS+ userdata: reads and writes (evidence: `README.md`)
- HFS+ userdata → iOS userland: provides root image (evidence: `README.md`)
- iOS userland → SpringBoard GUI: starts GUI (evidence: `README.md`)
- Patched XNU → Software display: provides services (evidence: `README.md`)
- Software display → Phone hardware: presents frames (evidence: `README.md`)
- Patched XNU → Touch and keys: delivers input (evidence: `README.md`)
- Touch and keys → Phone hardware: reads input (evidence: `README.md`)
- ADT builder → Device identity: sets device tree (evidence: `tools/mkadt.py`)
- ADT builder → Native activation: sets security status (evidence: `tools/mkadt.py`)
- Native activation → iOS userland: selects activation path (evidence: `tools/mkadt.py`)
- Patched XNU → Device identity: reports identity
