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