- Add some more misc. public definitions and fix exfuncs.h so that it can be included...
[reactos.git] / reactos / include / ndk / i386 / ketypes.h
index 294337a..9473ce2 100644 (file)
@@ -1,31 +1,50 @@
-/*
- * PROJECT:         ReactOS Native Headers
- * FILE:            include/ndk/i386/ketypes.h
- * PURPOSE:         I386-specific definitions for Kernel Types not defined in DDK/IFS
- * PROGRAMMER:      Alex Ionescu (alex@relsoft.net)
- * UPDATE HISTORY:
- *                  Created 06/10/04
- */
-#ifndef _I386_KETYPES_H
-#define _I386_KETYPES_H
+/*++ NDK Version: 0095
+
+Copyright (c) Alex Ionescu.  All rights reserved.
+
+Header Name:
+
+    ketypes.h (X86)
 
-/* DEPENDENCIES **************************************************************/
+Abstract:
 
-/* CONSTANTS *****************************************************************/
+    i386 Type definitions for the Kernel services.
 
-/* X86 80386 Segment Types */
-#define I386_TSS               0x9
-#define I386_ACTIVE_TSS        0xB
-#define I386_CALL_GATE         0xC
-#define I386_INTERRUPT_GATE    0xE
-#define I386_TRAP_GATE         0xF
+Author:
+
+    Alex Ionescu (alex.ionescu@reactos.com)   06-Oct-2004
+
+--*/
+
+#ifndef _I386_KETYPES_H
+#define _I386_KETYPES_H
 
-/* EXPORTED DATA *************************************************************/
+//
+// Dependencies
+//
 
-/* ENUMERATIONS **************************************************************/
+//
+// X86 80386 Segment Types
+//
+#define I386_TASK_GATE          0x5
+#define I386_TSS                0x9
+#define I386_ACTIVE_TSS         0xB
+#define I386_CALL_GATE          0xC
+#define I386_INTERRUPT_GATE     0xE
+#define I386_TRAP_GATE          0xF
 
-/* TYPES *********************************************************************/
+//
+// IPI Types
+//
+#define IPI_APC                 1
+#define IPI_DPC                 2
+#define IPI_FREEZE              3
+#define IPI_PACKET_READY        4
+#define IPI_SYNCH_REQUEST       10
 
+//
+// FN/FX (FPU) Save Area Structures
+//
 typedef struct _FNSAVE_FORMAT
 {
     ULONG ControlWord;
@@ -67,83 +86,83 @@ typedef struct _FX_SAVE_AREA
     ULONG Cr0NpxState;
 } FX_SAVE_AREA, *PFX_SAVE_AREA;
 
+//
+// Trap Frame Definition
+//
 typedef struct _KTRAP_FRAME
 {
-    PVOID DebugEbp;
-    PVOID DebugEip;
-    PVOID DebugArgMark;
-    PVOID DebugPointer;
-    PVOID TempCs;
-    PVOID TempEip;
+    ULONG DbgEbp;
+    ULONG DbgEip;
+    ULONG DbgArgMark;
+    ULONG DbgArgPointer;
+    ULONG TempSegCs;
+    ULONG TempEsp;
     ULONG Dr0;
     ULONG Dr1;
     ULONG Dr2;
     ULONG Dr3;
     ULONG Dr6;
     ULONG Dr7;
-    USHORT Gs;
-    USHORT Reserved1;
-    USHORT Es;
-    USHORT Reserved2;
-    USHORT Ds;
-    USHORT Reserved3;
+    ULONG SegGs;
+    ULONG SegEs;
+    ULONG SegDs;
     ULONG Edx;
     ULONG Ecx;
     ULONG Eax;
-    ULONG PreviousMode;
-    PVOID ExceptionList;
-    USHORT Fs;
-    USHORT Reserved4;
+    ULONG PreviousPreviousMode;
+    struct _EXCEPTION_REGISTRATION_RECORD *ExceptionList;
+    ULONG SegFs;
     ULONG Edi;
     ULONG Esi;
     ULONG Ebx;
     ULONG Ebp;
-    ULONG ErrorCode;
+    ULONG ErrCode;
     ULONG Eip;
-    ULONG Cs;
-    ULONG Eflags;
-    ULONG Esp;
-    USHORT Ss;
-    USHORT Reserved5;
-    USHORT V86_Es;
-    USHORT Reserved6;
-    USHORT V86_Ds;
-    USHORT Reserved7;
-    USHORT V86_Fs;
-    USHORT Reserved8;
-    USHORT V86_Gs;
-    USHORT Reserved9;
+    ULONG SegCs;
+    ULONG EFlags;
+    ULONG HardwareEsp;
+    ULONG HardwareSegSs;
+    ULONG V86Es;
+    ULONG V86Ds;
+    ULONG V86Fs;
+    ULONG V86Gs;
 } KTRAP_FRAME, *PKTRAP_FRAME;
 
