]> git.proxmox.com Git - mirror_edk2.git/blob - DuetPkg/CpuDxe/Ia32/CpuInterrupt.S
Linkage errors fixed.
[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 $ASM_PFX(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 ASM_PFX(TimerHandler)
337 jmp ExceptionDone
338 CallException:
339 call ASM_PFX(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 GDT_BASE:
432 # null descriptor
433 NULL_SEL = .-GDT_BASE
434 .short 0 # limit 15:0
435 .short 0 # base 15:0
436 .byte 0 # base 23:16
437 .byte 0 # type
438 .byte 0 # limit 19:16, flags
439 .byte 0 # base 31:24
440
441 # linear data segment descriptor
442 LINEAR_SEL = .-GDT_BASE
443 .short 0x0FFFF # limit 0xFFFFF
444 .short 0 # base 0
445 .byte 0
446 .byte 0x092 # present, ring 0, data, expand-up, writable
447 .byte 0x0CF # page-granular, 32-bit
448 .byte 0
449
450 # linear code segment descriptor
451 LINEAR_CODE_SEL = .-GDT_BASE
452 .short 0x0FFFF # limit 0xFFFFF
453 .short 0 # base 0
454 .byte 0
455 .byte 0x09A # present, ring 0, data, expand-up, writable
456 .byte 0x0CF # page-granular, 32-bit
457 .byte 0
458
459 # system data segment descriptor
460 SYS_DATA_SEL = .-GDT_BASE
461 .short 0x0FFFF # limit 0xFFFFF
462 .short 0 # base 0
463 .byte 0
464 .byte 0x092 # present, ring 0, data, expand-up, writable
465 .byte 0x0CF # page-granular, 32-bit
466 .byte 0
467
468 # system code segment descriptor
469 SYS_CODE_SEL = .-GDT_BASE
470 .short 0x0FFFF # limit 0xFFFFF
471 .short 0 # base 0
472 .byte 0
473 .byte 0x09A # present, ring 0, data, expand-up, writable
474 .byte 0x0CF # page-granular, 32-bit
475 .byte 0
476
477 # spare segment descriptor
478 SPARE3_SEL = .-GDT_BASE
479 .short 0 # limit 0xFFFFF
480 .short 0 # base 0
481 .byte 0
482 .byte 0 # present, ring 0, data, expand-up, writable
483 .byte 0 # page-granular, 32-bit
484 .byte 0
485
486 # spare segment descriptor
487 SPARE4_SEL = .-GDT_BASE
488 .short 0 # limit 0xFFFFF
489 .short 0 # base 0
490 .byte 0
491 .byte 0 # present, ring 0, data, expand-up, writable
492 .byte 0 # page-granular, 32-bit
493 .byte 0
494
495 # spare segment descriptor
496 SPARE5_SEL = .-GDT_BASE
497 .short 0 # limit 0xFFFFF
498 .short 0 # base 0
499 .byte 0
500 .byte 0 # present, ring 0, data, expand-up, writable
501 .byte 0 # page-granular, 32-bit
502 .byte 0
503
504 GDT_END:
505
506 .align 4
507
508
509
510 idtr: .short IDT_END - IDT_BASE - 1 # IDT limit
511 .long 0 # (IDT base gets set above)
512 #;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
513 # interrupt descriptor table (IDT)
514 #
515 # Note: The hardware IRQ's specified in this table are the normal PC/AT IRQ
516 # mappings. This implementation only uses the system timer and all other
517 # IRQs will remain masked. The descriptors for vectors 33+ are provided
518 # for convenience.
519 #;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
520
521 #idt_tag .byte "IDT",0
522 .align 4
523
524 IDT_BASE:
525 # divide by zero (INT 0)
526 DIV_ZERO_SEL = .-IDT_BASE
527 .short 0 # offset 15:0
528 .short SYS_CODE_SEL # selector 15:0
529 .byte 0 # 0 for interrupt gate
530 .byte 0x0e | 0x80 # type = 386 interrupt gate, present
531 .short 0 # offset 31:16
532
533 # debug exception (INT 1)
534 DEBUG_EXCEPT_SEL = .-IDT_BASE
535 .short 0 # offset 15:0
536 .short SYS_CODE_SEL # selector 15:0
537 .byte 0 # 0 for interrupt gate
538 .byte 0x0e | 0x80 # type = 386 interrupt gate, present
539 .short 0 # offset 31:16
540
541 # NMI (INT 2)
542 NMI_SEL = .-IDT_BASE
543 .short 0 # offset 15:0
544 .short SYS_CODE_SEL # selector 15:0
545 .byte 0 # 0 for interrupt gate
546 .byte 0x0e | 0x80 # type = 386 interrupt gate, present
547 .short 0 # offset 31:16
548
549 # soft breakpoint (INT 3)
550 BREAKPOINT_SEL = .-IDT_BASE
551 .short 0 # offset 15:0
552 .short SYS_CODE_SEL # selector 15:0
553 .byte 0 # 0 for interrupt gate
554 .byte 0x0e | 0x80 # type = 386 interrupt gate, present
555 .short 0 # offset 31:16
556
557 # overflow (INT 4)
558 OVERFLOW_SEL = .-IDT_BASE
559 .short 0 # offset 15:0
560 .short SYS_CODE_SEL # selector 15:0
561 .byte 0 # 0 for interrupt gate
562 .byte 0x0e | 0x80 # type = 386 interrupt gate, present
563 .short 0 # offset 31:16
564
565 # bounds check (INT 5)
566 BOUNDS_CHECK_SEL = .-IDT_BASE
567 .short 0 # offset 15:0
568 .short SYS_CODE_SEL # selector 15:0
569 .byte 0 # 0 for interrupt gate
570 .byte 0x0e | 0x80 # type = 386 interrupt gate, present
571 .short 0 # offset 31:16
572
573 # invalid opcode (INT 6)
574 INVALID_OPCODE_SEL = .-IDT_BASE
575 .short 0 # offset 15:0
576 .short SYS_CODE_SEL # selector 15:0
577 .byte 0 # 0 for interrupt gate
578 .byte 0x0e | 0x80 # type = 386 interrupt gate, present
579 .short 0 # offset 31:16
580
581 # device not available (INT 7)
582 DEV_NOT_AVAIL_SEL = .-IDT_BASE
583 .short 0 # offset 15:0
584 .short SYS_CODE_SEL # selector 15:0
585 .byte 0 # 0 for interrupt gate
586 .byte 0x0e | 0x80 # type = 386 interrupt gate, present
587 .short 0 # offset 31:16
588
589 # double fault (INT 8)
590 DOUBLE_FAULT_SEL = .-IDT_BASE
591 .short 0 # offset 15:0
592 .short SYS_CODE_SEL # selector 15:0
593 .byte 0 # 0 for interrupt gate
594 .byte 0x0e | 0x80 # type = 386 interrupt gate, present
595 .short 0 # offset 31:16
596
597 # Coprocessor segment overrun - reserved (INT 9)
598 RSVD_INTR_SEL1 = .-IDT_BASE
599 .short 0 # offset 15:0
600 .short SYS_CODE_SEL # selector 15:0
601 .byte 0 # 0 for interrupt gate
602 .byte 0x0e | 0x80 # type = 386 interrupt gate, present
603 .short 0 # offset 31:16
604
605 # invalid TSS (INT 0ah)
606 INVALID_TSS_SEL = .-IDT_BASE
607 .short 0 # offset 15:0
608 .short SYS_CODE_SEL # selector 15:0
609 .byte 0 # 0 for interrupt gate
610 .byte 0x0e | 0x80 # type = 386 interrupt gate, present
611 .short 0 # offset 31:16
612
613 # segment not present (INT 0bh)
614 SEG_NOT_PRESENT_SEL = .-IDT_BASE
615 .short 0 # offset 15:0
616 .short SYS_CODE_SEL # selector 15:0
617 .byte 0 # 0 for interrupt gate
618 .byte 0x0e | 0x80 # type = 386 interrupt gate, present
619 .short 0 # offset 31:16
620
621 # stack fault (INT 0ch)
622 STACK_FAULT_SEL = .-IDT_BASE
623 .short 0 # offset 15:0
624 .short SYS_CODE_SEL # selector 15:0
625 .byte 0 # 0 for interrupt gate
626 .byte 0x0e | 0x80 # type = 386 interrupt gate, present
627 .short 0 # offset 31:16
628
629 # general protection (INT 0dh)
630 GP_FAULT_SEL = .-IDT_BASE
631 .short 0 # offset 15:0
632 .short SYS_CODE_SEL # selector 15:0
633 .byte 0 # 0 for interrupt gate
634 .byte 0x0e | 0x80 # type = 386 interrupt gate, present
635 .short 0 # offset 31:16
636
637 # page fault (INT 0eh)
638 PAGE_FAULT_SEL = .-IDT_BASE
639 .short 0 # offset 15:0
640 .short SYS_CODE_SEL # selector 15:0
641 .byte 0 # 0 for interrupt gate
642 .byte 0x0e | 0x80 # type = 386 interrupt gate, present
643 .short 0 # offset 31:16
644
645 # Intel reserved - do not use (INT 0fh)
646 RSVD_INTR_SEL2 = .-IDT_BASE
647 .short 0 # offset 15:0
648 .short SYS_CODE_SEL # selector 15:0
649 .byte 0 # 0 for interrupt gate
650 .byte 0x0e | 0x80 # type = 386 interrupt gate, present
651 .short 0 # offset 31:16
652
653 # floating point error (INT 0x10)
654 FLT_POINT_ERR_SEL = .-IDT_BASE
655 .short 0 # offset 15:0
656 .short SYS_CODE_SEL # selector 15:0
657 .byte 0 # 0 for interrupt gate
658 .byte 0x0e | 0x80 # type = 386 interrupt gate, present
659 .short 0 # offset 31:16
660
661 # alignment check (INT 0x11)
662 ALIGNMENT_CHECK_SEL = .-IDT_BASE
663 .short 0 # offset 15:0
664 .short SYS_CODE_SEL # selector 15:0
665 .byte 0 # 0 for interrupt gate
666 .byte 0x0e | 0x80 # (10001110)type = 386 interrupt gate, present
667 .short 0 # offset 31:16
668
669 # machine check (INT 0x12)
670 MACHINE_CHECK_SEL = .-IDT_BASE
671 .short 0 # offset 15:0
672 .short SYS_CODE_SEL # selector 15:0
673 .byte 0 # 0 for interrupt gate
674 .byte 0x0e | 0x80 # (10001110)type = 386 interrupt gate, present
675 .short 0 # offset 31:16
676
677 # SIMD floating-point exception (INT 0x13)
678 SIMD_EXCEPTION_SEL = .-IDT_BASE
679 .short 0 # offset 15:0
680 .short SYS_CODE_SEL # selector 15:0
681 .byte 0 # 0 for interrupt gate
682 .byte 0x0e | 0x80 # (10001110)type = 386 interrupt gate, present
683 .short 0 # offset 31:16
684
685 .rept (32 - 20)
686 .short 0 # offset 15:0
687 .short SYS_CODE_SEL # selector 15:0
688 .byte 0 # 0 for interrupt gate
689 .byte 0x0e | 0x80 # (10001110)type = 386 interrupt gate, present
690 .short 0 # offset 31:16
691 .endr
692
693 # 72 unspecified descriptors
694 .rept 72 * 8
695 .byte 0
696 .endr
697
698 # IRQ 0 (System timer) - (INT 0x68)
699 IRQ0_SEL = .-IDT_BASE
700 .short 0 # offset 15:0
701 .short SYS_CODE_SEL # selector 15:0
702 .byte 0 # 0 for interrupt gate
703 .byte 0x0e | 0x80 # (10001110)type = 386 interrupt gate, present
704 .short 0 # offset 31:16
705
706 # IRQ 1 (8042 Keyboard controller) - (INT 0x69)
707 IRQ1_SEL = .-IDT_BASE
708 .short 0 # offset 15:0
709 .short SYS_CODE_SEL # selector 15:0
710 .byte 0 # 0 for interrupt gate
711 .byte 0x0e | 0x80 # (10001110)type = 386 interrupt gate, present
712 .short 0 # offset 31:16
713
714 # Reserved - IRQ 2 redirect (IRQ 2) - DO NOT USE!!! - (INT 6ah)
715 IRQ2_SEL = .-IDT_BASE
716 .short 0 # offset 15:0
717 .short SYS_CODE_SEL # selector 15:0
718 .byte 0 # 0 for interrupt gate
719 .byte 0x0e | 0x80 # (10001110)type = 386 interrupt gate, present
720 .short 0 # offset 31:16
721
722 # IRQ 3 (COM 2) - (INT 6bh)
723 IRQ3_SEL = .-IDT_BASE
724 .short 0 # offset 15:0
725 .short SYS_CODE_SEL # selector 15:0
726 .byte 0 # 0 for interrupt gate
727 .byte 0x0e | 0x80 # (10001110)type = 386 interrupt gate, present
728 .short 0 # offset 31:16
729
730 # IRQ 4 (COM 1) - (INT 6ch)
731 IRQ4_SEL = .-IDT_BASE
732 .short 0 # offset 15:0
733 .short SYS_CODE_SEL # selector 15:0
734 .byte 0 # 0 for interrupt gate
735 .byte 0x0e | 0x80 # (10001110)type = 386 interrupt gate, present
736 .short 0 # offset 31:16
737
738 # IRQ 5 (LPT 2) - (INT 6dh)
739 IRQ5_SEL = .-IDT_BASE
740 .short 0 # offset 15:0
741 .short SYS_CODE_SEL # selector 15:0
742 .byte 0 # 0 for interrupt gate
743 .byte 0x0e | 0x80 # (10001110)type = 386 interrupt gate, present
744 .short 0 # offset 31:16
745
746 # IRQ 6 (Floppy controller) - (INT 6eh)
747 IRQ6_SEL = .-IDT_BASE
748 .short 0 # offset 15:0
749 .short SYS_CODE_SEL # selector 15:0
750 .byte 0 # 0 for interrupt gate
751 .byte 0x0e | 0x80 # (10001110)type = 386 interrupt gate, present
752 .short 0 # offset 31:16
753
754 # IRQ 7 (LPT 1) - (INT 6fh)
755 IRQ7_SEL = .-IDT_BASE
756 .short 0 # offset 15:0
757 .short SYS_CODE_SEL # selector 15:0
758 .byte 0 # 0 for interrupt gate
759 .byte 0x0e | 0x80 # (10001110)type = 386 interrupt gate, present
760 .short 0 # offset 31:16
761
762 # IRQ 8 (RTC Alarm) - (INT 0x70)
763 IRQ8_SEL = .-IDT_BASE
764 .short 0 # offset 15:0
765 .short SYS_CODE_SEL # selector 15:0
766 .byte 0 # 0 for interrupt gate
767 .byte 0x0e | 0x80 # (10001110)type = 386 interrupt gate, present
768 .short 0 # offset 31:16
769
770 # IRQ 9 - (INT 0x71)
771 IRQ9_SEL = .-IDT_BASE
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
778 # IRQ 10 - (INT 0x72)
779 IRQ10_SEL = .-IDT_BASE
780 .short 0 # offset 15:0
781 .short SYS_CODE_SEL # selector 15:0
782 .byte 0 # 0 for interrupt gate
783 .byte 0x0e | 0x80 # (10001110)type = 386 interrupt gate, present
784 .short 0 # offset 31:16
785
786 # IRQ 11 - (INT 0x73)
787 IRQ11_SEL = .-IDT_BASE
788 .short 0 # offset 15:0
789 .short SYS_CODE_SEL # selector 15:0
790 .byte 0 # 0 for interrupt gate
791 .byte 0x0e | 0x80 # (10001110)type = 386 interrupt gate, present
792 .short 0 # offset 31:16
793
794 # IRQ 12 (PS/2 mouse) - (INT 0x74)
795 IRQ12_SEL = .-IDT_BASE
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
802 # IRQ 13 (Floating point error) - (INT 0x75)
803 IRQ13_SEL = .-IDT_BASE
804 .short 0 # offset 15:0
805 .short SYS_CODE_SEL # selector 15:0
806 .byte 0 # 0 for interrupt gate
807 .byte 0x0e | 0x80 # (10001110)type = 386 interrupt gate, present
808 .short 0 # offset 31:16
809
810 # IRQ 14 (Secondary IDE) - (INT 0x76)
811 IRQ14_SEL = .-IDT_BASE
812 .short 0 # offset 15:0
813 .short SYS_CODE_SEL # selector 15:0
814 .byte 0 # 0 for interrupt gate
815 .byte 0x0e | 0x80 # (10001110)type = 386 interrupt gate, present
816 .short 0 # offset 31:16
817
818 # IRQ 15 (Primary IDE) - (INT 0x77)
819 IRQ15_SEL = .-IDT_BASE
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 .rept 1 * 8
827 .byte 0
828 .endr
829
830 IDT_END:
831