A toy RISC-V kernel built with Zig for OS exploration (WIP).
Find a file
2026-05-14 04:21:40 +08:00
assets docs: update runtime-demo 2026-05-05 06:05:25 +08:00
bootloader chore: add banner and select sbi for level 2026-05-02 11:07:11 +08:00
os feat: add vmm 2026-05-05 06:02:36 +08:00
.gitignore chore: rm fxxking .DS_Store 2026-05-05 00:47:30 +08:00
build.zig chore: zig fmt 2026-05-05 03:13:40 +08:00
build.zig.zon chore: init project 2026-04-20 05:12:20 +08:00
Onlyfile chore: change Onlyfile default log_level to 'info' 2026-05-03 11:29:13 +08:00
README.md docs: how should i describe it? 2026-05-14 04:21:40 +08:00

🌱 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

  • Zig (>=0.16.0)
  • QEMU (>=11.0.0, if you don't have a real board)
  • Only (task runner if you like)

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 :)