Repository navigation
2 Boot and Early Kernel Initialization
Relevant source files
This page provides a high-level overview of the boot path in CadenzaOS, tracing execution from raw BIOS boot sectors through multi-stage bootloaders, memory map collection, long-mode transition, and finally into the higher-half kernel entry point and kmain orchestration src/kernel/kernel.zig1-14src/boot/boot.asm1-15 CadenzaOS operates as a 64-bit x86-64 bare-metal operating system, leveraging a higher-half layout src/kernel/kernel.zig88
For detailed technical breakdowns of specific sub-components, refer to the child pages:
-
Bootloader Stages and Linking —
boot.asmstage 1, stage2.asm long-mode transition and E820 collection, linker.ld higher-half layout, kernel_info.inc generation. - kmain Boot Sequence — Phase-by-phase walkthrough of kernel_entry/kmain: serial, framebuffer, stack switch, FS recovery, memory reservation, APIC/IDT setup, scheduler handoff.
-
Splash Screen and Branding —
splash.zig,logo.zig,Splash.rgbasset and boot-time visual presentation.
The boot sequence transforms the CPU state from 16-bit real mode into a fully paged 64-bit long-mode environment with active interrupt management, hardware timers, and memory allocation.
Title: Boot Path Code Entity Mapping

Sources: src/boot/boot.asm1-110src/kernel/kernel.zig1-14
The bootloader is split into distinct stages that progressively configure the hardware platform before handing control to the Zig kernel image. Stage 1 resides in the master boot record (src/boot/boot.asm) and uses BIOS interrupts (INT 13h extended read) to load Stage 2 from disk src/boot/boot.asm1-110 Stage 2 executes in real mode, transitions through unreal mode to access memory above 1 MiB, collects physical memory maps via BIOS INT 0x15 (E820), configures early page tables, and enables 64-bit long mode.
The kernel binary layout is governed by linker scripts which enforce a higher-half virtual base mapped against a physical load address of 1 MiB. During the build process, sector counts and entry symbols are automatically generated into build/kernel_info.inc to inform Stage 2 of the exact payload size required for disk reads.
For complete implementation details, see Bootloader Stages and Linking.
Sources: src/boot/boot.asm1-110
Once long mode is established, the CPU jumps to kernel_entry, which sets up essential segment registers and stacks before invoking kmain in src/kernel/kernel.zigsrc/kernel/kernel.zig1-14 The kmain routine executes an early-boot orchestration sequence:
- Initialises serial output drivers and framebuffers for logging src/kernel/kernel.zig46-47
- Configures bootstrap memory allocators (
FixedBufferAllocator) utilizingheap_buffersrc/kernel/kernel.zig71-81 - Restores and mounts the CodaFS filesystem instance (
fs_global) over the RAM disk region mapped atRAMDISK_VIRT_ADDR(0xFFFFFF8002000000) src/kernel/kernel.zig87-101 - Sets up interrupt descriptor tables, local APIC structures, and task state segments src/kernel/kernel.zig27-50
- Hands control over to the task scheduler to spawn the initial user-facing shell environment src/kernel/kernel.zig33
Title: Kernel Memory and Stack Topology

Sources: src/kernel/kernel.zig52-116
For a phase-by-phase walkthrough of this sequence, see kmain Boot Sequence.
Sources: src/kernel/kernel.zig1-116src/boot/boot.asm1-110
CadenzaOS incorporates early-boot visual presentation routines handled by splash.zig and rendered via the VESA VBE framebuffer or text-mode console. Utilizing compiled-in raw RGB assets (Splash.rgb) and modular font glyph generators (logo.zig), the kernel displays branding elements during the hardware initialization phase before transitioning to the interactive shell console.
For details on asset packaging and rendering mechanics, see Splash Screen and Branding.
Sources: src/kernel/kernel.zig49
- Overview
- Getting Started and Build System
- Kernel Configuration and Global State
- Project Governance and Contributing
- Boot and Early Kernel Initialization
- Bootloader Stages and Linking
- kmain Boot Sequence
- Splash Screen and Branding
- Interrupts, Scheduling, and Syscalls
- IDT, PIC, APIC and IRQ Stubs
- Scheduler and Task Lifecycle
- System Call Interface
- Demonstration Tasks
- CodaFS Filesystem and Storage
- On-Disk Format and Operations
- Space Manager and Block Devices
- Binary Format and Program Loading
- Shell, Terminal, and Display
- Shell Command Pipeline
- Terminal, Input Devices and Prompts
- Display: VGA, Framebuffer, Console and Serial