+//
+// LDT Entry Definition
+//
 typedef struct _LDT_ENTRY
 {
-    WORD LimitLow;
-    WORD BaseLow;
+    USHORT LimitLow;
+    USHORT BaseLow;
     union
     {
         struct
         {
-            BYTE BaseMid;
-            BYTE Flags1;
-            BYTE Flags2;
-            BYTE BaseHi;
+            UCHAR BaseMid;
+            UCHAR Flags1;
+            UCHAR Flags2;
+            UCHAR BaseHi;
         } Bytes;
         struct
         {
-            DWORD BaseMid : 8;
-            DWORD Type : 5;
-            DWORD Dpl : 2;
-            DWORD Pres : 1;
-            DWORD LimitHi : 4;
-            DWORD Sys : 1;
-            DWORD Reserved_0 : 1;
-            DWORD Default_Big : 1;
-            DWORD Granularity : 1;
-            DWORD BaseHi : 8;
+            ULONG BaseMid : 8;
+            ULONG Type : 5;
+            ULONG Dpl : 2;
+            ULONG Pres : 1;
+            ULONG LimitHi : 4;
+            ULONG Sys : 1;
+            ULONG Reserved_0 : 1;
+            ULONG Default_Big : 1;
+            ULONG Granularity : 1;
+            ULONG BaseHi : 8;
         } Bits;
     } HighWord;
 } LDT_ENTRY, *PLDT_ENTRY, *LPLDT_ENTRY;
 
+//
+// GDT Entry Definition
+//
 typedef struct _KGDTENTRY
 {
     USHORT LimitLow;
@@ -173,6 +192,9 @@ typedef struct _KGDTENTRY
     } HighWord;
 } KGDTENTRY, *PKGDTENTRY;
 
+//
+// IDT Entry Access Definition
+//
 typedef struct _KIDT_ACCESS
 {
     union
@@ -189,6 +211,9 @@ typedef struct _KIDT_ACCESS
     };
 } KIDT_ACCESS, *PKIDT_ACCESS;
 
+//
+// IDT Entry Definition
+//
 typedef struct _KIDTENTRY
 {
     USHORT Offset;
@@ -197,6 +222,9 @@ typedef struct _KIDTENTRY
     USHORT ExtendedOffset;
 } KIDTENTRY, *PKIDTENTRY;
 
