LazyDaysOS

Also known as DudeOS — a hobbyist 32-bit x86 kernel written from scratch in C and Assembly.

Architecture: i686 (x86-32) Multiboot Compliant Protected Mode + Paging VGA Text Mode

What This OS Does

LazyDaysOS boots via GRUB (Multiboot spec), initialises a 32-bit protected-mode environment, sets up a GDT, IDT and PIC, enables paging with identity-mapped memory, and drops into a VGA-text-mode terminal with keyboard input support.

Boot

GRUB loads the Multiboot ELF. Assembly stub sets up stack and switches to protected mode.

GDT

5-entry descriptor table: NULL, Ring-0 code/data, Ring-3 data/code. 4 KiB granularity.

IDT + PIC

256 interrupt gates. Master PIC → 0x20, Slave → 0x28. Keyboard & page-fault handlers.

Paging

Identity map of first 4 MiB (1024 page table entries). CR3 loaded, PG bit set in CR0.

VGA TTY

80×24 text-mode console. Scrolling, colour, putchar, writestring, scroll_down.

libk

Freestanding kernel library: k_print (printf), tty, keyboard input, memory utilities.

kernel/ — Core Kernel

kernel/
├── boot.s — Multiboot header, stack, GDT call, protected-mode switch, _start entry
├── kernel.c — kernel_main: terminal_initialize → init_idt → powerup_kernel_i386
├── gdt.c — GDT entries, GDTEntry/GDTDescriptor structs, i686_GDT_Initialize
├── gdt.h — Segment selector constants (0x08 code, 0x10 data)
├── idt.c — IDT table (256 entries), PIC init, idt_set_gate, init_idt
├── idt.h — IDT structs, ISR0-31 externs, PIC port definitions
├── idt_hndlr_setup.s — ASM ISR stubs that call idt_buf_drain / interrupt_handler
├── isr.c — interrupt_handler dispatch, register_routines, isr_map[255]
├── isr.h — register_routines / interrupt_handler prototypes
├── hwio.s — outb / inb inline-assembly I/O port helpers
└── hwio.h — outb / inb declarations, IDT_FLAG_PRESENT, FLAG_SET/UNSET

kernel/compat/i386/ — Architecture Layer

kernel/compat/i386/
├── kern_powerup.c — powerup_kernel_i386: CR0 check, mem$setup_paging, util$self_test
├── vm_watchdog.c — mem$setup_paging (identity map 4 MiB, CR3, CR0.PG), pagefault_hander
├── linker.ld — Link at 1 MiB, 4 KiB-aligned .text/.rodata/.data/.bss
└── include/
    ├── kern_powerup.h — KERN$PWRUP / KERN$PWRDOWN constants
    └── vm_watchdog.h — mem$setup_paging, pagefault_hander prototypes

libk/ — Kernel Library

libk/
├── include/
│ ├── kio.h — k_print(char* fmt, ...) declaration
│ ├── tty.h — terminal_* functions, INT_BASE enum, VGA dimensions
│ ├── ttyin.h — KEYCODE enum (scan codes), keyboard_to_ascii, keyboard_read
│ ├── util.h — lazy$block struct, blkcpy_weak/strong, util$self_test
│ └── vgadef.h — vga_color enum (16 colours), VGA_WIDTH=80, VGA_HEIGHT=24
├── kio/ kio.c — k_print implementation (variadic, format specifiers)
├── tty/ tty.c, ttyin.c — VGA terminal + keyboard scan-code reader
└── util/ memory.c — lazy$block copy operations and self-tests

Build System

TargetOutputDescription
makeLazyDaysOS.binLinks kernel + libk.a + util.a into ELF binary
make installLazyDaysOS.isoInstalls headers/libs, creates GRUB ISO via grub-mkrescue
make cleanRemoves *.o, *.bin, *.a, isodir/, sysroot/
make install-headerssysroot/usr/include/Copies libk headers
make install-libssysroot/usr/lib/libk.aInstalls static kernel library

Toolchain

ToolVariablePurpose
i686-elf-gcc -m32CCCross-compiler, freestanding, no stdlib
i686-elf-as --32ASMAssembler for .s files
i686-elf-arARStatic archive builder (libk.a, util.a)
grub-mkrescueCreates bootable ISO image
qemu-system-i386Emulation target (bootit.sh)
gdbRemote debugging (debug.sh + gdbconf)

Common Commands

# Build kernel binary
make

# Build and boot in QEMU
./bootit.sh

# Debug with GDB
./debug.sh

# Test Multiboot compliance
./test_multiboot.sh

# Generate GRUB config
./gen_grubcfg.sh <output> <kernel-name> <kernel-path>

# Full install + ISO
make install

Code Conventions

PatternMeaning
KERN$PWRUP / KERN$PWRDOWNKernel powerup return codes (1 = success, 0 = fail)
UTIL$SUCCESS / UTIL$FAILGeneral utility return codes (0x1 / 0x0)
lazy$blockMemory block descriptor: base pointer + limit
[K_INFO]k_print informational log prefix
[K_SUCC]k_print success log prefix
[K_FAIL]k_print failure log prefix
MAP_IRQ(n)Maps hardware IRQ n to interrupt vector n+0x20
__attribute__((packed))GDT/IDT descriptor structs must be packed
__attribute__((aligned(4096)))Page directory/table must be 4 KiB aligned
Note: The kernel is compiled with -nostdlib -ffreestanding. No standard C library is available. All runtime support comes from libk/ and -lgcc.
Known Issue: make clean does not delete the sysroot/ directory (see TOneverTHINK comment in Makefile).