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