# math-fehr/windos architecture

> Architecture diagram of the GitHub repository math-fehr/windos, 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/math-fehr/windos
- Repository: https://github.com/math-fehr/windos

## Overview

##### Main System Components

a) Hardware Layer (Bottom)
- ARM Processor (Cortex-A7)
- Memory Management Unit (MMU)
- Hardware Peripherals
- GPIO Controller
- UART/Serial
- Framebuffer
- Timer
- Interrupt Controller

b) Kernel Layer (Middle)
- Core Kernel Components
- Memory Management (memalloc.c, mmu.c)
- Process Management (process.c, scheduler.c)
- Interrupt Handling (interrupts.c)
- System Calls (syscalls.c)

c) File System Layer
- Virtual File System (vfs.c)
- File System Types
- EXT2 (ext2.c)
- PipeFS (pipefs.c)
- ProcFS (procfs.c)

d) User Space Layer (Top)
- System Programs
- Shell (wesh)
- Utilities (ls, cat, cp, etc.)
- Applications (pico editor, buddhabrot, etc.)

##### Component Relationships

- System call flow (user space → kernel)
- Hardware interactions (kernel → hardware)
- File system operations (VFS → concrete file systems)
- Process management flow

**┌─────────────────────────────────────┐**
- User Space (Applications & Utilities)│
- ┤
- System Call Interface               │
- ┤
- Kernel (Process, Memory, VFS)       │
- ┤
- Hardware Abstraction Layer          │
- ┤
- Physical Hardware                   │
- ┘

##### Important Details

- Memory Management:
- Page allocation system
- Virtual memory mapping
- Process Management:
- Scheduler
- Process creation/destruction
- Signal handling
- File Systems:
- VFS abstraction
- Multiple FS support
- Device Management:
- Device drivers
- Hardware interfaces

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef hardware fill:#D3D3D3,stroke:#333
    classDef kernel fill:#B3D9FF,stroke:#333
    classDef filesystem fill:#90EE90,stroke:#333
    classDef userspace fill:#FFE5B4,stroke:#333
    classDef syscall fill:#FFB6C1,stroke:#333

    %% Hardware Layer
    subgraph Hardware
        ARM[ARM Cortex-A7]:::hardware
        MMU[Memory Management Unit]:::hardware
        GPIO[GPIO Controller]:::hardware
        UART[UART/Serial]:::hardware
        FB[Framebuffer]:::hardware
        Timer[Timer]:::hardware
        IntCtrl[Interrupt Controller]:::hardware
    end

    %% Kernel Layer
    subgraph Kernel
        %% Memory Management
        MemMgmt[Memory Management]:::kernel
        MMUDrv[MMU Driver]:::kernel
        
        %% Process Management
        ProcMgmt[Process Management]:::kernel
        Sched[Scheduler]:::kernel
        
        %% Interrupt Handling
        IntHandler[Interrupt Handler]:::kernel
        
        %% System Calls
        SysCall[System Calls Interface]:::syscall
        
        %% Device Management
        DevMgmt[Device Management]:::kernel
    end

    %% File System Layer
    subgraph FileSystem
        VFS[Virtual File System]:::filesystem
        EXT2[EXT2]:::filesystem
        PipeFS[PipeFS]:::filesystem
        ProcFS[ProcFS]:::filesystem
    end

    %% User Space Layer
    subgraph UserSpace
        Shell[Shell - wesh]:::userspace
        Utils[System Utilities]:::userspace
        Apps[Applications]:::userspace
        LibC[C Library]:::userspace
    end

    %% Relationships
    UserSpace --> SysCall
    SysCall --> Kernel
    Kernel --> Hardware
    
    VFS --> |manages| EXT2
    VFS --> |manages| PipeFS
    VFS --> |manages| ProcFS
    
    ProcMgmt --> MMUDrv
    ProcMgmt --> Sched
    IntHandler --> ProcMgmt
    
    DevMgmt --> GPIO
    DevMgmt --> UART
    DevMgmt --> FB
    DevMgmt --> Timer
    
    %% Click Events
    click MemMgmt "https://github.com/Math-Fehr/WindOS/blob/master/src/memalloc.c"
    click MMUDrv "https://github.com/Math-Fehr/WindOS/blob/master/src/mmu.c"
    click ProcMgmt "https://github.com/Math-Fehr/WindOS/blob/master/src/process.c"
    click Sched "https://github.com/Math-Fehr/WindOS/blob/master/src/scheduler.c"
    click IntHandler "https://github.com/Math-Fehr/WindOS/blob/master/src/interrupts.c"
    click SysCall "https://github.com/Math-Fehr/WindOS/blob/master/src/syscalls.c"
    click VFS "https://github.com/Math-Fehr/WindOS/blob/master/src/vfs.c"
    click EXT2 "https://github.com/Math-Fehr/WindOS/blob/master/src/ext2.c"
    click PipeFS "https://github.com/Math-Fehr/WindOS/blob/master/src/pipefs.c"
    click ProcFS "https://github.com/Math-Fehr/WindOS/blob/master/src/procfs.c"
    click GPIO "https://github.com/Math-Fehr/WindOS/blob/master/src/gpio.c"
    click UART "https://github.com/Math-Fehr/WindOS/blob/master/src/serial.c"
    click FB "https://github.com/Math-Fehr/WindOS/blob/master/src/fb.c"
    click Timer "https://github.com/Math-Fehr/WindOS/blob/master/src/timer.c"
    click DevMgmt "https://github.com/Math-Fehr/WindOS/blob/master/src/dev.c"
    click Shell "https://github.com/Math-Fehr/WindOS/blob/master/usr/wesh/wesh.c"
    click LibC "https://github.com/Math-Fehr/WindOS/tree/master/libc/std/"

    %% Legend
    subgraph Legend
        L1[Hardware Components]:::hardware
        L2[Kernel Components]:::kernel
        L3[File System Components]:::filesystem
        L4[User Space Components]:::userspace
        L5[System Call Interface]:::syscall
    end
```
