meowix

Unix-like OS. x86-64, C++20 and assembly.

C++ / x86-64 / asmGitLab
Four-level paging / address decomposition

Example address: 0xffff800000001000

  1. PML4bits 47—39Index 256100000000
  2. PML3bits 38—30Index 0000000000
  3. PML2bits 29—21Index 0000000000
  4. PML1bits 20—12Index 1000000001

Page offset 09-bit indices; 12-bit page offset.

Interpretation of kernel/memory/paging.cc ↗

Boot & execution

Limine boot context and command-line parsing. The kernel initializes memory, descriptor tables, interrupts and devices before spawning a program from its initrd.

kernel/entry.cc

Memory & paging

Physical and virtual memory managers, four-level page tables, mapping and unmapping, and TLB flushing. Page-table entries include present, write, user and NX flags.

kernel/memory/paging.cc

Tasks & syscalls

Task contexts store general-purpose registers and SSE state. The user interface defines test-write, suicide, kill and getpid syscalls.

user/include/syscalls.h

Interrupts & devices

GDT, TSS, IDT, ACPI, APIC and IOAPIC code. Driver sources include PS/2 input, UART serial and a virtual terminal.

kernel/arch/

kernel/entry.cc · excerpt

Memory::PMM::init();
Memory::Paging::init();
Memory::VMM::init();

Arch::GDT::init();
Arch::IDT::init();

Sys::Multitasking::Man::start();
Read full source