Correction to 36917: EPROFILE/KPROFILE.Segment is pointer sized, not a pointer.
[reactos.git] / reactos / include / ndk / ketypes.h
index 6cb747d..d4ae1c5 100644 (file)
@@ -39,6 +39,21 @@ Author:
 //
 #define SSDT_MAX_ENTRIES                2
 
+//
+// Processor Architectures
+//
+#define PROCESSOR_ARCHITECTURE_INTEL    0
+#define PROCESSOR_ARCHITECTURE_MIPS     1
+#define PROCESSOR_ARCHITECTURE_ALPHA    2
+#define PROCESSOR_ARCHITECTURE_PPC      3
+#define PROCESSOR_ARCHITECTURE_SHX      4
+#define PROCESSOR_ARCHITECTURE_ARM      5
+#define PROCESSOR_ARCHITECTURE_IA64     6
+#define PROCESSOR_ARCHITECTURE_ALPHA64  7
+#define PROCESSOR_ARCHITECTURE_MSIL     8
+#define PROCESSOR_ARCHITECTURE_AMD64    9
+#define PROCESSOR_ARCHITECTURE_UNKNOWN  0xFFFF
+
 //
 // Object Type Mask for Kernel Dispatcher Objects
 //
@@ -50,11 +65,6 @@ Author:
 //
 #define THREAD_ALERT_INCREMENT          2
 
-//
-// User Shared Data in Kernel-Mode
-//
-#define KI_USER_SHARED_DATA             0xffdf0000
-
 //
 // Physical memory offset of KUSER_SHARED_DATA
 //
@@ -87,19 +97,16 @@ Author:
 #define KF_3DNOW                        0x00004000
 #define KF_AMDK6MTRR                    0x00008000
 #define KF_XMMI64                       0x00010000
-#define KF_NX_DISABLED                  0x00400000
-#define KF_NX_ENABLED                   0x00800000
+#define KF_DTS                          0x00020000
+#define KF_NX_BIT                       0x20000000
+#define KF_NX_DISABLED                  0x40000000
+#define KF_NX_ENABLED                   0x80000000
 
 //
-// KPCR Access for non-IA64 builds
+// Internal Exception Codes
 //
-#define K0IPCR                          ((ULONG_PTR)(KIP0PCRADDRESS))
-#define PCR                             ((volatile KPCR * const)K0IPCR)
-#if !defined(CONFIG_SMP) && !defined(NT_BUILD)
-#define KeGetPcr()                      PCR
-#else
-#define KeGetPcr()                      ((volatile KPCR * const)__readfsdword(0x1C))
-#endif
+#define KI_EXCEPTION_INTERNAL           0x10000000
+#define KI_EXCEPTION_ACCESS_VIOLATION   (KI_EXCEPTION_INTERNAL | 0x04)
 
 //
 // Number of dispatch codes supported by KINTERRUPT
@@ -276,10 +283,64 @@ typedef enum _KTHREAD_STATE
     Transition,
     DeferredReady,
 #if (NTDDI_VERSION >= NTDDI_WS03)
-    GateWait,
+    GateWait
 #endif
 } KTHREAD_STATE, *PKTHREAD_STATE;
 
+//
+// Kernel Object Types
+//
+typedef enum _KOBJECTS
+{
+    EventNotificationObject = 0,
+    EventSynchronizationObject = 1,
+    MutantObject = 2,
+    ProcessObject = 3,
+    QueueObject = 4,
+    SemaphoreObject = 5,
+    ThreadObject = 6,
+    GateObject = 7,
+    TimerNotificationObject = 8,
+    TimerSynchronizationObject = 9,
+    Spare2Object = 10,
+    Spare3Object = 11,
+    Spare4Object = 12,
+    Spare5Object = 13,
+    Spare6Object = 14,
+    Spare7Object = 15,
+    Spare8Object = 16,
+    Spare9Object = 17,
+    ApcObject = 18,
+    DpcObject = 19,
+    DeviceQueueObject = 20,
+    EventPairObject = 21,
+    InterruptObject = 22,
+    ProfileObject = 23,
+    ThreadedDpcObject = 24,
+    MaximumKernelObject = 25
+} KOBJECTS;
+
+//
+// Adjust reasons
+//
+typedef enum _ADJUST_REASON
+{
+    AdjustNone = 0,
+    AdjustUnwait = 1,
+    AdjustBoost = 2
+} ADJUST_REASON;
+
+//
+// Continue Status
+//
+typedef enum _KCONTINUE_STATUS
+{
+    ContinueError = 0,
+    ContinueSuccess,
+    ContinueProcessorReselected,
+    ContinueNextProcessor
+} KCONTINUE_STATUS;
+
 //
 // Process States
 //
