- Fix compile issues caused by previous patch.
- Fix KPROFILE definition.
- Protect ReactOS-only members of EPROCESS, OBJECT_HEADER, W32_CALLOUT_DATA.
- Protect MADDRESS_SPACE for ReactOS only.
Modified: trunk/reactos/include/ndk/asm.h
Modified: trunk/reactos/include/ndk/fixmes.txt
Modified: trunk/reactos/include/ndk/ketypes.h
Modified: trunk/reactos/include/ndk/mmtypes.h
Modified: trunk/reactos/include/ndk/obtypes.h
Modified: trunk/reactos/include/ndk/pstypes.h
Modified: trunk/reactos/ntoskrnl/ke/i386/exp.c
Modified: trunk/reactos/ntoskrnl/ke/i386/fpu.c
Modified: trunk/reactos/ntoskrnl/ke/i386/irq.c
Modified: trunk/reactos/ntoskrnl/ke/i386/thread.c
Modified: trunk/reactos/ntoskrnl/ke/i386/tss.c
Modified: trunk/reactos/ntoskrnl/ke/i386/usertrap.c
Modified: trunk/reactos/ntoskrnl/ke/i386/v86m.c
Modified: trunk/reactos/ntoskrnl/ke/profile.c
Modified: trunk/reactos/ntoskrnl/mm/i386/pfault.c

Modified: trunk/reactos/include/ndk/asm.h
--- trunk/reactos/include/ndk/asm.h	2005-11-27 18:24:32 UTC (rev 19693)
+++ trunk/reactos/include/ndk/asm.h	2005-11-27 19:21:19 UTC (rev 19694)
@@ -64,6 +64,7 @@
 #define KTSS_CR3                                0x1C
 #define KTSS_EFLAGS                             0x24
 #define KTSS_IOMAPBASE                          0x66
+#define KTSS_IO_MAPS                            0x68
 
 //
 // KTHREAD Offsets

Modified: trunk/reactos/include/ndk/fixmes.txt
--- trunk/reactos/include/ndk/fixmes.txt	2005-11-27 18:24:32 UTC (rev 19693)
+++ trunk/reactos/include/ndk/fixmes.txt	2005-11-27 19:21:19 UTC (rev 19694)
@@ -2,13 +2,7 @@
 --------------------------------------------------------------
 ______________________________________________________________________________________
 [CRITICAL]	- Breaking compatibility with official structures.
-|pstypes.h	- EPROCESS has ReactOS only fields. Includes ReactOS Internal header. IFDEF_OUT
-|pstypes.h	- W32_CALLOUT_DATA has ReactOS only fields.              IFDEF-OUT
 |obtypes.h	- Object callbacks are ReactOS only definitions.         IFDEF-OUT ADDREAL
-|obtypes.h	- Object Header includes ReactOS only type.              IFDEF-OUT
-|mmtypes.h	- _MADDRESS_SPACE is ReactOS only field.                 IFDEF-OUT
-|ketypes.h	- _KPROFILE needs to be updated with new definitions.    FIXFIX
-|ketypes.h	- _KINTERRUPT needs to be verified with new definitions. FIXFIX
 |haltypes.h	- Loader Parameter Block is ReactOS Version, not NT.     IFDEF-OUT ADDREAL
 |
 [MAJOR]		- Using incorrect, missing, or invalid names or definitions.

Modified: trunk/reactos/include/ndk/ketypes.h
--- trunk/reactos/include/ndk/ketypes.h	2005-11-27 18:24:32 UTC (rev 19693)
+++ trunk/reactos/include/ndk/ketypes.h	2005-11-27 19:21:19 UTC (rev 19694)
@@ -350,7 +350,7 @@
 } CONFIGURATION_COMPONENT_DATA, *PCONFIGURATION_COMPONENT_DATA;
 
 //
-// Kernel Memory Node (FIXME: mmtypes?
+// Kernel Memory Node
 //
 typedef struct _KNODE
 {
@@ -367,25 +367,26 @@
 } KNODE, *PKNODE;
 
 //
-// Kernel Profile Object (FIXME: Fix with new defs)
+// Kernel Profile Object
 //
 typedef struct _KPROFILE
 {
     CSHORT Type;
     CSHORT Size;
-    LIST_ENTRY ListEntry;
-    PVOID RegionStart;
-    PVOID RegionEnd;
+    LIST_ENTRY ProfileListEntry;
+    PKPROCESS Process;
+    PVOID RangeBase;
+    PVOID RangeLimit;
     ULONG BucketShift;
     PVOID Buffer;
+    ULONG Segment;
+    KAFFINITY Affinity;
     KPROFILE_SOURCE Source;
-    ULONG Affinity;
-    BOOLEAN Active;
-    struct _KPROCESS *Process;
+    BOOLEAN Started;
 } KPROFILE, *PKPROFILE;
 
 //
-// Kernel Interrupt Object (FIXME: Verify)
+// Kernel Interrupt Object
 //
 typedef struct _KINTERRUPT
 {

Modified: trunk/reactos/include/ndk/mmtypes.h
--- trunk/reactos/include/ndk/mmtypes.h	2005-11-27 18:24:32 UTC (rev 19693)
+++ trunk/reactos/include/ndk/mmtypes.h	2005-11-27 19:21:19 UTC (rev 19694)
@@ -202,6 +202,7 @@
 //
 // FIXME: REACTOS SPECIFIC HACK IN EPROCESS
 //
+#ifdef _REACTOS_
 typedef struct _MADDRESS_SPACE
 {
     struct _MEMORY_AREA *MemoryAreaRoot;
@@ -211,6 +212,7 @@
     PUSHORT PageTableRefCountTable;
     ULONG PageTableRefCountTableSize;
 } MADDRESS_SPACE, *PMADDRESS_SPACE;
+#endif
 
 //
 // Generic Address Range Structure

Modified: trunk/reactos/include/ndk/obtypes.h
--- trunk/reactos/include/ndk/obtypes.h	2005-11-27 18:24:32 UTC (rev 19693)
+++ trunk/reactos/include/ndk/obtypes.h	2005-11-27 19:21:19 UTC (rev 19694)
@@ -341,11 +341,13 @@
 } OBJECT_HEADER_CREATOR_INFO, *POBJECT_HEADER_CREATOR_INFO;
 
 //
