Skip to content

Rafisto/sys

Folders and files

NameName
Last commit message
Last commit date

Latest commit

1a6ea1e · Feb 21, 2025

History

15 Commits
Feb 21, 2025
Feb 21, 2025
Feb 11, 2025
Feb 21, 2025
Feb 11, 2025
Feb 11, 2025
Feb 21, 2025

Repository files navigation

Table of Contents

Framebuffer

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.

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.

Command Line Interface

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.

Command Line Interface

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.

Keyboard on Interrupts

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.

Keyboard 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

VGA Rainbow is a small bare-metal program created to display Hello World! in all colors provided by VGA text mode.

VGA Rainbow Showcase GIF

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.

Tricks

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