# rioktss/rioos architecture

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

- Interactive diagram: https://gitdiagram.com/rioktss/rioos
- Repository: https://github.com/rioktss/rioos

## Overview

RioOS is a small AArch64 bare-metal operating system for QEMU virt. Its main user workflow is interactive UART shell input, command dispatch, and kernel services such as filesystem and process operations; it also exposes syscall-based services to userspace. The graph preserves documented memory, scheduling, device, graphics/input, filesystem, and networking capabilities. Several relationships use README-level evidence because their implementation files were not sampled; unsampled details are not inferred.

Main entry points: [`kernel/commands.cpp`](https://github.com/rioktss/rioos/blob/main/kernel/commands.cpp) (Shell commands), [`kernel/syscall.cpp`](https://github.com/rioktss/rioos/blob/main/kernel/syscall.cpp) (Syscall dispatch), [`fs/fs.cpp`](https://github.com/rioktss/rioos/blob/main/fs/fs.cpp) (Custom filesystem), [`kernel/shell.cpp`](https://github.com/rioktss/rioos/blob/main/kernel/shell.cpp) (Interactive shell)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User interface"]
  node_shell["Interactive shell<br/>[shell.cpp]"]
  node_keyboard["Keyboard input<br/>[keyboard.cpp]"]
  node_commands["Shell commands<br/>[commands.cpp]"]
end

subgraph group_kernel["Kernel services"]
  node_syscalls["Syscall dispatch<br/>[syscall.cpp]"]
  node_security["Security and credentials<br/>[security.cpp]"]
  node_filedescriptors["File descriptors<br/>[fd.cpp]"]
end

subgraph group_execution["Processes and userspace"]
  node_process["Process lifecycle<br/>[process.cpp]"]
  node_scheduler["Process scheduling<br/>[scheduler.cpp]"]
  node_threads["Kernel threads<br/>[thread.cpp]"]
  node_elf["ELF loader<br/>[elf.cpp]"]
  node_calc["Bundled calculator<br/>[calc.cpp]"]
end

subgraph group_storage["Filesystem and storage"]
  node_vfs["Virtual filesystem<br/>[vfs.cpp]"]
  node_filesystem[("Custom filesystem<br/>[fs.cpp]")]
  node_storage_api["Storage interface<br/>[storage.cpp]"]
end

subgraph group_platform["Memory and devices"]
  node_uart["UART console<br/>[uart.cpp]"]
  node_block["VirtIO block driver<br/>[virtio_blk.cpp]"]
  node_virtio_mmio["VirtIO MMIO<br/>[virtio_mmio.cpp]"]
  node_memory["Memory management<br/>[memory.cpp]"]
  node_mmu["MMU setup<br/>[mmu.cpp]"]
  node_page_allocator["Page allocator<br/>[page_alloc.cpp]"]
  node_framebuffer["Framebuffer rendering<br/>[fb.cpp]"]
end

subgraph group_network["Networking"]
  node_network_stack["Network stack<br/>[netstack.cpp]"]
  node_net_driver["VirtIO network driver<br/>[virtio_net.cpp]"]
end

node_user(("Shell user"))

node_user -->|"enters commands"| node_shell
node_shell -->|"reads input"| node_keyboard
node_shell -->|"dispatches"| node_commands
node_shell -->|"uses console"| node_uart
node_commands -->|"runs file operations"| node_filesystem
node_commands -->|"runs network commands"| node_network_stack
node_commands -->|"queries processes"| node_process
node_commands -->|"queries scheduling"| node_scheduler
node_commands -->|"uses graphics"| node_framebuffer
node_calc -.->|"uses user API"| node_syscalls
node_syscalls -->|"dispatches FD calls"| node_filedescriptors
node_syscalls -->|"dispatches file calls"| node_filesystem
node_syscalls -->|"uses path context"| node_vfs
node_syscalls -->|"checks access"| node_security
node_syscalls -->|"dispatches UDP"| node_network_stack
node_filedescriptors -->|"reads and writes"| node_filesystem
node_vfs -->|"delegates operations"| node_filesystem
node_filesystem -->|"reads and writes sectors"| node_storage_api
node_storage_api -->|"delegates I/O"| node_block
node_block -->|"uses device access"| node_virtio_mmio
node_elf -->|"loads executable data"| node_filesystem
node_elf -->|"sets user mappings"| node_mmu
node_scheduler -->|"tracks processes"| node_process
node_threads -.->|"cooperatively yields"| node_scheduler
node_network_stack -->|"sends and receives frames"| node_net_driver
node_memory -.->|"uses allocation"| node_page_allocator
node_mmu -.->|"supports memory mappings"| node_memory

click node_shell "https://github.com/rioktss/rioos/blob/main/kernel/shell.cpp"
click node_keyboard "https://github.com/rioktss/rioos/blob/main/drivers/keyboard.cpp"
click node_commands "https://github.com/rioktss/rioos/blob/main/kernel/commands.cpp"
click node_uart "https://github.com/rioktss/rioos/blob/main/drivers/uart.cpp"
click node_syscalls "https://github.com/rioktss/rioos/blob/main/kernel/syscall.cpp"
click node_security "https://github.com/rioktss/rioos/blob/main/kernel/security.cpp"
click node_filedescriptors "https://github.com/rioktss/rioos/blob/main/kernel/fd.cpp"
click node_process "https://github.com/rioktss/rioos/blob/main/process/process.cpp"
click node_scheduler "https://github.com/rioktss/rioos/blob/main/process/scheduler.cpp"
click node_threads "https://github.com/rioktss/rioos/blob/main/process/thread.cpp"
click node_elf "https://github.com/rioktss/rioos/blob/main/process/elf.cpp"
click node_calc "https://github.com/rioktss/rioos/blob/main/userspace/calc.cpp"
click node_vfs "https://github.com/rioktss/rioos/blob/main/fs/vfs.cpp"
click node_filesystem "https://github.com/rioktss/rioos/blob/main/fs/fs.cpp"
click node_storage_api "https://github.com/rioktss/rioos/blob/main/drivers/storage.cpp"
click node_block "https://github.com/rioktss/rioos/blob/main/drivers/virtio_blk.cpp"
click node_virtio_mmio "https://github.com/rioktss/rioos/blob/main/drivers/virtio_mmio.cpp"
click node_memory "https://github.com/rioktss/rioos/blob/main/memory/memory.cpp"
click node_mmu "https://github.com/rioktss/rioos/blob/main/memory/mmu.cpp"
click node_page_allocator "https://github.com/rioktss/rioos/blob/main/memory/page_alloc.cpp"
click node_framebuffer "https://github.com/rioktss/rioos/blob/main/drivers/fb.cpp"
click node_network_stack "https://github.com/rioktss/rioos/blob/main/net/netstack.cpp"
click node_net_driver "https://github.com/rioktss/rioos/blob/main/drivers/virtio_net.cpp"

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_shell,node_keyboard,node_commands,node_user toneBlue
class node_syscalls,node_security,node_filedescriptors toneAmber
class node_process,node_scheduler,node_threads,node_elf,node_calc toneMint
class node_vfs,node_filesystem,node_storage_api toneRose
class node_uart,node_block,node_virtio_mmio,node_memory,node_mmu,node_page_allocator,node_framebuffer toneIndigo
class node_network_stack,node_net_driver toneTeal
```

## Components

### User interface

- [Interactive shell](https://github.com/rioktss/rioos/blob/main/kernel/shell.cpp): `kernel/shell.cpp`
- [Keyboard input](https://github.com/rioktss/rioos/blob/main/drivers/keyboard.cpp): `drivers/keyboard.cpp`
- [Shell commands](https://github.com/rioktss/rioos/blob/main/kernel/commands.cpp): `kernel/commands.cpp`

### Kernel services

- [Syscall dispatch](https://github.com/rioktss/rioos/blob/main/kernel/syscall.cpp): `kernel/syscall.cpp`
- [Security and credentials](https://github.com/rioktss/rioos/blob/main/kernel/security.cpp): `kernel/security.cpp`
- [File descriptors](https://github.com/rioktss/rioos/blob/main/kernel/fd.cpp): `kernel/fd.cpp`

### Processes and userspace

- [Process lifecycle](https://github.com/rioktss/rioos/blob/main/process/process.cpp): `process/process.cpp`
- [Process scheduling](https://github.com/rioktss/rioos/blob/main/process/scheduler.cpp): `process/scheduler.cpp`
- [Kernel threads](https://github.com/rioktss/rioos/blob/main/process/thread.cpp): `process/thread.cpp`
- [ELF loader](https://github.com/rioktss/rioos/blob/main/process/elf.cpp): `process/elf.cpp`
- [Bundled calculator](https://github.com/rioktss/rioos/blob/main/userspace/calc.cpp): `userspace/calc.cpp`

### Filesystem and storage

- [Virtual filesystem](https://github.com/rioktss/rioos/blob/main/fs/vfs.cpp): `fs/vfs.cpp`
- [Custom filesystem](https://github.com/rioktss/rioos/blob/main/fs/fs.cpp): `fs/fs.cpp`
- [Storage interface](https://github.com/rioktss/rioos/blob/main/drivers/storage.cpp): `drivers/storage.cpp`

### Memory and devices

- [UART console](https://github.com/rioktss/rioos/blob/main/drivers/uart.cpp): `drivers/uart.cpp`
- [VirtIO block driver](https://github.com/rioktss/rioos/blob/main/drivers/virtio_blk.cpp): `drivers/virtio_blk.cpp`
- [VirtIO MMIO](https://github.com/rioktss/rioos/blob/main/drivers/virtio_mmio.cpp): `drivers/virtio_mmio.cpp`
- [Memory management](https://github.com/rioktss/rioos/blob/main/memory/memory.cpp): `memory/memory.cpp`
- [MMU setup](https://github.com/rioktss/rioos/blob/main/memory/mmu.cpp): `memory/mmu.cpp`
- [Page allocator](https://github.com/rioktss/rioos/blob/main/memory/page_alloc.cpp): `memory/page_alloc.cpp`
- [Framebuffer rendering](https://github.com/rioktss/rioos/blob/main/drivers/fb.cpp): `drivers/fb.cpp`

### Networking

- [Network stack](https://github.com/rioktss/rioos/blob/main/net/netstack.cpp): `net/netstack.cpp`
- [VirtIO network driver](https://github.com/rioktss/rioos/blob/main/drivers/virtio_net.cpp): `drivers/virtio_net.cpp`

### Other components

- **Shell user**

## Connections

- Shell user → Interactive shell: enters commands (evidence: `README.md`)
- Interactive shell → Keyboard input: reads input (evidence: `kernel/shell.cpp`)
- Interactive shell → Shell commands: dispatches (evidence: `kernel/shell.cpp`)
- Interactive shell → UART console: uses console (evidence: `kernel/shell.cpp`)
- Shell commands → Custom filesystem: runs file operations (evidence: `kernel/commands.cpp`)
- Shell commands → Network stack: runs network commands (evidence: `kernel/commands.cpp`)
- Shell commands → Process lifecycle: queries processes (evidence: `kernel/commands.cpp`)
- Shell commands → Process scheduling: queries scheduling (evidence: `kernel/commands.cpp`)
- Shell commands → Framebuffer rendering: uses graphics (evidence: `kernel/commands.cpp`)
- Bundled calculator → Syscall dispatch: uses user API (evidence: `README.md`)
- Syscall dispatch → File descriptors: dispatches FD calls (evidence: `kernel/syscall.cpp`)
- Syscall dispatch → Custom filesystem: dispatches file calls (evidence: `kernel/syscall.cpp`)
- Syscall dispatch → Virtual filesystem: uses path context (evidence: `kernel/syscall.cpp`)
- Syscall dispatch → Security and credentials: checks access (evidence: `kernel/syscall.cpp`)
- Syscall dispatch → Network stack: dispatches UDP (evidence: `kernel/syscall.cpp`)
- File descriptors → Custom filesystem: reads and writes (evidence: `kernel/fd.cpp`)
- Virtual filesystem → Custom filesystem: delegates operations (evidence: `fs/vfs.cpp`)
- Custom filesystem → Storage interface: reads and writes sectors (evidence: `fs/fs.cpp`)
- Storage interface → VirtIO block driver: delegates I/O (evidence: `drivers/storage.cpp`)
- VirtIO block driver → VirtIO MMIO: uses device access (evidence: `drivers/virtio_blk.cpp`)
- ELF loader → Custom filesystem: loads executable data (evidence: `process/elf.cpp`)
- ELF loader → MMU setup: sets user mappings (evidence: `process/elf.cpp`)
- Process scheduling → Process lifecycle: tracks processes (evidence: `process/scheduler.cpp`)
- Kernel threads → Process scheduling: cooperatively yields (evidence: `README.md`)
- Network stack → VirtIO network driver: sends and receives frames (evidence: `net/netstack.cpp`)
- Memory management → Page allocator: uses allocation (evidence: `README.md`)
- MMU setup → Memory management: supports memory mappings (evidence: `README.md`)