-// FIXME: Object Header
+// Object Header
 //
 typedef struct _OBJECT_HEADER
 {
-    LIST_ENTRY Entry;
+#ifdef _REACTOS_
+    LIST_ENTRY Entry; // FIXME: REACTOS ONLY
+#endif
     LONG PointerCount;
     union
     {

Modified: trunk/reactos/include/ndk/pstypes.h
--- trunk/reactos/include/ndk/pstypes.h	2005-11-27 18:24:32 UTC (rev 19693)
+++ trunk/reactos/include/ndk/pstypes.h	2005-11-27 19:21:19 UTC (rev 19694)
@@ -529,10 +529,6 @@
 } THREAD_BASIC_INFORMATION, *PTHREAD_BASIC_INFORMATION;
 
 #ifndef NTOS_MODE_USER
-/* FIXME: see note in mmtypes.h */
-#ifdef _NTOSKRNL_
-#include <internal/mm.h>
-#endif
 
 //
 // EPROCESS Quota Structures
@@ -690,6 +686,10 @@
     UCHAR                          ActiveFaultCount;            /* 24E */
 } ETHREAD;
 
+#if defined(_NTOSKRNL_)
+    #include <internal/mm.h>
+#endif
+
 //
 // Executive Process (EPROCESS)
 //
@@ -818,16 +818,15 @@
     MM_AVL_TABLE          VadRoot;                      /* 250 */
     ULONG                 Cookie;                       /* 270 */
 
-/***************************************************************
- *                REACTOS SPECIFIC START
- ***************************************************************/
-    /* FIXME WILL BE DEPRECATED WITH PUSHLOCK SUPPORT IN 0.3.0 */
+#ifdef _REACTOS_
+    /* FIXME: WILL BE DEPRECATED WITH PUSHLOCK SUPPORT IN 0.3.0*/
     KEVENT                LockEvent;                    /* 274 */
     ULONG                 LockCount;                    /* 284 */
     struct _KTHREAD       *LockOwner;                   /* 288 */
 
-    /* FIXME MOVE TO AVL TREES                                 */
+    /* FIXME: MOVE TO AVL TREES                                */
     MADDRESS_SPACE        AddressSpace;                 /* 28C */
+#endif
 } EPROCESS;
 #include <poppack.h>
 
@@ -919,11 +918,12 @@
     OB_DELETE_METHOD WinStaDelete;
     OB_PARSE_METHOD WinStaParse;
     OB_OPEN_METHOD WinStaOpen;
-    
-    /* FIXME: These are ROS-ONLY and are fixed in a future local patch */
+#ifdef _REACTOS_
+    /* FIXME: REACTOS ONLY */
     OB_FIND_METHOD WinStaFind;
     OB_OPEN_METHOD WinStaCreate;
     OB_CREATE_METHOD DesktopCreate;
+#endif
 } W32_CALLOUT_DATA, *PW32_CALLOUT_DATA;
 
 #endif // !NTOS_MODE_USER

Modified: trunk/reactos/ntoskrnl/ke/i386/exp.c
--- trunk/reactos/ntoskrnl/ke/i386/exp.c	2005-11-27 18:24:32 UTC (rev 19693)
+++ trunk/reactos/ntoskrnl/ke/i386/exp.c	2005-11-27 19:21:19 UTC (rev 19694)
@@ -167,7 +167,7 @@
     {
       Er.ExceptionCode = STATUS_ACCESS_VIOLATION;
       Er.NumberParameters = 2;
-      Er.ExceptionInformation[0] = Tf->ErrorCode & 0x1;
+      Er.ExceptionInformation[0] = Tf->ErrCode & 0x1;
       Er.ExceptionInformation[1] = (ULONG)Cr2;
     }
   else
@@ -194,6 +194,7 @@
 VOID
 KiDoubleFaultHandler(VOID)
 {
+#if 0
   unsigned int cr2;
   ULONG StackLimit;
   ULONG StackBase;
@@ -212,7 +213,7 @@
 #endif
 
   OldTss = KeGetCurrentKPCR()->TSS;
-  Esp0 = OldTss->Esp;
+  Esp0 = OldTss->Esp0;
 
   /* Get CR2 */
   cr2 = Ke386GetCr2();
@@ -394,7 +395,7 @@
 	}
 #endif
     }
-
+#endif
    DbgPrint("\n");
    for(;;);
 }
@@ -406,8 +407,8 @@
   ULONG cr3_;
   ULONG StackLimit;
   ULONG Esp0;
-  ULONG ExceptionNr = (ULONG)Tf->DebugArgMark;
-  ULONG cr2 = (ULONG)Tf->DebugPointer;
+  ULONG ExceptionNr = (ULONG)Tf->DbgArgMark;
+  ULONG cr2 = (ULONG)Tf->DbgArgPointer;
 
   Esp0 = (ULONG)Tf;
 
@@ -417,14 +418,14 @@
    if (ExceptionNr < ARRAY_SIZE(ExceptionTypeStrings))
      {
 	DbgPrint("%s Exception: %d(%x)\n", ExceptionTypeStrings[ExceptionNr],
-		 ExceptionNr, Tf->ErrorCode&0xffff);
+		 ExceptionNr, Tf->ErrCode&0xffff);
      }
    else
      {
-	DbgPrint("Exception: %d(%x)\n", ExceptionNr, Tf->ErrorCode&0xffff);
+	DbgPrint("Exception: %d(%x)\n", ExceptionNr, Tf->ErrCode&0xffff);
      }
    DbgPrint("Processor: %d CS:EIP %x:%x ", KeGetCurrentProcessorNumber(),
-	    Tf->Cs&0xffff, Tf->Eip);
+	    Tf->SegCs&0xffff, Tf->Eip);
    KeRosPrintAddress((PVOID)Tf->Eip);
    DbgPrint("\n");
    Ke386GetPageTableDirectory(cr3_);
@@ -442,13 +443,13 @@
 		 PsGetCurrentThread()->Cid.UniqueThread);
      }
    DbgPrint("\n");
