A toy RISC-V kernel built with Zig for OS exploration (WIP).
- Zig 100%
| assets | ||
| bootloader | ||
| os | ||
| .gitignore | ||
| build.zig | ||
| build.zig.zon | ||
| Onlyfile | ||
| README.md | ||
🌱 KrcyOS
A toy RISC-V kernel built with Zig for OS exploration.
Current
- Booting: Clean RISC-V boot process over OpenSBI.
- Console: Formatted serial output via SBI calls.
- Power: Shutdown for both QEMU and bare-metal.
- Logging: Multiple terminal log printing methods.
- Panic: Panic triggered under exceptions or manually.
- Trap: Exception table with dynamic instruction length decoding.
- Pmm: Dynamic physical page allocation via intrusive free list.
- Vmm: Sv39 reality bending with mapping and kernel protection.
Motivation
Just to understand OS.
Prerequisites
Didn't check it yourself before asking? RTFM first.
Getting Started
Clone the toy
git clone https://codeberg.org/Kercy/krcyos.git
# if you prefer github:
# git clone https://github.com/KercyDing/krcyos.git
cd krcyos
# ...
Simply run it
zig build run -Dboard=qemu_virt
# or:
# only run qemu
If you have a real board:
zig build run -Dboard=real_board
# or:
# only run real
Then flash to your board.
Try another log level? You can:
zig build run -Dboard=qemu_virt -Dlog=info
# or:
# only run qemu info
That's it. Should be a piece of cake.
Why not Rust?
Simply put, I prefer Zig over Rust.
For me, Rust isn't explicit enough at the kernel level, even though 90% of my projects are written in Rust :)