-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathidt_asm.s
154 lines (128 loc) · 1.9 KB
/
idt_asm.s
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
.section .text
.global load_idt
.type load_idt, @function
# void load_idt(idt_ptr_t *)
load_idt:
movl 4(%esp),%eax
lidt (%eax)
ret
.size load_idt, . - load_idt
# Macro for interrupt handler which does not push an error (we push a dummy val)
.macro isr_noerr num
.global isr\num
isr\num:
cli
push $0
push $\num
jmp isr_stub
.endm
# Macro for interrupt handler which pushes an error
.macro isr_err num
.global isr\num
isr\num:
cli
push $\num
jmp isr_stub
.endm
isr_noerr 0
isr_noerr 1
isr_noerr 2
isr_noerr 3
isr_noerr 4
isr_noerr 5
isr_noerr 6
isr_noerr 7
isr_err 8
isr_noerr 9
isr_err 10
isr_err 11
isr_err 12
isr_err 13
isr_err 14
isr_noerr 15
isr_noerr 16
isr_noerr 17
isr_noerr 18
isr_noerr 19
isr_noerr 20
isr_noerr 21
isr_noerr 22
isr_noerr 23
isr_noerr 24
isr_noerr 25
isr_noerr 26
isr_noerr 27
isr_noerr 28
isr_noerr 29
isr_noerr 30
isr_noerr 31
.extern isr_handler
isr_stub:
pusha
mov %ds, %ax
pushl %eax
movl %eax, %esi
movw $0x10, %ax
movw %ax, %ds
movw %ax, %es
movw %ax, %fs
movw %ax, %gs
call isr_handler
pop %eax
movl %esi, %eax
mov %ax, %ds
movw %ax, %ds
movw %ax, %es
movw %ax, %fs
movw %ax, %gs
popa
add $8, %esp
sti
iret
# Interrupt Request Handlers
.macro irq num, map
.global irq\num
irq\num:
cli
push $0
push $\map
jmp irq_stub
.endm
irq 0, 32
irq 1, 33
irq 2, 34
irq 3, 35
irq 4, 36
irq 5, 37
irq 6, 38
irq 7, 39
irq 8, 40
irq 9, 41
irq 10, 42
irq 11, 43
irq 12, 44
irq 13, 45
irq 14, 46
irq 15, 47
.extern irq_handler
irq_stub:
pusha
mov %ds, %ax
pushl %eax
movl %eax, %esi
movw $0x10, %ax
movw %ax, %ds
movw %ax, %es
movw %ax, %fs
movw %ax, %gs
call irq_handler
pop %ebx
movl %esi, %ebx
movw %bx, %ds
movw %bx, %es
movw %bx, %fs
movw %bx, %gs
popa
add $8, %esp
sti
iret