feature: start to implement keyboard handler and better isrs/irqs
This commit is contained in:
@ -3,8 +3,8 @@
|
||||
#include "kprintf.h"
|
||||
#include "utils.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#define NTMFDP 0
|
||||
|
||||
const char *faults[] = {
|
||||
"division by zero",
|
||||
@ -29,36 +29,29 @@ const char *faults[] = {
|
||||
"SIMD floating point exception",
|
||||
};
|
||||
|
||||
void exception_handler(void)
|
||||
static isr_t interrupt_handlers[16];
|
||||
|
||||
void isr_handler(struct registers *regs)
|
||||
{
|
||||
int8_t index = -1;
|
||||
__asm__ volatile("movb %%bl, %0" ::"m"(index));
|
||||
|
||||
if (index == -1) {
|
||||
kprintf(KERN_ERR "interrupt triggered without a code\n");
|
||||
return;
|
||||
}
|
||||
|
||||
uint8_t i = 0;
|
||||
while (i < ARRAY_SIZE(faults)) {
|
||||
if (i == index)
|
||||
if (i == regs->int_no)
|
||||
kpanic("interrupt: %s\n", faults[i]);
|
||||
i++;
|
||||
}
|
||||
kprintf(KERN_ERR "interrupt triggered with no matching code\n");
|
||||
}
|
||||
|
||||
void irq_handler(void)
|
||||
void register_interrupt_handler(int i, isr_t handler)
|
||||
{
|
||||
int8_t index = -1;
|
||||
__asm__ volatile("movb %%bl, %0" ::"m"(index));
|
||||
|
||||
pic_send_eoi(index);
|
||||
if (index == -1) {
|
||||
kprintf(KERN_ERR "interrupt triggered without a code\n");
|
||||
return;
|
||||
}
|
||||
if (index == 0)
|
||||
return;
|
||||
kpanic("%d\n", index);
|
||||
interrupt_handlers[i] = handler;
|
||||
}
|
||||
|
||||
void irq_handler(struct registers *regs)
|
||||
{
|
||||
if (regs->int_no != 0) {
|
||||
isr_t handler = interrupt_handlers[regs->int_no];
|
||||
handler(regs);
|
||||
}
|
||||
pic_send_eoi(regs->int_no);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user