# manuothatceguy/so_tp02 architecture

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

- Interactive diagram: https://gitdiagram.com/manuothatceguy/so_tp02
- Repository: https://github.com/manuothatceguy/so_tp02

## Overview

##### Project type and purpose
- This is a bare-metal operating system skeleton (“x64BareBones”) for Intel x86_64 hardware. It provides:
- A bootloader (two flavors: BMFS-based and Pure64)
- A minimal C/ASM kernel with subsystems (memory management, scheduler, drivers, syscalls, module loader)
- A toolchain to pack modules and assemble the image
- A sample “userland” module to exercise syscalls
- Build/run scripts that invoke QEMU

##### File structure
- Top‐level directories:
- Bootloader/ (BMFS + Pure64 sources and docs)
- Toolchain/ (module packer, build rules)
- Kernel/ (C and ASM code, drivers, memory management, interrupts, syscalls, module loader)
- SharedLibraries/ (headers shared between kernel and modules)
- Userland/ (sample module, shell, tests)
- Image/ (Makefile for image layout)
- Configuration & scripts: Makefile, compile.sh, init.sh, run.sh
- External tools: nasm, gcc, make, qemu

##### Extract architecture insights from README
- Build flow: Toolchain → Kernel → Bootloader → run.sh (QEMU)
- Final image combines bootloader, kernel.bin, packed modules
- Entry point: bootloader loads kernel, initializes hardware, hands off to kernel
- Module loader in kernel can dynamically load extra binaries

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Host Build Environment
    subgraph "Host Build Environment"
        direction TB
        Makefile["Makefile"]:::build
        compileSh["compile.sh"]:::build
        initSh["init.sh"]:::build
        runSh["run.sh"]:::build
    end

    %% Toolchain
    subgraph "Toolchain"
        direction TB
        MPMain["ModulePacker/main.c"]:::build
        MPHeader["ModulePacker/modulePacker.h"]:::build
        MPMake["ModulePacker/Makefile"]:::build
    end

    %% Build Output
    BinaryImage["Binary Image"]:::build

    %% Bootloader Variants
    subgraph "Bootloader"
        direction TB
        BMFS["BMFS Variant"]:::runtime
        Pure64["Pure64 Variant"]:::runtime
    end

    %% Kernel and Subsystems
    subgraph "Kernel"
        direction TB
        subgraph "Core Entry"
            direction TB
            KernelC["kernel.c"]:::runtime
            KernelLD["kernel.ld"]:::runtime
            LoaderASM["loader.asm"]:::runtime
        end
        subgraph "Interrupts"
            direction TB
            IntASM["interrupts.asm"]:::runtime
            ExDispatcher["exceptionDispatcher.c"]:::runtime
            IDTLoaderC["idtLoader.c"]:::runtime
        end
        subgraph "Memory Management"
            direction TB
            BitmapMM["bitmapMemoryManager.c"]:::runtime
            BuddyMM["buddyMemoryManager.c"]:::runtime
            DummyMM["dummyMemoryManager.c"]:::runtime
        end
        subgraph "Process & Scheduling"
            direction TB
            ProcessC["process.c"]:::runtime
            SchedulerC["scheduler.c"]:::runtime
        end
        subgraph "IPC"
            direction TB
            PipesC["pipes.c"]:::runtime
            SemaphoreC["semaphore.c"]:::runtime
        end
        subgraph "Drivers"
            direction TB
            KBDriver["keyboardDriver.c"]:::runtime
            VIDriver["videoDriver.c"]:::runtime
            ClockDrv["clock.c"]:::runtime
            TimeDrv["time.c"]:::runtime
            SoundDrv["soundDriver.c"]:::runtime
            TextMod["textModule.c"]:::runtime
        end
        subgraph "Module Loader & Syscalls"
            direction TB
            ModLoaderC["moduleLoader.c"]:::runtime
            SyscallDisp["syscallDispatcher.c"]:::runtime
        end
    end

    %% Shared Libraries
    SharedLibs["shared_structs.h"]:::runtime

    %% Userland Modules
    subgraph "Userland Modules"
        direction TB
        SampleC["sampleCodeModule.c"]:::runtime
        LoaderUC["_loader.c"]:::runtime
        SyscallsASM["syscalls.asm"]:::runtime
        SyscallH["syscall.h"]:::runtime
        ULMake["Makefile"]:::build
    end

    %% Virtual Hardware
    QEMU["QEMU / BIOS / Firmware"]:::hardware

    %% Image Layout
    ImageMake["Image/Makefile"]:::build

    %% Relationships
    Makefile -->|orchestrates| MPMain
    compileSh --> MPMain
    initSh --> MPMain
    MPMain -->|packs modules| BinaryImage
    MPMain -->|builds kernel| KernelC
    MPMain -->|builds bootloader| BMFS
    MPMain -->|builds bootloader| Pure64
    BinaryImage --> ImageMake
    runSh -->|launches| QEMU
    QEMU -->|BIOS loads| BMFS
    QEMU -->|BIOS loads| Pure64
    BMFS -->|"load kernel"| LoaderASM
    Pure64 -->|"load kernel"| LoaderASM
    LoaderASM -->|jumps to| KernelC
    KernelC --> IntASM
    IntASM --> ExDispatcher
    ExDispatcher --> IDTLoaderC
    IDTLoaderC --> BitmapMM
    BitmapMM --> BuddyMM
    BuddyMM --> DummyMM
    DummyMM --> ProcessC
    ProcessC --> SchedulerC
    SchedulerC --> PipesC
    PipesC --> SemaphoreC
    SemaphoreC --> KBDriver
    KBDriver --> VIDriver
    VIDriver --> ClockDrv
    ClockDrv --> TimeDrv
    TimeDrv --> SoundDrv
    SoundDrv --> TextMod
    TextMod --> ModLoaderC
    ModLoaderC --> SyscallDisp
    SyscallDisp --> SharedLibs
    ModLoaderC --> SampleC
    SampleC --> SyscallsASM
    SyscallsASM --> SyscallDisp
    SyscallDisp -->|syscall| SampleC

    %% Click Events
    click BMFS "https://github.com/manuothatceguy/so_tp02/tree/main/Bootloader/BMFS/"
    click Pure64 "https://github.com/manuothatceguy/so_tp02/tree/main/Bootloader/Pure64/"
    click Makefile "https://github.com/manuothatceguy/so_tp02/tree/main/./Makefile"
    click compileSh "https://github.com/manuothatceguy/so_tp02/blob/main/./compile.sh"
    click initSh "https://github.com/manuothatceguy/so_tp02/blob/main/./init.sh"
    click runSh "https://github.com/manuothatceguy/so_tp02/blob/main/./run.sh"
    click MPMain "https://github.com/manuothatceguy/so_tp02/blob/main/Toolchain/ModulePacker/main.c"
    click MPHeader "https://github.com/manuothatceguy/so_tp02/blob/main/Toolchain/ModulePacker/modulePacker.h"
    click MPMake "https://github.com/manuothatceguy/so_tp02/tree/main/Toolchain/ModulePacker/Makefile"
    click KernelC "https://github.com/manuothatceguy/so_tp02/blob/main/Kernel/kernel.c"
    click KernelLD "https://github.com/manuothatceguy/so_tp02/blob/main/Kernel/kernel.ld"
    click LoaderASM "https://github.com/manuothatceguy/so_tp02/blob/main/Kernel/loader.asm"
    click IntASM "https://github.com/manuothatceguy/so_tp02/blob/main/Kernel/asm/interrupts.asm"
    click ExDispatcher "https://github.com/manuothatceguy/so_tp02/blob/main/Kernel/interrupts/exceptionDispatcher.c"
    click IDTLoaderC "https://github.com/manuothatceguy/so_tp02/blob/main/Kernel/interrupts/idtLoader.c"
    click BitmapMM "https://github.com/manuothatceguy/so_tp02/blob/main/Kernel/memoryManagement/bitmapMemoryManager.c"
    click BuddyMM "https://github.com/manuothatceguy/so_tp02/blob/main/Kernel/memoryManagement/buddyMemoryManager.c"
    click DummyMM "https://github.com/manuothatceguy/so_tp02/blob/main/Kernel/memoryManagement/dummyMemoryManager.c"
    click ProcessC "https://github.com/manuothatceguy/so_tp02/blob/main/Kernel/process/process.c"
    click SchedulerC "https://github.com/manuothatceguy/so_tp02/blob/main/Kernel/process/scheduler.c"
    click PipesC "https://github.com/manuothatceguy/so_tp02/blob/main/Kernel/pipes/pipes.c"
    click SemaphoreC "https://github.com/manuothatceguy/so_tp02/blob/main/Kernel/semaphores/semaphore.c"
    click KBDriver "https://github.com/manuothatceguy/so_tp02/blob/main/Kernel/drivers/keyboardDriver.c"
    click VIDriver "https://github.com/manuothatceguy/so_tp02/blob/main/Kernel/drivers/videoDriver.c"
    click ClockDrv "https://github.com/manuothatceguy/so_tp02/blob/main/Kernel/drivers/clock.c"
    click TimeDrv "https://github.com/manuothatceguy/so_tp02/blob/main/Kernel/drivers/time.c"
    click SoundDrv "https://github.com/manuothatceguy/so_tp02/blob/main/Kernel/drivers/soundDriver.c"
    click TextMod "https://github.com/manuothatceguy/so_tp02/blob/main/Kernel/drivers/textModule.c"
    click ModLoaderC "https://github.com/manuothatceguy/so_tp02/blob/main/Kernel/moduleLoader.c"
    click SyscallDisp "https://github.com/manuothatceguy/so_tp02/blob/main/Kernel/syscalls/syscallDispatcher.c"
    click SharedLibs "https://github.com/manuothatceguy/so_tp02/blob/main/SharedLibraries/shared_structs.h"
    click SampleC "https://github.com/manuothatceguy/so_tp02/blob/main/Userland/SampleCodeModule/sampleCodeModule.c"
    click LoaderUC "https://github.com/manuothatceguy/so_tp02/blob/main/Userland/SampleCodeModule/_loader.c"
    click SyscallsASM "https://github.com/manuothatceguy/so_tp02/blob/main/Userland/SampleCodeModule/asm/syscalls.asm"
    click SyscallH "https://github.com/manuothatceguy/so_tp02/blob/main/Userland/SampleCodeModule/include/syscall.h"
    click ULMake "https://github.com/manuothatceguy/so_tp02/tree/main/Userland/SampleCodeModule/Makefile"
    click ImageMake "https://github.com/manuothatceguy/so_tp02/tree/main/Image/Makefile"

    %% Styles
    classDef build fill:#cce5ff,stroke:#004085,color:#004085
    classDef runtime fill:#d4edda,stroke:#155724,color:#155724
    classDef hardware fill:#fff3cd,stroke:#856404,color:#856404
```
