universalisos/kernel/README.md
Fábio Coutada bafa872415 refactor(kernel): rewrite Stage 1 kernel in C++
- Rename kernel.c -> kernel.cpp and uart.c -> uart.cpp
- Add universalisos::uart namespace with constexpr register definitions
- Use extern "C" linkage for kernel_main() called from boot.S
- Compile with arm-none-eabi-g++ using C++17 freestanding flags
  (-fno-exceptions, -fno-rtti, -fno-threadsafe-statics, -fno-use-cxa-atexit)
- Update Makefile to use g++ and .cpp build rules
2026-07-06 22:53:50 +01:00

1.3 KiB

Universalisos Kernel — Stage 1 Bare-Metal Skeleton (C++)

This is the first bootable type-1 hypervisor milestone for Universalisos: a minimal bare-metal kernel written in C++ that runs on QEMU's ARM virt machine and prints to the PL011 UART.

Building

Requires arm-none-eabi-gcc and qemu-system-arm.

cd kernel
make

Outputs:

  • kernel.elf — ELF image for debugging
  • kernel.bin — raw binary for QEMU -kernel

Running in QEMU

make run

This runs qemu-system-arm with the ELF image so that QEMU loads the kernel at the address specified in the linker script.

Expected output:

Universalisos type-1 hypervisor booted.
Stage 1: bare-metal C++ skeleton running on QEMU ARM virt.

Press Ctrl+A then X to exit QEMU.

Inspecting the binary

make dump

Layout

File Purpose
arch/arm/boot.S Assembly entry point, stack/BSS setup
arch/arm/linker.ld Memory layout for QEMU virt (load at 0x40000000)
arch/arm/uart.cpp PL011 UART driver
arch/arm/uart.h UART interface
kernel.cpp kernel_main() entry point

Design notes

  • The kernel is loaded by QEMU at RAM base 0x40000000.
  • A 64 KiB stack is reserved immediately after the BSS section.
  • Interrupts are disabled in the boot stub; the kernel idles with wfi.