# mikaku/fiwix architecture

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

- Interactive diagram: https://gitdiagram.com/mikaku/fiwix
- Repository: https://github.com/mikaku/fiwix

## Overview

##### Main Structural Components

a. User Space (External Interface)
- As the topmost layer
- ELF binary support
- System calls interface

b. Kernel Space (Core Components)
In the following logical groups:

##### Process Management
- Scheduler (sched.c)
- Process control (process.c)
- Signal handling (signal.c)

##### Memory Management
- Components from /mm/
- Virtual memory management
- Page allocation
- Memory mapping

##### File System Layer
- VFS abstraction
- Supported filesystems:
- EXT2
- Minix (v1/v2)
- ISO9660
- PROCFS
- PIPEFS
- SOCKFS

##### Device Drivers
- In categories:
- Block devices (ATA, ATAPI, Floppy)
- Character devices (Console, Keyboard, Serial)
- PCI devices
- Video/Graphics

##### IPC Mechanisms
- Unix sockets
- System V IPC components
- Pipes

Use the following visual elements:

- Rectangles: Major subsystems
- Rounded rectangles: Interfaces
- Hexagons: Hardware interfaces

- Blue: Core kernel components
- Green: File systems
- Yellow: Device drivers
- Gray: Hardware layer
- Purple: IPC mechanisms

- Double lines: Data flow

##### Key Relationships to Highlight

- System call interface connecting user space to kernel
- VFS abstraction layer connecting to specific filesystems
- Device driver hierarchy
- Memory management interaction with process management
- IPC mechanisms crossing between processes

##### Additional Elements

- Version information (current: MIT License, Copyright 2018-2024)
- POSIX compliance points

##### Technical Details

- Virtual memory split options (3GB/1GB and 2GB/2GB)
- Supported hardware specifications
- Key kernel features (non-preemptive, 32-bit protected mode)
- Multiboot specification compliance

Remember to emphasize:
- The UNIX-like architecture
- POSIX compatibility
- The educational/hobby nature of the project
- Core kernel features
- Hardware support limitations

