# apple-oss-distributions/xnu architecture

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

- Interactive diagram: https://gitdiagram.com/apple-oss-distributions/xnu
- Repository: https://github.com/apple-oss-distributions/xnu

## Overview

XNU is Darwin’s hybrid kernel: Mach supplies core kernel facilities, BSD supplies system and networking interfaces, and IOKit exposes driver and hardware services. The principal workflow is a user process issuing a syscall, followed by policy evaluation, flow setup, packet processing, and delivery through a network device; syscall results return to the process. Separate branches cover bootstrapping, code-signing enforcement, interrupt and platform services, and Exclave storage upcalls. The graph combines README capabilities with sampled source; unsampled relationships are intentionally limited.

Main entry points: [`bsd/kern/uipc_syscalls.c`](https://github.com/apple-oss-distributions/xnu/blob/main/bsd/kern/uipc_syscalls.c) (BSD System Calls), [`bsd/net/if.c`](https://github.com/apple-oss-distributions/xnu/blob/main/bsd/net/if.c) (Network Interfaces), [`bsd/net/necp_client.c`](https://github.com/apple-oss-distributions/xnu/blob/main/bsd/net/necp_client.c) (NECP Policy), [`bsd/skywalk/nexus/flowswitch/flow/flow_manager.c`](https://github.com/apple-oss-distributions/xnu/blob/main/bsd/skywalk/nexus/flowswitch/flow/flow_manager.c) (Flow Manager)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["Kernel Interfaces"]
  node_bsd_syscalls["BSD System Calls<br/>[uipc_syscalls.c]"]
  node_necp_policy["NECP Policy<br/>[necp_client.c]"]
end

subgraph group_network["Networking"]
  node_flow_manager["Flow Manager<br/>[flow_manager.c]"]
  node_skywalk_core["Skywalk Core<br/>[skywalk.c]"]
  node_ip_stack["IP Stack<br/>[ip_output.c]"]
  node_transport_stack["Transport Stack<br/>[tcp_usrreq.c]"]
  node_network_interfaces["Network Interfaces<br/>[if.c]"]
end

subgraph group_iokit["IOKit Hardware"]
  node_interrupt_controller["Interrupt Controller"]
  node_passthru_controller["Passthru Controller"]
  node_nvram_controller["NVRAM Controller"]
  node_rtc_controller["RTC Controller<br/>[IORTCController.h]"]
  node_power_controller["Power Controller<br/>[IOPwrController.h]"]
end

subgraph group_core["Kernel Core"]
  node_mach_core["Mach Kernel"]
  node_bsd_bootstrap["BSD Bootstrap<br/>[bsd_init.c]"]
end

subgraph group_storage["Storage Security"]
  node_exec_security["Exec Security<br/>[kern_exec.c]"]
  node_code_signing["Code Signing<br/>[kern_codesigning.c]"]
  node_storage_upcalls["Storage Upcalls<br/>[exclaves_storage.c]"]
  node_storage_ipc["Storage IPC<br/>[exclaves_storage.c]"]
end

node_user_process(("User Process"))
node_network_device(("Network Device"))
node_platform_firmware(("Platform Firmware"))
node_storage_exclave(("Storage Exclave"))

node_user_process -->|"issues syscalls"| node_bsd_syscalls
node_bsd_syscalls -->|"requests policy"| node_necp_policy
node_necp_policy -->|"registers flows"| node_flow_manager
node_flow_manager -->|"uses nexus"| node_skywalk_core
node_transport_stack -->|"sends packets"| node_ip_stack
node_ip_stack -->|"emits packets"| node_network_interfaces
node_network_interfaces -->|"drives device"| node_network_device
node_network_device -->|"delivers packets"| node_network_interfaces
node_bsd_syscalls -->|"returns result"| node_user_process
node_bsd_bootstrap -->|"starts kernel"| node_mach_core
node_exec_security -->|"checks execution"| node_code_signing
node_platform_firmware -->|"provides platform"| node_passthru_controller
node_passthru_controller -->|"forwards interrupts"| node_interrupt_controller
node_network_device -->|"raises interrupts"| node_interrupt_controller
node_nvram_controller -->|"registers storage"| node_platform_firmware
node_storage_exclave -.->|"calls upcalls"| node_storage_upcalls
node_storage_upcalls -->|"maps shared memory"| node_storage_ipc

click node_bsd_syscalls "https://github.com/apple-oss-distributions/xnu/blob/main/bsd/kern/uipc_syscalls.c"
click node_necp_policy "https://github.com/apple-oss-distributions/xnu/blob/main/bsd/net/necp_client.c"
click node_mach_core "https://github.com/apple-oss-distributions/xnu/tree/main/osfmk"
click node_bsd_bootstrap "https://github.com/apple-oss-distributions/xnu/blob/main/bsd/kern/bsd_init.c"
click node_flow_manager "https://github.com/apple-oss-distributions/xnu/blob/main/bsd/skywalk/nexus/flowswitch/flow/flow_manager.c"
click node_skywalk_core "https://github.com/apple-oss-distributions/xnu/blob/main/bsd/skywalk/core/skywalk.c"
click node_ip_stack "https://github.com/apple-oss-distributions/xnu/blob/main/bsd/netinet/ip_output.c"
click node_transport_stack "https://github.com/apple-oss-distributions/xnu/blob/main/bsd/netinet/tcp_usrreq.c"
click node_network_interfaces "https://github.com/apple-oss-distributions/xnu/blob/main/bsd/net/if.c"
click node_interrupt_controller "https://github.com/apple-oss-distributions/xnu/blob/main/iokit/Kernel/IOInterruptController.cpp"
click node_passthru_controller "https://github.com/apple-oss-distributions/xnu/blob/main/iokit/Kernel/PassthruInterruptController.cpp"
click node_nvram_controller "https://github.com/apple-oss-distributions/xnu/blob/main/iokit/Families/IONVRAM/IONVRAMController.cpp"
click node_rtc_controller "https://github.com/apple-oss-distributions/xnu/blob/main/iokit/IOKit/rtc/IORTCController.h"
click node_power_controller "https://github.com/apple-oss-distributions/xnu/blob/main/iokit/IOKit/power/IOPwrController.h"
click node_exec_security "https://github.com/apple-oss-distributions/xnu/blob/main/bsd/kern/kern_exec.c"
click node_code_signing "https://github.com/apple-oss-distributions/xnu/blob/main/bsd/kern/kern_codesigning.c"
click node_storage_upcalls "https://github.com/apple-oss-distributions/xnu/blob/main/osfmk/kern/exclaves_storage.c"
click node_storage_ipc "https://github.com/apple-oss-distributions/xnu/blob/main/osfmk/kern/exclaves_storage.c"

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_bsd_syscalls,node_necp_policy,node_user_process toneBlue
class node_flow_manager,node_skywalk_core,node_ip_stack,node_transport_stack,node_network_interfaces,node_storage_exclave toneAmber
class node_interrupt_controller,node_passthru_controller,node_nvram_controller,node_rtc_controller,node_power_controller toneMint
class node_mach_core,node_bsd_bootstrap toneRose
class node_exec_security,node_code_signing,node_storage_upcalls,node_storage_ipc,node_network_device,node_platform_firmware toneIndigo
```

## Components

### Kernel Interfaces

- [BSD System Calls](https://github.com/apple-oss-distributions/xnu/blob/main/bsd/kern/uipc_syscalls.c): `bsd/kern/uipc_syscalls.c`
- [NECP Policy](https://github.com/apple-oss-distributions/xnu/blob/main/bsd/net/necp_client.c): `bsd/net/necp_client.c`

### Networking

- [Flow Manager](https://github.com/apple-oss-distributions/xnu/blob/main/bsd/skywalk/nexus/flowswitch/flow/flow_manager.c): `bsd/skywalk/nexus/flowswitch/flow/flow_manager.c`
- [Skywalk Core](https://github.com/apple-oss-distributions/xnu/blob/main/bsd/skywalk/core/skywalk.c): `bsd/skywalk/core/skywalk.c`
- [IP Stack](https://github.com/apple-oss-distributions/xnu/blob/main/bsd/netinet/ip_output.c): `bsd/netinet/ip_output.c`
- [Transport Stack](https://github.com/apple-oss-distributions/xnu/blob/main/bsd/netinet/tcp_usrreq.c): `bsd/netinet/tcp_usrreq.c`
- [Network Interfaces](https://github.com/apple-oss-distributions/xnu/blob/main/bsd/net/if.c): `bsd/net/if.c`

### IOKit Hardware

- [Interrupt Controller](https://github.com/apple-oss-distributions/xnu/blob/main/iokit/Kernel/IOInterruptController.cpp): `iokit/Kernel/IOInterruptController.cpp`
- [Passthru Controller](https://github.com/apple-oss-distributions/xnu/blob/main/iokit/Kernel/PassthruInterruptController.cpp): `iokit/Kernel/PassthruInterruptController.cpp`
- [NVRAM Controller](https://github.com/apple-oss-distributions/xnu/blob/main/iokit/Families/IONVRAM/IONVRAMController.cpp): `iokit/Families/IONVRAM/IONVRAMController.cpp`
- [RTC Controller](https://github.com/apple-oss-distributions/xnu/blob/main/iokit/IOKit/rtc/IORTCController.h): `iokit/IOKit/rtc/IORTCController.h`
- [Power Controller](https://github.com/apple-oss-distributions/xnu/blob/main/iokit/IOKit/power/IOPwrController.h): `iokit/IOKit/power/IOPwrController.h`

### Kernel Core

- [Mach Kernel](https://github.com/apple-oss-distributions/xnu/tree/main/osfmk): `osfmk`
- [BSD Bootstrap](https://github.com/apple-oss-distributions/xnu/blob/main/bsd/kern/bsd_init.c): `bsd/kern/bsd_init.c`

### Storage Security

- [Exec Security](https://github.com/apple-oss-distributions/xnu/blob/main/bsd/kern/kern_exec.c): `bsd/kern/kern_exec.c`
- [Code Signing](https://github.com/apple-oss-distributions/xnu/blob/main/bsd/kern/kern_codesigning.c): `bsd/kern/kern_codesigning.c`
- [Storage Upcalls](https://github.com/apple-oss-distributions/xnu/blob/main/osfmk/kern/exclaves_storage.c): `osfmk/kern/exclaves_storage.c`
- [Storage IPC](https://github.com/apple-oss-distributions/xnu/blob/main/osfmk/kern/exclaves_storage.c): `osfmk/kern/exclaves_storage.c`

### Other components

- **User Process**
- **Network Device**
- **Platform Firmware**
- **Storage Exclave**

## Connections

- User Process → BSD System Calls: issues syscalls
- BSD System Calls → NECP Policy: requests policy
- NECP Policy → Flow Manager: registers flows
- Flow Manager → Skywalk Core: uses nexus
- Transport Stack → IP Stack: sends packets
- IP Stack → Network Interfaces: emits packets
- Network Interfaces → Network Device: drives device
- Network Device → Network Interfaces: delivers packets
- BSD System Calls → User Process: returns result
- BSD Bootstrap → Mach Kernel: starts kernel
- Exec Security → Code Signing: checks execution
- Platform Firmware → Passthru Controller: provides platform
- Passthru Controller → Interrupt Controller: forwards interrupts
- Network Device → Interrupt Controller: raises interrupts
- NVRAM Controller → Platform Firmware: registers storage
- Storage Exclave → Storage Upcalls: calls upcalls
- Storage Upcalls → Storage IPC: maps shared memory
