summaryrefslogtreecommitdiff
path: root/kernel/syscalls/install_irq.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/syscalls/install_irq.c')
-rw-r--r--kernel/syscalls/install_irq.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/kernel/syscalls/install_irq.c b/kernel/syscalls/install_irq.c
new file mode 100644
index 0000000..c50c6e0
--- /dev/null
+++ b/kernel/syscalls/install_irq.c
@@ -0,0 +1,26 @@
+#include <sched/scheduler.h>
+#include <syscalls.h>
+
+process_t *tmp;
+void *handler;
+
+void jump_signal_handler(void *func, u32 esp);
+
+void test_handler(reg_t *regs) {
+ kprintf("IRQ FIRED\n");
+ kprintf("handler: %x\n", handler);
+ tmp->interrupt_handler = handler;
+ signal_t sig;
+ sig.handler_ip = (uintptr_t)handler;
+ process_push_signal(tmp, sig);
+ return;
+}
+
+int syscall_install_irq(void (*irq_handler)(), u8 irq) {
+ // TODO: This should be able to fail if the handler is already set
+ tmp = get_current_task();
+ handler = irq_handler;
+ kprintf("IRQ INSTALLED\n");
+ install_handler(test_handler, INT_32_INTERRUPT_GATE(0x0), 0x20 + irq);
+ return 1;
+}