ReactOS  0.4.15-dev-2721-g5912c11
ke.h File Reference
#include "intrin_i.h"
#include <pshpack1.h>
#include <poppack.h>
Include dependency graph for ke.h:

Go to the source code of this file.

Classes

struct  _KIDT_INIT
 
struct  _KI_INTERRUPT_DISPATCH_ENTRY
 

Macros

#define X86_EFLAGS_TF   0x00000100 /* Trap flag */
 
#define X86_EFLAGS_IF   0x00000200 /* Interrupt Enable flag */
 
#define X86_EFLAGS_IOPL   0x00003000 /* I/O Privilege Level bits */
 
#define X86_EFLAGS_NT   0x00004000 /* Nested Task flag */
 
#define X86_EFLAGS_RF   0x00010000 /* Resume flag */
 
#define X86_EFLAGS_VM   0x00020000 /* Virtual Mode */
 
#define X86_EFLAGS_ID   0x00200000 /* CPUID detection flag */
 
#define X86_CR0_PE   0x00000001 /* enable Protected Mode */
 
#define X86_CR0_NE   0x00000020 /* enable native FPU error reporting */
 
#define X86_CR0_TS   0x00000008 /* enable exception on FPU instruction for task switch */
 
#define X86_CR0_EM   0x00000004 /* enable FPU emulation (disable FPU) */
 
#define X86_CR0_MP   0x00000002 /* enable FPU monitoring */
 
#define X86_CR0_WP   0x00010000 /* enable Write Protect (copy on write) */
 
#define X86_CR0_PG   0x80000000 /* enable Paging */
 
#define X86_CR4_PAE   0x00000020 /* enable physical address extensions */
 
#define X86_CR4_PGE   0x00000080 /* enable global pages */
 
#define X86_CR4_OSFXSR   0x00000200 /* enable FXSAVE/FXRSTOR instructions */
 
#define X86_CR4_OSXMMEXCPT   0x00000400 /* enable #XF exception */
 
#define X86_FEATURE_FPU   0x00000001 /* x87 FPU is present */
 
#define X86_FEATURE_VME   0x00000002 /* Virtual 8086 Extensions are present */
 
#define X86_FEATURE_DBG   0x00000004 /* Debugging extensions are present */
 
#define X86_FEATURE_PSE   0x00000008 /* Page Size Extension is present */
 
#define X86_FEATURE_TSC   0x00000010 /* time stamp counters are present */
 
#define X86_FEATURE_PAE   0x00000040 /* physical address extension is present */
 
#define X86_FEATURE_CX8   0x00000100 /* CMPXCHG8B instruction present */
 
#define X86_FEATURE_SYSCALL   0x00000800 /* SYSCALL/SYSRET support present */
 
#define X86_FEATURE_MTTR   0x00001000 /* Memory type range registers are present */
 
#define X86_FEATURE_PGE   0x00002000 /* Page Global Enable */
 
#define X86_FEATURE_CMOV   0x00008000 /* "Conditional move" instruction supported */
 
#define X86_FEATURE_PAT   0x00010000 /* Page Attribute Table is supported */
 
#define X86_FEATURE_DS   0x00200000 /* Debug Store is present */
 
#define X86_FEATURE_MMX   0x00800000 /* MMX extension present */
 
#define X86_FEATURE_FXSR   0x01000000 /* FXSAVE/FXRSTOR instructions present */
 
#define X86_FEATURE_SSE   0x02000000 /* SSE extension present */
 
#define X86_FEATURE_SSE2   0x04000000 /* SSE2 extension present */
 
#define X86_FEATURE_HT   0x10000000 /* Hyper-Threading present */
 
#define X86_FEATURE_SSE3   0x00000001 /* SSE3 is supported */
 
#define X86_FEATURE_MONITOR   0x00000008 /* SSE3 Monitor instructions supported */
 
#define X86_FEATURE_VMX   0x00000020 /* Virtual Machine eXtensions are available */
 
#define X86_FEATURE_SSSE3   0x00000200 /* Supplemental SSE3 are available */
 
#define X86_FEATURE_FMA3   0x00001000 /* Fused multiple-add supported */
 
#define X86_FEATURE_CX16   0x00002000 /* CMPXCHG16B instruction are available */
 
#define X86_FEATURE_PCID   0x00020000 /* Process Context IDentifiers are supported */
 
#define X86_FEATURE_SSE41   0x00080000 /* SSE 4.1 is supported */
 
#define X86_FEATURE_SSE42   0x00100000 /* SSE 4.2 is supported */
 
#define X86_FEATURE_POPCNT   0x00800000 /* POPCNT instruction is available */
 
#define X86_FEATURE_XSAVE   0x04000000 /* XSAVE family are available */
 
#define X86_FEATURE_NX   0x00100000 /* NX support present */
 
#define X86_EXT_FEATURE_SSE3   0x00000001 /* SSE3 extension present */
 
#define X86_EXT_FEATURE_3DNOW   0x40000000 /* 3DNOW! extension present */
 
#define FRAME_EDITED   0xFFF8
 
#define X86_MSR_GSBASE   0xC0000101
 
#define X86_MSR_KERNEL_GSBASE   0xC0000102
 
#define X86_MSR_EFER   0xC0000080
 
#define X86_MSR_STAR   0xC0000081
 
#define X86_MSR_LSTAR   0xC0000082
 
#define X86_MSR_CSTAR   0xC0000083
 
#define X86_MSR_SFMASK   0xC0000084
 
#define EFER_SCE   0x0001
 
#define EFER_LME   0x0100
 
#define EFER_LMA   0x0400
 
#define EFER_NXE   0x0800
 
#define EFER_SVME   0x1000
 
#define EFER_FFXSR   0x4000
 
#define AMD64_TSS   9
 
#define APIC_EOI_REGISTER   0xFFFFFFFFFFFE00B0ULL
 
#define KD_BREAKPOINT_TYPE   UCHAR
 
#define KD_BREAKPOINT_SIZE   sizeof(UCHAR)
 
#define KD_BREAKPOINT_VALUE   0xCC
 
#define KeGetTrapFrame(Thread)
 
#define KeGetContextSwitches(Prcb)   (Prcb->KeContextSwitches)
 
#define KiGetSecondLevelDCacheSize()   ((PKIPCR)KeGetPcr())->SecondLevelCacheSize
 
#define KeGetExceptionFrame(Thread)
 
#define KeGetTrapFrameInterruptState(TrapFrame)   BooleanFlagOn((TrapFrame)->EFlags, EFLAGS_INTERRUPT_MASK)
 
#define Ki386PerfEnd()
 
#define KeArchInitThreadWithContext(Thread, SystemRoutine, StartRoutine, StartContext, Context)   Ke386InitThreadWithContext(Thread,SystemRoutine,StartRoutine,StartContext,Context)
 

Typedefs

typedef struct _KIDT_INIT KIDT_INIT
 
typedef struct _KIDT_INITPKIDT_INIT
 
typedef struct _KI_INTERRUPT_DISPATCH_ENTRY KI_INTERRUPT_DISPATCH_ENTRY
 
typedef struct _KI_INTERRUPT_DISPATCH_ENTRYPKI_INTERRUPT_DISPATCH_ENTRY
 

Functions

FORCEINLINE ULONG_PTR KeGetContextPc (PCONTEXT Context)
 
FORCEINLINE VOID KeSetContextPc (PCONTEXT Context, ULONG_PTR ProgramCounter)
 
FORCEINLINE ULONG_PTR KeGetContextReturnRegister (PCONTEXT Context)
 
FORCEINLINE VOID KeSetContextReturnRegister (PCONTEXT Context, ULONG_PTR ReturnValue)
 
