Implemented missing KeRaiseIrqlToXxLevel() functions
[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 KIRQL
203 STDCALL
204 KeRaiseIrqlToDpcLevel (
205 VOID
206 );
207
208 KIRQL
209 STDCALL
210 KeRaiseIrqlToSynchLevel (
211 VOID
212 );
213
214 /*
215 * FUNCTION: Raises a user mode exception
216 * ARGUMENTS:
217 * ExceptionCode = Status code of the exception
218 */
219 VOID
220 STDCALL
221 KeRaiseUserException (
222 IN NTSTATUS ExceptionCode
223 );
224
225 LONG
226 STDCALL
227 KeReadStateEvent (
228 PKEVENT Event
229 );
230
231 LONG
232 STDCALL
233 KeReadStateMutex (
234 PKMUTEX Mutex
235 );
236
237 LONG
238 STDCALL
239 KeReadStateSemaphore (
240 PKSEMAPHORE Semaphore
241 );
242
243 BOOLEAN
244 STDCALL
245 KeReadStateTimer (
246 PKTIMER Timer
247 );
248
249 BOOLEAN
250 STDCALL
251 KeRegisterBugCheckCallback (
252 PKBUGCHECK_CALLBACK_RECORD CallbackRecord,
253 PKBUGCHECK_CALLBACK_ROUTINE CallbackRoutine,
254 PVOID Buffer,
255 ULONG Length,
256 PUCHAR Component
257 );
258
259 LONG
260 STDCALL
261 KeReleaseMutex (
262 PKMUTEX Mutex,
263 BOOLEAN Wait
264 );
265
266 LONG
267 STDCALL
268 KeReleaseSemaphore (
269 PKSEMAPHORE Semaphore,
270 KPRIORITY Increment,
271 LONG Adjustment,
272 BOOLEAN Wait
273 );
274
275 VOID
276 STDCALL
277 KeReleaseSpinLock (
278 PKSPIN_LOCK Spinlock,
279 KIRQL NewIrql
280 );
281
282 VOID
283 STDCALL
284 KeReleaseSpinLockFromDpcLevel (
285 PKSPIN_LOCK Spinlock
286 );
287
288 PKDEVICE_QUEUE_ENTRY
289 STDCALL
290 KeRemoveByKeyDeviceQueue (
291 PKDEVICE_QUEUE DeviceQueue,
292 ULONG SortKey
293 );
294
295 PKDEVICE_QUEUE_ENTRY
296 STDCALL
297 KeRemoveDeviceQueue (
298 PKDEVICE_QUEUE DeviceQueue
299 );
300
301 BOOLEAN
302 STDCALL
303 KeRemoveEntryDeviceQueue (
304 PKDEVICE_QUEUE DeviceQueue,
305 PKDEVICE_QUEUE_ENTRY DeviceQueueEntry
306 );
307
308 BOOLEAN
309 STDCALL
310 KeRemoveQueueDpc (
311 PKDPC Dpc
312 );
313
314 LONG
315 STDCALL
316 KeResetEvent (
317 PKEVENT Event
318 );
319
320 LONG STDCALL KeSetBasePriorityThread (struct _KTHREAD* Thread,
321 LONG Increment);
322
323 LONG
324 STDCALL
325 KeSetEvent (
326 PKEVENT Event,
327 KPRIORITY Increment,
328 BOOLEAN Wait
329 );
330
331 KPRIORITY STDCALL KeSetPriorityThread (struct _KTHREAD* Thread,
332 KPRIORITY Priority);
333
334 BOOLEAN STDCALL KeSetTimer (PKTIMER Timer,
335 LARGE_INTEGER DueTime,
336 PKDPC Dpc);
337
338 BOOLEAN STDCALL KeSetTimerEx (PKTIMER Timer,
339 LARGE_INTEGER DueTime,
340 LONG Period,
341 PKDPC Dpc);
342
343 VOID STDCALL KeStallExecutionProcessor (ULONG MicroSeconds);
344
345 BOOLEAN STDCALL KeSynchronizeExecution (PKINTERRUPT Interrupt,
346 PKSYNCHRONIZE_ROUTINE SynchronizeRoutine,
347 PVOID SynchronizeContext);
348
349 NTSTATUS STDCALL KeWaitForMultipleObjects (ULONG Count,
350 PVOID Object[],
351 WAIT_TYPE WaitType,
352 KWAIT_REASON WaitReason,
353 KPROCESSOR_MODE WaitMode,
354 BOOLEAN Alertable,
355 PLARGE_INTEGER Timeout,
356 PKWAIT_BLOCK WaitBlockArray);
357
358 NTSTATUS
359 STDCALL
360 KeWaitForMutexObject (
361 PKMUTEX Mutex,
362 KWAIT_REASON WaitReason,
363 KPROCESSOR_MODE WaitMode,
364 BOOLEAN Alertable,
365 PLARGE_INTEGER Timeout
366 );
367
368 NTSTATUS
369 STDCALL
370 KeWaitForSingleObject (
371 PVOID Object,
372 KWAIT_REASON WaitReason,
373 KPROCESSOR_MODE WaitMode,
374 BOOLEAN Alertable,
375 PLARGE_INTEGER Timeout
376 );
377
378
379
380 // io permission map has a 8k size
381 // Each bit in the IOPM corresponds to an io port byte address. The bitmap
382 // is initialized to allow IO at any port. [ all bits set ].
383
384 typedef struct _IOPM
385 {
386 UCHAR Bitmap[8192];
387 } IOPM, *PIOPM;
388
389 /*
390 * FUNCTION: Provides the kernel with a new access map for a driver
391 * ARGUMENTS:
392 * NewMap: = If FALSE the kernel's map is set to all disabled. If TRUE
393 * the kernel disables access to a particular port.
394 * IoPortMap = Caller supplies storage for the io permission map.
395 * REMARKS
396 * Each bit in the IOPM corresponds to an io port byte address. The bitmap
397 * is initialized to allow IO at any port. [ all bits set ]. The IOPL determines
398 * the minium privilege level required to perform IO prior to checking the permission map.
399 */
400 VOID Ke386SetIoAccessMap(ULONG NewMap, PIOPM *IoPermissionMap);
401
402 /*
403 * FUNCTION: Queries the io permission map.
404 * ARGUMENTS:
405 * NewMap: = If FALSE the kernel's map is set to all disabled. If TRUE
406 * the kernel disables access to a particular port.
407 * IoPortMap = Caller supplies storage for the io permission map.
408 * REMARKS
409 * Each bit in the IOPM corresponds to an io port byte address. The bitmap
410 * is initialized to allow IO at any port. [ all bits set ]. The IOPL determines
411 * the minium privilege level required to perform IO prior to checking the permission map.
412 */
413 VOID Ke386QueryIoAccessMap(BOOLEAN NewMap, PIOPM *IoPermissionMap);
414
415 /*
416 * FUNCTION: Set the process IOPL
417 * ARGUMENTS:
418 * Eprocess = Pointer to a executive process object
419 * EnableIo = Specify TRUE to enable IO and FALSE to disable
420 */
421 NTSTATUS Ke386IoSetAccessProcess(struct _EPROCESS* Eprocess, BOOLEAN EnableIo);
422
423 /*
424 * FUNCTION: Releases a set of Global Descriptor Table Selectors
425 * ARGUMENTS:
426 * SelArray =
427 * NumOfSelectors =
428 */
429 NTSTATUS KeI386ReleaseGdtSelectors(OUT PULONG SelArray,
430 IN ULONG NumOfSelectors);
431
432 /*
433 * FUNCTION: Allocates a set of Global Descriptor Table Selectors
434 * ARGUMENTS:
435 * SelArray =
436 * NumOfSelectors =
437 */
438 NTSTATUS KeI386AllocateGdtSelectors(OUT PULONG SelArray,
439 IN ULONG NumOfSelectors);
440
441
442 KIRQL
443 FASTCALL
444 KfAcquireSpinLock (
445 IN PKSPIN_LOCK SpinLock
446 );
447
448 VOID
449 FASTCALL
450 KfLowerIrql (
451 IN KIRQL NewIrql
452 );
453
454
455 KIRQL
456 FASTCALL
457 KfRaiseIrql (
458 IN KIRQL NewIrql
459 );
460
461 VOID
462 FASTCALL
463 KfReleaseSpinLock (
464 IN PKSPIN_LOCK SpinLock,
465 IN KIRQL NewIrql
466 );
467
468
469 VOID STDCALL KiDeliverApc(ULONG Unknown1,
470 ULONG Unknown2,
471 ULONG Unknown3);
472
473 VOID STDCALL KiDispatchInterrupt(VOID);
474
475 #endif /* __INCLUDE_DDK_KEFUNCS_H */