2e6318b9c55ebbe0d34d31ba5bdd5ad31b17f767
[reactos.git] / reactos / ntoskrnl / ke / i386 / irqhand.s
1 #include <ndk/i386/segment.h>
2 #include <../hal/halx86/include/halirq.h>
3
4 #ifdef CONFIG_SMP
5
6 #define BUILD_INTERRUPT_HANDLER(intnum) \
7 .global _KiUnexpectedInterrupt##intnum; \
8 _KiUnexpectedInterrupt##intnum:; \
9 pusha; \
10 movl $0x##intnum, %ebx; \
11 jmp _KiCommonInterrupt;
12
13 /* Interrupt handlers and declarations */
14
15 #define B(x,y) \
16 BUILD_INTERRUPT_HANDLER(x##y)
17
18 #define B16(x) \
19 B(x,0) B(x,1) B(x,2) B(x,3) \
20 B(x,4) B(x,5) B(x,6) B(x,7) \
21 B(x,8) B(x,9) B(x,A) B(x,B) \
22 B(x,C) B(x,D) B(x,E) B(x,F)
23
24 _KiCommonInterrupt:
25 cld
26 pushl %ds
27 pushl %es
28 pushl %fs
29 pushl %gs
30 movl $0xceafbeef,%eax
31 pushl %eax
32 movl $KERNEL_DS,%eax
33 movl %eax,%ds
34 movl %eax,%es
35 movl %eax,%gs
36 movl $PCR_SELECTOR,%eax
37 movl %eax,%fs
38 pushl %esp
39 pushl %ebx
40 call _KiInterruptDispatch
41 addl $0xC, %esp
42 popl %gs
43 popl %fs
44 popl %es
45 popl %ds
46 popa
47 iret
48
49 B16(3) B16(4) B16(5) B16(6)
50 B16(7) B16(8) B16(9) B16(A)
51 B16(B) B16(C) B16(D) B16(E)
52 B16(F)
53
54 #undef B
55 #undef B16
56
57 #else /* CONFIG_SMP */
58
59 .global _irq_handler_0
60 _irq_handler_0:
61 cld
62 pusha
63 pushl %ds
64 pushl %es
65 pushl %fs
66 pushl %gs
67 movl $0xceafbeef,%eax
68 pushl %eax
69 movw $KERNEL_DS,%ax
70 movw %ax,%ds
71 movw %ax,%es
72 movw %ax,%gs
73 movl $PCR_SELECTOR, %eax
74 movl %eax, %fs
75 pushl %esp
76 pushl $(IRQ_BASE + 0)
77 call _KiInterruptDispatch
78 addl $0xC, %esp
79 popl %gs
80 popl %fs
81 popl %es
82 popl %ds
83 popa
84 iret
85
86 .global _irq_handler_1
87 _irq_handler_1:
88 cld
89 pusha
90 pushl %ds
91 pushl %es
92 pushl %fs
93 pushl %gs
94 movl $0xceafbeef,%eax
95 pushl %eax
96 movw $KERNEL_DS,%ax
97 movw %ax,%ds
98 movw %ax,%es
99 movw %ax,%gs
100 movl $PCR_SELECTOR, %eax
101 movl %eax, %fs
102 pushl %esp
103 pushl $(IRQ_BASE + 1)
104 call _KiInterruptDispatch
105 addl $0xC, %esp
106 popl %gs
107 popl %fs
108 popl %es
109 popl %ds
110 popa
111 iret
112
113 .global _irq_handler_2
114 _irq_handler_2:
115 cld
116 pusha
117 pushl %ds
118 pushl %es
119 pushl %fs
120 pushl %gs
121 movl $0xceafbeef,%eax
122 pushl %eax
123 movw $KERNEL_DS,%ax
124 movw %ax,%ds
125 movw %ax,%es
126 movw %ax,%gs
127 movl $PCR_SELECTOR, %eax
128 movl %eax, %fs
129 pushl %esp
130 pushl $(IRQ_BASE + 2)
131 call _KiInterruptDispatch
132 addl $0xC, %esp
133 popl %gs
134 popl %fs
135 popl %es
136 popl %ds
137 popa
138 iret
139
140 .global _irq_handler_3
141 _irq_handler_3:
142 cld
143 pusha
144 pushl %ds
145 pushl %es
146 pushl %fs
147 pushl %gs
148 movl $0xceafbeef,%eax
149 pushl %eax
150 movw $KERNEL_DS,%ax
151 movw %ax,%ds
152 movw %ax,%es
153 movw %ax,%gs
154 movl $PCR_SELECTOR, %eax
155 movl %eax, %fs
156 pushl %esp
157 pushl $(IRQ_BASE + 3)
158 call _KiInterruptDispatch
159 addl $0xC, %esp
160 popl %gs
161 popl %fs
162 popl %es
163 popl %ds
164 popa
165 iret
166
167 .global _irq_handler_4
168 _irq_handler_4:
169 cld
170 pusha
171 pushl %ds
172 pushl %es
173 pushl %fs
174 pushl %gs
175 movl $0xceafbeef,%eax
176 pushl %eax
177 movw $KERNEL_DS,%ax
178 movw %ax,%ds
179 movw %ax,%es
180 movw %ax,%gs
181 movl $PCR_SELECTOR, %eax
182 movl %eax, %fs
183 pushl %esp
184 pushl $(IRQ_BASE + 4)
185 call _KiInterruptDispatch
186 addl $0xC, %esp
187 popl %gs
188 popl %fs
189 popl %es
190 popl %ds
191 popa
192 iret
193
194 .global _irq_handler_5
195 _irq_handler_5:
196 cld
197 pusha
198 pushl %ds
199 pushl %es
200 pushl %fs
201 pushl %gs
202 movl $0xceafbeef,%eax
203 pushl %eax
204 movw $KERNEL_DS,%ax
205 movw %ax,%ds
206 movw %ax,%es
207 movw %ax,%gs
208 movl $PCR_SELECTOR, %eax
209 movl %eax, %fs
210 pushl %esp
211 pushl $(IRQ_BASE + 5)
212 call _KiInterruptDispatch
213 addl $0xC, %esp
214 popl %gs
215 popl %fs
216 popl %es
217 popl %ds
218 popa
219 iret
220
221 .global _irq_handler_6
222 _irq_handler_6:
223 cld
224 pusha
225 pushl %ds
226 pushl %es
227 pushl %fs
228 pushl %gs
229 movl $0xceafbeef,%eax
230 pushl %eax
231 movw $KERNEL_DS,%ax
232 movw %ax,%ds
233 movw %ax,%es
234 movw %ax,%gs
235 movl $PCR_SELECTOR, %eax
236 movl %eax, %fs
237 pushl %esp
238 pushl $(IRQ_BASE + 6)
239 call _KiInterruptDispatch
240 addl $0xC, %esp
241 popl %gs
242 popl %fs
243 popl %es
244 popl %ds
245 popa
246 iret
247
248 .global _irq_handler_7
249 _irq_handler_7:
250 cld
251 pusha
252 pushl %ds
253 pushl %es
254 pushl %fs
255 pushl %gs
256 movl $0xceafbeef,%eax
257 pushl %eax
258 movw $KERNEL_DS,%ax
259 movw %ax,%ds
260 movw %ax,%es
261 movw %ax,%gs
262 movl $PCR_SELECTOR, %eax
263 movl %eax, %fs
264 pushl %esp
265 pushl $(IRQ_BASE + 7)
266 call _KiInterruptDispatch
267 addl $0xC, %esp
268 popl %gs
269 popl %fs
270 popl %es
271 popl %ds
272 popa
273 iret
274
275 .global _irq_handler_8
276 _irq_handler_8:
277 cld
278 pusha
279 pushl %ds
280 pushl %es
281 pushl %fs
282 pushl %gs
283 movl $0xceafbeef,%eax
284 pushl %eax
285 movw $KERNEL_DS,%ax
286 movw %ax,%ds
287 movw %ax,%es
288 movw %ax,%gs
289 movl $PCR_SELECTOR, %eax
290 movl %eax, %fs
291 pushl %esp
292 pushl $(IRQ_BASE + 8)
293 call _KiInterruptDispatch
294 addl $0xC, %esp
295 popl %gs
296 popl %fs
297 popl %es
298 popl %ds
299 popa
300 iret
301
302 .global _irq_handler_9
303 _irq_handler_9:
304 cld
305 pusha
306 pushl %ds
307 pushl %es
308 pushl %fs
309 pushl %gs
310 movl $0xceafbeef,%eax
311 pushl %eax
312 movw $KERNEL_DS,%ax
313 movw %ax,%ds
314 movw %ax,%es
315 movw %ax,%gs
316 movl $PCR_SELECTOR, %eax
317 movl %eax, %fs
318 pushl %esp
319 pushl $(IRQ_BASE + 9)
320 call _KiInterruptDispatch
321 addl $0xC, %esp
322 popl %gs
323 popl %fs
324 popl %es
325 popl %ds
326 popa
327 iret
328
329 .global _irq_handler_10
330 _irq_handler_10:
331 cld
332 pusha
333 pushl %ds
334 pushl %es
335 pushl %fs
336 pushl %gs
337 movl $0xceafbeef,%eax
338 pushl %eax
339 movw $KERNEL_DS,%ax
340 movw %ax,%ds
341 movw %ax,%es
342 movw %ax,%gs
343 movl $PCR_SELECTOR, %eax
344 movl %eax, %fs
345 pushl %esp
346 pushl $(IRQ_BASE + 10)
347 call _KiInterruptDispatch
348 addl $0xC, %esp
349 popl %gs
350 popl %fs
351 popl %es
352 popl %ds
353 popa
354 iret
355
356 .global _irq_handler_11
357 _irq_handler_11:
358 cld
359 pusha
360 pushl %ds
361 pushl %es
362 pushl %fs
363 pushl %gs
364 movl $0xceafbeef,%eax
365 pushl %eax
366 movw $KERNEL_DS,%ax
367 movw %ax,%ds
368 movw %ax,%es
369 movw %ax,%gs
370 movl $PCR_SELECTOR, %eax
371 movl %eax, %fs
372 pushl %esp
373 pushl $(IRQ_BASE + 11)
374 call _KiInterruptDispatch
375 addl $0xC, %esp
376 popl %gs
377 popl %fs
378 popl %es
379 popl %ds
380 popa
381 iret
382
383 .global _irq_handler_12
384 _irq_handler_12:
385 cld
386 pusha
387 pushl %ds
388 pushl %es
389 pushl %fs
390 pushl %gs
391 movl $0xceafbeef,%eax
392 pushl %eax
393 movw $KERNEL_DS,%ax
394 movw %ax,%ds
395 movw %ax,%es
396 movw %ax,%gs
397 movl $PCR_SELECTOR, %eax
398 movl %eax, %fs
399 pushl %esp
400 pushl $(IRQ_BASE + 12)
401 call _KiInterruptDispatch
402 addl $0xC, %esp
403 popl %gs
404 popl %fs
405 popl %es
406 popl %ds
407 popa
408 iret
409
410 .global _irq_handler_13
411 _irq_handler_13:
412 cld
413 pusha
414 pushl %ds
415 pushl %es
416 pushl %fs
417 pushl %gs
418 movl $0xceafbeef,%eax
419 pushl %eax
420 movw $KERNEL_DS,%ax
421 movw %ax,%ds
422 movw %ax,%es
423 movw %ax,%gs
424 movl $PCR_SELECTOR, %eax
425 movl %eax, %fs
426 pushl %esp
427 pushl $(IRQ_BASE + 13)
428 call _KiInterruptDispatch
429 addl $0xC, %esp
430 popl %gs
431 popl %fs
432 popl %es
433 popl %ds
434 popa
435 iret
436
437 .global _irq_handler_14
438 _irq_handler_14:
439 cld
440 pusha
441 pushl %ds
442 pushl %es
443 pushl %fs
444 pushl %gs
445 movl $0xceafbeef,%eax
446 pushl %eax
447 movw $KERNEL_DS,%ax
448 movw %ax,%ds
449 movw %ax,%es
450 movw %ax,%gs
451 movl $PCR_SELECTOR, %eax
452 movl %eax, %fs
453 pushl %esp
454 pushl $(IRQ_BASE + 14)
455 call _KiInterruptDispatch
456 addl $0xC, %esp
457 popl %gs
458 popl %fs
459 popl %es
460 popl %ds
461 popa
462 iret
463
464 .global _irq_handler_15
465 _irq_handler_15:
466 cld
467 pusha
468 pushl %ds
469 pushl %es
470 pushl %fs
471 pushl %gs
472 movl $0xceafbeef,%eax
473 pushl %eax
474 movw $KERNEL_DS,%ax
475 movw %ax,%ds
476 movw %ax,%es
477 movw %ax,%gs
478 movl $PCR_SELECTOR, %eax
479 movl %eax, %fs
480 pushl %esp
481 pushl $(IRQ_BASE + 15)
482 call _KiInterruptDispatch
483 addl $0xC, %esp
484 popl %gs
485 popl %fs
486 popl %es
487 popl %ds
488 popa
489 iret
490
491 #endif /* CONFIG_SMP */