FORCEINLINE ULONG_PTR KeGetContextStackRegister (PCONTEXT Context)
 
FORCEINLINE ULONG_PTR KeGetContextFrameRegister (PCONTEXT Context)
 
FORCEINLINE VOID KeSetContextFrameRegister (PCONTEXT Context, ULONG_PTR Frame)
 
FORCEINLINE ULONG_PTR KeGetTrapFramePc (PKTRAP_FRAME TrapFrame)
 
FORCEINLINE PKTRAP_FRAME KiGetLinkedTrapFrame (PKTRAP_FRAME TrapFrame)
 
FORCEINLINE ULONG_PTR KeGetTrapFrameStackRegister (PKTRAP_FRAME TrapFrame)
 
FORCEINLINE ULONG_PTR KeGetTrapFrameFrameRegister (PKTRAP_FRAME TrapFrame)
 
FORCEINLINE BOOLEAN KeDisableInterrupts (VOID)
 
FORCEINLINE VOID KeRestoreInterrupts (BOOLEAN WereEnabled)
 
FORCEINLINE VOID KeInvalidateTlbEntry (IN PVOID Address)
 
FORCEINLINE VOID KeFlushProcessTb (VOID)
 
FORCEINLINE VOID KeSweepICache (IN PVOID BaseAddress, IN SIZE_T FlushSize)
 
FORCEINLINE VOID KiRundownThread (IN PKTHREAD Thread)
 
FORCEINLINE VOID KeRegisterInterruptHandler (IN ULONG Vector, IN PVOID Handler)
 
FORCEINLINE PVOID KeQueryInterruptHandler (IN ULONG Vector)
 
FORCEINLINE VOID KiSendEOI (VOID)
 
FORCEINLINE VOID KiEndInterrupt (IN KIRQL Irql, IN PKTRAP_FRAME TrapFrame)
 
FORCEINLINE BOOLEAN KiUserTrap (IN PKTRAP_FRAME TrapFrame)
 
DECLSPEC_NORETURN VOID KiSwitchToBootStack (IN ULONG_PTR InitialStack)
 
VOID KiDivideErrorFault (VOID)
 
VOID KiDebugTrapOrFault (VOID)
 
VOID KiNmiInterrupt (VOID)
 
VOID KiBreakpointTrap (VOID)
 
VOID KiOverflowTrap (VOID)
 
VOID KiBoundFault (VOID)
 
VOID KiInvalidOpcodeFault (VOID)
 
VOID KiNpxNotAvailableFault (VOID)
 
VOID KiDoubleFaultAbort (VOID)
 
VOID KiNpxSegmentOverrunAbort (VOID)
 
VOID KiInvalidTssFault (VOID)
 
VOID KiSegmentNotPresentFault (VOID)
 
VOID KiStackFault (VOID)
 
VOID KiGeneralProtectionFault (VOID)
 
VOID KiPageFault (VOID)
 
VOID KiFloatingErrorFault (VOID)
 
VOID KiAlignmentFault (VOID)
 
VOID KiMcheckAbort (VOID)
 
VOID KiXmmException (VOID)
 
VOID KiApcInterrupt (VOID)
 
VOID KiRaiseAssertion (VOID)
 
VOID KiDebugServiceTrap (VOID)
 
VOID KiDpcInterrupt (VOID)
 
VOID KiIpiInterrupt (VOID)
 
VOID KiGdtPrepareForApplicationProcessorInit (ULONG Id)
 
VOID Ki386InitializeLdt (VOID)
 
VOID Ki386SetProcessorFeatures (VOID)
 
VOID KiGetCacheInformation (VOID)
 
VOID KiSetProcessorType (VOID)
 
ULONG KiGetFeatureBits (VOID)
 
VOID KiInitializeCpuFeatures (VOID)
 
ULONG KeAllocateGdtSelector (ULONG Desc[2])
 
VOID KeFreeGdtSelector (ULONG Entry)
 
VOID NtEarlyInitVdm (VOID)
 
VOID KeApplicationProcessorInitDispatcher (VOID)
 
VOID KeCreateApplicationProcessorIdleThread (ULONG Id)
 
VOID Ke386InitThreadWithContext (PKTHREAD Thread, PKSYSTEM_ROUTINE SystemRoutine, PKSTART_ROUTINE StartRoutine, PVOID StartContext, PCONTEXT Context)
 
NTHALAPI NTSTATUS NTAPI HalAllocateAdapterChannel (IN PADAPTER_OBJECT AdapterObject, IN PWAIT_CONTEXT_BLOCK Wcb, IN ULONG NumberOfMapRegisters, IN PDRIVER_CONTROL ExecutionRoutine)
 
FORCEINLINE PULONG_PTR KiGetUserModeStackAddress (void)
 
VOID KiSetTrapContext (_Out_ PKTRAP_FRAME TrapFrame, _In_ PCONTEXT Context, _In_ KPROCESSOR_MODE RequestorMode)
 

Variables

ULONG KeI386NpxPresent
 
ULONG KeI386XMMIPresent
 
ULONG KeI386FxsrPresent
 
ULONG KeI386CpuType
 
ULONG KeI386CpuStep
 
NTKERNELAPI volatile KSYSTEM_TIME KeTickCount
 

Macro Definition Documentation

◆ AMD64_TSS

#define AMD64_TSS   9

Definition at line 81 of file ke.h.

◆ APIC_EOI_REGISTER

#define APIC_EOI_REGISTER   0xFFFFFFFFFFFE00B0ULL

Definition at line 83 of file ke.h.

◆ EFER_FFXSR

#define EFER_FFXSR   0x4000

Definition at line 79 of file ke.h.

◆ EFER_LMA

#define EFER_LMA   0x0400

Definition at line 76 of file ke.h.

◆ EFER_LME

#define EFER_LME   0x0100

Definition at line 75 of file ke.h.

◆ EFER_NXE

#define EFER_NXE   0x0800

Definition at line 77 of file ke.h.

◆ EFER_SCE

#define EFER_SCE   0x0001

Definition at line 74 of file ke.h.

◆ EFER_SVME

#define EFER_SVME   0x1000

Definition at line 78 of file ke.h.

◆ FRAME_EDITED

#define FRAME_EDITED   0xFFF8

Definition at line 64 of file ke.h.

◆ KD_BREAKPOINT_SIZE

#define KD_BREAKPOINT_SIZE   sizeof(UCHAR)

Definition at line 118 of file ke.h.

◆ KD_BREAKPOINT_TYPE

#define KD_BREAKPOINT_TYPE   UCHAR

Definition at line 117 of file ke.h.

◆ KD_BREAKPOINT_VALUE

#define KD_BREAKPOINT_VALUE   0xCC

Definition at line 119 of file ke.h.

◆ KeArchInitThreadWithContext

#define KeArchInitThreadWithContext (   Thread,
  SystemRoutine,
  StartRoutine,
  StartContext,
  Context 
)    Ke386InitThreadWithContext(Thread,SystemRoutine,StartRoutine,StartContext,Context)

Definition at line 418 of file ke.h.

◆ KeGetContextSwitches

#define KeGetContextSwitches (   Prcb)    (Prcb->KeContextSwitches)

Definition at line 212 of file ke.h.

◆ KeGetExceptionFrame

#define KeGetExceptionFrame (   Thread)
Value:
uint32_t ULONG_PTR
Definition: typedefs.h:65
struct _KEXCEPTION_FRAME * PKEXCEPTION_FRAME
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
#define KeGetTrapFrame(Thread)
Definition: ke.h:204

Definition at line 221 of file ke.h.

◆ KeGetTrapFrame

