005c3901088e7628fb8ad494814edd7cfcfff3ff
[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 two structures */
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
77 typedef struct _KQUEUE
78 {
79 DISPATCHER_HEADER Header;
80 LIST_ENTRY EntryListHead;
81 ULONG CurrentCount;
82 ULONG MaximumCount;
83 LIST_ENTRY ThreadListHead;
84 } KQUEUE, *PKQUEUE, *RESTRICTED_POINTER PRKQUEUE;
85 #endif
86
87 typedef struct _KNODE
88 {
89 SLIST_HEADER DeadStackList;
90 SLIST_HEADER PfnDereferenceSListHead;
91 ULONG ProcessorMask;
92 ULONG Color;
93 UCHAR Seed;
94 UCHAR NodeNumber;
95 ULONG Flags;
96 ULONG MmShiftedColor;
97 ULONG FreeCount[2];
98 struct _SINGLE_LIST_ENTRY *PfnDeferredList;
99 } KNODE, *PKNODE;
100
101 typedef struct _KPROFILE
102 {
103 CSHORT Type;
104 CSHORT Size;
105 LIST_ENTRY ListEntry;
106 PVOID RegionStart;
107 PVOID RegionEnd;
108 ULONG BucketShift;
109 PVOID Buffer;
110 KPROFILE_SOURCE Source;
111 ULONG Affinity;
112 BOOLEAN Active;
113 struct _KPROCESS *Process;
114 } KPROFILE, *PKPROFILE;
115
116 typedef struct _KINTERRUPT
117 {
118 CSHORT Type;
119 CSHORT Size;
120 LIST_ENTRY InterruptListEntry;
121 PKSERVICE_ROUTINE ServiceRoutine;
122 PVOID ServiceContext;
123 KSPIN_LOCK SpinLock;
124 ULONG TickCount;
125 PKSPIN_LOCK ActualLock;
126 PVOID DispatchAddress;
127 ULONG Vector;
128 KIRQL Irql;
129 KIRQL SynchronizeIrql;
130 BOOLEAN FloatingSave;
131 BOOLEAN Connected;
132 CHAR Number;
133 UCHAR ShareVector;
134 KINTERRUPT_MODE Mode;
135 ULONG ServiceCount;
136 ULONG DispatchCount;
137 ULONG DispatchCode[106];
138 } KINTERRUPT, *PKINTERRUPT;
139
140 typedef struct _KEVENT_PAIR
141 {
142 CSHORT Type;
143 CSHORT Size;
144 KEVENT LowEvent;
145 KEVENT HighEvent;
146 } KEVENT_PAIR, *PKEVENT_PAIR;
147
148 typedef struct _KEXECUTE_OPTIONS
149 {
150 UCHAR ExecuteDisable:1;
151 UCHAR ExecuteEnable:1;
152 UCHAR DisableThunkEmulation:1;
153 UCHAR Permanent:1;
154 UCHAR ExecuteDispatchEnable:1;
155 UCHAR ImageDispatchEnable:1;
156 UCHAR Spare:2;
157 } KEXECUTE_OPTIONS, *PKEXECUTE_OPTIONS;
158
159 typedef enum _KOBJECTS
160 {
161 EventNotificationObject = 0,
162 EventSynchronizationObject = 1,
163 MutantObject = 2,
164 ProcessObject = 3,
165 QueueObject = 4,
166 SemaphoreObject = 5,
167 ThreadObject = 6,
168 GateObject = 7,
169 TimerNotificationObject = 8,
170 TimerSynchronizationObject = 9,
171 Spare2Object = 10,
172 Spare3Object = 11,
173 Spare4Object = 12,
174 Spare5Object = 13,
175 Spare6Object = 14,
176 Spare7Object = 15,
177 Spare8Object = 16,
178 Spare9Object = 17,
179 ApcObject = 18,
180 DpcObject = 19,
181 DeviceQueueObject = 20,
182 EventPairObject = 21,
183 InterruptObject = 22,
184 ProfileObject = 23,
185 ThreadedDpcObject = 24,
186 MaximumKernelObject = 25
187 } KOBJECTS;
188
189 #include <pshpack1.h>
190
191 typedef struct _KTHREAD
192 {
193 DISPATCHER_HEADER DispatcherHeader; /* 00 */
194 LIST_ENTRY MutantListHead; /* 10 */
195 PVOID InitialStack; /* 18 */
196 ULONG_PTR StackLimit; /* 1C */
197 struct _TEB *Teb; /* 20 */
198 PVOID TlsArray; /* 24 */
199 PVOID KernelStack; /* 28 */
200 UCHAR DebugActive; /* 2C */
201 UCHAR State; /* 2D */
202 BOOLEAN Alerted[2]; /* 2E */
203 UCHAR Iopl; /* 30 */
204 UCHAR NpxState; /* 31 */
205 CHAR Saturation; /* 32 */
206 CHAR Priority; /* 33 */
207 KAPC_STATE ApcState; /* 34 */
208 ULONG ContextSwitches; /* 4C */
209 LONG WaitStatus; /* 50 */
210 KIRQL WaitIrql; /* 54 */
211 CHAR WaitMode; /* 55 */
212 UCHAR WaitNext; /* 56 */
213 UCHAR WaitReason; /* 57 */
214 union /* 58 */
215 {
216 PKWAIT_BLOCK WaitBlockList; /* 58 */
217 PKGATE GateObject; /* 58 */
218 }; /* 58 */
219 LIST_ENTRY WaitListEntry; /* 5C */
220 ULONG WaitTime; /* 64 */
221 CHAR BasePriority; /* 68 */
222 UCHAR DecrementCount; /* 69 */
223 UCHAR PriorityDecrement; /* 6A */
224 CHAR Quantum; /* 6B */
225 KWAIT_BLOCK WaitBlock[4]; /* 6C */
226 PVOID LegoData; /* CC */
227 union
228 {
229 struct
230 {
231 USHORT KernelApcDisable;
232 USHORT SpecialApcDisable;
233 };
234 ULONG CombinedApcDisable; /* D0 */
235 };
236 KAFFINITY UserAffinity; /* D4 */
237 UCHAR SystemAffinityActive;/* D8 */
238 UCHAR PowerState; /* D9 */
239 UCHAR NpxIrql; /* DA */
240 UCHAR Pad[1]; /* DB */
241 PVOID ServiceTable; /* DC */
242 struct _KQUEUE *Queue; /* E0 */
243 KSPIN_LOCK ApcQueueLock; /* E4 */
244 KTIMER Timer; /* E8 */
245 LIST_ENTRY QueueListEntry; /* 110 */
246 KAFFINITY Affinity; /* 118 */
247 UCHAR Preempted; /* 11C */
248 UCHAR ProcessReadyQueue; /* 11D */
249 UCHAR KernelStackResident; /* 11E */
250 UCHAR NextProcessor; /* 11F */
251 PVOID CallbackStack; /* 120 */
252 struct _W32THREAD *Win32Thread; /* 124 */
253 struct _KTRAP_FRAME *TrapFrame; /* 128 */
254 PKAPC_STATE ApcStatePointer[2]; /* 12C */
255 UCHAR EnableStackSwap; /* 134 */
256 UCHAR LargeStack; /* 135 */
257 UCHAR ResourceIndex; /* 136 */
258 UCHAR PreviousMode; /* 137 */
259 ULONG KernelTime; /* 138 */
260 ULONG UserTime; /* 13C */
261 KAPC_STATE SavedApcState; /* 140 */
262 UCHAR Alertable; /* 158 */
263 UCHAR ApcStateIndex; /* 159 */
264 UCHAR ApcQueueable; /* 15A */
265 UCHAR AutoAlignment; /* 15B */
266 PVOID StackBase; /* 15C */
267 KAPC SuspendApc; /* 160 */
268 KSEMAPHORE SuspendSemaphore; /* 190 */
269 LIST_ENTRY ThreadListEntry; /* 1A4 */
270 CHAR FreezeCount; /* 1AC */
271 UCHAR SuspendCount; /* 1AD */
272 UCHAR IdealProcessor; /* 1AE */
273 UCHAR DisableBoost; /* 1AF */
274 UCHAR QuantumReset; /* 1B0 */
275 } KTHREAD;
276
277 #include <poppack.h>
278
279 typedef struct _KPROCESS
280 {
281 DISPATCHER_HEADER Header; /* 000 */
282 LIST_ENTRY ProfileListHead; /* 010 */
283 PHYSICAL_ADDRESS DirectoryTableBase; /* 018 */
284 #if defined(_M_IX86)
285 KGDTENTRY LdtDescriptor; /* 020 */
286 KIDTENTRY Int21Descriptor; /* 028 */
287 USHORT IopmOffset; /* 030 */
288 UCHAR Iopl; /* 032 */
289 UCHAR Unused; /* 033 */
290 #endif
291 ULONG ActiveProcessors; /* 034 */
292 ULONG KernelTime; /* 038 */
293 ULONG UserTime; /* 03C */
294 LIST_ENTRY ReadyListHead; /* 040 */
295 LIST_ENTRY SwapListEntry; /* 048 */
296 PVOID VdmTrapcHandler; /* 04C */
297 LIST_ENTRY ThreadListHead; /* 050 */
298 KSPIN_LOCK ProcessLock; /* 058 */
299 KAFFINITY Affinity; /* 05C */
300 union
301 {
302 struct
303 {
304 ULONG AutoAlignment:1; /* 060.0 */
305 ULONG DisableBoost:1; /* 060.1 */
306 ULONG DisableQuantum:1; /* 060.2 */
307 ULONG ReservedFlags:29; /* 060.3 */
308 };
309 ULONG ProcessFlags; /* 060 */
310 };
311 CHAR BasePriority; /* 064 */
312 CHAR QuantumReset; /* 065 */
313 UCHAR State; /* 066 */
314 UCHAR ThreadSeed; /* 067 */
315 UCHAR PowerState; /* 068 */
316 UCHAR IdealNode; /* 069 */
317 UCHAR Visited; /* 06A */
318 KEXECUTE_OPTIONS Flags; /* 06B */
319 ULONG StackCount; /* 06C */
320 LIST_ENTRY ProcessListEntry; /* 070 */
321 } KPROCESS;
322
323 typedef enum _KTHREAD_STATE
324 {
325 Initialized,
326 Ready,
327 Running,
328 Standby,
329 Terminated,
330 Waiting,
331 Transition,
332 DeferredReady,
333 } KTHREAD_STATE, *PKTHREAD_STATE;
334
335 #endif