ReactOS 0.4.15-dev-7928-g68a8619
ke.h
Go to the documentation of this file.
1#pragma once
2
3#ifndef __ASM__
4
5#include "intrin_i.h"
6
7#ifdef __cplusplus
8extern "C"
9{
10#endif
11
12//
13// Thread Dispatcher Header DebugActive Mask
14//
15#define DR_MASK(x) (1 << (x))
16#define DR_REG_MASK 0x4F
17
18//
19// INT3 is 1 byte long
20//
21#define KD_BREAKPOINT_TYPE UCHAR
22#define KD_BREAKPOINT_SIZE sizeof(UCHAR)
23#define KD_BREAKPOINT_VALUE 0xCC
24
25/* CPUID 1 - EDX flags */
26#define X86_FEATURE_FPU 0x00000001 /* x87 FPU is present */
27#define X86_FEATURE_VME 0x00000002 /* Virtual 8086 Extensions are present */
28#define X86_FEATURE_DBG 0x00000004 /* Debugging extensions are present */
29#define X86_FEATURE_PSE 0x00000008 /* Page Size Extension is present */
30#define X86_FEATURE_TSC 0x00000010 /* Time Stamp Counters are present */
31#define X86_FEATURE_PAE 0x00000040 /* Physical Address Extension is present */
32#define X86_FEATURE_CX8 0x00000100 /* CMPXCHG8B instruction present */
33#define X86_FEATURE_APIC 0x00000200 /* APIC is present */
34#define X86_FEATURE_SYSCALL 0x00000800 /* SYSCALL/SYSRET support present */
35#define X86_FEATURE_MTTR 0x00001000 /* Memory type range registers are present */
36#define X86_FEATURE_PGE 0x00002000 /* Page Global Enable */
37#define X86_FEATURE_CMOV 0x00008000 /* "Conditional move" instruction supported */
38#define X86_FEATURE_PAT 0x00010000 /* Page Attribute Table is supported */
39#define X86_FEATURE_DS 0x00200000 /* Debug Store is present */
40#define X86_FEATURE_MMX 0x00800000 /* MMX extension present */
41#define X86_FEATURE_FXSR 0x01000000 /* FXSAVE/FXRSTOR instructions present */
42#define X86_FEATURE_SSE 0x02000000 /* SSE extension present */
43#define X86_FEATURE_SSE2 0x04000000 /* SSE2 extension present */
44#define X86_FEATURE_HT 0x10000000 /* Hyper-Threading present */
45
46/* CPUID 0x80000001 - EDX extended flags */
47#define X86_FEATURE_NX 0x00100000 /* NX support present */
48
49//
50// One-liners for getting and setting special purpose registers in portable code
51//
55{
56 return Context->Eip;
57}
58
60VOID
62{
63 Context->Eip = ProgramCounter;
64}
65
69{
70 return Context->Eax;
71}
72
74VOID
76{
77 Context->Eax = ReturnValue;
78}
79
83{
84 return Context->Ebp;
85}
86
88VOID
90{
91 Context->Ebp = Frame;
92}
93
97{
98 return TrapFrame->Eip;
99}
100
104{
105 return (PKTRAP_FRAME)TrapFrame->Edx;
106}
107
108
112{
113 if (TrapFrame->PreviousPreviousMode == KernelMode)
114 return TrapFrame->TempEsp;
115 return TrapFrame->HardwareEsp;
116}
117
121{
122 return TrapFrame->Ebp;
123}
124
125//
126// Macro to get trap and exception frame from a thread stack
127//
128#define KeGetTrapFrame(Thread) \
129 (PKTRAP_FRAME)((ULONG_PTR)((Thread)->InitialStack) - \
130 sizeof(KTRAP_FRAME) - \
131 sizeof(FX_SAVE_AREA))
132
133#define KeGetExceptionFrame(Thread) \
134 NULL
135
136//
137// Macro to get context switches from the PRCB
138// All architectures but x86 have it in the PRCB's KeContextSwitches
139//
140#define KeGetContextSwitches(Prcb) \
141 CONTAINING_RECORD(Prcb, KIPCR, PrcbData)->ContextSwitches
142
143//
144// Macro to get the second level cache size field name which differs between
145// CISC and RISC architectures, as the former has unified I/D cache
146//
147#define KiGetSecondLevelDCacheSize() ((PKIPCR)KeGetPcr())->SecondLevelCacheSize
148
149//
150// Returns the Interrupt State from a Trap Frame.
151// ON = TRUE, OFF = FALSE
152//
153#define KeGetTrapFrameInterruptState(TrapFrame) \
154 BooleanFlagOn((TrapFrame)->EFlags, EFLAGS_INTERRUPT_MASK)
155
156//
157// Flags for exiting a trap
158//
159#define KTE_SKIP_PM_BIT (((KTRAP_EXIT_SKIP_BITS) { { .SkipPreviousMode = TRUE } }).Bits)
160#define KTE_SKIP_SEG_BIT (((KTRAP_EXIT_SKIP_BITS) { { .SkipSegments = TRUE } }).Bits)
161#define KTE_SKIP_VOL_BIT (((KTRAP_EXIT_SKIP_BITS) { { .SkipVolatiles = TRUE } }).Bits)
162
164{
165 struct
166 {
171 };
174
175
176//
177// Flags used by the VDM/V8086 emulation engine for determining instruction prefixes
178//
179#define PFX_FLAG_ES 0x00000100
180#define PFX_FLAG_CS 0x00000200
181#define PFX_FLAG_SS 0x00000400
182#define PFX_FLAG_DS 0x00000800
183#define PFX_FLAG_FS 0x00001000
184#define PFX_FLAG_GS 0x00002000
185#define PFX_FLAG_OPER32 0x00004000
186#define PFX_FLAG_ADDR32 0x00008000
187#define PFX_FLAG_LOCK 0x00010000
188#define PFX_FLAG_REPNE 0x00020000
189#define PFX_FLAG_REP 0x00040000
190
191//
192// VDM Helper Macros
193//
194// All VDM/V8086 opcode emulators have the same FASTCALL function definition.
195// We need to keep 2 parameters while the original ASM implementation uses 4:
196// TrapFrame, PrefixFlags, Eip, InstructionSize;
197//
198// We pass the trap frame, and prefix flags, in our two parameters.
199//
200// We then realize that since the smallest prefix flag is 0x100, this gives us
201// a count of up to 0xFF. So we OR in the instruction size with the prefix flags
202//
203// We further realize that we always have access to EIP from the trap frame, and
204// that if we want the *current instruction* EIP, we simply have to add the
205// instruction size *MINUS ONE*, and that gives us the EIP we should be looking
206// at now, so we don't need to use the stack to push this parameter.
207//
208// We actually only care about the *current instruction* EIP in one location,
209// so although it may be slightly more expensive to re-calculate the EIP one
210// more time, this way we don't redefine ALL opcode handlers to have 3 parameters,
211// which would be forcing stack usage in all other scenarios.
212//
213#define KiVdmSetVdmEFlags(x) InterlockedOr((PLONG)KiNtVdmState, (x));
214#define KiVdmClearVdmEFlags(x) InterlockedAnd((PLONG)KiNtVdmState, ~(x))
215#define KiCallVdmHandler(x) KiVdmOpcode##x(TrapFrame, Flags)
216#define KiCallVdmPrefixHandler(x) KiVdmOpcodePrefix(TrapFrame, Flags | x)
217#define KiVdmUnhandledOpcode(x) \
218 BOOLEAN \
219 FASTCALL \
220 KiVdmOpcode##x(IN PKTRAP_FRAME TrapFrame, \
221 IN ULONG Flags) \
222 { \
223 /* Not yet handled */ \
224 UNIMPLEMENTED_DBGBREAK(); \
225 return FALSE; \
226 }
227
229
230//
231// Local parameters
232//
233typedef struct _KV86_FRAME
234{
239
240//
241// Virtual Stack Frame
242//
244{
249
250//
251// Large Pages Support
252//
254{
261
262//
263// Floating Point Internal Context Structure
264//
266{
272
273/* Diable interrupts and return whether they were enabled before */
277{
278 ULONG Flags;
279 BOOLEAN Return;
280
281 /* Get EFLAGS and check if the interrupt bit is set */
283 Return = (Flags & EFLAGS_INTERRUPT_MASK) ? TRUE: FALSE;
284
285 /* Disable interrupts */
286 _disable();
287 return Return;
288}
289
290/* Restore previous interrupt state */
292VOID
294{
295 if (WereEnabled) _enable();
296}
297
298//
299// Registers an interrupt handler with an IDT vector
300//
302VOID
305{
306 UCHAR Entry;
308 PKIPCR Pcr = (PKIPCR)KeGetPcr();
309
310 //
311 // Get the entry from the HAL
312 //
315
316 //
317 // Now set the data
318 //
319 Pcr->IDT[Entry].ExtendedOffset = (USHORT)(Address >> 16);
320 Pcr->IDT[Entry].Offset = (USHORT)Address;
321}
322
323//
324// Returns the registered interrupt handler for a given IDT vector
325//
327PVOID
329{
330 PKIPCR Pcr = (PKIPCR)KeGetPcr();
331 UCHAR Entry;
332
333 //
334 // Get the entry from the HAL
335 //
337
338 //
339 // Read the entry from the IDT
340 //
341 return (PVOID)(((Pcr->IDT[Entry].ExtendedOffset << 16) & 0xFFFF0000) |
342 (Pcr->IDT[Entry].Offset & 0xFFFF));
343}
344
345//
346// Invalidates the TLB entry for a specified address
347//
349VOID
351{
352 /* Invalidate the TLB entry for this address */
354}
355
357VOID
359{
360 /* Flush the TLB by resetting CR3 */
362}
363
365VOID
367 IN SIZE_T FlushSize)
368{
369 //
370 // Always sweep the whole cache
371 //
373 UNREFERENCED_PARAMETER(FlushSize);
374 __wbinvd();
375}
376
380{
381 /* Return the current thread */
382 return ((PKIPCR)KeGetPcr())->PrcbData.CurrentThread;
383}
384
386VOID
388{
389#ifndef CONFIG_SMP
390 /* Check if this is the NPX Thread */
391 if (KeGetCurrentPrcb()->NpxThread == Thread)
392 {
393 /* Clear it */
394 KeGetCurrentPrcb()->NpxThread = NULL;
395 Ke386FnInit();
396 }
397#else
398 /* Nothing to do */
399#endif
400}
401
402CODE_SEG("INIT")
403VOID
404NTAPI
405KiInitializePcr(IN ULONG ProcessorNumber,
406 IN PKIPCR Pcr,
407 IN PKIDTENTRY Idt,
408 IN PKGDTENTRY Gdt,
409 IN PKTSS Tss,
410 IN PKTHREAD IdleThread,
411 IN PVOID DpcStack);
412
414VOID
416{
417 GdtEntry->BaseLow = (USHORT)((ULONG_PTR)BaseAddress & 0xFFFF);
418 GdtEntry->HighWord.Bytes.BaseMid = (UCHAR)((ULONG_PTR)BaseAddress >> 16);
419 GdtEntry->HighWord.Bytes.BaseHi = (UCHAR)((ULONG_PTR)BaseAddress >> 24);
420}
421
423VOID
424KiSetTebBase(PKPCR Pcr, PNT_TIB TebAddress)
425{
426 Pcr->NtTib.Self = TebAddress;
427 Ke386SetGdtEntryBase(&Pcr->GDT[KGDT_R3_TEB / sizeof(KGDTENTRY)], TebAddress);
428}
429
430CODE_SEG("INIT")
431VOID
434 IN PKTSS Tss,
435 IN PKIDTENTRY Idt,
436 IN PKGDTENTRY Gdt
437);
438
439CODE_SEG("INIT")
440VOID
441NTAPI
443
444CODE_SEG("INIT")
445VOID
446NTAPI
448
449CODE_SEG("INIT")
451NTAPI
453 VOID
454);
455
456CODE_SEG("INIT")
458NTAPI
460 VOID
461);
462
463CODE_SEG("INIT")
464VOID
465NTAPI
467
468CODE_SEG("INIT")
469ULONG
470NTAPI
472
473#if DBG
474CODE_SEG("INIT")
475VOID
476KiReportCpuFeatures(VOID);
477#endif
478
479VOID
480NTAPI
482
484NTAPI
489);
490
491VOID
492NTAPI
494 IN FLOATING_SAVE_AREA *SaveArea
495);
496
497VOID
498NTAPI
500 IN PKTRAP_FRAME TrapFrame
501);
502
503VOID
504NTAPI
506 OUT PTEB VdmTeb
507);
508
509CODE_SEG("INIT")
510VOID
511NTAPI
513 VOID
514);
515
516CODE_SEG("INIT")
518NTAPI
521);
522
523CODE_SEG("INIT")
525NTAPI
528);
529
531NTAPI
533 IN PLARGE_IDENTITY_MAP IdentityMap,
534 IN PVOID StartPtr,
536);
537
538VOID
539NTAPI
541 IN PLARGE_IDENTITY_MAP IdentityMap
542);
543
544VOID
545NTAPI
547 IN ULONG_PTR StartAddress,
548 IN ULONG Cr3
549);
550
551CODE_SEG("INIT")
552VOID
553NTAPI
555 VOID
556);
557
558CODE_SEG("INIT")
559VOID
560NTAPI
562 VOID
563);
564
565CODE_SEG("INIT")
566VOID
567NTAPI
569 IN BOOLEAN FinalCpu
570);
571
572CODE_SEG("INIT")
573VOID
574NTAPI
576 VOID
577);
578
579CODE_SEG("INIT")
580VOID
581NTAPI
583 VOID
584);
585
586CODE_SEG("INIT")
588NTAPI
591);
592
593CODE_SEG("INIT")
595NTAPI
598);
599
600CODE_SEG("INIT")
602NTAPI
605);
606
608NTAPI
610 IN PKTRAP_FRAME TrapFrame
611);
612
614NTAPI
616 _In_ PKTRAP_FRAME TrapFrame
617);
618
622 IN PKTRAP_FRAME TrapFrame,
624);
625
629 IN PKTRAP_FRAME TrapFrame
630);
631
633VOID
636 IN PKTRAP_FRAME TrapFrame
637);
638
639VOID
642 IN PKTRAP_FRAME TrapFrame
643);
644
648 IN PKTRAP_FRAME TrapFrame
649);
650
652VOID
653NTAPI
656 IN ULONG Flags,
658 IN ULONG ParameterCount,
659 IN ULONG_PTR Parameter1,
660 IN ULONG_PTR Parameter2,
661 IN ULONG_PTR Parameter3,
662 IN PKTRAP_FRAME TrapFrame
663);
664
666NTAPI
668 VOID
669);
670
671//
672// Global x86 only Kernel data
673//
684extern ULONG KiMXCsrMask;
685extern ULONG KeI386CpuType;
686extern ULONG KeI386CpuStep;
699extern CHAR KiSystemCallExit[];
700extern CHAR KiSystemCallExit2[];
701
702//
703// Trap Macros
704//
705#include "trap_x.h"
706
707//
708// Returns a thread's FPU save area
709//
713{
714 ASSERT((ULONG_PTR)Thread->InitialStack % 16 == 0);
715 return (PFX_SAVE_AREA)((ULONG_PTR)Thread->InitialStack - sizeof(FX_SAVE_AREA));
716}
717
718//
719// Sanitizes a selector
720//
722ULONG
725{
726 //
727 // Check if we're in kernel-mode, and force CPL 0 if so.
728 // Otherwise, force CPL 3.
729 //
730 return ((Mode == KernelMode) ?
731 (Cs & (0xFFFF & ~RPL_MASK)) :
732 (RPL_MASK | (Cs & 0xFFFF)));
733}
734
735//
736// Sanitizes EFLAGS
737//
739ULONG
742{
743 //
744 // Check if we're in kernel-mode, and sanitize EFLAGS if so.
745 // Otherwise, also force interrupt mask on.
746 //
747 return ((Mode == KernelMode) ?
750}
751
752//
753// Sanitizes a Debug Register
754//
756PVOID
759{
760 //
761 // Check if we're in kernel-mode, and return the address directly if so.
762 // Otherwise, make sure it's not inside the kernel-mode address space.
763 // If it is, then clear the address.
764 //
765 return ((Mode == KernelMode) ? DrAddress :
766 (DrAddress <= MM_HIGHEST_USER_ADDRESS) ? DrAddress : 0);
767}
768
769//
770// Exception with no arguments
771//
774VOID
777 IN PKTRAP_FRAME TrapFrame)
778{
779 /* Helper for exceptions with no arguments */
780 KiDispatchExceptionFromTrapFrame(Code, 0, Address, 0, 0, 0, 0, TrapFrame);
781}
782
783//
784// Exception with one argument
785//
788VOID
791 IN ULONG P1,
792 IN PKTRAP_FRAME TrapFrame)
793{
794 /* Helper for exceptions with no arguments */
795 KiDispatchExceptionFromTrapFrame(Code, 0, Address, 1, P1, 0, 0, TrapFrame);
796}
797
798//
799// Exception with two arguments
800//
803VOID
806 IN ULONG P1,
807 IN ULONG P2,
808 IN PKTRAP_FRAME TrapFrame)
809{
810 /* Helper for exceptions with no arguments */
811 KiDispatchExceptionFromTrapFrame(Code, 0, Address, 2, P1, P2, 0, TrapFrame);
812}
813
814//
815// Performs a system call
816//
818NTAPI
820 _In_ PVOID Arguments,
821 _In_ ULONG StackBytes);
822
823
824//
825// Checks for pending APCs
826//
828VOID
830{
833
834 /* Check for V8086 or user-mode trap */
835 if ((TrapFrame->EFlags & EFLAGS_V86_MASK) || (KiUserTrap(TrapFrame)))
836 {
837 /* Get the thread */
839 while (TRUE)
840 {
841 /* Turn off the alerted state for kernel mode */
842 Thread->Alerted[KernelMode] = FALSE;
843
844 /* Are there pending user APCs? */
845 if (!Thread->ApcState.UserApcPending) break;
846
847 /* Raise to APC level and enable interrupts */
849 _enable();
850
851 /* Deliver APCs */
852 KiDeliverApc(UserMode, NULL, TrapFrame);
853
854 /* Restore IRQL and disable interrupts once again */
856 _disable();
857 }
858 }
859}
860
861//
862// Switches from boot loader to initial kernel stack
863//
864CODE_SEG("INIT")
867VOID
869{
871
872 /* We have to switch to a new stack before continuing kernel initialization */
873#ifdef __GNUC__
874 __asm__
875 (
876 "movl %0, %%esp\n\t"
877 "subl %1, %%esp\n\t"
878 "pushl %2\n\t"
879 "jmp _KiSystemStartupBootStack@0"
880 :
881 : "c"(InitialStack),
883 "i"(CR0_EM | CR0_TS | CR0_MP),
885 : "%esp"
886 );
887#elif defined(_MSC_VER)
888 __asm
889 {
890 mov esp, InitialStack
894 }
895#else
896#error Unknown Compiler
897#endif
898
900}
901
902//
903// Emits the iret instruction for C code
904//
907VOID
909{
910#if defined(__GNUC__)
911 __asm__ __volatile__
912 (
913 "iret"
914 );
915#elif defined(_MSC_VER)
916 __asm
917 {
918 iretd
919 }
920#else
921#error Unsupported compiler
922#endif
924}
925
926//
927// Normally this is done by the HAL, but on x86 as an optimization, the kernel
928// initiates the end by calling back into the HAL and exiting the trap here.
929//
931VOID
933 IN PKTRAP_FRAME TrapFrame)
934{
935 /* Disable interrupts and end the interrupt */
936 _disable();
937 HalEndSystemInterrupt(Irql, TrapFrame);
938
939 /* Exit the interrupt */
940 KiEoiHelper(TrapFrame);
941}
942
943//
944// PERF Code
945//
947VOID
949{
952 DbgPrint("Boot took %I64u cycles!\n", BootCyclesEnd - BootCycles);
953 DbgPrint("Interrupts: %u System Calls: %u Context Switches: %u\n",
954 KeGetCurrentPrcb()->InterruptCount,
955 KeGetCurrentPrcb()->KeSystemCalls,
957}
958
960PULONG
962{
963 return &(KeGetCurrentThread()->TrapFrame->HardwareEsp);
964}
965
966#ifdef __cplusplus
967} // extern "C"
968#endif
969
970#endif
#define CODE_SEG(...)
unsigned char BOOLEAN
#define EFLAGS_INTERRUPT_MASK
Definition: SystemCall.c:11
#define __cdecl
Definition: accygwin.h:79
UINT32 void void ** ReturnValue
Definition: acevents.h:216
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn UINT32 *TableIdx UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER Handler
Definition: acpixf.h:672
DECLSPEC_NORETURN VOID NTAPI KiSystemStartupBootStack(VOID)
Definition: krnlinit.c:142
#define MM_HIGHEST_USER_ADDRESS
Definition: armddk.h:17
LONG NTSTATUS
Definition: precomp.h:26
_Out_ PKIRQL Irql
Definition: csq.h:179
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define ULONG_PTR
Definition: config.h:101
#define PtrToUlong(u)
Definition: config.h:107
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define APC_LEVEL
Definition: env_spec_w32.h:695
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
VOID NTAPI HalEndSystemInterrupt(IN KIRQL OldIrql, IN PKTRAP_FRAME TrapFrame)
Definition: pic.c:335
VOID FASTCALL KfLowerIrql(IN KIRQL NewIrql)
Definition: pic.c:232
KIRQL FASTCALL KfRaiseIrql(IN KIRQL NewIrql)
Definition: pic.c:187
#define DbgPrint
Definition: hal.h:12
#define KeGetCurrentThread
Definition: hal.h:55
_In_ ULONG Mode
Definition: hubbusif.h:303
void __cdecl _disable(void)
Definition: intrin_arm.h:365
void __cdecl _enable(void)
Definition: intrin_arm.h:373
PPC_QUAL void __wbinvd(void)
Definition: intrin_ppc.h:759
PPC_QUAL unsigned long long __rdtsc(void)
Definition: intrin_ppc.h:688
__INTRIN_INLINE unsigned long __readcr3(void)
Definition: intrin_x86.h:1818
__INTRIN_INLINE uintptr_t __readeflags(void)
Definition: intrin_x86.h:1674
__INTRIN_INLINE void __invlpg(void *Address)
Definition: intrin_x86.h:1968
__INTRIN_INLINE void __writecr3(unsigned int Data)
Definition: intrin_x86.h:1794
#define C_ASSERT(e)
Definition: intsafe.h:73
#define ASSERT(a)
Definition: mode.c:44
#define _In_
Definition: ms_sal.h:308
#define KernelMode
Definition: asm.h:34
#define CR0_MP
Definition: asm.h:246
#define CR0_EM
Definition: asm.h:247
#define UserMode
Definition: asm.h:35
#define KTRAP_FRAME_LENGTH
Definition: asm.h:126
#define MAXIMUM_IDTVECTOR
Definition: asm.h:280
#define KTRAP_FRAME_ALIGN
Definition: asm.h:125
#define CR0_TS
Definition: asm.h:248
#define EFLAGS_USER_SANITIZE
Definition: ketypes.h:198
#define EFLAGS_V86_MASK
Definition: ketypes.h:193
FORCEINLINE struct _KPRCB * KeGetCurrentPrcb(VOID)
Definition: ketypes.h:1146
struct _KIPCR * PKIPCR
#define RPL_MASK
Definition: ketypes.h:130
#define HalVectorToIDTEntry
Definition: halfuncs.h:51
#define NPX_FRAME_LENGTH
Definition: asm.h:247
#define KGDT_R3_TEB
Definition: ketypes.h:129
#define KeGetPcr()
Definition: ketypes.h:81
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
Definition: mmfuncs.h:404
#define FASTCALL
Definition: nt_native.h:50
#define UNREACHABLE
#define DECLSPEC_NORETURN
Definition: ntbasedef.h:176
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
FORCEINLINE ULONG_PTR KeGetTrapFrameFrameRegister(PKTRAP_FRAME TrapFrame)
Definition: ke.h:200
DECLSPEC_NORETURN VOID KiSwitchToBootStack(IN ULONG_PTR InitialStack)
Definition: ke.h:868
ULONG KeI386NpxPresent
Definition: cpu.c:27
#define KeGetContextSwitches(Prcb)
Definition: ke.h:216
FORCEINLINE ULONG_PTR KeGetContextFrameRegister(PCONTEXT Context)
Definition: ke.h:165
ULONG KeI386XMMIPresent
Definition: cpu.c:32
FORCEINLINE VOID KeInvalidateTlbEntry(IN PVOID Address)
Definition: ke.h:264
FORCEINLINE VOID KeFlushProcessTb(VOID)
Definition: ke.h:272
FORCEINLINE VOID KeSetContextFrameRegister(PCONTEXT Context, ULONG_PTR Frame)
Definition: ke.h:172
FORCEINLINE ULONG_PTR KeGetTrapFrameStackRegister(PKTRAP_FRAME TrapFrame)
Definition: ke.h:193
VOID KiGetCacheInformation(VOID)
Definition: cpu.c:418
FORCEINLINE BOOLEAN KeDisableInterrupts(VOID)
Definition: ke.h:239
ULONG64 KiGetFeatureBits(VOID)
Evaluates the KeFeatureFlag bits for the current CPU.
Definition: cpu.c:165
FORCEINLINE PVOID KeQueryInterruptHandler(IN ULONG Vector)
Definition: ke.h:327
FORCEINLINE VOID KeRestoreInterrupts(BOOLEAN WereEnabled)
Definition: ke.h:254
ULONG KeI386CpuType
Definition: cpu.c:24
VOID KiSetProcessorType(VOID)
Definition: cpu.c:99
FORCEINLINE VOID KiRundownThread(IN PKTHREAD Thread)
Definition: ke.h:293
ULONG KeI386FxsrPresent
Definition: cpu.c:33
FORCEINLINE BOOLEAN KiUserTrap(IN PKTRAP_FRAME TrapFrame)
Definition: ke.h:364
FORCEINLINE VOID KeSweepICache(IN PVOID BaseAddress, IN SIZE_T FlushSize)
Definition: ke.h:280
FORCEINLINE VOID KeRegisterInterruptHandler(IN ULONG Vector, IN PVOID Handler)
Definition: ke.h:301
FORCEINLINE PULONG_PTR KiGetUserModeStackAddress(void)
Definition: ke.h:466
ULONG KeI386CpuStep
Definition: cpu.c:25
#define KeSetContextReturnRegister(Context, ReturnValue)
Definition: ke.h:43
#define Ki386PerfEnd()
Definition: ke.h:174
#define KiGetLinkedTrapFrame(x)
Definition: ke.h:177
#define KeSetContextPc(Context, ProgramCounter)
Definition: ke.h:34
#define KeGetContextPc(Context)
Definition: ke.h:31
#define KeGetContextReturnRegister(Context)
Definition: ke.h:40
#define KeGetTrapFramePc(TrapFrame)
Definition: ke.h:37
#define KiEndInterrupt(x, y)
Definition: ke.h:175
struct _LARGE_IDENTITY_MAP LARGE_IDENTITY_MAP
BOOLEAN NTAPI VdmDispatchPageFault(_In_ PKTRAP_FRAME TrapFrame)
Definition: vdmexec.c:367
PVOID Ki386IopmSaveArea
Definition: v86vdm.c:23
BOOLEAN NTAPI VdmDispatchBop(IN PKTRAP_FRAME TrapFrame)
Definition: vdmexec.c:313
FORCEINLINE ULONG Ke386SanitizeFlags(IN ULONG Eflags, IN KPROCESSOR_MODE Mode)
Definition: ke.h:740
FORCEINLINE DECLSPEC_NORETURN VOID KiDispatchException2Args(IN NTSTATUS Code, IN ULONG_PTR Address, IN ULONG P1, IN ULONG P2, IN PKTRAP_FRAME TrapFrame)
Definition: ke.h:804
VOID NTAPI KiInitializePAT(VOID)
Definition: patpge.c:61
VOID NTAPI ExpInterlockedPopEntrySListResume(VOID)
BOOLEAN FASTCALL KiVdmOpcodePrefix(IN PKTRAP_FRAME TrapFrame, IN ULONG Flags)
Definition: v86vdm.c:442
DECLSPEC_NORETURN VOID NTAPI KiDispatchExceptionFromTrapFrame(IN NTSTATUS Code, IN ULONG Flags, IN ULONG_PTR Address, IN ULONG ParameterCount, IN ULONG_PTR Parameter1, IN ULONG_PTR Parameter2, IN ULONG_PTR Parameter3, IN PKTRAP_FRAME TrapFrame)
Definition: exp.c:1055
VOID FASTCALL Ki386InitializeTss(IN PKTSS Tss, IN PKIDTENTRY Idt, IN PKGDTENTRY Gdt)
Definition: cpu.c:819
BOOLEAN FASTCALL Ki386HandleOpcodeV86(IN PKTRAP_FRAME TrapFrame)
Definition: v86vdm.c:456
ULONG_PTR NTAPI Ki386EnableTargetLargePage(IN ULONG_PTR Context)
Definition: patpge.c:70
VOID NTAPI KiFlushNPXState(IN FLOATING_SAVE_AREA *SaveArea)
ULONG KiFastSystemCallDisable
Definition: cpu.c:28
struct _KV86_FRAME KV86_FRAME
VOID __cdecl KiTrap13(VOID)
UCHAR KiDebugRegisterContextOffsets[9]
VOID __cdecl KiTrap02(VOID)
UCHAR KiDebugRegisterTrapOffsets[9]
VOID __cdecl KiTrap08(VOID)
struct _KV8086_STACK_FRAME KV8086_STACK_FRAME
union _KTRAP_EXIT_SKIP_BITS * PKTRAP_EXIT_SKIP_BITS
BOOLEAN KeI386VirtualIntExtensions
Definition: v86vdm.c:24
struct _LARGE_IDENTITY_MAP * PLARGE_IDENTITY_MAP
ULONG KeI386EFlagsAndMaskV86
Definition: v86vdm.c:21
struct _FLOATING_SAVE_CONTEXT * PFLOATING_SAVE_CONTEXT
NTSTATUS NTAPI Ke386GetGdtEntryThread(IN PKTHREAD Thread, IN ULONG Offset, IN PKGDTENTRY Descriptor)
Definition: ldt.c:26
DECLSPEC_NORETURN VOID FASTCALL KiEoiHelper(IN PKTRAP_FRAME TrapFrame)
Definition: traphdlr.c:126
union _KTRAP_EXIT_SKIP_BITS KTRAP_EXIT_SKIP_BITS
VOID __cdecl KiFastCallEntry(VOID)
VOID NTAPI KiI386PentiumLockErrataFixup(VOID)
Definition: cpu.c:1108
BOOLEAN NTAPI KiIsNpxErrataPresent(VOID)
Definition: cpu.c:1179
CHAR KiSystemCallExitBranch[]
struct _KV86_FRAME * PKV86_FRAME
ULONG_PTR NTAPI Ki386EnableXMMIExceptions(IN ULONG_PTR Context)
Definition: cpu.c:1085
VOID NTAPI KiAmdK6InitializeMTRR(VOID)
Definition: mtrr.c:31
ULONG_PTR NTAPI Ki386EnableFxsr(IN ULONG_PTR Context)
Definition: cpu.c:1075
VOID __cdecl ReadBatch(VOID)
BOOLEAN NTAPI Ki386CreateIdentityMap(IN PLARGE_IDENTITY_MAP IdentityMap, IN PVOID StartPtr, IN ULONG Length)
FORCEINLINE DECLSPEC_NORETURN VOID KiDispatchException0Args(IN NTSTATUS Code, IN ULONG_PTR Address, IN PKTRAP_FRAME TrapFrame)
Definition: ke.h:775
ULONG KeI386EFlagsOrMaskV86
Definition: v86vdm.c:22
CHAR KiSystemCallExit[]
VOID NTAPI Ki386EnableCurrentLargePage(IN ULONG_PTR StartAddress, IN ULONG Cr3)
VOID NTAPI KiRestoreFastSyscallReturnState(VOID)
Definition: cpu.c:1031
FORCEINLINE VOID KiSetTebBase(PKPCR Pcr, PNT_TIB TebAddress)
Definition: ke.h:424
BOOLEAN KiI386PentiumLockErrataPresent
Definition: cpu.c:42
VOID __cdecl CopyParams(VOID)
ULONG_PTR NTAPI Ki386EnableGlobalPage(IN ULONG_PTR Context)
Definition: patpge.c:23
VOID NTAPI Ki386FreeIdentityMap(IN PLARGE_IDENTITY_MAP IdentityMap)
ULONG KiMXCsrMask
Definition: cpu.c:30
VOID NTAPI KiInitializeMTRR(IN BOOLEAN FinalCpu)
Definition: mtrr.c:22
NTSTATUS NTAPI KiSystemCallTrampoline(_In_ PVOID Handler, _In_ PVOID Arguments, _In_ ULONG StackBytes)
VOID NTAPI KiSetCR0Bits(VOID)
Definition: cpu.c:748
VOID NTAPI Ki386SetupAndExitToV86Mode(OUT PTEB VdmTeb)
FORCEINLINE DECLSPEC_NORETURN VOID KiDispatchException1Args(IN NTSTATUS Code, IN ULONG_PTR Address, IN ULONG P1, IN PKTRAP_FRAME TrapFrame)
Definition: ke.h:789
KIDTENTRY KiIdt[MAXIMUM_IDTVECTOR+1]
Definition: except.c:50
VOID NTAPI Ki386AdjustEsp0(IN PKTRAP_FRAME TrapFrame)
Definition: exp.c:280
FORCEINLINE PFX_SAVE_AREA KiGetThreadNpxArea(IN PKTHREAD Thread)
Definition: ke.h:712
VOID NTAPI KiInitializePcr(IN ULONG ProcessorNumber, IN PKIPCR Pcr, IN PKIDTENTRY Idt, IN PKGDTENTRY Gdt, IN PKTSS Tss, IN PKTHREAD IdleThread, IN PVOID DpcStack)
Definition: kiinit.c:284
FORCEINLINE PVOID Ke386SanitizeDr(IN PVOID DrAddress, IN KPROCESSOR_MODE Mode)
Definition: ke.h:757
ULONG_PTR FASTCALL KiExitV86Mode(IN PKTRAP_FRAME TrapFrame)
Definition: v86vdm.c:468
NTSTATUS NTAPI KiConvertToGuiThread(VOID)
struct _FLOATING_SAVE_CONTEXT FLOATING_SAVE_CONTEXT
FORCEINLINE DECLSPEC_NORETURN VOID KiIret(VOID)
Definition: ke.h:908
struct _KV8086_STACK_FRAME * PKV8086_STACK_FRAME
FORCEINLINE VOID Ke386SetGdtEntryBase(PKGDTENTRY GdtEntry, PVOID BaseAddress)
Definition: ke.h:415
CHAR KiSystemCallExit2[]
BOOLEAN NTAPI KiIsNpxPresent(VOID)
VOID FASTCALL Ki386BiosCallReturnAddress(IN PKTRAP_FRAME TrapFrame)
KDESCRIPTOR KiIdtDescriptor
Definition: except.c:51
ULONG_PTR NTAPI Ki386EnableDE(IN ULONG_PTR Context)
Definition: cpu.c:1065
FORCEINLINE ULONG Ke386SanitizeSeg(IN ULONG Cs, IN KPROCESSOR_MODE Mode)
Definition: ke.h:723
VOID NTAPI KeI386VdmInitialize(VOID)
Definition: vdmmain.c:42
FORCEINLINE VOID KiCheckForApcDelivery(IN PKTRAP_FRAME TrapFrame)
Definition: ke.h:829
VOID NTAPI ExpInterlockedPopEntrySListFault(VOID)
VOID NTAPI KiThreadStartup(VOID)
Definition: thrdini.c:63
ULONGLONG BootCyclesEnd
Definition: ke.h:152
ULONGLONG BootCycles
Definition: kiinit.c:37
VOID NTAPI KiDeliverApc(IN KPROCESSOR_MODE DeliveryMode, IN PKEXCEPTION_FRAME ExceptionFrame, IN PKTRAP_FRAME TrapFrame)
Definition: apc.c:302
unsigned short USHORT
Definition: pedump.c:61
static WCHAR Address[46]
Definition: ping.c:68
__asm__(".p2align 4, 0x90\n" ".seh_proc __seh2_global_filter_func\n" "__seh2_global_filter_func:\n" "\tpush %rbp\n" "\t.seh_pushreg %rbp\n" "\tsub $32, %rsp\n" "\t.seh_stackalloc 32\n" "\t.seh_endprologue\n" "\tmov %rdx, %rbp\n" "\tjmp *%rax\n" "__seh2_global_filter_func_exit:\n" "\t.p2align 4\n" "\tadd $32, %rsp\n" "\tpop %rbp\n" "\tret\n" "\t.seh_endproc")
static void push(calc_node_t *op)
Definition: rpn_ieee.c:113
base of all file and directory entries
Definition: entries.h:83
PKTHREAD CurrentThread
Definition: ke.h:267
PFX_SAVE_AREA PfxSaveArea
Definition: ke.h:270
PFX_SAVE_AREA Buffer
Definition: ke.h:269
KIRQL OldNpxIrql
Definition: ke.h:268
USHORT Offset
Definition: ketypes.h:440
USHORT ExtendedOffset
Definition: ketypes.h:443
PKIDTENTRY IDT
Definition: ketypes.h:812
Definition: ke.h:294
NT_TIB NtTib
Definition: ke.h:297
PUSHORT GDT
Definition: ke.h:54
ULONG TempEsp
Definition: ketypes.h:300
ULONG Ebp
Definition: ketypes.h:319
ULONG PreviousPreviousMode
Definition: ketypes.h:313
ULONG HardwareEsp
Definition: ketypes.h:324
ULONG Eip
Definition: ketypes.h:321
ULONG Edx
Definition: ketypes.h:310
Definition: ketypes.h:844
KTRAP_FRAME TrapFrame
Definition: ke.h:245
KV86_FRAME V86Frame
Definition: ke.h:247
FX_SAVE_AREA NpxArea
Definition: ke.h:246
PVOID ThreadTeb
Definition: ke.h:236
PVOID PcrTeb
Definition: ke.h:237
PVOID ThreadStack
Definition: ke.h:235
ULONG_PTR StartAddress
Definition: ke.h:257
PVOID PagesList[30]
Definition: ke.h:259
PHARDWARE_PTE TopLevelDirectory
Definition: ke.h:255
ULONG PagesCount
Definition: ke.h:258
struct _NT_TIB * Self
Definition: compat.h:720
Definition: compat.h:836
uint32_t * PULONG
Definition: typedefs.h:59
#define NTAPI
Definition: typedefs.h:36
ULONG_PTR SIZE_T
Definition: typedefs.h:80
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
uint64_t ULONGLONG
Definition: typedefs.h:67
#define OUT
Definition: typedefs.h:40
UCHAR SkipSegments
Definition: ke.h:168
UCHAR SkipPreviousMode
Definition: ke.h:167
UCHAR Reserved
Definition: ke.h:170
UCHAR SkipVolatiles
Definition: ke.h:169
_In_ UCHAR _In_ UCHAR _In_ ULONG Code
Definition: wdfdevice.h:1701
_Must_inspect_result_ _In_ WDFIORESLIST _In_ PIO_RESOURCE_DESCRIPTOR Descriptor
Definition: wdfresource.h:342
#define FORCEINLINE
Definition: wdftypes.h:67
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:778
CCHAR KPROCESSOR_MODE
Definition: ketypes.h:7
unsigned char UCHAR
Definition: xmlstorage.h:181
char CHAR
Definition: xmlstorage.h:175