How 0nera/bmosp works
Purpose and execution model
BMOSP is an educational, modular x86_64 platform rather than a general-purpose OS. It targets BIOS/UEFI boot and is intended primarily for QEMU. The kernel is built as a freestanding C/GAS image, booted through Limine, then extended with separately built runtime modules. Top-level build/run entry points are build.sh, build_mods.sh, and run.sh.
Boot and kernel initialization
Limine boot configuration and image layout are defined in configs/limine.cfg and configs/linker.ld. Kernel control begins in kernel/start.c, which establishes the platform runtime and coordinates early subsystem initialization. Architecture-specific setup is concentrated under kernel/cpu/arch.c and kernel/cpu/cpu.c.
CPU, interrupts, and scheduling boundary
The x86_64 hardware layer configures descriptor tables, interrupt handling, PIC/PIT timing, paging, and task switching. Key paths are kernel/cpu/idt.c, kernel/cpu/idt_stubs.s, and kernel/cpu/paging.c; task execution/switching spans kernel/cpu/task.c and kernel/cpu/task_switch.s. This layer is the boundary between raw processor events and kernel services.
Kernel services and shared interfaces
Core services include memory management, framebuffer output, logging, synchronization, buffered I/O, and general system calls/services. Their implementation resides in kernel/mem.c, kernel/fb.c, kernel/log.c, kernel/lock.c, kernel/io_buf.c, and kernel/sys.c. Public kernel-facing contracts are exposed through headers such as include/mem.h, include/sys.h, include/fb.h, and include/mod.h; modules should depend on these interfaces rather than internal kernel files.
Module loading and executable format
The platform’s defining extension mechanism is dynamically managed modules. kernel/mod.c owns module lifecycle/loading behavior, while kernel/elf.c handles ELF-format executable/module parsing. Module ABI and system-facing types are supplied by modlib/modstd.h, modlib/system.h, and modlib/types.h. The module linker layout is defined by modules/link.ld.
Modules and device/application functionality
Modules are independently compiled C components with their own build.sh entry points. They provide demonstrations and platform capabilities: example output (modules/helloworld/main.c), in-memory filesystem behavior (modules/imfs/main.c), PCI discovery (modules/pci/main.c), PS/2 input (modules/ps2/main.c), and a Doom workload (modules/doom/main.c). The module catalog is represented by modules/modules.json.
Build, SDK, and delivery infrastructure
Build scripts assemble the kernel, module artifacts, boot configuration, and image/runtime workflow. build.sh is the primary kernel build orchestrator; scripts/build_sdk.sh and scripts/get_sdk.sh manage the required SDK/toolchain; scripts/modmanager.py supports module management. CI, static analysis, and release automation run in GitHub Actions through .github/workflows/build.yml, .github/workflows/codeql.yml, and .github/workflows/release.yml.
Main entry points: start.c Kernel startup · main.c Runtime modules · build.sh Kernel build · build_mods.sh Module builds
Components 20
Build & Delivery
- SDK toolchain · Installed and managed by SDK scripts.
scripts/build_sdk.sh - Kernel build · Builds the freestanding kernel and boot image.
build.sh - Module builds · Independently builds runtime module artifacts.
build_mods.sh - Module manager
scripts/modmanager.py - CI and releases · Build, analysis, and release automation.
.github/workflows/build.yml - QEMU runtime · Runs the BIOS/UEFI bootable image.
run.sh
Boot Image
- Limine boot config
configs/limine.cfg - Kernel linker layout
configs/linker.ld
Kernel Runtime
- Kernel startup · Establishes the runtime and initializes subsystems.
kernel/start.c - CPU platform setup · Sets up processor architecture state.
kernel/cpu/arch.c - Interrupts and paging · Translates processor events and manages virtual memory.
kernel/cpu/idt.c - Tasks and switching · Executes tasks and performs context switches.
kernel/cpu/task.c - Kernel services · Memory, framebuffer, logging, locks, buffered I/O, and system services.
kernel/sys.c - Public kernel API · Interfaces modules use instead of kernel internals.
include/mod.h - Module loader · Loads and manages module lifecycle.
kernel/mod.c - ELF parser · Parses module executable format.
kernel/elf.c
Module Ecosystem
- Module ABI · System types and module-facing ABI.
modlib/modstd.h - Module linker layout
modules/link.ld - Module catalog
modules/modules.json - Runtime modules · Hello world, IMFS, PCI, PS/2, and Doom capabilities.
modules/helloworld/main.c
Connections 23
- SDK toolchain → Kernel build: provides toolchain
- SDK toolchain → Module builds: provides toolchain
- Kernel build → Kernel linker layout: links with
- Kernel build → Limine boot config: packages boot config
- Module builds → Module linker layout: links with
- Module manager → Module catalog: manages
- Module builds → Runtime modules: builds
- CI and releases → Kernel build: automates
- CI and releases → Module builds: automates
- QEMU runtime → Limine boot config: boots image via
- Limine boot config → Kernel startup: boots
- Kernel linker layout → Kernel startup: places image
- Kernel startup → CPU platform setup: initializes
- CPU platform setup → Interrupts and paging: configures
- Interrupts and paging → Tasks and switching: dispatches execution
- Kernel startup → Kernel services: initializes
- Kernel services → Public kernel API: exports
- Kernel startup → Module loader: starts
- Module loader → ELF parser: parses through
- Module loader → Runtime modules: loads
- Runtime modules → Module ABI: uses
- Runtime modules → Public kernel API: calls
- Module catalog → Runtime modules: lists