Proof of concept kernel/operating-system.
This is a hobbyist project with the goal of building everything from scratch.
The entire development envoriment is contained within a docker image, including the cross compilers and emulators.
sh shell.sh
Once inside the development envorinment one can use the helper scripts to build and run project.
sh qemu.sh
To debug the kernel including bootstrap code use sh qemu-gdb.sh
which will
start the emulator and wait for a debugger to connect before executing anything.
Unfortunately gdb has an issue when the kernel switches to long mode. A patched version of gdb has been included in the tools/gdb directory or you can choose to compiler your own from here.
Docker is already forwarding the gdbserver port to the host machine, so after starting qemu in the container just run gdb on the host machine and connect it to the remote target:
(gdb) set arch i386:x86-64
(gdb) target remote localhost:1234
Controlling the QEMU emulator once its boted the kernel can be done through several key combinations.
The most important key combinations are:
Ctrl-a + x
which will close the emulatorCtrl-a + c
which will switch to the console
More key combinations here.
Once in the console you can run commands:
(qemu) info registers
(qemu) info mem
More commands here.
- Start Docker - Starts the container using
shell.sh
- Stop Docker - Stops the container
- Clean - Runs
clean.sh
from within the container - Qemu - Runs
qemu.sh
from within the contains - Qemu with GDB - Runs
qemu-gdb.sh
from with the container
You will need to install the Native Debug extension for the gdb configuration to work.
The default configuration will use the gdb binary located at
./tools/gdb/bin/x86_64-pc-linux-gnu-gdb
in order to utilize the necessary
patches.
A general workflow should be:
- Start the docker container with
shell.sh
or the VSCode task - Start Qemu with GDB inside the container with
qemu-gdb.sh
or the VSCode task - Place a breakpoint from the VSCode debug window
- Select
Attach to EQMU
from the VSCode debug window - Start stepping through code
- Phase I - Basics
- Setting up a Cross-Toolchain
- Creating a Hello World kernel
- Setting up a Project
- i386
- x86_64 - Long Mode
- Calling Global Constructors
- Terminal Support
- Stack Smash Protector
- Multiboot
- Global Descriptor Table
- Memory Management
- Interrupts
- Multithreaded Kernel
- Keyboard
- Internal Kernel Debugger
- Filesystem Support
- Phase II - User-Space
- Phase III - Extending your Operating System
- Phase IV - Bootstrapping
- Porting Software
- Porting GCC
- Compiling your OS under your OS
- Fully Self-hosting