first boot
This commit is contained in:
18
src/kernel/kernel.cpp
Normal file
18
src/kernel/kernel.cpp
Normal 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);
|
||||
}
|
||||
13
src/kernel/vga_console.cpp
Normal file
13
src/kernel/vga_console.cpp
Normal 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
3
src/kernel/vga_console.h
Normal file
@@ -0,0 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
void vgaPrint(char* string);
|
||||
Reference in New Issue
Block a user