Skip to content

Architecture

Oguzhan KAYNAK edited this page Oct 20, 2026 · 1 revision

Architecture

Boot flow

  1. GRUB loads atlOS.kernel (multiboot2) at 4 MB and enters _start in 32-bit mode.
  2. boot.S builds the boot page tables (an identity map and the higher half at 0xFFFFFFFF80000000, 2 MB pages), enables long mode and calls kernelMain.
  3. kernelMain (kernel/core/main.cpp) is the composition root. It constructs the kernel's objects in dependency order and hands them to their users by reference:
VGATextConsole, SerialPort      -> Core::setConsole (printf)
IDT
PhysicalMemoryManager           <- multiboot memory map
AddressSpace(pmm)               -> heap (kmalloc)
PIC                             -> ISR dispatcher
PIT(pic)
Scheduler(pit)                  -> threads

The objects live in Cxx::Uninitialized<T> storage: static memory whose constructor runs exactly when kernelMain calls construct(), not as a global constructor.

Address space

Virtual range Contents
0 .. kernel_physical_end identity map from boot
0xFFFFFF0000000000 (PML4[510]) recursive mapping of the page tables
0xFFFFFFFF80000000 .. kernel_virtual_end kernel image
kernel_virtual_end .. top heap, thread stacks, MMIO mappings (2 MB pages)

Interrupts

ISR stubs (arch/x86_64/idt/isr.S) save the registers and call intHandler. Exceptions print a register dump and halt; IRQs are acknowledged through the InterruptController and dispatched to the handler a driver attached. The timer interrupt only counts ticks: the scheduler is cooperative.

Source layout

kernel/
  arch/x86_64/   boot, crt, cpu (context switch, CPUID), gdt, idt, io ports, mmu
  core/          kernelMain, console, panic, logger
  cxx/           C++ runtime (global constructors, new/delete, Uninitialized)
  mm/            pmm, vmm, heap (liballoc)
  sched/         scheduler, threads
  drivers/       pic, pit, serial, vga console, keyboard, disk/
  dev/ fs/ firmware/ sync/ lib/ tests/
libc/            freestanding C library (libk)

Headers sit next to their sources; includes are relative to kernel/, e.g. #include <mm/vmm.hpp>.

More: docs/architecture.md

Clone this wiki locally