#define KeGetTrapFrame (   Thread)
Value:
(PKTRAP_FRAME)((ULONG_PTR)((Thread)->InitialStack) - \
sizeof(KTRAP_FRAME))
uint32_t ULONG_PTR
Definition: typedefs.h:65
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
struct _KTRAP_FRAME * PKTRAP_FRAME

Definition at line 204 of file ke.h.

◆ KeGetTrapFrameInterruptState

#define KeGetTrapFrameInterruptState (   TrapFrame)    BooleanFlagOn((TrapFrame)->EFlags, EFLAGS_INTERRUPT_MASK)

Definition at line 229 of file ke.h.

◆ Ki386PerfEnd

#define Ki386PerfEnd ( )

Definition at line 366 of file ke.h.

◆ KiGetSecondLevelDCacheSize

#define KiGetSecondLevelDCacheSize ( )    ((PKIPCR)KeGetPcr())->SecondLevelCacheSize

Definition at line 219 of file ke.h.

◆ X86_CR0_EM

#define X86_CR0_EM   0x00000004 /* enable FPU emulation (disable FPU) */

Definition at line 15 of file ke.h.

◆ X86_CR0_MP

#define X86_CR0_MP   0x00000002 /* enable FPU monitoring */

Definition at line 16 of file ke.h.

◆ X86_CR0_NE

#define X86_CR0_NE   0x00000020 /* enable native FPU error reporting */

Definition at line 13 of file ke.h.

◆ X86_CR0_PE

#define X86_CR0_PE   0x00000001 /* enable Protected Mode */

Definition at line 12 of file ke.h.

◆ X86_CR0_PG

#define X86_CR0_PG   0x80000000 /* enable Paging */

Definition at line 18 of file ke.h.

◆ X86_CR0_TS

#define X86_CR0_TS   0x00000008 /* enable exception on FPU instruction for task switch */

Definition at line 14 of file ke.h.

◆ X86_CR0_WP

#define X86_CR0_WP   0x00010000 /* enable Write Protect (copy on write) */

Definition at line 17 of file ke.h.

◆ X86_CR4_OSFXSR

#define X86_CR4_OSFXSR   0x00000200 /* enable FXSAVE/FXRSTOR instructions */

Definition at line 22 of file ke.h.

◆ X86_CR4_OSXMMEXCPT

#define X86_CR4_OSXMMEXCPT   0x00000400 /* enable #XF exception */

Definition at line 23 of file ke.h.

◆ X86_CR4_PAE

#define X86_CR4_PAE   0x00000020 /* enable physical address extensions */

Definition at line 20 of file ke.h.

◆ X86_CR4_PGE

#define X86_CR4_PGE   0x00000080 /* enable global pages */

Definition at line 21 of file ke.h.

◆ X86_EFLAGS_ID

#define X86_EFLAGS_ID   0x00200000 /* CPUID detection flag */

Definition at line 10 of file ke.h.

◆ X86_EFLAGS_IF

#define X86_EFLAGS_IF   0x00000200 /* Interrupt Enable flag */

Definition at line 5 of file ke.h.

◆ X86_EFLAGS_IOPL

#define X86_EFLAGS_IOPL   0x00003000 /* I/O Privilege Level bits */

Definition at line 6 of file ke.h.

◆ X86_EFLAGS_NT

#define X86_EFLAGS_NT   0x00004000 /* Nested Task flag */

Definition at line 7 of file ke.h.

◆ X86_EFLAGS_RF

#define X86_EFLAGS_RF   0x00010000 /* Resume flag */

Definition at line 8 of file ke.h.

◆ X86_EFLAGS_TF

#define X86_EFLAGS_TF   0x00000100 /* Trap flag */

Definition at line 4 of file ke.h.

◆ X86_EFLAGS_VM

#define X86_EFLAGS_VM   0x00020000 /* Virtual Mode */

Definition at line 9 of file ke.h.

◆ X86_EXT_FEATURE_3DNOW

#define X86_EXT_FEATURE_3DNOW   0x40000000 /* 3DNOW! extension present */

Definition at line 62 of file ke.h.

◆ X86_EXT_FEATURE_SSE3

#define X86_EXT_FEATURE_SSE3   0x00000001 /* SSE3 extension present */

Definition at line 61 of file ke.h.

◆ X86_FEATURE_CMOV

#define X86_FEATURE_CMOV   0x00008000 /* "Conditional move" instruction supported */

Definition at line 36 of file ke.h.

◆ X86_FEATURE_CX16

#define X86_FEATURE_CX16   0x00002000 /* CMPXCHG16B instruction are available */

Definition at line 51 of file ke.h.

◆ X86_FEATURE_CX8

#define X86_FEATURE_CX8   0x00000100 /* CMPXCHG8B instruction present */

Definition at line 32 of file ke.h.

◆ X86_FEATURE_DBG

#define X86_FEATURE_DBG   0x00000004 /* Debugging extensions are present */

Definition at line 28 of file ke.h.

◆ X86_FEATURE_DS

#define X86_FEATURE_DS   0x00200000 /* Debug Store is present */

Definition at line 38 of file ke.h.

◆ X86_FEATURE_FMA3

#define X86_FEATURE_FMA3   0x00001000 /* Fused multiple-add supported */

Definition at line 50 of file ke.h.

◆ X86_FEATURE_FPU

#define X86_FEATURE_FPU   0x00000001 /* x87 FPU is present */

Definition at line 26 of file ke.h.

◆ X86_FEATURE_FXSR

#define X86_FEATURE_FXSR   0x01000000 /* FXSAVE/FXRSTOR instructions present */

Definition at line 40 of file ke.h.

◆ X86_FEATURE_HT

#define X86_FEATURE_HT   0x10000000 /* Hyper-Threading present */

Definition at line 43 of file ke.h.

◆ X86_FEATURE_MMX

#define X86_FEATURE_MMX   0x00800000 /* MMX extension present */

Definition at line 39 of file ke.h.

◆ X86_FEATURE_MONITOR

#define X86_FEATURE_MONITOR   0x00000008 /* SSE3 Monitor instructions supported */

Definition at line 47 of file ke.h.

◆ X86_FEATURE_MTTR

#define X86_FEATURE_MTTR   0x00001000 /* Memory type range registers are present */

Definition at line 34 of file ke.h.

◆ X86_FEATURE_NX

#define X86_FEATURE_NX   0x00100000 /* NX support present */

Definition at line 59 of file ke.h.

◆ X86_FEATURE_PAE

#define X86_FEATURE_PAE   0x00000040 /* physical address extension is present */

Definition at line 31 of file ke.h.

◆ X86_FEATURE_PAT

#define X86_FEATURE_PAT   0x00010000 /* Page Attribute Table is supported */

Definition at line 37 of file ke.h.

◆ X86_FEATURE_PCID

#define X86_FEATURE_PCID   0x00020000 /* Process Context IDentifiers are supported */

Definition at line 52 of file ke.h.

◆ X86_FEATURE_PGE

#define X86_FEATURE_PGE   0x00002000 /* Page Global Enable */

Definition at line 35 of file ke.h.

◆ X86_FEATURE_POPCNT

#define X86_FEATURE_POPCNT   0x00800000 /* POPCNT instruction is available */

Definition at line 55 of file ke.h.

◆ X86_FEATURE_PSE

#define X86_FEATURE_PSE   0x00000008 /* Page Size Extension is present */

Definition at line 29 of file ke.h.

◆ X86_FEATURE_SSE

#define X86_FEATURE_SSE   0x02000000 /* SSE extension present */

Definition at line 41 of file ke.h.

◆ X86_FEATURE_SSE2

#define X86_FEATURE_SSE2   0x04000000 /* SSE2 extension present */

Definition at line 42 of file ke.h.

◆ X86_FEATURE_SSE3

#define X86_FEATURE_SSE3   0x00000001 /* SSE3 is supported */

