first boot

This commit is contained in:
2026-07-13 13:07:29 +10:00
commit e40059e70d
8 changed files with 307 additions and 0 deletions

18
src/kernel/kernel.cpp Normal file
View File

@@ -0,0 +1,18 @@
#include "../include/multiboot.h"
#include "vga_console.h"
typedef void(*constructor)();
extern "C" constructor start_ctors;
extern "C" constructor end_ctors;
extern "C" void callConstructors()
{
for (constructor* i = &start_ctors; i != &end_ctors; i++) {
(*i)();
}
}
extern "C" void kernelMain(multiboot_info* multibootInfo, unsigned int magicNumber) {
vgaPrint("Hello, world!");
while (true);
}

View File

@@ -0,0 +1,13 @@
#include "vga_console.h"
void vgaPrint(char* string) {
static unsigned short* vgaVideoMemory = (unsigned short*)0xb8000;
for (unsigned int i = 0; string[i] != 0; i++) {
/*
The high byte in the VGA video memory contains colour info we don't want to overwrite.
So, we have to combine the high byte with the char we're writing.
*/
vgaVideoMemory[i] = (vgaVideoMemory[i] & 0xFF00) | string[i];
}
}

3
src/kernel/vga_console.h Normal file
View File

@@ -0,0 +1,3 @@
#pragma once
void vgaPrint(char* string);