+//
+// Page Table Entry Definition
+//
 typedef struct _HARDWARE_PTE_X86
 {
     ULONG Valid             : 1;
@@ -216,39 +244,46 @@ typedef struct _HARDWARE_PTE_X86
 
 typedef struct _DESCRIPTOR
 {
-    WORD Pad;
-    WORD Limit;
-    DWORD Base;
+    USHORT Pad;
+    USHORT Limit;
+    ULONG Base;
 } KDESCRIPTOR, *PKDESCRIPTOR;
 
+//
+// Special Registers Structure (outside of CONTEXT)
+//
 typedef struct _KSPECIAL_REGISTERS
 {
-    DWORD Cr0;
-    DWORD Cr2;
-    DWORD Cr3;
-    DWORD Cr4;
-    DWORD KernelDr0;
-    DWORD KernelDr1;
-    DWORD KernelDr2;
-    DWORD KernelDr3;
-    DWORD KernelDr6;
-    DWORD KernelDr7;
+    ULONG Cr0;
+    ULONG Cr2;
+    ULONG Cr3;
+    ULONG Cr4;
+    ULONG KernelDr0;
+    ULONG KernelDr1;
+    ULONG KernelDr2;
+    ULONG KernelDr3;
+    ULONG KernelDr6;
+    ULONG KernelDr7;
     KDESCRIPTOR Gdtr;
     KDESCRIPTOR Idtr;
-    WORD Tr;
-    WORD Ldtr;
-    DWORD Reserved[6];
+    USHORT Tr;
+    USHORT Ldtr;
+    ULONG Reserved[6];
 } KSPECIAL_REGISTERS, *PKSPECIAL_REGISTERS;
 
+//
+// Processor State Data
+//
 #pragma pack(push,4)
-
 typedef struct _KPROCESSOR_STATE
 {
     PCONTEXT ContextFrame;
     KSPECIAL_REGISTERS SpecialRegisters;
 } KPROCESSOR_STATE;
 
-/* Processor Control Block */
+//
+// Processor Region Control Block
+//
 typedef struct _KPRCB
 {
     USHORT MinorVersion;
@@ -379,137 +414,103 @@ typedef struct _KPRCB
     PROCESSOR_POWER_STATE PowerState;
 } KPRCB, *PKPRCB;
 
-/*
- * This is the complete, internal KPCR structure
- */
+//
+// Processor Control Region
+//
 typedef struct _KIPCR
 {
-    KPCR_TIB  Tib;                /* 00 */
-    struct _KPCR  *Self;          /* 1C */
-    struct _KPRCB  *Prcb;         /* 20 */
-    KIRQL  Irql;                  /* 24 */
-    ULONG  IRR;                   /* 28 */
-    ULONG  IrrActive;             /* 2C */
-    ULONG  IDR;                   /* 30 */
-    PVOID  KdVersionBlock;        /* 34 */
-    PUSHORT  IDT;                 /* 38 */
-    PUSHORT  GDT;                 /* 3C */
-    struct _KTSS  *TSS;           /* 40 */
-    USHORT  MajorVersion;         /* 44 */
-    USHORT  MinorVersion;         /* 46 */
-    KAFFINITY  SetMember;         /* 48 */
-    ULONG  StallScaleFactor;      /* 4C */
-    UCHAR  SparedUnused;          /* 50 */
-    UCHAR  Number;                /* 51 */
-    UCHAR  Reserved;              /* 52 */
-    UCHAR  L2CacheAssociativity;  /* 53 */
-    ULONG  VdmAlert;              /* 54 */
-    ULONG  KernelReserved[14];    /* 58 */
-    ULONG  L2CacheSize;           /* 90 */
-    ULONG  HalReserved[16];       /* 94 */
-    ULONG  InterruptMode;         /* D4 */
-    UCHAR  KernelReserved2[0x48]; /* D8 */
-    KPRCB  PrcbData;              /* 120 */
+    union
+    {
+        NT_TIB NtTib;
+        struct 
+        {
+            struct _EXCEPTION_REGISTRATION_RECORD *Used_ExceptionList;
+            PVOID Used_StackBase;
+            PVOID PerfGlobalGroupMask;
+            PVOID TssCopy;
+            ULONG ContextSwitches;
+            KAFFINITY SetMemberCopy;
+            PVOID Used_Self;
+        };
+    };
+    struct _KPCR *Self;          /* 1C */
+    struct _KPRCB *Prcb;         /* 20 */
+    KIRQL Irql;                  /* 24 */
+    ULONG IRR;                   /* 28 */
+    ULONG IrrActive;             /* 2C */
+    ULONG IDR;                   /* 30 */
+    PVOID KdVersionBlock;        /* 34 */
+#ifdef _REACTOS_
+    PUSHORT IDT;                 /* 38 */
+    PUSHORT GDT;                 /* 3C */
+#else
+    PKIDTENTRY IDT;              /* 38 */
+    PKGDTENTRY GDT;              /* 3C */
+#endif
+    struct _KTSS *TSS;           /* 40 */
+    USHORT MajorVersion;         /* 44 */
+    USHORT MinorVersion;         /* 46 */
+    KAFFINITY SetMember;         /* 48 */
+    ULONG StallScaleFactor;      /* 4C */
+    UCHAR SparedUnused;          /* 50 */
+    UCHAR Number;                /* 51 */
+    UCHAR Reserved;              /* 52 */
+    UCHAR L2CacheAssociativity;  /* 53 */
+    ULONG VdmAlert;              /* 54 */
+    ULONG KernelReserved[14];    /* 58 */
+    ULONG L2CacheSize;           /* 90 */
+    ULONG HalReserved[16];       /* 94 */
+    ULONG InterruptMode;         /* D4 */
+    UCHAR KernelReserved2[0x48]; /* D8 */
+    KPRCB PrcbData;              /* 120 */
 } KIPCR, *PKIPCR;
-
 #pragma pack(pop)
 
-#include <pshpack1.h>
-
-typedef struct _KTSSNOIOPM
+//
+// TSS Definition
+//
+typedef struct _KiIoAccessMap
 {
-    USHORT PreviousTask;
-    USHORT Reserved1;
-    ULONG  Esp0;
-    USHORT Ss0;
-    USHORT Reserved2;
-    ULONG  Esp1;
-    USHORT Ss1;
-    USHORT Reserved3;
-    ULONG  Esp2;
-    USHORT Ss2;
-    USHORT Reserved4;
-    ULONG  Cr3;
-    ULONG  Eip;
-    ULONG  Eflags;
-    ULONG  Eax;
-    ULONG  Ecx;
-    ULONG  Edx;
-    ULONG  Ebx;
-    ULONG  Esp;
-    ULONG  Ebp;
-    ULONG  Esi;
-    ULONG  Edi;
-    USHORT Es;
-    USHORT Reserved5;
-    USHORT Cs;
-    USHORT Reserved6;
-    USHORT Ss;
-    USHORT Reserved7;
-    USHORT Ds;
-    USHORT Reserved8;
-    USHORT Fs;
-    USHORT Reserved9;
-    USHORT Gs;
-    USHORT Reserved10;
-    USHORT Ldt;
-    USHORT Reserved11;
-    USHORT Trap;
-    USHORT IoMapBase;
-    /* no interrupt redirection map */
-    UCHAR IoBitmap[1];
-} KTSSNOIOPM;
+    UCHAR DirectionMap[32];
+    UCHAR IoMap[8196];
+} KIIO_ACCESS_MAP;
 
