I wanted to understand what the bare minimum of an operating system looks like.
So I built one in Zig, keeping the whole thing under 1000 lines of code.
It can:
→ Boot from GRUB
→ Manage memory
→ Schedule simple tasks
→ Output text to VGA
The point was not to make it feature-rich, but to show how much is possible with just a few hundred lines if you strip everything down to the essentials.
noone_youknow•2h ago
Nice work! Looks like most of the basics are covered, and meanwhile in my current kernel the RISC-V entrypoint is >700 lines (of C) just to get to the arch-independent entrypoint!
I was just looking around for your input/output code, I don’t know zig but I expected to find putChar in kernel.zig based on the import in common.zig, but I don’t see it, should I be looking somewhere else? I didn’t see any simple command line processing either as mentioned in the README?
Mostly just looking around since your README mentioned VGA (and you seem to have a BIOS boot) which struck me as interesting on a RISC-V project, I was curious if you were actually using the SBI routines or had actually mapped in a VGA text mode buffer?
cyberclimb•2h ago
Hi botirk, really interesting project!
If I build the project what is the output format and how could configure things to boot it?
I know how to this with IMG and ISO files of course but not sure what to do with the build output if it's an executable?
Also any insights into whether this would also boot on an ARM machine? Thanks!
coffeeri•1h ago
Check the build.zig file. It defines the arguments for QEMU to run the OS.
You should be able to run zig build run.
hdjxjdjdkshsb•56m ago
Curious: is it 1k lines of zig total with no libraries or 1k lines of zig with libraries?
mcny•38m ago
I don't know zig but the only import I see here is std so my guess is there are no libraries here?
tjpnz•28m ago
Nice project! I'm more accustomed to building and running these using QEMU/VirtualBox (which I understand you can do with here). But what's going on when I build and execute it under the host OS? Is it also running in userspace?
botirk•3d ago
So I built one in Zig, keeping the whole thing under 1000 lines of code.
It can: → Boot from GRUB → Manage memory → Schedule simple tasks → Output text to VGA
The point was not to make it feature-rich, but to show how much is possible with just a few hundred lines if you strip everything down to the essentials.
noone_youknow•2h ago
I was just looking around for your input/output code, I don’t know zig but I expected to find putChar in kernel.zig based on the import in common.zig, but I don’t see it, should I be looking somewhere else? I didn’t see any simple command line processing either as mentioned in the README?
Mostly just looking around since your README mentioned VGA (and you seem to have a BIOS boot) which struck me as interesting on a RISC-V project, I was curious if you were actually using the SBI routines or had actually mapped in a VGA text mode buffer?
cyberclimb•2h ago
If I build the project what is the output format and how could configure things to boot it?
I know how to this with IMG and ISO files of course but not sure what to do with the build output if it's an executable?
Also any insights into whether this would also boot on an ARM machine? Thanks!
coffeeri•1h ago
You should be able to run zig build run.
hdjxjdjdkshsb•56m ago
mcny•38m ago
tjpnz•28m ago