Setup simple kernel with Hello World output via debugcon (AI)

This commit is contained in:
AI
2026-02-23 08:24:50 +00:00
parent 34382babb3
commit a048764a3d
6 changed files with 101 additions and 6 deletions

View File

@@ -1,3 +1,31 @@
void _start() {
while(1) {}
#include <multiboot2.h>
#include <stdint.h>
#include <stddef.h>
static inline void outb(uint16_t port, uint8_t val)
{
asm volatile ( "outb %b0, %w1" : : "a"(val), "Nd"(port) );
}
void offset_print(const char *str)
{
while (*str) {
outb(0xE9, *str);
str++;
}
}
#define MULTIBOOT_BOOTLOADER_MAGIC 0x2BADB002
void kernel_main(uint32_t magic, uint32_t addr) {
(void)addr; // Unused for now
if (magic != MULTIBOOT2_BOOTLOADER_MAGIC && magic != MULTIBOOT_BOOTLOADER_MAGIC) {
offset_print("Invalid magic number: ");
// I don't have hex print yet, but I can print something generic
offset_print("Unknown\n");
return;
}
offset_print("Hello, world\n");
}