-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathirq.S
375 lines (329 loc) · 5.47 KB
/
irq.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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
.global _de_irq_handler
.global _nmi_irq_handler
.global _db_irq_handler
.global _bp_irq_handler
.global _of_irq_handler
.global _br_irq_handler
.global _ud_irq_handler
.global _nm_irq_handler
.global _df_irq_handler
.global _ts_irq_handler
.global _np_irq_handler
.global _ss_irq_handler
.global _gp_irq_handler
.global _pf_irq_handler
.global _40h_irq_handler
.global _41h_irq_handler
.global _42h_irq_handler
.global _43h_irq_handler
.global _44h_irq_handler
.global _45h_irq_handler
.global _46h_irq_handler
.global _47h_irq_handler
.global _48h_irq_handler
.global _49h_irq_handler
.global _4ah_irq_handler
.global _4bh_irq_handler
.global _4ch_irq_handler
.global _4dh_irq_handler
.global _4eh_irq_handler
.global _4fh_irq_handler
.global _50h_irq_handler
.global _51h_irq_handler
.global _52h_irq_handler
.global _53h_irq_handler
.global _54h_irq_handler
.global _55h_irq_handler
.global _56h_irq_handler
.global _57h_irq_handler
.global _timer_irq_handler
.global _spurious_irq_handler
.global _syscall_irq_handler
.global _default_irq_handler
.global irq_handler
.global return_from_syscall
.global _interrupt_stack_bottom
.global schedule
# context from %rdi
return_from_syscall:
mov %rdi, %rsp
pop %rax
mov %ax, %ds
pop %rax
mov %ax, %es
pop %rax
mov %ax, %fs
pop %rax
mov %ax, %gs
pop %rax
mov %rax, %cr3
pop %r15
pop %r14
pop %r13
pop %r12
pop %r11
pop %r10
pop %r9
pop %r8
pop %rbp
pop %rsi
pop %rdi
pop %rbx
pop %rdx
pop %rcx
pop %rax
add $16, %rsp
iretq
_irq_handler:
push %rax
push %rcx
push %rdx
push %rbx
push %rdi
push %rsi
push %rbp
push %r8
push %r9
push %r10
push %r11
push %r12
push %r13
push %r14
push %r15
mov %cr3, %rax
push %rax
xor %rax, %rax
mov %gs, %ax
push %rax
mov %fs, %ax
push %rax
mov %es, %ax
push %rax
mov %ds, %ax
push %rax
movq %rsp, %rdi
call store_current_thread_context
movq 160(%rsp), %rdi
movq 168(%rsp), %rsi
call irq_handler
call schedule
call current_context
mov %rax, %rdi
jmp return_from_syscall
# divide by 0
_de_irq_handler:
pushq $0
pushq $0
jmp _irq_handler
iretq
# debugger
_db_irq_handler:
pushq $0
pushq $1
jmp _irq_handler
iretq
# NMI
_nmi_irq_handler:
pushq $0
pushq $2
jmp _irq_handler
iretq
# breakpoint
_bp_irq_handler:
pushq $0
pushq $3
jmp _irq_handler
iretq
# overflow
_of_irq_handler:
pushq $0
pushq $4
jmp _irq_handler
iretq
# bound-range
_br_irq_handler:
pushq $0
pushq $5
jmp _irq_handler
iretq
# invalid opcode
_ud_irq_handler:
pushq $0
pushq $6
jmp _irq_handler
iretq
# device not available
_nm_irq_handler:
pushq $0
pushq $7
jmp _irq_handler
iretq
# double fault
_df_irq_handler:
pushq $8
jmp _irq_handler
iretq
# invalid tss
_ts_irq_handler:
pushq $10
jmp _irq_handler
iretq
# segment not present
_np_irq_handler:
pushq $11
jmp _irq_handler
iretq
# stack exception
_ss_irq_handler:
pushq $12
jmp _irq_handler
iretq
# general protection
_gp_irq_handler:
pushq $13
jmp _irq_handler
iretq
# page fault
_pf_irq_handler:
pushq $14
jmp _irq_handler
iretq
_timer_irq_handler:
pushq $0
pushq $32
jmp _irq_handler
iretq
_spurious_irq_handler:
pushq $0
pushq $37
jmp _irq_handler
iretq
_syscall_irq_handler:
pushq $0
pushq $42
jmp _irq_handler
iretq
_40h_irq_handler:
pushq $0
pushq $0x40
jmp _irq_handler
iretq
_41h_irq_handler:
pushq $0
pushq $0x41
jmp _irq_handler
iretq
_42h_irq_handler:
pushq $0
pushq $0x42
jmp _irq_handler
iretq
_43h_irq_handler:
pushq $0
pushq $0x43
jmp _irq_handler
iretq
_44h_irq_handler:
pushq $0
pushq $0x44
jmp _irq_handler
iretq
_45h_irq_handler:
pushq $0
pushq $0x45
jmp _irq_handler
iretq
_46h_irq_handler:
pushq $0
pushq $0x46
jmp _irq_handler
iretq
_47h_irq_handler:
pushq $0
pushq $0x47
jmp _irq_handler
iretq
_48h_irq_handler:
pushq $0
pushq $0x48
jmp _irq_handler
iretq
_49h_irq_handler:
pushq $0
pushq $0x49
jmp _irq_handler
iretq
_4ah_irq_handler:
pushq $0
pushq $0x4a
jmp _irq_handler
iretq
_4bh_irq_handler:
pushq $0
pushq $0x4b
jmp _irq_handler
iretq
_4ch_irq_handler:
pushq $0
pushq $0x4c
jmp _irq_handler
iretq
_4dh_irq_handler:
pushq $0
pushq $0x4d
jmp _irq_handler
iretq
_4eh_irq_handler:
pushq $0
pushq $0x4e
jmp _irq_handler
iretq
_4fh_irq_handler:
pushq $0
pushq $0x4f
jmp _irq_handler
iretq
_50h_irq_handler:
pushq $0
pushq $0x50
jmp _irq_handler
iretq
_51h_irq_handler:
pushq $0
pushq $0x51
jmp _irq_handler
iretq
_52h_irq_handler:
pushq $0
pushq $0x52
jmp _irq_handler
iretq
_53h_irq_handler:
pushq $0
pushq $0x53
jmp _irq_handler
iretq
_54h_irq_handler:
pushq $0
pushq $0x54
jmp _irq_handler
iretq
_55h_irq_handler:
pushq $0
pushq $0x55
jmp _irq_handler
iretq
_56h_irq_handler:
pushq $0
pushq $0x56
jmp _irq_handler
iretq
_57h_irq_handler:
pushq $0
pushq $0x57
jmp _irq_handler
iretq
_default_irq_handler:
pushq $-1
pushq $0xff
jmp _irq_handler