RtlGenerate8dot3Name() is now "pass"ed
[reactos.git] / 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 KeInitializeMutant(IN PKMUTANT Mutant,
129                                 IN BOOLEAN InitialOwner);
130
131 VOID STDCALL KeInitializeMutex (PKMUTEX Mutex,
132                                 ULONG   Level);
133
134 VOID STDCALL
135 KeInitializeQueue(IN PKQUEUE Queue,
136                   IN ULONG Count);
137
138 VOID STDCALL KeInitializeSemaphore (PKSEMAPHORE Semaphore,
139                                     LONG                Count,
140                                     LONG                Limit);
141
142 /*
143  * FUNCTION: Initializes a spinlock
144  * ARGUMENTS:
145  *        SpinLock = Spinlock to initialize
146  */
147 VOID STDCALL KeInitializeSpinLock (PKSPIN_LOCK  SpinLock);
148
149 VOID STDCALL KeInitializeTimer (PKTIMER Timer);
150
151 VOID STDCALL KeInitializeTimerEx (PKTIMER               Timer,
152                                   TIMER_TYPE    Type);
153
154 BOOLEAN STDCALL KeInsertByKeyDeviceQueue (PKDEVICE_QUEUE DeviceQueue,
155                                           PKDEVICE_QUEUE_ENTRY  QueueEntry,
156                                           ULONG                 SortKey);
157
158 BOOLEAN STDCALL KeInsertDeviceQueue (PKDEVICE_QUEUE             DeviceQueue,
159                                      PKDEVICE_QUEUE_ENTRY DeviceQueueEntry);
160
161 LONG STDCALL
162 KeInsertHeadQueue(IN PKQUEUE Queue,
163                   IN PLIST_ENTRY Entry);
164
165 LONG STDCALL
166 KeInsertQueue(IN PKQUEUE Queue,
167               IN PLIST_ENTRY Entry);
168
169 VOID STDCALL KeInsertQueueApc (PKAPC    Apc,
170                                PVOID    SystemArgument1,
171                                PVOID    SystemArgument2,
172                                UCHAR    Mode);
173
174 BOOLEAN STDCALL KeInsertQueueDpc (PKDPC Dpc,
175                                   PVOID SystemArgument1,
176                                   PVOID SystemArgument2);
177
178 VOID STDCALL KeLeaveCriticalRegion (VOID);
179
180 VOID STDCALL KeLowerIrql (KIRQL NewIrql);
181
182 NTSTATUS STDCALL KePulseEvent (PKEVENT          Event,
183                                KPRIORITY        Increment,
184                                BOOLEAN          Wait);
185
186 LARGE_INTEGER
187 STDCALL
188 KeQueryPerformanceCounter (
189         PLARGE_INTEGER  PerformanceFrequency
190         );
191
192 VOID
193 STDCALL
194 KeQuerySystemTime (
195         PLARGE_INTEGER  CurrentTime
196         );
197
198 VOID
199 STDCALL
200 KeQueryTickCount (
201         PLARGE_INTEGER  TickCount
202         );
203
204 ULONG
205 STDCALL
206 KeQueryTimeIncrement (
207         VOID
208         );
209
210 VOID
211 STDCALL
212 KeRaiseIrql (
213         KIRQL   NewIrql,
214         PKIRQL  OldIrql
215         );
216
217 KIRQL
218 STDCALL
219 KeRaiseIrqlToDpcLevel (
220         VOID
221         );
222
223 KIRQL
224 STDCALL
225 KeRaiseIrqlToSynchLevel (
226         VOID
227         );
228
229 /*
230  * FUNCTION: Raises a user mode exception
231  * ARGUMENTS:
232  *      ExceptionCode = Status code of the exception
233  */
234 VOID
235 STDCALL
236 KeRaiseUserException (
237         IN      NTSTATUS        ExceptionCode
238         );
239
240 LONG
241 STDCALL
242 KeReadStateEvent (
243         PKEVENT Event
244         );
245
246 LONG STDCALL
247 KeReadStateMutant(IN PKMUTANT Mutant);
248
249 LONG STDCALL
250 KeReadStateMutex(IN PKMUTEX Mutex);
251
252 LONG STDCALL
253 KeReadStateQueue(IN PKQUEUE Queue);
254
255 LONG STDCALL
256 KeReadStateSemaphore(IN PKSEMAPHORE Semaphore);
257
258 BOOLEAN STDCALL
259 KeReadStateTimer(IN PKTIMER Timer);
260
261 BOOLEAN
262 STDCALL
263 KeRegisterBugCheckCallback (
264         PKBUGCHECK_CALLBACK_RECORD      CallbackRecord,
265         PKBUGCHECK_CALLBACK_ROUTINE     CallbackRoutine,
266         PVOID                           Buffer,
267         ULONG                           Length,
268         PUCHAR                          Component
269         );
270
271 LONG
272 STDCALL
273 KeReleaseMutant(
274         IN PKMUTANT Mutant,
275         IN KPRIORITY Increment,
276         IN BOOLEAN Abandon,
277         IN BOOLEAN Wait
278         );
279
280 LONG
281 STDCALL
282 KeReleaseMutex (
283         PKMUTEX Mutex,
284         BOOLEAN Wait
285         );
286
287 LONG
288 STDCALL
289 KeReleaseSemaphore (
290         PKSEMAPHORE     Semaphore,
291         KPRIORITY       Increment,
292         LONG            Adjustment,
293         BOOLEAN         Wait
294         );
295
296 VOID
297 STDCALL
298 KeReleaseSpinLock (
299         PKSPIN_LOCK     Spinlock,
300         KIRQL           NewIrql
301         );
302
303 VOID
304 STDCALL
305 KeReleaseSpinLockFromDpcLevel (
306         PKSPIN_LOCK     Spinlock
307         );
308
309 PKDEVICE_QUEUE_ENTRY
310 STDCALL
311 KeRemoveByKeyDeviceQueue (
312         PKDEVICE_QUEUE  DeviceQueue,
313         ULONG           SortKey
314         );
315
316 PKDEVICE_QUEUE_ENTRY
317 STDCALL
318 KeRemoveDeviceQueue (
319         PKDEVICE_QUEUE  DeviceQueue
320         );
321
322 BOOLEAN STDCALL
323 KeRemoveEntryDeviceQueue(PKDEVICE_QUEUE DeviceQueue,
324                          PKDEVICE_QUEUE_ENTRY DeviceQueueEntry);
325
326 PLIST_ENTRY STDCALL
327 KeRemoveQueue(IN PKQUEUE Queue,
328               IN KPROCESSOR_MODE WaitMode,
329               IN PLARGE_INTEGER Timeout OPTIONAL);
330
331 BOOLEAN STDCALL
332 KeRemoveQueueDpc(IN PKDPC Dpc);
333
334 LONG STDCALL
335 KeResetEvent(IN PKEVENT Event);
336
337 LONG STDCALL
338 KeSetBasePriorityThread(struct _KTHREAD* Thread,
339                         LONG Increment);
340
341 LONG
342 STDCALL
343 KeSetEvent (
344         PKEVENT         Event,
345         KPRIORITY       Increment,
346         BOOLEAN         Wait
347         );
348
349 KPRIORITY STDCALL KeSetPriorityThread (struct _KTHREAD* Thread,
350                                        KPRIORITY        Priority);
351
352 BOOLEAN STDCALL KeSetTimer (PKTIMER             Timer,
353                             LARGE_INTEGER       DueTime,
354                             PKDPC               Dpc);
355
356 BOOLEAN STDCALL KeSetTimerEx (PKTIMER           Timer,
357                               LARGE_INTEGER     DueTime,
358                               LONG              Period,
359                               PKDPC             Dpc);
360
361 VOID STDCALL KeStallExecutionProcessor (ULONG   MicroSeconds);
362
363 BOOLEAN STDCALL KeSynchronizeExecution (PKINTERRUPT             Interrupt,
364                                         PKSYNCHRONIZE_ROUTINE SynchronizeRoutine,
365                                         PVOID SynchronizeContext);
366
367 NTSTATUS STDCALL KeWaitForMultipleObjects (ULONG                Count,
368                                            PVOID                Object[],
369                                            WAIT_TYPE    WaitType,
370                                            KWAIT_REASON WaitReason,
371                                            KPROCESSOR_MODE      WaitMode,
372                                            BOOLEAN              Alertable,
373                                            PLARGE_INTEGER       Timeout,
374                                            PKWAIT_BLOCK WaitBlockArray);
375
376 NTSTATUS
377 STDCALL
378 KeWaitForMutexObject (
379         PKMUTEX         Mutex,
380         KWAIT_REASON    WaitReason,
381         KPROCESSOR_MODE WaitMode,
382         BOOLEAN         Alertable,
383         PLARGE_INTEGER  Timeout
384         );
385
386 NTSTATUS
387 STDCALL
388 KeWaitForSingleObject (
389         PVOID           Object,
390         KWAIT_REASON    WaitReason,
391         KPROCESSOR_MODE WaitMode,
392         BOOLEAN         Alertable,
393         PLARGE_INTEGER  Timeout
394         );
395
396
397
398 // io permission map has a 8k size
399 // Each bit in the IOPM corresponds to an io port byte address. The bitmap
400 // is initialized to allow IO at any port. [ all bits set ]. 
401
402 typedef struct _IOPM
403 {
404         UCHAR Bitmap[8192];
405 } IOPM, *PIOPM;
406
407 /*
408  * FUNCTION: Provides the kernel with a new access map for a driver
409  * ARGUMENTS:
410  *      NewMap: =  If FALSE the kernel's map is set to all disabled. If TRUE
411  *                      the kernel disables access to a particular port.
412  *      IoPortMap = Caller supplies storage for the io permission map.
413  * REMARKS
414  *      Each bit in the IOPM corresponds to an io port byte address. The bitmap
415  *      is initialized to allow IO at any port. [ all bits set ]. The IOPL determines
416  *      the minium privilege level required to perform IO prior to checking the permission map.
417  */
418 VOID Ke386SetIoAccessMap(ULONG NewMap, PIOPM *IoPermissionMap);
419
420 /*
421  * FUNCTION: Queries the io permission  map.
422  * ARGUMENTS:
423  *      NewMap: =  If FALSE the kernel's map is set to all disabled. If TRUE
424  *                      the kernel disables access to a particular port.
425  *      IoPortMap = Caller supplies storage for the io permission map.
426  * REMARKS
427  *      Each bit in the IOPM corresponds to an io port byte address. The bitmap
428  *      is initialized to allow IO at any port. [ all bits set ]. The IOPL determines
429  *      the minium privilege level required to perform IO prior to checking the permission map.
430  */
431 VOID Ke386QueryIoAccessMap(BOOLEAN NewMap, PIOPM *IoPermissionMap);
432
433 /*
434  * FUNCTION: Set the process IOPL
435  * ARGUMENTS:
436  *      Eprocess = Pointer to a executive process object
437  *      EnableIo = Specify TRUE to enable IO and FALSE to disable 
438  */
439 NTSTATUS Ke386IoSetAccessProcess(struct _EPROCESS* Eprocess, BOOLEAN EnableIo);
440
441 /*
442  * FUNCTION: Releases a set of Global Descriptor Table Selectors
443  * ARGUMENTS:
444  *      SelArray = 
445  *      NumOfSelectors = 
446  */
447 NTSTATUS KeI386ReleaseGdtSelectors(OUT PULONG SelArray,
448                                    IN ULONG NumOfSelectors);
449
450 /*
451  * FUNCTION: Allocates a set of Global Descriptor Table Selectors
452  * ARGUMENTS:
453  *      SelArray = 
454  *      NumOfSelectors = 
455  */
456 NTSTATUS KeI386AllocateGdtSelectors(OUT PULONG SelArray,
457                                     IN ULONG NumOfSelectors);
458
459
460 KIRQL
461 FASTCALL
462 KfAcquireSpinLock (
463         IN      PKSPIN_LOCK     SpinLock
464         );
465
466 VOID
467 FASTCALL
468 KfLowerIrql (
469         IN      KIRQL   NewIrql
470         );
471
472
473 KIRQL
474 FASTCALL
475 KfRaiseIrql (
476         IN      KIRQL   NewIrql
477         );
478
479 VOID
480 FASTCALL
481 KfReleaseSpinLock (
482         IN      PKSPIN_LOCK     SpinLock,
483         IN      KIRQL           NewIrql
484         );
485
486
487 VOID STDCALL KiDeliverApc(ULONG Unknown1,
488                           ULONG Unknown2,
489                           ULONG Unknown3);
490
491 VOID STDCALL KiDispatchInterrupt(VOID);
492
493 #endif /* __INCLUDE_DDK_KEFUNCS_H */