xref: /reactos/ntoskrnl/include/internal/ke.h (revision 3c1e022d)
1c2c66affSColin Finck #pragma once
2c2c66affSColin Finck 
3c2c66affSColin Finck /* INCLUDES *****************************************************************/
4c2c66affSColin Finck 
5c2c66affSColin Finck #include "arch/ke.h"
6c2c66affSColin Finck 
731afbf10SJérôme Gardou #ifdef __cplusplus
831afbf10SJérôme Gardou extern "C"
931afbf10SJérôme Gardou {
1031afbf10SJérôme Gardou #endif
1131afbf10SJérôme Gardou 
12c2c66affSColin Finck /* INTERNAL KERNEL TYPES ****************************************************/
13c2c66affSColin Finck 
14c2c66affSColin Finck typedef struct _WOW64_PROCESS
15c2c66affSColin Finck {
16c2c66affSColin Finck   PVOID Wow64;
17c2c66affSColin Finck } WOW64_PROCESS, *PWOW64_PROCESS;
18c2c66affSColin Finck 
19c2c66affSColin Finck typedef struct _KPROFILE_SOURCE_OBJECT
20c2c66affSColin Finck {
21c2c66affSColin Finck     KPROFILE_SOURCE Source;
22c2c66affSColin Finck     LIST_ENTRY ListEntry;
23c2c66affSColin Finck } KPROFILE_SOURCE_OBJECT, *PKPROFILE_SOURCE_OBJECT;
24c2c66affSColin Finck 
25c2c66affSColin Finck typedef enum _CONNECT_TYPE
26c2c66affSColin Finck {
27c2c66affSColin Finck     NoConnect,
28c2c66affSColin Finck     NormalConnect,
29c2c66affSColin Finck     ChainConnect,
30c2c66affSColin Finck     UnknownConnect
31c2c66affSColin Finck } CONNECT_TYPE, *PCONNECT_TYPE;
32c2c66affSColin Finck 
33c2c66affSColin Finck typedef struct _DISPATCH_INFO
34c2c66affSColin Finck {
35c2c66affSColin Finck     CONNECT_TYPE Type;
36c2c66affSColin Finck     PKINTERRUPT Interrupt;
37c2c66affSColin Finck     PKINTERRUPT_ROUTINE NoDispatch;
38c2c66affSColin Finck     PKINTERRUPT_ROUTINE InterruptDispatch;
39c2c66affSColin Finck     PKINTERRUPT_ROUTINE FloatingDispatch;
40c2c66affSColin Finck     PKINTERRUPT_ROUTINE ChainedDispatch;
41c2c66affSColin Finck     PKINTERRUPT_ROUTINE *FlatDispatch;
42c2c66affSColin Finck } DISPATCH_INFO, *PDISPATCH_INFO;
43c2c66affSColin Finck 
44f15afdbcSPierre Schweitzer typedef struct _PROCESS_VALUES
45f15afdbcSPierre Schweitzer {
46f15afdbcSPierre Schweitzer     LARGE_INTEGER TotalKernelTime;
47f15afdbcSPierre Schweitzer     LARGE_INTEGER TotalUserTime;
48f15afdbcSPierre Schweitzer     IO_COUNTERS IoInfo;
49f15afdbcSPierre Schweitzer } PROCESS_VALUES, *PPROCESS_VALUES;
50f15afdbcSPierre Schweitzer 
51c2c66affSColin Finck typedef struct _DEFERRED_REVERSE_BARRIER
52c2c66affSColin Finck {
53c2c66affSColin Finck     ULONG Barrier;
54c2c66affSColin Finck     ULONG TotalProcessors;
55c2c66affSColin Finck } DEFERRED_REVERSE_BARRIER, *PDEFERRED_REVERSE_BARRIER;
56c2c66affSColin Finck 
57c2c66affSColin Finck typedef struct _KI_SAMPLE_MAP
58c2c66affSColin Finck {
59c2c66affSColin Finck     LARGE_INTEGER PerfStart;
60c2c66affSColin Finck     LARGE_INTEGER PerfEnd;
61c2c66affSColin Finck     LONGLONG PerfDelta;
62c2c66affSColin Finck     LARGE_INTEGER PerfFreq;
63c2c66affSColin Finck     LONGLONG TSCStart;
64c2c66affSColin Finck     LONGLONG TSCEnd;
65c2c66affSColin Finck     LONGLONG TSCDelta;
66c2c66affSColin Finck     ULONG MHz;
67c2c66affSColin Finck } KI_SAMPLE_MAP, *PKI_SAMPLE_MAP;
68c2c66affSColin Finck 
69c2c66affSColin Finck #define MAX_TIMER_DPCS                      16
70c2c66affSColin Finck 
71c2c66affSColin Finck typedef struct _DPC_QUEUE_ENTRY
72c2c66affSColin Finck {
73c2c66affSColin Finck     PKDPC Dpc;
74c2c66affSColin Finck     PKDEFERRED_ROUTINE Routine;
75c2c66affSColin Finck     PVOID Context;
76c2c66affSColin Finck } DPC_QUEUE_ENTRY, *PDPC_QUEUE_ENTRY;
77c2c66affSColin Finck 
78c2c66affSColin Finck typedef struct _KNMI_HANDLER_CALLBACK
79c2c66affSColin Finck {
80c2c66affSColin Finck     struct _KNMI_HANDLER_CALLBACK* Next;
81c2c66affSColin Finck     PNMI_CALLBACK Callback;
82c2c66affSColin Finck     PVOID Context;
83c2c66affSColin Finck     PVOID Handle;
84c2c66affSColin Finck } KNMI_HANDLER_CALLBACK, *PKNMI_HANDLER_CALLBACK;
85c2c66affSColin Finck 
86c2c66affSColin Finck typedef PCHAR
87c2c66affSColin Finck (NTAPI *PKE_BUGCHECK_UNICODE_TO_ANSI)(
88c2c66affSColin Finck     IN PUNICODE_STRING Unicode,
89c2c66affSColin Finck     IN PCHAR Ansi,
90c2c66affSColin Finck     IN ULONG Length
91c2c66affSColin Finck );
92c2c66affSColin Finck 
93c2c66affSColin Finck extern KAFFINITY KeActiveProcessors;
94c2c66affSColin Finck extern PKNMI_HANDLER_CALLBACK KiNmiCallbackListHead;
95c2c66affSColin Finck extern KSPIN_LOCK KiNmiCallbackListLock;
96c2c66affSColin Finck extern PVOID KeUserApcDispatcher;
97c2c66affSColin Finck extern PVOID KeUserCallbackDispatcher;
98c2c66affSColin Finck extern PVOID KeUserExceptionDispatcher;
99c2c66affSColin Finck extern PVOID KeRaiseUserExceptionDispatcher;
100c2c66affSColin Finck extern LARGE_INTEGER KeBootTime;
101c2c66affSColin Finck extern ULONGLONG KeBootTimeBias;
102c2c66affSColin Finck extern BOOLEAN ExCmosClockIsSane;
103c2c66affSColin Finck extern USHORT KeProcessorArchitecture;
104c2c66affSColin Finck extern USHORT KeProcessorLevel;
105c2c66affSColin Finck extern USHORT KeProcessorRevision;
106c2c66affSColin Finck extern ULONG KeFeatureBits;
107c2c66affSColin Finck extern KNODE KiNode0;
108c2c66affSColin Finck extern PKNODE KeNodeBlock[1];
109c2c66affSColin Finck extern UCHAR KeNumberNodes;
110c2c66affSColin Finck extern UCHAR KeProcessNodeSeed;
111c2c66affSColin Finck extern ETHREAD KiInitialThread;
112c2c66affSColin Finck extern EPROCESS KiInitialProcess;
113c2c66affSColin Finck extern PULONG KiInterruptTemplateObject;
114c2c66affSColin Finck extern PULONG KiInterruptTemplateDispatch;
115c2c66affSColin Finck extern PULONG KiInterruptTemplate2ndDispatch;
116c2c66affSColin Finck extern ULONG KiUnexpectedEntrySize;
117c2c66affSColin Finck extern ULONG_PTR KiDoubleFaultStack;
118c2c66affSColin Finck extern EX_PUSH_LOCK KernelAddressSpaceLock;
119c2c66affSColin Finck extern ULONG KiMaximumDpcQueueDepth;
120c2c66affSColin Finck extern ULONG KiMinimumDpcRate;
121c2c66affSColin Finck extern ULONG KiAdjustDpcThreshold;
122c2c66affSColin Finck extern ULONG KiIdealDpcRate;
123c2c66affSColin Finck extern BOOLEAN KeThreadDpcEnable;
124c2c66affSColin Finck extern LARGE_INTEGER KiTimeIncrementReciprocal;
125c2c66affSColin Finck extern UCHAR KiTimeIncrementShiftCount;
126c2c66affSColin Finck extern ULONG KiTimeLimitIsrMicroseconds;
127c2c66affSColin Finck extern ULONG KiServiceLimit;
128c2c66affSColin Finck extern LIST_ENTRY KeBugcheckCallbackListHead, KeBugcheckReasonCallbackListHead;
129c2c66affSColin Finck extern KSPIN_LOCK BugCheckCallbackLock;
130c2c66affSColin Finck extern KDPC KiTimerExpireDpc;
131c2c66affSColin Finck extern KTIMER_TABLE_ENTRY KiTimerTableListHead[TIMER_TABLE_SIZE];
132c2c66affSColin Finck extern FAST_MUTEX KiGenericCallDpcMutex;
133c2c66affSColin Finck extern LIST_ENTRY KiProfileListHead, KiProfileSourceListHead;
134c2c66affSColin Finck extern KSPIN_LOCK KiProfileLock;
135c2c66affSColin Finck extern LIST_ENTRY KiProcessListHead;
136c2c66affSColin Finck extern LIST_ENTRY KiProcessInSwapListHead, KiProcessOutSwapListHead;
137c2c66affSColin Finck extern LIST_ENTRY KiStackInSwapListHead;
138c2c66affSColin Finck extern KEVENT KiSwapEvent;
139c2c66affSColin Finck extern PKPRCB KiProcessorBlock[];
1401ee23d33STimo Kreuzer extern KAFFINITY KiIdleSummary;
141c2c66affSColin Finck extern PVOID KeUserApcDispatcher;
142c2c66affSColin Finck extern PVOID KeUserCallbackDispatcher;
143c2c66affSColin Finck extern PVOID KeUserExceptionDispatcher;
144c2c66affSColin Finck extern PVOID KeRaiseUserExceptionDispatcher;
145c2c66affSColin Finck extern ULONG KeTimeIncrement;
146c2c66affSColin Finck extern ULONG KeTimeAdjustment;
147c2c66affSColin Finck extern BOOLEAN KiTimeAdjustmentEnabled;
148c2c66affSColin Finck extern LONG KiTickOffset;
149c2c66affSColin Finck extern ULONG KiFreezeFlag;
150c2c66affSColin Finck extern ULONG KiDPCTimeout;
151c2c66affSColin Finck extern PGDI_BATCHFLUSH_ROUTINE KeGdiFlushUserBatch;
152c2c66affSColin Finck extern ULONGLONG BootCycles, BootCyclesEnd;
153c2c66affSColin Finck extern ULONG ProcessCount;
154c2c66affSColin Finck extern VOID __cdecl KiInterruptTemplate(VOID);
155c2c66affSColin Finck 
156c2c66affSColin Finck /* MACROS *************************************************************************/
157c2c66affSColin Finck 
158f92c44b2STimo Kreuzer #define PRIORITY_MASK(Priority) (1UL << (Priority))
159c2c66affSColin Finck 
160c2c66affSColin Finck /* Tells us if the Timer or Event is a Syncronization or Notification Object */
161c2c66affSColin Finck #define TIMER_OR_EVENT_TYPE 0x7L
162c2c66affSColin Finck 
163c2c66affSColin Finck /* One of the Reserved Wait Blocks, this one is for the Thread's Timer */
164c2c66affSColin Finck #define TIMER_WAIT_BLOCK 0x3L
165c2c66affSColin Finck 
166c2c66affSColin Finck /* INTERNAL KERNEL FUNCTIONS ************************************************/
167c2c66affSColin Finck 
168c2c66affSColin Finck /* Finds a new thread to run */
169c2c66affSColin Finck LONG_PTR
170c2c66affSColin Finck FASTCALL
171c2c66affSColin Finck KiSwapThread(
172c2c66affSColin Finck     IN PKTHREAD Thread,
173c2c66affSColin Finck     IN PKPRCB Prcb
174c2c66affSColin Finck );
175c2c66affSColin Finck 
176c2c66affSColin Finck VOID
177c2c66affSColin Finck NTAPI
178c2c66affSColin Finck KeReadyThread(
179c2c66affSColin Finck     IN PKTHREAD Thread
180c2c66affSColin Finck );
181c2c66affSColin Finck 
182c2c66affSColin Finck BOOLEAN
183c2c66affSColin Finck NTAPI
184c2c66affSColin Finck KeSetDisableBoostThread(
185c2c66affSColin Finck     IN OUT PKTHREAD Thread,
186c2c66affSColin Finck     IN BOOLEAN Disable
187c2c66affSColin Finck );
188c2c66affSColin Finck 
189c2c66affSColin Finck BOOLEAN
190c2c66affSColin Finck NTAPI
191c2c66affSColin Finck KeSetDisableBoostProcess(
192c2c66affSColin Finck     IN PKPROCESS Process,
193c2c66affSColin Finck     IN BOOLEAN Disable
194c2c66affSColin Finck );
195c2c66affSColin Finck 
196c2c66affSColin Finck BOOLEAN
197c2c66affSColin Finck NTAPI
198c2c66affSColin Finck KeSetAutoAlignmentProcess(
199c2c66affSColin Finck     IN PKPROCESS Process,
200c2c66affSColin Finck     IN BOOLEAN Enable
201c2c66affSColin Finck );
202c2c66affSColin Finck 
203c2c66affSColin Finck KAFFINITY
204c2c66affSColin Finck NTAPI
205c2c66affSColin Finck KeSetAffinityProcess(
206c2c66affSColin Finck     IN PKPROCESS Process,
207c2c66affSColin Finck     IN KAFFINITY Affinity
208c2c66affSColin Finck );
209c2c66affSColin Finck 
210c2c66affSColin Finck VOID
211c2c66affSColin Finck NTAPI
212c2c66affSColin Finck KeBoostPriorityThread(
213c2c66affSColin Finck     IN PKTHREAD Thread,
214c2c66affSColin Finck     IN KPRIORITY Increment
215c2c66affSColin Finck );
216c2c66affSColin Finck 
217c2c66affSColin Finck VOID
218c2c66affSColin Finck NTAPI
219c2c66affSColin Finck KeBalanceSetManager(IN PVOID Context);
220c2c66affSColin Finck 
221c2c66affSColin Finck VOID
222c2c66affSColin Finck NTAPI
223c2c66affSColin Finck KiReadyThread(IN PKTHREAD Thread);
224c2c66affSColin Finck 
225c2c66affSColin Finck ULONG
226c2c66affSColin Finck NTAPI
227c2c66affSColin Finck KeSuspendThread(PKTHREAD Thread);
228c2c66affSColin Finck 
229c2c66affSColin Finck BOOLEAN
230c2c66affSColin Finck NTAPI
231c2c66affSColin Finck KeReadStateThread(IN PKTHREAD Thread);
232c2c66affSColin Finck 
233c2c66affSColin Finck BOOLEAN
234c2c66affSColin Finck FASTCALL
235c2c66affSColin Finck KiSwapContext(
236c2c66affSColin Finck     IN KIRQL WaitIrql,
237c2c66affSColin Finck     IN PKTHREAD CurrentThread
238c2c66affSColin Finck );
239c2c66affSColin Finck 
240c2c66affSColin Finck VOID
241c2c66affSColin Finck NTAPI
242c2c66affSColin Finck KiAdjustQuantumThread(IN PKTHREAD Thread);
243c2c66affSColin Finck 
244c2c66affSColin Finck VOID
245c2c66affSColin Finck FASTCALL
246c2c66affSColin Finck KiExitDispatcher(KIRQL OldIrql);
247c2c66affSColin Finck 
248c2c66affSColin Finck VOID
249c2c66affSColin Finck FASTCALL
250c2c66affSColin Finck KiDeferredReadyThread(IN PKTHREAD Thread);
251c2c66affSColin Finck 
252c2c66affSColin Finck PKTHREAD
253c2c66affSColin Finck FASTCALL
254c2c66affSColin Finck KiIdleSchedule(
255c2c66affSColin Finck     IN PKPRCB Prcb
256c2c66affSColin Finck );
257c2c66affSColin Finck 
258c2c66affSColin Finck VOID
259c2c66affSColin Finck FASTCALL
260c2c66affSColin Finck KiProcessDeferredReadyList(
261c2c66affSColin Finck     IN PKPRCB Prcb
262c2c66affSColin Finck );
263c2c66affSColin Finck 
264c2c66affSColin Finck KAFFINITY
265c2c66affSColin Finck FASTCALL
266c2c66affSColin Finck KiSetAffinityThread(
267c2c66affSColin Finck     IN PKTHREAD Thread,
268c2c66affSColin Finck     IN KAFFINITY Affinity
269c2c66affSColin Finck );
270c2c66affSColin Finck 
271c2c66affSColin Finck PKTHREAD
272c2c66affSColin Finck FASTCALL
273c2c66affSColin Finck KiSelectNextThread(
274c2c66affSColin Finck     IN PKPRCB Prcb
275c2c66affSColin Finck );
276c2c66affSColin Finck 
277c2c66affSColin Finck BOOLEAN
278c2c66affSColin Finck FASTCALL
279c2c66affSColin Finck KiInsertTimerTable(
280c2c66affSColin Finck     IN PKTIMER Timer,
281c2c66affSColin Finck     IN ULONG Hand
282c2c66affSColin Finck );
283c2c66affSColin Finck 
284c2c66affSColin Finck VOID
285c2c66affSColin Finck FASTCALL
286c2c66affSColin Finck KiTimerListExpire(
287c2c66affSColin Finck     IN PLIST_ENTRY ExpiredListHead,
288c2c66affSColin Finck     IN KIRQL OldIrql
289c2c66affSColin Finck );
290c2c66affSColin Finck 
291c2c66affSColin Finck BOOLEAN
292c2c66affSColin Finck FASTCALL
293c2c66affSColin Finck KiInsertTreeTimer(
294c2c66affSColin Finck     IN PKTIMER Timer,
295c2c66affSColin Finck     IN LARGE_INTEGER Interval
296c2c66affSColin Finck );
297c2c66affSColin Finck 
298c2c66affSColin Finck VOID
299c2c66affSColin Finck FASTCALL
300c2c66affSColin Finck KiCompleteTimer(
301c2c66affSColin Finck     IN PKTIMER Timer,
302c2c66affSColin Finck     IN PKSPIN_LOCK_QUEUE LockQueue
303c2c66affSColin Finck );
304c2c66affSColin Finck 
305516ccad3SJustin Miller CODE_SEG("INIT")
306516ccad3SJustin Miller VOID
307516ccad3SJustin Miller NTAPI
308516ccad3SJustin Miller KeStartAllProcessors(
309516ccad3SJustin Miller     VOID
310516ccad3SJustin Miller );
311516ccad3SJustin Miller 
312c2c66affSColin Finck /* gmutex.c ********************************************************************/
313c2c66affSColin Finck 
314c2c66affSColin Finck VOID
315c2c66affSColin Finck FASTCALL
316c2c66affSColin Finck KiAcquireGuardedMutex(
317c2c66affSColin Finck     IN OUT PKGUARDED_MUTEX GuardedMutex
318c2c66affSColin Finck );
319c2c66affSColin Finck 
320c2c66affSColin Finck VOID
321c2c66affSColin Finck FASTCALL
322c2c66affSColin Finck KiAcquireFastMutex(
323c2c66affSColin Finck     IN PFAST_MUTEX FastMutex
324c2c66affSColin Finck );
325c2c66affSColin Finck 
326c2c66affSColin Finck /* gate.c **********************************************************************/
327c2c66affSColin Finck 
328c2c66affSColin Finck VOID
329c2c66affSColin Finck FASTCALL
330c2c66affSColin Finck KeInitializeGate(PKGATE Gate);
331c2c66affSColin Finck 
332c2c66affSColin Finck VOID
333c2c66affSColin Finck FASTCALL
334c2c66affSColin Finck KeSignalGateBoostPriority(PKGATE Gate);
335c2c66affSColin Finck 
336c2c66affSColin Finck VOID
337c2c66affSColin Finck FASTCALL
338c2c66affSColin Finck KeWaitForGate(
339c2c66affSColin Finck     PKGATE Gate,
340c2c66affSColin Finck     KWAIT_REASON WaitReason,
341c2c66affSColin Finck     KPROCESSOR_MODE WaitMode
342c2c66affSColin Finck );
343c2c66affSColin Finck 
344c2c66affSColin Finck /* ipi.c ********************************************************************/
345c2c66affSColin Finck 
346c2c66affSColin Finck VOID
347c2c66affSColin Finck FASTCALL
348c2c66affSColin Finck KiIpiSend(
349c2c66affSColin Finck     KAFFINITY TargetSet,
350c2c66affSColin Finck     ULONG IpiRequest
351c2c66affSColin Finck );
352c2c66affSColin Finck 
353c2c66affSColin Finck VOID
354c2c66affSColin Finck NTAPI
355c2c66affSColin Finck KiIpiSendPacket(
356c2c66affSColin Finck     IN KAFFINITY TargetProcessors,
357c2c66affSColin Finck     IN PKIPI_WORKER WorkerFunction,
358c2c66affSColin Finck     IN PKIPI_BROADCAST_WORKER BroadcastFunction,
359c2c66affSColin Finck     IN ULONG_PTR Context,
360c2c66affSColin Finck     IN PULONG Count
361c2c66affSColin Finck );
362c2c66affSColin Finck 
363c2c66affSColin Finck VOID
364c2c66affSColin Finck FASTCALL
365c2c66affSColin Finck KiIpiSignalPacketDone(
366c2c66affSColin Finck     IN PKIPI_CONTEXT PacketContext
367c2c66affSColin Finck );
368c2c66affSColin Finck 
369c2c66affSColin Finck VOID
370c2c66affSColin Finck FASTCALL
371c2c66affSColin Finck KiIpiSignalPacketDoneAndStall(
372c2c66affSColin Finck     IN PKIPI_CONTEXT PacketContext,
373c2c66affSColin Finck     IN volatile PULONG ReverseStall
374c2c66affSColin Finck );
375c2c66affSColin Finck 
376c2c66affSColin Finck /* next file ***************************************************************/
377c2c66affSColin Finck 
378c2c66affSColin Finck UCHAR
379c2c66affSColin Finck NTAPI
380c2c66affSColin Finck KeFindNextRightSetAffinity(
381c2c66affSColin Finck     IN UCHAR Number,
3821ee23d33STimo Kreuzer     IN KAFFINITY Set
383c2c66affSColin Finck );
384c2c66affSColin Finck 
385c2c66affSColin Finck VOID
386c2c66affSColin Finck NTAPI
387c2c66affSColin Finck DbgBreakPointNoBugCheck(VOID);
388c2c66affSColin Finck 
389c2c66affSColin Finck VOID
390c2c66affSColin Finck NTAPI
391c2c66affSColin Finck KeInitializeProfile(
392c2c66affSColin Finck     struct _KPROFILE* Profile,
393c2c66affSColin Finck     struct _KPROCESS* Process,
394c2c66affSColin Finck     PVOID ImageBase,
395c2c66affSColin Finck     SIZE_T ImageSize,
396c2c66affSColin Finck     ULONG BucketSize,
397c2c66affSColin Finck     KPROFILE_SOURCE ProfileSource,
398c2c66affSColin Finck     KAFFINITY Affinity
399c2c66affSColin Finck );
400c2c66affSColin Finck 
401c2c66affSColin Finck BOOLEAN
402c2c66affSColin Finck NTAPI
403c2c66affSColin Finck KeStartProfile(
404c2c66affSColin Finck     struct _KPROFILE* Profile,
405c2c66affSColin Finck     PVOID Buffer
406c2c66affSColin Finck );
407c2c66affSColin Finck 
408c2c66affSColin Finck BOOLEAN
409c2c66affSColin Finck NTAPI
410c2c66affSColin Finck KeStopProfile(struct _KPROFILE* Profile);
411c2c66affSColin Finck 
412c2c66affSColin Finck ULONG
413c2c66affSColin Finck NTAPI
414c2c66affSColin Finck KeQueryIntervalProfile(KPROFILE_SOURCE ProfileSource);
415c2c66affSColin Finck 
416c2c66affSColin Finck VOID
417c2c66affSColin Finck NTAPI
418c2c66affSColin Finck KeSetIntervalProfile(
419c2c66affSColin Finck     ULONG Interval,
420c2c66affSColin Finck     KPROFILE_SOURCE ProfileSource
421c2c66affSColin Finck );
422c2c66affSColin Finck 
423c2c66affSColin Finck VOID
424c2c66affSColin Finck NTAPI
425c2c66affSColin Finck KeUpdateRunTime(
426c2c66affSColin Finck     PKTRAP_FRAME TrapFrame,
427c2c66affSColin Finck     KIRQL Irql
428c2c66affSColin Finck );
429c2c66affSColin Finck 
430c2c66affSColin Finck VOID
431c2c66affSColin Finck NTAPI
432c2c66affSColin Finck KiExpireTimers(
433c2c66affSColin Finck     PKDPC Dpc,
434c2c66affSColin Finck     PVOID DeferredContext,
435c2c66affSColin Finck     PVOID SystemArgument1,
436c2c66affSColin Finck     PVOID SystemArgument2
437c2c66affSColin Finck );
438c2c66affSColin Finck 
439c2c66affSColin Finck VOID
440c2c66affSColin Finck NTAPI
441c2c66affSColin Finck KeInitializeThread(
442c2c66affSColin Finck     IN PKPROCESS Process,
443c2c66affSColin Finck     IN OUT PKTHREAD Thread,
444c2c66affSColin Finck     IN PKSYSTEM_ROUTINE SystemRoutine,
445c2c66affSColin Finck     IN PKSTART_ROUTINE StartRoutine,
446c2c66affSColin Finck     IN PVOID StartContext,
447c2c66affSColin Finck     IN PCONTEXT Context,
448c2c66affSColin Finck     IN PVOID Teb,
449c2c66affSColin Finck     IN PVOID KernelStack
450c2c66affSColin Finck );
451c2c66affSColin Finck 
452c2c66affSColin Finck VOID
453c2c66affSColin Finck NTAPI
454c2c66affSColin Finck KeUninitThread(
455c2c66affSColin Finck     IN PKTHREAD Thread
456c2c66affSColin Finck );
457c2c66affSColin Finck 
458c2c66affSColin Finck NTSTATUS
459c2c66affSColin Finck NTAPI
460c2c66affSColin Finck KeInitThread(
461c2c66affSColin Finck     IN OUT PKTHREAD Thread,
462c2c66affSColin Finck     IN PVOID KernelStack,
463c2c66affSColin Finck     IN PKSYSTEM_ROUTINE SystemRoutine,
464c2c66affSColin Finck     IN PKSTART_ROUTINE StartRoutine,
465c2c66affSColin Finck     IN PVOID StartContext,
466c2c66affSColin Finck     IN PCONTEXT Context,
467c2c66affSColin Finck     IN PVOID Teb,
468c2c66affSColin Finck     IN PKPROCESS Process
469c2c66affSColin Finck );
470c2c66affSColin Finck 
471c2c66affSColin Finck VOID
472c2c66affSColin Finck NTAPI
473c2c66affSColin Finck KiInitializeContextThread(
474c2c66affSColin Finck     PKTHREAD Thread,
475c2c66affSColin Finck     PKSYSTEM_ROUTINE SystemRoutine,
476c2c66affSColin Finck     PKSTART_ROUTINE StartRoutine,
477c2c66affSColin Finck     PVOID StartContext,
478c2c66affSColin Finck     PCONTEXT Context
479c2c66affSColin Finck );
480c2c66affSColin Finck 
481c2c66affSColin Finck VOID
482c2c66affSColin Finck NTAPI
483c2c66affSColin Finck KeStartThread(
484c2c66affSColin Finck     IN OUT PKTHREAD Thread
485c2c66affSColin Finck );
486c2c66affSColin Finck 
487c2c66affSColin Finck BOOLEAN
488c2c66affSColin Finck NTAPI
489c2c66affSColin Finck KeAlertThread(
490c2c66affSColin Finck     IN PKTHREAD Thread,
491c2c66affSColin Finck     IN KPROCESSOR_MODE AlertMode
492c2c66affSColin Finck );
493c2c66affSColin Finck 
494c2c66affSColin Finck ULONG
495c2c66affSColin Finck NTAPI
496c2c66affSColin Finck KeAlertResumeThread(
497c2c66affSColin Finck     IN PKTHREAD Thread
498c2c66affSColin Finck );
499c2c66affSColin Finck 
500c2c66affSColin Finck ULONG
501c2c66affSColin Finck NTAPI
502c2c66affSColin Finck KeResumeThread(
503c2c66affSColin Finck     IN PKTHREAD Thread
504c2c66affSColin Finck );
505c2c66affSColin Finck 
506c2c66affSColin Finck PVOID
507c2c66affSColin Finck NTAPI
508c2c66affSColin Finck KeSwitchKernelStack(
509c2c66affSColin Finck     IN PVOID StackBase,
510c2c66affSColin Finck     IN PVOID StackLimit
511c2c66affSColin Finck );
512c2c66affSColin Finck 
513c2c66affSColin Finck VOID
514c2c66affSColin Finck NTAPI
515c2c66affSColin Finck KeRundownThread(VOID);
516c2c66affSColin Finck 
517c2c66affSColin Finck NTSTATUS
518c2c66affSColin Finck NTAPI
519c2c66affSColin Finck KeReleaseThread(PKTHREAD Thread);
520c2c66affSColin Finck 
521c2c66affSColin Finck VOID
522c2c66affSColin Finck NTAPI
523c2c66affSColin Finck KiSuspendRundown(
524c2c66affSColin Finck     IN PKAPC Apc
525c2c66affSColin Finck );
526c2c66affSColin Finck 
527c2c66affSColin Finck VOID
528c2c66affSColin Finck NTAPI
529c2c66affSColin Finck KiSuspendNop(
530c2c66affSColin Finck     IN PKAPC Apc,
531c2c66affSColin Finck     IN PKNORMAL_ROUTINE *NormalRoutine,
532c2c66affSColin Finck     IN PVOID *NormalContext,
533c2c66affSColin Finck     IN PVOID *SystemArgument1,
534c2c66affSColin Finck     IN PVOID *SystemArgument2
535c2c66affSColin Finck );
536c2c66affSColin Finck 
537c2c66affSColin Finck VOID
538c2c66affSColin Finck NTAPI
539c2c66affSColin Finck KiSuspendThread(
540c2c66affSColin Finck     IN PVOID NormalContext,
541c2c66affSColin Finck     IN PVOID SystemArgument1,
542c2c66affSColin Finck     IN PVOID SystemArgument2
543c2c66affSColin Finck );
544c2c66affSColin Finck 
545c2c66affSColin Finck LONG
546c2c66affSColin Finck NTAPI
547c2c66affSColin Finck KeQueryBasePriorityThread(IN PKTHREAD Thread);
548c2c66affSColin Finck 
549c2c66affSColin Finck VOID
550c2c66affSColin Finck FASTCALL
551c2c66affSColin Finck KiSetPriorityThread(
552c2c66affSColin Finck     IN PKTHREAD Thread,
553c2c66affSColin Finck     IN KPRIORITY Priority
554c2c66affSColin Finck );
555c2c66affSColin Finck 
556c2c66affSColin Finck VOID
557c2c66affSColin Finck FASTCALL
558c2c66affSColin Finck KiUnlinkThread(
559c2c66affSColin Finck     IN PKTHREAD Thread,
560c2c66affSColin Finck     IN LONG_PTR WaitStatus
561c2c66affSColin Finck );
562c2c66affSColin Finck 
563c2c66affSColin Finck VOID
564c2c66affSColin Finck NTAPI
565c2c66affSColin Finck KeDumpStackFrames(PULONG Frame);
566c2c66affSColin Finck 
567c2c66affSColin Finck BOOLEAN
568c2c66affSColin Finck NTAPI
569c2c66affSColin Finck KiTestAlert(VOID);
570c2c66affSColin Finck 
571c2c66affSColin Finck VOID
572c2c66affSColin Finck FASTCALL
573c2c66affSColin Finck KiUnwaitThread(
574c2c66affSColin Finck     IN PKTHREAD Thread,
575c2c66affSColin Finck     IN LONG_PTR WaitStatus,
576c2c66affSColin Finck     IN KPRIORITY Increment
577c2c66affSColin Finck );
578c2c66affSColin Finck 
579c2c66affSColin Finck VOID
580c2c66affSColin Finck NTAPI
581c2c66affSColin Finck KeInitializeProcess(
582c2c66affSColin Finck     struct _KPROCESS *Process,
583c2c66affSColin Finck     KPRIORITY Priority,
584c2c66affSColin Finck     KAFFINITY Affinity,
585c2c66affSColin Finck     PULONG_PTR DirectoryTableBase,
586c2c66affSColin Finck     IN BOOLEAN Enable
587c2c66affSColin Finck );
588c2c66affSColin Finck 
589c2c66affSColin Finck VOID
590c2c66affSColin Finck NTAPI
591c2c66affSColin Finck KeSetQuantumProcess(
592c2c66affSColin Finck     IN PKPROCESS Process,
593c2c66affSColin Finck     IN UCHAR Quantum
594c2c66affSColin Finck );
595c2c66affSColin Finck 
596c2c66affSColin Finck KPRIORITY
597c2c66affSColin Finck NTAPI
598c2c66affSColin Finck KeSetPriorityAndQuantumProcess(
599c2c66affSColin Finck     IN PKPROCESS Process,
600c2c66affSColin Finck     IN KPRIORITY Priority,
601c2c66affSColin Finck     IN UCHAR Quantum OPTIONAL
602c2c66affSColin Finck );
603c2c66affSColin Finck 
604c2c66affSColin Finck ULONG
605c2c66affSColin Finck NTAPI
606c2c66affSColin Finck KeForceResumeThread(IN PKTHREAD Thread);
607c2c66affSColin Finck 
608c2c66affSColin Finck VOID
609c2c66affSColin Finck NTAPI
610c2c66affSColin Finck KeThawAllThreads(
611c2c66affSColin Finck     VOID
612c2c66affSColin Finck );
613c2c66affSColin Finck 
614c2c66affSColin Finck VOID
615c2c66affSColin Finck NTAPI
616c2c66affSColin Finck KeFreezeAllThreads(
617c2c66affSColin Finck     VOID
618c2c66affSColin Finck );
619c2c66affSColin Finck 
620c2c66affSColin Finck BOOLEAN
621c2c66affSColin Finck NTAPI
622c2c66affSColin Finck KeDisableThreadApcQueueing(IN PKTHREAD Thread);
623c2c66affSColin Finck 
624c2c66affSColin Finck VOID
625c2c66affSColin Finck FASTCALL
626c2c66affSColin Finck KiWaitTest(
627c2c66affSColin Finck     PVOID Object,
628c2c66affSColin Finck     KPRIORITY Increment
629c2c66affSColin Finck );
630c2c66affSColin Finck 
631c2c66affSColin Finck VOID
632c2c66affSColin Finck NTAPI
633c2c66affSColin Finck KeContextToTrapFrame(
634c2c66affSColin Finck     PCONTEXT Context,
635c2c66affSColin Finck     PKEXCEPTION_FRAME ExeptionFrame,
636c2c66affSColin Finck     PKTRAP_FRAME TrapFrame,
637c2c66affSColin Finck     ULONG ContextFlags,
638c2c66affSColin Finck     KPROCESSOR_MODE PreviousMode
639c2c66affSColin Finck );
640c2c66affSColin Finck 
641c2c66affSColin Finck VOID
642c2c66affSColin Finck NTAPI
643c2c66affSColin Finck Ke386SetIOPL(VOID);
644c2c66affSColin Finck 
645c2c66affSColin Finck VOID
646c2c66affSColin Finck NTAPI
647c2c66affSColin Finck KiCheckForKernelApcDelivery(VOID);
648c2c66affSColin Finck 
649c2c66affSColin Finck LONG
650c2c66affSColin Finck NTAPI
651c2c66affSColin Finck KiInsertQueue(
652c2c66affSColin Finck     IN PKQUEUE Queue,
653c2c66affSColin Finck     IN PLIST_ENTRY Entry,
654c2c66affSColin Finck     BOOLEAN Head
655c2c66affSColin Finck );
656c2c66affSColin Finck 
657c2c66affSColin Finck VOID
658c2c66affSColin Finck NTAPI
659c2c66affSColin Finck KiTimerExpiration(
660c2c66affSColin Finck     IN PKDPC Dpc,
661c2c66affSColin Finck     IN PVOID DeferredContext,
662c2c66affSColin Finck     IN PVOID SystemArgument1,
663c2c66affSColin Finck     IN PVOID SystemArgument2
664c2c66affSColin Finck );
665c2c66affSColin Finck 
666c2c66affSColin Finck ULONG
667c2c66affSColin Finck NTAPI
668c2c66affSColin Finck KeSetProcess(
669c2c66affSColin Finck     struct _KPROCESS* Process,
670c2c66affSColin Finck     KPRIORITY Increment,
671c2c66affSColin Finck     BOOLEAN InWait
672c2c66affSColin Finck );
673c2c66affSColin Finck 
674c2c66affSColin Finck VOID
675c2c66affSColin Finck NTAPI
676c2c66affSColin Finck KeInitializeEventPair(PKEVENT_PAIR EventPair);
677c2c66affSColin Finck 
678c2c66affSColin Finck VOID
679c2c66affSColin Finck NTAPI
680c2c66affSColin Finck KiInitializeUserApc(
681c2c66affSColin Finck     IN PKEXCEPTION_FRAME Reserved,
682c2c66affSColin Finck     IN PKTRAP_FRAME TrapFrame,
683c2c66affSColin Finck     IN PKNORMAL_ROUTINE NormalRoutine,
684c2c66affSColin Finck     IN PVOID NormalContext,
685c2c66affSColin Finck     IN PVOID SystemArgument1,
686c2c66affSColin Finck     IN PVOID SystemArgument2
687c2c66affSColin Finck );
688c2c66affSColin Finck 
689c2c66affSColin Finck PLIST_ENTRY
690c2c66affSColin Finck NTAPI
691c2c66affSColin Finck KeFlushQueueApc(
692c2c66affSColin Finck     IN PKTHREAD Thread,
693c2c66affSColin Finck     IN KPROCESSOR_MODE PreviousMode
694c2c66affSColin Finck );
695c2c66affSColin Finck 
696c2c66affSColin Finck VOID
697c2c66affSColin Finck NTAPI
698c2c66affSColin Finck KiAttachProcess(
699c2c66affSColin Finck     struct _KTHREAD *Thread,
700c2c66affSColin Finck     struct _KPROCESS *Process,
701c2c66affSColin Finck     PKLOCK_QUEUE_HANDLE ApcLock,
702c2c66affSColin Finck     struct _KAPC_STATE *SavedApcState
703c2c66affSColin Finck );
704c2c66affSColin Finck 
705c2c66affSColin Finck VOID
706c2c66affSColin Finck NTAPI
707c2c66affSColin Finck KiSwapProcess(
708c2c66affSColin Finck     struct _KPROCESS *NewProcess,
709c2c66affSColin Finck     struct _KPROCESS *OldProcess
710c2c66affSColin Finck );
711c2c66affSColin Finck 
712c2c66affSColin Finck BOOLEAN
713c2c66affSColin Finck NTAPI
714c2c66affSColin Finck KeTestAlertThread(IN KPROCESSOR_MODE AlertMode);
715c2c66affSColin Finck 
716c2c66affSColin Finck BOOLEAN
717c2c66affSColin Finck NTAPI
718c2c66affSColin Finck KeRemoveQueueApc(PKAPC Apc);
719c2c66affSColin Finck 
720c2c66affSColin Finck VOID
721c2c66affSColin Finck FASTCALL
722c2c66affSColin Finck KiActivateWaiterQueue(IN PKQUEUE Queue);
723c2c66affSColin Finck 
724c2c66affSColin Finck ULONG
725c2c66affSColin Finck NTAPI
726c2c66affSColin Finck KeQueryRuntimeProcess(IN PKPROCESS Process,
727c2c66affSColin Finck                       OUT PULONG UserTime);
728c2c66affSColin Finck 
729f15afdbcSPierre Schweitzer VOID
730f15afdbcSPierre Schweitzer NTAPI
731f15afdbcSPierre Schweitzer KeQueryValuesProcess(IN PKPROCESS Process,
732f15afdbcSPierre Schweitzer                      PPROCESS_VALUES Values);
733f15afdbcSPierre Schweitzer 
734c2c66affSColin Finck /* INITIALIZATION FUNCTIONS *************************************************/
735c2c66affSColin Finck 
7363adf4508SJérôme Gardou CODE_SEG("INIT")
737c2c66affSColin Finck BOOLEAN
738c2c66affSColin Finck NTAPI
739c2c66affSColin Finck KeInitSystem(VOID);
740c2c66affSColin Finck 
7413adf4508SJérôme Gardou CODE_SEG("INIT")
742c2c66affSColin Finck VOID
743c2c66affSColin Finck NTAPI
744c2c66affSColin Finck KeInitExceptions(VOID);
745c2c66affSColin Finck 
746c2c66affSColin Finck VOID
747c2c66affSColin Finck NTAPI
748c2c66affSColin Finck KeInitInterrupts(VOID);
749c2c66affSColin Finck 
7503adf4508SJérôme Gardou CODE_SEG("INIT")
751c2c66affSColin Finck VOID
752c2c66affSColin Finck NTAPI
753c2c66affSColin Finck KiInitializeBugCheck(VOID);
754c2c66affSColin Finck 
755e0400e78SSerge Gautherie DECLSPEC_NORETURN
7563adf4508SJérôme Gardou CODE_SEG("INIT")
757c2c66affSColin Finck VOID
758c2c66affSColin Finck NTAPI
759c2c66affSColin Finck KiSystemStartup(
760c2c66affSColin Finck     IN PLOADER_PARAMETER_BLOCK LoaderBlock
761c2c66affSColin Finck );
762c2c66affSColin Finck 
763c2c66affSColin Finck BOOLEAN
764c2c66affSColin Finck NTAPI
765c2c66affSColin Finck KiDeliverUserApc(PKTRAP_FRAME TrapFrame);
766c2c66affSColin Finck 
767c2c66affSColin Finck VOID
768c2c66affSColin Finck NTAPI
769c2c66affSColin Finck KiMoveApcState(
770c2c66affSColin Finck     PKAPC_STATE OldState,
771c2c66affSColin Finck     PKAPC_STATE NewState
772c2c66affSColin Finck );
773c2c66affSColin Finck 
774c2c66affSColin Finck VOID
775c2c66affSColin Finck NTAPI
776c2c66affSColin Finck KiAddProfileEvent(
777c2c66affSColin Finck     KPROFILE_SOURCE Source,
778c2c66affSColin Finck     ULONG Pc
779c2c66affSColin Finck );
780c2c66affSColin Finck 
781c2c66affSColin Finck VOID
782c2c66affSColin Finck NTAPI
783c2c66affSColin Finck KiDispatchException(
784c2c66affSColin Finck     PEXCEPTION_RECORD ExceptionRecord,
785c2c66affSColin Finck     PKEXCEPTION_FRAME ExceptionFrame,
786c2c66affSColin Finck     PKTRAP_FRAME Tf,
787c2c66affSColin Finck     KPROCESSOR_MODE PreviousMode,
788c2c66affSColin Finck     BOOLEAN SearchFrames
789c2c66affSColin Finck );
790c2c66affSColin Finck 
791c2c66affSColin Finck VOID
792c2c66affSColin Finck NTAPI
793c2c66affSColin Finck KeTrapFrameToContext(
794c2c66affSColin Finck     IN PKTRAP_FRAME TrapFrame,
795c2c66affSColin Finck     IN PKEXCEPTION_FRAME ExceptionFrame,
796c2c66affSColin Finck     IN OUT PCONTEXT Context
797c2c66affSColin Finck );
798c2c66affSColin Finck 
799c2c66affSColin Finck DECLSPEC_NORETURN
800c2c66affSColin Finck VOID
801c2c66affSColin Finck NTAPI
802c2c66affSColin Finck KeBugCheckWithTf(
803c2c66affSColin Finck     ULONG BugCheckCode,
804c2c66affSColin Finck     ULONG_PTR BugCheckParameter1,
805c2c66affSColin Finck     ULONG_PTR BugCheckParameter2,
806c2c66affSColin Finck     ULONG_PTR BugCheckParameter3,
807c2c66affSColin Finck     ULONG_PTR BugCheckParameter4,
808c2c66affSColin Finck     PKTRAP_FRAME Tf
809c2c66affSColin Finck );
810c2c66affSColin Finck 
811c2c66affSColin Finck BOOLEAN
812c2c66affSColin Finck NTAPI
813c2c66affSColin Finck KiHandleNmi(VOID);
814c2c66affSColin Finck 
815c2c66affSColin Finck VOID
816c2c66affSColin Finck NTAPI
817c2c66affSColin Finck KeFlushCurrentTb(VOID);
818c2c66affSColin Finck 
819c2c66affSColin Finck BOOLEAN
820c2c66affSColin Finck NTAPI
821c2c66affSColin Finck KeInvalidateAllCaches(VOID);
822c2c66affSColin Finck 
823c2c66affSColin Finck VOID
824c2c66affSColin Finck FASTCALL
825c2c66affSColin Finck KeZeroPages(IN PVOID Address,
826c2c66affSColin Finck             IN ULONG Size);
827c2c66affSColin Finck 
828c2c66affSColin Finck BOOLEAN
829c2c66affSColin Finck FASTCALL
830c2c66affSColin Finck KeInvalidAccessAllowed(IN PVOID TrapInformation OPTIONAL);
831c2c66affSColin Finck 
832c2c66affSColin Finck VOID
833c2c66affSColin Finck NTAPI
834c2c66affSColin Finck KeRosDumpStackFrames(
835c2c66affSColin Finck     PULONG_PTR Frame,
836c2c66affSColin Finck     ULONG FrameCount
837c2c66affSColin Finck );
838c2c66affSColin Finck 
839c2c66affSColin Finck VOID
840c2c66affSColin Finck NTAPI
841c2c66affSColin Finck KeSetSystemTime(
842c2c66affSColin Finck     IN PLARGE_INTEGER NewSystemTime,
843c2c66affSColin Finck     OUT PLARGE_INTEGER OldSystemTime,
844c2c66affSColin Finck     IN BOOLEAN FixInterruptTime,
845c2c66affSColin Finck     IN PLARGE_INTEGER HalTime
846c2c66affSColin Finck );
847c2c66affSColin Finck 
848c2c66affSColin Finck ULONG
849c2c66affSColin Finck NTAPI
850c2c66affSColin Finck KeV86Exception(
851c2c66affSColin Finck     ULONG ExceptionNr,
852c2c66affSColin Finck     PKTRAP_FRAME Tf,
853c2c66affSColin Finck     ULONG address
854c2c66affSColin Finck );
855c2c66affSColin Finck 
856c2c66affSColin Finck VOID
857c2c66affSColin Finck NTAPI
858c2c66affSColin Finck KiStartUnexpectedRange(
859c2c66affSColin Finck     VOID
860c2c66affSColin Finck );
861c2c66affSColin Finck 
862c2c66affSColin Finck VOID
863c2c66affSColin Finck NTAPI
864c2c66affSColin Finck KiEndUnexpectedRange(
865c2c66affSColin Finck     VOID
866c2c66affSColin Finck );
867c2c66affSColin Finck 
868c2c66affSColin Finck NTSTATUS
869c2c66affSColin Finck NTAPI
870c2c66affSColin Finck KiRaiseException(
871c2c66affSColin Finck     IN PEXCEPTION_RECORD ExceptionRecord,
872c2c66affSColin Finck     IN PCONTEXT Context,
873c2c66affSColin Finck     IN PKEXCEPTION_FRAME ExceptionFrame,
874c2c66affSColin Finck     IN PKTRAP_FRAME TrapFrame,
875c2c66affSColin Finck     IN BOOLEAN SearchFrames
876c2c66affSColin Finck );
877c2c66affSColin Finck 
878c2c66affSColin Finck NTSTATUS
879c2c66affSColin Finck NTAPI
880c2c66affSColin Finck KiContinue(
881c2c66affSColin Finck     IN PCONTEXT Context,
882c2c66affSColin Finck     IN PKEXCEPTION_FRAME ExceptionFrame,
883c2c66affSColin Finck     IN PKTRAP_FRAME TrapFrame
884c2c66affSColin Finck );
885c2c66affSColin Finck 
886c2c66affSColin Finck #ifndef _M_AMD64
887c2c66affSColin Finck VOID
888c2c66affSColin Finck FASTCALL
889c2c66affSColin Finck KiInterruptDispatch(
890c2c66affSColin Finck     IN PKTRAP_FRAME TrapFrame,
891c2c66affSColin Finck     IN PKINTERRUPT Interrupt
892c2c66affSColin Finck );
893c2c66affSColin Finck #endif
894c2c66affSColin Finck 
895c2c66affSColin Finck VOID
896c2c66affSColin Finck FASTCALL
897c2c66affSColin Finck KiChainedDispatch(
898c2c66affSColin Finck     IN PKTRAP_FRAME TrapFrame,
899c2c66affSColin Finck     IN PKINTERRUPT Interrupt
900c2c66affSColin Finck );
901c2c66affSColin Finck 
9023adf4508SJérôme Gardou CODE_SEG("INIT")
903c2c66affSColin Finck VOID
904c2c66affSColin Finck NTAPI
905c2c66affSColin Finck KiInitializeMachineType(
906c2c66affSColin Finck     VOID
907c2c66affSColin Finck );
908c2c66affSColin Finck 
909c2c66affSColin Finck VOID
910c2c66affSColin Finck NTAPI
911c2c66affSColin Finck KiSetupStackAndInitializeKernel(
912c2c66affSColin Finck     IN PKPROCESS InitProcess,
913c2c66affSColin Finck     IN PKTHREAD InitThread,
914c2c66affSColin Finck     IN PVOID IdleStack,
915c2c66affSColin Finck     IN PKPRCB Prcb,
916c2c66affSColin Finck     IN CCHAR Number,
917c2c66affSColin Finck     IN PLOADER_PARAMETER_BLOCK LoaderBlock
918c2c66affSColin Finck );
919c2c66affSColin Finck 
9203adf4508SJérôme Gardou CODE_SEG("INIT")
921c2c66affSColin Finck VOID
922c2c66affSColin Finck NTAPI
923c2c66affSColin Finck KiInitSpinLocks(
924c2c66affSColin Finck     IN PKPRCB Prcb,
925c2c66affSColin Finck     IN CCHAR Number
926c2c66affSColin Finck );
927c2c66affSColin Finck 
9283adf4508SJérôme Gardou CODE_SEG("INIT")
929c2c66affSColin Finck LARGE_INTEGER
930c2c66affSColin Finck NTAPI
931c2c66affSColin Finck KiComputeReciprocal(
932c2c66affSColin Finck     IN LONG Divisor,
933c2c66affSColin Finck     OUT PUCHAR Shift
934c2c66affSColin Finck );
935c2c66affSColin Finck 
9363adf4508SJérôme Gardou CODE_SEG("INIT")
937c2c66affSColin Finck VOID
938c2c66affSColin Finck NTAPI
939c2c66affSColin Finck KiInitSystem(
940c2c66affSColin Finck     VOID
941c2c66affSColin Finck );
942c2c66affSColin Finck 
943c2c66affSColin Finck VOID
944c2c66affSColin Finck FASTCALL
945c2c66affSColin Finck KiInsertQueueApc(
946c2c66affSColin Finck     IN PKAPC Apc,
947c2c66affSColin Finck     IN KPRIORITY PriorityBoost
948c2c66affSColin Finck );
949c2c66affSColin Finck 
950c2c66affSColin Finck NTSTATUS
951c2c66affSColin Finck NTAPI
952c2c66affSColin Finck KiCallUserMode(
953c2c66affSColin Finck     IN PVOID *OutputBuffer,
954c2c66affSColin Finck     IN PULONG OutputLength
955c2c66affSColin Finck );
956c2c66affSColin Finck 
957c2c66affSColin Finck DECLSPEC_NORETURN
958c2c66affSColin Finck VOID
959c2c66affSColin Finck FASTCALL
960c2c66affSColin Finck KiCallbackReturn(
961c2c66affSColin Finck     IN PVOID Stack,
962c2c66affSColin Finck     IN NTSTATUS Status
963c2c66affSColin Finck );
964c2c66affSColin Finck 
9653adf4508SJérôme Gardou CODE_SEG("INIT")
966c2c66affSColin Finck VOID
967c2c66affSColin Finck NTAPI
968c2c66affSColin Finck KiInitMachineDependent(VOID);
969c2c66affSColin Finck 
97092297093STimo Kreuzer VOID
97192297093STimo Kreuzer NTAPI
97292297093STimo Kreuzer KxFreezeExecution(
97392297093STimo Kreuzer     VOID);
97492297093STimo Kreuzer 
97592297093STimo Kreuzer VOID
97692297093STimo Kreuzer NTAPI
97792297093STimo Kreuzer KxThawExecution(
97892297093STimo Kreuzer     VOID);
97992297093STimo Kreuzer 
980c2c66affSColin Finck BOOLEAN
981c2c66affSColin Finck NTAPI
982c2c66affSColin Finck KeFreezeExecution(IN PKTRAP_FRAME TrapFrame,
983c2c66affSColin Finck                   IN PKEXCEPTION_FRAME ExceptionFrame);
984c2c66affSColin Finck 
985c2c66affSColin Finck VOID
986c2c66affSColin Finck NTAPI
987c2c66affSColin Finck KeThawExecution(IN BOOLEAN Enable);
988c2c66affSColin Finck 
98972fd54a7STimo Kreuzer KCONTINUE_STATUS
99072fd54a7STimo Kreuzer NTAPI
99172fd54a7STimo Kreuzer KxSwitchKdProcessor(
99272fd54a7STimo Kreuzer     _In_ ULONG ProcessorIndex);
99372fd54a7STimo Kreuzer 
99437d0a9c3SJérôme Gardou _IRQL_requires_min_(DISPATCH_LEVEL)
99537d0a9c3SJérôme Gardou _Acquires_nonreentrant_lock_(*LockHandle->Lock)
99637d0a9c3SJérôme Gardou _Acquires_exclusive_lock_(*LockHandle->Lock)
997c2c66affSColin Finck VOID
998c2c66affSColin Finck FASTCALL
999c2c66affSColin Finck KeAcquireQueuedSpinLockAtDpcLevel(
100037d0a9c3SJérôme Gardou     _Inout_ PKSPIN_LOCK_QUEUE LockQueue
1001c2c66affSColin Finck );
1002c2c66affSColin Finck 
100337d0a9c3SJérôme Gardou _IRQL_requires_min_(DISPATCH_LEVEL)
100437d0a9c3SJérôme Gardou _Releases_nonreentrant_lock_(*LockHandle->Lock)
100537d0a9c3SJérôme Gardou _Releases_exclusive_lock_(*LockHandle->Lock)
1006c2c66affSColin Finck VOID
1007c2c66affSColin Finck FASTCALL
1008c2c66affSColin Finck KeReleaseQueuedSpinLockFromDpcLevel(
100937d0a9c3SJérôme Gardou     _Inout_ PKSPIN_LOCK_QUEUE LockQueue
1010c2c66affSColin Finck );
1011c2c66affSColin Finck 
1012c2c66affSColin Finck VOID
1013c2c66affSColin Finck NTAPI
1014c2c66affSColin Finck KiRestoreProcessorControlState(
1015c2c66affSColin Finck     IN PKPROCESSOR_STATE ProcessorState
1016c2c66affSColin Finck );
1017c2c66affSColin Finck 
1018c2c66affSColin Finck VOID
1019c2c66affSColin Finck NTAPI
1020c2c66affSColin Finck KiSaveProcessorControlState(
1021c2c66affSColin Finck     OUT PKPROCESSOR_STATE ProcessorState
1022c2c66affSColin Finck );
1023c2c66affSColin Finck 
1024c2c66affSColin Finck VOID
1025c2c66affSColin Finck NTAPI
1026c2c66affSColin Finck KiSaveProcessorState(
1027af2ce4d0STimo Kreuzer     _In_ PKTRAP_FRAME TrapFrame,
1028af2ce4d0STimo Kreuzer     _In_ PKEXCEPTION_FRAME ExceptionFrame);
1029af2ce4d0STimo Kreuzer 
1030af2ce4d0STimo Kreuzer VOID
1031af2ce4d0STimo Kreuzer NTAPI
1032af2ce4d0STimo Kreuzer KiRestoreProcessorState(
1033af2ce4d0STimo Kreuzer     _Out_ PKTRAP_FRAME TrapFrame,
1034af2ce4d0STimo Kreuzer     _Out_ PKEXCEPTION_FRAME ExceptionFrame);
1035c2c66affSColin Finck 
1036c2c66affSColin Finck VOID
1037c2c66affSColin Finck FASTCALL
1038c2c66affSColin Finck KiRetireDpcList(
1039c2c66affSColin Finck     IN PKPRCB Prcb
1040c2c66affSColin Finck );
1041c2c66affSColin Finck 
1042c2c66affSColin Finck VOID
1043c2c66affSColin Finck NTAPI
1044c2c66affSColin Finck KiQuantumEnd(
1045c2c66affSColin Finck     VOID
1046c2c66affSColin Finck );
1047c2c66affSColin Finck 
10485f1d79f0SSerge Gautherie DECLSPEC_NORETURN
1049c2c66affSColin Finck VOID
1050c2c66affSColin Finck KiIdleLoop(
1051c2c66affSColin Finck     VOID
1052c2c66affSColin Finck );
1053c2c66affSColin Finck 
1054c2c66affSColin Finck DECLSPEC_NORETURN
1055c2c66affSColin Finck VOID
1056c2c66affSColin Finck FASTCALL
1057c2c66affSColin Finck KiSystemFatalException(
1058c2c66affSColin Finck     IN ULONG ExceptionCode,
1059c2c66affSColin Finck     IN PKTRAP_FRAME TrapFrame
1060c2c66affSColin Finck );
1061c2c66affSColin Finck 
1062c2c66affSColin Finck PVOID
1063c2c66affSColin Finck NTAPI
1064*3c1e022dSHermès Bélusca-Maïto KiPcToFileHeader(IN PVOID Pc,
1065c2c66affSColin Finck                  OUT PLDR_DATA_TABLE_ENTRY *LdrEntry,
1066c2c66affSColin Finck                  IN BOOLEAN DriversOnly,
1067c2c66affSColin Finck                  OUT PBOOLEAN InKernel);
1068c2c66affSColin Finck 
1069c2c66affSColin Finck PVOID
1070c2c66affSColin Finck NTAPI
1071*3c1e022dSHermès Bélusca-Maïto KiRosPcToUserFileHeader(IN PVOID Pc,
1072c2c66affSColin Finck                         OUT PLDR_DATA_TABLE_ENTRY *LdrEntry);
1073c2c66affSColin Finck 
1074c2c66affSColin Finck PCHAR
1075c2c66affSColin Finck NTAPI
1076c2c66affSColin Finck KeBugCheckUnicodeToAnsi(
1077c2c66affSColin Finck     IN PUNICODE_STRING Unicode,
1078c2c66affSColin Finck     OUT PCHAR Ansi,
1079c2c66affSColin Finck     IN ULONG Length
1080c2c66affSColin Finck );
1081c2c66affSColin Finck 
108231afbf10SJérôme Gardou #ifdef __cplusplus
108331afbf10SJérôme Gardou } // extern "C"
1084aeffd16bSJérôme Gardou 
1085aeffd16bSJérôme Gardou namespace ntoskrnl
1086aeffd16bSJérôme Gardou {
1087aeffd16bSJérôme Gardou 
1088aeffd16bSJérôme Gardou /* Like std::lock_guard, but for a Queued Spinlock */
1089aeffd16bSJérôme Gardou template <KSPIN_LOCK_QUEUE_NUMBER n>
1090aeffd16bSJérôme Gardou class KiQueuedSpinLockGuard
1091aeffd16bSJérôme Gardou {
1092aeffd16bSJérôme Gardou private:
1093aeffd16bSJérôme Gardou     KIRQL m_OldIrql;
1094aeffd16bSJérôme Gardou public:
1095aeffd16bSJérôme Gardou 
_Requires_lock_not_held_(n)1096aeffd16bSJérôme Gardou     _Requires_lock_not_held_(n)
1097aeffd16bSJérôme Gardou     _Acquires_lock_(n)
1098aeffd16bSJérôme Gardou     _IRQL_raises_(DISPATCH_LEVEL)
1099aeffd16bSJérôme Gardou     explicit KiQueuedSpinLockGuard()
1100aeffd16bSJérôme Gardou     {
1101aeffd16bSJérôme Gardou         m_OldIrql = KeAcquireQueuedSpinLock(n);
1102aeffd16bSJérôme Gardou     }
1103aeffd16bSJérôme Gardou 
1104aeffd16bSJérôme Gardou     _Requires_lock_held_(n)
_Releases_lock_(n)1105aeffd16bSJérôme Gardou     _Releases_lock_(n)
1106aeffd16bSJérôme Gardou     ~KiQueuedSpinLockGuard()
1107aeffd16bSJérôme Gardou     {
1108aeffd16bSJérôme Gardou         KeReleaseQueuedSpinLock(n, m_OldIrql);
1109aeffd16bSJérôme Gardou     }
1110aeffd16bSJérôme Gardou 
1111aeffd16bSJérôme Gardou private:
1112aeffd16bSJérôme Gardou     KiQueuedSpinLockGuard(KiQueuedSpinLockGuard const&) = delete;
1113aeffd16bSJérôme Gardou     KiQueuedSpinLockGuard& operator=(KiQueuedSpinLockGuard const&) = delete;
1114aeffd16bSJérôme Gardou };
1115aeffd16bSJérôme Gardou 
1116aeffd16bSJérôme Gardou }
1117aeffd16bSJérôme Gardou 
111831afbf10SJérôme Gardou #endif
111931afbf10SJérôme Gardou 
1120c2c66affSColin Finck #include "ke_x.h"
1121