From 474ba91122aa4b32fdd9348d90aec7468b3d2b8a Mon Sep 17 00:00:00 2001 From: Franklin Wei Date: Sun, 1 Feb 2015 21:35:36 -0500 Subject: a lotta changes, crashes on STI --- kernel/isr.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'kernel/isr.c') diff --git a/kernel/isr.c b/kernel/isr.c index 424bd22..a4627d0 100644 --- a/kernel/isr.c +++ b/kernel/isr.c @@ -1,17 +1,31 @@ +#include #include #include "isr.h" #include "idt.h" +#include "panic.h" -void isr_handle(struct regs_t *regs) +void (*int_callbacks[256])(struct regs_t) = { NULL }; + +void set_interrupt_handler(uint8_t n, void (*callback)(struct regs_t)) +{ + int_callbacks[n] = callback; +} + +void isr_handler(struct regs_t regs) { - if(regs->int_no < 32) + if(int_callbacks[regs.int_no]) + { + int_callbacks[regs.int_no](regs); + } + else { - panic("received exception!\n"); + printf("WARNING: unhandled ISR"); } } void isr_init(void) { + printf("ISR handlers installed.\n"); idt_set_gate(0, (uint32_t)_isr0, 0x08, 0x8E); idt_set_gate(1, (uint32_t)_isr1, 0x08, 0x8E); idt_set_gate(2, (uint32_t)_isr2, 0x08, 0x8E); -- cgit v1.1