summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'kernel')
-rw-r--r--kernel/cpu/idt.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/kernel/cpu/idt.c b/kernel/cpu/idt.c
index bf4b499..8bddc21 100644
--- a/kernel/cpu/idt.c
+++ b/kernel/cpu/idt.c
@@ -3,6 +3,7 @@
#include <comus/asm.h>
#include <comus/cpu.h>
#include <comus/drivers/pit.h>
+#include <comus/memory.h>
#include "idt.h"
#include "pic.h"
@@ -66,6 +67,9 @@ void idt_init(void)
entry->isr_mid = (isr >> 16) & 0xffff;
entry->isr_high = (isr >> 32) & 0xffffffff;
entry->reserved = 0;
+
+ if (vector == 0x80)
+ entry->flags |= RING3;
}
__asm__ volatile("lidt %0" : : "m"(idtr));
@@ -116,6 +120,9 @@ void idt_exception_handler(uint64_t exception, uint64_t code,
{
uint64_t cr2;
+ // make sure were in the kernel memory context
+ mem_ctx_switch(kernel_mem_ctx);
+
switch (exception) {
case EX_PAGE_FAULT:
// page faults store the offending address in cr2