Zig OS explained

Over the time, I have made more and more progress with my operating system. Now I can even get keyboard presses (scan codes) in the kernel, which is a huge step!

But recently I decided to move that stuff from my old repo (https://codeberg.org/sfiedler/zig_os) to a new organization (https://codeberg.org/loup-os) and to “downgrade” the old repo to the state of my last post about it (see here).
Because then I could keep it up-to-date with the latest Zig master and explain all the code to help other people get started with operating system development.

The new, explained Zig OS is available at https://codeberg.org/sfiedler/zig_os, so feel free to have a look!


What made you decide to go with an EFI bootloader over an MBR based one? I’ve written an MBR bootloader but haven’t done one using EFI:

Bootloader Standalone: GitHub - marler8997/crystal: A simple static bootloader
Large OS toy project: GitHub - marler8997/maros

I did some EFI development when I was at HP, I implemented “secure boot” where we would hash/verify our Windows CE kernel image at the time, but I wasn’t aware how all the pieces “fit together”. Excited to look more deeply into your project to learn more about it.

Mainly, it was the interface when I was completely new to the OS programming stuff.
So I found the std.os.uefi namespace and decided to try reading some EFI bootloaders. As far as I know, MBR works with the BIOS and I wanted to focus on the main thing (parsing the kernel executable) instead of having to bother with interrupts.
However, as my repo only contains the basic stuff, most of the code is around half a year old. In that time, I improved the kernel and learned really much about the architecture of processors and operating systems.
Now, I think I could program a MBR bootloader, but why touch a working piece of code? :smiley:
Just joking. In the future I may support EFI and MBR using a bootloader “core” which parses the kernel executable and two bootloader “interfaces” that are wrappers to UEFI and BIOS.