-
Notifications
You must be signed in to change notification settings - Fork 0
/
isr.c
52 lines (46 loc) · 1.26 KB
/
isr.c
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
48
49
50
51
52
//
// isr.c -- Handle level interrupt service routines and interrupt request handlers.
// Code from JamesM's kernel developement tutorials
//
#include "common.h"
#include "isr.h"
#include "monitor.h"
isr_t interrupt_handlers[256];
// This gets called from our ASM interrupt handler stub.
void isr_handler(registers_t regs)
{
if(interrupt_handlers[regs.int_no] != 0)
{
isr_t handler = interrupt_handlers[regs.int_no];
handler(regs);
}
else
{
monitor_write("recieved interrupt: ");
monitor_write_dec(regs.int_no);
monitor_put('\n');
}
}
// This gets called from our ASM interrupt handler stub.
void register_interrupt_handler(u8int n, isr_t handler)
{
interrupt_handlers[n] = handler;
}
// This gets called from our ASM interrupt handler stub.
void irq_handler(registers_t regs)
{
// Send an EOI (end of interrupt) signal to the PICs.
// If this interrupt involved the slave.
if(regs.int_no >= 40)
{
// Send the reset signal to slave.
outb(0xA0, 0x20);
}
// Send reset signal to master. (As well as slave, if necessary).
outb(0x20, 0x20);
if(interrupt_handlers[regs.int_no] != 0)
{
isr_t handler = interrupt_handlers[regs.int_no];
handler(regs);
}
}