How maastaar/539kernel works
Project Type and Purpose
• This is an educational, monolithic x86 32-bit kernel (no user-land or network stack) intended to illustrate OS internals (bootloader, protected-mode setup, memory management, scheduling, drivers, filesystem).
File Structure
• Top level:
• src/ – contains the “final” kernel code and all subsystems as they stand at the book’s end.
• evolution_by_versions/ – step-by-step kernel versions per chapter.
• Within src/:
• Assembly modules for early initialization and switching to protected mode:
– bootstrap.asm, starter.asm, simple_kernel.asm, gdt.asm, idt.asm
• C modules for core subsystems:
– main.c (entrypoint)
– process.{c,h}, scheduler.{c,h} (process management, round-robin scheduler)
– heap.{c,h}, paging.{c,h} (memory management, paging, heap allocator)
– filesystem.{c,h}, ata.{c,h} (block-device driver, file system)
– screen.{c,h} (VGA text driver)
– str.{c,h} (basic string routines)
• linker.ld – the ELF/linker script defining memory layout
• Makefile – orchestrates assembling, compiling, linking, and generating the bootable image
• bochs – Bochs emulator config for testing
README
• Confirms this is purely an educational kernel and that src/ is the latest codebase.
• No network protocols, GUIs, or user-space—everything runs in one address space under Bochs or real hardware.
a. Boot Path Components
• BIOS/Emulator (Bochs) → Bootloader (bootstrap.asm) → Protected-Mode Setup (gdt.asm, idt.asm) → Kernel Entry (starter.asm)
1. Memory Management
• Paging module (paging.c/h)
• Heap allocator (heap.c/h)
2. Process Management
• Process abstraction (process.c/h)
• Scheduler (scheduler.c/h)
3. Device Drivers
• ATA driver (ata.c/h) → used by Filesystem
• Screen/VGA text driver (screen.c/h)
4. Filesystem Module (filesystem.c/h)
5. Utilities
• String library (str.c/h)
6. Kernel Entrypoint (main.c)
c. Build & Link Pipeline
• Source (ASM & C) → Assembly/Compilation → Linker script (linker.ld) → Kernel binary → Bootable image via Makefile
d. Testing Environment
• Bochs emulator config used to run the image
Relationships & Data Flows
• Kernel Entry → Memory Manager init
• Memory Manager ↔ Paging & Heap modules
• Kernel Entry → Interrupt subsystem (IDT)
• Kernel Entry → Process Manager → Scheduler
• Scheduler → Process switching
• Device Drivers → provide primitives to Filesystem and Process (e.g., load code)
• Main loop in main.c tying everything together (init then dispatch)
• Build pipeline at the bottom: Tools → AS/CC → Linker → Image → Bochs
Architectural Patterns & Principles
• Monolithic kernel: all code linked into one binary
• Separation of concerns: distinct modules for CPU init, memory, processes, drivers, FS
• Linear bootstrap chain: real mode → protected mode → kernel C runtime
• Educational layering: each chapter adds one module (captured in evolution_by_versions/)
• Clear labels for each component and module
• A note calling out this is a monolithic, single-address-space, educational kernel