]> git.proxmox.com Git - mirror_edk2.git/blame - DuetPkg/CpuDxe/Ia32/CpuInterrupt.S
Patch for CpuInterrupt.S from Tristan Gingold.
[mirror_edk2.git] / DuetPkg / CpuDxe / Ia32 / CpuInterrupt.S
CommitLineData
5ffcd257 1#------------------------------------------------------------------------------\r
2#*\r
3#* Copyright 2006, Intel Corporation \r
4#* All rights reserved. This program and the accompanying materials \r
5#* are licensed and made available under the terms and conditions of the BSD License \r
6#* which accompanies this distribution. The full text of the license may be found at \r
7#* http://opensource.org/licenses/bsd-license.php \r
8#* \r
9#* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
10#* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
11#* \r
12#* CpuInterrupt.S\r
13#* \r
14#* Abstract:\r
15#*\r
16#------------------------------------------------------------------------------\r
17\r
18#PUBLIC SystemTimerHandler\r
19#PUBLIC SystemExceptionHandler\r
20#EXTERNDEF mExceptionCodeSize:DWORD\r
21\r
22#EXTERN TimerHandler: NEAR\r
23#EXTERN ExceptionHandler: NEAR\r
24#EXTERN mTimerVector: DWORD\r
25\r
26 .data\r
27 .globl ASM_PFX(mExceptionCodeSize)\r
28ASM_PFX(mExceptionCodeSize): .long 9\r
29\r
30 .text\r
31 .globl ASM_PFX(InitDescriptor)\r
32\r
6794a1b9 33ASM_PFX(InitDescriptor):\r
5ffcd257 34 movl $GDT_BASE,%eax # EAX=PHYSICAL address of gdt\r
35 movl %eax, gdtr + 2 # Put address of gdt into the gdtr\r
6794a1b9 36 lgdt gdtr\r
5ffcd257 37 movl $IDT_BASE,%eax # EAX=PHYSICAL address of idt\r
38 movl %eax, idtr + 2 # Put address of idt into the idtr\r
6794a1b9 39 lidt idtr\r
40 ret\r
41\r
5ffcd257 42# VOID\r
43# InstallInterruptHandler (\r
44# UINTN Vector,\r
45# VOID (*Handler)(VOID)\r
46# )\r
47 .globl ASM_PFX(InstallInterruptHandler)\r
6794a1b9 48ASM_PFX(InstallInterruptHandler):\r
5ffcd257 49# Vector:DWORD @ 4(%esp)\r
50# Handler:DWORD @ 8(%esp)\r
51\r
52 push %edi\r
53 pushf # save eflags\r
6794a1b9 54 cli # turn off interrupts\r
5ffcd257 55 subl $6,%esp # open some space on the stack\r
56 movl %esp,%edi\r
57 sidt (%edi) # get fword address of IDT\r
58 movl 2(%edi), %edi # move offset of IDT into EDI\r
59 addl $6,%esp # correct stack\r
60 movl 12(%esp),%eax # Get vector number\r
61 shl $3,%eax # multiply by 8 to get offset\r
62 addl %eax,%edi # add to IDT base to get entry\r
63 movl 16(%esp),%eax # load new address into IDT entry\r
64 movw %ax,(%edi) # write bits 15..0 of offset\r
65 shrl $16,%eax # use ax to copy 31..16 to descriptors\r
66 movw %ax,6(%edi) # write bits 31..16 of offset\r
67 popf # restore flags (possible enabling interrupts)\r
6794a1b9 68 pop %edi\r
69 ret\r
70\r
5ffcd257 71 .macro JmpCommonIdtEntry\r
72 # jmp commonIdtEntry - this must be hand coded to keep the assembler from\r
73 # using a 8 bit reletive jump when the entries are\r
74 # within 255 bytes of the common entry. This must\r
75 # be done to maintain the consistency of the size\r
76 # of entry points...\r
77 .byte 0xe9 # jmp 16 bit reletive \r
78 .long commonIdtEntry - . - 4 # offset to jump to\r
79 .endm\r
80\r
81 .align 2\r
82 .globl ASM_PFX(SystemExceptionHandler)\r
6794a1b9 83ASM_PFX(SystemExceptionHandler):\r
84INT0:\r
5ffcd257 85 pushl $0x0 # push error code place holder on the stack\r
86 pushl $0x0 \r
87 JmpCommonIdtEntry\r
88# db 0e9h # jmp 16 bit reletive \r
89# dd commonIdtEntry - $ - 4 # offset to jump to\r
90 \r
6794a1b9 91INT1:\r
5ffcd257 92 pushl $0x0 # push error code place holder on the stack\r
93 pushl $0x1 \r
94 JmpCommonIdtEntry\r
95 \r
6794a1b9 96INT2:\r
5ffcd257 97 pushl $0x0 # push error code place holder on the stack\r
98 pushl $0x2 \r
99 JmpCommonIdtEntry\r
100 \r
6794a1b9 101INT3:\r
5ffcd257 102 pushl $0x0 # push error code place holder on the stack\r
103 pushl $0x3 \r
104 JmpCommonIdtEntry\r
105 \r
6794a1b9 106INT4:\r
5ffcd257 107 pushl $0x0 # push error code place holder on the stack\r
108 pushl $0x4 \r
109 JmpCommonIdtEntry\r
110 \r
6794a1b9 111INT5:\r
5ffcd257 112 pushl $0x0 # push error code place holder on the stack\r
113 pushl $0x5 \r
114 JmpCommonIdtEntry\r
115 \r
6794a1b9 116INT6:\r
5ffcd257 117 pushl $0x0 # push error code place holder on the stack\r
118 pushl $0x6 \r
119 JmpCommonIdtEntry\r
120 \r
6794a1b9 121INT7:\r
5ffcd257 122 pushl $0x0 # push error code place holder on the stack\r
123 pushl $0x7 \r
124 JmpCommonIdtEntry\r
125 \r
6794a1b9 126INT8:\r
5ffcd257 127# Double fault causes an error code to be pushed so no phony push necessary\r
6794a1b9 128 nop\r
129 nop\r
5ffcd257 130 pushl $0x8 \r
131 JmpCommonIdtEntry\r
132 \r
6794a1b9 133INT9:\r
5ffcd257 134 pushl $0x0 # push error code place holder on the stack\r
135 pushl $0x9 \r
136 JmpCommonIdtEntry\r
137 \r
6794a1b9 138INT10:\r
5ffcd257 139# Invalid TSS causes an error code to be pushed so no phony push necessary\r
6794a1b9 140 nop\r
141 nop\r
142 pushl $10\r
5ffcd257 143 JmpCommonIdtEntry\r
144 \r
6794a1b9 145INT11:\r
5ffcd257 146# Segment Not Present causes an error code to be pushed so no phony push necessary\r
6794a1b9 147 nop\r
148 nop\r
149 pushl $11\r
5ffcd257 150 JmpCommonIdtEntry\r
151 \r
6794a1b9 152INT12:\r
5ffcd257 153# Stack fault causes an error code to be pushed so no phony push necessary\r
6794a1b9 154 nop\r
155 nop\r
156 pushl $12\r
5ffcd257 157 JmpCommonIdtEntry\r
158 \r
6794a1b9 159INT13:\r
5ffcd257 160# GP fault causes an error code to be pushed so no phony push necessary\r
6794a1b9 161 nop\r
162 nop\r
163 pushl $13\r
5ffcd257 164 JmpCommonIdtEntry\r
165 \r
6794a1b9 166INT14:\r
5ffcd257 167# Page fault causes an error code to be pushed so no phony push necessary\r
6794a1b9 168 nop\r
169 nop\r
170 pushl $14\r
5ffcd257 171 JmpCommonIdtEntry\r
172 \r
6794a1b9 173INT15:\r
5ffcd257 174 pushl $0x0 # push error code place holder on the stack\r
175 pushl $15\r
176 JmpCommonIdtEntry\r
177 \r
6794a1b9 178INT16:\r
5ffcd257 179 pushl $0x0 # push error code place holder on the stack\r
180 pushl $16\r
181 JmpCommonIdtEntry\r
182 \r
6794a1b9 183INT17:\r
5ffcd257 184# Alignment check causes an error code to be pushed so no phony push necessary\r
6794a1b9 185 nop\r
186 nop\r
187 pushl $17\r
5ffcd257 188 JmpCommonIdtEntry\r
189 \r
6794a1b9 190INT18:\r
5ffcd257 191 pushl $0x0 # push error code place holder on the stack\r
192 pushl $18\r
193 JmpCommonIdtEntry\r
194 \r
6794a1b9 195INT19:\r
5ffcd257 196 pushl $0x0 # push error code place holder on the stack\r
197 pushl $19\r
198 JmpCommonIdtEntry\r
6794a1b9 199\r
5ffcd257 200INTUnknown:\r
201 .rept (32 - 20)\r
202 pushl $0x0 # push error code place holder on the stack\r
203# push xxh # push vector number\r
204 .byte 0x6a\r
205 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
206 JmpCommonIdtEntry\r
207 .endr\r
208\r
209 .globl ASM_PFX(SystemTimerHandler)\r
6794a1b9 210ASM_PFX(SystemTimerHandler):\r
5ffcd257 211 pushl $0\r
212 pushl $mTimerVector\r
213 JmpCommonIdtEntry\r
6794a1b9 214\r
215commonIdtEntry:\r
216# +---------------------+\r
217# + EFlags +\r
218# +---------------------+\r
219# + CS +\r
220# +---------------------+\r
221# + EIP +\r
222# +---------------------+\r
223# + Error Code +\r
224# +---------------------+\r
225# + Vector Number +\r
226# +---------------------+\r
227# + EBP +\r
228# +---------------------+ <-- EBP\r
229\r
230 cli\r
5ffcd257 231 push %ebp\r
232 movl %esp,%ebp\r
6794a1b9 233\r
234 #\r
235 # Align stack to make sure that EFI_FX_SAVE_STATE_IA32 of EFI_SYSTEM_CONTEXT_IA32\r
236 # is 16-byte aligned\r
237 #\r
5ffcd257 238 andl $0xfffffff0,%esp\r
239 subl $12,%esp\r
6794a1b9 240\r
241## UINT32 Edi, Esi, Ebp, Esp, Ebx, Edx, Ecx, Eax#\r
5ffcd257 242 push %eax\r
243 push %ecx\r
244 push %edx\r
245 push %ebx\r
246 leal 6*4(%ebp),%ecx\r
247 push %ecx # ESP\r
248 push (%ebp) # EBP\r
249 push %esi\r
250 push %edi\r
6794a1b9 251\r
252## UINT32 Gs, Fs, Es, Ds, Cs, Ss#\r
5ffcd257 253 movw %ss,%ax\r
254 push %eax\r
255 movzx 4*4(%ebp),%eax\r
256 push %eax\r
257 movw %ds,%ax\r
258 push %eax\r
259 movw %es,%ax\r
260 push %eax\r
261 movw %fs,%ax\r
262 push %eax\r
263 movw %gs,%ax\r
264 push %eax\r
6794a1b9 265\r
266## UINT32 Eip#\r
5ffcd257 267 pushl 3*4(%ebp)\r
6794a1b9 268\r
269## UINT32 Gdtr[2], Idtr[2]#\r
5ffcd257 270 subl $8,%esp\r
271 sidt (%esp)\r
272 subl $8,%esp\r
273 sgdt (%esp)\r
6794a1b9 274\r
275## UINT32 Ldtr, Tr#\r
5ffcd257 276 xorl %eax, %eax\r
277 str %ax\r
278 push %eax\r
279 sldt %eax\r
280 push %eax\r
6794a1b9 281\r
282## UINT32 EFlags#\r
5ffcd257 283 pushl 5*4(%ebp)\r
6794a1b9 284\r
285## UINT32 Cr0, Cr1, Cr2, Cr3, Cr4#\r
5ffcd257 286 mov %cr4,%eax\r
287 orl $0x208,%eax\r
288 mov %eax,%cr4\r
289 push %eax\r
290 mov %cr3,%eax\r
291 push %eax\r
292 mov %cr2,%eax\r
293 push %eax\r
294 xor %eax, %eax\r
295 push %eax\r
296 mov %cr0,%eax\r
297 push %eax\r
6794a1b9 298\r
299## UINT32 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7#\r
5ffcd257 300 mov %dr7,%eax\r
301 push %eax\r
6794a1b9 302## clear Dr7 while executing debugger itself\r
5ffcd257 303 xor %eax, %eax\r
304 mov %eax,%dr7\r
6794a1b9 305\r
5ffcd257 306 mov %dr6,%eax\r
307 push %eax\r
6794a1b9 308## insure all status bits in dr6 are clear...\r
5ffcd257 309 xor %eax, %eax\r
310 mov %eax,%dr6\r
311\r
312 mov %dr3,%eax\r
313 push %eax\r
314 mov %dr2,%eax\r
315 push %eax\r
316 mov %dr1,%eax\r
317 push %eax\r
318 mov %dr0,%eax\r
319 push %eax\r
320\r
321## FX_SAVE_STATE_IA32 FxSaveState;\r
322 sub $512,%esp\r
323 mov %esp,%edi\r
6794a1b9 324 fxsave (%edi)\r
5ffcd257 325\r
326## UINT32 ExceptionData;\r
6794a1b9 327 pushl 2*4(%ebp)\r
328\r
329## Prepare parameter and call\r
5ffcd257 330 mov %esp,%edx\r
331 push %edx\r
332 mov 1*4(%ebp),%eax\r
333 push %eax\r
334 cmpl $32,%eax\r
6794a1b9 335 jb CallException\r
5ffcd257 336 call TimerHandler\r
6794a1b9 337 jmp ExceptionDone\r
338CallException:\r
5ffcd257 339 call ExceptionHandler\r
6794a1b9 340ExceptionDone:\r
5ffcd257 341 addl $8,%esp\r
6794a1b9 342\r
343 cli\r
5ffcd257 344## UINT32 ExceptionData;\r
345 addl $4,%esp\r
346\r
347## FX_SAVE_STATE_IA32 FxSaveState;\r
348 mov %esp,%esi\r
349 fxrstor (%esi)\r
350 addl $512,%esp\r
351\r
352#; UINT32 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7;\r
353 pop %eax\r
354 mov %eax,%dr0\r
355 pop %eax\r
356 mov %eax,%dr1\r
357 pop %eax\r
358 mov %eax,%dr2\r
359 pop %eax\r
360 mov %eax,%dr3\r
6794a1b9 361## skip restore of dr6. We cleared dr6 during the context save.\r
5ffcd257 362 addl $4,%esp\r
363 pop %eax\r
364 mov %eax,%dr7\r
365\r
366## UINT32 Cr0, Cr1, Cr2, Cr3, Cr4;\r
367 pop %eax\r
368 mov %eax,%cr0\r
369 addl $4,%esp # not for Cr1\r
370 pop %eax\r
371 mov %eax,%cr2\r
372 pop %eax\r
373 mov %eax,%cr3\r
374 pop %eax\r
375 mov %eax,%cr4\r
376\r
377## UINT32 EFlags;\r
378 popl 5*4(%ebp)\r
379\r
380## UINT32 Ldtr, Tr;\r
381## UINT32 Gdtr[2], Idtr[2];\r
6794a1b9 382## Best not let anyone mess with these particular registers...\r
5ffcd257 383 addl $24,%esp\r
6794a1b9 384\r
5ffcd257 385## UINT32 Eip;\r
386 popl 3*4(%ebp)\r
6794a1b9 387\r
5ffcd257 388## UINT32 Gs, Fs, Es, Ds, Cs, Ss;\r
6794a1b9 389## NOTE - modified segment registers could hang the debugger... We\r
390## could attempt to insulate ourselves against this possibility,\r
391## but that poses risks as well.\r
392##\r
5ffcd257 393 pop %gs\r
394 pop %fs\r
395 pop %es\r
396 pop %ds\r
6794a1b9 397 popl 4*4(%ebp)\r
5ffcd257 398 pop %ss\r
6794a1b9 399\r
5ffcd257 400## UINT32 Edi, Esi, Ebp, Esp, Ebx, Edx, Ecx, Eax;\r
401 pop %edi\r
402 pop %esi\r
403 addl $4,%esp # not for ebp\r
404 addl $4,%esp # not for esp\r
405 pop %ebx\r
406 pop %edx\r
407 pop %ecx\r
408 pop %eax\r
409\r
410 mov %ebp,%esp\r
411 pop %ebp\r
412 addl $8,%esp\r
413 iret\r
414\r
415\r
416#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r
6794a1b9 417# data\r
5ffcd257 418#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r
6794a1b9 419\r
5ffcd257 420 .data\r
421 .align 4\r
422\r
423gdtr: .short GDT_END - GDT_BASE - 1 # GDT limit\r
424 .long 0 # (GDT base gets set above)\r
425#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r
6794a1b9 426# global descriptor table (GDT)\r
5ffcd257 427#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r
6794a1b9 428\r
5ffcd257 429 .align 4\r
6794a1b9 430\r
5ffcd257 431 .globl GDT_BASE\r
6794a1b9 432GDT_BASE:\r
5ffcd257 433# null descriptor\r
434NULL_SEL = .-GDT_BASE\r
435 .short 0 # limit 15:0\r
436 .short 0 # base 15:0\r
437 .byte 0 # base 23:16\r
438 .byte 0 # type\r
439 .byte 0 # limit 19:16, flags\r
440 .byte 0 # base 31:24\r
441\r
442# linear data segment descriptor\r
443LINEAR_SEL = .-GDT_BASE\r
444 .short 0x0FFFF # limit 0xFFFFF\r
445 .short 0 # base 0\r
446 .byte 0\r
447 .byte 0x092 # present, ring 0, data, expand-up, writable\r
448 .byte 0x0CF # page-granular, 32-bit\r
449 .byte 0\r
450\r
451# linear code segment descriptor\r
452LINEAR_CODE_SEL = .-GDT_BASE\r
453 .short 0x0FFFF # limit 0xFFFFF\r
454 .short 0 # base 0\r
455 .byte 0\r
456 .byte 0x09A # present, ring 0, data, expand-up, writable\r
457 .byte 0x0CF # page-granular, 32-bit\r
458 .byte 0\r
459\r
460# system data segment descriptor\r
461SYS_DATA_SEL = .-GDT_BASE\r
462 .short 0x0FFFF # limit 0xFFFFF\r
463 .short 0 # base 0\r
464 .byte 0\r
465 .byte 0x092 # present, ring 0, data, expand-up, writable\r
466 .byte 0x0CF # page-granular, 32-bit\r
467 .byte 0\r
468\r
469# system code segment descriptor\r
470SYS_CODE_SEL = .-GDT_BASE\r
471 .short 0x0FFFF # limit 0xFFFFF\r
472 .short 0 # base 0\r
473 .byte 0\r
474 .byte 0x09A # present, ring 0, data, expand-up, writable\r
475 .byte 0x0CF # page-granular, 32-bit\r
476 .byte 0\r
477\r
478# spare segment descriptor\r
479SPARE3_SEL = .-GDT_BASE\r
480 .short 0 # limit 0xFFFFF\r
481 .short 0 # base 0\r
482 .byte 0\r
483 .byte 0 # present, ring 0, data, expand-up, writable\r
484 .byte 0 # page-granular, 32-bit\r
485 .byte 0\r
486\r
487# spare segment descriptor\r
488SPARE4_SEL = .-GDT_BASE\r
489 .short 0 # limit 0xFFFFF\r
490 .short 0 # base 0\r
491 .byte 0\r
492 .byte 0 # present, ring 0, data, expand-up, writable\r
493 .byte 0 # page-granular, 32-bit\r
494 .byte 0\r
495\r
496# spare segment descriptor\r
497SPARE5_SEL = .-GDT_BASE\r
498 .short 0 # limit 0xFFFFF\r
499 .short 0 # base 0\r
500 .byte 0\r
501 .byte 0 # present, ring 0, data, expand-up, writable\r
502 .byte 0 # page-granular, 32-bit\r
503 .byte 0\r
504\r
505GDT_END:\r
506\r
507 .align 4\r
508\r
509\r
510\r
511idtr: .short IDT_END - IDT_BASE - 1 # IDT limit\r
512 .long 0 # (IDT base gets set above)\r
513#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r
6794a1b9 514# interrupt descriptor table (IDT)\r
515#\r
516# Note: The hardware IRQ's specified in this table are the normal PC/AT IRQ\r
517# mappings. This implementation only uses the system timer and all other\r
518# IRQs will remain masked. The descriptors for vectors 33+ are provided\r
519# for convenience.\r
5ffcd257 520#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r
6794a1b9 521\r
5ffcd257 522#idt_tag .byte "IDT",0 \r
523 .align 4\r
6794a1b9 524\r
5ffcd257 525.globl IDT_BASE\r
6794a1b9 526IDT_BASE:\r
6794a1b9 527# divide by zero (INT 0)\r
5ffcd257 528DIV_ZERO_SEL = .-IDT_BASE\r
529 .short 0 # offset 15:0\r
530 .short SYS_CODE_SEL # selector 15:0\r
531 .byte 0 # 0 for interrupt gate\r
532 .byte 0x0e | 0x80 # type = 386 interrupt gate, present\r
533 .short 0 # offset 31:16\r
6794a1b9 534\r
535# debug exception (INT 1)\r
5ffcd257 536DEBUG_EXCEPT_SEL = .-IDT_BASE\r
537 .short 0 # offset 15:0\r
538 .short SYS_CODE_SEL # selector 15:0\r
539 .byte 0 # 0 for interrupt gate\r
540 .byte 0x0e | 0x80 # type = 386 interrupt gate, present\r
541 .short 0 # offset 31:16\r
6794a1b9 542\r
543# NMI (INT 2)\r
5ffcd257 544NMI_SEL = .-IDT_BASE\r
545 .short 0 # offset 15:0\r
546 .short SYS_CODE_SEL # selector 15:0\r
547 .byte 0 # 0 for interrupt gate\r
548 .byte 0x0e | 0x80 # type = 386 interrupt gate, present\r
549 .short 0 # offset 31:16\r
6794a1b9 550\r
551# soft breakpoint (INT 3)\r
5ffcd257 552BREAKPOINT_SEL = .-IDT_BASE\r
553 .short 0 # offset 15:0\r
554 .short SYS_CODE_SEL # selector 15:0\r
555 .byte 0 # 0 for interrupt gate\r
556 .byte 0x0e | 0x80 # type = 386 interrupt gate, present\r
557 .short 0 # offset 31:16\r
6794a1b9 558\r
559# overflow (INT 4)\r
5ffcd257 560OVERFLOW_SEL = .-IDT_BASE\r
561 .short 0 # offset 15:0\r
562 .short SYS_CODE_SEL # selector 15:0\r
563 .byte 0 # 0 for interrupt gate\r
564 .byte 0x0e | 0x80 # type = 386 interrupt gate, present\r
565 .short 0 # offset 31:16\r
6794a1b9 566\r
567# bounds check (INT 5)\r
5ffcd257 568BOUNDS_CHECK_SEL = .-IDT_BASE\r
569 .short 0 # offset 15:0\r
570 .short SYS_CODE_SEL # selector 15:0\r
571 .byte 0 # 0 for interrupt gate\r
572 .byte 0x0e | 0x80 # type = 386 interrupt gate, present\r
573 .short 0 # offset 31:16\r
6794a1b9 574\r
575# invalid opcode (INT 6)\r
5ffcd257 576INVALID_OPCODE_SEL = .-IDT_BASE\r
577 .short 0 # offset 15:0\r
578 .short SYS_CODE_SEL # selector 15:0\r
579 .byte 0 # 0 for interrupt gate\r
580 .byte 0x0e | 0x80 # type = 386 interrupt gate, present\r
581 .short 0 # offset 31:16\r
6794a1b9 582\r
583# device not available (INT 7)\r
5ffcd257 584DEV_NOT_AVAIL_SEL = .-IDT_BASE\r
585 .short 0 # offset 15:0\r
586 .short SYS_CODE_SEL # selector 15:0\r
587 .byte 0 # 0 for interrupt gate\r
588 .byte 0x0e | 0x80 # type = 386 interrupt gate, present\r
589 .short 0 # offset 31:16\r
6794a1b9 590\r
591# double fault (INT 8)\r
5ffcd257 592DOUBLE_FAULT_SEL = .-IDT_BASE\r
593 .short 0 # offset 15:0\r
594 .short SYS_CODE_SEL # selector 15:0\r
595 .byte 0 # 0 for interrupt gate\r
596 .byte 0x0e | 0x80 # type = 386 interrupt gate, present\r
597 .short 0 # offset 31:16\r
6794a1b9 598\r
599# Coprocessor segment overrun - reserved (INT 9)\r
5ffcd257 600RSVD_INTR_SEL1 = .-IDT_BASE\r
601 .short 0 # offset 15:0\r
602 .short SYS_CODE_SEL # selector 15:0\r
603 .byte 0 # 0 for interrupt gate\r
604 .byte 0x0e | 0x80 # type = 386 interrupt gate, present\r
605 .short 0 # offset 31:16\r
6794a1b9 606\r
607# invalid TSS (INT 0ah)\r
5ffcd257 608INVALID_TSS_SEL = .-IDT_BASE\r
609 .short 0 # offset 15:0\r
610 .short SYS_CODE_SEL # selector 15:0\r
611 .byte 0 # 0 for interrupt gate\r
612 .byte 0x0e | 0x80 # type = 386 interrupt gate, present\r
613 .short 0 # offset 31:16\r
6794a1b9 614\r
615# segment not present (INT 0bh)\r
5ffcd257 616SEG_NOT_PRESENT_SEL = .-IDT_BASE\r
617 .short 0 # offset 15:0\r
618 .short SYS_CODE_SEL # selector 15:0\r
619 .byte 0 # 0 for interrupt gate\r
620 .byte 0x0e | 0x80 # type = 386 interrupt gate, present\r
621 .short 0 # offset 31:16\r
6794a1b9 622\r
623# stack fault (INT 0ch)\r
5ffcd257 624STACK_FAULT_SEL = .-IDT_BASE\r
625 .short 0 # offset 15:0\r
626 .short SYS_CODE_SEL # selector 15:0\r
627 .byte 0 # 0 for interrupt gate\r
628 .byte 0x0e | 0x80 # type = 386 interrupt gate, present\r
629 .short 0 # offset 31:16\r
6794a1b9 630\r
631# general protection (INT 0dh)\r
5ffcd257 632GP_FAULT_SEL = .-IDT_BASE\r
633 .short 0 # offset 15:0\r
634 .short SYS_CODE_SEL # selector 15:0\r
635 .byte 0 # 0 for interrupt gate\r
636 .byte 0x0e | 0x80 # type = 386 interrupt gate, present\r
637 .short 0 # offset 31:16\r
6794a1b9 638\r
639# page fault (INT 0eh)\r
5ffcd257 640PAGE_FAULT_SEL = .-IDT_BASE\r
641 .short 0 # offset 15:0\r
642 .short SYS_CODE_SEL # selector 15:0\r
643 .byte 0 # 0 for interrupt gate\r
644 .byte 0x0e | 0x80 # type = 386 interrupt gate, present\r
645 .short 0 # offset 31:16\r
6794a1b9 646\r
647# Intel reserved - do not use (INT 0fh)\r
5ffcd257 648RSVD_INTR_SEL2 = .-IDT_BASE\r
649 .short 0 # offset 15:0\r
650 .short SYS_CODE_SEL # selector 15:0\r
651 .byte 0 # 0 for interrupt gate\r
652 .byte 0x0e | 0x80 # type = 386 interrupt gate, present\r
653 .short 0 # offset 31:16\r
654\r
655# floating point error (INT 0x10)\r
656FLT_POINT_ERR_SEL = .-IDT_BASE\r
657 .short 0 # offset 15:0\r
658 .short SYS_CODE_SEL # selector 15:0\r
659 .byte 0 # 0 for interrupt gate\r
660 .byte 0x0e | 0x80 # type = 386 interrupt gate, present\r
661 .short 0 # offset 31:16\r
662\r
663# alignment check (INT 0x11)\r
664ALIGNMENT_CHECK_SEL = .-IDT_BASE\r
665 .short 0 # offset 15:0\r
666 .short SYS_CODE_SEL # selector 15:0\r
667 .byte 0 # 0 for interrupt gate\r
668 .byte 0x0e | 0x80 # (10001110)type = 386 interrupt gate, present\r
669 .short 0 # offset 31:16\r
670\r
671# machine check (INT 0x12)\r
672MACHINE_CHECK_SEL = .-IDT_BASE\r
673 .short 0 # offset 15:0\r
674 .short SYS_CODE_SEL # selector 15:0\r
675 .byte 0 # 0 for interrupt gate\r
676 .byte 0x0e | 0x80 # (10001110)type = 386 interrupt gate, present\r
677 .short 0 # offset 31:16\r
678\r
679# SIMD floating-point exception (INT 0x13)\r
680SIMD_EXCEPTION_SEL = .-IDT_BASE\r
681 .short 0 # offset 15:0\r
682 .short SYS_CODE_SEL # selector 15:0\r
683 .byte 0 # 0 for interrupt gate\r
684 .byte 0x0e | 0x80 # (10001110)type = 386 interrupt gate, present\r
685 .short 0 # offset 31:16\r
686\r
687 .rept (32 - 20)\r
688 .short 0 # offset 15:0\r
689 .short SYS_CODE_SEL # selector 15:0\r
690 .byte 0 # 0 for interrupt gate\r
691 .byte 0x0e | 0x80 # (10001110)type = 386 interrupt gate, present\r
692 .short 0 # offset 31:16\r
693 .endr\r
6794a1b9 694\r
695# 72 unspecified descriptors\r
5ffcd257 696 .rept 72 * 8\r
697 .byte 0\r
698 .endr\r
6794a1b9 699 \r
5ffcd257 700# IRQ 0 (System timer) - (INT 0x68)\r
701IRQ0_SEL = .-IDT_BASE\r
702 .short 0 # offset 15:0\r
703 .short SYS_CODE_SEL # selector 15:0\r
704 .byte 0 # 0 for interrupt gate\r
705 .byte 0x0e | 0x80 # (10001110)type = 386 interrupt gate, present\r
706 .short 0 # offset 31:16\r
707\r
708# IRQ 1 (8042 Keyboard controller) - (INT 0x69)\r
709IRQ1_SEL = .-IDT_BASE\r
710 .short 0 # offset 15:0\r
711 .short SYS_CODE_SEL # selector 15:0\r
712 .byte 0 # 0 for interrupt gate\r
713 .byte 0x0e | 0x80 # (10001110)type = 386 interrupt gate, present\r
714 .short 0 # offset 31:16\r
6794a1b9 715\r
716# Reserved - IRQ 2 redirect (IRQ 2) - DO NOT USE!!! - (INT 6ah)\r
5ffcd257 717IRQ2_SEL = .-IDT_BASE\r
718 .short 0 # offset 15:0\r
719 .short SYS_CODE_SEL # selector 15:0\r
720 .byte 0 # 0 for interrupt gate\r
721 .byte 0x0e | 0x80 # (10001110)type = 386 interrupt gate, present\r
722 .short 0 # offset 31:16\r
6794a1b9 723\r
724# IRQ 3 (COM 2) - (INT 6bh)\r
5ffcd257 725IRQ3_SEL = .-IDT_BASE\r
726 .short 0 # offset 15:0\r
727 .short SYS_CODE_SEL # selector 15:0\r
728 .byte 0 # 0 for interrupt gate\r
729 .byte 0x0e | 0x80 # (10001110)type = 386 interrupt gate, present\r
730 .short 0 # offset 31:16\r
6794a1b9 731\r
732# IRQ 4 (COM 1) - (INT 6ch)\r
5ffcd257 733IRQ4_SEL = .-IDT_BASE\r
734 .short 0 # offset 15:0\r
735 .short SYS_CODE_SEL # selector 15:0\r
736 .byte 0 # 0 for interrupt gate\r
737 .byte 0x0e | 0x80 # (10001110)type = 386 interrupt gate, present\r
738 .short 0 # offset 31:16\r
6794a1b9 739\r
740# IRQ 5 (LPT 2) - (INT 6dh)\r
5ffcd257 741IRQ5_SEL = .-IDT_BASE\r
742 .short 0 # offset 15:0\r
743 .short SYS_CODE_SEL # selector 15:0\r
744 .byte 0 # 0 for interrupt gate\r
745 .byte 0x0e | 0x80 # (10001110)type = 386 interrupt gate, present\r
746 .short 0 # offset 31:16\r
6794a1b9 747\r
748# IRQ 6 (Floppy controller) - (INT 6eh)\r
5ffcd257 749IRQ6_SEL = .-IDT_BASE\r
750 .short 0 # offset 15:0\r
751 .short SYS_CODE_SEL # selector 15:0\r
752 .byte 0 # 0 for interrupt gate\r
753 .byte 0x0e | 0x80 # (10001110)type = 386 interrupt gate, present\r
754 .short 0 # offset 31:16\r
6794a1b9 755\r
756# IRQ 7 (LPT 1) - (INT 6fh)\r
5ffcd257 757IRQ7_SEL = .-IDT_BASE\r
758 .short 0 # offset 15:0\r
759 .short SYS_CODE_SEL # selector 15:0\r
760 .byte 0 # 0 for interrupt gate\r
761 .byte 0x0e | 0x80 # (10001110)type = 386 interrupt gate, present\r
762 .short 0 # offset 31:16\r
763\r
764# IRQ 8 (RTC Alarm) - (INT 0x70)\r
765IRQ8_SEL = .-IDT_BASE\r
766 .short 0 # offset 15:0\r
767 .short SYS_CODE_SEL # selector 15:0\r
768 .byte 0 # 0 for interrupt gate\r
769 .byte 0x0e | 0x80 # (10001110)type = 386 interrupt gate, present\r
770 .short 0 # offset 31:16\r
771\r
772# IRQ 9 - (INT 0x71)\r
773IRQ9_SEL = .-IDT_BASE\r
774 .short 0 # offset 15:0\r
775 .short SYS_CODE_SEL # selector 15:0\r
776 .byte 0 # 0 for interrupt gate\r
777 .byte 0x0e | 0x80 # (10001110)type = 386 interrupt gate, present\r
778 .short 0 # offset 31:16\r
779\r
780# IRQ 10 - (INT 0x72)\r
781IRQ10_SEL = .-IDT_BASE\r
782 .short 0 # offset 15:0\r
783 .short SYS_CODE_SEL # selector 15:0\r
784 .byte 0 # 0 for interrupt gate\r
785 .byte 0x0e | 0x80 # (10001110)type = 386 interrupt gate, present\r
786 .short 0 # offset 31:16\r
787\r
788# IRQ 11 - (INT 0x73)\r
789IRQ11_SEL = .-IDT_BASE\r
790 .short 0 # offset 15:0\r
791 .short SYS_CODE_SEL # selector 15:0\r
792 .byte 0 # 0 for interrupt gate\r
793 .byte 0x0e | 0x80 # (10001110)type = 386 interrupt gate, present\r
794 .short 0 # offset 31:16\r
795\r
796# IRQ 12 (PS/2 mouse) - (INT 0x74)\r
797IRQ12_SEL = .-IDT_BASE\r
798 .short 0 # offset 15:0\r
799 .short SYS_CODE_SEL # selector 15:0\r
800 .byte 0 # 0 for interrupt gate\r
801 .byte 0x0e | 0x80 # (10001110)type = 386 interrupt gate, present\r
802 .short 0 # offset 31:16\r
803\r
804# IRQ 13 (Floating point error) - (INT 0x75)\r
805IRQ13_SEL = .-IDT_BASE\r
806 .short 0 # offset 15:0\r
807 .short SYS_CODE_SEL # selector 15:0\r
808 .byte 0 # 0 for interrupt gate\r
809 .byte 0x0e | 0x80 # (10001110)type = 386 interrupt gate, present\r
810 .short 0 # offset 31:16\r
811\r
812# IRQ 14 (Secondary IDE) - (INT 0x76)\r
813IRQ14_SEL = .-IDT_BASE\r
814 .short 0 # offset 15:0\r
815 .short SYS_CODE_SEL # selector 15:0\r
816 .byte 0 # 0 for interrupt gate\r
817 .byte 0x0e | 0x80 # (10001110)type = 386 interrupt gate, present\r
818 .short 0 # offset 31:16\r
819\r
820# IRQ 15 (Primary IDE) - (INT 0x77)\r
821IRQ15_SEL = .-IDT_BASE\r
822 .short 0 # offset 15:0\r
823 .short SYS_CODE_SEL # selector 15:0\r
824 .byte 0 # 0 for interrupt gate\r
825 .byte 0x0e | 0x80 # (10001110)type = 386 interrupt gate, present\r
826 .short 0 # offset 31:16\r
827\r
828 .rept 1 * 8\r
829 .byte 0\r
830 .endr\r
831\r
6794a1b9 832IDT_END:\r
5ffcd257 833\r