How tingwei628/barukanos works
Project Type & Purpose
• This is an educational, full-fledged toy operating system (bare-metal software)
• Key purposes: demonstrate x86_64 boot sequence (real → protected → long mode), paging, interrupts, system calls, process scheduling, FAT16 FS, and a CLI
File Structure
• boot/: multi-stage bootloader (real, protected, long mode), assembler and C code for loader, GDT/IDT setup
• kernel/: core OS code—startup (main.c, kernel.asm), memory manager (mem.c, vm.c), interrupt/trap handlers (idt.c, trap.asm), process manager, syscall interface, printing, linked via linker.ld
• drivers/: PS/2 keyboard driver, I/O port abstraction
• fs/fat16/: FAT16 file-system implementation (init, read/write, file.h)
• user/: simple userland libraries and example user programs built via user Makefiles
• examples/: sample user binaries and FAT16 images for testing
• Top-level Makefiles orchestrate cross-compilation, image creation, QEMU/Bochs launch
Extract Architecture Insights from README
• Multi-stage boot → kernel load → FS and process management
• Monolithic design: all kernel services link into one binary
• Relies on virtualization (QEMU/Bochs) and FAT16 disk image
Main Components & Interactions
[Hardware Layer]
‣ CPU (x86_64 real/protected/long mode)
‣ Physical RAM
‣ Disk (FAT16 image)
‣ PS/2 Keyboard
‣ Programmable Interval Timer (PIT)
[Bootloader (boot/)]
‣ Stage 1 (real mode) → loads Stage 2 (protected) → Stage 3 (long mode)
‣ Loads kernel.bin into memory
[Kernel Core (kernel/)]
‣ Initialization: GDT, IDT, paging (4-level), 2 MB pages
‣ Memory Manager: physical and virtual memory (mem.c, vm.c)
‣ Interrupt Handling: trap entry (trap.asm), interrupt dispatch (idt.c)
‣ Process Manager: scheduling via timer interrupts
‣ Syscall Interface: user ↔ kernel boundary (syscall.c)
‣ Console I/O: printing on screen (print.c)
[Device Drivers (drivers/)]
‣ Keyboard driver (PS/2)
‣ Port I/O abstraction
[File System (fs/fat16/)]
‣ FAT16 driver for on-disk file operations
‣ Exposed to kernel and via system calls to userland
[Userland (user/ & examples/)]
‣ User libraries (console.c, memory.c, print.c)
‣ Sample programs (in examples/) loaded from FAT16 at boot
‣ Interact via system calls
[Development & Build Tools]
‣ Cross-compiler toolchain (dockcross/linux-x64)
‣ Makefiles for Linux/Windows
‣ Bochs/QEMU for emulation
Architectural Patterns & Design Principles
• Layered Kernel: bootloader → kernel core → subsystems → userland
• Monolithic Integration: all services in a single address space, compile-time linked
• Modular Subsystems: separate directories for drivers, FS, process, memory
• Interrupt-driven I/O: hardware IRQ → IDT → handler → kernel → user
Checklist
‣ Clear labels for each module and layer
‣ Notes on major assembler vs. C components (e.g., kernel.asm, trap.asm, print.c)
‣ Entry point markers (e.g., boot.asm start, main.c in kernel, user start.c)