blob: afb11495a0a5a7d32f5606d7503bf6c010648474 (
plain)
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
118
119
120
121
122
123
124
125
126
127
128
|
extern idt_exception_handler
global isr_stub_table
%macro PUSHALL 0
push rbx
push rcx
push rdx
push rsi
push rdi
push r8
push r9
push r10
push r11
push r12
push r13
push r14
push r15
%endmacro
%macro POPALL 0
pop r15
pop r14
pop r13
pop r12
pop r11
pop r10
pop r9
pop r8
pop rdi
pop rsi
pop rdx
pop rcx
pop rbx
%endmacro
; call the exception handler with the interrupt number
; args: interrupt number
%macro ISRException 1
align 8
isr_stub_%+%1:
PUSHALL
cld
mov rdi, %1
mov rsi, 0
call idt_exception_handler
POPALL
iretq
%endmacro
; call the exception handler with the interrupt number
; these exceptions also put an error code on the stack
; args: interrupt number
%macro ISRExceptionCode 1
align 8
isr_stub_%+%1:
PUSHALL
cld
mov rdi, %1
pop rsi
call idt_exception_handler
POPALL
iretq
%endmacro
; do nothing
; args: interrupt number
%macro ISRIgnore 1
align 8
isr_stub_%+%1:
iretq
%endmacro
; isr stubs
section .text
bits 64
ISRException 0
ISRException 1
ISRException 2
ISRException 3
ISRException 4
ISRException 5
ISRException 6
ISRException 7
ISRExceptionCode 8
ISRException 9
ISRExceptionCode 10
ISRExceptionCode 11
ISRExceptionCode 12
ISRExceptionCode 13
ISRExceptionCode 14
ISRException 15
ISRException 16
ISRExceptionCode 17
ISRException 18
ISRException 19
ISRException 20
ISRExceptionCode 21
ISRException 22
ISRException 23
ISRException 24
ISRException 25
ISRException 26
ISRException 27
ISRException 28
ISRExceptionCode 29
ISRExceptionCode 30
ISRException 31
%assign i 32
; ignore other interrupts
%rep 0x100 - i
ISRIgnore i
%assign i i+1
%endrep
; isr stub table
section .rodata
bits 64
align 16
isr_stub_table:
%assign i 0
%rep 256
dq isr_stub_%+i
%assign i i+1
%endrep
|