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