# daegatoya/barelyos architecture

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

- Interactive diagram: https://gitdiagram.com/daegatoya/barelyos
- Repository: https://github.com/daegatoya/barelyos

## Overview

BarelyOS is an experimental, freestanding C++ operating-system kernel intended to boot in a virtual machine. The principal path is firmware/bootloader handoff to the Limine-aware kernel entry, which initializes memory, display, keyboard, scheduler, and shell, then polls for keyboard input and passes characters to the shell. The shell and terminal provide a minimal interactive CLI; memory management and cooperative thread scheduling are additional kernel capabilities. Edges are limited to relationships visible in the supplied excerpts, source index, or README; some internal calls are not shown.

Main entry points: [`BarelyOS/kernel/main.cpp`](https://github.com/daegatoya/barelyos/blob/main/BarelyOS/kernel/main.cpp) (Kernel entry), [`BarelyOS/kernel/shell/shell.cpp`](https://github.com/daegatoya/barelyos/blob/main/BarelyOS/kernel/shell/shell.cpp) (Command shell), [`BarelyOS/kernel/terminal/terminal.cpp`](https://github.com/daegatoya/barelyos/blob/main/BarelyOS/kernel/terminal/terminal.cpp) (Text terminal), [`BarelyOS/kernel/graphics/graphics.cpp`](https://github.com/daegatoya/barelyos/blob/main/BarelyOS/kernel/graphics/graphics.cpp) (Framebuffer graphics)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_boot["Boot and kernel"]
  node_limine["Limine handoff<br/>[limine.h]"]
  node_kernel["Kernel entry<br/>[main.cpp]"]
end

subgraph group_interaction["Console interaction"]
  node_keyboard["Keyboard input<br/>[keyboard.cpp]"]
  node_scan_codes["Scan-code map<br/>[scanCodeTable.h]"]
  node_shell["Command shell<br/>[shell.cpp]"]
  node_terminal["Text terminal<br/>[terminal.cpp]"]
  node_graphics["Framebuffer graphics<br/>[graphics.cpp]"]
end

subgraph group_resources["Memory and threading"]
  node_pmm["Physical memory<br/>[pmm.cpp]"]
  node_scheduler["Thread scheduler<br/>[scheduler.cpp]"]
  node_thread["Thread context<br/>[thread.h]"]
  node_cpu_context["CPU context<br/>[cpucontext.h]"]
end

subgraph group_support["Kernel support"]
  node_font["Bitmap font<br/>[bitmap_font.cpp]"]
  node_font_data["8x8 glyph data<br/>[font8xx8_basic.h]"]
  node_mem["Memory routines<br/>[mem.cpp]"]
end

node_vm_user(("VM user"))

node_vm_user -.->|"boots image"| node_limine
node_limine -.->|"hands off"| node_kernel
node_kernel -->|"polls input"| node_keyboard
node_kernel -->|"dispatches characters"| node_shell
node_kernel -->|"initializes"| node_pmm
node_kernel -->|"initializes"| node_scheduler
node_kernel -->|"initializes"| node_terminal
node_kernel -->|"constructs"| node_graphics
node_kernel -->|"constructs"| node_font
node_keyboard -->|"maps codes"| node_scan_codes
node_shell -.->|"uses console"| node_terminal
node_shell -.->|"controls tasks"| node_scheduler
node_terminal -.->|"draws text"| node_graphics
node_graphics -.->|"reads glyphs"| node_font
node_font -->|"uses glyph table"| node_font_data
node_scheduler -.->|"allocates pages"| node_pmm
node_thread -->|"stores context"| node_cpu_context

click node_limine "https://github.com/daegatoya/barelyos/blob/main/BarelyOS/boot/limine.h"
click node_kernel "https://github.com/daegatoya/barelyos/blob/main/BarelyOS/kernel/main.cpp"
click node_keyboard "https://github.com/daegatoya/barelyos/blob/main/BarelyOS/kernel/keyboard/keyboard.cpp"
click node_scan_codes "https://github.com/daegatoya/barelyos/blob/main/BarelyOS/kernel/keyboard/scanCodeTable.h"
click node_shell "https://github.com/daegatoya/barelyos/blob/main/BarelyOS/kernel/shell/shell.cpp"
click node_terminal "https://github.com/daegatoya/barelyos/blob/main/BarelyOS/kernel/terminal/terminal.cpp"
click node_graphics "https://github.com/daegatoya/barelyos/blob/main/BarelyOS/kernel/graphics/graphics.cpp"
click node_font "https://github.com/daegatoya/barelyos/blob/main/BarelyOS/kernel/fonts/bitmap_font.cpp"
click node_font_data "https://github.com/daegatoya/barelyos/blob/main/BarelyOS/kernel/fonts/font8xx8_basic.h"
click node_pmm "https://github.com/daegatoya/barelyos/blob/main/BarelyOS/kernel/memory/pmm.cpp"
click node_mem "https://github.com/daegatoya/barelyos/blob/main/BarelyOS/kernel/memory/mem.cpp"
click node_scheduler "https://github.com/daegatoya/barelyos/blob/main/BarelyOS/kernel/threading/scheduler.cpp"
click node_thread "https://github.com/daegatoya/barelyos/blob/main/BarelyOS/kernel/threading/thread.h"
click node_cpu_context "https://github.com/daegatoya/barelyos/blob/main/BarelyOS/kernel/threading/cpucontext.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_limine,node_kernel,node_vm_user toneBlue
class node_keyboard,node_scan_codes,node_shell,node_terminal,node_graphics toneAmber
class node_pmm,node_scheduler,node_thread,node_cpu_context toneMint
class node_font,node_font_data,node_mem toneRose
```

## Components

### Boot and kernel

- [Limine handoff](https://github.com/daegatoya/barelyos/blob/main/BarelyOS/boot/limine.h): `BarelyOS/boot/limine.h`
- [Kernel entry](https://github.com/daegatoya/barelyos/blob/main/BarelyOS/kernel/main.cpp): `BarelyOS/kernel/main.cpp`

### Console interaction

- [Keyboard input](https://github.com/daegatoya/barelyos/blob/main/BarelyOS/kernel/keyboard/keyboard.cpp): `BarelyOS/kernel/keyboard/keyboard.cpp`
- [Scan-code map](https://github.com/daegatoya/barelyos/blob/main/BarelyOS/kernel/keyboard/scanCodeTable.h): `BarelyOS/kernel/keyboard/scanCodeTable.h`
- [Command shell](https://github.com/daegatoya/barelyos/blob/main/BarelyOS/kernel/shell/shell.cpp): `BarelyOS/kernel/shell/shell.cpp`
- [Text terminal](https://github.com/daegatoya/barelyos/blob/main/BarelyOS/kernel/terminal/terminal.cpp): `BarelyOS/kernel/terminal/terminal.cpp`
- [Framebuffer graphics](https://github.com/daegatoya/barelyos/blob/main/BarelyOS/kernel/graphics/graphics.cpp): `BarelyOS/kernel/graphics/graphics.cpp`

### Memory and threading

- [Physical memory](https://github.com/daegatoya/barelyos/blob/main/BarelyOS/kernel/memory/pmm.cpp): `BarelyOS/kernel/memory/pmm.cpp`
- [Thread scheduler](https://github.com/daegatoya/barelyos/blob/main/BarelyOS/kernel/threading/scheduler.cpp): `BarelyOS/kernel/threading/scheduler.cpp`
- [Thread context](https://github.com/daegatoya/barelyos/blob/main/BarelyOS/kernel/threading/thread.h): `BarelyOS/kernel/threading/thread.h`
- [CPU context](https://github.com/daegatoya/barelyos/blob/main/BarelyOS/kernel/threading/cpucontext.h): `BarelyOS/kernel/threading/cpucontext.h`

### Kernel support

- [Bitmap font](https://github.com/daegatoya/barelyos/blob/main/BarelyOS/kernel/fonts/bitmap_font.cpp): `BarelyOS/kernel/fonts/bitmap_font.cpp`
- [8x8 glyph data](https://github.com/daegatoya/barelyos/blob/main/BarelyOS/kernel/fonts/font8xx8_basic.h): `BarelyOS/kernel/fonts/font8xx8_basic.h`
- [Memory routines](https://github.com/daegatoya/barelyos/blob/main/BarelyOS/kernel/memory/mem.cpp): `BarelyOS/kernel/memory/mem.cpp`

### Other components

- **VM user**

## Connections

- VM user → Limine handoff: boots image (evidence: `README.md`)
- Limine handoff → Kernel entry: hands off (evidence: `BarelyOS/kernel/main.cpp`)
- Kernel entry → Keyboard input: polls input (evidence: `BarelyOS/kernel/main.cpp`)
- Kernel entry → Command shell: dispatches characters (evidence: `BarelyOS/kernel/main.cpp`)
- Kernel entry → Physical memory: initializes (evidence: `BarelyOS/kernel/main.cpp`)
- Kernel entry → Thread scheduler: initializes (evidence: `BarelyOS/kernel/main.cpp`)
- Kernel entry → Text terminal: initializes (evidence: `BarelyOS/kernel/main.cpp`)
- Kernel entry → Framebuffer graphics: constructs (evidence: `BarelyOS/kernel/main.cpp`)
- Kernel entry → Bitmap font: constructs (evidence: `BarelyOS/kernel/main.cpp`)
- Keyboard input → Scan-code map: maps codes
- Command shell → Text terminal: uses console
- Command shell → Thread scheduler: controls tasks
- Text terminal → Framebuffer graphics: draws text
- Framebuffer graphics → Bitmap font: reads glyphs
- Bitmap font → 8x8 glyph data: uses glyph table (evidence: `BarelyOS/kernel/fonts/bitmap_font.cpp`)
- Thread scheduler → Physical memory: allocates pages
- Thread context → CPU context: stores context (evidence: `BarelyOS/kernel/threading/thread.h`)