Definition at line 46 of file ke.h.

◆ X86_FEATURE_SSE41

#define X86_FEATURE_SSE41   0x00080000 /* SSE 4.1 is supported */

Definition at line 53 of file ke.h.

◆ X86_FEATURE_SSE42

#define X86_FEATURE_SSE42   0x00100000 /* SSE 4.2 is supported */

Definition at line 54 of file ke.h.

◆ X86_FEATURE_SSSE3

#define X86_FEATURE_SSSE3   0x00000200 /* Supplemental SSE3 are available */

Definition at line 49 of file ke.h.

◆ X86_FEATURE_SYSCALL

#define X86_FEATURE_SYSCALL   0x00000800 /* SYSCALL/SYSRET support present */

Definition at line 33 of file ke.h.

◆ X86_FEATURE_TSC

#define X86_FEATURE_TSC   0x00000010 /* time stamp counters are present */

Definition at line 30 of file ke.h.

◆ X86_FEATURE_VME

#define X86_FEATURE_VME   0x00000002 /* Virtual 8086 Extensions are present */

Definition at line 27 of file ke.h.

◆ X86_FEATURE_VMX

#define X86_FEATURE_VMX   0x00000020 /* Virtual Machine eXtensions are available */

Definition at line 48 of file ke.h.

◆ X86_FEATURE_XSAVE

#define X86_FEATURE_XSAVE   0x04000000 /* XSAVE family are available */

Definition at line 56 of file ke.h.

◆ X86_MSR_CSTAR

#define X86_MSR_CSTAR   0xC0000083

Definition at line 71 of file ke.h.

◆ X86_MSR_EFER

#define X86_MSR_EFER   0xC0000080

Definition at line 68 of file ke.h.

◆ X86_MSR_GSBASE

#define X86_MSR_GSBASE   0xC0000101

Definition at line 66 of file ke.h.

◆ X86_MSR_KERNEL_GSBASE

#define X86_MSR_KERNEL_GSBASE   0xC0000102

Definition at line 67 of file ke.h.

◆ X86_MSR_LSTAR

#define X86_MSR_LSTAR   0xC0000082

Definition at line 70 of file ke.h.

◆ X86_MSR_SFMASK

#define X86_MSR_SFMASK   0xC0000084

Definition at line 72 of file ke.h.

◆ X86_MSR_STAR

#define X86_MSR_STAR   0xC0000081

Definition at line 69 of file ke.h.

Typedef Documentation

◆ KI_INTERRUPT_DISPATCH_ENTRY

◆ KIDT_INIT

◆ PKI_INTERRUPT_DISPATCH_ENTRY

◆ PKIDT_INIT

Function Documentation

◆ HalAllocateAdapterChannel()

NTHALAPI NTSTATUS NTAPI HalAllocateAdapterChannel ( IN PADAPTER_OBJECT  AdapterObject,
IN PWAIT_CONTEXT_BLOCK  Wcb,
IN ULONG  NumberOfMapRegisters,
IN PDRIVER_CONTROL  ExecutionRoutine 
)

Definition at line 88 of file dma.c.

92 {
94  while (TRUE);
95  return STATUS_SUCCESS;
96 }
#define TRUE
Definition: types.h:120
#define UNIMPLEMENTED
Definition: debug.h:115
#define STATUS_SUCCESS
Definition: shellext.h:65

Referenced by HalGetScatterGatherList(), and IoAllocateAdapterChannel().

◆ Ke386InitThreadWithContext()

VOID Ke386InitThreadWithContext ( PKTHREAD  Thread,
PKSYSTEM_ROUTINE  SystemRoutine,
PKSTART_ROUTINE  StartRoutine,
PVOID  StartContext,
PCONTEXT  Context 
)

◆ KeAllocateGdtSelector()

ULONG KeAllocateGdtSelector ( ULONG  Desc[2])

◆ KeApplicationProcessorInitDispatcher()

VOID KeApplicationProcessorInitDispatcher ( VOID  )

◆ KeCreateApplicationProcessorIdleThread()

VOID KeCreateApplicationProcessorIdleThread ( ULONG  Id)

◆ KeDisableInterrupts()

FORCEINLINE BOOLEAN KeDisableInterrupts ( VOID  )

Definition at line 235 of file ke.h.

236 {
238 
239  /* Get EFLAGS and check if the interrupt bit is set */
240  Flags = __readeflags();
241 
242  /* Disable interrupts */
243  _disable();
244  return (Flags & EFLAGS_INTERRUPT_MASK) ? TRUE : FALSE;
245 }
#define TRUE
Definition: types.h:120
uint32_t ULONG_PTR
Definition: typedefs.h:65
__INTRIN_INLINE uintptr_t __readeflags(void)
Definition: intrin_x86.h:1675
#define FALSE
Definition: types.h:117
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
void __cdecl _disable(void)
Definition: intrin_arm.h:365
#define EFLAGS_INTERRUPT_MASK
Definition: ketypes.h:126

Referenced by _ExiDisableInterruptsAndAcquireSpinlock(), KdPollBreakIn(), KeFreezeExecution(), KeRemoveQueueDpc(), and Ki386EnableGlobalPage().

◆ KeFlushProcessTb()

FORCEINLINE VOID KeFlushProcessTb ( VOID  )

Definition at line 268 of file ke.h.

269 {
270  /* Flush the TLB by resetting CR3 */
272 }
__INTRIN_INLINE unsigned long __readcr3(void)
Definition: intrin_x86.h:1819
__INTRIN_INLINE void __writecr3(unsigned int Data)
Definition: intrin_x86.h:1795

Referenced by MiMapPageInHyperSpace(), MiMapPagesInZeroSpace(), MiReserveAlignedSystemPtes(), and MiUnmapLockedPagesInUserSpace().

◆ KeFreeGdtSelector()

VOID KeFreeGdtSelector ( ULONG  Entry)

◆ KeGetContextFrameRegister()

FORCEINLINE ULONG_PTR KeGetContextFrameRegister ( PCONTEXT  Context)

Definition at line 161 of file ke.h.

162 {
163  return Context->Rbp;
164 }

Referenced by KdbpCmdBackTrace().

◆ KeGetContextPc()

FORCEINLINE ULONG_PTR KeGetContextPc ( PCONTEXT  Context)

Definition at line 126 of file ke.h.

127 {
128  return Context->Rip;
129 }

◆ KeGetContextReturnRegister()

FORCEINLINE ULONG_PTR KeGetContextReturnRegister ( PCONTEXT  Context)

Definition at line 140 of file ke.h.

141 {
142  return Context->Rax;
143 }

◆ KeGetContextStackRegister()

FORCEINLINE ULONG_PTR KeGetContextStackRegister ( PCONTEXT  Context)

Definition at line 154 of file ke.h.

155 {
156  return Context->Rsp;
157 }

◆ KeGetTrapFrameFrameRegister()

FORCEINLINE ULONG_PTR KeGetTrapFrameFrameRegister ( PKTRAP_FRAME  TrapFrame)

Definition at line 196 of file ke.h.

197 {
198  return TrapFrame->Rbp;
199 }
UINT64 Rbp
Definition: ketypes.h:376

Referenced by KdbpCmdThread().

◆ KeGetTrapFramePc()

FORCEINLINE ULONG_PTR KeGetTrapFramePc ( PKTRAP_FRAME  TrapFrame)

Definition at line 175 of file ke.h.

176 {
177  return TrapFrame->Rip;
178 }
UINT64 Rip
Definition: ketypes.h:383

◆ KeGetTrapFrameStackRegister()

FORCEINLINE ULONG_PTR KeGetTrapFrameStackRegister ( PKTRAP_FRAME  TrapFrame)

