# terries111/netos architecture

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

- Interactive diagram: https://gitdiagram.com/terries111/netos
- Repository: https://github.com/terries111/netos

## Overview

NetOS is a freestanding AArch64 operating-system kernel targeting Cortex-A53 on QEMU virt. Its demonstrated startup workflow initializes serial output, reads the device tree to discover memory and GIC registers, initializes physical memory and virtual memory, enables interrupt/timer support, and brings up the heap. The repository also contains exception handling, CPU diagnostics, logging, and formatted output. Some subsystem implementations are indexed as read but not excerpted, so their internal call relationships are omitted rather than inferred.

Main entry points: [`kernel/main.c`](https://github.com/terries111/netos/blob/main/kernel/main.c) (Kernel Initialization), [`mm/heap.c`](https://github.com/terries111/netos/blob/main/mm/heap.c) (Kernel Heap), [`mm/mmu.c`](https://github.com/terries111/netos/blob/main/mm/mmu.c) (Virtual Memory), [`mm/pmm.c`](https://github.com/terries111/netos/blob/main/mm/pmm.c) (Physical Allocator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_startup["Kernel Startup"]
  node_kernel_main["Kernel Initialization<br/>[main.c]"]
  node_device_tree["Device Tree Parser<br/>[fdt.c]"]
end

subgraph group_hardware["Hardware Support"]
  node_uart["PL011 UART<br/>[pl011.c]"]
  node_gic["GICv2 Controller<br/>[gicv2.c]"]
  node_interrupts["Interrupt Dispatch<br/>[interrupt.c]"]
  node_timer["ARM Timer<br/>[timer.c]"]
end

subgraph group_memory["Memory Management"]
  node_pmm["Physical Allocator<br/>[pmm.c]"]
  node_mmu["Virtual Memory<br/>[mmu.c]"]
  node_heap["Kernel Heap<br/>[heap.c]"]
  node_memory_map["Memory Layout<br/>[memory_map.c]"]
end

subgraph group_kernel["Kernel Services"]
  node_exceptions["Exception Handling<br/>[exception.c]"]
  node_cpu["CPU Diagnostics<br/>[cpu.c]"]
  node_logging["Kernel Logging<br/>[log.c]"]
  node_formatting["Formatted Output<br/>[printf.c]"]
  node_panic["Kernel Panic<br/>[panic.c]"]
end

node_boot_actor(("Boot Environment"))

node_boot_actor -.->|"enters kernel"| node_kernel_main
node_kernel_main -->|"initializes"| node_uart
node_kernel_main -->|"discovers devices"| node_device_tree
node_kernel_main -->|"initializes"| node_pmm
node_kernel_main -->|"initializes"| node_memory_map
node_kernel_main -->|"initializes"| node_mmu
node_kernel_main -->|"initializes"| node_gic
node_kernel_main -->|"initializes"| node_timer
node_kernel_main -->|"initializes"| node_heap
node_mmu -->|"allocates tables"| node_pmm
node_heap -->|"allocates pages"| node_pmm
node_heap -->|"maps pages"| node_mmu

click node_kernel_main "https://github.com/terries111/netos/blob/main/kernel/main.c"
click node_device_tree "https://github.com/terries111/netos/blob/main/devicetree/fdt.c"
click node_uart "https://github.com/terries111/netos/blob/main/drivers/uart/pl011.c"
click node_gic "https://github.com/terries111/netos/blob/main/drivers/interrupt/gicv2.c"
click node_interrupts "https://github.com/terries111/netos/blob/main/drivers/interrupt/interrupt.c"
click node_timer "https://github.com/terries111/netos/blob/main/drivers/timer/timer.c"
click node_pmm "https://github.com/terries111/netos/blob/main/mm/pmm.c"
click node_mmu "https://github.com/terries111/netos/blob/main/mm/mmu.c"
click node_heap "https://github.com/terries111/netos/blob/main/mm/heap.c"
click node_memory_map "https://github.com/terries111/netos/blob/main/mm/memory_map.c"
click node_exceptions "https://github.com/terries111/netos/blob/main/kernel/exception.c"
click node_cpu "https://github.com/terries111/netos/blob/main/kernel/cpu.c"
click node_logging "https://github.com/terries111/netos/blob/main/kernel/log.c"
click node_formatting "https://github.com/terries111/netos/blob/main/kernel/printf.c"
click node_panic "https://github.com/terries111/netos/blob/main/kernel/panic.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_kernel_main,node_device_tree toneBlue
class node_uart,node_gic,node_interrupts,node_timer toneAmber
class node_pmm,node_mmu,node_heap,node_memory_map toneMint
class node_exceptions,node_cpu,node_logging,node_formatting,node_panic toneRose
class node_boot_actor toneIndigo
```

## Components

### Kernel Startup

- [Kernel Initialization](https://github.com/terries111/netos/blob/main/kernel/main.c): `kernel/main.c`
- [Device Tree Parser](https://github.com/terries111/netos/blob/main/devicetree/fdt.c): `devicetree/fdt.c`

### Hardware Support

- [PL011 UART](https://github.com/terries111/netos/blob/main/drivers/uart/pl011.c): `drivers/uart/pl011.c`
- [GICv2 Controller](https://github.com/terries111/netos/blob/main/drivers/interrupt/gicv2.c): `drivers/interrupt/gicv2.c`
- [Interrupt Dispatch](https://github.com/terries111/netos/blob/main/drivers/interrupt/interrupt.c): `drivers/interrupt/interrupt.c`
- [ARM Timer](https://github.com/terries111/netos/blob/main/drivers/timer/timer.c): `drivers/timer/timer.c`

### Memory Management

- [Physical Allocator](https://github.com/terries111/netos/blob/main/mm/pmm.c): `mm/pmm.c`
- [Virtual Memory](https://github.com/terries111/netos/blob/main/mm/mmu.c): `mm/mmu.c`
- [Kernel Heap](https://github.com/terries111/netos/blob/main/mm/heap.c): `mm/heap.c`
- [Memory Layout](https://github.com/terries111/netos/blob/main/mm/memory_map.c): `mm/memory_map.c`

### Kernel Services

- [Exception Handling](https://github.com/terries111/netos/blob/main/kernel/exception.c): `kernel/exception.c`
- [CPU Diagnostics](https://github.com/terries111/netos/blob/main/kernel/cpu.c): `kernel/cpu.c`
- [Kernel Logging](https://github.com/terries111/netos/blob/main/kernel/log.c): `kernel/log.c`
- [Formatted Output](https://github.com/terries111/netos/blob/main/kernel/printf.c): `kernel/printf.c`
- [Kernel Panic](https://github.com/terries111/netos/blob/main/kernel/panic.c): `kernel/panic.c`

### Other components

- **Boot Environment**

## Connections

- Boot Environment → Kernel Initialization: enters kernel
- Kernel Initialization → PL011 UART: initializes (evidence: `kernel/main.c`)
- Kernel Initialization → Device Tree Parser: discovers devices (evidence: `kernel/main.c`)
- Kernel Initialization → Physical Allocator: initializes (evidence: `kernel/main.c`)
- Kernel Initialization → Memory Layout: initializes (evidence: `kernel/main.c`)
- Kernel Initialization → Virtual Memory: initializes (evidence: `kernel/main.c`)
- Kernel Initialization → GICv2 Controller: initializes (evidence: `kernel/main.c`)
- Kernel Initialization → ARM Timer: initializes (evidence: `kernel/main.c`)
- Kernel Initialization → Kernel Heap: initializes (evidence: `kernel/main.c`)
- Virtual Memory → Physical Allocator: allocates tables (evidence: `mm/mmu.c`)
- Kernel Heap → Physical Allocator: allocates pages (evidence: `mm/heap.c`)
- Kernel Heap → Virtual Memory: maps pages (evidence: `mm/heap.c`)
