An implementation of a kernel entirely from scratch.
  • Zig 95.1%
  • Assembly 3%
  • Linker Script 1.7%
  • Python 0.2%
Find a file
Vimthusiast 1b1ce1d697
All checks were successful
Zig Test / test (push) Successful in 1m1s
docs: add TODO
2026-09-04 16:01:18 +02:00
.forgejo/workflows feat: zig test workflow 2026-09-03 12:21:39 +02:00
apps/hello-world feat: clean up hello-world and put _start into shared libsys-start 2026-08-29 04:32:09 +02:00
libsys feat: clean up hello-world and put _start into shared libsys-start 2026-08-29 04:32:09 +02:00
scripts feat: better boot.S, gdb init scripting with zig build step, vmm fixes 2026-08-14 20:36:14 +02:00
src fix: error on test due to wrong log impl 2026-09-03 11:52:51 +02:00
.gitignore feat: load kernel.elf segments into memory 2026-07-11 00:53:50 +02:00
.python-version feat: better boot.S, gdb init scripting with zig build step, vmm fixes 2026-08-14 20:36:14 +02:00
build.zig feat: disable v, f/d, c ISA extensions in kernel 2026-08-31 02:40:13 +02:00
build.zig.zon chore: zig init 2026-07-05 21:06:04 +02:00
pyproject.toml feat: better boot.S, gdb init scripting with zig build step, vmm fixes 2026-08-14 20:36:14 +02:00
pyrightconfig.json feat: better boot.S, gdb init scripting with zig build step, vmm fixes 2026-08-14 20:36:14 +02:00
README.md docs: add build and run instructions 2026-08-31 20:41:50 +02:00
TODO.md docs: add TODO 2026-09-04 16:01:18 +02:00
uv.lock feat: better boot.S, gdb init scripting with zig build step, vmm fixes 2026-08-14 20:36:14 +02:00

TinySys

An implementation of a kernel entirely from scratch.

Motivation for this Project

I always prefer to know how the things I use on a daily basis work under the hood. One of those things is Linux, which I use on all of my devices.

Maybe I'll get it to the point where it can be considered an operating system, eventually...

Tech Stack: literally just Zig

Many would want to use C/C++ for such a project. So why choose Zig, you may ask? Because it has:

  • an amazing build system (check the build.zig),
  • the beautiful comptime keyword, instead of C preprocessor macros,
  • defer and errdefer, handling 95% of what the borrow checker in Rust is for,
  • no hidden control flow, everything is explicit and therefore easier to reason about,
  • no hidden allocations, it is all explicit, using the std.mem.Allocator interface,

and because I just wanted to see how Zig does in such a project, at the lowest level of software there is! (aside from firmware maybe)

First Prototype Goals - for the Hack Club Macondo YSWS

finished

  • Booting via the SBI boot protocol
  • UART driver for basic printing
  • A single U-mode process executing -> just a kernel-embedded binary at first -> basic syscalls work: write, exit

Future Goals

  • Small TTY/Shell Initial Process:
    • using basic graphics -> bitmap font rendering?
    • environment variables and $PATH lookups
    • coloring support (ANSI? -> maybe something less complex)
  • Symmetric Multi-Processing:
    • implement infrastructure for easly declaration of per-CPU state (using the tp register)
    • simple preemptive scheduler, maybe based on fair shares?
  • Persistent Filesystem:
    • FAT32 first
    • Ext4 later
  • Advanced Graphics Support:
    • windowing/window compositor => Wayland protocol?

Project Structure

  • src/ Kernel and Bootloader
  • libsys/ System Zig Library, equivalent to a POSIX libc
  • apps/ Userspace Applications
    • apps/hello-world: A hello world program, that simply prints to stdout.

Building and Running from Source Code

Requirements:

  • Zig 0.16.0
  • QEMU installation including qemy-system-riscv to emulate the RISC-V 64-bit ISA
# Run in an optimized build in a headless QEMU with maximum verbose logging
zig build -Dheadless -Dlog-level=debug --release=small run