@@ -486,14 +547,14 @@ typedef enum _KAPC_ENVIRONMENT
 } KAPC_ENVIRONMENT;
 
 //
-// CPU Cache Types
-//
-typedef enum _PROCESSOR_CACHE_TYPE
+// CPU Cache Types      
+//      
+typedef enum _PROCESSOR_CACHE_TYPE      
 {
-    CacheUnified,
-    CacheInstruction,
-    CacheData,
-    CacheTrace,
+    CacheUnified,       
+    CacheInstruction,   
+    CacheData,          
+    CacheTrace,         
 } PROCESSOR_CACHE_TYPE;
 
 //
@@ -502,7 +563,7 @@ typedef enum _PROCESSOR_CACHE_TYPE
 typedef struct _KDPC_DATA
 {
     LIST_ENTRY DpcListHead;
-    ULONG DpcLock;
+    ULONG_PTR DpcLock;
     volatile ULONG DpcQueueDepth;
     ULONG DpcCount;
 } KDPC_DATA, *PKDPC_DATA;
@@ -517,15 +578,15 @@ typedef struct _PP_LOOKASIDE_LIST
 } PP_LOOKASIDE_LIST, *PPP_LOOKASIDE_LIST;
 
 //
-// CPU Cache Descriptor
-//
-typedef struct _CACHE_DESCRIPTOR
+// CPU Cache Descriptor         
+//      
+typedef struct _CACHE_DESCRIPTOR        
 {
-    UCHAR Level;
-    UCHAR Associativity;
-    USHORT LineSize;
-    ULONG Size;
-    PROCESSOR_CACHE_TYPE Type;
+    UCHAR Level;        
+    UCHAR Associativity;        
+    USHORT LineSize;    
+    ULONG Size;         
+    PROCESSOR_CACHE_TYPE Type;          
 } CACHE_DESCRIPTOR, *PCACHE_DESCRIPTOR;
 
 //
@@ -565,7 +626,7 @@ typedef struct _KPROFILE
     PVOID RangeLimit;
     ULONG BucketShift;
     PVOID Buffer;
-    ULONG Segment;
+    ULONG_PTR Segment;
     KAFFINITY Affinity;
     KPROFILE_SOURCE Source;
     BOOLEAN Started;
@@ -588,14 +649,14 @@ typedef struct _KINTERRUPT
     KSPIN_LOCK SpinLock;
     ULONG TickCount;
     PKSPIN_LOCK ActualLock;
-    PVOID DispatchAddress;
+    PKINTERRUPT_ROUTINE DispatchAddress;
     ULONG Vector;
     KIRQL Irql;
     KIRQL SynchronizeIrql;
     BOOLEAN FloatingSave;
     BOOLEAN Connected;
-    CHAR Number;
-    UCHAR ShareVector;
+    CCHAR Number;
+    BOOLEAN ShareVector;
     KINTERRUPT_MODE Mode;
 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
     KINTERRUPT_POLARITY Polarity;
@@ -606,7 +667,7 @@ typedef struct _KINTERRUPT
     ULONGLONG Rsvd1;
 #endif
     ULONG DispatchCode[KINTERRUPT_DISPATCH_CODES];
-} KINTERRUPT, *PKINTERRUPT;
+} KINTERRUPT;
 
 //
 // Kernel Event Pair Object
@@ -633,49 +694,16 @@ typedef struct _KEXECUTE_OPTIONS
     UCHAR Spare:2;
 } KEXECUTE_OPTIONS, *PKEXECUTE_OPTIONS;
 
-//
-// Kernel Object Types
-//
-typedef enum _KOBJECTS
-{
-    EventNotificationObject = 0,
-    EventSynchronizationObject = 1,
-    MutantObject = 2,
-    ProcessObject = 3,
-    QueueObject = 4,
-    SemaphoreObject = 5,
-    ThreadObject = 6,
-    GateObject = 7,
-    TimerNotificationObject = 8,
-    TimerSynchronizationObject = 9,
-    Spare2Object = 10,
-    Spare3Object = 11,
-    Spare4Object = 12,
-    Spare5Object = 13,
-    Spare6Object = 14,
-    Spare7Object = 15,
-    Spare8Object = 16,
-    Spare9Object = 17,
-    ApcObject = 18,
-    DpcObject = 19,
-    DeviceQueueObject = 20,
-    EventPairObject = 21,
-    InterruptObject = 22,
-    ProfileObject = 23,
-    ThreadedDpcObject = 24,
-    MaximumKernelObject = 25
-} KOBJECTS;
-
 //
 // Kernel Thread (KTHREAD)
 //
