1
2 #include <freeldr.h>
3
4
5 KIDTENTRY DECLSPEC_ALIGN(4) i386Idt[32];
6 KDESCRIPTOR i386IdtDescriptor = {0, 255, (ULONG)i386Idt};
7
8 static
9 void
InitIdtVector(UCHAR Vector,PVOID ServiceHandler,USHORT Access)10 InitIdtVector(
11 UCHAR Vector,
12 PVOID ServiceHandler,
13 USHORT Access)
14 {
15 i386Idt[Vector].Offset = (ULONG)ServiceHandler & 0xffff;
16 i386Idt[Vector].ExtendedOffset = (ULONG)ServiceHandler >> 16;
17 i386Idt[Vector].Selector = PMODE_CS;
18 i386Idt[Vector].Access = Access;
19 }
20
21 void
22 __cdecl
InitIdt(void)23 InitIdt(void)
24 {
25 InitIdtVector(0, i386DivideByZero, 0x8e00);
26 InitIdtVector(1, i386DebugException, 0x8e00);
27 InitIdtVector(2, i386NMIException, 0x8e00);
28 InitIdtVector(3, i386Breakpoint, 0x8e00);
29 InitIdtVector(4, i386Overflow, 0x8e00);
30 InitIdtVector(5, i386BoundException, 0x8e00);
31 InitIdtVector(6, i386InvalidOpcode, 0x8e00);
32 InitIdtVector(7, i386FPUNotAvailable, 0x8e00);
33 InitIdtVector(8, i386DoubleFault, 0x8e00);
34 InitIdtVector(9, i386CoprocessorSegment, 0x8e00);
35 InitIdtVector(10, i386InvalidTSS, 0x8e00);
36 InitIdtVector(11, i386SegmentNotPresent, 0x8e00);
37 InitIdtVector(12, i386StackException, 0x8e00);
38 InitIdtVector(13, i386GeneralProtectionFault, 0x8e00);
39 InitIdtVector(14, i386PageFault, 0x8e00);
40 InitIdtVector(16, i386CoprocessorError, 0x8e00);
41 InitIdtVector(17, i386AlignmentCheck, 0x8e00);
42 InitIdtVector(18, i386MachineCheck, 0x8e00);
43 }
44