]> git.proxmox.com Git - mirror_edk2.git/blob - DuetPkg/CpuDxe/Ia32/CpuInterrupt.S
Patch for CpuInterrupt.S from Tristan Gingold.
[mirror_edk2.git] / DuetPkg / CpuDxe / Ia32 / CpuInterrupt.S
1 #------------------------------------------------------------------------------
2 #*
3 #* Copyright 2006, Intel Corporation
4 #* All rights reserved. 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 .globl ASM_PFX(mExceptionCodeSize)
28 ASM_PFX(mExceptionCodeSize): .long 9
29
30 .text
31 .globl 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 .globl 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 .align 2
82 .globl 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 .rept (32 - 20)
202 pushl $0x0 # push error code place holder on the stack
203 # push xxh # push vector number
204 .byte 0x6a
205 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number
206 JmpCommonIdtEntry
207 .endr
208
209 .globl ASM_PFX(SystemTimerHandler)
210 ASM_PFX(SystemTimerHandler):
211 pushl $0
212 pushl $mTimerVector
213 JmpCommonIdtEntry
214
215 commonIdtEntry:
216 # +---------------------+
217 # + EFlags +
218 # +---------------------+
219 # + CS +
220 # +---------------------+
221 # + EIP +
222 # +---------------------+
223 # + Error Code +
224 # +---------------------+
225 # + Vector Number +
226 # +---------------------+
227 # + EBP +
228 # +---------------------+ <-- EBP
229
230 cli
231 push %ebp
232 movl %esp,%ebp
233
234 #
235 # Align stack to make sure that EFI_FX_SAVE_STATE_IA32 of EFI_SYSTEM_CONTEXT_IA32
236 # is 16-byte aligned
237 #
238 andl $0xfffffff0,%esp
239 subl $12,%esp
240
241 ## UINT32 Edi, Esi, Ebp, Esp, Ebx, Edx, Ecx, Eax#
242 push %eax
243 push %ecx
244 push %edx
245 push %ebx
246 leal 6*4(%ebp),%ecx
247 push %ecx # ESP
248 push (%ebp) # EBP
249 push %esi
250 push %edi
251
252 ## UINT32 Gs, Fs, Es, Ds, Cs, Ss#
253 movw %ss,%ax
254 push %eax
255 movzx 4*4(%ebp),%eax
256 push %eax
257 movw %ds,%ax
258 push %eax
259 movw %es,%ax
260 push %eax
261 movw %fs,%ax
262 push %eax
263 movw %gs,%ax
264 push %eax
265
266 ## UINT32 Eip#
267 pushl 3*4(%ebp)
268
269 ## UINT32 Gdtr[2], Idtr[2]#
270 subl $8,%esp
271 sidt (%esp)
272 subl $8,%esp
273 sgdt (%esp)
274
275 ## UINT32 Ldtr, Tr#
276 xorl %eax, %eax
277 str %ax
278 push %eax
279 sldt %eax
280 push %eax
281
282 ## UINT32 EFlags#
283 pushl 5*4(%ebp)
284
285 ## UINT32 Cr0, Cr1, Cr2, Cr3, Cr4#
286 mov %cr4,%eax
287 orl $0x208,%eax
288 mov %eax,%cr4
289 push %eax
290 mov %cr3,%eax
291 push %eax
292 mov %cr2,%eax
293 push %eax
294 xor %eax, %eax
295 push %eax
296 mov %cr0,%eax
297 push %eax
298
299 ## UINT32 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7#
300 mov %dr7,%eax
301 push %eax
302 ## clear Dr7 while executing debugger itself
303 xor %eax, %eax
304 mov %eax,%dr7
305
306 mov %dr6,%eax
307 push %eax
308 ## insure all status bits in dr6 are clear...
309 xor %eax, %eax
310 mov %eax,%dr6
311
312 mov %dr3,%eax
313 push %eax
314 mov %dr2,%eax
315 push %eax
316 mov %dr1,%eax
317 push %eax
318 mov %dr0,%eax
319 push %eax
320
321 ## FX_SAVE_STATE_IA32 FxSaveState;
322 sub $512,%esp
323 mov %esp,%edi
324 fxsave (%edi)
325
326 ## UINT32 ExceptionData;
327 pushl 2*4(%ebp)
328
329 ## Prepare parameter and call
330 mov %esp,%edx
331 push %edx
332 mov 1*4(%ebp),%eax
333 push %eax
334 cmpl $32,%eax
335 jb CallException
336 call TimerHandler
337 jmp ExceptionDone
338 CallException:
339 call ExceptionHandler
340 ExceptionDone:
341 addl $8,%esp
342
343 cli
344 ## UINT32 ExceptionData;
345 addl $4,%esp
346
347 ## FX_SAVE_STATE_IA32 FxSaveState;
348 mov %esp,%esi
349 fxrstor (%esi)
350 addl $512,%esp
351
352 #; UINT32 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7;
353 pop %eax
354 mov %eax,%dr0
355 pop %eax
356 mov %eax,%dr1
357 pop %eax
358 mov %eax,%dr2
359 pop %eax
360 mov %eax,%dr3
361 ## skip restore of dr6. We cleared dr6 during the context save.
362 addl $4,%esp
363 pop %eax
364 mov %eax,%dr7
365
366 ## UINT32 Cr0, Cr1, Cr2, Cr3, Cr4;
367 pop %eax
368 mov %eax,%cr0
369 addl $4,%esp # not for Cr1
370 pop %eax
371 mov %eax,%cr2
372 pop %eax
373 mov %eax,%cr3
374 pop %eax
375 mov %eax,%cr4
376
377 ## UINT32 EFlags;
378 popl 5*4(%ebp)
379
380 ## UINT32 Ldtr, Tr;
381 ## UINT32 Gdtr[2], Idtr[2];
382 ## Best not let anyone mess with these particular registers...
383 addl $24,%esp
384
385 ## UINT32 Eip;
386 popl 3*4(%ebp)
387
388 ## UINT32 Gs, Fs, Es, Ds, Cs, Ss;
389 ## NOTE - modified segment registers could hang the debugger... We
390 ## could attempt to insulate ourselves against this possibility,
391 ## but that poses risks as well.
392 ##
393 pop %gs
394 pop %fs
395 pop %es
396 pop %ds
397 popl 4*4(%ebp)
398 pop %ss
399
400 ## UINT32 Edi, Esi, Ebp, Esp, Ebx, Edx, Ecx, Eax;
401 pop %edi
402 pop %esi
403 addl $4,%esp # not for ebp
404 addl $4,%esp # not for esp
405 pop %ebx
406 pop %edx
407 pop %ecx
408 pop %eax
409
410 mov %ebp,%esp
411 pop %ebp
412 addl $8,%esp
413 iret
414
415
416 #;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
417 # data
418 #;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
419
420 .data
421 .align 4
422
423 gdtr: .short GDT_END - GDT_BASE - 1 # GDT limit
424 .long 0 # (GDT base gets set above)
425 #;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
426 # global descriptor table (GDT)
427 #;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
428
429 .align 4
430
431 .globl GDT_BASE
432 GDT_BASE:
433 # null descriptor
434 NULL_SEL = .-GDT_BASE
435 .short 0 # limit 15:0
436 .short 0 # base 15:0
437 .byte 0 # base 23:16
438 .byte 0 # type
439 .byte 0 # limit 19:16, flags
440 .byte 0 # base 31:24
441
442 # linear data segment descriptor
443 LINEAR_SEL = .-GDT_BASE
444 .short 0x0FFFF # limit 0xFFFFF
445 .short 0 # base 0
446 .byte 0
447 .byte 0x092 # present, ring 0, data, expand-up, writable
448 .byte 0x0CF # page-granular, 32-bit
449 .byte 0
450
451 # linear code segment descriptor
452 LINEAR_CODE_SEL = .-GDT_BASE
453 .short 0x0FFFF # limit 0xFFFFF
454 .short 0 # base 0
455 .byte 0
456 .byte 0x09A # present, ring 0, data, expand-up, writable
457 .byte 0x0CF # page-granular, 32-bit
458 .byte 0
459
460 # system data segment descriptor
461 SYS_DATA_SEL = .-GDT_BASE
462 .short 0x0FFFF # limit 0xFFFFF
463 .short 0 # base 0
464 .byte 0
465 .byte 0x092 # present, ring 0, data, expand-up, writable
466 .byte 0x0CF # page-granular, 32-bit
467 .byte 0
468
469 # system code segment descriptor
470 SYS_CODE_SEL = .-GDT_BASE
471 .short 0x0FFFF # limit 0xFFFFF
472 .short 0 # base 0
473 .byte 0
474 .byte 0x09A # present, ring 0, data, expand-up, writable
475 .byte 0x0CF # page-granular, 32-bit
476 .byte 0
477
478 # spare segment descriptor
479 SPARE3_SEL = .-GDT_BASE
480 .short 0 # limit 0xFFFFF
481 .short 0 # base 0
482 .byte 0
483 .byte 0 # present, ring 0, data, expand-up, writable
484 .byte 0 # page-granular, 32-bit
485 .byte 0
486
487 # spare segment descriptor
488 SPARE4_SEL = .-GDT_BASE
489 .short 0 # limit 0xFFFFF
490 .short 0 # base 0
491 .byte 0
492 .byte 0 # present, ring 0, data, expand-up, writable
493 .byte 0 # page-granular, 32-bit
494 .byte 0
495
496 # spare segment descriptor
497 SPARE5_SEL = .-GDT_BASE
498 .short 0 # limit 0xFFFFF
499 .short 0 # base 0
500 .byte 0
501 .byte 0 # present, ring 0, data, expand-up, writable
502 .byte 0 # page-granular, 32-bit
503 .byte 0
504
505 GDT_END:
506
507 .align 4
508
509
510
511 idtr: .short IDT_END - IDT_BASE - 1 # IDT limit
512 .long 0 # (IDT base gets set above)
513 #;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
514 # interrupt descriptor table (IDT)
515 #
516 # Note: The hardware IRQ's specified in this table are the normal PC/AT IRQ
517 # mappings. This implementation only uses the system timer and all other
518 # IRQs will remain masked. The descriptors for vectors 33+ are provided
519 # for convenience.
520 #;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
521
522 #idt_tag .byte "IDT",0
523 .align 4
524
525 .globl IDT_BASE
526 IDT_BASE:
527 # divide by zero (INT 0)
528 DIV_ZERO_SEL = .-IDT_BASE
529 .short 0 # offset 15:0
530 .short SYS_CODE_SEL # selector 15:0
531 .byte 0 # 0 for interrupt gate
532 .byte 0x0e | 0x80 # type = 386 interrupt gate, present
533 .short 0 # offset 31:16
534
535 # debug exception (INT 1)
536 DEBUG_EXCEPT_SEL = .-IDT_BASE
537 .short 0 # offset 15:0
538 .short SYS_CODE_SEL # selector 15:0
539 .byte 0 # 0 for interrupt gate
540 .byte 0x0e | 0x80 # type = 386 interrupt gate, present
541 .short 0 # offset 31:16
542
543 # NMI (INT 2)
544 NMI_SEL = .-IDT_BASE
545 .short 0 # offset 15:0
546 .short SYS_CODE_SEL # selector 15:0
547 .byte 0 # 0 for interrupt gate
548 .byte 0x0e | 0x80 # type = 386 interrupt gate, present
549 .short 0 # offset 31:16
550
551 # soft breakpoint (INT 3)
552 BREAKPOINT_SEL = .-IDT_BASE
553 .short 0 # offset 15:0
554 .short SYS_CODE_SEL # selector 15:0
555 .byte 0 # 0 for interrupt gate
556 .byte 0x0e | 0x80 # type = 386 interrupt gate, present
557 .short 0 # offset 31:16
558
559 # overflow (INT 4)
560 OVERFLOW_SEL = .-IDT_BASE
561 .short 0 # offset 15:0
562 .short SYS_CODE_SEL # selector 15:0
563 .byte 0 # 0 for interrupt gate
564 .byte 0x0e | 0x80 # type = 386 interrupt gate, present
565 .short 0 # offset 31:16
566
567 # bounds check (INT 5)
568 BOUNDS_CHECK_SEL = .-IDT_BASE
569 .short 0 # offset 15:0
570 .short SYS_CODE_SEL # selector 15:0
571 .byte 0 # 0 for interrupt gate
572 .byte 0x0e | 0x80 # type = 386 interrupt gate, present
573 .short 0 # offset 31:16
574
575 # invalid opcode (INT 6)
576 INVALID_OPCODE_SEL = .-IDT_BASE
577 .short 0 # offset 15:0
578 .short SYS_CODE_SEL # selector 15:0
579 .byte 0 # 0 for interrupt gate
580 .byte 0x0e | 0x80 # type = 386 interrupt gate, present
581 .short 0 # offset 31:16
582
583 # device not available (INT 7)
584 DEV_NOT_AVAIL_SEL = .-IDT_BASE
585 .short 0 # offset 15:0
586 .short SYS_CODE_SEL # selector 15:0
587 .byte 0 # 0 for interrupt gate
588 .byte 0x0e | 0x80 # type = 386 interrupt gate, present
589 .short 0 # offset 31:16
590
591 # double fault (INT 8)
592 DOUBLE_FAULT_SEL = .-IDT_BASE
593 .short 0 # offset 15:0
594 .short SYS_CODE_SEL # selector 15:0
595 .byte 0 # 0 for interrupt gate
596 .byte 0x0e | 0x80 # type = 386 interrupt gate, present
597 .short 0 # offset 31:16
598
599 # Coprocessor segment overrun - reserved (INT 9)
600 RSVD_INTR_SEL1 = .-IDT_BASE
601 .short 0 # offset 15:0
602 .short SYS_CODE_SEL # selector 15:0
603 .byte 0 # 0 for interrupt gate
604 .byte 0x0e | 0x80 # type = 386 interrupt gate, present
605 .short 0 # offset 31:16
606
607 # invalid TSS (INT 0ah)
608 INVALID_TSS_SEL = .-IDT_BASE
609 .short 0 # offset 15:0
610 .short SYS_CODE_SEL # selector 15:0
611 .byte 0 # 0 for interrupt gate
612 .byte 0x0e | 0x80 # type = 386 interrupt gate, present
613 .short 0 # offset 31:16
614
615 # segment not present (INT 0bh)
616 SEG_NOT_PRESENT_SEL = .-IDT_BASE
617 .short 0 # offset 15:0
618 .short SYS_CODE_SEL # selector 15:0
619 .byte 0 # 0 for interrupt gate
620 .byte 0x0e | 0x80 # type = 386 interrupt gate, present
621 .short 0 # offset 31:16
622
623 # stack fault (INT 0ch)
624 STACK_FAULT_SEL = .-IDT_BASE
625 .short 0 # offset 15:0
626 .short SYS_CODE_SEL # selector 15:0
627 .byte 0 # 0 for interrupt gate
628 .byte 0x0e | 0x80 # type = 386 interrupt gate, present
629 .short 0 # offset 31:16
630
631 # general protection (INT 0dh)
632 GP_FAULT_SEL = .-IDT_BASE
633 .short 0 # offset 15:0
634 .short SYS_CODE_SEL # selector 15:0
635 .byte 0 # 0 for interrupt gate
636 .byte 0x0e | 0x80 # type = 386 interrupt gate, present
637 .short 0 # offset 31:16
638
639 # page fault (INT 0eh)
640 PAGE_FAULT_SEL = .-IDT_BASE
641 .short 0 # offset 15:0
642 .short SYS_CODE_SEL # selector 15:0
643 .byte 0 # 0 for interrupt gate
644 .byte 0x0e | 0x80 # type = 386 interrupt gate, present
645 .short 0 # offset 31:16
646
647 # Intel reserved - do not use (INT 0fh)
648 RSVD_INTR_SEL2 = .-IDT_BASE
649 .short 0 # offset 15:0
650 .short SYS_CODE_SEL # selector 15:0
651 .byte 0 # 0 for interrupt gate
652 .byte 0x0e | 0x80 # type = 386 interrupt gate, present
653 .short 0 # offset 31:16
654
655 # floating point error (INT 0x10)
656 FLT_POINT_ERR_SEL = .-IDT_BASE
657 .short 0 # offset 15:0
658 .short SYS_CODE_SEL # selector 15:0
659 .byte 0 # 0 for interrupt gate
660 .byte 0x0e | 0x80 # type = 386 interrupt gate, present
661 .short 0 # offset 31:16
662
663 # alignment check (INT 0x11)
664 ALIGNMENT_CHECK_SEL = .-IDT_BASE
665 .short 0 # offset 15:0
666 .short SYS_CODE_SEL # selector 15:0
667 .byte 0 # 0 for interrupt gate
668 .byte 0x0e | 0x80 # (10001110)type = 386 interrupt gate, present
669 .short 0 # offset 31:16
670
671 # machine check (INT 0x12)
672 MACHINE_CHECK_SEL = .-IDT_BASE
673 .short 0 # offset 15:0
674 .short SYS_CODE_SEL # selector 15:0
675 .byte 0 # 0 for interrupt gate
676 .byte 0x0e | 0x80 # (10001110)type = 386 interrupt gate, present
677 .short 0 # offset 31:16
678
679 # SIMD floating-point exception (INT 0x13)
680 SIMD_EXCEPTION_SEL = .-IDT_BASE
681 .short 0 # offset 15:0
682 .short SYS_CODE_SEL # selector 15:0
683 .byte 0 # 0 for interrupt gate
684 .byte 0x0e | 0x80 # (10001110)type = 386 interrupt gate, present
685 .short 0 # offset 31:16
686
687 .rept (32 - 20)
688 .short 0 # offset 15:0
689 .short SYS_CODE_SEL # selector 15:0
690 .byte 0 # 0 for interrupt gate
691 .byte 0x0e | 0x80 # (10001110)type = 386 interrupt gate, present
692 .short 0 # offset 31:16
693 .endr
694
695 # 72 unspecified descriptors
696 .rept 72 * 8
697 .byte 0
698 .endr
699
700 # IRQ 0 (System timer) - (INT 0x68)
701 IRQ0_SEL = .-IDT_BASE
702 .short 0 # offset 15:0
703 .short SYS_CODE_SEL # selector 15:0
704 .byte 0 # 0 for interrupt gate
705 .byte 0x0e | 0x80 # (10001110)type = 386 interrupt gate, present
706 .short 0 # offset 31:16
707
708 # IRQ 1 (8042 Keyboard controller) - (INT 0x69)
709 IRQ1_SEL = .-IDT_BASE
710 .short 0 # offset 15:0
711 .short SYS_CODE_SEL # selector 15:0
712 .byte 0 # 0 for interrupt gate
713 .byte 0x0e | 0x80 # (10001110)type = 386 interrupt gate, present
714 .short 0 # offset 31:16
715
716 # Reserved - IRQ 2 redirect (IRQ 2) - DO NOT USE!!! - (INT 6ah)
717 IRQ2_SEL = .-IDT_BASE
718 .short 0 # offset 15:0
719 .short SYS_CODE_SEL # selector 15:0
720 .byte 0 # 0 for interrupt gate
721 .byte 0x0e | 0x80 # (10001110)type = 386 interrupt gate, present
722 .short 0 # offset 31:16
723
724 # IRQ 3 (COM 2) - (INT 6bh)
725 IRQ3_SEL = .-IDT_BASE
726 .short 0 # offset 15:0
727 .short SYS_CODE_SEL # selector 15:0
728 .byte 0 # 0 for interrupt gate
729 .byte 0x0e | 0x80 # (10001110)type = 386 interrupt gate, present
730 .short 0 # offset 31:16
731
732 # IRQ 4 (COM 1) - (INT 6ch)
733 IRQ4_SEL = .-IDT_BASE
734 .short 0 # offset 15:0
735 .short SYS_CODE_SEL # selector 15:0
736 .byte 0 # 0 for interrupt gate
737 .byte 0x0e | 0x80 # (10001110)type = 386 interrupt gate, present
738 .short 0 # offset 31:16
739
740 # IRQ 5 (LPT 2) - (INT 6dh)
741 IRQ5_SEL = .-IDT_BASE
742 .short 0 # offset 15:0
743 .short SYS_CODE_SEL # selector 15:0
744 .byte 0 # 0 for interrupt gate
745 .byte 0x0e | 0x80 # (10001110)type = 386 interrupt gate, present
746 .short 0 # offset 31:16
747
748 # IRQ 6 (Floppy controller) - (INT 6eh)
749 IRQ6_SEL = .-IDT_BASE
750 .short 0 # offset 15:0
751 .short SYS_CODE_SEL # selector 15:0
752 .byte 0 # 0 for interrupt gate
753 .byte 0x0e | 0x80 # (10001110)type = 386 interrupt gate, present
754 .short 0 # offset 31:16
755
756 # IRQ 7 (LPT 1) - (INT 6fh)
757 IRQ7_SEL = .-IDT_BASE
758 .short 0 # offset 15:0
759 .short SYS_CODE_SEL # selector 15:0
760 .byte 0 # 0 for interrupt gate
761 .byte 0x0e | 0x80 # (10001110)type = 386 interrupt gate, present
762 .short 0 # offset 31:16
763
764 # IRQ 8 (RTC Alarm) - (INT 0x70)
765 IRQ8_SEL = .-IDT_BASE
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
772 # IRQ 9 - (INT 0x71)
773 IRQ9_SEL = .-IDT_BASE
774 .short 0 # offset 15:0
775 .short SYS_CODE_SEL # selector 15:0
776 .byte 0 # 0 for interrupt gate
777 .byte 0x0e | 0x80 # (10001110)type = 386 interrupt gate, present
778 .short 0 # offset 31:16
779
780 # IRQ 10 - (INT 0x72)
781 IRQ10_SEL = .-IDT_BASE
782 .short 0 # offset 15:0
783 .short SYS_CODE_SEL # selector 15:0
784 .byte 0 # 0 for interrupt gate
785 .byte 0x0e | 0x80 # (10001110)type = 386 interrupt gate, present
786 .short 0 # offset 31:16
787
788 # IRQ 11 - (INT 0x73)
789 IRQ11_SEL = .-IDT_BASE
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
796 # IRQ 12 (PS/2 mouse) - (INT 0x74)
797 IRQ12_SEL = .-IDT_BASE
798 .short 0 # offset 15:0
799 .short SYS_CODE_SEL # selector 15:0
800 .byte 0 # 0 for interrupt gate
801 .byte 0x0e | 0x80 # (10001110)type = 386 interrupt gate, present
802 .short 0 # offset 31:16
803
804 # IRQ 13 (Floating point error) - (INT 0x75)
805 IRQ13_SEL = .-IDT_BASE
806 .short 0 # offset 15:0
807 .short SYS_CODE_SEL # selector 15:0
808 .byte 0 # 0 for interrupt gate
809 .byte 0x0e | 0x80 # (10001110)type = 386 interrupt gate, present
810 .short 0 # offset 31:16
811
812 # IRQ 14 (Secondary IDE) - (INT 0x76)
813 IRQ14_SEL = .-IDT_BASE
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
820 # IRQ 15 (Primary IDE) - (INT 0x77)
821 IRQ15_SEL = .-IDT_BASE
822 .short 0 # offset 15:0
823 .short SYS_CODE_SEL # selector 15:0
824 .byte 0 # 0 for interrupt gate
825 .byte 0x0e | 0x80 # (10001110)type = 386 interrupt gate, present
826 .short 0 # offset 31:16
827
828 .rept 1 * 8
829 .byte 0
830 .endr
831
832 IDT_END:
833