This project to make a Real Time Operating System. This kernel runs in 32-bit Protected Mode, boots via GRUB, and includes basic timer and keyboard drivers, a custom heap allocator, and interrupt handling. Every feature of the kernel are the legacy features, assembly instructions, memory alignment, ELF structure and Multiboot spec.
- Boot
-
GRUB + Multiboot compliant
-
Custom linker script for memory layout
-
VGA text mode buffer
-
Serial output for debugging
- Descriptor Tables
- Global Descriptor Table (GDT)
- Interrupt Descriptor Table (IDT)
- Interrupts & PIC
- CPU exceptions
- Hardware Interrupt (IRQ) handling
- PIC remapping
- Drivers
- Keyboard driver to print pressed keys
- Timer driver to tick at 100 Hz
- Memory Management
- Parse Multiboot memory map
- Print free blocks
- Initialize heap
- Implement
kalloc
andkfree
with First-Fit approach - Memory Alignment for heap and allocations
- Debugging
-
GDB
withQEMU
-
Inspect registers such as,
PIC
registers,EFLAGS
and segment registers
├── boot/ # Bootloader code (Multiboot header)
├── gdt/ # Global Descriptor Table setup
├── idt/ # Interrupt Descriptor Table & IRQs
│ ├── irq/ # IRQ handling
│ └── isr/ # Exception handling
├── drivers/ # Keyboard, Timer, Serial drivers
├── kernel/ # Core kernel logic & memory management
├── display/ # VGA text mode output
├── grub/ # GRUB config
├── include/ # Header files
├── iso/ # ISO build directory for GRUB boot
├── linker/ # Linker script
├── build/ # Compiled objects & ISO
└── Makefile # Build automation
qemu-system-i386
orqemu-system-x86_64
i686-elf-gcc
cross-compilermake
nasm
gdb-multiarch
(for debugging)
make
This generates:
-
build/ticktos.elf
– Kernel ELF binary -
build/ticktos.iso
– Bootable ISO (GRUB)
Standard graphical mode:
qemu-system-i386 -cdrom build/ticktos.iso
Non-graphical with serial output:
qemu-system-i386 -cdrom build/ticktos.iso -nographic -serial mon:stdio
For older machine (to inspect PIC and disable APIC):
qemu-system-x86_64 -cdrom build/ticktos.iso -serial stdio -machine isapc
To log output to a file:
qemu-system-x86_64 -cdrom build/ticktos.iso -serial stdio -machine isapc > qemu.log 2>&1
Run QEMU
in debug mode:
qemu-system-i386 -cdrom build/ticktos.iso -nographic -serial mon:stdio -s -S
Attach GDB
:
gdb-multiarch build/ticktos.elf
(gdb) target remote localhost:1234
(gdb) break kernel_main
(gdb) continue
- Virtual memory and paging
printf
and basicstdio
-like functions- Multitasking between dummy tasks
- Porting my mini shell into the kernel