-
Notifications
You must be signed in to change notification settings - Fork 5
/
c_traps.c
68 lines (58 loc) · 1.15 KB
/
c_traps.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
#include "plat.h"
#include "print.h"
char *exception_messages[] =
{
"Division By Zero",
"Debug",
"Non Maskable Interrupt",
"Breakpoint",
"Into Detected Overflow",
"Out of Bounds",
"Invalid Opcode",
"No Coprocessor",
"Double Fault",
"Coprocessor Segment Overrun",
"Bad TSS",
"Segment Not Present",
"Stack Fault",
"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"
};
void handle_exception(uint32_t vector)
{
print("Exception raised: ");
print(exception_messages[vector]);
x86_halt();
}
void handle_unknown(void){
handle_exception(16);
}
void x86_exception_handler(x86_iframe_t* iframe){
uint32_t vector = iframe->vector;
if(31 >= vector){
handle_exception(vector);
}
else if(47 >= vector){
handle_platform_irq(iframe);
}
else{
handle_unknown();
}
}