-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathisr.c
More file actions
36 lines (28 loc) · 690 Bytes
/
isr.c
File metadata and controls
36 lines (28 loc) · 690 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include "isr.h"
typedef void (*isr_t)(registers_t); void register_interrupt_handler(unsigned char n, isr_t handler);
isr_t interrupt_handlers[256];
void register_interrupt_handler(unsigned char n, isr_t handler)
{
puts("Inserting Handler");
interrupt_handlers[n] = handler;
puts("Handler inserted");
}
void isr_handler(registers_t regs)
{
puts("recieved interrupt: ");
putdec(regs.int_no);
putch('\n');
}
void irq_handler(registers_t regs)
{
if (regs.int_no >= 40)
{
outportb(0xA0, 0x20);
}
outportb(0x20, 0x20);
if (interrupt_handlers[regs.int_no] != 0)
{
isr_t handler = interrupt_handlers[regs.int_no];
handler(regs);
}
}