Definition at line 189 of file ke.h.

190 {
191  return TrapFrame->Rsp;
192 }
UINT64 Rsp
Definition: ketypes.h:390

Referenced by KdbpCmdThread().

◆ KeInvalidateTlbEntry()

FORCEINLINE VOID KeInvalidateTlbEntry ( IN PVOID  Address)

Definition at line 260 of file ke.h.

261 {
262  /* Invalidate the TLB entry for this address */
263  __invlpg(Address);
264 }
static WCHAR Address[46]
Definition: ping.c:68
__INTRIN_INLINE void __invlpg(void *Address)
Definition: intrin_x86.h:1969

Referenced by FreeWsleIndex(), KdpPhysMap(), KiI386PentiumLockErrataFixup(), MiDbgTranslatePhysicalAddress(), MiDbgUnTranslatePhysicalAddress(), MiProtectVirtualMemory(), MmDeleteVirtualMapping(), MmSetDirtyBit(), MmSetPageProtect(), and TrimWsList().

◆ KeQueryInterruptHandler()

FORCEINLINE PVOID KeQueryInterruptHandler ( IN ULONG  Vector)

Definition at line 323 of file ke.h.

324 {
325  UCHAR Entry;
326  PKIDTENTRY64 Idt;
327 
328  /* Get the entry from the HAL */
330 
331  /* Get the IDT entry */
332  Idt = &KeGetPcr()->IdtBase[Entry];
333 
334  /* Return the address */
335  return (PVOID)((ULONG64)Idt->OffsetHigh << 32 |
336  (ULONG64)Idt->OffsetMiddle << 16 |
337  (ULONG64)Idt->OffsetLow);
338 }
struct _Entry Entry
Definition: kefuncs.h:627
union _KIDTENTRY64 * IdtBase
Definition: ke.h:305
USHORT OffsetLow
Definition: ketypes.h:470
USHORT OffsetMiddle
Definition: ketypes.h:477
unsigned __int64 ULONG64
Definition: imports.h:198
unsigned char UCHAR
Definition: xmlstorage.h:181
FORCEINLINE PKPCR KeGetPcr(VOID)
Definition: ke.h:327
base of all file and directory entries
Definition: entries.h:82
ULONG OffsetHigh
Definition: ketypes.h:478
#define HalVectorToIDTEntry
Definition: halfuncs.h:51

Referenced by HalpInitializeTsc(), HalpSwitchToRealModeTrapHandlers(), KeConnectInterrupt(), and KiGetVectorDispatch().

◆ KeRegisterInterruptHandler()

FORCEINLINE VOID KeRegisterInterruptHandler ( IN ULONG  Vector,
IN PVOID  Handler 
)

Definition at line 297 of file ke.h.

299 {
300  UCHAR Entry;
301  PKIDTENTRY64 Idt;
302 
303  /* Get the entry from the HAL */
305 
306  /* Now set the data */
307  Idt = &KeGetPcr()->IdtBase[Entry];
308  Idt->OffsetLow = (ULONG_PTR)Handler & 0xffff;
309  Idt->OffsetMiddle = ((ULONG_PTR)Handler >> 16) & 0xffff;
310  Idt->OffsetHigh = (ULONG_PTR)Handler >> 32;
311  Idt->Selector = KGDT64_R0_CODE;
312  Idt->IstIndex = 0;
313  Idt->Type = 0x0e;
314  Idt->Dpl = 0;
315  Idt->Present = 1;
316  Idt->Reserved0 = 0;
317  Idt->Reserved1 = 0;
318 }
struct _Entry Entry
Definition: kefuncs.h:627
union _KIDTENTRY64 * IdtBase
Definition: ke.h:305
USHORT Selector
Definition: ketypes.h:471
USHORT OffsetLow
Definition: ketypes.h:470
USHORT Reserved0
Definition: ketypes.h:473
USHORT Type
Definition: ketypes.h:474
USHORT Present
Definition: ketypes.h:476
USHORT OffsetMiddle
Definition: ketypes.h:477
#define KGDT64_R0_CODE
Definition: ketypes.h:72
USHORT IstIndex
Definition: ketypes.h:472
unsigned char UCHAR
Definition: xmlstorage.h:181
USHORT Dpl
Definition: ketypes.h:475
ULONG Reserved1
Definition: ketypes.h:479
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn BOOLEAN Physical 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:668
FORCEINLINE PKPCR KeGetPcr(VOID)
Definition: ke.h:327
#define ULONG_PTR
Definition: config.h:101
base of all file and directory entries
Definition: entries.h:82
ULONG OffsetHigh
Definition: ketypes.h:478
#define HalVectorToIDTEntry
Definition: halfuncs.h:51

Referenced by ApicInitializeLocalApic(), HalpEnableInterruptHandler(), HalpInitializePICs(), HalpInitializeTsc(), HalpRestoreTrapHandlers(), HalpSwitchToRealModeTrapHandlers(), KeConnectInterrupt(), and KiConnectVectorToInterrupt().

◆ KeRestoreInterrupts()

FORCEINLINE VOID KeRestoreInterrupts ( BOOLEAN  WereEnabled)

Definition at line 250 of file ke.h.

251 {
252  if (WereEnabled) _enable();
253 }
void __cdecl _enable(void)
Definition: intrin_arm.h:373

Referenced by _ExiReleaseSpinLockAndRestoreInterrupts(), and Ki386EnableGlobalPage().

◆ KeSetContextFrameRegister()

FORCEINLINE VOID KeSetContextFrameRegister ( PCONTEXT  Context,
ULONG_PTR  Frame 
)

Definition at line 168 of file ke.h.

169 {
170  Context->Rbp = Frame;
171 }

Referenced by KdbpCmdBackTrace().

◆ KeSetContextPc()

FORCEINLINE VOID KeSetContextPc ( PCONTEXT  Context,
ULONG_PTR  ProgramCounter 
)

Definition at line 133 of file ke.h.

134 {
135  Context->Rip = ProgramCounter;
136 }

◆ KeSetContextReturnRegister()

FORCEINLINE VOID KeSetContextReturnRegister ( PCONTEXT  Context,
ULONG_PTR  ReturnValue 
)

Definition at line 147 of file ke.h.

148 {
149  Context->Rax = ReturnValue;
150 }
UINT32 void void ** ReturnValue
Definition: acevents.h:214

◆ KeSweepICache()

FORCEINLINE VOID KeSweepICache ( IN PVOID  BaseAddress,
IN SIZE_T  FlushSize 
)

Definition at line 276 of file ke.h.

278 {
279  //
280  // Always sweep the whole cache
281  //
283  UNREFERENCED_PARAMETER(FlushSize);
284  __wbinvd();
285 }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
Definition: mmfuncs.h:404
PPC_QUAL void __wbinvd(void)
Definition: intrin_ppc.h:759

Referenced by KdpCopyMemoryChunks(), and NtFlushInstructionCache().

◆ Ki386InitializeLdt()

VOID Ki386InitializeLdt ( VOID  )

◆ Ki386SetProcessorFeatures()

VOID Ki386SetProcessorFeatures ( VOID  )

◆ KiAlignmentFault()

VOID KiAlignmentFault ( VOID  )

◆ KiApcInterrupt()

VOID KiApcInterrupt ( VOID  )

Definition at line 229 of file trapc.c.

