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