This commit was generated by cvs2svn to compensate for changes in r52,
[reactos.git] / reactos / include / ddk / kefuncs.h
1 #ifndef __INCLUDE_DDK_KEFUNCS_H
2 #define __INCLUDE_DDK_KEFUNCS_H
3
4 /* KERNEL FUNCTIONS ********************************************************/
5
6 struct _KAPC;
7
8 void KeInitializeApc(
9 struct _KAPC *Apc,
10 PKTHREAD Thread,
11 UCHAR StateIndex,
12 PKKERNEL_ROUTINE KernelRoutine,
13 PKRUNDOWN_ROUTINE RundownRoutine,
14 PKNORMAL_ROUTINE NormalRoutine,
15 UCHAR Mode,
16 PVOID Context
17 );
18
19 void KeInsertQueueApc(struct _KAPC *Apc, PVOID SystemArgument1,
20 PVOID SystemArgument2, UCHAR Mode);
21 void KeAttachProcess(struct _EPROCESS* Process);
22 void KeDetachProcess(VOID);
23 VOID KeDrainApcQueue(VOID);
24 PKPROCESS KeGetCurrentProcess(VOID);
25
26 /*
27 * FUNCTION: Acquires a spinlock so the caller can synchronize access to
28 * data
29 * ARGUMENTS:
30 * SpinLock = Initialized spinlock
31 * OldIrql (OUT) = Set the previous irql on return
32 */
33 VOID KeAcquireSpinLock(PKSPIN_LOCK SpinLock, PKIRQL OldIrql);
34
35 VOID KeAcquireSpinLockAtDpcLevel(PKSPIN_LOCK SpinLock);
36 BOOLEAN KeCancelTimer(PKTIMER Timer);
37 VOID KeClearEvent(PKEVENT Event);
38 NTSTATUS KeDelayExecutionThread(KPROCESSOR_MODE WaitMode,
39 BOOLEAN Alertable,
40 PLARGE_INTEGER Internal);
41 BOOLEAN KeDeregisterBugCheckCallback(PKBUGCHECK_CALLBACK_RECORD
42 CallbackRecord);
43 VOID KeEnterCriticalRegion(VOID);
44 VOID KeFlushIoBuffers(PMDL Mdl, BOOLEAN ReadOperation, BOOLEAN DmaOperation);
45 KIRQL KeGetCurrentIrql(VOID);
46 ULONG KeGetCurrentProcessorNumber(VOID);
47 ULONG KeGetDcacheFillSize(VOID);
48 PKTHREAD KeGetCurrentThread(VOID);
49 VOID KeInitializeCallbackRecord(PKBUGCHECK_CALLBACK_RECORD CallbackRecord);
50 VOID KeInitializeDeviceQueue(PKDEVICE_QUEUE DeviceQueue);
51 VOID KeInitializeDpc(PKDPC Dpc, PKDEFERRED_ROUTINE DeferredRoutine,
52 PVOID DeferredContext);
53 VOID KeInitializeEvent(PKEVENT Event, EVENT_TYPE Type, BOOLEAN State);
54 VOID KeInitializeMutex(PKMUTEX Mutex, ULONG Level);
55 VOID KeInitializeSemaphore(PKSEMAPHORE Semaphore, LONG Count, LONG Limit);
56 VOID KeInitializeTimer(PKTIMER Timer);
57 VOID KeInitializeTimerEx(PKTIMER Timer, TIMER_TYPE Type);
58 BOOLEAN KeInsertByKeyDeviceQueue(PKDEVICE_QUEUE DeviceQueue,
59 PKDEVICE_QUEUE_ENTRY DeviceQueueEntry,
60 ULONG SortKey);
61 BOOLEAN KeInsertDeviceQueue(PKDEVICE_QUEUE DeviceQueue,
62 PKDEVICE_QUEUE_ENTRY DeviceQueueEntry);
63 BOOLEAN KeInsertQueueDpc(PKDPC Dpc, PVOID SystemArgument1,
64 PVOID SystemArgument2);
65 VOID KeLeaveCriticalRegion(VOID);
66 VOID KeLowerIrql(KIRQL NewIrql);
67 LARGE_INTEGER KeQueryPerformanceCounter(PLARGE_INTEGER PerformanceFrequency);
68 VOID KeQuerySystemTime(PLARGE_INTEGER CurrentTime);
69 VOID KeQueryTickCount(PLARGE_INTEGER TickCount);
70 ULONG KeQueryTimeIncrement(VOID);
71 VOID KeRaiseIrql(KIRQL NewIrql, PKIRQL OldIrql);
72 LONG KeReadStateEvent(PKEVENT Event);
73 LONG KeReadStateMutex(PKMUTEX Mutex);
74 LONG KeReadStateSemaphore(PKSEMAPHORE Semaphore);
75 BOOLEAN KeReadStateTimer(PKTIMER Timer);
76 BOOLEAN KeRegisterBugCheckCallback(PKBUGCHECK_CALLBACK_RECORD CallbackRecord,
77 PKBUGCHECK_CALLBACK_ROUTINE CallbackRoutine,
78 PVOID Buffer,
79 ULONG Length,
80 PUCHAR Component);
81 LONG KeReleaseMutex(PKMUTEX Mutex, BOOLEAN Wait);
82 LONG KeReleaseSemaphore(PKSEMAPHORE Semaphore, KPRIORITY Increment,
83 LONG Adjustment, BOOLEAN Wait);
84 VOID KeReleaseSpinLock(PKSPIN_LOCK Spinlock, KIRQL NewIrql);
85 VOID KeReleaseSpinLockFromDpcLevel(PKSPIN_LOCK Spinlock);
86 PKDEVICE_QUEUE_ENTRY KeRemoveByKeyDeviceQueue(PKDEVICE_QUEUE DeviceQueue,
87 ULONG SortKey);
88 PKDEVICE_QUEUE_ENTRY KeRemoveDeviceQueue(PKDEVICE_QUEUE DeviceQueue);
89 BOOLEAN KeRemoveEntryDeviceQueue(PKDEVICE_QUEUE DeviceQueue,
90 PKDEVICE_QUEUE_ENTRY DeviceQueueEntry);
91 BOOLEAN KeRemoveQueueDpc(PKDPC Dpc);
92 LONG KeResetEvent(PKEVENT Event);
93 LONG KeSetBasePriorityThread(PKTHREAD Thread, LONG Increment);
94 LONG KeSetEvent(PKEVENT Event, KPRIORITY Increment, BOOLEAN Wait);
95 KPRIORITY KeSetPriorityThread(PKTHREAD Thread, KPRIORITY Priority);
96 BOOLEAN KeSetTimer(PKTIMER Timer, LARGE_INTEGER DueTime, PKDPC Dpc);
97 BOOLEAN KeSetTimerEx(PKTIMER Timer, LARGE_INTEGER DueTime, LONG Period,
98 PKDPC Dpc);
99 VOID KeStallExecutionProcessor(ULONG MicroSeconds);
100 BOOLEAN KeSynchronizeExecution(PKINTERRUPT Interrupt,
101 PKSYNCHRONIZE_ROUTINE SynchronizeRoutine,
102 PVOID SynchronizeContext);
103 NTSTATUS KeWaitForMultipleObjects(ULONG Count,
104 PVOID Object[],
105 WAIT_TYPE WaitType,
106 KWAIT_REASON WaitReason,
107 KPROCESSOR_MODE WaitMode,
108 BOOLEAN Alertable,
109 PLARGE_INTEGER Timeout,
110 PKWAIT_BLOCK WaitBlockArray);
111 NTSTATUS KeWaitForMutexObject(PKMUTEX Mutex, KWAIT_REASON WaitReason,
112 KPROCESSOR_MODE WaitMode, BOOLEAN Alertable,
113 PLARGE_INTEGER Timeout);
114 NTSTATUS KeWaitForSingleObject(PVOID Object, KWAIT_REASON WaitReason,
115 KPROCESSOR_MODE WaitMode,
116 BOOLEAN Alertable, PLARGE_INTEGER Timeout);
117
118 /*
119 * FUNCTION: Initializes a spinlock
120 * ARGUMENTS:
121 * SpinLock = Spinlock to initialize
122 */
123 VOID KeInitializeSpinLock(PKSPIN_LOCK SpinLock);
124
125 /*
126 * FUNCTION: Sets the current irql without altering the current processor
127 * state
128 * ARGUMENTS:
129 * newlvl = IRQ level to set
130 * NOTE: This is for internal use only
131 */
132 VOID KeSetCurrentIrql(KIRQL newlvl);
133
134
135 /*
136 * FUNCTION: Brings the system down in a controlled manner when an
137 * inconsistency that might otherwise cause corruption has been detected
138 * ARGUMENTS:
139 * BugCheckCode = Specifies the reason for the bug check
140 * BugCheckParameter[1-4] = Additional information about bug
141 * RETURNS: Doesn't
142 */
143 VOID KeBugCheckEx(ULONG BugCheckCode,
144 ULONG BugCheckParameter1,
145 ULONG BugCheckParameter2,
146 ULONG BugCheckParameter3,
147 ULONG BugCheckParameter4);
148
149 /*
150 * FUNCTION: Brings the system down in a controlled manner when an
151 * inconsistency that might otherwise cause corruption has been detected
152 * ARGUMENTS:
153 * BugCheckCode = Specifies the reason for the bug check
154 * RETURNS: Doesn't
155 */
156 VOID KeBugCheck(ULONG BugCheckCode);
157
158 // kmutant definition slightly modified from nt5 ddk
159
160 typedef struct _KMUTANT
161 {
162 DISPATCHER_HEADER Header;
163 LIST_ENTRY MutantListEntry;
164 struct _KTHREAD* OwnerThread;
165 BOOLEAN Abandoned;
166 UCHAR ApcDisable;
167 } KMUTANT, *PKMUTANT;
168
169 // io permission map has a 8k size
170 // Each bit in the IOPM corresponds to an io port byte address. The bitmap
171 // is initialized to allow IO at any port. [ all bits set ].
172
173 typedef struct _IOPM
174 {
175 UCHAR Bitmap[8192];
176 } IOPM, *PIOPM;
177
178 /*
179 * FUNCTION: Provides the kernel with a new access map for a driver
180 * ARGUMENTS:
181 * NewMap: = If FALSE the kernel's map is set to all disabled. If TRUE
182 * the kernel disables access to a particular port.
183 * IoPortMap = Caller supplies storage for the io permission map.
184 * REMARKS
185 * Each bit in the IOPM corresponds to an io port byte address. The bitmap
186 * is initialized to allow IO at any port. [ all bits set ]. The IOPL determines
187 * the minium privilege level required to perform IO prior to checking the permission map.
188 */
189 void Ke386SetIoAccessMap(int NewMap, PIOPM *IoPermissionMap);
190
191 /*
192 * FUNCTION: Queries the io permission map.
193 * ARGUMENTS:
194 * NewMap: = If FALSE the kernel's map is set to all disabled. If TRUE
195 * the kernel disables access to a particular port.
196 * IoPortMap = Caller supplies storage for the io permission map.
197 * REMARKS
198 * Each bit in the IOPM corresponds to an io port byte address. The bitmap
199 * is initialized to allow IO at any port. [ all bits set ]. The IOPL determines
200 * the minium privilege level required to perform IO prior to checking the permission map.
201 */
202 void Ke386QueryIoAccessMap(BOOLEAN NewMap, PIOPM *IoPermissionMap);
203
204 /*
205 * FUNCTION: Set the process IOPL
206 * ARGUMENTS:
207 * Eprocess = Pointer to a executive process object
208 * EnableIo = Specify TRUE to enable IO and FALSE to disable
209 */
210 NTSTATUS Ke386IoSetAccessProcess(PEPROCESS Eprocess, BOOLEAN EnableIo);
211
212 /*
213 * FUNCTION: Releases a set of Global Descriptor Table Selectors
214 * ARGUMENTS:
215 * SelArray =
216 * NumOfSelectors =
217 */
218 NTSTATUS KeI386ReleaseGdtSelectors(
219 OUT PULONG SelArray,
220 IN ULONG NumOfSelectors
221 );
222
223 /*
224 * FUNCTION: Allocates a set of Global Descriptor Table Selectors
225 * ARGUMENTS:
226 * SelArray =
227 * NumOfSelectors =
228 */
229 NTSTATUS KeI386AllocateGdtSelectors(
230 OUT PULONG SelArray,
231 IN ULONG NumOfSelectors
232 );
233
234 /*
235 * FUNCTION: Raises a user mode exception
236 * ARGUMENTS:
237 * ExceptionCode = Status code of the exception
238 */
239 void KeRaiseUserException(NTSTATUS ExceptionCode);
240
241
242 #endif /* __INCLUDE_DDK_KEFUNCS_H */