230 {
232  KEXCEPTION_FRAME ExceptionFrame;
233  PKTRAP_FRAME TrapFrame = KeGetCurrentThread()->TrapFrame;
234 
235  DPRINT1("[APC TRAP]\n");
236  while (TRUE);
237 
238  //
239  // Isolate previous mode
240  //
241  PreviousMode = KiGetPreviousMode(TrapFrame);
242 
243  //
244  // FIXME-USER: Handle APC interrupt while in user-mode
245  //
247 
248  //
249  // Disable interrupts
250  //
251  _disable();
252 
253  //
254  // Clear APC interrupt
255  //
257 
258  //
259  // Re-enable interrupts
260  //
261  _enable();
262 
263  //
264  // Deliver APCs
265  //
266  KiDeliverApc(PreviousMode, &ExceptionFrame, TrapFrame);
267 }
#define TRUE
Definition: types.h:120
void __cdecl _enable(void)
Definition: intrin_arm.h:373
#define FALSE
Definition: types.h:117
_In_ KPROCESSOR_MODE PreviousMode
Definition: sefuncs.h:103
#define ASSERT(a)
Definition: mode.c:44
CCHAR KPROCESSOR_MODE
Definition: ketypes.h:7
#define KiGetPreviousMode(tf)
Definition: ke.h:180
#define DPRINT1
Definition: precomp.h:8
VOID FASTCALL HalClearSoftwareInterrupt(IN KIRQL Irql)
Definition: pic.c:282
void __cdecl _disable(void)
Definition: intrin_arm.h:365
#define KeGetCurrentThread
Definition: hal.h:50
VOID NTAPI KiDeliverApc(IN KPROCESSOR_MODE DeliveryMode, IN PKEXCEPTION_FRAME ExceptionFrame, IN PKTRAP_FRAME TrapFrame)
Definition: apc.c:302
#define APC_LEVEL
Definition: env_spec_w32.h:695

Referenced by KiInitializePcr().

◆ KiBoundFault()

VOID KiBoundFault ( VOID  )

◆ KiBreakpointTrap()

VOID KiBreakpointTrap ( VOID  )

◆ KiDebugServiceTrap()

VOID KiDebugServiceTrap ( VOID  )

◆ KiDebugTrapOrFault()

VOID KiDebugTrapOrFault ( VOID  )

◆ KiDivideErrorFault()

VOID KiDivideErrorFault ( VOID  )

◆ KiDoubleFaultAbort()

VOID KiDoubleFaultAbort ( VOID  )

◆ KiDpcInterrupt()

VOID KiDpcInterrupt ( VOID  )

◆ KiEndInterrupt()

FORCEINLINE VOID KiEndInterrupt ( IN KIRQL  Irql,
IN PKTRAP_FRAME  TrapFrame 
)

Definition at line 350 of file ke.h.

352 {
353  /* Make sure this is from the clock handler */
354  ASSERT(TrapFrame->ErrorCode == 0xc10c4);
355  //KeLowerIrql(Irql);
356 }
#define ASSERT(a)
Definition: mode.c:44

◆ KiFloatingErrorFault()

VOID KiFloatingErrorFault ( VOID  )

◆ KiGdtPrepareForApplicationProcessorInit()

VOID KiGdtPrepareForApplicationProcessorInit ( ULONG  Id)

◆ KiGeneralProtectionFault()

VOID KiGeneralProtectionFault ( VOID  )

◆ KiGetCacheInformation()

VOID KiGetCacheInformation ( VOID  )

Definition at line 208 of file cpu.c.

209 {
210  PKIPCR Pcr = (PKIPCR)KeGetPcr();
211  ULONG Vendor;
212  ULONG CacheRequests = 0, i;
213  ULONG CurrentRegister;
214  UCHAR RegisterByte;
215  BOOLEAN FirstPass = TRUE;
216  CPU_INFO CpuInfo;
217 
218  /* Set default L2 size */
219  Pcr->SecondLevelCacheSize = 0;
220 
221  /* Get the Vendor ID and make sure we support CPUID */
222  Vendor = KiGetCpuVendor();
223  if (!Vendor) return;
224 
225  /* Check the Vendor ID */
226  switch (Vendor)
227  {
228  /* Handle Intel case */
229  case CPU_INTEL:
230 
231  /*Check if we support CPUID 2 */
232  KiCpuId(&CpuInfo, 0);
233  if (CpuInfo.Eax >= 2)
234  {
235  /* We need to loop for the number of times CPUID will tell us to */
236  do
237  {
238  /* Do the CPUID call */
239  KiCpuId(&CpuInfo, 2);
240 
241  /* Check if it was the first call */
242  if (FirstPass)
243  {
244  /*
245  * The number of times to loop is the first byte. Read
246  * it and then destroy it so we don't get confused.
247  */
248  CacheRequests = CpuInfo.Eax & 0xFF;
249  CpuInfo.Eax &= 0xFFFFFF00;
250 
251  /* Don't go over this again */
252  FirstPass = FALSE;
253  }
254 
255  /* Loop all 4 registers */
256  for (i = 0; i < 4; i++)
257  {
258  /* Get the current register */
259  CurrentRegister = CpuInfo.AsUINT32[i];
260 
261  /*
262  * If the upper bit is set, then this register should
263  * be skipped.
264  */
265  if (CurrentRegister & 0x80000000) continue;
266 
267  /* Keep looping for every byte inside this register */
268  while (CurrentRegister)
269  {
270  /* Read a byte, skip a byte. */
271  RegisterByte = (UCHAR)(CurrentRegister & 0xFF);
272  CurrentRegister >>= 8;
273  if (!RegisterByte) continue;
274 
275  /*
276  * Valid values are from 0x40 (0 bytes) to 0x49
277  * (32MB), or from 0x80 to 0x89 (same size but
278  * 8-way associative.
279  */
280  if (((RegisterByte > 0x40) &&
281  (RegisterByte <= 0x49)) ||
282  ((RegisterByte > 0x80) &&
283  (RegisterByte <= 0x89)))
284  {
285  /* Mask out only the first nibble */
286  RegisterByte &= 0x0F;
287 
288  /* Set the L2 Cache Size */
289  Pcr->SecondLevelCacheSize = 0x10000 <<
290  RegisterByte;
291  }
292  }
293  }
294  } while (--CacheRequests);
295  }
296  break;
297 
298  case CPU_AMD:
299 
300  /* Check if we support CPUID 0x80000006 */
301  KiCpuId(&CpuInfo, 0x80000000);
302  if (CpuInfo.Eax >= 6)
303  {
304  /* Get 2nd level cache and tlb size */
305  KiCpuId(&CpuInfo, 0x80000006);
306 
307  /* Set the L2 Cache Size */
308  Pcr->SecondLevelCacheSize = (CpuInfo.Ecx & 0xFFFF0000) >> 6;
309  }
310  break;
311  }
312 }
#define TRUE
Definition: types.h:120
struct _KIPCR * PKIPCR
#define KeGetPcr()
Definition: ke.h:26
ULONG NTAPI KiGetCpuVendor(VOID)
Definition: cpu.c:79
#define FALSE
Definition: types.h:117
unsigned char BOOLEAN
ULONG SecondLevelCacheSize
Definition: ketypes.h:885
ULONG Eax
Definition: ketypes.h:300
ULONG Ecx
Definition: ketypes.h:302
unsigned char UCHAR
Definition: xmlstorage.h:181
UINT32 AsUINT32[4]
Definition: ketypes.h:297
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
Definition: glfuncs.h:248
unsigned int ULONG
Definition: retypes.h:1

Referenced by KiSystemStartupBootStack().

◆ KiGetFeatureBits()

ULONG KiGetFeatureBits ( VOID  )

Definition at line 119 of file cpu.c.

