Add vcprojmaker.cpp to the msvc project
[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 #ifndef NTOS_MODE_USER
14 #include <arc/arc.h>
15 #include "arch/ketypes.h"
16 #endif
17
18 /* CONSTANTS *****************************************************************/
19 #define SSDT_MAX_ENTRIES 4
20 #define PROCESSOR_FEATURE_MAX 64
21 #define CONTEXT_DEBUGGER (CONTEXT_FULL | CONTEXT_FLOATING_POINT)
22
23 #ifdef NTOS_MODE_USER
24 #define SharedUserData ((KUSER_SHARED_DATA * CONST) USER_SHARED_DATA)
25 #endif
26
27 /* ENUMERATIONS **************************************************************/
28
29 #ifdef NTOS_MODE_USER
30 typedef enum _EVENT_TYPE
31 {
32 NotificationEvent,
33 SynchronizationEvent
34 } EVENT_TYPE;
35
36 typedef enum _TIMER_TYPE
37 {
38 NotificationTimer,
39 SynchronizationTimer
40 } TIMER_TYPE;
41
42 typedef enum _WAIT_TYPE
43 {
44 WaitAll,
45 WaitAny
46 } WAIT_TYPE;
47
48 typedef enum _MODE
49 {
50 KernelMode,
51 UserMode,
52 MaximumMode
53 } MODE;
54
55 typedef enum _KWAIT_REASON
56 {
57 Executive,
58 FreePage,
59 PageIn,
60 PoolAllocation,
61 DelayExecution,
62 Suspended,
63 UserRequest,
64 WrExecutive,
65 WrFreePage,
66 WrPageIn,
67 WrPoolAllocation,
68 WrDelayExecution,
69 WrSuspended,
70 WrUserRequest,
71 WrEventPair,
72 WrQueue,
73 WrLpcReceive,
74 WrLpcReply,
75 WrVirtualMemory,
76 WrPageOut,
77 WrRendezvous,
78 Spare2,
79 WrGuardedMutex,
80 Spare4,
81 Spare5,
82 Spare6,
83 WrKernel,
84 WrResource,
85 WrPushLock,
86 WrMutex,
87 WrQuantumEnd,
88 WrDispatchInt,
89 WrPreempted,
90 WrYieldExecution,
91 MaximumWaitReason
92 } KWAIT_REASON;
93
94 typedef enum _KPROFILE_SOURCE
95 {
96 ProfileTime,
97 ProfileAlignmentFixup,
98 ProfileTotalIssues,
99 ProfilePipelineDry,
100 ProfileLoadInstructions,
101 ProfilePipelineFrozen,
102 ProfileBranchInstructions,
103 ProfileTotalNonissues,
104 ProfileDcacheMisses,
105 ProfileIcacheMisses,
106 ProfileCacheMisses,
107 ProfileBranchMispredictions,
108 ProfileStoreInstructions,
109 ProfileFpInstructions,
110 ProfileIntegerInstructions,
111 Profile2Issue,
112 Profile3Issue,
113 Profile4Issue,
114 ProfileSpecialInstructions,
115 ProfileTotalCycles,
116 ProfileIcacheIssues,
117 ProfileDcacheAccesses,
118 ProfileMemoryBarrierCycles,
119 ProfileLoadLinkedIssues,
120 ProfileMaximum
121 } KPROFILE_SOURCE;
122
123 typedef enum _NT_PRODUCT_TYPE
124 {
125 NtProductWinNt = 1,
126 NtProductLanManNt,
127 NtProductServer
128 } NT_PRODUCT_TYPE, *PNT_PRODUCT_TYPE;
129
130 typedef enum _ALTERNATIVE_ARCHITECTURE_TYPE
131 {
132 StandardDesign,
133 NEC98x86,
134 EndAlternatives
135 } ALTERNATIVE_ARCHITECTURE_TYPE;
136 #endif
137
138 typedef enum _KTHREAD_STATE
139 {
140 Initialized,
141 Ready,
142 Running,
143 Standby,
144 Terminated,
145 Waiting,
146 Transition,
147 DeferredReady,
148 } KTHREAD_STATE, *PKTHREAD_STATE;
149
150 typedef enum _KPROCESS_STATE
151 {
152 ProcessInMemory,
153 ProcessOutOfMemory,
154 ProcessInTransition,
155 } KPROCESS_STATE, *PKPROCESS_STATE;
156
157 /* FUNCTION TYPES ************************************************************/
158
159 #ifdef NTOS_MODE_USER
160 typedef VOID
161 (NTAPI *PKNORMAL_ROUTINE)(
162 IN PVOID NormalContext,
163 IN PVOID SystemArgument1,
164 IN PVOID SystemArgument2);
165
166 typedef VOID
167 (NTAPI *PTIMER_APC_ROUTINE)(
168 IN PVOID TimerContext,
169 IN ULONG TimerLowValue,
170 IN LONG TimerHighValue);
171 #endif
172
173 /* TYPES *********************************************************************/
174
175 typedef LONG KPRIORITY;
176
177 #ifdef NTOS_MODE_USER
178 typedef CCHAR KPROCESSOR_MODE;
179
180 typedef struct _KSYSTEM_TIME
181 {
182 ULONG LowPart;
183 LONG High1Time;
184 LONG High2Time;
185 } KSYSTEM_TIME, *PKSYSTEM_TIME;
186
187 typedef struct _KUSER_SHARED_DATA
188 {
189 ULONG TickCountLowDeprecated;
190 ULONG TickCountMultiplier;
191 volatile KSYSTEM_TIME InterruptTime;
192 volatile KSYSTEM_TIME SystemTime;
193 volatile KSYSTEM_TIME TimeZoneBias;
194 USHORT ImageNumberLow;
195 USHORT ImageNumberHigh;
196 WCHAR NtSystemRoot[260];
197 ULONG MaxStackTraceDepth;
198 ULONG CryptoExponent;
199 ULONG TimeZoneId;
200 ULONG LargePageMinimum;
201 ULONG Reserved2[7];
202 NT_PRODUCT_TYPE NtProductType;
203 BOOLEAN ProductTypeIsValid;
204 ULONG NtMajorVersion;
205 ULONG NtMinorVersion;
206 BOOLEAN ProcessorFeatures[PROCESSOR_FEATURE_MAX];
207 ULONG Reserved1;
208 ULONG Reserved3;
209 volatile ULONG TimeSlip;
210 ALTERNATIVE_ARCHITECTURE_TYPE AlternativeArchitecture;
211 LARGE_INTEGER SystemExpirationDate;
212 ULONG SuiteMask;
213 BOOLEAN KdDebuggerEnabled;
214 volatile ULONG ActiveConsoleId;
215 volatile ULONG DismountCount;
216 ULONG ComPlusPackage;
217 ULONG LastSystemRITEventTickCount;
218 ULONG NumberOfPhysicalPages;
219 BOOLEAN SafeBootMode;
220 ULONG TraceLogging;
221 ULONGLONG Fill0;
222 ULONGLONG SystemCall[4];
223 union {
224 volatile KSYSTEM_TIME TickCount;
225 volatile ULONG64 TickCountQuad;
226 };
227 } KUSER_SHARED_DATA, *PKUSER_SHARED_DATA;
228 #endif
229
230 #ifndef NTOS_MODE_USER
231 typedef struct _CONFIGURATION_COMPONENT_DATA
232 {
233 struct _CONFIGURATION_COMPONENT_DATA *Parent;
234 struct _CONFIGURATION_COMPONENT_DATA *Child;
235 struct _CONFIGURATION_COMPONENT_DATA *Sibling;
236 CONFIGURATION_COMPONENT Component;
237 } CONFIGURATION_COMPONENT_DATA, *PCONFIGURATION_COMPONENT_DATA;
238
239 typedef enum _KAPC_ENVIRONMENT
240 {
241 OriginalApcEnvironment,
242 AttachedApcEnvironment,
243 CurrentApcEnvironment
244 } KAPC_ENVIRONMENT;
245
246 typedef struct _KNODE
247 {
248 SLIST_HEADER DeadStackList;
249 SLIST_HEADER PfnDereferenceSListHead;
250 ULONG ProcessorMask;
251 ULONG Color;
252 UCHAR Seed;
253 UCHAR NodeNumber;
254 ULONG Flags;
255 ULONG MmShiftedColor;
256 ULONG FreeCount[2];
257 struct _SINGLE_LIST_ENTRY *PfnDeferredList;
258 } KNODE, *PKNODE;
259
260 typedef struct _KPROFILE
261 {
262 CSHORT Type;
263 CSHORT Size;
264 LIST_ENTRY ListEntry;
265 PVOID RegionStart;
266 PVOID RegionEnd;
267 ULONG BucketShift;
268 PVOID Buffer;
269 KPROFILE_SOURCE Source;
270 ULONG Affinity;
271 BOOLEAN Active;
272 struct _KPROCESS *Process;
273 } KPROFILE, *PKPROFILE;
274
275 typedef struct _KINTERRUPT
276 {
277 CSHORT Type;
278 CSHORT Size;
279 LIST_ENTRY InterruptListEntry;
280 PKSERVICE_ROUTINE ServiceRoutine;
281 PVOID ServiceContext;
282 KSPIN_LOCK SpinLock;
283 ULONG TickCount;
284 PKSPIN_LOCK ActualLock;
285 PVOID DispatchAddress;
286 ULONG Vector;
287 KIRQL Irql;
288 KIRQL SynchronizeIrql;
289 BOOLEAN FloatingSave;
290 BOOLEAN Connected;
291 CHAR Number;
292 UCHAR ShareVector;
293 KINTERRUPT_MODE Mode;
294 ULONG ServiceCount;
295 ULONG DispatchCount;
296 ULONG DispatchCode[106];
297 } KINTERRUPT, *PKINTERRUPT;
298
299 typedef struct _KEVENT_PAIR
300 {
301 CSHORT Type;
302 CSHORT Size;
303 KEVENT LowEvent;
304 KEVENT HighEvent;
305 } KEVENT_PAIR, *PKEVENT_PAIR;
306
307 typedef struct _KEXECUTE_OPTIONS
308 {
309 UCHAR ExecuteDisable:1;
310 UCHAR ExecuteEnable:1;
311 UCHAR DisableThunkEmulation:1;
312 UCHAR Permanent:1;
313 UCHAR ExecuteDispatchEnable:1;
314 UCHAR ImageDispatchEnable:1;
315 UCHAR Spare:2;
316 } KEXECUTE_OPTIONS, *PKEXECUTE_OPTIONS;
317
318 typedef enum _KOBJECTS
319 {
320 EventNotificationObject = 0,
321 EventSynchronizationObject = 1,
322 MutantObject = 2,
323 ProcessObject = 3,
324 QueueObject = 4,
325 SemaphoreObject = 5,
326 ThreadObject = 6,
327 GateObject = 7,
328 TimerNotificationObject = 8,
329 TimerSynchronizationObject = 9,
330 Spare2Object = 10,
331 Spare3Object = 11,
332 Spare4Object = 12,
333 Spare5Object = 13,
334 Spare6Object = 14,
335 Spare7Object = 15,
336 Spare8Object = 16,
337 Spare9Object = 17,
338 ApcObject = 18,
339 DpcObject = 19,
340 DeviceQueueObject = 20,
341 EventPairObject = 21,
342 InterruptObject = 22,
343 ProfileObject = 23,
344 ThreadedDpcObject = 24,
345 MaximumKernelObject = 25
346 } KOBJECTS;
347
348 #include <pshpack1.h>
349
350 typedef struct _KTHREAD
351 {
352 DISPATCHER_HEADER DispatcherHeader; /* 00 */
353 LIST_ENTRY MutantListHead; /* 10 */
354 PVOID InitialStack; /* 18 */
355 ULONG_PTR StackLimit; /* 1C */
356 struct _TEB *Teb; /* 20 */
357 PVOID TlsArray; /* 24 */
358 PVOID KernelStack; /* 28 */
359 UCHAR DebugActive; /* 2C */
360 UCHAR State; /* 2D */
361 BOOLEAN Alerted[2]; /* 2E */
362 UCHAR Iopl; /* 30 */
363 UCHAR NpxState; /* 31 */
364 CHAR Saturation; /* 32 */
365 CHAR Priority; /* 33 */
366 KAPC_STATE ApcState; /* 34 */
367 ULONG ContextSwitches; /* 4C */
368 LONG WaitStatus; /* 50 */
369 KIRQL WaitIrql; /* 54 */
370 CHAR WaitMode; /* 55 */
371 UCHAR WaitNext; /* 56 */
372 UCHAR WaitReason; /* 57 */
373 union /* 58 */
374 {
375 PKWAIT_BLOCK WaitBlockList; /* 58 */
376 PKGATE GateObject; /* 58 */
377 }; /* 58 */
378 LIST_ENTRY WaitListEntry; /* 5C */
379 ULONG WaitTime; /* 64 */
380 CHAR BasePriority; /* 68 */
381 UCHAR DecrementCount; /* 69 */
382 UCHAR PriorityDecrement; /* 6A */
383 CHAR Quantum; /* 6B */
384 KWAIT_BLOCK WaitBlock[4]; /* 6C */
385 PVOID LegoData; /* CC */
386 union
387 {
388 struct
389 {
390 USHORT KernelApcDisable;
391 USHORT SpecialApcDisable;
392 };
393 ULONG CombinedApcDisable; /* D0 */
394 };
395 KAFFINITY UserAffinity; /* D4 */
396 UCHAR SystemAffinityActive;/* D8 */
397 UCHAR PowerState; /* D9 */
398 UCHAR NpxIrql; /* DA */
399 UCHAR Pad[1]; /* DB */
400 PVOID ServiceTable; /* DC */
401 struct _KQUEUE *Queue; /* E0 */
402 KSPIN_LOCK ApcQueueLock; /* E4 */
403 KTIMER Timer; /* E8 */
404 LIST_ENTRY QueueListEntry; /* 110 */
405 KAFFINITY Affinity; /* 118 */
406 UCHAR Preempted; /* 11C */
407 UCHAR ProcessReadyQueue; /* 11D */
408 UCHAR KernelStackResident; /* 11E */
409 UCHAR NextProcessor; /* 11F */
410 PVOID CallbackStack; /* 120 */
411 struct _W32THREAD *Win32Thread; /* 124 */
412 struct _KTRAP_FRAME *TrapFrame; /* 128 */
413 PKAPC_STATE ApcStatePointer[2]; /* 12C */
414 UCHAR EnableStackSwap; /* 134 */
415 UCHAR LargeStack; /* 135 */
416 UCHAR ResourceIndex; /* 136 */
417 UCHAR PreviousMode; /* 137 */
418 ULONG KernelTime; /* 138 */
419 ULONG UserTime; /* 13C */
420 KAPC_STATE SavedApcState; /* 140 */
421 UCHAR Alertable; /* 158 */
422 UCHAR ApcStateIndex; /* 159 */
423 UCHAR ApcQueueable; /* 15A */
424 UCHAR AutoAlignment; /* 15B */
425 PVOID StackBase; /* 15C */
426 KAPC SuspendApc; /* 160 */
427 KSEMAPHORE SuspendSemaphore; /* 190 */
428 LIST_ENTRY ThreadListEntry; /* 1A4 */
429 CHAR FreezeCount; /* 1AC */
430 UCHAR SuspendCount; /* 1AD */
431 UCHAR IdealProcessor; /* 1AE */
432 UCHAR DisableBoost; /* 1AF */
433 UCHAR QuantumReset; /* 1B0 */
434 } KTHREAD;
435
436 #include <poppack.h>
437
438 typedef struct _KPROCESS
439 {
440 DISPATCHER_HEADER Header; /* 000 */
441 LIST_ENTRY ProfileListHead; /* 010 */
442 PHYSICAL_ADDRESS DirectoryTableBase; /* 018 */
443 #if defined(_M_IX86)
444 KGDTENTRY LdtDescriptor; /* 020 */
445 KIDTENTRY Int21Descriptor; /* 028 */
446 USHORT IopmOffset; /* 030 */
447 UCHAR Iopl; /* 032 */
448 UCHAR Unused; /* 033 */
449 #endif
450 ULONG ActiveProcessors; /* 034 */
451 ULONG KernelTime; /* 038 */
452 ULONG UserTime; /* 03C */
453 LIST_ENTRY ReadyListHead; /* 040 */
454 LIST_ENTRY SwapListEntry; /* 048 */
455 PVOID VdmTrapcHandler; /* 04C */
456 LIST_ENTRY ThreadListHead; /* 050 */
457 KSPIN_LOCK ProcessLock; /* 058 */
458 KAFFINITY Affinity; /* 05C */
459 union
460 {
461 struct
462 {
463 ULONG AutoAlignment:1; /* 060.0 */
464 ULONG DisableBoost:1; /* 060.1 */
465 ULONG DisableQuantum:1; /* 060.2 */
466 ULONG ReservedFlags:29; /* 060.3 */
467 };
468 ULONG ProcessFlags; /* 060 */
469 };
470 CHAR BasePriority; /* 064 */
471 CHAR QuantumReset; /* 065 */
472 UCHAR State; /* 066 */
473 UCHAR ThreadSeed; /* 067 */
474 UCHAR PowerState; /* 068 */
475 UCHAR IdealNode; /* 069 */
476 UCHAR Visited; /* 06A */
477 KEXECUTE_OPTIONS Flags; /* 06B */
478 ULONG StackCount; /* 06C */
479 LIST_ENTRY ProcessListEntry; /* 070 */
480 } KPROCESS;
481
482 typedef struct _KSERVICE_TABLE_DESCRIPTOR
483 {
484 PULONG_PTR Base;
485 PULONG Count;
486 ULONG Limit;
487 #if defined(_IA64_)
488 LONG TableBaseGpOffset;
489 #endif
490 PUCHAR Number;
491 } KSERVICE_TABLE_DESCRIPTOR, *PKSERVICE_TABLE_DESCRIPTOR;
492 #endif /* !NTOS_MODE_USER */
493
494 /* EXPORTED DATA *************************************************************/
495 #ifndef NTOS_MODE_USER
496 extern CHAR NTSYSAPI KeNumberProcessors;
497 extern LOADER_PARAMETER_BLOCK NTSYSAPI KeLoaderBlock;
498 extern ULONG NTSYSAPI KeDcacheFlushCount;
499 extern ULONG NTSYSAPI KeIcacheFlushCount;
500 extern KAFFINITY NTSYSAPI KeActiveProcessors;
501 extern ULONG NTSYSAPI KiDmaIoCoherency; /* RISC Architectures only */
502 extern ULONG NTSYSAPI KeMaximumIncrement;
503 extern ULONG NTSYSAPI KeMinimumIncrement;
504 extern ULONG NTSYSAPI NtBuildNumber;
505 extern KSERVICE_TABLE_DESCRIPTOR NTSYSAPI KeServiceDescriptorTable[SSDT_MAX_ENTRIES];
506 extern KSERVICE_TABLE_DESCRIPTOR NTSYSAPI KeServiceDescriptorTableShadow[SSDT_MAX_ENTRIES];
507 #endif
508
509 #endif