Nucleus
Barry Global Descriptor Tables b9a1b73 (3 years, 3 months ago)
diff --git a/kernel/idt.c b/kernel/idt.c
index 4c594bb..85f64c6 100644
--- a/kernel/idt.c
+++ b/kernel/idt.c
@@ -9,8 +9,9 @@
#include <string.h>
#include <nucleus/panic.h>
#include <nucleus/memory.h>
+#include <nucleus/cpu.h>
#include <io.h>
-#include "idt.h"
+#include "desc.h"
/* Structure for an IDT Entry */
static struct IDTEntry {
@@ -37,6 +38,11 @@ install_idt_entry(uint8_t num, void *addr)
static void
exc_handler(int num, struct InterruptFrame *frame, uint32_t err)
{
+ if (!exceptions[num]) {
+ panic("Failed to handle exception %d (%#.8x)",
+ num, err);
+ }
+
ASSERT(exceptions[num]);
exceptions[num](frame, err);
@@ -350,3 +356,14 @@ init_idt(void)
interrupts = (void *) (exceptions + 32);
memset(exceptions, 0, 1024);
}
+
+/* Load the IDT */
+void
+cpu_load_idt(void)
+{
+ struct DescRecord ptr = {
+ .limit = sizeof(struct IDTEntry) * 256,
+ .base = (uintptr_t) IDT,
+ };
+ asm volatile("lidt %0" :: "m" (ptr));
+}