+#include <pshpack1.h>
 typedef struct _KTSS
 {
-    USHORT PreviousTask;
-    USHORT Reserved1;
-    ULONG  Esp0;
+    USHORT Backlink;
+    USHORT Reserved0;
+    ULONG Esp0;
     USHORT Ss0;
+    USHORT Reserved1;
+    ULONG NotUsed1[4];
+    ULONG CR3;
+    ULONG Eip;
+    ULONG NotUsed2[9];
+    USHORT Es;
     USHORT Reserved2;
-    ULONG  Esp1;
-    USHORT Ss1;
+    USHORT Cs;
     USHORT Reserved3;
-    ULONG  Esp2;
-    USHORT Ss2;
+    USHORT Ss;
     USHORT Reserved4;
-    ULONG  Cr3;
-    ULONG  Eip;
-    ULONG  Eflags;
-    ULONG  Eax;
-    ULONG  Ecx;
-    ULONG  Edx;
-    ULONG  Ebx;
-    ULONG  Esp;
-    ULONG  Ebp;
-    ULONG  Esi;
-    ULONG  Edi;
-    USHORT Es;
+    USHORT Ds;
     USHORT Reserved5;
-    USHORT Cs;
+    USHORT Fs;
     USHORT Reserved6;
-    USHORT Ss;
+    USHORT Gs;
     USHORT Reserved7;
-    USHORT Ds;
+    USHORT LDT;
     USHORT Reserved8;
-    USHORT Fs;
-    USHORT Reserved9;
-    USHORT Gs;
-    USHORT Reserved10;
-    USHORT Ldt;
-    USHORT Reserved11;
-    USHORT Trap;
+    USHORT Flags;
     USHORT IoMapBase;
-    /* no interrupt redirection map */
-    UCHAR  IoBitmap[8193];
-} KTSS;
-
+    KIIO_ACCESS_MAP IoMaps[1];
+    UCHAR IntDirectionMap[32];
+} KTSS, *PKTSS;
 #include <poppack.h>
 
-/* i386 Doesn't have Exception Frames */
-typedef struct _KEXCEPTION_FRAME
-{
-
-} KEXCEPTION_FRAME, *PKEXCEPTION_FRAME;
+//
+// i386 CPUs don't have exception frames
+//
+typedef struct _KEXCEPTION_FRAME KEXCEPTION_FRAME, *PKEXCEPTION_FRAME;
 
 #endif