An operating system written in Swift.
Important
This project is in the very early stages of development.
I'm currently focusing on supporting AArch64 and Raspberry Pi 4, but I plan to support more CPU architectures and hardware in the future.
Boot— Minimal boot code before entering Swift.Kernel— Kernel executable and system entry point.KernelCore— Architecture- and platform-independent kernel logic (scheduler, memory management, core services).EarlyKernelCore— Pre-MMU kernel logic.
Hardware— Hardware abstraction layer defining device interfaces independent of CPU architecture and platform (console, timer, framebuffer, etc.).- CPU architecture support
ArchAArch64- AArch64 CPU support (exceptions, MMU, vector tables, system registers).EarlyArchAArch64- Pre-MMU AArch64 CPU support.
ArchX8664- (planned) x86_64 CPU support (IDT, paging, interrupts).
- Platform support
RaspberryPi— Raspberry Pi platform implementation (UART, mailbox, framebuffer, interrupt controller).
KernLibc— Minimal libc for kernel space.EmbeddedPlatform— The Embedded Swift Platform Abstraction Layer implementation.AppLibc— Minimal libc for user space.AsmSupport— Assembly helper functions.LinkerSupport— Swift bindings for linker-defined symbols.
- QEMU 9.0 or later
- Arch Linux:
sudo pacman -S qemu-system-aarch64 - Fedora 41 or later:
sudo dnf install qemu-system-aarch64-core - Ubuntu 24.04: Build from source
- Debian 13 or later:
run0 apt install qemu-system-arm - macOS 14 or later:
brew install qemu
- Arch Linux:
- Swiftly
- Swift toolchain: Just run
swiftly installafter installing Swiftly
swift build --triple aarch64-none-none-elf --toolset toolset.json --build-system native.build/debug/Kernel is the kernel binary.
swift run --triple aarch64-none-none-elf --toolset toolset.json --build-system nativeDebug build (recommended for development):
swift build --triple aarch64-none-none-elf --toolset toolset.json --build-system native
llvm-objcopy .build/debug/Kernel -O binary .build/kernel8.imgRelease build (recommended for deployment):
swift build -c release --triple aarch64-none-none-elf --toolset toolset.json --build-system native
llvm-objcopy .build/release/Kernel -O binary .build/kernel8.imgHow to boot:
- Build
.build/kernel8.imgfollowing the above instructions - Read this article and prepare a bootable SD card
- Replace
kernel8.imgon the SD card with.build/kernel8.imgyou built - Insert the SD card to your Raspberry Pi 4
- Turn the power on
swift package cleanThis project is using swift-format for formatting and linting.
Format:
swift format format -rip .Lint:
swift format lint -rsp .