artehe/ZagOS
An operating system written in Zig
An experimental toy kernel/OS written using Zig as much as possible. Assembly will be used where required for funtionality (e.g loading the GDT in x86/x64), however this ideally will be done using inline assembly rather than seperate assembly files.
Currently the only supported architecture is x86_64 (x64). However the project should hopefully be setup and configured in such a way that if I (or maybe someone else) decides they want to learn and support another architecture then this could be relatively easily implemented.
All the features currently implemented and also the implementation progress of planned future features.
This section contains all of the information you need to be able to build, run, debug, or test ZagOS.
There's a few tools required to build and/or run the OS. If you're on Ubuntu with snap installed (or similar) then you can just run the following commands and it will install everything you should need:
snap install zig --classic --beta
sudo apt update
sudo apt install build-essential gdb grub-common qemu-system-x86 xorriso
However if not then you'll need to install Zig 0.14.0 as well as ensure you have the following tools available on your system:
If you want to do any debugging, testing, or running you'll probably want these as well:
You can build the OS by running:
make build
This will download the bootloader (Limine) and build it, before compiling the kernel and assembling everything together into a single bootable ISO image (ZagOS.iso
).
There's a couple of different options you can change in the Makefile
to configure the OS. The available options are at the top of the file and all of the possible values are listed, you can also see the value below.
# Available architecture targets: x86_64
ARCH := x86_64
# Available optimization levels = Debug, ReleaseSafe, ReleaseFast, ReleaseSmall
OPTIMIZATION_LEVEL := Debug
To generate and run an ISO image of ZagOS with Qemu you can run:
make run
This will launch the latest generated ISO image in Qemu with all the standard configured flags. These flags can be edited within the Makefile
in case you wish to use a slightly different configuration for Qemu.
You can run the ZagOS in debug mode which will then launch Qemu and then wait you to connect with gdb by using the command:
make run-debug
Alternatively if you use VS Code then this can be done from within the editor by using the inbuild tasks (or just press F5), this will then automatically connect with GDB for you.
Similar to previously all of the unit/integration tests can be run via:
make run-test
This will launch the OS in test mode the the custom Zig test runnner and execute all of the tests which are found outputting the results to the screen and producing an error code on failure.
This project is licensed under the Unlicense (LICENSE or https://opensource.org/license/Unlicense), with the exceptions of the 3rd party software/assets which are noted below
ZagOS depends on several other projects for assets and/or software. These dependencies are NOT covered by the for ZagOS License. These are instead licensed as described by each individual project's documentation, and with the licenses used by said projects linked in the list below:
All contributions are welcome in whatever form, from bug reports to feature suggestions, or best of all pull requests.
Some very helpful documents which can be useful for developing this OS: