1 #include <aros/i386/asm.h>
5 #define BUILD_IRQ(nr) \
7 .globl TRAP##nr##_trap; \
8 .type TRAP##nr##_trap, @function; \
13 .size TRAP##nr##_trap, .-TRAP##nr##_trap;
15 #define BUILD_IRQ_ERR(nr) \
17 .globl TRAP##nr##_trap; \
18 .type TRAP##nr##_trap, @function; \
22 .size TRAP##nr##_trap, .-TRAP##nr##_trap;
24 BUILD_IRQ
(0x00) // Divide-By-Zero Exception
25 BUILD_IRQ
(0x01) // Debug Exception
26 BUILD_IRQ
(0x02) // NMI Exception
27 BUILD_IRQ
(0x03) // Breakpoint Exception
28 BUILD_IRQ
(0x04) // Overflow Exception
29 BUILD_IRQ
(0x05) // Bound-Range Exception
30 BUILD_IRQ
(0x06) // Invalid-Opcode Exception
31 BUILD_IRQ
(0x07) // Device-Not-Available Exception
32 BUILD_IRQ_ERR
(0x08) // Double-Fault Exception
33 BUILD_IRQ
(0x09) // Unused
(used to
be Coprocesor-Segment-Overrun
)
34 BUILD_IRQ_ERR
(0x0a) // Invalid-TSS Exception
35 BUILD_IRQ_ERR
(0x0b) // Segment-Not-Present Exception
36 BUILD_IRQ_ERR
(0x0c) // Stack Exception
37 BUILD_IRQ_ERR
(0x0d) // General-Protection Exception
38 BUILD_IRQ_ERR
(0x0e) // Page-Fault Exception
39 BUILD_IRQ
(0x0f) // Reserved
40 BUILD_IRQ
(0x10) // Floating-Point Exception
41 BUILD_IRQ_ERR
(0x11) // Alignment-Check Exception
42 BUILD_IRQ
(0x12) // Machine-Check Exception
43 BUILD_IRQ
(0x13) // SIMD-Floating-Point Exception
73 BUILD_IRQ
(0x80) // SysCall exception
74 BUILD_IRQ
(0xFE) // APIC Error Exception
78 .type core_Interrupt,@function
80 core_Interrupt
: // At this point two ULONGs for segment registers are
81 // already reserved. They are occupied by error code
and IRQ number
82 pushl $
0 // Reserve two more ULONGs
(for ES
and DS
)
84 pushl
%ebp
// Now save GPRs
91 pushl $ECF_SEGMENTS
// Flags. We have no FPU context here
and even no pointer for it.
92 movl
%esp
, %ebx
// Fixate context pointer in EBX
93 movl reg_fs
(%ebx
), %eax
// IRQ number
- third argument to core_IRQHandle
()
95 movl reg_gs
(%ebx
), %eax
// Error number
- second argument
97 pushl
%ebx
// Context pointer
- first argument
98 xorl
%eax
, %eax
// Zero-pad segments
99 mov
%ds
, %ax
// Now save segment registers
100 movl
%eax
, reg_ds
(%ebx
)
102 movl
%eax
, reg_es
(%ebx
)
104 movl
%eax
, reg_fs
(%ebx
)
106 movl
%eax
, reg_gs
(%ebx
)
107 mov $KERNEL_DS
, %ax
// We are supervisor now
111 call handleException
// Call C handler. EBX will
be preserved.
113 movl Flags
(%ebx
), %eax
// Test if the context contains segment registers
114 test $ECF_SEGMENTS
, %eax
116 movl reg_ds
(%ebx
), %eax
// Restore segment registers if present
118 movl reg_es
(%ebx
), %eax
120 movl reg_fs
(%ebx
), %eax
122 movl reg_gs
(%ebx
), %eax
125 movl
%ebx
, %esp
// Load context pointer into SP
, we will pop everything
126 popl
%eax
// These were flags
, just remove them
127 popl
%eax
// Restore GPRs
134 addl $
16, %esp
// Remove segments
136 .globl core_Unused_Int
137 .type core_Unused_Int, @function
140 .size core_Interrupt, .-core_Interrupt
142 .globl core_LeaveInterrupt
143 .type core_LeaveInterrupt, @function
145 popl
%ebx
// Remove return address
146 popl
%ebx
// Get argument
148 .size core_LeaveInterrupt, .-core_LeaveInterrupt
150 .globl core_Supervisor
151 .type core_Supervisor, @function
154 popl
%ebx
// Similar to above
, but chains to the routine
155 popl
%ebx
// pointed to by EDI
156 movl Flags
(%ebx
), %eax
// Note that data segments will
be reset back to user-mode values
157 test $ECF_SEGMENTS
, %eax
159 movl reg_ds
(%ebx
), %eax
161 movl reg_es
(%ebx
), %eax
163 movl reg_fs
(%ebx
), %eax
165 movl reg_gs
(%ebx
), %eax