This repository contains a two-stage bootloader, an x86_64 kernel, and a ring 3 OS stub, all written from scratch.
The system is under development. Does not run DOOM yet 👿
Latest feature: mmap
ing the framebuffer from userspace to draw graphics!
The imitation of the DVD logo is rendered by the OS, not the kernel.
Make sure you have the required dependencies:
- make
- nasm
- QEMU (qemu-system-x86_64)
- x86_64-elf-gcc
- x86_64-elf-ld
Then run
make -j qemu64 # anywhere
to build the image and boot it in QEMU.
- Bootloader
- Protected mode
- Long mode
- Enabling SSE, AVX*
- Loading arbitrarily large images
- VGA controller
- Printing text to the screen
- Setting VESA modes automatically
- Ability to
mmap
framebuffer from userspace
- Interrupts
- IDT setup with PIC remapping
- Event-based system for handing keyboard interrupts
- Handling special keys and combinations (shift, backspace...)
- Clock config (IRQ 0)
- Memory management
- Handling page faults
- Physical memory manager
- Virtual memory manager
- Kernel heap management (
kmalloc
,kfree
) through liballoc
- Operating system
- Getting to ring 3
- Handling
syscall
- Handling
malloc
- with
brk
- also
free
- with
- Porting a libc (musl)
- Porting DOOM
- Choosing a better name for the project
Provided that XSAVE is supported by the CPU, we can enable AVX
within the kernel.
To do this, we enable the avx
CPU feature in QEMU.
However, QEMU's TCG cannot translate AVX instructions, and so they cannot be
emulated. This means that we cannot actually use AVX to vectorize kernel code. Attempting to compile the kernel
with -mavx
will result in a General Protection Fault.
On MacOS, it is possible to run the kernel with Hypervisor acceleration. However, qemu-system-x86_64
on Mac does not
allow unsigned binaries to use it.
To sign the QEMU binary, run the following command from repository root:
codesign -s - --entitlements qemu/app.entitlements --force "$(command -v qemu-system-x86_64)"
Note that the HVF in QEMU does not support SSE. Do not compile with -O3
if you want to use the hvf
target.
This target will be removed in the future, as x86_64 does need SSE2 to be present.