fwsGonzo / barebones

Barebones multiboot kernel for beginners
150 stars 10 forks source link
beginner c11 cpp cpp17 osdev

Barebones multiboot kernel

Features

Running

Use ./run.sh <folder> to build and run your kernel stored in machines folder.

Changing build options

Go into the build folder in your machines folder and type ccmake .., which opens a GUI with some adjustable settings. After changing settings press C to configure the changes, and then E to exit the GUI. Changes will be rebuilt automatically using run.sh, or you could simply use make like normally in the build folder itself.

Goal

The goal is to provide a barebones kernel project that implements the most basic C/C++ voodoo to let people start reading/writing to registers and devices immediately. The goal is also to provide people with a choice of using C or C++, or a mix of both.

Future work

Validate output

./run.sh output should match:

------------------
* Multiboot EAX: 0x2badb002
* Multiboot EBX: 0x9500
* SSE instructions ... work!
* Global constructors ... work!

Hello OSdev world!
my_kernel (This is a test kernel!)

Press Ctrl+A -> X to close
Returned from kernel_start! Halting...

Common issues

Undefined sanitizer

Link-Time Optimization

Thread-Local Storage

EASTL, RTTI and exceptions

Qemu defaults

Qemu provides you with some default devices to start with

As an example, use this function to clear the VGA textmode screen:

uint16_t* vga = (uint16_t*) 0xb8000;
for (int i = 0; i < 25*80; i++)
{
  vga[i] = ' ' | (7 << 8);
}

What it's actually doing is filling the text buffer with spaces. Spaces that have a gray color. You just can't see them, because spaces are spaces.