1 ; AcessOS Microkernel Version
4 %include "arch/x86/common.inc.asm"
13 ; CS = 0x08, Type = 32-bit Interrupt (0xE = 1 110)
14 times 256 dd 0x00080000,0x00000E00
17 dw 256 * 16 - 1 ; Limit
22 [global Desctab_Install]
26 ; - Set an IDT entry to an ISR
29 mov WORD [gIDT + %1*8], ax
31 mov WORD [gIDT + %1*8+6], ax
33 mov ax, WORD [gIDT + %1*8 + 4]
35 mov WORD [gIDT + %1*8 + 4], ax
37 ; Enable user calling of an ISR
39 or WORD [gIDT + %1*8 + 4], 0x6000
41 ; Set an ISR as a trap (leaves interrupts enabled when invoked)
43 or WORD [gIDT + %1*8 + 4], 0x0100
56 SET_TRAP 0xAC ; Interruptable
60 SETISR 0xED ; 0xED Inter-processor HALT
61 SETISR 0xEE ; 0xEE Timer
62 SETISR 0xEF ; 0xEF Spurious Interrupt
79 out dx, al ; Init Command
82 out dx, al ; Offset (Start of IDT Range)
84 out dx, al ; IRQ connected to Slave (00000100b) = IRQ2
92 out dx, al ; Init Command
95 out dx, al ; Offset (Start of IDT Range)
97 out dx, al ; IRQ Line connected to master
101 out dx, al ; Set Mode
142 ISR_NOERR 0; 0: Divide By Zero Exception
143 ISR_NOERR 1; 1: Debug Exception
144 ISR_NOERR 2; 2: Non Maskable Interrupt Exception
145 ISR_NOERR 3; 3: Int 3 Exception
146 ISR_NOERR 4; 4: INTO Exception
147 ISR_NOERR 5; 5: Out of Bounds Exception
148 ISR_NOERR 6; 6: Invalid Opcode Exception
149 ISR_NOERR 7; 7: Coprocessor Not Available Exception
150 ISR_ERRNO 8; 8: Double Fault Exception (With Error Code!)
151 ISR_NOERR 9; 9: Coprocessor Segment Overrun Exception
152 ISR_ERRNO 10; 10: Bad TSS Exception (With Error Code!)
153 ISR_ERRNO 11; 11: Segment Not Present Exception (With Error Code!)
154 ISR_ERRNO 12; 12: Stack Fault Exception (With Error Code!)
155 ISR_ERRNO 13; 13: General Protection Fault Exception (With Error Code!)
156 ISR_ERRNO 14; 14: Page Fault Exception (With Error Code!)
157 ISR_NOERR 15; 15: Reserved Exception
158 ISR_NOERR 16; 16: Floating Point Exception
159 ISR_NOERR 17; 17: Alignment Check Exception
160 ISR_NOERR 18; 18: Machine Check Exception
161 ISR_NOERR 19; 19: Reserved
162 ISR_NOERR 20; 20: Reserved
163 ISR_NOERR 21; 21: Reserved
164 ISR_NOERR 22; 22: Reserved
165 ISR_NOERR 23; 23: Reserved
166 ISR_NOERR 24; 24: Reserved
167 ISR_NOERR 25; 25: Reserved
168 ISR_NOERR 26; 26: Reserved
169 ISR_NOERR 27; 27: Reserved
170 ISR_NOERR 28; 28: Reserved
171 ISR_NOERR 29; 29: Reserved
172 ISR_NOERR 30; 30: Reserved
173 ISR_NOERR 31; 31: Reserved
175 DEF_SYSCALL 0xAC ; Acess System Call
179 ; 0xED - Interprocessor HALT
186 [extern Proc_EventTimer_LAPIC]
187 ; AP's Timer Interrupt
189 push eax ; Line up with interrupt number
190 mov eax, dr1 ; CPU Number
192 mov eax, [esp+4] ; Load EAX back
193 jmp Proc_EventTimer_LAPIC
197 xchg bx, bx ; MAGIC BREAK
205 [extern Proc_EventTimer_PIT]
206 [extern SetAPICTimerCount]
208 push 0 ; Line up with Argument in errors
210 ;xchg bx, bx ; MAGIC BREAK
213 jmp SetAPICTimerCount ; This is reset once the bus speed has been calculated
215 jmp Proc_EventTimer_PIT
224 [extern ReturnFromInterrupt]
225 ; ---------------------
226 ; Common error handling
227 ; ---------------------
228 [extern ErrorHandler]
238 ; and WORD [esp], 0xFEFF
251 jmp ReturnFromInterrupt
253 ; --------------------------
254 ; Common System Call Handler
255 ; --------------------------
256 [extern SyscallHandler]
258 PUSH_CC ; Actually a pusha
265 ; Pass changes to TF on to the user
266 ; EFLAGS is stored at ESP[4+8+2+2]
267 ; 4 Segment Registers
269 ; 2 Error Code / Interrupt ID
273 and eax, 0x100 ; 0x100 = Trace Flag
274 and WORD [esp+(4+8+2+2)*4], ~0x100 ; Clear
275 or DWORD [esp+(4+8+2+2)*4], eax ; Set for user
277 jmp ReturnFromInterrupt
284 [global IRQCommon_handled]
285 IRQCommon_handled equ IRQCommon.handled
300 add esp, 8 ; Error Code and ID