-#include <pshpack1.h>
 typedef struct _KTHREAD
 {
     DISPATCHER_HEADER DispatcherHeader;
 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
     ULONGLONG CycleTime;
     ULONG HighCycleTime;
+    ULONGLONG QuantumTarget;
 #else
     LIST_ENTRY MutantListHead;
 #endif
@@ -690,31 +718,49 @@ typedef struct _KTHREAD
         {
             UCHAR ApcStateFill[23];
             UCHAR ApcQueueable;
+            volatile UCHAR NextProcessor;
+            volatile UCHAR DeferredProcessor;
+            UCHAR AdjustReason;
+            SCHAR AdjustIncrement;
         };
     };
-    volatile UCHAR NextProcessor;
-    volatile UCHAR DeferredProcessor;
-    UCHAR AdjustReason;
-    SCHAR AdjustIncrement;
     KSPIN_LOCK ApcQueueLock;
     ULONG ContextSwitches;
     volatile UCHAR State;
     UCHAR NpxState;
-    UCHAR WaitIrql;
-    SCHAR WaitMode;
-    LONG WaitStatus;
+    KIRQL WaitIrql;
+    KPROCESSOR_MODE WaitMode;
+    LONG_PTR WaitStatus;
     union
     {
         PKWAIT_BLOCK WaitBlockList;
         PKGATE GateObject;
     };
-    UCHAR Alertable;
-    UCHAR WaitNext;
+#if (NTDDI_VERSION >= NTDDI_LONGHORN)
+    union
+    {
+        struct
+        {
+            ULONG KernelStackResident:1;
+            ULONG ReadyTransition:1;
+            ULONG ProcessReadyQueue:1;
+            ULONG WaitNext:1;
+            ULONG SystemAffinityActive:1;
+            ULONG Alertable:1;
+            ULONG GdiFlushActive:1;
+            ULONG Reserved:25;
+        };
+        LONG MiscFlags;
+    };
+#else
+    BOOLEAN Alertable;
+    BOOLEAN WaitNext;
+#endif
     UCHAR WaitReason;
     SCHAR Priority;
-    UCHAR EnableStackSwap;
+    BOOLEAN EnableStackSwap;
     volatile UCHAR SwapBusy;
