summaryrefslogtreecommitdiff
path: root/kernel/core/interrupt.c
diff options
context:
space:
mode:
authorDanny Holman <dholman@gymli.org>2025-01-12 01:17:36 -0600
committerDanny Holman <dholman@gymli.org>2025-01-12 01:19:11 -0600
commit95cd78840f0891e60f5ebecc8a8eb4fbaf3c2ebf (patch)
treec8c35347b50477929727fa5be9f5d0f55cbe18fd /kernel/core/interrupt.c
parent5e166f3042a8e7b3031aae4da7006f80caa53ecc (diff)
PROJECT RESTRUCTURING
Move the entire kernel into its own directory. Create new directories for system commands, libraries and other required essentials for a complete Unix-like operating system. Signed-off-by: Danny Holman <dholman@gymli.org>
Diffstat (limited to 'kernel/core/interrupt.c')
-rw-r--r--kernel/core/interrupt.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/kernel/core/interrupt.c b/kernel/core/interrupt.c
new file mode 100644
index 0000000..6d9e69d
--- /dev/null
+++ b/kernel/core/interrupt.c
@@ -0,0 +1,21 @@
+#include <kernel/interrupt.h>
+#include <kernel/panic.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);
+}