- NDK 0.98, now with versionned headers. Too many changes to list, see the TinyKRNL...
[reactos.git] / reactos / ntoskrnl / ke / i386 / irqhand.s
1 #include <ndk/asm.h>
2 #include <../hal/halx86/include/halirq.h>
3
4 _KiCommonInterrupt:
5 cld
6 pushl %ds
7 pushl %es
8 pushl %fs
9 pushl %gs
10 pushl $0xceafbeef
11 movl $KGDT_R0_DATA,%eax
12 movl %eax,%ds
13 movl %eax,%es
14 movl %eax,%gs
15 movl $KGDT_R0_PCR,%eax
16 movl %eax,%fs
17 pushl %esp
18 pushl %ebx
19 call _KiInterruptDispatch
20 addl $0xC, %esp
21 popl %gs
22 popl %fs
23 popl %es
24 popl %ds
25 popa
26 iret
27
28
29 #ifdef CONFIG_SMP
30
31 #define BUILD_INTERRUPT_HANDLER(intnum) \
32 .global _KiUnexpectedInterrupt##intnum; \
33 _KiUnexpectedInterrupt##intnum:; \
34 pusha; \
35 movl $0x##intnum, %ebx; \
36 jmp _KiCommonInterrupt;
37
38 /* Interrupt handlers and declarations */
39
40 #define B(x,y) \
41 BUILD_INTERRUPT_HANDLER(x##y)
42
43 #define B16(x) \
44 B(x,0) B(x,1) B(x,2) B(x,3) \
45 B(x,4) B(x,5) B(x,6) B(x,7) \
46 B(x,8) B(x,9) B(x,A) B(x,B) \
47 B(x,C) B(x,D) B(x,E) B(x,F)
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 #undef BUILD_INTERRUPT_HANDLER
57
58 #else /* CONFIG_SMP */
59
60 #define BUILD_INTERRUPT_HANDLER(intnum) \
61 .global _irq_handler_##intnum; \
62 _irq_handler_##intnum:; \
63 pusha; \
64 movl $(##intnum + IRQ_BASE), %ebx; \
65 jmp _KiCommonInterrupt;
66
67 /* Interrupt handlers and declarations */
68
69 #define B(x) \
70 BUILD_INTERRUPT_HANDLER(x)
71
72 B(0) B(1) B(2) B(3)
73 B(4) B(5) B(6) B(7)
74 B(8) B(9) B(10) B(11)
75 B(12) B(13) B(14) B(15)
76
77 #undef B
78 #undef BUILD_INTERRUPT_HANDLER
79
80 #endif /* CONFIG_SMP */
81
82 .intel_syntax noprefix
83 .globl _KiUnexpectedInterrupt@0
84 _KiUnexpectedInterrupt@0:
85
86 /* Bugcheck with invalid interrupt code */
87 push 0x12
88 call _KeBugCheck@4
89