Hux - An x86 32-bit toy operating system kernel built from scratch, following the OSTEP book structure and terminology.
Author | Kernel Src LoC (temp) | Tutorial LoC (temp) |
---|---|---|
Guanzhou Hu | C + x86 ASM | Markdown |
Jun. 2021 | 4975 | 4397 |
I document the whole development process of Hux - its skeleton, related theories, practice pitfalls, plus everything I reckon important as a complete set of tutorials. They can be found at:
- The WIKI pages 📝 of this repo
- The Hux kernel dev doc PDF (identical, WIP)
If there are any typos / mistakes / errors, please raise an issue!
With QEMU (recommended), download the CDROM image hux.iso
and do:
$ qemu-system-i386 -cdrom hux.iso
# Or, if you clone the repo and build Hux yourself:
$ make
$ make qemu
You will see the QEMU GUI popping up with GRUB loaded. Choose the "Hux
" option with Enter to boot into Hux.
For development setup & instructions, please check out the wiki pages (recommended). I have every single detail documented there.
The main goal of Hux is to be Understandable: structured in a way that is easy to understand (not mimicking existing UNIX-like systems). OS development seems scary at first glance for beginners mostly because it involves too many hairy technical details. I admit that, in real-world systems, we must face the complexity to ensure compatibility, performance, robustness, security, etc. Yet, a toy kernel project would help demonstrate the key concepts of an operating system, including its most essential steps of development, layers of abstractions, and the ideas of virtualization, concurrency, and persistence.
Goals of the Hux kernel include:
- Understandability: as stated above
- Minimalism: a minimal workable core design
- Code clarity: though monolithic kernel, I will try to keep the code structure modularized
- Experimentalism: not mimicking existing UNIX flavor, not targeting at practical use
I choose to write it in C language with i386-IA32
architecture, since beginners tend to be more comfortable with this combination. More up-to-date system programming languages like Rust are great choices for modern 64-bit OS dev (Philipp is making his Rust OS kernel here), but I will start with easier settings for now to maintain better understandability. Rust itself is still "niche" (maybe not?) and you have to incorporate some of its "dark magics" to succeed in OS dev. It definitely confuses new learners.
These are general and long-term goals which I will (hopefully) follow throughout the project. I hope this can lead towards a full HuxOS which we can install on real devices and play with in the future (kept simple, of course 😁)
Main references:
- The OSDev Wiki (IMPORTANT ✭)
- JamesM's Kernel Tutorial by James, along with its known bugs
- Writing an OS in Rust by Philipp (still updating...)
- The xv6 Kernel x86 ver. by MIT PDOS (no longer updated)
OS conceptual materials:
- Operating Systems: Three Easy Pieces (OSTEP) by Prof. Arpaci-Dusseaus
- My reading notes on OSTEP book & lectures
Check the "References" section here for the full list.
- The basic kernel skeleton
- VGA text mode driver
- Debugging utilities stack
- Interrupts & timer
- Keyboard input support
- Global descriptors table
- Virtual memory (paging)
- Heal memory allocator
- Process isolation
- Context switch & scheduling
- Multi-threading concurrency
- Synchronization primitives
- Basic IDE disk driver
- Very simple file system
- Wiki pages & README
- Extend Hux to Rux with Rust