# tanmaygadge/riscv-os architecture

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

- Interactive diagram: https://gitdiagram.com/tanmaygadge/riscv-os
- Repository: https://github.com/tanmaygadge/riscv-os

## Overview

This is a small bare-metal RISC-V kernel. Its visible workflow initializes physical memory and page tables, enables the MMU, installs the runtime allocator, then enables timer traps and reports ticks over UART. Memory management includes physical-page allocation, virtual-range allocation, and page mapping/unmapping. The excerpts establish the main calls among these components; boot assembly behavior and other unsampled implementation details are not inferred.

Main entry points: [`src/main.rs`](https://github.com/tanmaygadge/riscv-os/blob/master/src/main.rs) (Kernel startup), [`src/paging.rs`](https://github.com/tanmaygadge/riscv-os/blob/master/src/paging.rs) (Page tables), [`src/pmm.rs`](https://github.com/tanmaygadge/riscv-os/blob/master/src/pmm.rs) (Physical allocator), [`src/trap.rs`](https://github.com/tanmaygadge/riscv-os/blob/master/src/trap.rs) (Trap handling)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_kernel["Kernel runtime"]
  node_kernel["Kernel startup<br/>[main.rs]"]
end

subgraph group_memory["Memory management"]
  node_paging["Page tables<br/>[paging.rs]"]
  node_pmm["Physical allocator<br/>[pmm.rs]"]
  node_vma["Virtual ranges<br/>[pmm.rs]"]
end

subgraph group_io["Diagnostics and traps"]
  node_trap["Trap handling<br/>[trap.rs]"]
  node_uart["UART output<br/>[uart.rs]"]
end

node_platform(("RISC-V platform"))

node_platform -.->|"boots"| node_kernel
node_kernel -->|"initializes"| node_pmm
node_kernel -->|"builds mappings"| node_paging
node_kernel -->|"initializes pool"| node_vma
node_kernel -->|"enables traps"| node_trap
node_kernel -->|"prints status"| node_uart
node_paging -->|"allocates pages"| node_pmm
node_pmm -->|"maps and unmaps"| node_paging
node_trap -->|"prints diagnostics"| node_uart

click node_kernel "https://github.com/tanmaygadge/riscv-os/blob/master/src/main.rs"
click node_trap "https://github.com/tanmaygadge/riscv-os/blob/master/src/trap.rs"
click node_paging "https://github.com/tanmaygadge/riscv-os/blob/master/src/paging.rs"
click node_pmm "https://github.com/tanmaygadge/riscv-os/blob/master/src/pmm.rs"
click node_vma "https://github.com/tanmaygadge/riscv-os/blob/master/src/pmm.rs"
click node_uart "https://github.com/tanmaygadge/riscv-os/blob/master/src/uart.rs"

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 toneBlue
class node_paging,node_pmm,node_vma toneAmber
class node_trap,node_uart toneMint
class node_platform toneIndigo
```

## Components

### Kernel runtime

- [Kernel startup](https://github.com/tanmaygadge/riscv-os/blob/master/src/main.rs): `src/main.rs`

### Memory management

- [Page tables](https://github.com/tanmaygadge/riscv-os/blob/master/src/paging.rs): `src/paging.rs`
- [Physical allocator](https://github.com/tanmaygadge/riscv-os/blob/master/src/pmm.rs): `src/pmm.rs`
- [Virtual ranges](https://github.com/tanmaygadge/riscv-os/blob/master/src/pmm.rs): `src/pmm.rs`

### Diagnostics and traps

- [Trap handling](https://github.com/tanmaygadge/riscv-os/blob/master/src/trap.rs): `src/trap.rs`
- [UART output](https://github.com/tanmaygadge/riscv-os/blob/master/src/uart.rs): `src/uart.rs`

### Other components

- **RISC-V platform**

## Connections

- RISC-V platform → Kernel startup: boots
- Kernel startup → Physical allocator: initializes (evidence: `src/main.rs`)
- Kernel startup → Page tables: builds mappings (evidence: `src/main.rs`)
- Kernel startup → Virtual ranges: initializes pool (evidence: `src/main.rs`)
- Kernel startup → Trap handling: enables traps (evidence: `src/main.rs`)
- Kernel startup → UART output: prints status (evidence: `src/main.rs`)
- Page tables → Physical allocator: allocates pages (evidence: `src/paging.rs`)
- Physical allocator → Page tables: maps and unmaps (evidence: `src/pmm.rs`)
- Trap handling → UART output: prints diagnostics (evidence: `src/trap.rs`)