120 {
121  PKPRCB Prcb = KeGetCurrentPrcb();
122  ULONG Vendor;
123  ULONG FeatureBits = KF_WORKING_PTE;
124  CPU_INFO CpuInfo;
125 
126  /* Get the Vendor ID */
127  Vendor = KiGetCpuVendor();
128 
129  /* Make sure we got a valid vendor ID at least. */
130  if (!Vendor) return FeatureBits;
131 
132  /* Get the CPUID Info. */
133  KiCpuId(&CpuInfo, 1);
134 
135  /* Set the initial APIC ID */
136  Prcb->InitialApicId = (UCHAR)(CpuInfo.Ebx >> 24);
137 
138  /* Convert all CPUID Feature bits into our format */
139  if (CpuInfo.Edx & X86_FEATURE_VME) FeatureBits |= KF_V86_VIS | KF_CR4;
140  if (CpuInfo.Edx & X86_FEATURE_PSE) FeatureBits |= KF_LARGE_PAGE | KF_CR4;
141  if (CpuInfo.Edx & X86_FEATURE_TSC) FeatureBits |= KF_RDTSC;
142  if (CpuInfo.Edx & X86_FEATURE_CX8) FeatureBits |= KF_CMPXCHG8B;
143  if (CpuInfo.Edx & X86_FEATURE_SYSCALL) FeatureBits |= KF_FAST_SYSCALL;
144  if (CpuInfo.Edx & X86_FEATURE_MTTR) FeatureBits |= KF_MTRR;
145  if (CpuInfo.Edx & X86_FEATURE_PGE) FeatureBits |= KF_GLOBAL_PAGE | KF_CR4;
146  if (CpuInfo.Edx & X86_FEATURE_CMOV) FeatureBits |= KF_CMOV;
147  if (CpuInfo.Edx & X86_FEATURE_PAT) FeatureBits |= KF_PAT;
148  if (CpuInfo.Edx & X86_FEATURE_DS) FeatureBits |= KF_DTS;
149  if (CpuInfo.Edx & X86_FEATURE_MMX) FeatureBits |= KF_MMX;
150  if (CpuInfo.Edx & X86_FEATURE_FXSR) FeatureBits |= KF_FXSR;
151  if (CpuInfo.Edx & X86_FEATURE_SSE) FeatureBits |= KF_XMMI;
152  if (CpuInfo.Edx & X86_FEATURE_SSE2) FeatureBits |= KF_XMMI64;
153 
154  if (CpuInfo.Ecx & X86_FEATURE_SSE3) FeatureBits |= KF_SSE3;
155  //if (CpuInfo.Ecx & X86_FEATURE_MONITOR) FeatureBits |= KF_MONITOR;
156  //if (CpuInfo.Ecx & X86_FEATURE_SSSE3) FeatureBits |= KF_SSE3SUP;
157  if (CpuInfo.Ecx & X86_FEATURE_CX16) FeatureBits |= KF_CMPXCHG16B;
158  //if (CpuInfo.Ecx & X86_FEATURE_SSE41) FeatureBits |= KF_SSE41;
159  //if (CpuInfo.Ecx & X86_FEATURE_POPCNT) FeatureBits |= KF_POPCNT;
160  if (CpuInfo.Ecx & X86_FEATURE_XSAVE) FeatureBits |= KF_XSTATE;
161 
162  /* Check if the CPU has hyper-threading */
163  if (CpuInfo.Edx & X86_FEATURE_HT)
164  {
165  /* Set the number of logical CPUs */
166  Prcb->LogicalProcessorsPerPhysicalProcessor = (UCHAR)(CpuInfo.Ebx >> 16);
168  {
169  /* We're on dual-core */
171  }
172  }
173  else
174  {
175  /* We only have a single CPU */
177  }
178 
179  /* Check extended cpuid features */
180  KiCpuId(&CpuInfo, 0x80000000);
181  if ((CpuInfo.Eax & 0xffffff00) == 0x80000000)
182  {
183  /* Check if CPUID 0x80000001 is supported */
184  if (CpuInfo.Eax >= 0x80000001)
185  {
186  /* Check which extended features are available. */
187  KiCpuId(&CpuInfo, 0x80000001);
188 
189  /* Check if NX-bit is supported */
190  if (CpuInfo.Edx & X86_FEATURE_NX) FeatureBits |= KF_NX_BIT;
191 
192  /* Now handle each features for each CPU Vendor */
193  switch (Vendor)
194  {
195  case CPU_AMD:
196  if (CpuInfo.Edx & 0x80000000) FeatureBits |= KF_3DNOW;
197  break;
198  }
199  }
200  }
201 
202  /* Return the Feature Bits */
203  return FeatureBits;
204 }
#define X86_FEATURE_PGE
Definition: ke.h:35
#define X86_FEATURE_SYSCALL
Definition: ke.h:33
#define X86_FEATURE_VME
Definition: ke.h:27
UCHAR LogicalProcessorsPerPhysicalProcessor
Definition: ketypes.h:705
#define KF_CMPXCHG8B
Definition: ketypes.h:150
#define TRUE
Definition: types.h:120
#define X86_FEATURE_MMX
Definition: ke.h:39
#define X86_FEATURE_SSE2
Definition: ke.h:42
#define X86_FEATURE_HT
Definition: ke.h:43
#define KF_RDTSC
Definition: ketypes.h:144
FORCEINLINE struct _KPRCB * KeGetCurrentPrcb(VOID)
Definition: ketypes.h:1079
#define KF_MMX
Definition: ketypes.h:151
#define X86_FEATURE_FXSR
Definition: ke.h:40
#define KF_NX_BIT
Definition: ketypes.h:165
#define X86_FEATURE_XSAVE
Definition: ke.h:56
ULONG NTAPI KiGetCpuVendor(VOID)
Definition: cpu.c:79
#define KF_LARGE_PAGE
Definition: ketypes.h:148
#define KF_PAT
Definition: ketypes.h:153
#define KF_XMMI
Definition: ketypes.h:156
#define X86_FEATURE_CX16
Definition: ke.h:51
#define X86_FEATURE_PSE
Definition: ke.h:29
ULONG Eax
Definition: ketypes.h:300
#define X86_FEATURE_PAT
Definition: ke.h:37
#define KF_CR4
Definition: ketypes.h:145
ULONG Ebx
Definition: ketypes.h:301
#define KF_MTRR
Definition: ketypes.h:149
ULONG Ecx
Definition: ketypes.h:302
#define X86_FEATURE_NX
Definition: ke.h:59
#define KF_WORKING_PTE
Definition: ketypes.h:152
#define KF_FAST_SYSCALL
Definition: ketypes.h:155
#define KF_V86_VIS
Definition: ketypes.h:143
#define KF_FXSR
Definition: ketypes.h:154
#define KF_3DNOW
Definition: ketypes.h:157
#define X86_FEATURE_MTTR
Definition: ke.h:34
unsigned char UCHAR
Definition: xmlstorage.h:181
#define KF_XMMI64
Definition: ketypes.h:159
#define KF_CMPXCHG16B
Definition: ketypes.h:163
#define X86_FEATURE_SSE
Definition: ke.h:41
#define X86_FEATURE_CX8
Definition: ke.h:32
#define KF_SSE3
Definition: ketypes.h:162
#define X86_FEATURE_CMOV
Definition: ke.h:36
unsigned int ULONG
Definition: retypes.h:1
#define KF_DTS
Definition: ketypes.h:160
#define X86_FEATURE_TSC
Definition: ke.h:30
#define KF_XSTATE
Definition: ketypes.h:164
#define X86_FEATURE_DS
Definition: ke.h:38
#define KF_GLOBAL_PAGE
Definition: ketypes.h:147
ULONG Edx
Definition: ketypes.h:303
BOOLEAN KiSMTProcessorsPresent
Definition: cpu.c:28
#define KF_CMOV
Definition: ketypes.h:146
#define X86_FEATURE_SSE3
Definition: ke.h:46
ULONG InitialApicId
Definition: ketypes.h:621

