# oosexgang/hakios-xnu-kernel architecture

> Architecture diagram of the GitHub repository oosexgang/hakios-xnu-kernel, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/oosexgang/hakios-xnu-kernel
- Repository: https://github.com/oosexgang/hakios-xnu-kernel

## Overview

HakiOS ports XNU to Android phones and boots it with its own UEFI loader; it also runs in QEMU. The main runtime path is loader handoff to XNU, whose device drivers expose hardware capabilities to user space. The repository also contains a native Adreno Metal implementation and APFS support. The README establishes the high-level product relationships; sampled code confirms details of loader behavior, selected drivers, and Metal rendering. Most driver and user-space internals were not sampled, so their connections are shown only where documented.

Main entry points: [`xnu/files`](https://github.com/oosexgang/hakios-xnu-kernel/tree/main/xnu/files) (XNU kernel), [`drivers`](https://github.com/oosexgang/hakios-xnu-kernel/tree/main/drivers) (Hardware drivers), [`xnuloader/loader.c`](https://github.com/oosexgang/hakios-xnu-kernel/blob/main/xnuloader/loader.c) (XNU loader), [`userland/src`](https://github.com/oosexgang/hakios-xnu-kernel/tree/main/userland/src) (HakiOS user space)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_boot["Boot and kernel"]
  node_loader["XNU loader<br/>[loader.c]"]
  node_xnu["XNU kernel"]
  node_qemu["QEMU runtime"]
end

subgraph group_devices["Device drivers"]
  node_drivers["Hardware drivers"]
  node_touch["Touch input<br/>[hakios.goodix.c]"]
  node_audio["Audio drivers"]
  node_camera["Camera drivers"]
  node_wireless["Wireless drivers"]
end

subgraph group_graphics["Graphics stack"]
  node_gpu["Adreno driver<br/>[hakios.adreno.c]"]
  node_metal["HakiOS Metal<br/>[render.cpp]"]
  node_eagl["EAGL graphics<br/>[eagl.c]"]
end

subgraph group_storage["Storage and images"]
  node_ufs["UFS storage<br/>[hakios.ufs.c]"]
  node_apfs["APFS kernel support"]
  node_sysimage["System image tools"]
end

subgraph group_userspace["User space"]
  node_userland["HakiOS user space"]
end

node_operator(("Device operator"))
node_uefi["UEFI firmware"]

node_operator -->|"starts device"| node_uefi
node_uefi -->|"starts loader"| node_loader
node_loader -->|"loads and boots"| node_xnu
node_xnu -->|"hosts drivers"| node_drivers
node_drivers -->|"provides hardware support"| node_userland
node_drivers -->|"includes"| node_touch
node_gpu -->|"serves GPU commands"| node_metal
node_userland -->|"includes graphics implementation"| node_eagl
node_xnu -->|"includes storage driver"| node_ufs
node_xnu -.->|"includes filesystem support"| node_apfs
node_operator -.->|"prepares system image"| node_sysimage
node_qemu -->|"runs kernel"| node_xnu

click node_loader "https://github.com/oosexgang/hakios-xnu-kernel/blob/main/xnuloader/loader.c"
click node_xnu "https://github.com/oosexgang/hakios-xnu-kernel/tree/main/xnu/files"
click node_drivers "https://github.com/oosexgang/hakios-xnu-kernel/tree/main/drivers"
click node_touch "https://github.com/oosexgang/hakios-xnu-kernel/blob/main/drivers/input/hakios.goodix.c"
click node_audio "https://github.com/oosexgang/hakios-xnu-kernel/tree/main/drivers/audio"
click node_camera "https://github.com/oosexgang/hakios-xnu-kernel/tree/main/drivers/camera"
click node_wireless "https://github.com/oosexgang/hakios-xnu-kernel/tree/main/drivers/wifi"
click node_gpu "https://github.com/oosexgang/hakios-xnu-kernel/blob/main/drivers/gpu/hakios.adreno.c"
click node_metal "https://github.com/oosexgang/hakios-xnu-kernel/blob/main/hakios-metal/src/render.cpp"
click node_eagl "https://github.com/oosexgang/hakios-xnu-kernel/blob/main/userland/src/eagl.c"
click node_ufs "https://github.com/oosexgang/hakios-xnu-kernel/blob/main/drivers/storage/hakios.ufs.c"
click node_apfs "https://github.com/oosexgang/hakios-xnu-kernel/tree/main/xnu/files/bsd/miscfs/apfs"
click node_sysimage "https://github.com/oosexgang/hakios-xnu-kernel/tree/main/sysimage"
click node_userland "https://github.com/oosexgang/hakios-xnu-kernel/tree/main/userland/src"
click node_qemu "https://github.com/oosexgang/hakios-xnu-kernel/tree/main/qemu"

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_loader,node_xnu,node_qemu toneBlue
class node_drivers,node_touch,node_audio,node_camera,node_wireless toneAmber
class node_gpu,node_metal,node_eagl toneMint
class node_ufs,node_apfs,node_sysimage toneRose
class node_userland,node_operator,node_uefi toneIndigo
```

## Components

### Boot and kernel

- [XNU loader](https://github.com/oosexgang/hakios-xnu-kernel/blob/main/xnuloader/loader.c): `xnuloader/loader.c`
- [XNU kernel](https://github.com/oosexgang/hakios-xnu-kernel/tree/main/xnu/files): `xnu/files`
- [QEMU runtime](https://github.com/oosexgang/hakios-xnu-kernel/tree/main/qemu): `qemu`

### Device drivers

- [Hardware drivers](https://github.com/oosexgang/hakios-xnu-kernel/tree/main/drivers): `drivers`
- [Touch input](https://github.com/oosexgang/hakios-xnu-kernel/blob/main/drivers/input/hakios.goodix.c): `drivers/input/hakios.goodix.c`
- [Audio drivers](https://github.com/oosexgang/hakios-xnu-kernel/tree/main/drivers/audio): `drivers/audio`
- [Camera drivers](https://github.com/oosexgang/hakios-xnu-kernel/tree/main/drivers/camera): `drivers/camera`
- [Wireless drivers](https://github.com/oosexgang/hakios-xnu-kernel/tree/main/drivers/wifi): `drivers/wifi`

### Graphics stack

- [Adreno driver](https://github.com/oosexgang/hakios-xnu-kernel/blob/main/drivers/gpu/hakios.adreno.c): `drivers/gpu/hakios.adreno.c`
- [HakiOS Metal](https://github.com/oosexgang/hakios-xnu-kernel/blob/main/hakios-metal/src/render.cpp): `hakios-metal/src/render.cpp`
- [EAGL graphics](https://github.com/oosexgang/hakios-xnu-kernel/blob/main/userland/src/eagl.c): `userland/src/eagl.c`

### Storage and images

- [UFS storage](https://github.com/oosexgang/hakios-xnu-kernel/blob/main/drivers/storage/hakios.ufs.c): `drivers/storage/hakios.ufs.c`
- [APFS kernel support](https://github.com/oosexgang/hakios-xnu-kernel/tree/main/xnu/files/bsd/miscfs/apfs): `xnu/files/bsd/miscfs/apfs`
- [System image tools](https://github.com/oosexgang/hakios-xnu-kernel/tree/main/sysimage): `sysimage`

### User space

- [HakiOS user space](https://github.com/oosexgang/hakios-xnu-kernel/tree/main/userland/src): `userland/src`

### Other components

- **Device operator**
- **UEFI firmware**

## Connections

- Device operator → UEFI firmware: starts device (evidence: `README.md`)
- UEFI firmware → XNU loader: starts loader (evidence: `README.md`)
- XNU loader → XNU kernel: loads and boots (evidence: `xnuloader/loader.c`)
- XNU kernel → Hardware drivers: hosts drivers (evidence: `README.md`)
- Hardware drivers → HakiOS user space: provides hardware support (evidence: `README.md`)
- Hardware drivers → Touch input: includes (evidence: `drivers/input/hakios.goodix.c`)
- Adreno driver → HakiOS Metal: serves GPU commands (evidence: `README.md`)
- HakiOS user space → EAGL graphics: includes graphics implementation (evidence: `userland/src/eagl.c`)
- XNU kernel → UFS storage: includes storage driver (evidence: `drivers/storage/hakios.ufs.c`)
- XNU kernel → APFS kernel support: includes filesystem support (evidence: `README.md`)
- Device operator → System image tools: prepares system image
- QEMU runtime → XNU kernel: runs kernel (evidence: `README.md`)
