efa3b73b11d5d029d831e3aaa2fb3ff65c49a4ae
[reactos.git] / reactos / include / ddk / ketypes.h
1 /* KERNEL TYPES **************************************************************/
2
3 #ifndef __INCLUDE_DDK_KETYPES_H
4 #define __INCLUDE_DDK_KETYPES_H
5
6 /* include ntos/ketypes.h here? */
7
8 # define RESTRICTED_POINTER __restrict
9
10 struct _KMUTANT;
11
12 typedef LONG KPRIORITY;
13
14 typedef LONG FLONG;
15
16
17 typedef VOID STDCALL_FUNC
18 (*PKBUGCHECK_CALLBACK_ROUTINE)(PVOID Buffer, ULONG Length);
19
20 typedef BOOLEAN STDCALL_FUNC
21 (*PKSYNCHRONIZE_ROUTINE)(PVOID SynchronizeContext);
22
23 struct _KAPC;
24
25 typedef VOID STDCALL_FUNC
26 (*PKNORMAL_ROUTINE)(PVOID NormalContext,
27 PVOID SystemArgument1,
28 PVOID SystemArgument2);
29
30 typedef VOID STDCALL_FUNC
31 (*PKKERNEL_ROUTINE)(struct _KAPC* Apc,
32 PKNORMAL_ROUTINE* NormalRoutine,
33 PVOID* NormalContext,
34 PVOID* SystemArgument1,
35 PVOID* SystemArgument2);
36
37 typedef VOID STDCALL_FUNC
38 (*PKRUNDOWN_ROUTINE)(struct _KAPC* Apc);
39
40 typedef enum _MODE
41 {
42 KernelMode,
43 UserMode,
44 MaximumMode
45 } MODE;
46
47 typedef enum _KOBJECTS {
48 EventNotificationObject = 0,
49 EventSynchronizationObject = 1,
50 MutantObject = 2,
51 ProcessObject = 3,
52 QueueObject = 4,
53 SemaphoreObject = 5,
54 ThreadObject = 6,
55 GateObject = 7,
56 TimerNotificationObject = 8,
57 TimerSynchronizationObject = 9,
58 Spare2Object = 10,
59 Spare3Object = 11,
60 Spare4Object = 12,
61 Spare5Object = 13,
62 Spare6Object = 14,
63 Spare7Object = 15,
64 Spare8Object = 16,
65 Spare9Object = 17,
66 ApcObject = 18,
67 DpcObject = 19,
68 DeviceQueueObject = 20,
69 EventPairObject = 21,
70 InterruptObject = 22,
71 ProfileObject = 23,
72 ThreadedDpcObject = 24,
73 MaximumKernelObject = 25
74 } KOBJECTS;
75
76 #include <pshpack1.h>
77
78 typedef struct _DISPATCHER_HEADER
79 {
80 union {
81 struct {
82 UCHAR Type;
83 UCHAR Absolute;
84 UCHAR Size;
85 union {
86 UCHAR Inserted;
87 BOOLEAN DebugActive;
88 };
89 };
90 volatile LONG Lock;
91 };
92 LONG SignalState;
93 LIST_ENTRY WaitListHead;
94 } DISPATCHER_HEADER;
95
96 #include <poppack.h>
97
98 typedef struct _KQUEUE
99 {
100 DISPATCHER_HEADER Header;
101 LIST_ENTRY EntryListHead;
102 ULONG CurrentCount;
103 ULONG MaximumCount;
104 LIST_ENTRY ThreadListHead;
105 } KQUEUE, *PKQUEUE, *RESTRICTED_POINTER PRKQUEUE;
106
107 typedef struct _KGATE
108 {
109 DISPATCHER_HEADER Header;
110 } KGATE, *PKGATE, *RESTRICTED_POINTER PRKGATE;
111
112 struct _KDPC;
113
114 typedef struct _KTIMER
115 {
116 DISPATCHER_HEADER Header;
117 ULARGE_INTEGER DueTime;
118 LIST_ENTRY TimerListEntry;
119 struct _KDPC *Dpc;
120 LONG Period;
121 } KTIMER, *PKTIMER, *RESTRICTED_POINTER PRKTIMER;
122
123 typedef struct _KMUTANT
124 {
125 DISPATCHER_HEADER Header;
126 LIST_ENTRY MutantListEntry;
127 struct _KTHREAD *RESTRICTED_POINTER OwnerThread;
128 BOOLEAN Abandoned;
129 UCHAR ApcDisable;
130 } KMUTANT, *PKMUTANT, *RESTRICTED_POINTER PRKMUTANT, KMUTEX, *PKMUTEX, *RESTRICTED_POINTER PRKMUTEX;
131
132 typedef struct _KGUARDED_MUTEX
133 {
134 LONG Count;
135 struct _KTHREAD* Owner;
136 ULONG Contention;
137 KGATE Gate;
138 union {
139 struct {
140 SHORT KernelApcDisable;
141 SHORT SpecialApcDisable;
142 };
143 ULONG CombinedApcDisable;
144 };
145 } KGUARDED_MUTEX, *PKGUARDED_MUTEX;
146
147 typedef struct _KSEMAPHORE
148 {
149 DISPATCHER_HEADER Header;
150 LONG Limit;
151 } KSEMAPHORE, *PKSEMAPHORE, *RESTRICTED_POINTER PRKSEMAPHORE;
152
153 typedef struct _KEVENT
154 {
155 DISPATCHER_HEADER Header;
156 } KEVENT, *PKEVENT, *RESTRICTED_POINTER PRKEVENT;
157
158 typedef struct _KEVENT_PAIR
159 {
160 CSHORT Type;
161 CSHORT Size;
162 KEVENT LowEvent;
163 KEVENT HighEvent;
164 } KEVENT_PAIR, *PKEVENT_PAIR;
165
166 typedef ULONG_PTR KSPIN_LOCK, *PKSPIN_LOCK;
167
168 typedef struct _KDEVICE_QUEUE
169 {
170 CSHORT Type;
171 CSHORT Size;
172 LIST_ENTRY DeviceListHead;
173 KSPIN_LOCK Lock;
174 BOOLEAN Busy;
175 } KDEVICE_QUEUE, *PKDEVICE_QUEUE, *RESTRICTED_POINTER PRKDEVICE_QUEUE;
176
177 typedef struct _KDEVICE_QUEUE_ENTRY
178 {
179 LIST_ENTRY DeviceListEntry;
180 ULONG SortKey;
181 BOOLEAN Inserted;
182 } KDEVICE_QUEUE_ENTRY, *PKDEVICE_QUEUE_ENTRY, *RESTRICTED_POINTER PRKDEVICE_QUEUE_ENTRY;
183
184 /*
185 * Size of the profile hash table.
186 */
187 #define PROFILE_HASH_TABLE_SIZE (32)
188
189 #include <pshpack2.h>
190
191 typedef struct _KAPC
192 {
193 CSHORT Type;
194 CSHORT Size;
195 ULONG Spare0;
196 struct _KTHREAD* Thread;
197 LIST_ENTRY ApcListEntry;
198 PKKERNEL_ROUTINE KernelRoutine;
199 PKRUNDOWN_ROUTINE RundownRoutine;
200 PKNORMAL_ROUTINE NormalRoutine;
201 PVOID NormalContext;
202 PVOID SystemArgument1;
203 PVOID SystemArgument2;
204 CCHAR ApcStateIndex;
205 KPROCESSOR_MODE ApcMode;
206 BOOLEAN Inserted;
207 } KAPC, *PKAPC, *RESTRICTED_POINTER PRKAPC;
208 #include <poppack.h>
209
210 #ifndef __USE_W32API
211
212 typedef struct _KAPC_STATE
213 {
214 LIST_ENTRY ApcListHead[MaximumMode];
215 struct _KPROCESS *Process;
216 BOOLEAN KernelApcInProgress;
217 BOOLEAN KernelApcPending;
218 BOOLEAN UserApcPending;
219 } KAPC_STATE, *PKAPC_STATE, *RESTRICTED_POINTER PRKAPC_STATE;
220
221 #endif /* __USE_W32API */
222
223 typedef struct _KBUGCHECK_CALLBACK_RECORD
224 {
225 LIST_ENTRY Entry;
226 PKBUGCHECK_CALLBACK_ROUTINE CallbackRoutine;
227 PVOID Buffer;
228 ULONG Length;
229 PUCHAR Component;
230 ULONG Checksum;
231 UCHAR State;
232 } KBUGCHECK_CALLBACK_RECORD, *PKBUGCHECK_CALLBACK_RECORD;
233
234 struct _KDPC;
235
236 typedef struct _KSPIN_LOCK_QUEUE {
237 struct _KSPIN_LOCK_QUEUE * volatile Next;
238 PKSPIN_LOCK volatile Lock;
239 } KSPIN_LOCK_QUEUE, *PKSPIN_LOCK_QUEUE;
240
241 typedef struct _KLOCK_QUEUE_HANDLE {
242 KSPIN_LOCK_QUEUE LockQueue;
243 KIRQL OldIrql;
244 } KLOCK_QUEUE_HANDLE, *PKLOCK_QUEUE_HANDLE;
245
246 typedef struct _KWAIT_BLOCK
247 {
248 LIST_ENTRY WaitListEntry;
249 struct _KTHREAD *RESTRICTED_POINTER Thread;
250 PVOID Object;
251 struct _KWAIT_BLOCK *RESTRICTED_POINTER NextWaitBlock;
252 USHORT WaitKey;
253 USHORT WaitType;
254 } KWAIT_BLOCK, *PKWAIT_BLOCK, *RESTRICTED_POINTER PRKWAIT_BLOCK;
255
256 /*
257 * PURPOSE: Defines a delayed procedure call routine
258 * NOTE:
259 * Dpc = The associated DPC object
260 * DeferredContext = Driver defined context for the DPC
261 * SystemArgument[1-2] = Undocumented.
262 *
263 */
264 typedef VOID STDCALL_FUNC
265 (*PKDEFERRED_ROUTINE)(struct _KDPC* Dpc,
266 PVOID DeferredContext,
267 PVOID SystemArgument1,
268 PVOID SystemArgument2);
269
270 #define DPC_NORMAL 0
271 #define DPC_THREADED 1
272 /*
273 * PURPOSE: Defines a delayed procedure call object
274 */
275 typedef struct _KDPC
276 {
277 CSHORT Type;
278 UCHAR Number;
279 UCHAR Importance;
280 LIST_ENTRY DpcListEntry;
281 PKDEFERRED_ROUTINE DeferredRoutine;
282 PVOID DeferredContext;
283 PVOID SystemArgument1;
284 PVOID SystemArgument2;
285 PVOID DpcData;
286 } KDPC, *PKDPC;
287
288 typedef struct _KDPC_DATA {
289 LIST_ENTRY DpcListHead;
290 ULONG DpcLock;
291 ULONG DpcQueueDepth;
292 ULONG DpcCount;
293 } KDPC_DATA, *PKDPC_DATA;
294
295 typedef enum _KBUGCHECK_CALLBACK_REASON {
296 KbCallbackInvalid,
297 KbCallbackReserved1,
298 KbCallbackSecondaryDumpData,
299 KbCallbackDumpIo,
300 } KBUGCHECK_CALLBACK_REASON;
301
302 typedef
303 VOID
304 (*PKBUGCHECK_REASON_CALLBACK_ROUTINE) (
305 IN KBUGCHECK_CALLBACK_REASON Reason,
306 IN PVOID Record, // This should be struct _KBUGCHECK_REASON_CALLBACK_RECORD* but minggw doesn't want to allow that...
307 IN OUT PVOID ReasonSpecificData,
308 IN ULONG ReasonSpecificDataLength
309 );
310
311 typedef struct _KBUGCHECK_REASON_CALLBACK_RECORD {
312 LIST_ENTRY Entry;
313 PKBUGCHECK_REASON_CALLBACK_ROUTINE CallbackRoutine;
314 PUCHAR Component;
315 ULONG_PTR Checksum;
316 KBUGCHECK_CALLBACK_REASON Reason;
317 UCHAR State;
318 } KBUGCHECK_REASON_CALLBACK_RECORD, *PKBUGCHECK_REASON_CALLBACK_RECORD;
319
320 struct _KINTERRUPT;
321
322 typedef BOOLEAN STDCALL_FUNC
323 (*PKSERVICE_ROUTINE)(struct _KINTERRUPT* Interrupt,
324 PVOID ServiceContext);
325 typedef struct _EPROCESS EPROCESS, *PEPROCESS;
326
327 typedef HANDLE HSEMAPHORE;
328
329 typedef HANDLE HDRVOBJ;
330
331 typedef LONG FLOAT_LONG, *PFLOAT_LONG;
332
333 typedef LONG FLOATL;
334
335 typedef LONG FIX; /* fixed-point number */
336
337 typedef struct _M128 {
338 ULONGLONG Low;
339 LONGLONG High;
340 } M128, *PM128;
341
342 typedef struct _KEXCEPTION_FRAME {
343 ULONG64 P1Home;
344 ULONG64 P2Home;
345 ULONG64 P3Home;
346 ULONG64 P4Home;
347 ULONG64 P5;
348 ULONG64 InitialStack;
349 M128 Xmm6;
350 M128 Xmm7;
351 M128 Xmm8;
352 M128 Xmm9;
353 M128 Xmm10;
354 M128 Xmm11;
355 M128 Xmm12;
356 M128 Xmm13;
357 M128 Xmm14;
358 M128 Xmm15;
359 ULONG64 TrapFrame;
360 ULONG64 CallbackStack;
361 ULONG64 OutputBuffer;
362 ULONG64 OutputLength;
363 UCHAR ExceptionRecord[64];
364 ULONG64 Fill1;
365 ULONG64 Rbp;
366 ULONG64 Rbx;
367 ULONG64 Rdi;
368 ULONG64 Rsi;
369 ULONG64 R12;
370 ULONG64 R13;
371 ULONG64 R14;
372 ULONG64 R15;
373 ULONG64 Return;
374 } KEXCEPTION_FRAME, *PKEXCEPTION_FRAME;
375
376 /* copied from W32API */
377 typedef struct _KFLOATING_SAVE
378 {
379 ULONG ControlWord;
380 ULONG StatusWord;
381 ULONG ErrorOffset;
382 ULONG ErrorSelector;
383 ULONG DataOffset;
384 ULONG DataSelector;
385 ULONG Cr0NpxState;
386 ULONG Spare1;
387 } KFLOATING_SAVE, *PKFLOATING_SAVE;
388
389 #endif /* __INCLUDE_DDK_KETYPES_H */