# adam97-1/novaos architecture

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

- Interactive diagram: https://gitdiagram.com/adam97-1/novaos
- Repository: https://github.com/adam97-1/novaos

## Overview

This repository implements a staged x86 boot path: a first-stage loader leads into stage 1.5, which finds a FAT partition, loads stage 2, and transfers control; stage 2 enables A20 and enters protected mode. It also contains a separate Multiboot kernel that reports boot information. The README is empty, so the map follows the sampled stage code and source index; connections to unsampled first-stage and disk internals are omitted where their calls are not shown.

Main entry points: [`stage1_5/stage1_5.c`](https://github.com/adam97-1/novaos/blob/master/stage1_5/stage1_5.c) (Stage 1.5), [`lib16/fat/fat.c`](https://github.com/adam97-1/novaos/blob/master/lib16/fat/fat.c) (FAT filesystem), [`stage2/stage2.c`](https://github.com/adam97-1/novaos/blob/master/stage2/stage2.c) (Stage 2), [`lib16/mode/mode.c`](https://github.com/adam97-1/novaos/blob/master/lib16/mode/mode.c) (Protected mode)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_boot["Boot stages"]
  node_stage1["Stage 1<br/>[stage1.asm]"]
  node_loader15["Stage 1.5<br/>[stage1_5.c]"]
  node_stage2["Stage 2<br/>[stage2.c]"]
  node_exec["Real-mode transfer<br/>[exec_16b.asm]"]
end

subgraph group_storage["Disk and filesystems"]
  node_disk["Disk access"]
  node_mbr["Partition lookup<br/>[mbr.c]"]
  node_fat["FAT filesystem<br/>[fat.c]"]
  node_memory["Memory helpers<br/>[memory.c]"]
  node_strings["String helpers<br/>[string.c]"]
end

subgraph group_hardware["Platform support"]
  node_a20["A20 enable<br/>[enable_a20_16b.asm]"]
  node_mode["Protected mode<br/>[mode.c]"]
  node_nmi["NMI control<br/>[nmi.c]"]
  node_io["Port I/O<br/>[io.h]"]
  node_printing["Text output<br/>[print.c]"]
end

subgraph group_kernel["Multiboot kernel"]
  node_kernel["Kernel entry<br/>[kernel.c]"]
  node_multiboot["Multiboot definitions<br/>[multiboot2.h]"]
end

node_bios(("Boot firmware"))

node_loader15 -->|"initializes disk"| node_disk
node_loader15 -->|"reads partitions"| node_mbr
node_mbr -->|"reads sectors"| node_disk
node_loader15 -->|"initializes and searches"| node_fat
node_fat -->|"reads sectors"| node_disk
node_fat -->|"uses strings"| node_strings
node_fat -->|"copies data"| node_memory
node_loader15 -->|"loads file"| node_fat
node_loader15 -->|"transfers control"| node_exec
node_stage2 -->|"enables A20"| node_a20
node_stage2 -->|"enters protected mode"| node_mode
node_mode -->|"disables NMI"| node_nmi
node_nmi -->|"reads port"| node_io
node_mode -->|"reports errors"| node_printing
node_loader15 -->|"prints status"| node_printing
node_stage2 -->|"prints status"| node_printing
node_bios -.->|"starts boot"| node_stage1
node_bios -->|"passes Multiboot data"| node_kernel
node_kernel -->|"parses boot tags"| node_multiboot

click node_stage1 "https://github.com/adam97-1/novaos/blob/master/stage1/stage1.asm"
click node_loader15 "https://github.com/adam97-1/novaos/blob/master/stage1_5/stage1_5.c"
click node_stage2 "https://github.com/adam97-1/novaos/blob/master/stage2/stage2.c"
click node_exec "https://github.com/adam97-1/novaos/blob/master/lib16/exec/asm/exec_16b.asm"
click node_disk "https://github.com/adam97-1/novaos/tree/master/lib16/disk"
click node_mbr "https://github.com/adam97-1/novaos/blob/master/lib16/mbr/mbr.c"
click node_fat "https://github.com/adam97-1/novaos/blob/master/lib16/fat/fat.c"
click node_memory "https://github.com/adam97-1/novaos/blob/master/lib16/memory/memory.c"
click node_strings "https://github.com/adam97-1/novaos/blob/master/lib16/string/string.c"
click node_a20 "https://github.com/adam97-1/novaos/blob/master/lib16/a20/asm/enable_a20_16b.asm"
click node_mode "https://github.com/adam97-1/novaos/blob/master/lib16/mode/mode.c"
click node_nmi "https://github.com/adam97-1/novaos/blob/master/lib16/nmi/nmi.c"
click node_io "https://github.com/adam97-1/novaos/blob/master/lib16/io/io.h"
click node_printing "https://github.com/adam97-1/novaos/blob/master/lib16/print/print.c"
click node_kernel "https://github.com/adam97-1/novaos/blob/master/kernel/kernel.c"
click node_multiboot "https://github.com/adam97-1/novaos/blob/master/kernel/multiboot2.h"

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_stage1,node_loader15,node_stage2,node_exec toneBlue
class node_disk,node_mbr,node_fat,node_memory,node_strings toneAmber
class node_a20,node_mode,node_nmi,node_io,node_printing toneMint
class node_kernel,node_multiboot toneRose
class node_bios toneIndigo
```

## Components

### Boot stages

- [Stage 1](https://github.com/adam97-1/novaos/blob/master/stage1/stage1.asm): `stage1/stage1.asm`
- [Stage 1.5](https://github.com/adam97-1/novaos/blob/master/stage1_5/stage1_5.c): `stage1_5/stage1_5.c`
- [Stage 2](https://github.com/adam97-1/novaos/blob/master/stage2/stage2.c): `stage2/stage2.c`
- [Real-mode transfer](https://github.com/adam97-1/novaos/blob/master/lib16/exec/asm/exec_16b.asm): `lib16/exec/asm/exec_16b.asm`

### Disk and filesystems

- [Disk access](https://github.com/adam97-1/novaos/tree/master/lib16/disk): `lib16/disk`
- [Partition lookup](https://github.com/adam97-1/novaos/blob/master/lib16/mbr/mbr.c): `lib16/mbr/mbr.c`
- [FAT filesystem](https://github.com/adam97-1/novaos/blob/master/lib16/fat/fat.c): `lib16/fat/fat.c`
- [Memory helpers](https://github.com/adam97-1/novaos/blob/master/lib16/memory/memory.c): `lib16/memory/memory.c`
- [String helpers](https://github.com/adam97-1/novaos/blob/master/lib16/string/string.c): `lib16/string/string.c`

### Platform support

- [A20 enable](https://github.com/adam97-1/novaos/blob/master/lib16/a20/asm/enable_a20_16b.asm): `lib16/a20/asm/enable_a20_16b.asm`
- [Protected mode](https://github.com/adam97-1/novaos/blob/master/lib16/mode/mode.c): `lib16/mode/mode.c`
- [NMI control](https://github.com/adam97-1/novaos/blob/master/lib16/nmi/nmi.c): `lib16/nmi/nmi.c`
- [Port I/O](https://github.com/adam97-1/novaos/blob/master/lib16/io/io.h): `lib16/io/io.h`
- [Text output](https://github.com/adam97-1/novaos/blob/master/lib16/print/print.c): `lib16/print/print.c`

### Multiboot kernel

- [Kernel entry](https://github.com/adam97-1/novaos/blob/master/kernel/kernel.c): `kernel/kernel.c`
- [Multiboot definitions](https://github.com/adam97-1/novaos/blob/master/kernel/multiboot2.h): `kernel/multiboot2.h`

### Other components

- **Boot firmware**

## Connections

- Stage 1.5 → Disk access: initializes disk (evidence: `stage1_5/stage1_5.c`)
- Stage 1.5 → Partition lookup: reads partitions (evidence: `stage1_5/stage1_5.c`)
- Partition lookup → Disk access: reads sectors (evidence: `lib16/mbr/mbr.c`)
- Stage 1.5 → FAT filesystem: initializes and searches (evidence: `stage1_5/stage1_5.c`)
- FAT filesystem → Disk access: reads sectors (evidence: `lib16/fat/fat.c`)
- FAT filesystem → String helpers: uses strings (evidence: `lib16/fat/fat.c`)
- FAT filesystem → Memory helpers: copies data (evidence: `lib16/fat/fat.c`)
- Stage 1.5 → FAT filesystem: loads file (evidence: `stage1_5/stage1_5.c`)
- Stage 1.5 → Real-mode transfer: transfers control (evidence: `stage1_5/stage1_5.c`)
- Stage 2 → A20 enable: enables A20 (evidence: `stage2/stage2.c`)
- Stage 2 → Protected mode: enters protected mode (evidence: `stage2/stage2.c`)
- Protected mode → NMI control: disables NMI (evidence: `lib16/mode/mode.c`)
- NMI control → Port I/O: reads port (evidence: `lib16/nmi/nmi.c`)
- Protected mode → Text output: reports errors (evidence: `lib16/mode/mode.c`)
- Stage 1.5 → Text output: prints status (evidence: `stage1_5/stage1_5.c`)
- Stage 2 → Text output: prints status (evidence: `stage2/stage2.c`)
- Boot firmware → Stage 1: starts boot
- Boot firmware → Kernel entry: passes Multiboot data (evidence: `kernel/kernel.c`)
- Kernel entry → Multiboot definitions: parses boot tags (evidence: `kernel/kernel.c`)