-    UCHAR Alerted[2];
+    BOOLEAN Alerted[MaximumMode];
     union
     {
         LIST_ENTRY WaitListEntry;
@@ -735,51 +781,54 @@ typedef struct _KTHREAD
     union
     {
         KTIMER Timer;
-        UCHAR TimerFill[40];
-    };
-    union
-    {
         struct
         {
-            LONG AutoAlignment:1;
-            LONG DisableBoost:1;
+            UCHAR TimerFill[40];
+            union
+            {
+                struct
+                {
+                    LONG AutoAlignment:1;
+                    LONG DisableBoost:1;
 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
-            LONG EtwStackTrace1ApcInserted:1;
-            LONG EtwStackTrace2ApcInserted:1;
-            LONG CycleChargePending:1;
-            LONG ReservedFlags:27;
+                    LONG EtwStackTrace1ApcInserted:1;
+                    LONG EtwStackTrace2ApcInserted:1;
+                    LONG CycleChargePending:1;
+                    LONG ReservedFlags:27;
 #else
-            LONG ReservedFlags:30;
+                    LONG ReservedFlags:30;
 #endif
+                };
+                LONG ThreadFlags;
+            };
         };
-        LONG ThreadFlags;
     };
-    PVOID Padding;
     union
     {
-        KWAIT_BLOCK WaitBlock[4];
-        union
+        KWAIT_BLOCK WaitBlock[THREAD_WAIT_OBJECTS + 1];
+        struct
         {
-            struct
-            {
-                UCHAR WaitBlockFill0[23];
-                UCHAR SystemAffinityActive;
-            };
-            struct
-            {
-                UCHAR WaitBlockFill1[47];
-                SCHAR PreviousMode;
-            };
-            struct
-            {
-                UCHAR WaitBlockFill2[71];
-                UCHAR ResourceIndex;
-            };
-            struct
-            {
-                UCHAR WaitBlockFill3[95];
-                UCHAR LargeStack;
-            };
+            UCHAR WaitBlockFill0[23];
+#if (NTDDI_VERSION >= NTDDI_LONGHORN)
+            UCHAR IdealProcessor;
+#else
+            BOOLEAN SystemAffinityActive;
+#endif
+        };
+        struct
+        {
+            UCHAR WaitBlockFill1[47];
+            CCHAR PreviousMode;
+        };
+        struct
+        {
+            UCHAR WaitBlockFill2[71];
+            UCHAR ResourceIndex;
+        };
+        struct
+        {
+            UCHAR WaitBlockFill3[95];
+            UCHAR LargeStack;
         };
     };
     LIST_ENTRY QueueListEntry;
@@ -790,31 +839,22 @@ typedef struct _KTHREAD
     PVOID CallbackStack;
     PVOID ServiceTable;
     UCHAR ApcStateIndex;
+#if (NTDDI_VERSION < NTDDI_LONGHORN)
     UCHAR IdealProcessor;
-    UCHAR Preempted;
+#endif
+    BOOLEAN Preempted;
 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
-    UCHAR CalloutActive;
+    BOOLEAN CalloutActive;
 #else
-    UCHAR ProcessReadyQueue;
+    BOOLEAN ProcessReadyQueue;
+    BOOLEAN KernelStackResident;
 #endif
-    UCHAR KernelStackResident;
-    CHAR BasePriority;
-    CHAR PriorityDecrement;
+    SCHAR BasePriority;
+    SCHAR PriorityDecrement;
     CHAR Saturation;
 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
     ULONG SystemCallNumber;
-    union
-    {
-        struct
-        {
-            ULONG Reserved0:1;
-            ULONG ReadyTransition:1;
-            ULONG ProcessReadyQueue:1;
-            ULONG Reserved2:1;
-            ULONG Reserved3:28;
-        };
-        LONG MiscFlags;
-    };
+    ULONG Spare2;
 #endif
     KAFFINITY UserAffinity;
     struct _KPROCESS *Process;
@@ -823,29 +863,29 @@ typedef struct _KTHREAD
     union
     {
         KAPC_STATE SavedApcState;
-        union
+        struct
         {
             UCHAR SavedApcStateFill[23];
-            SCHAR FreezeCount;
-        };
-    };
-    SCHAR SuspendCount;
-    UCHAR UserIdealProcessor;
+            CCHAR FreezeCount;
+            CCHAR SuspendCount;
+            UCHAR UserIdealProcessor;
 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
-    union
-    {
-        struct
-        {
-            UCHAR ReservedBits0:1;
-            UCHAR SegmentsPresent:1;
-            UCHAR Reservedbits1:1;
-        };
-        UCHAR NestedStateFlags;
-    };
+            union
+            {
+                struct
+                {
+                    UCHAR ReservedBits0:1;
+                    UCHAR SegmentsPresent:1;
+                    UCHAR Reservedbits1:1;
+                };
+                UCHAR NestedStateFlags;
+            };
 #else
-    UCHAR CalloutActive;
+            UCHAR CalloutActive;
 #endif
-    UCHAR Iopl;
+            UCHAR Iopl;
+        };
+    };
     PVOID Win32Thread;
     PVOID StackBase;
     union
@@ -884,15 +924,18 @@ typedef struct _KTHREAD
         {
             UCHAR SuspendApcFill5[47];
             UCHAR PowerState;
+            ULONG UserTime;
         };
     };
-    ULONG UserTime;
     union
     {
         KSEMAPHORE SuspendSemaphore;
-        UCHAR SuspendSemaphorefill[20];
+        struct
+        {
+            UCHAR SuspendSemaphorefill[20];
+            ULONG SListFaultCount;
+        };
     };
-    ULONG SListFaultCount;
     LIST_ENTRY ThreadListEntry;
 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
     LIST_ENTRY MutantListHead;
@@ -902,7 +945,6 @@ typedef struct _KTHREAD
     PVOID MdlForLockedteb;
 #endif
 } KTHREAD;
-#include <poppack.h>
 
 #define ASSERT_THREAD(object) \
     ASSERT((((object)->DispatcherHeader.Type & KOBJECT_TYPE_MASK) == ThreadObject))
@@ -914,7 +956,12 @@ typedef struct _KPROCESS
 {
     DISPATCHER_HEADER Header;
     LIST_ENTRY ProfileListHead;
-    LARGE_INTEGER DirectoryTableBase;
+#if (NTDDI_VERSION >= NTDDI_LONGHORN)
+    ULONG DirectoryTableBase;
+    ULONG Unused0;
+#else
+    ULONG DirectoryTableBase[2];
+#endif
 #if defined(_M_IX86)
     KGDTENTRY LdtDescriptor;
     KIDTENTRY Int21Descriptor;
@@ -959,7 +1006,7 @@ typedef struct _KPROCESS
 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
     ULONGLONG CycleTime;
 #endif
-} KPROCESS, *PKPROCESS;
+} KPROCESS;
 
 #define ASSERT_PROCESS(object) \
     ASSERT((((object)->Header.Type & KOBJECT_TYPE_MASK) == ProcessObject))