How petitstrawberry/scarlet works
1. Repository shape
This is a monorepo for an operating-system stack, not just a kernel. The top-level split is: kernel/ for the OS core, user/ for userspace libraries and programs, drivers/ for reusable device-driver crates, modules/ for loadable kernel modules, bundles/ and projects/ for bootable image definitions, and tools/ / scripts/ for build and deployment automation.
2. Boot and system image boundary
Scarlet boots through the Limine boot protocol on both AArch64 and RISC-V 64. The projects/* and bundles/* trees define the bootable layouts: kernel + initramfs/rootfs + system configuration + userspace binaries. The kernel/lds/ and project-specific linker scripts control final image layout, while docs/boot/ and docs/architecture/ describe the target boot and memory model.
3. Kernel core responsibilities
The kernel/ crate is the central runtime. It contains task scheduling, memory management, VFS, IPC, networking, syscalls, signal/process handling, and device management. This kernel is designed to host multiple ABIs natively and to expose the same underlying kernel objects to all of them.
4. Multi-ABI execution model
A key architectural boundary is the ABI layer under kernel/src/abi/. Scarlet native, xv6, and partial Linux support are implemented as separate ABI modules, but they share common kernel subsystems such as VFS, task objects, pipes, sockets, and memory mappings. The kernel selects behavior based on the binary format / ABI being launched, which is what enables cross-ABI piping and container-like coexistence.
5. Architecture-specific execution paths
kernel/src/arch/aarch64/ and kernel/src/arch/riscv64/ hold CPU-specific boot, trap, interrupt, timer, MMU, FPU, and context-switch logic. These platform layers adapt the shared kernel to the actual machine. The repo also includes architecture-specific targets under kernel/targets/ and user/targets/, indicating separate build outputs for kernel and userspace.
6. Device model and driver split
The kernel has an internal device abstraction layer under kernel/src/device/, while reusable low-level driver implementations live under kernel/src/drivers/ and the standalone drivers/ workspace crates. This separation lets the kernel talk to generic devices like block, char, graphics, input, network, USB, PCI, and power while arch- or platform-specific drivers bind to actual hardware or virtio devices.
7. Filesystem and container isolation
VFS v2 is a major subsystem (kernel/src/fs/vfs_v2/) with drivers for tmpfs, cpiofs, devfs, devpts, ext2, fat32, overlayfs, and initramfs. The filesystem layer is tied to container isolation through mount namespaces, bind mounts, and overlay behavior. In practice, this is where rootfs images, initramfs content, and per-task filesystem views converge.
8. Task, object, and IPC layer
Process-like execution is managed by kernel/src/task/ and kernel/src/sched/, while kernel/src/object/ provides capability-oriented handles for files, sockets, memory mappings, selectable objects, streams, and introspection. IPC is a first-class subsystem (pipe, event, shared_memory, counter), and user-space programs depend on these shared kernel objects for composition across ABI boundaries.
9. Networking stack
The kernel includes a full protocol stack under kernel/src/network/ with Ethernet, ARP, IPv4, ICMP, UDP, TCP, local sockets, and syscall bindings. Driver integration is primarily through virtio networking and the common socket/file abstractions, which makes networking part of the same cross-ABI resource model as files and pipes.
10. Graphics, input, and desktop pipeline
Graphics support flows from device drivers into the kernel graphics manager and framebuffer/display abstractions, then out to userspace windowing services. The desktop stack is split across user/bin/src/sws*, user/bin/src/sas*, user/bin/src/stemd/desktop.rs, and client libraries under user/lib/sws-client and user/lib/slint-scarlet. This forms the window compositor, input routing, and UI protocol boundary.
11. Userspace platform libraries and apps
user/lib/ contains the runtime and system libraries used by applications: Scarlet OS FFI and handles, syscalls, sockets, IPC, polling, time, hypervisor support, GUI/windowing clients, and package management. user/bin/ contains the actual executables and services: shell, login, networking tools, desktop components, compositor, resolver, package manager, and various demo/test programs. These binaries are the main consumers of the kernel ABI surface.
12. Service management and system initialization
System startup is coordinated by stemd and service definitions in bundles/*/fs/system/scarlet/etc/stemd.d/ and corresponding userspace implementations in user/bin/src/stemd/. Services include networking configuration, login, resolver, desktop compositor, and input/bridge services. The architecture resembles a small service graph rather than a single monolithic init process.
13. Hypervisor and guest support
Scarlet also contains an experimental built-in hypervisor under kernel/src/hypervisor/ and architecture-specific virtual-machine support in kernel/src/arch/*/hv/. The guest_tests/ directory and user/bin/src/ushv/ show the guest-facing and device-model side of this subsystem. This is a distinct boundary from normal process execution: the kernel can run guests with separate virtual CPUs, memory, and device emulation.
14. Build, packaging, and deployment
The repo is built as a reproducible system with Nix flakes, cargo-make, and Docker support, while projects/ and bundles/ define concrete runtime images. tools/ holds image-building, guest-image, and deployment scripts; test-pkg/ and tools/scpm-pack/ support package creation; and CI workflows in .github/workflows/ automate build, test, and deployment. For an architecture diagram, these are the outer orchestration layers feeding the kernel/userspace images.
Main entry points: kernel Kernel core · abi ABI layer · bundles Boot images · architecture Architecture docs
Components 22
Kernel core
Shared OS runtime and execution model.
- Kernel core · Central kernel crate providing process, memory, VFS, IPC, networking, and syscalls.
kernel - Boot & arch · Boot entry, CPU setup, traps, interrupts, timers, MMU, and context switching for AArch64 and RISC-V.
kernel/src/arch - ABI layer · Scarlet, xv6, and partial Linux execution paths sharing the same kernel objects.
kernel/src/abi - Memory · Physical and virtual memory management, paging, boot mappings, and ioremap.
kernel/src/mem - Tasks & sched · Task lifecycle, namespaces, and scheduler coordination.
kernel/src/task - VFS v2 · Unified filesystem and mount layer with overlay, tmpfs, initramfs, ext2, fat32, devfs, and devpts.
kernel/src/fs/vfs_v2 - Objects & IPC · Capability-style handles, memory mappings, pipes, events, counters, and shared memory.
kernel/src/object - Networking · Ethernet, ARP, IPv4, ICMP, UDP, TCP, local sockets, and syscall bindings.
kernel/src/network - Device model · Kernel-facing device manager and generic device classes for block, char, input, graphics, network, USB, PCI, and power.
kernel/src/device - Kernel drivers · Built-in drivers for virtio, graphics, UART, USB, PCI, RTC, and timers.
kernel/src/drivers - Hypervisor · Built-in VM, vCPU, trap, and device-model support for guest execution.
kernel/src/hypervisor
Userspace
Libraries, services, and applications.
- Runtime libs · Scarlet ABI, runtime, syscalls, handles, IPC, sockets, polling, time, and GUI client libraries.
user/lib - User programs · Shell, login, network tools, desktop components, package manager, demos, and system services.
user/bin - Std binaries · Standalone utility programs and small service binaries built against the userspace standard library.
user/std-bin - Desktop stack · SWS compositor, SAS input/service path, desktop shell, and GUI client libraries.
user/bin/src/sws - System init · stemd and service definitions used to start login, networking, resolver, and desktop services.
user/bin/src/stemd
Images & build
Bootable layouts and orchestration.
- Boot images · Bootable system definitions combining kernel, rootfs/initramfs, config, and userspace.
bundles - Project layouts · Per-target image definitions and linker scripts for Limine boot and final layout.
projects - Build tools · Scripts and tools for image building, deployment, guest images, and packaging.
tools
Reusable drivers
Standalone hardware driver crates.
- Driver crates · Reusable low-level driver crates outside the kernel workspace, especially Apple platform components.
drivers
Loadable modules
Kernel module experiments and tests.
- Loadable modules · Experimental and testable loadable modules for the kernel module interface.
modules/loadable
Docs
Architecture and subsystem design notes.
- Architecture docs · Boot, architecture, container, network, hypervisor, graphics, services, and module design notes.
docs/architecture
Connections 28
- Boot images → Kernel core: bundle kernel · Bootable images package the central kernel runtime.
- Project layouts → Boot images: define layouts · Project BSPs and linker scripts assemble concrete images.
- Build tools → Boot images: build/deploy · Automation produces system images and deployment artifacts.
- Build tools → Project layouts: run targets · Scripts launch project-specific boot and test flows.
- Kernel core → Boot & arch: uses · The kernel depends on architecture-specific boot and execution paths.
- Kernel core → ABI layer: dispatches · Binary format and ABI determine syscall and process behavior.
- Kernel core → Memory: manages · Kernel memory management underpins mappings and allocation.
- Kernel core → Tasks & sched: schedules · Task and scheduler subsystems drive execution.
- Kernel core → VFS v2: mounts · Filesystem operations converge in VFS v2.
- Kernel core → Objects & IPC: exposes · Kernel objects and IPC are the shared composition boundary.
- Kernel core → Networking: serves · Sockets and network syscalls sit on the kernel stack.
- Kernel core → Device model: binds devices · The kernel mediates hardware through its device abstraction.
- Kernel core → Kernel drivers: loads drivers · Built-in drivers connect the kernel to platforms and virtio.
- Kernel core → Hypervisor: hosts guests · Guest execution is implemented as a distinct kernel subsystem.
- ABI layer → VFS v2: shares · ABIs reuse the same filesystem and mount objects.
- ABI layer → Objects & IPC: shares · ABIs share handles, pipes, sockets, and mappings.
- ABI layer → Tasks & sched: reuses · ABI-specific process behavior runs on the common task model.
- Device model → Driver crates: integrates · Generic device classes connect to reusable driver crates.
- Boot & arch → Driver crates: platform support · Architecture layers depend on low-level platform drivers.
- Runtime libs → Kernel core: syscalls · Userspace libraries are the primary consumers of the kernel ABI.
- User programs → Runtime libs: link against · Applications and services use the userspace runtime libraries.
- Std binaries → Runtime libs: link against · Utility binaries share the same userspace foundations.
- Desktop stack → Device model: renders/input · Desktop components sit on top of graphics and input device abstractions.
- System init → User programs: starts · stemd launches and coordinates service binaries.
- Loadable modules → Kernel core: extends · Modules attach to kernel internals through the module interface.
- Architecture docs → Kernel core: describes · Docs explain the core kernel architecture and boundaries.
- Architecture docs → Boot images: describes · Docs explain the boot and image model.
- Architecture docs → Desktop stack: describes · Docs explain the graphics and desktop pipeline.