-
Notifications
You must be signed in to change notification settings - Fork 2
/
isrs.c
117 lines (113 loc) · 3.21 KB
/
isrs.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#include <system.h>
extern void _isr0();
extern void _isr1();
extern void _isr2();
extern void _isr3();
extern void _isr4();
extern void _isr5();
extern void _isr6();
extern void _isr7();
extern void _isr8();
extern void _isr9();
extern void _isr10();
extern void _isr11();
extern void _isr12();
extern void _isr13();
extern void _isr14();
extern void _isr15();
extern void _isr16();
extern void _isr17();
extern void _isr18();
extern void _isr19();
extern void _isr20();
extern void _isr21();
extern void _isr22();
extern void _isr23();
extern void _isr24();
extern void _isr25();
extern void _isr26();
extern void _isr27();
extern void _isr28();
extern void _isr29();
extern void _isr30();
extern void _isr31();
void isrs_install()
{
idt_set_gate(0, (unsigned)_isr0, 0x08, 0x8E);
idt_set_gate(1, (unsigned)_isr1, 0x08, 0x8E);
idt_set_gate(2, (unsigned)_isr2, 0x08, 0x8E);
idt_set_gate(3, (unsigned)_isr3, 0x08, 0x8E);
idt_set_gate(4, (unsigned)_isr4, 0x08, 0x8E);
idt_set_gate(5, (unsigned)_isr5, 0x08, 0x8E);
idt_set_gate(6, (unsigned)_isr6, 0x08, 0x8E);
idt_set_gate(7, (unsigned)_isr7, 0x08, 0x8E);
idt_set_gate(8, (unsigned)_isr8, 0x08, 0x8E);
idt_set_gate(9, (unsigned)_isr9, 0x08, 0x8E);
idt_set_gate(10, (unsigned)_isr10, 0x08, 0x8E);
idt_set_gate(11, (unsigned)_isr11, 0x08, 0x8E);
idt_set_gate(12, (unsigned)_isr12, 0x08, 0x8E);
idt_set_gate(13, (unsigned)_isr13, 0x08, 0x8E);
idt_set_gate(14, (unsigned)_isr14, 0x08, 0x8E);
idt_set_gate(15, (unsigned)_isr15, 0x08, 0x8E);
idt_set_gate(16, (unsigned)_isr16, 0x08, 0x8E);
idt_set_gate(17, (unsigned)_isr17, 0x08, 0x8E);
idt_set_gate(18, (unsigned)_isr18, 0x08, 0x8E);
idt_set_gate(19, (unsigned)_isr19, 0x08, 0x8E);
idt_set_gate(20, (unsigned)_isr20, 0x08, 0x8E);
idt_set_gate(21, (unsigned)_isr21, 0x08, 0x8E);
idt_set_gate(22, (unsigned)_isr22, 0x08, 0x8E);
idt_set_gate(23, (unsigned)_isr23, 0x08, 0x8E);
idt_set_gate(24, (unsigned)_isr24, 0x08, 0x8E);
idt_set_gate(25, (unsigned)_isr25, 0x08, 0x8E);
idt_set_gate(26, (unsigned)_isr26, 0x08, 0x8E);
idt_set_gate(27, (unsigned)_isr27, 0x08, 0x8E);
idt_set_gate(28, (unsigned)_isr28, 0x08, 0x8E);
idt_set_gate(29, (unsigned)_isr29, 0x08, 0x8E);
idt_set_gate(30, (unsigned)_isr30, 0x08, 0x8E);
idt_set_gate(31, (unsigned)_isr31, 0x08, 0x8E);
}
unsigned char *exception_messages[] =
{
"Division By Zero",
"Debug",
"Non Maskable Interrupt",
"Breakpoint",
"Into Detected Overflow",
"Out of Bounds",
"Invalid Opcode",
"No Corprocessor",
"Double Fault",
"Coprocessor Segment Overrun",
"Bad TSS",
"Segment Not Present",
"Stack Fault Exception",
"General Protection Fault",
"Page Fault",
"Unknown Interrupt",
"Coprocessor Fault",
"Alignment Check",
"Machine Check",
"Reserved",
"Reserved",
"Reserved",
"Reserved",
"Reserved",
"Reserved",
"Reserved",
"Reserved",
"Reserved",
"Reserved",
"Reserved",
"Reserved",
"Reserved",
"Reserved",
};
void fault_handler(struct regs *r)
{
if (r->int_no < 32)
{
puts(exception_messages[r->int_no]);
puts(" Exception. System Halted!\n");
for (;;);
}
}