Fix KEBUGCHECK
[reactos.git] / reactos / include / ddk / kefuncs.h
1 #ifndef __INCLUDE_DDK_KEFUNCS_H
2 #define __INCLUDE_DDK_KEFUNCS_H
3
4
5 /* KERNEL FUNCTIONS ********************************************************/
6
7 #ifndef KeFlushIoBuffers
8 #define KeFlushIoBuffers(Mdl, ReadOperation, DmaOperation)
9 #endif
10
11 VOID STDCALL KeAttachProcess (struct _EPROCESS* Process);
12
13 VOID KeDrainApcQueue(VOID);
14 struct _KPROCESS* KeGetCurrentProcess(VOID);
15
16 /*
17 * FUNCTION: Acquires a spinlock so the caller can synchronize access to
18 * data
19 * ARGUMENTS:
20 * SpinLock = Initialized spinlock
21 * OldIrql (OUT) = Set the previous irql on return
22 */
23 VOID STDCALL KeAcquireSpinLock (PKSPIN_LOCK SpinLock,
24 PKIRQL OldIrql);
25
26 #ifndef __USE_W32API
27
28 VOID STDCALL KeAcquireSpinLockAtDpcLevel (IN PKSPIN_LOCK SpinLock);
29
30 //NTOSAPI
31 //DDKFASTAPI
32
33 //STDCALL
34 //VOID
35 //KefAcquireSpinLockAtDpcLevel(
36 // IN PKSPIN_LOCK SpinLock);
37
38 #define KefAcquireSpinLockAtDpcLevel KeAcquireSpinLockAtDpcLevel
39
40 //NTOSAPI
41 //DDKFASTAPI
42
43 STDCALL
44 VOID
45 KeReleaseSpinLockFromDpcLevel(
46 IN PKSPIN_LOCK SpinLock);
47
48 #endif
49
50 /*
51 * FUNCTION: Brings the system down in a controlled manner when an
52 * inconsistency that might otherwise cause corruption has been detected
53 * ARGUMENTS:
54 * BugCheckCode = Specifies the reason for the bug check
55 * RETURNS: Doesn't
56 *
57 * NOTES - please use the macro KEBUGCHECK with the same argument so the end-user
58 * knows what file/line number where the bug check occured
59 */
60 VOID STDCALL KeBugCheck (ULONG BugCheckCode);
61 #define KEBUGCHECK(a) DbgPrint("KeBugCheck at %s:%i\n",__FILE__,__LINE__), KeBugCheck(a)
62
63 /*
64 * FUNCTION: Brings the system down in a controlled manner when an
65 * inconsistency that might otherwise cause corruption has been detected
66 * ARGUMENTS:
67 * BugCheckCode = Specifies the reason for the bug check
68 * BugCheckParameter[1-4] = Additional information about bug
69 * RETURNS: Doesn't
70 *
71 * NOTES - please use the macro KEBUGCHECKEX with the same arguments so the end-user
72 * knows what file/line number where the bug check occured
73 */
74 VOID STDCALL KeBugCheckEx (ULONG BugCheckCode,
75 ULONG BugCheckParameter1,
76 ULONG BugCheckParameter2,
77 ULONG BugCheckParameter3,
78 ULONG BugCheckParameter4);
79 #define KEBUGCHECKEX(a,b,c,d,e) DbgPrint("KeBugCheckEx at %s:%i\n",__FILE__,__LINE__), KeBugCheckEx(a,b,c,d,e)
80
81 BOOLEAN STDCALL KeCancelTimer (PKTIMER Timer);
82
83 VOID STDCALL KeClearEvent (PKEVENT Event);
84
85 NTSTATUS STDCALL KeConnectInterrupt(PKINTERRUPT InterruptObject);
86
87 NTSTATUS STDCALL KeDelayExecutionThread (KPROCESSOR_MODE WaitMode,
88 BOOLEAN Alertable,
89 PLARGE_INTEGER Internal);
90
91 BOOLEAN STDCALL KeDeregisterBugCheckCallback (
92 PKBUGCHECK_CALLBACK_RECORD CallbackRecord);
93
94 VOID STDCALL KeDetachProcess (VOID);
95
96 VOID STDCALL KeDisconnectInterrupt(PKINTERRUPT InterruptObject);
97
98 VOID STDCALL KeEnterCriticalRegion (VOID);
99
100 /*
101 * FUNCTION: Enters the kernel debugger
102 * ARGUMENTS:
103 * None
104 */
105 VOID STDCALL KeEnterKernelDebugger (VOID);
106
107 VOID STDCALL KeFlushWriteBuffer (VOID);
108
109 KIRQL STDCALL KeGetCurrentIrql (VOID);
110
111 #ifndef __USE_W32API
112 ULONG KeGetCurrentProcessorNumber(VOID);
113 ULONG KeGetDcacheFillSize(VOID);
114 ULONG STDCALL KeGetPreviousMode (VOID);
115 #endif
116
117 struct _KTHREAD* STDCALL KeGetCurrentThread (VOID);
118
119 VOID STDCALL KeInitializeApc (IN PKAPC Apc,
120 IN PKTHREAD Thread,
121 IN UCHAR StateIndex,
122 IN PKKERNEL_ROUTINE KernelRoutine,
123 IN PKRUNDOWN_ROUTINE RundownRoutine,
124 IN PKNORMAL_ROUTINE NormalRoutine,
125 IN UCHAR Mode,
126 IN PVOID Context);
127
128
129 /*
130 * VOID
131 * KeInitializeCallbackRecord (
132 * PKBUGCHECK_CALLBACK_RECORD CallbackRecord
133 * );
134 */
135 #ifndef KeInitializeCallbackRecord
136 #define KeInitializeCallbackRecord(CallbackRecord) \
137 (CallbackRecord)->State = BufferEmpty
138 #endif
139
140 VOID STDCALL KeInitializeDeviceQueue (PKDEVICE_QUEUE DeviceQueue);
141
142 VOID STDCALL KeInitializeDpc (PKDPC Dpc,
143 PKDEFERRED_ROUTINE DeferredRoutine,
144 PVOID DeferredContext);
145
146 VOID STDCALL KeInitializeEvent (PKEVENT Event,
147 EVENT_TYPE Type,
148 BOOLEAN State);
149
150 NTSTATUS STDCALL KeInitializeInterrupt(PKINTERRUPT InterruptObject,
151 PKSERVICE_ROUTINE ServiceRoutine,
152 PVOID ServiceContext,
153 PKSPIN_LOCK SpinLock,
154 ULONG Vector,
155 KIRQL Irql,
156 KIRQL SynchronizeIrql,
157 KINTERRUPT_MODE InterruptMode,
158 BOOLEAN ShareVector,
159 KAFFINITY ProcessorEnableMask,
160 BOOLEAN FloatingSave);
161
162 VOID STDCALL KeInitializeMutant(IN PKMUTANT Mutant,
163 IN BOOLEAN InitialOwner);
164
165 VOID STDCALL KeInitializeMutex (PKMUTEX Mutex,
166 ULONG Level);
167
168 VOID STDCALL
169 KeInitializeQueue(IN PKQUEUE Queue,
170 IN ULONG Count);
171
172 PLIST_ENTRY STDCALL
173 KeRundownQueue(IN PKQUEUE Queue);
174
175 VOID STDCALL KeInitializeSemaphore (PKSEMAPHORE Semaphore,
176 LONG Count,
177 LONG Limit);
178
179 /*
180 * FUNCTION: Initializes a spinlock
181 * ARGUMENTS:
182 * SpinLock = Spinlock to initialize
183 */
184 VOID STDCALL KeInitializeSpinLock (PKSPIN_LOCK SpinLock);
185
186 VOID STDCALL KeInitializeTimer (PKTIMER Timer);
187
188 VOID STDCALL KeInitializeTimerEx (PKTIMER Timer,
189 TIMER_TYPE Type);
190
191 BOOLEAN STDCALL KeInsertByKeyDeviceQueue (PKDEVICE_QUEUE DeviceQueue,
192 PKDEVICE_QUEUE_ENTRY QueueEntry,
193 ULONG SortKey);
194
195 BOOLEAN STDCALL KeInsertDeviceQueue (PKDEVICE_QUEUE DeviceQueue,
196 PKDEVICE_QUEUE_ENTRY DeviceQueueEntry);
197
198 LONG STDCALL
199 KeInsertHeadQueue(IN PKQUEUE Queue,
200 IN PLIST_ENTRY Entry);
201
202 LONG STDCALL
203 KeInsertQueue(IN PKQUEUE Queue,
204 IN PLIST_ENTRY Entry);
205
206 BOOLEAN STDCALL KeInsertQueueApc (PKAPC Apc,
207 PVOID SystemArgument1,
208 PVOID SystemArgument2,
209 KPRIORITY PriorityBoost);
210
211 BOOLEAN STDCALL KeInsertQueueDpc (PKDPC Dpc,
212 PVOID SystemArgument1,
213 PVOID SystemArgument2);
214
215 VOID STDCALL KeLeaveCriticalRegion (VOID);
216
217 VOID STDCALL KeLowerIrql (KIRQL NewIrql);
218
219 NTSTATUS STDCALL KePulseEvent (PKEVENT Event,
220 KPRIORITY Increment,
221 BOOLEAN Wait);
222
223 LARGE_INTEGER
224 STDCALL
225 KeQueryPerformanceCounter (
226 PLARGE_INTEGER PerformanceFrequency
227 );
228
229 VOID
230 STDCALL
231 KeQuerySystemTime (
232 PLARGE_INTEGER CurrentTime
233 );
234
235 VOID
236 STDCALL
237 KeQueryTickCount (
238 PLARGE_INTEGER TickCount
239 );
240
241 ULONG
242 STDCALL
243 KeQueryTimeIncrement (
244 VOID
245 );
246
247 VOID
248 STDCALL
249 KeRaiseIrql (
250 KIRQL NewIrql,
251 PKIRQL OldIrql
252 );
253
254 KIRQL
255 STDCALL
256 KeRaiseIrqlToDpcLevel (
257 VOID
258 );
259
260 /*
261 * FUNCTION: Raises a user mode exception
262 * ARGUMENTS:
263 * ExceptionCode = Status code of the exception
264 */
265 VOID
266 STDCALL
267 KeRaiseUserException (
268 IN NTSTATUS ExceptionCode
269 );
270
271 LONG
272 STDCALL
273 KeReadStateEvent (
274 PKEVENT Event
275 );
276
277 LONG STDCALL
278 KeReadStateMutant(IN PKMUTANT Mutant);
279
280 LONG STDCALL
281 KeReadStateMutex(IN PKMUTEX Mutex);
282
283 LONG STDCALL
284 KeReadStateQueue(IN PKQUEUE Queue);
285
286 LONG STDCALL
287 KeReadStateSemaphore(IN PKSEMAPHORE Semaphore);
288
289 BOOLEAN STDCALL
290 KeReadStateTimer(IN PKTIMER Timer);
291
292 BOOLEAN
293 STDCALL
294 KeRegisterBugCheckCallback (
295 PKBUGCHECK_CALLBACK_RECORD CallbackRecord,
296 PKBUGCHECK_CALLBACK_ROUTINE CallbackRoutine,
297 PVOID Buffer,
298 ULONG Length,
299 PUCHAR Component
300 );
301
302 LONG
303 STDCALL
304 KeReleaseMutant(
305 IN PKMUTANT Mutant,
306 IN KPRIORITY Increment,
307 IN BOOLEAN Abandon,
308 IN BOOLEAN Wait
309 );
310
311 LONG
312 STDCALL
313 KeReleaseMutex (
314 PKMUTEX Mutex,
315 BOOLEAN Wait
316 );
317
318 LONG
319 STDCALL
320 KeReleaseSemaphore (
321 PKSEMAPHORE Semaphore,
322 KPRIORITY Increment,
323 LONG Adjustment,
324 BOOLEAN Wait
325 );
326
327 VOID
328 STDCALL
329 KeReleaseSpinLock (
330 PKSPIN_LOCK Spinlock,
331 KIRQL NewIrql
332 );
333
334 #ifndef __USE_W32API
335 VOID
336 STDCALL
337 KeReleaseSpinLockFromDpcLevel (
338 PKSPIN_LOCK Spinlock
339 );
340 #endif
341
342 PKDEVICE_QUEUE_ENTRY
343 STDCALL
344 KeRemoveByKeyDeviceQueue (
345 PKDEVICE_QUEUE DeviceQueue,
346 ULONG SortKey
347 );
348
349 PKDEVICE_QUEUE_ENTRY
350 STDCALL
351 KeRemoveDeviceQueue (
352 PKDEVICE_QUEUE DeviceQueue
353 );
354
355 BOOLEAN STDCALL
356 KeRemoveEntryDeviceQueue(PKDEVICE_QUEUE DeviceQueue,
357 PKDEVICE_QUEUE_ENTRY DeviceQueueEntry);
358
359 PLIST_ENTRY STDCALL
360 KeRemoveQueue(IN PKQUEUE Queue,
361 IN KPROCESSOR_MODE WaitMode,
362 IN PLARGE_INTEGER Timeout OPTIONAL);
363
364 BOOLEAN STDCALL
365 KeRemoveQueueDpc(IN PKDPC Dpc);
366
367 LONG STDCALL
368 KeResetEvent(IN PKEVENT Event);
369
370 LONG STDCALL
371 KeSetBasePriorityThread(struct _KTHREAD* Thread,
372 LONG Increment);
373
374 LONG
375 STDCALL
376 KeSetEvent (
377 PKEVENT Event,
378 KPRIORITY Increment,
379 BOOLEAN Wait
380 );
381
382 KPRIORITY STDCALL KeSetPriorityThread (struct _KTHREAD* Thread,
383 KPRIORITY Priority);
384
385 BOOLEAN STDCALL KeSetTimer (PKTIMER Timer,
386 LARGE_INTEGER DueTime,
387 PKDPC Dpc);
388
389 BOOLEAN STDCALL KeSetTimerEx (PKTIMER Timer,
390 LARGE_INTEGER DueTime,
391 LONG Period,
392 PKDPC Dpc);
393
394 VOID STDCALL KeStallExecutionProcessor (ULONG MicroSeconds);
395
396 BOOLEAN STDCALL KeSynchronizeExecution (PKINTERRUPT Interrupt,
397 PKSYNCHRONIZE_ROUTINE SynchronizeRoutine,
398 PVOID SynchronizeContext);
399
400 NTSTATUS STDCALL KeWaitForMultipleObjects (ULONG Count,
401 PVOID Object[],
402 WAIT_TYPE WaitType,
403 KWAIT_REASON WaitReason,
404 KPROCESSOR_MODE WaitMode,
405 BOOLEAN Alertable,
406 PLARGE_INTEGER Timeout,
407 PKWAIT_BLOCK WaitBlockArray);
408
409 NTSTATUS
410 STDCALL
411 KeWaitForMutexObject (
412 PKMUTEX Mutex,
413 KWAIT_REASON WaitReason,
414 KPROCESSOR_MODE WaitMode,
415 BOOLEAN Alertable,
416 PLARGE_INTEGER Timeout
417 );
418
419 NTSTATUS
420 STDCALL
421 KeWaitForSingleObject (
422 PVOID Object,
423 KWAIT_REASON WaitReason,
424 KPROCESSOR_MODE WaitMode,
425 BOOLEAN Alertable,
426 PLARGE_INTEGER Timeout
427 );
428
429
430
431 // io permission map has a 8k size
432 // Each bit in the IOPM corresponds to an io port byte address. The bitmap
433 // is initialized to allow IO at any port. [ all bits set ].
434
435 typedef struct _IOPM
436 {
437 UCHAR Bitmap[8192];
438 } IOPM, *PIOPM;
439
440 /*
441 * FUNCTION: Provides the kernel with a new access map for a driver
442 * ARGUMENTS:
443 * NewMap: = If FALSE the kernel's map is set to all disabled. If TRUE
444 * the kernel disables access to a particular port.
445 * IoPortMap = Caller supplies storage for the io permission map.
446 * REMARKS
447 * Each bit in the IOPM corresponds to an io port byte address. The bitmap
448 * is initialized to allow IO at any port. [ all bits set ]. The IOPL determines
449 * the minium privilege level required to perform IO prior to checking the permission map.
450 */
451 VOID Ke386SetIoAccessMap(ULONG NewMap, PIOPM *IoPermissionMap);
452
453 /*
454 * FUNCTION: Queries the io permission map.
455 * ARGUMENTS:
456 * NewMap: = If FALSE the kernel's map is set to all disabled. If TRUE
457 * the kernel disables access to a particular port.
458 * IoPortMap = Caller supplies storage for the io permission map.
459 * REMARKS
460 * Each bit in the IOPM corresponds to an io port byte address. The bitmap
461 * is initialized to allow IO at any port. [ all bits set ]. The IOPL determines
462 * the minium privilege level required to perform IO prior to checking the permission map.
463 */
464 VOID Ke386QueryIoAccessMap(BOOLEAN NewMap, PIOPM *IoPermissionMap);
465
466 /*
467 * FUNCTION: Set the process IOPL
468 * ARGUMENTS:
469 * Eprocess = Pointer to a executive process object
470 * EnableIo = Specify TRUE to enable IO and FALSE to disable
471 */
472 NTSTATUS Ke386IoSetAccessProcess(struct _EPROCESS* Eprocess, BOOLEAN EnableIo);
473
474 /*
475 * FUNCTION: Releases a set of Global Descriptor Table Selectors
476 * ARGUMENTS:
477 * SelArray =
478 * NumOfSelectors =
479 */
480 NTSTATUS KeI386ReleaseGdtSelectors(OUT PULONG SelArray,
481 IN ULONG NumOfSelectors);
482
483 /*
484 * FUNCTION: Allocates a set of Global Descriptor Table Selectors
485 * ARGUMENTS:
486 * SelArray =
487 * NumOfSelectors =
488 */
489 NTSTATUS KeI386AllocateGdtSelectors(OUT PULONG SelArray,
490 IN ULONG NumOfSelectors);
491
492
493 KIRQL
494 FASTCALL
495 KfAcquireSpinLock (
496 IN PKSPIN_LOCK SpinLock
497 );
498
499 VOID
500 FASTCALL
501 KfLowerIrql (
502 IN KIRQL NewIrql
503 );
504
505
506 KIRQL
507 FASTCALL
508 KfRaiseIrql (
509 IN KIRQL NewIrql
510 );
511
512 VOID
513 FASTCALL
514 KfReleaseSpinLock (
515 IN PKSPIN_LOCK SpinLock,
516 IN KIRQL NewIrql
517 );
518
519
520 VOID STDCALL KiDeliverApc(ULONG Unknown1,
521 ULONG Unknown2,
522 ULONG Unknown3);
523
524 VOID STDCALL KiDispatchInterrupt(VOID);
525
526 #endif /* __INCLUDE_DDK_KEFUNCS_H */