summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'kernel')
-rw-r--r--kernel/interrupt.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/kernel/interrupt.c b/kernel/interrupt.c
new file mode 100644
index 0000000..9639aea
--- /dev/null
+++ b/kernel/interrupt.c
@@ -0,0 +1,20 @@
+#include <kernel/interrupt.h>
+#include <kernel/asm.h>
+
+static void (*isr_handlers[MAX_ISR])(struct isr_frame *frame);
+
+void register_isr_handler(unsigned int isr, void (*handler)(struct isr_frame *frame)) {
+ if (isr > MAX_ISR)
+ panic("Attempted to set non-existant interrupt vector");
+ isr_handlers[isr] = handler;
+}
+
+void clear_isr_handler(unsigned int isr) {
+ if (isr > MAX_ISR)
+ panic("Attempted to clear non-existant interrupt vector");
+ isr_handlers[isr] = NULL;
+}
+
+void isr_dispatch(struct isr_frame frame) {
+ (*isr_handlers[frame.isr_vector])(&frame);
+}