1 ; AcessOS Microkernel Version
11 GDT_SIZE equ (1+2*2+1+MAX_CPUS)*8
19 dd 0x00000000, 0x00000000 ; 00 NULL Entry
20 dd 0x0000FFFF, 0x00CF9A00 ; 08 PL0 Code
21 dd 0x0000FFFF, 0x00CF9200 ; 10 PL0 Data
22 dd 0x0000FFFF, 0x00CFFA00 ; 18 PL3 Code
23 dd 0x0000FFFF, 0x00CFF200 ; 20 PL3 Data
24 dd 26*4-1, 0x00408900 ; 28 Double Fault TSS
25 times MAX_CPUS dd 26*4-1, 0x00408900 ; 30+ TSSes
34 ; CS = 0x08, Type = 32-bit Interrupt (0xE = 1 110)
35 times 256 dd 0x00080000,0x00000E00
38 dw 256 * 16 - 1 ; Limit
43 [global Desctab_Install]
47 mov ax, 0x10 ; PL0 Data
58 ; - Set an IDT entry to an ISR
61 mov WORD [gIDT + %1*8], ax
63 mov WORD [gIDT + %1*8+6], ax
65 mov ax, WORD [gIDT + %1*8 + 4]
67 mov WORD [gIDT + %1*8 + 4], ax
69 ; Enable user calling of an ISR
71 or WORD [gIDT + %1*8 + 4], 0x6000
73 ; Set an ISR as a trap (leaves interrupts enabled when invoked)
75 or WORD [gIDT + %1*8 + 4], 0x0100
88 SET_TRAP 0xAC ; Interruptable
92 SETISR 0xED ; 0xED Inter-processor HALT
93 SETISR 0xEE ; 0xEE Timer
94 SETISR 0xEF ; 0xEF Spurious Interrupt
111 out dx, al ; Init Command
114 out dx, al ; Offset (Start of IDT Range)
116 out dx, al ; IRQ connected to Slave (00000100b) = IRQ2
118 out dx, al ; Set Mode
120 out dx, al ; Set Mode
124 out dx, al ; Init Command
127 out dx, al ; Offset (Start of IDT Range)
129 out dx, al ; IRQ Line connected to master
131 out dx, al ; Set Mode
133 out dx, al ; Set Mode
174 ISR_NOERR 0; 0: Divide By Zero Exception
175 ISR_NOERR 1; 1: Debug Exception
176 ISR_NOERR 2; 2: Non Maskable Interrupt Exception
177 ISR_NOERR 3; 3: Int 3 Exception
178 ISR_NOERR 4; 4: INTO Exception
179 ISR_NOERR 5; 5: Out of Bounds Exception
180 ISR_NOERR 6; 6: Invalid Opcode Exception
181 ISR_NOERR 7; 7: Coprocessor Not Available Exception
182 ISR_ERRNO 8; 8: Double Fault Exception (With Error Code!)
183 ISR_NOERR 9; 9: Coprocessor Segment Overrun Exception
184 ISR_ERRNO 10; 10: Bad TSS Exception (With Error Code!)
185 ISR_ERRNO 11; 11: Segment Not Present Exception (With Error Code!)
186 ISR_ERRNO 12; 12: Stack Fault Exception (With Error Code!)
187 ISR_ERRNO 13; 13: General Protection Fault Exception (With Error Code!)
188 ISR_ERRNO 14; 14: Page Fault Exception (With Error Code!)
189 ISR_NOERR 15; 15: Reserved Exception
190 ISR_NOERR 16; 16: Floating Point Exception
191 ISR_NOERR 17; 17: Alignment Check Exception
192 ISR_NOERR 18; 18: Machine Check Exception
193 ISR_NOERR 19; 19: Reserved
194 ISR_NOERR 20; 20: Reserved
195 ISR_NOERR 21; 21: Reserved
196 ISR_NOERR 22; 22: Reserved
197 ISR_NOERR 23; 23: Reserved
198 ISR_NOERR 24; 24: Reserved
199 ISR_NOERR 25; 25: Reserved
200 ISR_NOERR 26; 26: Reserved
201 ISR_NOERR 27; 27: Reserved
202 ISR_NOERR 28; 28: Reserved
203 ISR_NOERR 29; 29: Reserved
204 ISR_NOERR 30; 30: Reserved
205 ISR_NOERR 31; 31: Reserved
207 DEF_SYSCALL 0xAC ; Acess System Call
211 ; 0xED - Interprocessor HALT
218 [extern SchedulerBase]
219 ; AP's Timer Interrupt
221 push eax ; Line up with interrupt number
222 mov eax, dr1 ; CPU Number
224 mov eax, [esp-4] ; Load EAX back
229 xchg bx, bx ; MAGIC BREAK
237 [extern SchedulerBase]
238 [extern SetAPICTimerCount]
240 push 0 ; Line up with Argument in errors
242 ;xchg bx, bx ; MAGIC BREAK
245 jmp SetAPICTimerCount ; This is reset once the bus speed has been calculated
256 ; ---------------------
257 ; Common error handling
258 ; ---------------------
259 [extern ErrorHandler]
261 ;xchg bx, bx ; MAGIC BREAK
271 ; and WORD [esp], 0xFEFF
289 add esp, 8 ; Error Code and ID
292 ; --------------------------
293 ; Common System Call Handler
294 ; --------------------------
295 [extern SyscallHandler]
307 ; Pass changes to TF on to the user
308 ; EFLAGS is stored at ESP[4+8+2+2]
309 ; 4 Segment Registers
311 ; 2 Error Code / Interrupt ID
315 and eax, 0x100 ; 0x100 = Trace Flag
316 and WORD [esp+(4+8+2+2)*4], ~0x100 ; Clear
317 or DWORD [esp+(4+8+2+2)*4], eax ; Set for user
324 add esp, 8 ; Error Code and ID
332 [global IRQCommon_handled]
333 IRQCommon_handled equ IRQCommon.handled
357 add esp, 8 ; Error Code and ID