How malwarepad/cavos works
Purpose and Build Surface
cavOS is a monolithic, x86_64 Unix-like/POSIX-oriented OS written primarily in C with x86 assembly. It builds a bootable disk image containing the kernel, musl-based userspace, system startup code, and a target root filesystem. Primary build/orchestration points are Makefile, src/kernel/Makefile, and image tooling in tools/kernel/make_disk.sh.
Boot and Kernel Entry
Limine loads the kernel, with boot protocol integration and early handoff in src/kernel/entry/bootloader.c and src/kernel/entry/kernel.c. Link layout is defined by src/kernel/link.ld. The boot image configuration is target/boot/limine/limine.conf; FAT32 is used for boot media, while Ext2 is intended for the root partition.
CPU, Interrupt, and Platform Initialization
Early kernel setup establishes memory/CPU execution state, descriptor tables, interrupt handling, APIC timing, and ACPI hardware discovery. Core boundaries are src/kernel/cpu/gdt.c, src/kernel/cpu/idt.c, src/kernel/cpu/isr.c, src/kernel/cpu/apic.c, and src/kernel/acpi/uacpi_glue.c. This layer converts firmware and hardware interrupts into kernel control flow before device drivers and scheduling run.
Memory and Multitasking
Physical and virtual memory management underpin kernel allocation and per-process address spaces: src/kernel/memory/pmm.c, src/kernel/memory/paging.c, and src/kernel/memory/vmm.c. Preemptive execution is managed through task structures, stacks, and scheduling in src/kernel/multitasking/task.c, src/kernel/multitasking/stack.c, and src/kernel/multitasking/schedule.c. Syscall entry uses the x86 syscall path (src/kernel/cpu/fastSyscall.c).
Device and Console Layer
PCI discovery selects storage, input, display, and NIC drivers through src/kernel/drivers/pci.c and src/kernel/drivers/nics/nic_controller.c. Storage flows from AHCI/disk drivers (src/kernel/drivers/ahci.c, src/kernel/drivers/disk.c) into filesystems. Console output targets VGA/framebuffer and terminal rendering through src/kernel/graphical/console.c, src/kernel/graphical/fb.c, and src/kernel/graphical/ansi.c; framebuffer exposure supports /dev/fb0.
Filesystem and Process Interfaces
The VFS is the principal filesystem boundary, mounting and dispatching paths via src/kernel/filesystems/vfs/vfs_controller.c and src/kernel/filesystems/vfs/vfs_mnt.c. It fronts Ext2 root storage (src/kernel/filesystems/ext2/ext2_controller.c), FAT32, and synthetic /dev, /proc, and /sys controllers. ELF program loading is implemented in src/kernel/utilities/elf.c. Linux-shaped syscall compatibility routes user requests in src/kernel/syscalls/syscalls.c into filesystem, process, memory, I/O, signal, polling, and IPC implementations.
Networking and Userspace Runtime
Physical NIC drivers feed a kernel networking layer and bundled lwIP TCP/IP stack: src/kernel/networking/socket.c, src/kernel/networking/stack/netqueue.c, and src/kernel/networking/lwip/core/tcp.c. Supported external network services include DHCP and TCP/IP via lwIP; Unix-domain sockets are handled separately in src/kernel/syscalls/unixSocket.c. Userspace is built against musl (src/libs/musl/build.sh), started through the system CRT/runtime (src/libs/system/crt0.c, src/libs/system/main.c), and populated from target/, including Xorg configuration and Alpine apk-assembled packages.
Main entry points: kernel.c Kernel initialization · syscalls.c Syscall compatibility · pci.c PCI & device drivers · Makefile Top-level build
Components 22
Build & Image
- Top-level build · Builds the kernel, userspace, target root, and bootable image.
Makefile - Kernel build
src/kernel/Makefile - Disk image tool · Creates bootable FAT32 media and the root partition image.
tools/kernel/make_disk.sh - Target root filesystem · Contains packaged userspace, boot assets, and system configuration.
Boot
- Limine configuration
target/boot/limine/limine.conf - Boot handoff · Receives Limine state and enters early kernel initialization.
src/kernel/entry/bootloader.c - Kernel initialization
src/kernel/entry/kernel.c - Kernel link layout
src/kernel/link.ld
Kernel Core
- CPU, interrupts & ACPI · Establishes descriptor tables, interrupt control, APIC timing, and firmware discovery.
src/kernel/cpu/idt.c - Memory management · Provides physical allocation, virtual mappings, and process address spaces.
src/kernel/memory/paging.c - Tasks & scheduler · Manages task state, stacks, and scheduling.
src/kernel/multitasking/schedule.c - Fast syscall entry
src/kernel/cpu/fastSyscall.c - Syscall compatibility · Routes Linux-shaped requests to process, memory, I/O, IPC, and filesystem services.
src/kernel/syscalls/syscalls.c - ELF loader
src/kernel/utilities/elf.c
Devices, FS & Network
- PCI & device drivers · Discovers PCI hardware and selects storage, input, display, and NIC drivers.
src/kernel/drivers/pci.c - AHCI disk layer
src/kernel/drivers/ahci.c - VFS mounts & dispatch · Dispatches paths across Ext2, FAT32, and synthetic filesystem controllers.
src/kernel/filesystems/vfs/vfs_controller.c - Ext2 root storage
src/kernel/filesystems/ext2/ext2_controller.c - Network stack · Connects NIC traffic to socket handling and the bundled TCP/IP stack.
src/kernel/networking/socket.c - Framebuffer console · Renders terminal output and exposes framebuffer support for /dev/fb0.
src/kernel/graphical/console.c
Userspace
- musl runtime build
src/libs/musl/build.sh - System CRT startup · Initializes userspace before invoking the system main routine.
src/libs/system/crt0.c
Connections 23
- Top-level build → Kernel build: builds
- Top-level build → Target root filesystem: populates
- Top-level build → Disk image tool: invokes
- Kernel build → Kernel link layout: links with
- Disk image tool → Limine configuration: includes
- Disk image tool → Target root filesystem: packages
- Boot handoff → Kernel initialization: hands off to
- Kernel initialization → CPU, interrupts & ACPI: initializes
- Kernel initialization → Memory management: initializes
- Kernel initialization → Tasks & scheduler: starts
- CPU, interrupts & ACPI → PCI & device drivers: enables
- Memory management → Tasks & scheduler: provides address spaces
- Fast syscall entry → Syscall compatibility: dispatches
- Syscall compatibility → VFS mounts & dispatch: filesystem requests
- Syscall compatibility → Network stack: socket requests
- Syscall compatibility → ELF loader: exec requests
- PCI & device drivers → AHCI disk layer: selects
- PCI & device drivers → Network stack: connects NICs
- PCI & device drivers → Framebuffer console: provides display hardware
- AHCI disk layer → Ext2 root storage: block I/O
- VFS mounts & dispatch → Ext2 root storage: mounts root
- musl runtime build → System CRT startup: runtime for
- System CRT startup → Fast syscall entry: user requests