-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathirq.c
More file actions
48 lines (42 loc) · 1.18 KB
/
irq.c
File metadata and controls
48 lines (42 loc) · 1.18 KB
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
37
38
39
40
41
42
43
44
45
46
47
#include "irq.h"
#include "idt.h"
#include "asmintr.h"
void (*irq_handlers[16])(int irq);
void irq_common_handler(int inum) {
if(irq_handlers[inum - 32]) {
irq_handlers[inum - 32](inum - 32);
}
if(inum > 40)
outb(0xA0, 0x20);
outb(0x20, 0x20);
}
void install_irq(void *handler, int gate) {
irq_handlers[gate] = handler;
}
void init_irq() {
outb(0x20, 0x11);
outb(0xA0, 0x11);
outb(0x21, 0x20);
outb(0xA1, 0x28);
outb(0x21, 0x04);
outb(0xA1, 0x02);
outb(0x21, 0x01);
outb(0xA1, 0x01);
outb(0x21, 0x0);
outb(0xA1, 0x0);
install_handler(irq_common_handler, 32);
install_handler(irq_common_handler, 33);
install_handler(irq_common_handler, 34);
install_handler(irq_common_handler, 35);
install_handler(irq_common_handler, 36);
install_handler(irq_common_handler, 37);
install_handler(irq_common_handler, 38);
install_handler(irq_common_handler, 39);
install_handler(irq_common_handler, 40);
install_handler(irq_common_handler, 41);
install_handler(irq_common_handler, 42);
install_handler(irq_common_handler, 43);
install_handler(irq_common_handler, 44);
install_handler(irq_common_handler, 45);
install_handler(irq_common_handler, 46);
}