# otolias/anthill-os architecture

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

- Interactive diagram: https://gitdiagram.com/otolias/anthill-os
- Repository: https://github.com/otolias/anthill-os

## Overview

##### Main Components

a. Kernel Layer:
- Boot components (/src/boot)
- Memory Management (/src/kernel/mm.c)
- Task Management (/src/kernel/task.c)
- System Calls (/src/kernel/syscalls.c)
- ELF Loading (/src/kernel/elf.c)
- Message Queue System (/src/kernel/mqueue.c)

b. Driver Layer:
- IRQ Management (/src/drivers/irq)
- Timer Management (/src/drivers/timer)
- UART Communication (/src/drivers/uart)

c. Module System:
- PL011 Driver Module
- RD (RAM Disk) Module
- UART Module
- VFS (Virtual File System) Module

d. Library Layer:
- Standard C Library (libc)
- VFS Library (libvfs)

e. User Space:
- Shell (/src/bin/sh)
- Test Suite
- Hello Program
- ExportFS Utility

**[User Space Applications]**
- ↕
**[System Libraries (libc, libvfs)]**
- ↕
**[VFS & Module System]**
- ↕
**[Kernel Core]**
- ↕
**[Hardware Abstraction Layer]**
- ↕
**[Hardware (aarch64)]**

##### Key Relationships to Highlight

- Interaction between user space applications and the kernel through system calls
- Message queue system's role in inter-process communication
- Demonstrate how the VFS module interfaces with both the kernel and user space
- Driver modules' relationship with the hardware abstraction layer

##### Implementation Details

- Rectangles: Major subsystems
- Hexagons: Modules

##### Additional Elements

- A boot sequence flow
- Memory management architecture
- Task scheduling system
- Interrupt handling paths

## Diagram (Mermaid)

```mermaid
graph TB
    %% Hardware Layer
    subgraph Hardware
        AARCH64[aarch64 Hardware]:::hardware
    end

    %% Hardware Abstraction Layer
    subgraph HAL[Hardware Abstraction Layer]
        IRQ[IRQ Management]:::driver
        TIMER[Timer Management]:::driver
        UART_HAL[UART Communication]:::driver
    end

    %% Kernel Layer
    subgraph Kernel[Kernel Core]
        BOOT[Boot Components]:::kernel
        MM[Memory Management]:::kernel
        TASK[Task Management]:::kernel
        SYSCALL[System Calls]:::kernel
        ELF[ELF Loading]:::kernel
        MQUEUE[Message Queue System]:::kernel
    end

    %% Module System
    subgraph Modules[Module System]
        PL011[PL011 Driver]:::module
        RD[RAM Disk]:::module
        UART_MOD[UART Module]:::module
        VFS_MOD[VFS Module]:::module
    end

    %% Library Layer
    subgraph Libraries[System Libraries]
        LIBC[Standard C Library]:::library
        LIBVFS[VFS Library]:::library
    end

    %% User Space
    subgraph UserSpace[User Space Applications]
        SHELL[Shell]:::app
        TEST[Test Suite]:::app
        HELLO[Hello Program]:::app
        EXPORTFS[ExportFS Utility]:::app
    end

    %% Relationships
    UserSpace --> Libraries
    Libraries --> Modules
    Libraries --> Kernel
    Modules --> Kernel
    Kernel --> HAL
    HAL --> Hardware

    %% Click Events
    click BOOT "https://github.com/otolias/anthill-os/tree/main//src/boot"
    click MM "https://github.com/otolias/anthill-os/blob/main//src/kernel/mm.c"
    click TASK "https://github.com/otolias/anthill-os/blob/main//src/kernel/task.c"
    click SYSCALL "https://github.com/otolias/anthill-os/blob/main//src/kernel/syscalls.c"
    click ELF "https://github.com/otolias/anthill-os/blob/main//src/kernel/elf.c"
    click MQUEUE "https://github.com/otolias/anthill-os/blob/main//src/kernel/mqueue.c"
    click IRQ "https://github.com/otolias/anthill-os/blob/main//src/drivers/irq/irq.c"
    click TIMER "https://github.com/otolias/anthill-os/blob/main//src/drivers/timer/timer.c"
    click UART_HAL "https://github.com/otolias/anthill-os/blob/main//src/drivers/uart/uart.c"
    click PL011 "https://github.com/otolias/anthill-os/tree/main//src/modules/pl011"
    click RD "https://github.com/otolias/anthill-os/tree/main//src/modules/rd"
    click UART_MOD "https://github.com/otolias/anthill-os/tree/main//src/modules/uart"
    click VFS_MOD "https://github.com/otolias/anthill-os/tree/main//src/modules/vfs"
    click LIBC "https://github.com/otolias/anthill-os/tree/main//src/lib/libc"
    click LIBVFS "https://github.com/otolias/anthill-os/tree/main//src/lib/libvfs"
    click SHELL "https://github.com/otolias/anthill-os/tree/main//src/bin/sh"
    click TEST "https://github.com/otolias/anthill-os/tree/main//src/bin/test_suite"
    click HELLO "https://github.com/otolias/anthill-os/tree/main//src/bin/hello"
    click EXPORTFS "https://github.com/otolias/anthill-os/tree/main//src/bin/exportfs"

    %% Styles
    classDef kernel fill:#2196F3,stroke:#1565C0,color:white
    classDef driver fill:#4CAF50,stroke:#2E7D32,color:white
    classDef module fill:#9C27B0,stroke:#6A1B9A,color:white
    classDef library fill:#FF9800,stroke:#EF6C00,color:white
    classDef app fill:#FFEB3B,stroke:#FBC02D,color:black
    classDef hardware fill:#9E9E9E,stroke:#616161,color:white

    %% Legend
    subgraph Legend
        K[Kernel Components]:::kernel
        D[Drivers]:::driver
        M[Modules]:::module
        L[Libraries]:::library
        A[Applications]:::app
        H[Hardware]:::hardware
    end
```
