doing some memory work and gdt and timer and vga

This commit is contained in:
2025-05-13 11:39:16 -07:00
parent 10b8fdc33f
commit 799f744f47
14 changed files with 273 additions and 21 deletions

View File

@@ -1,21 +1,34 @@
#include "terminal.h"
#include "serial.h"
#include "isr.h"
static isr_callback_t interrupt_handlers[MAX_INTERRUPTS] = { 0 };
void isr_handler(uint32_t int_num, uint32_t err_code) {
terminal_write("Interrupt occurred: ");
// Add simple int-to-string printing here
// Here you can add a basic itoa to print int_num
serial_write("INT triggered\n");
if (int_num == 0) {
terminal_write(" -> Divide by zero error!\n");
} else if (int_num == 13) {
terminal_write(" -> General Protection Fault!\n");
if (interrupt_handlers[int_num]) {
interrupt_handlers[int_num](); // Call registered handler
} else {
terminal_write(" -> Unknown interrupt\n");
}
terminal_write(" -> No handler registered\n");
// Halt CPU
while (1) {
asm volatile ("hlt");
if (int_num == 0) {
terminal_write(" -> Divide by zero error!\n");
} else if (int_num == 13) {
terminal_write(" -> General Protection Fault!\n");
} else {
terminal_write(" -> Unknown interrupt\n");
}
// Halt CPU
while (1) {
asm volatile ("hlt");
}
}
}
void register_interrupt_handler(uint8_t n, isr_callback_t handler) {
interrupt_handlers[n] = handler;
}