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