From 77ea930fcba3aefb33886dc680ba5ea0cf8c7ca5 Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Thu, 9 Aug 2007 07:12:59 +0000 Subject: [PATCH] - Fix definition of _DESCRIPTOR/KDESCRIPTOR - Fix all code/data structures of GDT/IDT to match new definition - Kernel is now MSVC/WDK compilable (but not linkable yet) - Remove two previous fixes for bootvid/kdcom MSVC/WDK compiling svn path=/trunk/; revision=28254 --- reactos/drivers/base/bootvid/precomp.h | 4 ---- reactos/drivers/base/kdcom/kdbg.c | 5 ----- reactos/include/ndk/i386/ketypes.h | 4 +--- reactos/ntoskrnl/ke/freeldr.c | 4 ++-- reactos/ntoskrnl/ke/i386/cpu.c | 14 +++++++------- reactos/ntoskrnl/ke/i386/kiinit.c | 4 ++-- reactos/ntoskrnl/ke/i386/trap.s | 1 + 7 files changed, 13 insertions(+), 23 deletions(-) diff --git a/reactos/drivers/base/bootvid/precomp.h b/reactos/drivers/base/bootvid/precomp.h index 2dae8e0bcf1..88c95e7f4f2 100644 --- a/reactos/drivers/base/bootvid/precomp.h +++ b/reactos/drivers/base/bootvid/precomp.h @@ -1,7 +1,3 @@ -#ifdef _MSC_VER -void _enable(void); -void _disable(void); -#endif #include "ntddk.h" #include "arc/arc.h" #include "halfuncs.h" diff --git a/reactos/drivers/base/kdcom/kdbg.c b/reactos/drivers/base/kdcom/kdbg.c index 4726dd586df..6180bd4f007 100644 --- a/reactos/drivers/base/kdcom/kdbg.c +++ b/reactos/drivers/base/kdcom/kdbg.c @@ -12,11 +12,6 @@ /* INCLUDES *****************************************************************/ -#ifdef _MSC_VER -void _enable(void); -void _disable(void); -#endif - #define NOEXTAPI #include #define NDEBUG diff --git a/reactos/include/ndk/i386/ketypes.h b/reactos/include/ndk/i386/ketypes.h index d467a10150c..ebb5a01877d 100644 --- a/reactos/include/ndk/i386/ketypes.h +++ b/reactos/include/ndk/i386/ketypes.h @@ -261,14 +261,12 @@ typedef struct _KIDTENTRY USHORT ExtendedOffset; } KIDTENTRY, *PKIDTENTRY; -#include typedef struct _DESCRIPTOR { + USHORT Pad; USHORT Limit; ULONG Base; - USHORT Padding; } KDESCRIPTOR, *PKDESCRIPTOR; -#include #ifndef NTOS_MODE_USER // diff --git a/reactos/ntoskrnl/ke/freeldr.c b/reactos/ntoskrnl/ke/freeldr.c index 3166e8f1f77..9d8bcdee27e 100644 --- a/reactos/ntoskrnl/ke/freeldr.c +++ b/reactos/ntoskrnl/ke/freeldr.c @@ -356,8 +356,8 @@ KiRosPrepareForSystemStartup(IN ULONG Dummy, PKGDTENTRY TssEntry; /* Load the GDT and IDT */ - Ke386SetGlobalDescriptorTable(KiGdtDescriptor); - Ke386SetInterruptDescriptorTable(KiIdtDescriptor); + Ke386SetGlobalDescriptorTable(*(PKDESCRIPTOR)&KiGdtDescriptor.Limit); + Ke386SetInterruptDescriptorTable(*(PKDESCRIPTOR)&KiIdtDescriptor.Limit); /* Initialize the boot TSS */ Tss = &KiBootTss; diff --git a/reactos/ntoskrnl/ke/i386/cpu.c b/reactos/ntoskrnl/ke/i386/cpu.c index b534d197627..d5dbbde7d84 100644 --- a/reactos/ntoskrnl/ke/i386/cpu.c +++ b/reactos/ntoskrnl/ke/i386/cpu.c @@ -47,7 +47,7 @@ KGDTENTRY KiBootGdt[256] = }; /* GDT Descriptor */ -KDESCRIPTOR KiGdtDescriptor = {sizeof(KiBootGdt), (ULONG)KiBootGdt}; +KDESCRIPTOR KiGdtDescriptor = {0, sizeof(KiBootGdt), (ULONG)KiBootGdt}; /* CPU Features and Flags */ ULONG KeI386CpuType; @@ -705,8 +705,8 @@ KiRestoreProcessorControlState(PKPROCESSOR_STATE ProcessorState) // // Restore GDT, IDT, LDT and TSS // - Ke386SetGlobalDescriptorTable(ProcessorState->SpecialRegisters.Gdtr.Base); - Ke386SetInterruptDescriptorTable(ProcessorState->SpecialRegisters.Idtr.Base); + Ke386SetGlobalDescriptorTable(*(PKDESCRIPTOR)&ProcessorState->SpecialRegisters.Gdtr.Limit); + Ke386SetInterruptDescriptorTable(*(PKDESCRIPTOR)&ProcessorState->SpecialRegisters.Idtr.Limit); Ke386SetTr(ProcessorState->SpecialRegisters.Tr); Ke386SetLocalDescriptorTable(ProcessorState->SpecialRegisters.Ldtr); } @@ -732,8 +732,8 @@ KiSaveProcessorControlState(OUT PKPROCESSOR_STATE ProcessorState) Ke386SetDr7(0); /* Save GDT, IDT, LDT and TSS */ - Ke386GetGlobalDescriptorTable(ProcessorState->SpecialRegisters.Gdtr.Base); - Ke386GetInterruptDescriptorTable(ProcessorState->SpecialRegisters.Idtr.Base); + Ke386GetGlobalDescriptorTable(*(PKDESCRIPTOR)&ProcessorState->SpecialRegisters.Gdtr.Limit); + Ke386GetInterruptDescriptorTable(*(PKDESCRIPTOR)&ProcessorState->SpecialRegisters.Idtr.Limit); Ke386GetTr(ProcessorState->SpecialRegisters.Tr); Ke386GetLocalDescriptorTable(ProcessorState->SpecialRegisters.Ldtr); } @@ -832,14 +832,14 @@ KiI386PentiumLockErrataFixup(VOID) _disable(); /* Get the current IDT and copy it */ - Ke386GetInterruptDescriptorTable(IdtDescriptor); + Ke386GetInterruptDescriptorTable(*(PKDESCRIPTOR)&IdtDescriptor.Limit); RtlCopyMemory(NewIdt2, (PVOID)IdtDescriptor.Base, IdtDescriptor.Limit + 1); IdtDescriptor.Base = (ULONG)NewIdt2; /* Set the new IDT */ - Ke386SetInterruptDescriptorTable(IdtDescriptor); + Ke386SetInterruptDescriptorTable(*(PKDESCRIPTOR)&IdtDescriptor.Limit); ((PKIPCR)KeGetPcr())->IDT = NewIdt2; /* Restore interrupts */ diff --git a/reactos/ntoskrnl/ke/i386/kiinit.c b/reactos/ntoskrnl/ke/i386/kiinit.c index e6ef8cba598..b84d0664d1f 100644 --- a/reactos/ntoskrnl/ke/i386/kiinit.c +++ b/reactos/ntoskrnl/ke/i386/kiinit.c @@ -619,8 +619,8 @@ KiGetMachineBootPointers(IN PKGDTENTRY *Gdt, USHORT Tr = 0, Fs; /* Get GDT and IDT descriptors */ - Ke386GetGlobalDescriptorTable(GdtDescriptor); - Ke386GetInterruptDescriptorTable(IdtDescriptor); + Ke386GetGlobalDescriptorTable(*(PKDESCRIPTOR)&GdtDescriptor.Limit); + Ke386GetInterruptDescriptorTable(*(PKDESCRIPTOR)&IdtDescriptor.Limit); /* Save IDT and GDT */ *Gdt = (PKGDTENTRY)GdtDescriptor.Base; diff --git a/reactos/ntoskrnl/ke/i386/trap.s b/reactos/ntoskrnl/ke/i386/trap.s index 0844fdba09c..004a67f9b1f 100644 --- a/reactos/ntoskrnl/ke/i386/trap.s +++ b/reactos/ntoskrnl/ke/i386/trap.s @@ -80,6 +80,7 @@ GENERATE_IDT_STUBS /* INT 30-FF: UNEXPECTED INTERRUPTS */ .globl _KiIdtDescriptor _KiIdtDescriptor: + .short 0 .short 0x800 .long _KiIdt