projects

KFS

A custom 32-bit x86 kernel written in freestanding C and Assembly, featuring a Multiboot-compliant bootloader, memory paging, and hardware interrupt handling.

RoleSystems Engineer
Client42 Project
Year2025
Technologies
C (Freestanding)x86 AssemblyGCC Cross-Compiler+3
KFS cover

Overview

Minimal x86 kernel in C and assembly with custom bootloader, GDT/IDT initialization, and basic shell.

The Challenge

Developing an operating system from scratch is the ultimate test of low-level systems engineering. Without standard libraries, system calls, or memory allocators, you are communicating directly with bare-metal hardware. The challenge was to successfully bootstrap the CPU, transition to 32-bit protected mode, and construct the foundational data structures required for a functioning OS.

The Solution

x86 kernel with custom bootloader, GDT/IDT initialization, interrupt handlers, basic shell implementation, and terminal I/O.

Architecture & Topology

Core Implementation

; Loading the Interrupt Descriptor Table (IDT)
global idt_load
idt_load:
    mov eax, [esp + 4]  ; Get pointer to IDT descriptor
    lidt [eax]          ; Load IDT
    sti                 ; Enable hardware interrupts
    ret

Technical Deep Dive

Cross-Compiler & Bootstrapping

Configured a custom GCC cross-compiler (i686-elf) to target bare-metal x86 architecture. Engineered a Multiboot-compliant assembly stub to interface with the GRUB bootloader.

Memory Management & Paging

Wrote a custom Linker Script (linker.ld) to precisely define memory boundaries, ensuring the .text, .data, and .bss sections were loaded into memory exactly where the CPU expected them.

CPU Descriptor Tables

Programmed the Global Descriptor Table (GDT) to define memory segments and execution privileges (Ring 0 for Kernel, Ring 3 for User space).

Hardware Interrupts

Configured the Programmable Interrupt Controller (8259 PIC) via low-level I/O port writes. Constructed the Interrupt Descriptor Table (IDT) and authored Interrupt Service Routines (ISRs) in Assembly.