◆ KiGetLinkedTrapFrame()

FORCEINLINE PKTRAP_FRAME KiGetLinkedTrapFrame ( PKTRAP_FRAME  TrapFrame)

Definition at line 182 of file ke.h.

183 {
184  return (PKTRAP_FRAME)TrapFrame->TrapFrame;
185 }
UINT64 TrapFrame
Definition: ketypes.h:372

◆ KiGetUserModeStackAddress()

FORCEINLINE PULONG_PTR KiGetUserModeStackAddress ( void  )

Definition at line 447 of file ke.h.

448 {
449  return &PsGetCurrentThread()->Tcb.TrapFrame->Rsp;
450 }
#define PsGetCurrentThread()
Definition: env_spec_w32.h:81

Referenced by KeUserModeCallback().

◆ KiInitializeCpuFeatures()

VOID KiInitializeCpuFeatures ( VOID  )

◆ KiInvalidOpcodeFault()

VOID KiInvalidOpcodeFault ( VOID  )

◆ KiInvalidTssFault()

VOID KiInvalidTssFault ( VOID  )

◆ KiIpiInterrupt()

VOID KiIpiInterrupt ( VOID  )

◆ KiMcheckAbort()

VOID KiMcheckAbort ( VOID  )

◆ KiNmiInterrupt()

VOID KiNmiInterrupt ( VOID  )

◆ KiNpxNotAvailableFault()

VOID KiNpxNotAvailableFault ( VOID  )

◆ KiNpxSegmentOverrunAbort()

VOID KiNpxSegmentOverrunAbort ( VOID  )

◆ KiOverflowTrap()

VOID KiOverflowTrap ( VOID  )

◆ KiPageFault()

VOID KiPageFault ( VOID  )

◆ KiRaiseAssertion()

VOID KiRaiseAssertion ( VOID  )

◆ KiRundownThread()

FORCEINLINE VOID KiRundownThread ( IN PKTHREAD  Thread)

Definition at line 289 of file ke.h.

290 {
291  /* Nothing to do */
292 }

Referenced by KeTerminateThread().

◆ KiSegmentNotPresentFault()

VOID KiSegmentNotPresentFault ( VOID  )

◆ KiSendEOI()

FORCEINLINE VOID KiSendEOI ( VOID  )

Definition at line 342 of file ke.h.

343 {
344  /* Write 0 to the apic EOI register */
345  *((volatile ULONG*)APIC_EOI_REGISTER) = 0;
346 }
#define APIC_EOI_REGISTER
Definition: ke.h:83
unsigned int ULONG
Definition: retypes.h:1

Referenced by KiDpcInterruptHandler().

◆ KiSetProcessorType()

VOID KiSetProcessorType ( VOID  )

Definition at line 49 of file cpu.c.

50 {
51  CPU_INFO CpuInfo;
52  ULONG Stepping, Type;
53 
54  /* Do CPUID 1 now */
55  KiCpuId(&CpuInfo, 1);
56 
57  /*
58  * Get the Stepping and Type. The stepping contains both the
59  * Model and the Step, while the Type contains the returned Type.
60  * We ignore the family.
61  *
62  * For the stepping, we convert this: zzzzzzxy into this: x0y
63  */
64  Stepping = CpuInfo.Eax & 0xF0;
65  Stepping <<= 4;
66  Stepping += (CpuInfo.Eax & 0xFF);
67  Stepping &= 0xF0F;
68  Type = CpuInfo.Eax & 0xF00;
69  Type >>= 8;
70 
71  /* Save them in the PRCB */
72  KeGetCurrentPrcb()->CpuID = TRUE;
73  KeGetCurrentPrcb()->CpuType = (UCHAR)Type;
74  KeGetCurrentPrcb()->CpuStep = (USHORT)Stepping;
75 }
#define TRUE
Definition: types.h:120
FORCEINLINE struct _KPRCB * KeGetCurrentPrcb(VOID)
Definition: ketypes.h:1079
ULONG Eax
Definition: ketypes.h:300
Type
Definition: Type.h:6
unsigned char UCHAR
Definition: xmlstorage.h:181
unsigned short USHORT
Definition: pedump.c:61
unsigned int ULONG
Definition: retypes.h:1

◆ KiSetTrapContext()

VOID KiSetTrapContext ( _Out_ PKTRAP_FRAME  TrapFrame,
_In_ PCONTEXT  Context,
_In_ KPROCESSOR_MODE  RequestorMode 
)

Referenced by _IRQL_requires_().

◆ KiStackFault()

VOID KiStackFault ( VOID  )

◆ KiSwitchToBootStack()

DECLSPEC_NORETURN VOID KiSwitchToBootStack ( IN ULONG_PTR  InitialStack)

Definition at line 816 of file ke.h.

817 {
819 
820  /* We have to switch to a new stack before continuing kernel initialization */
821 #ifdef __GNUC__
822  __asm__
823  (
824  "movl %0, %%esp\n\t"
825  "subl %1, %%esp\n\t"
826  "pushl %2\n\t"
827  "jmp _KiSystemStartupBootStack@0"
828  :
829  : "c"(InitialStack),
831  "i"(CR0_EM | CR0_TS | CR0_MP),
833  : "%esp"
834  );
835 #elif defined(_MSC_VER)
836  __asm
837  {
838  mov esp, InitialStack
840  push (CR0_EM | CR0_TS | CR0_MP)
842  }
843 #else
844 #error Unknown Compiler
845 #endif
846 
847  UNREACHABLE;
848 }
#define CR0_EM
Definition: asm.h:247
#define NPX_FRAME_LENGTH
Definition: asm.h:246
DECLSPEC_NORETURN VOID NTAPI KiSystemStartupBootStack(VOID)
Definition: krnlinit.c:58
#define DECLSPEC_NORETURN
Definition: ntbasedef.h:176
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
__asm__("\t.globl GetPhys\n" "GetPhys:\t\n" "mflr 0\n\t" "stwu 0,-16(1)\n\t" "mfmsr 5\n\t" "andi. 6,5,0xffef\n\t" "mtmsr 6\n\t" "isync\n\t" "sync\n\t" "lwz 3,0(3)\n\t" "mtmsr 5\n\t" "isync\n\t" "sync\n\t" "lwz 0,0(1)\n\t" "addi 1,1,16\n\t" "mtlr 0\n\t" "blr")
CODE_SEG("INIT")
Definition: Interface.c:1810
#define CR0_TS
Definition: asm.h:248
#define UNREACHABLE
#define KTRAP_FRAME_LENGTH
Definition: asm.h:126
static void push(calc_node_t *op)
Definition: rpn_ieee.c:113
#define CR0_MP
Definition: asm.h:246
#define KTRAP_FRAME_ALIGN
Definition: asm.h:125
jmp_buf jmp
Definition: mach.c:35

Referenced by KiSystemStartup().

◆ KiUserTrap()

◆ KiXmmException()

VOID KiXmmException ( VOID  )

◆ NtEarlyInitVdm()

VOID NtEarlyInitVdm ( VOID  )

Variable Documentation

◆ KeI386CpuStep

ULONG KeI386CpuStep

Definition at line 23 of file cpu.c.

Referenced by KiInitializeKernel(), and KiInitializeKernelMachineDependent().

◆ KeI386CpuType

ULONG KeI386CpuType

Definition at line 22 of file cpu.c.

Referenced by KiInitializeKernel(), and KiInitializeKernelMachineDependent().

◆ KeI386FxsrPresent

◆ KeI386NpxPresent

◆ KeI386XMMIPresent

ULONG KeI386XMMIPresent

Definition at line 30 of file cpu.c.

Referenced by KiInitializeKernel(), and KiInitMachineDependent().

◆ KeTickCount