OpenOS is a 32-bit x86 educational operating system kernel designed to demonstrate fundamental OS concepts. It runs in protected mode and provides a minimal but functional interrupt-driven system with keyboard support.
boot.S_start in boot.S)
kmain()kmain in kernel.c)
Physical Memory Map:
┌──────────────────────┬─────────────┐
│ 0x00000000 │ BIOS/IVT │
├──────────────────────┼─────────────┤
│ 0x00007C00 │ Bootloader │
├──────────────────────┼─────────────┤
│ 0x00100000 (1 MiB) │ Kernel │
│ - .multiboot │ Multiboot │
│ - .text │ Code │
│ - .rodata │ Read-only │
│ - .data │ Data │
│ - .bss │ BSS │
│ - Stack (16KB) │ Stack │
└──────────────────────┴─────────────┘
OpenOS uses a flat memory model with the following GDT segments:
idt.cThe 8259A PIC is configured as follows:
This remapping avoids conflicts with CPU exceptions (0x00-0x1F).
IRQ Assignments:
Hardware Event (e.g., key press)
↓
PIC receives signal on IRQ1
↓
PIC sends interrupt to CPU (vector 0x21)
↓
CPU looks up handler in IDT[0x21]
↓
CPU pushes state and jumps to irq1_handler (isr.S)
↓
irq1_handler saves registers
↓
irq1_handler calls keyboard_handler() in C
↓
keyboard_handler reads scancode, processes key
↓
keyboard_handler sends EOI to PIC
↓
irq1_handler restores registers
↓
iret instruction returns to interrupted code
Components:
keyboard.h/c - PS/2 keyboard driver implementationisr.S - Assembly interrupt service routineFeatures:
State Tracking:
shift_pressed - Current shift key statecaps_lock - Caps lock toggle stateinput_buffer - 256-byte line bufferline_ready - Flag indicating complete lineA simple command prompt that:
See roadmap.md for planned enhancements:
| File | Purpose |
|---|---|
boot.S |
Multiboot header and entry point |
kernel.c |
Main kernel logic and VGA terminal |
idt.c/h |
Interrupt descriptor table management |
pic.c/h |
PIC initialization and EOI handling |
isr.S/h |
Assembly interrupt service routines |
keyboard.c/h |
Keyboard driver implementation |
linker.ld |
Linker script for memory layout |
The kernel is compiled with:
-ffreestanding - No hosted environment-nostdlib - No standard library-m32 - 32-bit x86 target-O2 - Optimization level 2-Wall -Wextra - All warnings enabled