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