Table of Contents
- Framebuffer - Rotating a cube using framebuffer set in the bootloader.
- Command Line Interface - CLI with a few commands to interact with the system.
- Keyboard on Interrupts - Keyboard controller on x86 with GDT, IDT and IRQ.
- VGA Rainbow - Display Hello World! in all colors provided by VGA text mode.
I configured the framebuffer in GRUB and have managed to request its address using Multiboot2 headers. I also enabled the FPU and SSE instructions to be used in the program. The framebuffer is then used to show a rotating pink cube.
Having no stdlib I wrote a few alogrithms, sin
, cos
using Taylor series approximation and line drawing using Bresenham's algorithm. The cube is drawn using 8 vertices and 12 edges. It is then rotated along each axis.
CLI presents a few commands to interact with the system. It allows for specifying up to 16 arguments for each command. Just by adding a new function to the commands.c
and updating the commands.h
file you can add a new command.
void sum_command(int argc, char** argv) {
int sum = 0;
for (int i = 1; i < argc; i++) {
sum += atoi(argv[i]);
}
write_format("%d\n", sum);
}
I also added simple kalloc()
and set up paging to be used later for dynamic memory allocation.
KBD is a continuation of my bare-metal journey. Thanks to this stackoverflow answer I was able to successfully recreate a keyboard controller on interrupts.
Most of the program is done in boot.asm, where I initialize GDT, and in idt.h, where I use the interrupt controller. A little dependency injection was made in the console.c
, as the console_input()
is actually passed as a function to be called after a key is pressed.
VGA Rainbow is a small bare-metal program created to display Hello World! in all colors provided by VGA text mode.
This is an exetension of hello-os
project, I added a simple virtual screen and keyboard controller which can be further extended to create more complex programs.
You can debug the kernel using QEMU and GDB. Remember to compile the kernel with debug symbols.
make qemu-gdb
gdb -ex "target remote localhost:1234" -ex "symbol-file _build/kernel.elf"
In order to run the kernel on a real machine, you can create a bootable USB stick.
sudo dd if=_build/hello.iso of=/dev/sdb bs=1MB
sync