Loading...

Powering the future with cloud-native infrastructure and AI-assisted learning. Master Generative AI, Kernel Security, VLSI design, and Edge Systems with live tools and real production workflows.Explore Data Science Research →

Systems Programming Track

Kernel Build &
Boot Mechanics

How a real kernel wakes up the hardware. No abstractions. Just the raw transition from Reset Vector to Ring 0.

Stage 1

BIOS / UEFI

Firmware initializes chipset, DRAM, and finds boot devices.

Stage 2

Bootloader (ASM)

Mode switches (16 → 32 → 64-bit) and Page Table setup.

The Assembly Handover

Before C code can execute, the environment must be "primed." The CPU starts in Real Mode (16-bit). To reach the kernel, the bootloader must navigate privilege levels and enable the Long Mode bit in the EFER MSR.

boot_entry.asmx86_64
_start:
    cli                ; 1. Disable maskable interrupts
    lgdt [gdt_ptr]     ; 2. Load Global Descriptor Table
    
    ; 3. Transition to 64-bit Long Mode
    mov eax, cr4
    or  eax, 1 << 5    ; Enable PAE
    mov cr4, eax
    
    ; ... (Setup Page Tables) ...
    
    jmp 0x08:kernel_main ; 4. Far jump into C kernel

Bootloader Duties

  • Building GDT & IDT structures
  • Creating the initial PML4 Page Tables
  • Parsing ELF/PE kernel headers

Kernel Initialization

  • Setting up the Stack Pointer (RSP)
  • Initializing the Physical Memory Manager
  • Probing the PCI bus for devices

The Ring 0 Reality

In Kernel Space, there is no safety net. A single null pointer dereference won't crash an app—it will Triple Fault the entire CPU, resulting in a hard system reboot.