# jprx/qemu-sptm architecture

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

- Interactive diagram: https://gitdiagram.com/jprx/qemu-sptm
- Repository: https://github.com/jprx/qemu-sptm

## Overview

qemu-sptm is a QEMU-based Apple Silicon/Darwin hardware emulator. The principal workflow is to start the `darwin` machine with a kernelcache, device tree, and optional SPTM/TXM firmware, trustcache, and ramdisk, then boot XNU. The README documents the machine options and major emulation capabilities; source excerpts are limited, so the graph does not claim unshown implementation-level calls. The external `darwin-vm` scripts prepare inputs but are outside this repository.

Main entry points: [`hw/arm/darwin.c`](https://github.com/jprx/qemu-sptm/blob/main/hw/arm/darwin.c) (Darwin machine), [`hw/arm`](https://github.com/jprx/qemu-sptm/tree/main/hw/arm) (Firmware boot), [`hw/arm/xnu_patch.c`](https://github.com/jprx/qemu-sptm/blob/main/hw/arm/xnu_patch.c) (XNU patching), [`target/arm/tcg/pauth_helper.c`](https://github.com/jprx/qemu-sptm/blob/main/target/arm/tcg/pauth_helper.c) (PAC handling)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_boot["Boot inputs"]
  node_kernel["Kernelcache"]
  node_dtree["Device tree"]
  node_sptmfirmware["SPTM firmware"]
  node_txmfirmware["TXM firmware"]
  node_trustcache["Trustcache"]
  node_ramdisk["APFS ramdisk"]
end

subgraph group_machine["Darwin machine"]
  node_machine["Darwin machine<br/>[darwin.c]"]
  node_firmwareboot["Firmware boot"]
  node_xnu_patch["XNU patching<br/>[xnu_patch.c]"]
end

subgraph group_security["Security emulation"]
  node_sprr_gxf["SPRR / GXF"]
  node_sptm_txm["SPTM / TXM"]
  node_mie_mte["MIE / MTE"]
  node_pac["PAC handling<br/>[pauth_helper.c]"]
end

subgraph group_devices["Apple devices"]
  node_apple_regs["Apple registers<br/>[apple_regs.c]"]
  node_amcc["AMCC emulation<br/>[apple_amcc.c]"]
  node_aic["AIC emulation"]
  node_sep["SEP emulation"]
  node_uart_fiq["UART / FIQ"]
end

node_operator(("VM operator"))
node_darwinvm["darwin-vm tools"]

node_operator -->|"starts"| node_machine
node_operator -->|"provides"| node_kernel
node_operator -->|"provides"| node_dtree
node_operator -.->|"optionally provides"| node_sptmfirmware
node_operator -.->|"optionally provides"| node_txmfirmware
node_operator -.->|"optionally provides"| node_trustcache
node_operator -.->|"optionally provides"| node_ramdisk
node_darwinvm -->|"prepares"| node_dtree
node_darwinvm -.->|"fetches"| node_kernel
node_darwinvm -.->|"fetches"| node_sptmfirmware
node_darwinvm -.->|"fetches"| node_txmfirmware
node_darwinvm -.->|"prepares"| node_trustcache
node_darwinvm -.->|"prepares"| node_ramdisk
node_machine -->|"boots"| node_firmwareboot
node_machine -->|"applies patch"| node_xnu_patch
node_machine -->|"emulates"| node_sprr_gxf
node_machine -->|"emulates"| node_sptm_txm
node_machine -->|"emulates"| node_mie_mte
node_machine -->|"uses"| node_pac
node_machine -->|"emulates"| node_apple_regs
node_machine -->|"emulates"| node_amcc
node_machine -->|"emulates"| node_aic
node_machine -->|"emulates"| node_sep
node_machine -->|"supports"| node_uart_fiq
node_machine -->|"loads"| node_trustcache
node_machine -->|"loads"| node_ramdisk

click node_machine "https://github.com/jprx/qemu-sptm/blob/main/hw/arm/darwin.c"
click node_firmwareboot "https://github.com/jprx/qemu-sptm/tree/main/hw/arm"
click node_xnu_patch "https://github.com/jprx/qemu-sptm/blob/main/hw/arm/xnu_patch.c"
click node_sprr_gxf "https://github.com/jprx/qemu-sptm/tree/main/hw/arm"
click node_sptm_txm "https://github.com/jprx/qemu-sptm/tree/main/hw/arm"
click node_mie_mte "https://github.com/jprx/qemu-sptm/tree/main/hw/arm"
click node_pac "https://github.com/jprx/qemu-sptm/blob/main/target/arm/tcg/pauth_helper.c"
click node_apple_regs "https://github.com/jprx/qemu-sptm/blob/main/hw/arm/apple_regs.c"
click node_amcc "https://github.com/jprx/qemu-sptm/blob/main/hw/arm/apple_amcc.c"
click node_aic "https://github.com/jprx/qemu-sptm/tree/main/hw/arm"
click node_sep "https://github.com/jprx/qemu-sptm/tree/main/hw/arm"
click node_uart_fiq "https://github.com/jprx/qemu-sptm/tree/main/hw/arm"

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_kernel,node_dtree,node_sptmfirmware,node_txmfirmware,node_trustcache,node_ramdisk toneBlue
class node_machine,node_firmwareboot,node_xnu_patch toneAmber
class node_sprr_gxf,node_sptm_txm,node_mie_mte,node_pac toneMint
class node_apple_regs,node_amcc,node_aic,node_sep,node_uart_fiq toneRose
class node_operator,node_darwinvm toneIndigo
```

## Components

### Boot inputs

- **Kernelcache**
- **Device tree**
- **SPTM firmware**
- **TXM firmware**
- **Trustcache**
- **APFS ramdisk**

### Darwin machine

- [Darwin machine](https://github.com/jprx/qemu-sptm/blob/main/hw/arm/darwin.c): `hw/arm/darwin.c`
- [Firmware boot](https://github.com/jprx/qemu-sptm/tree/main/hw/arm): `hw/arm`
- [XNU patching](https://github.com/jprx/qemu-sptm/blob/main/hw/arm/xnu_patch.c): `hw/arm/xnu_patch.c`

### Security emulation

- [SPRR / GXF](https://github.com/jprx/qemu-sptm/tree/main/hw/arm): `hw/arm`
- [SPTM / TXM](https://github.com/jprx/qemu-sptm/tree/main/hw/arm): `hw/arm`
- [MIE / MTE](https://github.com/jprx/qemu-sptm/tree/main/hw/arm): `hw/arm`
- [PAC handling](https://github.com/jprx/qemu-sptm/blob/main/target/arm/tcg/pauth_helper.c): `target/arm/tcg/pauth_helper.c`

### Apple devices

- [Apple registers](https://github.com/jprx/qemu-sptm/blob/main/hw/arm/apple_regs.c): `hw/arm/apple_regs.c`
- [AMCC emulation](https://github.com/jprx/qemu-sptm/blob/main/hw/arm/apple_amcc.c): `hw/arm/apple_amcc.c`
- [AIC emulation](https://github.com/jprx/qemu-sptm/tree/main/hw/arm): `hw/arm`
- [SEP emulation](https://github.com/jprx/qemu-sptm/tree/main/hw/arm): `hw/arm`
- [UART / FIQ](https://github.com/jprx/qemu-sptm/tree/main/hw/arm): `hw/arm`

### Other components

- **VM operator**
- **darwin-vm tools**

## Connections

- VM operator → Darwin machine: starts (evidence: `README.md`)
- VM operator → Kernelcache: provides (evidence: `README.md`)
- VM operator → Device tree: provides (evidence: `README.md`)
- VM operator → SPTM firmware: optionally provides (evidence: `README.md`)
- VM operator → TXM firmware: optionally provides (evidence: `README.md`)
- VM operator → Trustcache: optionally provides (evidence: `README.md`)
- VM operator → APFS ramdisk: optionally provides (evidence: `README.md`)
- darwin-vm tools → Device tree: prepares (evidence: `README.md`)
- darwin-vm tools → Kernelcache: fetches (evidence: `README.md`)
- darwin-vm tools → SPTM firmware: fetches (evidence: `README.md`)
- darwin-vm tools → TXM firmware: fetches (evidence: `README.md`)
- darwin-vm tools → Trustcache: prepares (evidence: `README.md`)
- darwin-vm tools → APFS ramdisk: prepares (evidence: `README.md`)
- Darwin machine → Firmware boot: boots (evidence: `README.md`)
- Darwin machine → XNU patching: applies patch (evidence: `README.md`)
- Darwin machine → SPRR / GXF: emulates (evidence: `README.md`)
- Darwin machine → SPTM / TXM: emulates (evidence: `README.md`)
- Darwin machine → MIE / MTE: emulates (evidence: `README.md`)
- Darwin machine → PAC handling: uses (evidence: `README.md`)
- Darwin machine → Apple registers: emulates (evidence: `README.md`)
- Darwin machine → AMCC emulation: emulates (evidence: `README.md`)
- Darwin machine → AIC emulation: emulates (evidence: `README.md`)
- Darwin machine → SEP emulation: emulates (evidence: `README.md`)
- Darwin machine → UART / FIQ: supports (evidence: `README.md`)
- Darwin machine → Trustcache: loads (evidence: `README.md`)
- Darwin machine → APFS ramdisk: loads (evidence: `README.md`)