This will provide a comprehensive view of the Fiwix kernel architecture while maintaining clarity and usefulness for both educational and development purposes.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph User_Space
        ELF["ELF Binaries"]
        SYSCALL["System Call Interface"]:::interface
        click SYSCALL "https://github.com/mikaku/Fiwix/blob/master/kernel/syscalls.c"
    end

    subgraph Kernel_Space
        subgraph Process_Management
            SCHED["Scheduler"]:::core
            PROC["Process Control"]:::core
            SIG["Signal Handling"]:::core
            click SCHED "https://github.com/mikaku/Fiwix/blob/master/kernel/sched.c"
            click PROC "https://github.com/mikaku/Fiwix/blob/master/kernel/process.c"
            click SIG "https://github.com/mikaku/Fiwix/blob/master/kernel/signal.c"
        end

        subgraph Memory_Management
            MM["Memory Manager"]:::core
            VMEM["Virtual Memory"]:::core
            PAGING["Page Allocation"]:::core
            MMAP["Memory Mapping"]:::core
            click MM "https://github.com/mikaku/Fiwix/blob/master/mm/memory.c"
            click PAGING "https://github.com/mikaku/Fiwix/blob/master/mm/page.c"
            click MMAP "https://github.com/mikaku/Fiwix/blob/master/mm/mmap.c"
        end

        subgraph File_System_Layer
            VFS["VFS Abstraction"]:::fs
            EXT2["EXT2"]:::fs
            MINIX["Minix v1/v2"]:::fs
            ISO["ISO9660"]:::fs
            PROC["PROCFS"]:::fs
            PIPE["PIPEFS"]:::fs
            SOCK["SOCKFS"]:::fs
            click VFS "https://github.com/mikaku/Fiwix/blob/master/fs/super.c"
            click EXT2 "https://github.com/mikaku/Fiwix/tree/master/fs/ext2"
            click MINIX "https://github.com/mikaku/Fiwix/tree/master/fs/minix"
            click ISO "https://github.com/mikaku/Fiwix/tree/master/fs/iso9660"
            click PROC "https://github.com/mikaku/Fiwix/tree/master/fs/procfs"
            click PIPE "https://github.com/mikaku/Fiwix/tree/master/fs/pipefs"
            click SOCK "https://github.com/mikaku/Fiwix/tree/master/fs/sockfs"
        end

        subgraph IPC_Mechanisms
            UNIX_SOCK["Unix Sockets"]:::ipc
            SYSV["System V IPC"]:::ipc
            PIPES["Pipes"]:::ipc
            MSG["Message Queues"]:::ipc
            click UNIX_SOCK "https://github.com/mikaku/Fiwix/blob/master/net/unix.c"
            click SYSV "https://github.com/mikaku/Fiwix/blob/master/kernel/syscalls/ipc.c"
            click PIPES "https://github.com/mikaku/Fiwix/blob/master/fs/pipefs/pipe.c"
            click MSG "https://github.com/mikaku/Fiwix/blob/master/kernel/syscalls/msgctl.c"
        end

        subgraph Device_Drivers
            BLOCK["Block Devices"]:::driver
            CHAR["Character Devices"]:::driver
            PCI["PCI Devices"]:::driver
            VIDEO["Video/Graphics"]:::driver
            click BLOCK "https://github.com/mikaku/Fiwix/tree/master/drivers/block"
            click CHAR "https://github.com/mikaku/Fiwix/tree/master/drivers/char"
            click PCI "https://github.com/mikaku/Fiwix/tree/master/drivers/pci"
            click VIDEO "https://github.com/mikaku/Fiwix/tree/master/drivers/video"
        end

        subgraph Hardware_Layer
            CPU["CPU Management"]:::hw
            PIC["PIC Controller"]:::hw
            PIT["PIT Timer"]:::hw
            IRQ["IRQ Handling"]:::hw
            click CPU "https://github.com/mikaku/Fiwix/blob/master/kernel/cpu.c"
            click PIC "https://github.com/mikaku/Fiwix/blob/master/kernel/pic.c"
            click PIT "https://github.com/mikaku/Fiwix/blob/master/kernel/pit.c"
            click IRQ "https://github.com/mikaku/Fiwix/tree/master/kernel/irq"
        end
    end

    %% Connections
    ELF --> SYSCALL
    SYSCALL --> PROC
    SYSCALL --> MM
    SYSCALL --> VFS
    SYSCALL --> IPC_Mechanisms

    PROC <--> SCHED
    PROC <--> SIG
    PROC <--> MM

    MM <--> VMEM
    MM <--> PAGING
    MM <--> MMAP

    VFS --> EXT2
    VFS --> MINIX
    VFS --> ISO
    VFS --> PROC
    VFS --> PIPE
    VFS --> SOCK

    UNIX_SOCK <--> SYSV
    PIPES <--> MSG

    BLOCK --> PCI
    CHAR --> PCI
    VIDEO --> PCI

    Device_Drivers --> Hardware_Layer

    %% Styles
    classDef interface fill:#f9f,stroke:#333,stroke-width:2px
    classDef core fill:#9cf,stroke:#333,stroke-width:2px
    classDef fs fill:#9f9,stroke:#333,stroke-width:2px
    classDef driver fill:#ff9,stroke:#333,stroke-width:2px
    classDef hw fill:#ddd,stroke:#333,stroke-width:2px
    classDef ipc fill:#c9f,stroke:#333,stroke-width:2px

    %% Legend
    subgraph Legend
        L1["Interface"]:::interface
        L2["Core Components"]:::core
        L3["File Systems"]:::fs
        L4["Device Drivers"]:::driver
        L5["Hardware"]:::hw
        L6["IPC"]:::ipc
    end
```
