16#define REQUIRED_FEATURE_BITS (KF_RDTSC|KF_CR4|KF_CMPXCHG8B|KF_XMMI|KF_XMMI64| \
17 KF_LARGE_PAGE|KF_FAST_SYSCALL|KF_GLOBAL_PAGE| \
18 KF_CMOV|KF_PAT|KF_MMX|KF_FXSR|KF_NX_BIT|KF_MTRR)
54 DPRINT(
"Large Page support detected but not yet taken advantage of!\n");
61 DPRINT(
"Global Page support detected but not yet taken advantage of!\n");
68 DPRINT(
"MTRR support detected but not yet taken advantage of!\n");
75 DPRINT(
"PAT support detected but not yet taken advantage of!\n");
105 Pcr->Self = (
PKPCR)Pcr;
106 Pcr->CurrentPrcb = &Pcr->Prcb;
117 Pcr->Prcb.BuildType = 0;
126 Pcr->Prcb.Number = (
UCHAR)ProcessorNumber;
127 Pcr->Prcb.SetMember = 1ULL << ProcessorNumber;
130 Pcr->GdtBase = GdtBase;
131 Pcr->IdtBase = IdtBase;
134 Pcr->TssBase = TssBase;
136 Pcr->Prcb.RspBase = Pcr->TssBase->Rsp0;
139 Pcr->Prcb.DpcStack = DpcStack;
142 Pcr->Prcb.MultiThreadProcessorSet = Pcr->Prcb.SetMember;
145 Pcr->Prcb.ProcessorState.SpecialRegisters.KernelDr6 = 0;
146 Pcr->Prcb.ProcessorState.SpecialRegisters.KernelDr7 = 0;
152 Pcr->Prcb.CurrentThread = IdleThread;
182 FrLdrDbgPrint(
"CPU doesn't have needed features! Has: 0x%x, required: 0x%x\n",
193 Pcr->
Prcb.FeatureBitsHigh = FeatureBits >> 32;
258 Tss->IoMapBase = 0x68;
261 Tss->Rsp0 = (
ULONG64)InitialStack;
264 Tss->Ist[1] = (
ULONG64)DoubleFaultStack;
267 Tss->Ist[2] = (
ULONG64)DoubleFaultStack;
270 Tss->Ist[3] = (
ULONG64)NmiStack;
311 KDESCRIPTOR GdtDescriptor = {{0},0,0}, IdtDescriptor = {{0},0,0};
322 __sgdt(&GdtDescriptor.
Limit);
323 __sidt(&IdtDescriptor.Limit);
359 FeatureBits = Prcb->FeatureBits | (
ULONG64)Prcb->FeatureBitsHigh << 32;
438 KiReportCpuFeatures(Prcb);
455 for (
Entry = LoaderBlock->LoadOrderListHead.Flink,
i = 0;
456 Entry != &LoaderBlock->LoadOrderListHead &&
i < 3;
510 LoaderBlock->KernelStack &= ~(16 - 1);
513 InitialStack = LoaderBlock->KernelStack;
514 InitialThread = (
PKTHREAD)LoaderBlock->Thread;
517 InitialThread->
ApcState.Process = (
PVOID)LoaderBlock->Process;
538 DPRINT1(
"Pcr = %p, Gdt = %p, Idt = %p, Tss = %p\n",
char * strstr(char *String1, char *String2)
FORCEINLINE PKGDTENTRY64 KiGetGdtEntry(PVOID pGdt, USHORT Selector)
FORCEINLINE PVOID KiGetGdtDescriptorBase(PKGDTENTRY Entry)
FORCEINLINE VOID KiInitGdtEntry(PKGDTENTRY64 Entry, ULONG64 Base, ULONG Size, UCHAR Type, UCHAR Dpl)
void KiInitializeSegments()
static VOID KiInitializePcr(_Out_ PKIPCR Pcr, _In_ ULONG ProcessorNumber, _In_ PKGDTENTRY64 GdtBase, _In_ PKIDTENTRY64 IdtBase, _In_ PKTSS64 TssBase, _In_ PKTHREAD IdleThread, _In_ PVOID DpcStack)
void KiSystemCallEntry32()
ULONG(* FrLdrDbgPrint)(const char *Format,...)
DECLSPEC_NORETURN VOID NTAPI KiSystemStartup(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
static VOID KiInitializeP0BootStructures(_Inout_ PLOADER_PARAMETER_BLOCK LoaderBlock)
KSPIN_LOCK KiFreezeExecutionLock
PVOID KiP0DoubleFaultStack
static LDR_DATA_TABLE_ENTRY LdrCoreEntries[3]
void KiInitModuleList(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
VOID NTAPI KiInitMachineDependent(VOID)
VOID NTAPI KiInitializeKernelMachineDependent(IN PKPRCB Prcb, IN PLOADER_PARAMETER_BLOCK LoaderBlock)
void KiSystemCallEntry64()
static VOID KiInitializeTss(_In_ PKIPCR Pcr, _Out_ PKTSS64 Tss, _In_ PVOID InitialStack, _In_ PVOID DoubleFaultStack, _In_ PVOID NmiStack)
#define REQUIRED_FEATURE_BITS
VOID NTAPI KiInitializeCpu(PKIPCR Pcr)
VOID KiInitializeProcessorBootStructures(_In_ ULONG ProcessorNumber, _Out_ PKIPCR Pcr, _In_ PKGDTENTRY64 GdtBase, _In_ PKIDTENTRY64 IdtBase, _In_ PKTSS64 TssBase, _In_ PKTHREAD IdleThread, _In_ PVOID KernelStack, _In_ PVOID DpcStack, _In_ PVOID DoubleFaultStack, _In_ PVOID NmiStack)
DECLSPEC_NORETURN VOID NTAPI KeBugCheck(ULONG BugCheckCode)
#define InsertTailList(ListHead, Entry)
#define InitializeListHead(ListHead)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
KIRQL FASTCALL KfRaiseIrql(IN KIRQL NewIrql)
VOID NTAPI HalInitializeProcessor(IN ULONG ProcessorNumber, IN PLOADER_PARAMETER_BLOCK LoaderBlock)
PPC_QUAL void __writemsr(const unsigned long Value)
PPC_QUAL unsigned long long __readmsr()
PPC_QUAL unsigned long long __rdtsc(void)
__INTRIN_INLINE unsigned long __readcr4(void)
__INTRIN_INLINE unsigned long __readcr0(void)
__INTRIN_INLINE void __writecr0(unsigned int Data)
__INTRIN_INLINE void __sidt(void *Destination)
__INTRIN_INLINE void __writecr4(unsigned int Data)
BOOLEAN NTAPI KdInitSystem(_In_ ULONG BootPhase, _In_opt_ PLOADER_PARAMETER_BLOCK LoaderBlock)
BOOLEAN NTAPI KdPollBreakIn(VOID)
PLOADER_PARAMETER_BLOCK KeLoaderBlock
VOID KeSetCurrentIrql(KIRQL NewIrql)
#define PRCB_MINOR_VERSION
#define EFLAGS_NESTED_TASK
#define KF_VIRT_FIRMWARE_ENABLED
#define PRCB_MAJOR_VERSION
#define PRCB_BUILD_UNIPROCESSOR
#define DBG_STATUS_CONTROL_C
#define PROCESSOR_ARCHITECTURE_AMD64
struct _KTHREAD * PKTHREAD
#define DECLSPEC_ALIGN(x)
#define DECLSPEC_NORETURN
DECLSPEC_NORETURN VOID KiSwitchToBootStack(IN ULONG_PTR InitialStack)
ULONG64 KiGetFeatureBits(VOID)
Evaluates the KeFeatureFlag bits for the current CPU.
VOID KiSetProcessorType(VOID)
EPROCESS KiInitialProcess
PKPRCB KiProcessorBlock[]
KAFFINITY KeActiveProcessors
VOID NTAPI KeInitExceptions(VOID)
USHORT KeProcessorRevision
USHORT KeProcessorArchitecture
LIST_ENTRY PsLoadedModuleList
#define KERNEL_STACK_SIZE
#define PCR_MINOR_VERSION
#define PCR_MAJOR_VERSION
base of all file and directory entries
union _KGDTENTRY64 * GdtBase
union _KIDTENTRY64 * IdtBase
#define RtlZeroMemory(Destination, Length)
#define CONTAINING_RECORD(address, type, field)
__analysis_noreturn NTSYSAPI VOID NTAPI DbgBreakPointWithStatus(_In_ ULONG Status)
#define PF_RDWRFSGSBASE_AVAILABLE
#define PF_CHANNELS_ENABLED
#define PF_SECOND_LEVEL_ADDRESS_TRANSLATION
#define NX_SUPPORT_POLICY_ALWAYSOFF
#define PF_3DNOW_INSTRUCTIONS_AVAILABLE
#define PF_RDPID_INSTRUCTION_AVAILABLE
#define PF_SSE4_2_INSTRUCTIONS_AVAILABLE
#define PF_MMX_INSTRUCTIONS_AVAILABLE
#define PF_XMMI64_INSTRUCTIONS_AVAILABLE
#define PF_VIRT_FIRMWARE_ENABLED
#define PF_XMMI_INSTRUCTIONS_AVAILABLE
#define NX_SUPPORT_POLICY_OPTIN
#define PF_AVX2_INSTRUCTIONS_AVAILABLE
#define PF_SSSE3_INSTRUCTIONS_AVAILABLE
#define NX_SUPPORT_POLICY_OPTOUT
#define NX_SUPPORT_POLICY_ALWAYSON
#define PF_FLOATING_POINT_PRECISION_ERRATA
#define PF_AVX_INSTRUCTIONS_AVAILABLE
#define PF_COMPARE_EXCHANGE_DOUBLE
#define PF_FASTFAIL_AVAILABLE
#define PF_FLOATING_POINT_EMULATED
#define PF_SSE3_INSTRUCTIONS_AVAILABLE
#define PF_SSE_DAZ_MODE_AVAILABLE
#define PF_AVX512F_INSTRUCTIONS_AVAILABLE
#define PF_RDRAND_INSTRUCTION_AVAILABLE
#define PF_RDTSC_INSTRUCTION_AVAILABLE
#define PF_COMPARE64_EXCHANGE128
#define PF_COMPARE_EXCHANGE128
#define PF_SSE4_1_INSTRUCTIONS_AVAILABLE
#define PF_RDTSCP_INSTRUCTION_AVAILABLE
void _mm_setcsr(unsigned int a)