-   DbgPrint("DS %x ES %x FS %x GS %x\n", Tf->Ds&0xffff, Tf->Es&0xffff,
-	    Tf->Fs&0xffff, Tf->Gs&0xfff);
+   DbgPrint("DS %x ES %x FS %x GS %x\n", Tf->SegDs&0xffff, Tf->SegEs&0xffff,
+	    Tf->SegFs&0xffff, Tf->SegGs&0xfff);
    DbgPrint("EAX: %.8x   EBX: %.8x   ECX: %.8x\n", Tf->Eax, Tf->Ebx, Tf->Ecx);
    DbgPrint("EDX: %.8x   EBP: %.8x   ESI: %.8x   ESP: %.8x\n", Tf->Edx,
 	    Tf->Ebp, Tf->Esi, Esp0);
-   DbgPrint("EDI: %.8x   EFLAGS: %.8x ", Tf->Edi, Tf->Eflags);
-   if ((Tf->Cs&0xffff) == KGDT_R0_CODE)
+   DbgPrint("EDI: %.8x   EFLAGS: %.8x ", Tf->Edi, Tf->EFlags);
+   if ((Tf->SegCs&0xffff) == KGDT_R0_CODE)
      {
 	DbgPrint("kESP %.8x ", Esp0);
 	if (PsGetCurrentThread() != NULL)
@@ -490,21 +491,21 @@
    ASSERT(ExceptionNr != 14);
 
    /* Store the exception number in an unused field in the trap frame. */
-   Tf->DebugArgMark = ExceptionNr;
+   Tf->DbgArgMark = ExceptionNr;
 
    /* Use the address of the trap frame as approximation to the ring0 esp */
    Esp0 = (ULONG)&Tf->Eip;
 
    /* Get CR2 */
    cr2 = Ke386GetCr2();
-   Tf->DebugPointer = cr2;
+   Tf->DbgArgPointer = cr2;
 
    /*
     * If this was a V86 mode exception then handle it specially
     */
-   if (Tf->Eflags & (1 << 17))
+   if (Tf->EFlags & (1 << 17))
      {
-       DPRINT("Tf->Eflags, %x, Tf->Eip %x, ExceptionNr: %d\n", Tf->Eflags, Tf->Eip, ExceptionNr);
+       DPRINT("Tf->Eflags, %x, Tf->Eip %x, ExceptionNr: %d\n", Tf->EFlags, Tf->Eip, ExceptionNr);
        return(KeV86Exception(ExceptionNr, Tf, cr2));
      }
 
@@ -561,7 +562,7 @@
    /*
     * Handle user exceptions differently
     */
-   if ((Tf->Cs & 0xFFFF) == (KGDT_R3_CODE | RPL_MASK))
+   if ((Tf->SegCs & 0xFFFF) == (KGDT_R3_CODE | RPL_MASK))
      {
        return(KiUserTrapHandler(Tf, ExceptionNr, (PVOID)cr2));
      }
@@ -576,15 +577,15 @@
 KiEspFromTrapFrame(IN PKTRAP_FRAME TrapFrame)
 {
     /* Check if this is user-mode or V86 */
-    if ((TrapFrame->Cs & 1) || (TrapFrame->Eflags & X86_EFLAGS_VM))
+    if ((TrapFrame->SegCs & MODE_MASK) || (TrapFrame->EFlags & X86_EFLAGS_VM))
     {
         /* Return it directly */
-        return TrapFrame->Esp;
+        return TrapFrame->HardwareEsp;
     }
     else
     {
         /* Edited frame */
-        if (!(TrapFrame->Cs & FRAME_EDITED))
+        if (!(TrapFrame->SegCs & FRAME_EDITED))
         {
             /* Return edited value */
             return TrapFrame->TempEsp;
@@ -592,7 +593,7 @@
         else
         {
             /* Virgin frame, calculate */
-            return (ULONG)&TrapFrame->Esp;
+            return (ULONG)&TrapFrame->HardwareEsp;
         }
     }
 }
@@ -605,10 +606,10 @@
     ULONG Previous = KiEspFromTrapFrame(TrapFrame);
 
     /* Check if this is user-mode or V86 */
-    if ((TrapFrame->Cs & MODE_MASK) || (TrapFrame->Eflags & X86_EFLAGS_VM))
+    if ((TrapFrame->SegCs & MODE_MASK) || (TrapFrame->EFlags & X86_EFLAGS_VM))
     {
         /* Write it directly */
-        TrapFrame->Esp = Esp;
+        TrapFrame->HardwareEsp = Esp;
     }
     else
     {
@@ -619,7 +620,7 @@
         }
 
         /* Create an edit frame, check if it was alrady */
-        if (!(TrapFrame->Cs & FRAME_EDITED))
+        if (!(TrapFrame->SegCs & FRAME_EDITED))
         {
             /* Update the value */
             TrapFrame->TempEsp = Esp;
@@ -630,8 +631,8 @@
             if (Previous != Esp)
             {
                 /* Save CS */
-                TrapFrame->TempCs = TrapFrame->Cs;
-                TrapFrame->Cs &= ~FRAME_EDITED;
+                TrapFrame->TempSegCs = TrapFrame->SegCs;
+                TrapFrame->SegCs &= ~FRAME_EDITED;
 
                 /* Save ESP */
                 TrapFrame->TempEsp = Esp;
@@ -645,15 +646,15 @@
 KiSsFromTrapFrame(IN PKTRAP_FRAME TrapFrame)
 {
     /* If this was V86 Mode */
-    if (TrapFrame->Eflags & X86_EFLAGS_VM)
+    if (TrapFrame->EFlags & X86_EFLAGS_VM)
     {
         /* Just return it */
-        return TrapFrame->Ss;
+        return TrapFrame->HardwareSegSs;
     }
-    else if (TrapFrame->Cs & MODE_MASK)
+    else if (TrapFrame->SegCs & MODE_MASK)
     {
         /* Usermode, return the User SS */
-        return TrapFrame->Ss | RPL_MASK;
+        return TrapFrame->HardwareSegSs | RPL_MASK;
     }
     else
     {
@@ -671,15 +672,15 @@
     Ss &= 0xFFFF;
 
     /* If this was V86 Mode */
-    if (TrapFrame->Eflags & X86_EFLAGS_VM)
+    if (TrapFrame->EFlags & X86_EFLAGS_VM)
     {
         /* Just write it */
-        TrapFrame->Ss = Ss;
+        TrapFrame->HardwareSegSs = Ss;
     }
-    else if (TrapFrame->Cs & MODE_MASK)
+    else if (TrapFrame->SegCs & MODE_MASK)
     {
         /* Usermode, save the User SS */
-        TrapFrame->Ss = Ss | RPL_MASK;
+        TrapFrame->HardwareSegSs = Ss | RPL_MASK;
     }
 }
 
@@ -697,35 +698,35 @@
     {
         /* Check if we went through a V86 switch */
         if ((Context->EFlags & X86_EFLAGS_VM) !=
-            (TrapFrame->Eflags & X86_EFLAGS_VM))
+            (TrapFrame->EFlags & X86_EFLAGS_VM))
         {
             /* We did, remember this for later */
             V86Switch = TRUE;
         }
 
         /* Copy EFLAGS. FIXME: Needs to be sanitized */
-        TrapFrame->Eflags = Context->EFlags;
+        TrapFrame->EFlags = Context->EFlags;
 
         /* Copy EBP and EIP */
         TrapFrame->Ebp = Context->Ebp;
         TrapFrame->Eip = Context->Eip;
 
         /* Check if we were in V86 Mode */
-        if (TrapFrame->Eflags & X86_EFLAGS_VM)
+        if (TrapFrame->EFlags & X86_EFLAGS_VM)
         {
             /* Simply copy the CS value */
-            TrapFrame->Cs = Context->SegCs;
+            TrapFrame->SegCs = Context->SegCs;
         }
         else
         {
             /* We weren't in V86, so sanitize the CS (FIXME!) */
-            TrapFrame->Cs = Context->SegCs;
+            TrapFrame->SegCs = Context->SegCs;
 
             /* Don't let it under 8, that's invalid */
-            if ((PreviousMode != KernelMode) && (TrapFrame->Cs < 8))
+            if ((PreviousMode != KernelMode) && (TrapFrame->SegCs < 8))
             {
                 /* Force it to User CS */
-                TrapFrame->Cs = (KGDT_R3_CODE | RPL_MASK);
+                TrapFrame->SegCs = (KGDT_R3_CODE | RPL_MASK);
             }
         }
 
@@ -754,39 +755,39 @@
     if ((Context->ContextFlags & CONTEXT_SEGMENTS) == CONTEXT_SEGMENTS)
     {
         /* Check if we were in V86 Mode */
-        if (TrapFrame->Eflags & X86_EFLAGS_VM)
+        if (TrapFrame->EFlags & X86_EFLAGS_VM)
         {
             /* Copy the V86 Segments directlry */
-            TrapFrame->V86_Ds = Context->SegDs;
-            TrapFrame->V86_Es = Context->SegEs;
-            TrapFrame->V86_Fs = Context->SegFs;
-            TrapFrame->V86_Gs = Context->SegGs;
+            TrapFrame->V86Ds = Context->SegDs;
+            TrapFrame->V86Es = Context->SegEs;
+            TrapFrame->V86Fs = Context->SegFs;
+            TrapFrame->V86Gs = Context->SegGs;
         }
-        else if (!(TrapFrame->Cs & MODE_MASK))
+        else if (!(TrapFrame->SegCs & MODE_MASK))
         {
             /* For user mode, write the values directly */
-            TrapFrame->Ds = KGDT_R3_DATA | RPL_MASK;
-            TrapFrame->Es = KGDT_R3_DATA | RPL_MASK;
-            TrapFrame->Fs = Context->SegFs;
-            TrapFrame->Gs = 0;
+            TrapFrame->SegDs = KGDT_R3_DATA | RPL_MASK;
+            TrapFrame->SegEs = KGDT_R3_DATA | RPL_MASK;
+            TrapFrame->SegFs = Context->SegFs;
+            TrapFrame->SegGs = 0;
         }
         else
         {
             /* For kernel-mode, return the values */
-            TrapFrame->Ds = Context->SegDs;
-            TrapFrame->Es = Context->SegEs;
-            TrapFrame->Fs = Context->SegFs;
+            TrapFrame->SegDs = Context->SegDs;
+            TrapFrame->SegEs = Context->SegEs;
+            TrapFrame->SegFs = Context->SegFs;
 
             /* Handle GS specially */
-            if (TrapFrame->Cs == (KGDT_R3_CODE | RPL_MASK))
+            if (TrapFrame->SegCs == (KGDT_R3_CODE | RPL_MASK))
             {
                 /* Don't use it, if user */
-                TrapFrame->Gs = 0;
+                TrapFrame->SegGs = 0;
             }
             else
             {
                 /* Copy it if kernel */
-                TrapFrame->Gs = Context->SegGs;
+                TrapFrame->SegGs = Context->SegGs;
             }
         }
     }
@@ -828,19 +829,19 @@
         /* EBP, EIP and EFLAGS */
         Context->Ebp = TrapFrame->Ebp;
         Context->Eip = TrapFrame->Eip;
-        Context->EFlags = TrapFrame->Eflags;
+        Context->EFlags = TrapFrame->EFlags;
 
         /* Return the correct CS */
-        if (!(TrapFrame->Cs & FRAME_EDITED) &&
-            !(TrapFrame->Eflags & X86_EFLAGS_VM))
+        if (!(TrapFrame->SegCs & FRAME_EDITED) &&
+            !(TrapFrame->EFlags & X86_EFLAGS_VM))
         {
             /* Get it from the Temp location */
-            Context->SegCs = TrapFrame->TempCs & 0xFFFF;
+            Context->SegCs = TrapFrame->TempSegCs & 0xFFFF;
         }
         else
         {
             /* Return it directly */
-            Context->SegCs = TrapFrame->Cs & 0xFFFF;
+            Context->SegCs = TrapFrame->SegCs & 0xFFFF;
         }
 
         /* Get the Ss and ESP */
@@ -852,31 +853,31 @@
     if ((Context->ContextFlags & CONTEXT_SEGMENTS) == CONTEXT_SEGMENTS)
     {
         /* Do V86 Mode first */
-        if (TrapFrame->Eflags & X86_EFLAGS_VM)
+        if (TrapFrame->EFlags & X86_EFLAGS_VM)
         {
             /* Return from the V86 location */
-            Context->SegGs = TrapFrame->V86_Gs & 0xFFFF;
-            Context->SegFs = TrapFrame->V86_Fs & 0xFFFF;
-            Context->SegEs = TrapFrame->V86_Es & 0xFFFF;
-            Context->SegDs = TrapFrame->V86_Ds & 0xFFFF;
+            Context->SegGs = TrapFrame->V86Gs & 0xFFFF;
+            Context->SegFs = TrapFrame->V86Fs & 0xFFFF;
+            Context->SegEs = TrapFrame->V86Es & 0xFFFF;
+            Context->SegDs = TrapFrame->V86Ds & 0xFFFF;
         }
         else
         {
             /* Check if this was a Kernel Trap */
-            if (TrapFrame->Cs == KGDT_R0_CODE)
+            if (TrapFrame->SegCs == KGDT_R0_CODE)
             {
                 /* Set valid selectors */
-                TrapFrame->Gs = 0;
-                TrapFrame->Fs = KGDT_R0_PCR;
-                TrapFrame->Es = KGDT_R3_DATA | RPL_MASK;
-                TrapFrame->Ds = KGDT_R3_DATA | RPL_MASK;
+                TrapFrame->SegGs = 0;
+                TrapFrame->SegFs = KGDT_R0_PCR;
+                TrapFrame->SegEs = KGDT_R3_DATA | RPL_MASK;
+                TrapFrame->SegDs = KGDT_R3_DATA | RPL_MASK;
             }
 
             /* Return the segments */
-            Context->SegGs = TrapFrame->Gs & 0xFFFF;
-            Context->SegFs = TrapFrame->Fs & 0xFFFF;
-            Context->SegEs = TrapFrame->Es & 0xFFFF;
-            Context->SegDs = TrapFrame->Ds & 0xFFFF;
+            Context->SegGs = TrapFrame->SegGs & 0xFFFF;
+            Context->SegFs = TrapFrame->SegFs & 0xFFFF;
+            Context->SegEs = TrapFrame->SegEs & 0xFFFF;
+            Context->SegDs = TrapFrame->SegDs & 0xFFFF;
         }
     }
 

Modified: trunk/reactos/ntoskrnl/ke/i386/fpu.c
--- trunk/reactos/ntoskrnl/ke/i386/fpu.c	2005-11-27 18:24:32 UTC (rev 19693)
+++ trunk/reactos/ntoskrnl/ke/i386/fpu.c	2005-11-27 19:21:19 UTC (rev 19694)
@@ -373,7 +373,7 @@
 
         (void) cr0;
         ASSERT((cr0 & X86_CR0_TS) == X86_CR0_TS);
-        ASSERT((Tf->Eflags & X86_EFLAGS_VM) == 0);
+        ASSERT((Tf->EFlags & X86_EFLAGS_VM) == 0);
         ASSERT((cr0 & X86_CR0_EM) == 0);
 
         /* disable scheduler, clear TS in cr0 */
@@ -485,7 +485,7 @@
         }
         KeLowerIrql(OldIrql);
 
-        PreviousMode = ((Tf->Cs & 0xffff) == (KGDT_R3_CODE | RPL_MASK)) ? (UserMode) : (KernelMode);
+        PreviousMode = ((Tf->SegCs & 0xffff) == (KGDT_R3_CODE | RPL_MASK)) ? (UserMode) : (KernelMode);
         DPRINT("Math/Xmm fault happened! (PreviousMode = %s)\n",
                (PreviousMode != KernelMode) ? ("UserMode") : ("KernelMode"));
 

Modified: trunk/reactos/ntoskrnl/ke/i386/irq.c
--- trunk/reactos/ntoskrnl/ke/i386/irq.c	2005-11-27 18:24:32 UTC (rev 19693)
+++ trunk/reactos/ntoskrnl/ke/i386/irq.c	2005-11-27 19:21:19 UTC (rev 19694)
@@ -170,42 +170,42 @@
 KeIRQTrapFrameToTrapFrame(PKIRQ_TRAPFRAME IrqTrapFrame,
                           PKTRAP_FRAME TrapFrame)
 {
-   TrapFrame->Gs     = (USHORT)IrqTrapFrame->Gs;
-   TrapFrame->Fs     = (USHORT)IrqTrapFrame->Fs;
-   TrapFrame->Es     = (USHORT)IrqTrapFrame->Es;
-   TrapFrame->Ds     = (USHORT)IrqTrapFrame->Ds;
+   TrapFrame->SegGs     = (USHORT)IrqTrapFrame->Gs;
+   TrapFrame->SegFs     = (USHORT)IrqTrapFrame->Fs;
+   TrapFrame->SegEs     = (USHORT)IrqTrapFrame->Es;
+   TrapFrame->SegDs     = (USHORT)IrqTrapFrame->Ds;
    TrapFrame->Eax    = IrqTrapFrame->Eax;
    TrapFrame->Ecx    = IrqTrapFrame->Ecx;
    TrapFrame->Edx    = IrqTrapFrame->Edx;
    TrapFrame->Ebx    = IrqTrapFrame->Ebx;
-   TrapFrame->Esp    = IrqTrapFrame->Esp;
+   TrapFrame->HardwareEsp    = IrqTrapFrame->Esp;
    TrapFrame->Ebp    = IrqTrapFrame->Ebp;
    TrapFrame->Esi    = IrqTrapFrame->Esi;
    TrapFrame->Edi    = IrqTrapFrame->Edi;
    TrapFrame->Eip    = IrqTrapFrame->Eip;
-   TrapFrame->Cs     = IrqTrapFrame->Cs;
-   TrapFrame->Eflags = IrqTrapFrame->Eflags;
+   TrapFrame->SegCs     = IrqTrapFrame->Cs;
+   TrapFrame->EFlags = IrqTrapFrame->Eflags;
 }
 
 STATIC VOID
 KeTrapFrameToIRQTrapFrame(PKTRAP_FRAME TrapFrame,
                           PKIRQ_TRAPFRAME IrqTrapFrame)
 {
-   IrqTrapFrame->Gs     = TrapFrame->Gs;
-   IrqTrapFrame->Fs     = TrapFrame->Fs;
-   IrqTrapFrame->Es     = TrapFrame->Es;
-   IrqTrapFrame->Ds     = TrapFrame->Ds;
+   IrqTrapFrame->Gs     = TrapFrame->SegGs;
+   IrqTrapFrame->Fs     = TrapFrame->SegFs;
+   IrqTrapFrame->Es     = TrapFrame->SegEs;
+   IrqTrapFrame->Ds     = TrapFrame->SegDs;
    IrqTrapFrame->Eax    = TrapFrame->Eax;
    IrqTrapFrame->Ecx    = TrapFrame->Ecx;
    IrqTrapFrame->Edx    = TrapFrame->Edx;
    IrqTrapFrame->Ebx    = TrapFrame->Ebx;
-   IrqTrapFrame->Esp    = TrapFrame->Esp;
+   IrqTrapFrame->Esp    = TrapFrame->HardwareEsp;
    IrqTrapFrame->Ebp    = TrapFrame->Ebp;
    IrqTrapFrame->Esi    = TrapFrame->Esi;
    IrqTrapFrame->Edi    = TrapFrame->Edi;
    IrqTrapFrame->Eip    = TrapFrame->Eip;
-   IrqTrapFrame->Cs     = TrapFrame->Cs;
-   IrqTrapFrame->Eflags = TrapFrame->Eflags;
+   IrqTrapFrame->Cs     = TrapFrame->SegCs;
+   IrqTrapFrame->Eflags = TrapFrame->EFlags;
 }
 
 VOID STDCALL

Modified: trunk/reactos/ntoskrnl/ke/i386/thread.c
--- trunk/reactos/ntoskrnl/ke/i386/thread.c	2005-11-27 18:24:32 UTC (rev 19693)
+++ trunk/reactos/ntoskrnl/ke/i386/thread.c	2005-11-27 19:21:19 UTC (rev 19694)
@@ -95,11 +95,11 @@
         }
 
         /* Enable Interrupts and disable some unsupported flags right now */
-        TrapFrame->Eflags = Context->EFlags | X86_EFLAGS_IF;
-        TrapFrame->Eflags &= ~(X86_EFLAGS_VM | X86_EFLAGS_NT | X86_EFLAGS_IOPL);
+        TrapFrame->EFlags = Context->EFlags | X86_EFLAGS_IF;
+        TrapFrame->EFlags &= ~(X86_EFLAGS_VM | X86_EFLAGS_NT | X86_EFLAGS_IOPL);
 
         /* Set the previous mode as user */
-        TrapFrame->PreviousMode = UserMode;
+        TrapFrame->PreviousPreviousMode = UserMode;
 
         /* Terminate the Exception Handler List */
         TrapFrame->ExceptionList = (PVOID)0xFFFFFFFF;

Modified: trunk/reactos/ntoskrnl/ke/i386/tss.c
--- trunk/reactos/ntoskrnl/ke/i386/tss.c	2005-11-27 18:24:32 UTC (rev 19693)
+++ trunk/reactos/ntoskrnl/ke/i386/tss.c	2005-11-27 19:21:19 UTC (rev 19694)
@@ -16,6 +16,11 @@
 
 /* GLOBALS *******************************************************************/
 
+typedef struct _KTSSNOIOPM
+{
+    UCHAR TssData[KTSS_IO_MAPS];
+} KTSSNOIOPM;
+
 static KTSS* Ki386TssArray[MAXIMUM_PROCESSORS];
 PVOID Ki386InitialStackArray[MAXIMUM_PROCESSORS];
 static KTSSNOIOPM* Ki386TrapTssArray[MAXIMUM_PROCESSORS];
@@ -38,7 +43,7 @@
   USHORT Offset;
 
   if(EnableDisable > 1) return FALSE;
-  Offset = (EnableDisable) ? (USHORT) FIELD_OFFSET(KTSS, IoBitmap) : 0xffff;
+  Offset = (EnableDisable) ? (USHORT) FIELD_OFFSET(KTSS, IoMaps) : 0xffff;
 
   oldIrql = KeRaiseIrqlToSynchLevel();
   Process->Pcb.IopmOffset = Offset;
@@ -62,7 +67,7 @@
 
   oldIrql = KeRaiseIrqlToSynchLevel();
 
-  memcpy(&KeGetCurrentKPCR()->TSS->IoBitmap[0],
+  memcpy(&KeGetCurrentKPCR()->TSS->IoMaps[0],
          IOMapStart,
          0x2000);
 
@@ -85,7 +90,7 @@
   oldIrql = KeRaiseIrqlToSynchLevel();
 
   memcpy(IOMapStart,
-         &KeGetCurrentKPCR()->TSS->IoBitmap[0],
+         &KeGetCurrentKPCR()->TSS->IoMaps[0],
          0x2000);
 
   KeLowerIrql(oldIrql);
@@ -96,8 +101,8 @@
 Ki386ApplicationProcessorInitializeTSS(VOID)
 {
   ULONG cr3_;
-  KTSS* Tss;
-  KTSSNOIOPM* TrapTss;
+  PKTSS Tss;
+  PKTSS TrapTss;
   PVOID TrapStack;
   ULONG Id;
   PUSHORT Gdt;
@@ -113,7 +118,7 @@
   TrapStack = ExAllocatePool(NonPagedPool, MM_STACK_SIZE);
 
   Ki386TssArray[Id] = Tss;
-  Ki386TrapTssArray[Id] = TrapTss;
+  Ki386TrapTssArray[Id] = (KTSSNOIOPM*)TrapTss;
   Ki386TrapStackArray[Id] = TrapStack;
   KeGetCurrentKPCR()->TSS = Tss;
 
@@ -121,8 +126,7 @@
   Tss->Esp0 = (ULONG)Ki386InitialStackArray[Id] + MM_STACK_SIZE; /* FIXME: - sizeof(FX_SAVE_AREA)? */
   Tss->Ss0 = KGDT_R0_DATA;
   Tss->IoMapBase = 0xFFFF; /* No i/o bitmap */
-  Tss->IoBitmap[8192] = 0xFF;
-  Tss->Ldt = 0;
+  Tss->LDT = 0;
 
   /*
    * Initialize a descriptor for the TSS
@@ -137,20 +141,16 @@
     ((base & 0xFF000000) >> 16));
 
   /* Initialize the TSS used for handling double faults. */
-  TrapTss->Eflags = 0;
+  TrapTss->Flags = 0;
   TrapTss->Esp0 = ((ULONG)TrapStack + MM_STACK_SIZE); /* FIXME: - sizeof(FX_SAVE_AREA)? */
   TrapTss->Ss0 = KGDT_R0_DATA;
-  TrapTss->Esp = ((ULONG)TrapStack + MM_STACK_SIZE); /* FIXME: - sizeof(FX_SAVE_AREA)? */
   TrapTss->Cs = KGDT_R0_CODE;
   TrapTss->Eip = (ULONG)KiTrap8;
-  TrapTss->Ss = KGDT_R0_DATA;
   TrapTss->Ds = KGDT_R0_DATA;
   TrapTss->Es = KGDT_R0_DATA;
   TrapTss->Fs = KGDT_R0_PCR;
   TrapTss->IoMapBase = 0xFFFF; /* No i/o bitmap */
-  TrapTss->IoBitmap[0] = 0xFF;
-  TrapTss->Ldt = 0;
-  TrapTss->Cr3 = cr3_;
+  TrapTss->LDT = 0;
 
   /*
    * Initialize a descriptor for the trap TSS.
@@ -185,6 +185,7 @@
   ULONG cr3_;
   extern unsigned int trap_stack, trap_stack_top;
   unsigned int base, length;
+  PKTSS Tss;
 
   Ke386GetPageTableDirectory(cr3_);
 
@@ -196,10 +197,8 @@
   /* Initialize the boot TSS. */
   KiBootTss.Esp0 = (ULONG)init_stack_top - sizeof(FX_SAVE_AREA);
   KiBootTss.Ss0 = KGDT_R0_DATA;
-  //   KiBootTss.IoMapBase = FIELD_OFFSET(KTSS, IoBitmap);
   KiBootTss.IoMapBase = 0xFFFF; /* No i/o bitmap */
-  KiBootTss.IoBitmap[8192] = 0xFF;
-  KiBootTss.Ldt = KGDT_LDT;
+  KiBootTss.LDT = KGDT_LDT;
 
   /*
    * Initialize a descriptor for the TSS
@@ -214,20 +213,17 @@
     ((base & 0xFF000000) >> 16);
 
   /* Initialize the TSS used for handling double faults. */
-  KiBootTrapTss.Eflags = 0;
-  KiBootTrapTss.Esp0 = (ULONG)trap_stack_top; /* FIXME: - sizeof(FX_SAVE_AREA)? */
-  KiBootTrapTss.Ss0 = KGDT_R0_DATA;
-  KiBootTrapTss.Esp = (ULONG)trap_stack_top; /* FIXME: - sizeof(FX_SAVE_AREA)? */
-  KiBootTrapTss.Cs = KGDT_R0_CODE;
-  KiBootTrapTss.Eip = (ULONG)KiTrap8;
-  KiBootTrapTss.Ss = KGDT_R0_DATA;
-  KiBootTrapTss.Ds = KGDT_R0_DATA;
-  KiBootTrapTss.Es = KGDT_R0_DATA;
-  KiBootTrapTss.Fs = KGDT_R0_PCR;
-  KiBootTrapTss.IoMapBase = 0xFFFF; /* No i/o bitmap */
-  KiBootTrapTss.IoBitmap[0] = 0xFF;
-  KiBootTrapTss.Ldt = 0x0;
-  KiBootTrapTss.Cr3 = cr3_;
+  Tss = (PKTSS)&KiBootTrapTss;
+  Tss->Flags = 0;
+  Tss->Esp0 = (ULONG)trap_stack_top; /* FIXME: - sizeof(FX_SAVE_AREA)? */
+  Tss->Ss0 = KGDT_R0_DATA;
+  Tss->Cs = KGDT_R0_CODE;
+  Tss->Eip = (ULONG)KiTrap8;
+  Tss->Ds = KGDT_R0_DATA;
+  Tss->Es = KGDT_R0_DATA;
+  Tss->Fs = KGDT_R0_PCR;
+  Tss->IoMapBase = 0xFFFF; /* No i/o bitmap */
+  Tss->LDT = 0x0;
 
   /*
    * Initialize a descriptor for the trap TSS.

Modified: trunk/reactos/ntoskrnl/ke/i386/usertrap.c
--- trunk/reactos/ntoskrnl/ke/i386/usertrap.c	2005-11-27 18:24:32 UTC (rev 19693)
+++ trunk/reactos/ntoskrnl/ke/i386/usertrap.c	2005-11-27 19:21:19 UTC (rev 19694)
@@ -117,7 +117,7 @@
   if (ExceptionNr == 14)
     {
       Er.NumberParameters = 2;
-      Er.ExceptionInformation[0] = Tf->ErrorCode & 0x1;
+      Er.ExceptionInformation[0] = Tf->ErrCode & 0x1;
       Er.ExceptionInformation[1] = (ULONG)Cr2;
     }
   else

Modified: trunk/reactos/ntoskrnl/ke/i386/v86m.c
--- trunk/reactos/ntoskrnl/ke/i386/v86m.c	2005-11-27 18:24:32 UTC (rev 19693)
+++ trunk/reactos/ntoskrnl/ke/i386/v86m.c	2005-11-27 19:21:19 UTC (rev 19694)
@@ -37,12 +37,12 @@
   ULONG i = 0;
   BOOL Exit = FALSE;
 
-  ip = (PUCHAR)((Tf->Cs & 0xFFFF) * 16 + (Tf->Eip & 0xFFFF));
-  sp = (PUSHORT)((Tf->Ss & 0xFFFF) * 16 + (Tf->Esp & 0xFFFF));
+  ip = (PUCHAR)((Tf->SegCs & 0xFFFF) * 16 + (Tf->Eip & 0xFFFF));
+  sp = (PUSHORT)((Tf->HardwareSegSs & 0xFFFF) * 16 + (Tf->HardwareEsp & 0xFFFF));
   dsp = (PULONG)sp;
 
   DPRINT("KeV86GPF handling %x at %x:%x ss:sp %x:%x Flags %x\n",
-	 ip[0], Tf->Cs, Tf->Eip, Tf->Ss, Tf->Esp, VTf->regs->Flags);
+	 ip[0], Tf->SegCs, Tf->Eip, Tf->Ss, Tf->HardwareEsp, VTf->regs->Flags);
 
   while (!Exit)
     {
@@ -113,9 +113,9 @@
 	      Tf->Eip++;
 	      if (!BigAddressPrefix)
 		{
-		  Tf->Esp = Tf->Esp - 2;
+		  Tf->HardwareEsp = Tf->HardwareEsp - 2;
 		  sp = sp - 1;
-		  sp[0] = (USHORT)(Tf->Eflags & 0xFFFF);
+		  sp[0] = (USHORT)(Tf->EFlags & 0xFFFF);
 		  if (VTf->regs->Vif == 1)
 		    {
 		      sp[0] = (USHORT)(sp[0] | INTERRUPT_FLAG);
@@ -127,9 +127,9 @@
 		}
 	      else
 		{
-		  Tf->Esp = Tf->Esp - 4;
+		  Tf->HardwareEsp = Tf->HardwareEsp - 4;
 		  dsp = dsp - 1;
-		  dsp[0] = Tf->Eflags;
+		  dsp[0] = Tf->EFlags;
 		  dsp[0] = dsp[0] & VALID_FLAGS;
 		  if (VTf->regs->Vif == 1)
 		    {
@@ -157,9 +157,9 @@
 	      Tf->Eip++;
 	      if (!BigAddressPrefix)
 		{
-		  Tf->Eflags = Tf->Eflags & (~0xFFFF);
-		  Tf->Eflags = Tf->Eflags | (sp[0] & VALID_FLAGS);
-		  if (Tf->Eflags & INTERRUPT_FLAG)
+		  Tf->EFlags = Tf->EFlags & (~0xFFFF);
+		  Tf->EFlags = Tf->EFlags | (sp[0] & VALID_FLAGS);
+		  if (Tf->EFlags & INTERRUPT_FLAG)
 		    {
 		      VTf->regs->Vif = 1;
 		    }
@@ -167,12 +167,12 @@
 		    {
 		      VTf->regs->Vif = 0;
 		    }
-		  Tf->Eflags = Tf->Eflags | INTERRUPT_FLAG;
-		  Tf->Esp = Tf->Esp + 2;
+		  Tf->EFlags = Tf->EFlags | INTERRUPT_FLAG;
+		  Tf->HardwareEsp = Tf->HardwareEsp + 2;
 		}
 	      else
 		{
-		  Tf->Eflags = Tf->Eflags | (dsp[0] & VALID_FLAGS);
+		  Tf->EFlags = Tf->EFlags | (dsp[0] & VALID_FLAGS);
 		  if (dsp[0] & INTERRUPT_FLAG)
 		    {
 		      VTf->regs->Vif = 1;
@@ -181,8 +181,8 @@
 		    {
 		      VTf->regs->Vif = 0;
 		    }
-		  Tf->Eflags = Tf->Eflags | INTERRUPT_FLAG;
-		  Tf->Esp = Tf->Esp + 2;
+		  Tf->EFlags = Tf->EFlags | INTERRUPT_FLAG;
+		  Tf->HardwareEsp = Tf->HardwareEsp + 2;
 		}
 	      return(0);
 	    }
@@ -199,10 +199,10 @@
 	  if (VTf->regs->Flags & KV86M_EMULATE_CLI_STI)
 	    {
 	      Tf->Eip = sp[0];
-	      Tf->Cs = sp[1];
-	      Tf->Eflags = Tf->Eflags & (~0xFFFF);
-	      Tf->Eflags = Tf->Eflags | sp[2];
-	      if (Tf->Eflags & INTERRUPT_FLAG)
+	      Tf->SegCs = sp[1];
+	      Tf->EFlags = Tf->EFlags & (~0xFFFF);
+	      Tf->EFlags = Tf->EFlags | sp[2];
+	      if (Tf->EFlags & INTERRUPT_FLAG)
 		{
 		  VTf->regs->Vif = 1;
 		}
@@ -210,8 +210,8 @@
 		{
 		  VTf->regs->Vif = 0;
 		}
-	      Tf->Eflags = Tf->Eflags & (~INTERRUPT_FLAG);
-	      Tf->Esp = Tf->Esp + 6;
+	      Tf->EFlags = Tf->EFlags & (~INTERRUPT_FLAG);
+	      Tf->HardwareEsp = Tf->HardwareEsp + 6;
 	      return(0);
 	    }
 	  Exit = TRUE;
@@ -433,11 +433,11 @@
 		{
 		  Offset = Offset & 0xFFFF;
 		}
-	      Buffer = (PUCHAR)((Tf->Es * 16) + Offset);
+	      Buffer = (PUCHAR)((Tf->SegEs * 16) + Offset);
 	      for (; Count > 0; Count--)
 		{
 		  WRITE_PORT_UCHAR(Port, *Buffer);
-		  if (Tf->Eflags & DIRECTION_FLAG)
+		  if (Tf->EFlags & DIRECTION_FLAG)
 		    {
 		      Buffer++;
 		    }
@@ -480,11 +480,11 @@
 		}
 	      if (BigDataPrefix)
 		{
-		  BufferL = (PULONG)((Tf->Es * 16) + Offset);
+		  BufferL = (PULONG)((Tf->SegEs * 16) + Offset);
 		}
 	      else
 		{
-		  BufferS = (PUSHORT)((Tf->Es * 16) + Offset);
+		  BufferS = (PUSHORT)((Tf->SegEs * 16) + Offset);
 		}
 	      for (; Count > 0; Count--)
 		{
@@ -496,7 +496,7 @@
 		    {
 		      WRITE_PORT_USHORT((PUSHORT)Port, *BufferS);
 		    }
-		  if (Tf->Eflags & DIRECTION_FLAG)
+		  if (Tf->EFlags & DIRECTION_FLAG)
 		    {
 		      if (BigDataPrefix)
 			{
@@ -550,11 +550,11 @@
 		{
 		  Offset = Offset & 0xFFFF;
 		}
-	      Buffer = (PUCHAR)((Tf->Es * 16) + Offset);
+	      Buffer = (PUCHAR)((Tf->SegEs * 16) + Offset);
 	      for (; Count > 0; Count--)
 		{
 		  *Buffer = READ_PORT_UCHAR(Port);
-		  if (Tf->Eflags & DIRECTION_FLAG)
+		  if (Tf->EFlags & DIRECTION_FLAG)
 		    {
 		      Buffer++;
 		    }
@@ -597,11 +597,11 @@
 		}
 	      if (BigDataPrefix)
 		{
[truncated at 1000 lines; 210 more skipped]