fixed some signed/unsigned comparison warnings with -Wsign-compare
[reactos.git] / reactos / include / ndk / ketypes.h
1 /*
2 * PROJECT: ReactOS Native Headers
3 * FILE: include/ndk/ketypes.h
4 * PURPOSE: Definitions for Kernel Types not defined in DDK/IFS
5 * PROGRAMMER: Alex Ionescu (alex@relsoft.net)
6 * UPDATE HISTORY:
7 * Created 06/10/04
8 */
9 #ifndef _KETYPES_H
10 #define _KETYPES_H
11
12 /* DEPENDENCIES **************************************************************/
13 #include "haltypes.h"
14 #include "potypes.h"
15 #include "mmtypes.h"
16 #include <arc/arc.h>
17
18 /*
19 * Architecture-specific types
20 * NB: Although KPROCESS is Arch-Specific,
21 * only some members are different and we will use #ifdef
22 * directly in the structure to avoid dependency-hell
23 */
24 #include "arch/ketypes.h"
25
26 /* CONSTANTS *****************************************************************/
27 #define SSDT_MAX_ENTRIES 4
28 #define PROCESSOR_FEATURE_MAX 64
29
30 #define CONTEXT_DEBUGGER (CONTEXT_FULL | CONTEXT_FLOATING_POINT)
31
32 #define THREAD_WAIT_OBJECTS 4
33
34 /* EXPORTED DATA *************************************************************/
35 extern CHAR NTOSAPI KeNumberProcessors;
36 extern LOADER_PARAMETER_BLOCK NTOSAPI KeLoaderBlock;
37 extern ULONG NTOSAPI KeDcacheFlushCount;
38 extern ULONG NTOSAPI KeIcacheFlushCount;
39 extern KAFFINITY NTOSAPI KeActiveProcessors;
40 extern ULONG NTOSAPI KiDmaIoCoherency; /* RISC Architectures only */
41 extern ULONG NTOSAPI KeMaximumIncrement;
42 extern ULONG NTOSAPI KeMinimumIncrement;
43 extern ULONG NTOSAPI NtBuildNumber;
44 extern SSDT_ENTRY NTOSAPI KeServiceDescriptorTable[SSDT_MAX_ENTRIES];
45 extern SSDT_ENTRY NTOSAPI KeServiceDescriptorTableShadow[SSDT_MAX_ENTRIES];
46
47 /* ENUMERATIONS **************************************************************/
48
49 /* TYPES *********************************************************************/
50
51 typedef struct _CONFIGURATION_COMPONENT_DATA
52 {
53 struct _CONFIGURATION_COMPONENT_DATA *Parent;
54 struct _CONFIGURATION_COMPONENT_DATA *Child;
55 struct _CONFIGURATION_COMPONENT_DATA *Sibling;
56 CONFIGURATION_COMPONENT Component;
57 } CONFIGURATION_COMPONENT_DATA, *PCONFIGURATION_COMPONENT_DATA;
58
59 typedef enum _KAPC_ENVIRONMENT
60 {
61 OriginalApcEnvironment,
62 AttachedApcEnvironment,
63 CurrentApcEnvironment
64 } KAPC_ENVIRONMENT;
65
66 /* We don't want to force NTIFS usage only for a single structure */
67 #ifndef _NTIFS_
68 typedef struct _KAPC_STATE
69 {
70 LIST_ENTRY ApcListHead[2];
71 PKPROCESS Process;
72 BOOLEAN KernelApcInProgress;
73 BOOLEAN KernelApcPending;
74 BOOLEAN UserApcPending;
75 } KAPC_STATE, *PKAPC_STATE, *RESTRICTED_POINTER PRKAPC_STATE;
76 #endif
77
78 typedef struct _KNODE
79 {
80 SLIST_HEADER DeadStackList;
81 SLIST_HEADER PfnDereferenceSListHead;
82 ULONG ProcessorMask;
83 ULONG Color;
84 UCHAR Seed;
85 UCHAR NodeNumber;
86 ULONG Flags;
87 ULONG MmShiftedColor;
88 ULONG FreeCount[2];
89 struct _SINGLE_LIST_ENTRY *PfnDeferredList;
90 } KNODE, *PKNODE;
91
92 typedef struct _KPROFILE
93 {
94 CSHORT Type;
95 CSHORT Size;
96 LIST_ENTRY ListEntry;
97 PVOID RegionStart;
98 PVOID RegionEnd;
99 ULONG BucketShift;
100 PVOID Buffer;
101 KPROFILE_SOURCE Source;
102 ULONG Affinity;
103 BOOLEAN Active;
104 struct _KPROCESS *Process;
105 } KPROFILE, *PKPROFILE;
106
107 typedef struct _KINTERRUPT
108 {
109 CSHORT Type;
110 CSHORT Size;
111 LIST_ENTRY InterruptListEntry;
112 PKSERVICE_ROUTINE ServiceRoutine;
113 PVOID ServiceContext;
114 KSPIN_LOCK SpinLock;
115 ULONG TickCount;
116 PKSPIN_LOCK ActualLock;
117 PVOID DispatchAddress;
118 ULONG Vector;
119 KIRQL Irql;
120 KIRQL SynchronizeIrql;
121 BOOLEAN FloatingSave;
122 BOOLEAN Connected;
123 CHAR Number;
124 UCHAR ShareVector;
125 KINTERRUPT_MODE Mode;
126 ULONG ServiceCount;
127 ULONG DispatchCount;
128 ULONG DispatchCode[106];
129 } KINTERRUPT, *PKINTERRUPT;
130
131 typedef struct _KEVENT_PAIR
132 {
133 CSHORT Type;
134 CSHORT Size;
135 KEVENT LowEvent;
136 KEVENT HighEvent;
137 } KEVENT_PAIR, *PKEVENT_PAIR;
138
139 typedef struct _KEXECUTE_OPTIONS
140 {
141 UCHAR ExecuteDisable:1;
142 UCHAR ExecuteEnable:1;
143 UCHAR DisableThunkEmulation:1;
144 UCHAR Permanent:1;
145 UCHAR ExecuteDispatchEnable:1;
146 UCHAR ImageDispatchEnable:1;
147 UCHAR Spare:2;
148 } KEXECUTE_OPTIONS, *PKEXECUTE_OPTIONS;
149
150 typedef enum _KOBJECTS
151 {
152 EventNotificationObject = 0,
153 EventSynchronizationObject = 1,
154 MutantObject = 2,
155 ProcessObject = 3,
156 QueueObject = 4,
157 SemaphoreObject = 5,
158 ThreadObject = 6,
159 GateObject = 7,
160 TimerNotificationObject = 8,
161 TimerSynchronizationObject = 9,
162 Spare2Object = 10,
163 Spare3Object = 11,
164 Spare4Object = 12,
165 Spare5Object = 13,
166 Spare6Object = 14,
167 Spare7Object = 15,
168 Spare8Object = 16,
169 Spare9Object = 17,
170 ApcObject = 18,
171 DpcObject = 19,
172 DeviceQueueObject = 20,
173 EventPairObject = 21,
174 InterruptObject = 22,
175 ProfileObject = 23,
176 ThreadedDpcObject = 24,
177 MaximumKernelObject = 25
178 } KOBJECTS;
179
180 #include <pshpack1.h>
181
182 typedef struct _KTHREAD
183 {
184 DISPATCHER_HEADER DispatcherHeader; /* 00 */
185 LIST_ENTRY MutantListHead; /* 10 */
186 PVOID InitialStack; /* 18 */
187 ULONG_PTR StackLimit; /* 1C */
188 struct _TEB *Teb; /* 20 */
189 PVOID TlsArray; /* 24 */
190 PVOID KernelStack; /* 28 */
191 UCHAR DebugActive; /* 2C */
192 UCHAR State; /* 2D */
193 BOOLEAN Alerted[2]; /* 2E */
194 UCHAR Iopl; /* 30 */
195 UCHAR NpxState; /* 31 */
196 CHAR Saturation; /* 32 */
197 CHAR Priority; /* 33 */
198 KAPC_STATE ApcState; /* 34 */
199 ULONG ContextSwitches; /* 4C */
200 LONG WaitStatus; /* 50 */
201 KIRQL WaitIrql; /* 54 */
202 CHAR WaitMode; /* 55 */
203 UCHAR WaitNext; /* 56 */
204 UCHAR WaitReason; /* 57 */
205 union /* 58 */
206 {
207 PKWAIT_BLOCK WaitBlockList; /* 58 */
208 PKGATE GateObject; /* 58 */
209 }; /* 58 */
210 LIST_ENTRY WaitListEntry; /* 5C */
211 ULONG WaitTime; /* 64 */
212 CHAR BasePriority; /* 68 */
213 UCHAR DecrementCount; /* 69 */
214 UCHAR PriorityDecrement; /* 6A */
215 CHAR Quantum; /* 6B */
216 KWAIT_BLOCK WaitBlock[4]; /* 6C */
217 PVOID LegoData; /* CC */
218 union
219 {
220 struct
221 {
222 USHORT KernelApcDisable;
223 USHORT SpecialApcDisable;
224 };
225 ULONG CombinedApcDisable; /* D0 */
226 };
227 KAFFINITY UserAffinity; /* D4 */
228 UCHAR SystemAffinityActive;/* D8 */
229 UCHAR PowerState; /* D9 */
230 UCHAR NpxIrql; /* DA */
231 UCHAR Pad[1]; /* DB */
232 PVOID ServiceTable; /* DC */
233 struct _KQUEUE *Queue; /* E0 */
234 KSPIN_LOCK ApcQueueLock; /* E4 */
235 KTIMER Timer; /* E8 */
236 LIST_ENTRY QueueListEntry; /* 110 */
237 KAFFINITY Affinity; /* 118 */
238 UCHAR Preempted; /* 11C */
239 UCHAR ProcessReadyQueue; /* 11D */
240 UCHAR KernelStackResident; /* 11E */
241 UCHAR NextProcessor; /* 11F */
242 PVOID CallbackStack; /* 120 */
243 struct _W32THREAD *Win32Thread; /* 124 */
244 struct _KTRAP_FRAME *TrapFrame; /* 128 */
245 PKAPC_STATE ApcStatePointer[2]; /* 12C */
246 UCHAR EnableStackSwap; /* 134 */
247 UCHAR LargeStack; /* 135 */
248 UCHAR ResourceIndex; /* 136 */
249 UCHAR PreviousMode; /* 137 */
250 ULONG KernelTime; /* 138 */
251 ULONG UserTime; /* 13C */
252 KAPC_STATE SavedApcState; /* 140 */
253 UCHAR Alertable; /* 158 */
254 UCHAR ApcStateIndex; /* 159 */
255 UCHAR ApcQueueable; /* 15A */
256 UCHAR AutoAlignment; /* 15B */
257 PVOID StackBase; /* 15C */
258 KAPC SuspendApc; /* 160 */
259 KSEMAPHORE SuspendSemaphore; /* 190 */
260 LIST_ENTRY ThreadListEntry; /* 1A4 */
261 CHAR FreezeCount; /* 1AC */
262 UCHAR SuspendCount; /* 1AD */
263 UCHAR IdealProcessor; /* 1AE */
264 UCHAR DisableBoost; /* 1AF */
265 UCHAR QuantumReset; /* 1B0 */
266 } KTHREAD;
267
268 #include <poppack.h>
269
270 typedef struct _KPROCESS
271 {
272 DISPATCHER_HEADER Header; /* 000 */
273 LIST_ENTRY ProfileListHead; /* 010 */
274 PHYSICAL_ADDRESS DirectoryTableBase; /* 018 */
275 #if defined(_M_IX86)
276 KGDTENTRY LdtDescriptor; /* 020 */
277 KIDTENTRY Int21Descriptor; /* 028 */
278 USHORT IopmOffset; /* 030 */
279 UCHAR Iopl; /* 032 */
280 UCHAR Unused; /* 033 */
281 #endif
282 ULONG ActiveProcessors; /* 034 */
283 ULONG KernelTime; /* 038 */
284 ULONG UserTime; /* 03C */
285 LIST_ENTRY ReadyListHead; /* 040 */
286 LIST_ENTRY SwapListEntry; /* 048 */
287 PVOID VdmTrapcHandler; /* 04C */
288 LIST_ENTRY ThreadListHead; /* 050 */
289 KSPIN_LOCK ProcessLock; /* 058 */
290 KAFFINITY Affinity; /* 05C */
291 union
292 {
293 struct
294 {
295 ULONG AutoAlignment:1; /* 060.0 */
296 ULONG DisableBoost:1; /* 060.1 */
297 ULONG DisableQuantum:1; /* 060.2 */
298 ULONG ReservedFlags:29; /* 060.3 */
299 };
300 ULONG ProcessFlags; /* 060 */
301 };
302 CHAR BasePriority; /* 064 */
303 CHAR QuantumReset; /* 065 */
304 UCHAR State; /* 066 */
305 UCHAR ThreadSeed; /* 067 */
306 UCHAR PowerState; /* 068 */
307 UCHAR IdealNode; /* 069 */
308 UCHAR Visited; /* 06A */
309 KEXECUTE_OPTIONS Flags; /* 06B */
310 ULONG StackCount; /* 06C */
311 LIST_ENTRY ProcessListEntry; /* 070 */
312 } KPROCESS;
313
314 typedef enum _KTHREAD_STATE
315 {
316 Initialized,
317 Ready,
318 Running,
319 Standby,
320 Terminated,
321 Waiting,
322 Transition,
323 DeferredReady,
324 } KTHREAD_STATE, *PKTHREAD_STATE;
325
326 #endif