How remenod/bare-metal-snake works
Project Type and Purpose
• This is a bare-metal, ring-0-only, monolithic OS for x86, booting via BIOS/MBR into 32-bit protected mode.
• It includes a custom bootloader (in Assembly), a kernel (C + Assembly), hardware drivers, a minimal C runtime (“lib”), and several demo applications (Snake, Text Sandbox, etc.).
File Structure
• Top-level directories:
• boot/ – MBR bootloader (boot.asm)
• / – Public headers (arch, drivers, kernel, lib)
• src/ – Implementation code
– arch/x86/interrupts, ports, timer (architecture-specific CPU/interrupt code)
– kernel/ (core kernel services + drivers)
– lib/ (freestanding C library)
– apps/ (demo applications)
• Key build artifacts: linker scripts (linker.ld), Makefile, build output image.
Extract Architecture Insights from README
• Single-stage BIOS → MBR → protected-mode transition.
• Kernel subsystems: exception handling, PIC/PIT, keyboard, VGA text/graphics, stack guard, RSoD panic.
• “Apps” live on top of the kernel and invoke driver APIs directly.
1. BIOS (real-mode firmware)
2. MBR Bootloader (boot/boot.asm)
3. Protected-Mode Kernel
• Core Subsystem (kernel/core)
• Arch Layer (src/arch/x86)
– Interrupt Descriptor Table (IDT), exception & ISR handlers
– Programmable Interrupt Controller (PIC) & PIT timer
– Port I/O abstraction
• Drivers (kernel/drivers + include/drivers)
– PS/2 Keyboard
– QEMU Serial
– VGA Text Mode & Mode-13 Graphics + Palette + Font loader
• Stack Guard Module
• RSoD Panic Handler
4. Freestanding C Library (src/lib + include/lib)
5. Applications (src/apps/*)
– App Selector, Snake, Text Sandbox, RSoD Roulette, Segment Test
6. Hardware Peripherals
– x86 CPU, Memory Bus, VGA Framebuffer, PS/2 Controller, PIT, PIC
• BIOS → loads → MBR Bootloader → switches to protected mode → loads → Kernel
• Kernel Core ← uses → Arch Layer (IDT/PIC/PIT/ports)
• Core & Apps ← call → Drivers ← interact → Hardware (Keyboard, VGA, PIT)
• Apps ← link against → Freestanding C Library
c. Architectural Patterns & Principles:
• Monolithic kernel in ring 0 only
• Layered design: Bootloader → Kernel Core → Hardware Abstraction (Arch & Drivers) → Applications
• Freestanding C runtime (no libc)
• Event-driven via hardware interrupts
d. Key Technologies & Frameworks:
• Assembly: NASM for MBR, ISRs, protected-mode entry
• C: i386-elf-gcc for kernel, drivers, apps
• Linker script (linker.ld)
• QEMU for emulation/testing