A recreational attempt to build a very basic kernel in Swift
- Swift 59.1%
- Linker Script 29.5%
- Assembly 11.4%
| .vscode | ||
| Sources | ||
| .gitignore | ||
| linker.ld | ||
| Package.swift | ||
| README.md | ||
| toolset.json | ||
Swift Kernel
A recreational attempt to build a very basic kernel.
This project uses embedded Swift, which is a subset of
the Swift language.
The associated blog post article is here.
Dependencies for the compiler
- QEMU, a free machine emulator,
- swift main-snapshot.
Build
First, verify you are on main-snapshot version of Swift.
This should list XX-dev
swift --version
If not, install it and use it for this project:
swiftly install main-snapshot
swiftly use main-snapshotw
Now, you can build the kernel
# debug
swift build --triple aarch64-none-none-elf --toolset toolset.json --build-system native
# release
swift build -c release --triple aarch64-none-none-elf --toolset toolset.json --build-system native
and use QEMU to run it
# debug
qemu-system-aarch64 -machine virt -cpu cortex-a57 -nographic -kernel .build/aarch64-none-none-elf/debug/kernel
# release
qemu-system-aarch64 -machine virt -cpu cortex-a57 -nographic -kernel .build/aarch64-none-none-elf/release/kernel
To kill QEMU: Ctrl+A, then X.