hal/halx86/apic/halinit.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/hal/halx86/apic/halinit.c b/hal/halx86/apic/halinit.c index 3143175..487e864 100644 --- a/hal/halx86/apic/halinit.c +++ b/hal/halx86/apic/halinit.c @@ -20,6 +20,36 @@ ApicInitializeLocalApic(ULONG Cpu); VOID NTAPI +HalInitApicInterruptHandlers(VOID) +{ +#ifdef _M_IX86 + KDESCRIPTOR IdtDescriptor; + PKIDTENTRY Idt; + + __sidt(&IdtDescriptor.Limit); + Idt = (PKIDTENTRY)IdtDescriptor.Base; + + /* The 0x37 vector should be PicSpuriousService37, + but it is functionally identical to ApicSpuriousService. + */ + Idt[0x37].Offset = PtrToUlong(ApicSpuriousService); + Idt[0x37].Selector = KGDT_R0_CODE; + Idt[0x37].Access = 0x8E00; + Idt[0x37].ExtendedOffset = (PtrToUlong(ApicSpuriousService) >> 16); + + Idt[0x1F].Offset = PtrToUlong(ApicSpuriousService); + Idt[0x1F].Selector = KGDT_R0_CODE; + Idt[0x1F].Access = 0x8E00; + Idt[0x1F].ExtendedOffset = (PtrToUlong(ApicSpuriousService) >> 16); +#else + /* FIXME! + AMD64 uses 0x3F vector instead of 0x1F (like X86). + */ +#endif +} + +VOID +NTAPI HalpInitProcessor( IN ULONG ProcessorNumber, IN PLOADER_PARAMETER_BLOCK LoaderBlock) @@ -32,6 +62,7 @@ HalpInitProcessor( /* Initialize the timer */ //ApicInitializeTimer(ProcessorNumber); + HalInitApicInterruptHandlers(); } VOID