Interrupt Dispatch and Handling (for first common vectors)

This commit is contained in:
2025-12-22 21:04:45 +01:00
parent d0b4da0596
commit 42fc169e10
6 changed files with 30 additions and 4 deletions

View File

@@ -6,6 +6,7 @@
#include "io/serial.h"
#include "mem/gdt.h"
#include "mem/utils.h"
#include "idt/idt.h"
// Limine version used
__attribute__((used, section(".limine_requests")))
@@ -35,6 +36,20 @@ static void hcf()
}
}
static inline void trigger_div0(void)
{
asm volatile (
"mov $1, %%rax\n"
"xor %%rdx, %%rdx\n"
"xor %%rcx, %%rcx\n" // divisor = 0
"idiv %%rcx\n"
:
:
: "rax", "rcx", "rdx"
);
}
// This is our entry point
void kmain()
{
@@ -47,14 +62,13 @@ void kmain()
if (term_init()) hcf();
if (serial_init()) kputs("kernel: serial: error: Cannot init serial communication!");
serial_kputs("\n\nkernel: serial: Hello, world from serial!\n");
gdt_init();
serial_kputs("kernel: gdt: Initialized GDT!");
idt_init();
// Draw something
printf("%s, %s!", "Hello", "world");
trigger_div0();
hcf();
}