summaryrefslogtreecommitdiffstats
path: root/arch/x86_64/idt.c
diff options
context:
space:
mode:
authorJon Santmyer <jon@jonsantmyer.com>2025-09-26 13:17:41 -0400
committerJon Santmyer <jon@jonsantmyer.com>2025-09-26 13:17:41 -0400
commit2dadbfc899df4179ca70c4ea04f74a5e190c2ae7 (patch)
treeb166aaa9af42406cd07fbaf150f93aefeb2fbe33 /arch/x86_64/idt.c
parentddc4fbc15223e362896a9f42beca73f05f48e664 (diff)
downloadjove-kernel-2dadbfc899df4179ca70c4ea04f74a5e190c2ae7.tar.gz
jove-kernel-2dadbfc899df4179ca70c4ea04f74a5e190c2ae7.tar.bz2
jove-kernel-2dadbfc899df4179ca70c4ea04f74a5e190c2ae7.zip
fix usermode interrupts. add ability to define custom interrupt handlersmain
Diffstat (limited to 'arch/x86_64/idt.c')
-rw-r--r--arch/x86_64/idt.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/arch/x86_64/idt.c b/arch/x86_64/idt.c
index 1080f92..2eebf41 100644
--- a/arch/x86_64/idt.c
+++ b/arch/x86_64/idt.c
@@ -1,12 +1,20 @@
#include "arch/x86_64/tables.h"
#include "arch/x86_64/idt.h"
+#include "print.h"
__attribute__((aligned(0x10)))
-interrupt_gate_t s_idtd[256];
+static interrupt_gate_t s_idtd[256];
+
+kernel_isr_handler_t kernel_isr_handles[256];
void
isr_handle(ivt_state_t* state)
{
+ kernel_isr_handler_t kernel_handle = kernel_isr_handles[state->num];
+ if(kernel_handle) {
+ kernel_handle(state);
+ return;
+ }
kpanic_state(state, "Unhandled interrupt %i", state->num);
}
@@ -34,6 +42,8 @@ idt_setup(processor_t *processor)
processor->idtr.base = (uintptr_t)&s_idtd;
processor->idtr.length = sizeof(s_idtd) - 1;
- extern void idt_load(void* idtr);
- idt_load(&processor->idtr);
+ klogf("%X\n", s_idtd[0].type_flags);
+
+ __asm__ volatile("lidt %0":: "m"(processor->idtr));
+ __asm__ volatile("cli");
}