Architecture

The design and structure of the MinimalOS NextGen kernel.

Table of contents

Microkernel Design #

MinimalOS NextGen follows a strict microkernel architecture. The kernel provides only the minimal set of mechanisms required to build a complete operating system — all policy decisions are made in userspace.

    graph TD
      subgraph US["USERSPACE - Ring 3"]
        Init["Init Process"]
        Serial["Serial Driver"]
        VFS["VFS Service"]
        Net["Network Stack"]
      end
      subgraph KN["KERNEL - Ring 0"]
        AS["Address Spaces"]
        Cap["Capabilities"]
        IPC["IPC Delivery"]
        Sched["Scheduler"]
        IRQ["Interrupt Routing"]
        MemG["Memory Grants"]
      end
      subgraph HW["HARDWARE - x86_64"]
        CPU["CPU Cores"]
        RAM["Physical RAM"]
        IO["I/O Devices"]
      end
      Init & Serial & VFS & Net -->|"IPC"| IPC
      IPC --> AS & Cap & Sched
      AS & IRQ & MemG --> CPU & RAM & IO
    

Kernel Responsibilities (6 services)

  1. Address space isolation — Create and manage per-process page tables
  2. Capability enforcement — Validate unforgeable tokens on every resource access
  3. IPC message delivery — Transfer opaque byte buffers + capabilities between processes
  4. CPU time multiplexing — Tickless scheduler with per-core run queues
  5. Interrupt routing — Deliver hardware interrupts to capability holders
  6. Memory grant transfers — Zero-copy page sharing between address spaces

What the kernel does NOT do

All of these are implemented as userspace services communicating via IPC.


Capability-Based Security #

Instead of traditional Unix-style permissions (user/group/other), MinimalOS uses capabilities — unforgeable tokens that grant specific rights to specific resources.

Key Properties

Capability Types (Planned)

TypeDescription
MemoryAccess to a region of physical memory (for DMA, MMIO)
IPC EndpointPermission to send/receive on a communication channel
InterruptRight to receive a specific hardware interrupt
ProcessControl over a process (suspend, resume, kill)
ThreadControl over a thread within a process

Memory Layout #

Virtual Address Space

    block-beta
      columns 1
      block:top["0xFFFFFFFFFFFFFFFF"]
        A["Reserved / Guard"]
      end
      block:kernel["0xFFFFFFFF80200000"]
        B["Kernel .text, .rodata, .data, .bss"]
      end
      block:kbase["0xFFFFFFFF80000000 ← Kernel base"]
        C["2MB Padding"]
      end
      block:hhdm["~0xFFFF800000000000"]
        D["Higher Half Direct Map - HHDM\nAll physical RAM mapped here"]
      end
      block:hole[" "]
        E["Canonical Hole\nx86_64 architecture gap"]
      end
      block:user["0x00007FFFFFFFFFFF"]
        F["User Address Space\nOne per process, full lower half"]
      end
      block:zero["0x0000000000000000"]
        columns 1
      end
    

Kernel Sections

Each section is page-aligned (4 KiB) for W^X enforcement:

SectionPermissionsContents
.textRead + ExecuteExecutable code
.rodataRead onlyString literals, constants, Limine requests, .got
.dataRead + WriteInitialized mutable globals
.bssRead + WriteZero-initialized mutable globals

The linker script places the kernel at 0xFFFFFFFF80200000 (higher-half base + 2MB offset). Limine sets up the page tables at boot.

Physical Memory Management

The kernel uses a bitmap allocator for physical frames:


Boot Sequence #

MinimalOS boots via the Limine boot protocol:

Firmware → Bootloader → Kernel

  1. Power on → UEFI firmware initializes hardware
  2. UEFI loads Limine from the EFI System Partition
  3. Limine reads boot/limine.conf, loads the kernel ELF
  4. Limine sets up 64-bit long mode with paging:
    • Identity map of low memory
    • Higher-half kernel map at 0xFFFFFFFF80000000+
    • HHDM (all physical RAM accessible at a fixed offset)
  5. Limine fills in request structures and jumps to kmain()

Kernel Initialization (5 Phases)

PhaseNameDescription
1Deaf and BlindInitialize COM1 serial UART. After this, kprintln!() works.
2Can SeeParse boot info (HHDM, memory map, framebuffer, ACPI). Init framebuffer console.
3Can RememberInit PMM (bitmap allocator), kernel heap (Vec, Box, String available). VMM infrastructure ready.
4Can Think(Planned) GDT/IDT, LAPIC, I/O APIC, scheduler, SMP.
5Alive(Planned) SYSCALL/SYSRET, ELF loader, init process, enter Ring 3.

Syscall Interface (Planned) #

The kernel will expose approximately 22 syscalls, grouped by subsystem:

Memory Syscalls

IPC Syscalls

Capability Syscalls

Process/Thread Syscalls

System Syscalls


Technology Stack #

ComponentChoiceRationale
LanguageRust (nightly)Memory safety, zero-cost abstractions, no_std support
Targetx86_64-unknown-noneBare metal, no OS dependency
BootloaderLimine v8.6.0UEFI support, higher-half mapping, rich boot protocol
BuildCargo + MakeCargo for Rust, Make for ISO & QEMU orchestration
CIGitHub ActionsAutomated build, ISO creation, release management
Edition2024Latest Rust edition
Key crateslimine, spin, bitflags, x86_64, logMinimal, audited dependencies for Ring 0