ReactOS  r74006
ke.h File Reference

Go to the source code of this file.

Classes

struct  _KPCR
 

Macros

#define PASSIVE_LEVEL   0
 
#define LOW_LEVEL   0
 
#define APC_LEVEL   1
 
#define DISPATCH_LEVEL   2
 
#define CMCI_LEVEL   5
 
#define CLOCK_LEVEL   13
 
#define IPI_LEVEL   14
 
#define DRS_LEVEL   14
 
#define POWER_LEVEL   14
 
#define PROFILE_LEVEL   15
 
#define HIGH_LEVEL   15
 
#define KI_USER_SHARED_DATA   0xFFFFF78000000000ULL
 
#define SharedUserData   ((KUSER_SHARED_DATA * const)KI_USER_SHARED_DATA)
 
#define SharedInterruptTime   (KI_USER_SHARED_DATA + 0x8)
 
#define SharedSystemTime   (KI_USER_SHARED_DATA + 0x14)
 
#define SharedTickCount   (KI_USER_SHARED_DATA + 0x320)
 
#define PAGE_SIZE   0x1000
 
#define PAGE_SHIFT   12L
 
#define EFLAG_SIGN   0x8000
 
#define EFLAG_ZERO   0x4000
 
#define EFLAG_SELECT   (EFLAG_SIGN | EFLAG_ZERO)
 
#define KeQueryInterruptTime()   (*(volatile ULONG64*)SharedInterruptTime)
 
#define KeQuerySystemTime(CurrentCount)   *(ULONG64*)(CurrentCount) = *(volatile ULONG64*)SharedSystemTime
 
#define KeQueryTickCount(CurrentCount)   *(ULONG64*)(CurrentCount) = *(volatile ULONG64*)SharedTickCount
 
#define KeGetDcacheFillSize()   1L
 
#define YieldProcessor   _mm_pause
 
#define MemoryBarrier   __faststorefence
 
#define FastFence   __faststorefence
 
#define LoadFence   _mm_lfence
 
#define MemoryFence   _mm_mfence
 
#define StoreFence   _mm_sfence
 
#define LFENCE_ACQUIRE()   LoadFence()
 
#define KeMemoryBarrierWithoutFence()   _ReadWriteBarrier()
 
#define KeRaiseIrql(a, b)   *(b) = KfRaiseIrql(a)
 
#define KeFlushIoBuffers(_Mdl, _ReadOperation, _DmaOperation)
 
#define DbgRaiseAssertionFailure   __int2c
 
#define PAUSE_PROCESSOR   YieldProcessor();
 
#define KERNEL_STACK_SIZE   0x6000
 
#define KERNEL_LARGE_STACK_SIZE   0x12000
 
#define KERNEL_LARGE_STACK_COMMIT   KERNEL_STACK_SIZE
 
#define KERNEL_MCA_EXCEPTION_STACK_SIZE   0x2000
 
#define EXCEPTION_READ_FAULT   0
 
#define EXCEPTION_WRITE_FAULT   1
 
#define EXCEPTION_EXECUTE_FAULT   8
 
#define CONTEXT_AMD64   0x100000
 
#define CONTEXT_CONTROL   (CONTEXT_AMD64 | 0x1L)
 
#define CONTEXT_INTEGER   (CONTEXT_AMD64 | 0x2L)
 
#define CONTEXT_SEGMENTS   (CONTEXT_AMD64 | 0x4L)
 
#define CONTEXT_FLOATING_POINT   (CONTEXT_AMD64 | 0x8L)
 
#define CONTEXT_DEBUG_REGISTERS   (CONTEXT_AMD64 | 0x10L)
 
#define CONTEXT_FULL   (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT)
 
#define CONTEXT_ALL   (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS)
 
#define CONTEXT_XSTATE   (CONTEXT_AMD64 | 0x20L)
 
#define CONTEXT_EXCEPTION_ACTIVE   0x8000000
 
#define CONTEXT_SERVICE_ACTIVE   0x10000000
 
#define CONTEXT_EXCEPTION_REQUEST   0x40000000
 
#define CONTEXT_EXCEPTION_REPORTING   0x80000000
 
#define INITIAL_MXCSR   0x1f80
 
#define INITIAL_FPCSR   0x027f
 
#define PCR_MINOR_VERSION   1
 
#define PCR_MAJOR_VERSION   1
 

Typedefs

typedef XSAVE_FORMAT XMM_SAVE_AREA32
 
typedef XSAVE_FORMATPXMM_SAVE_AREA32
 
typedef struct _KPCR KPCR
 
typedef struct _KPCRPKPCR
 

Functions

 $if (_WDMDDK_) typedef struct _KFLOATING_SAVE
 
FORCEINLINE VOID KeMemoryBarrier (VOID)
 
 _IRQL_requires_max_ (HIGH_LEVEL) _IRQL_saves_ FORCEINLINE KIRQL KeGetCurrentIrql(VOID)
 
 _IRQL_requires_max_ (DISPATCH_LEVEL) _IRQL_saves_ _IRQL_raises_(DISPATCH_LEVEL) FORCEINLINE KIRQL KeRaiseIrqlToDpcLevel(VOID)
 
FORCEINLINE KIRQL KeRaiseIrqlToSynchLevel (VOID)
 
FORCEINLINE PKTHREAD KeGetCurrentThread (VOID)
 
 _Always_ (_Post_satisfies_(return<=0)) _Must_inspect_result_ _IRQL_requires_max_(DISPATCH_LEVEL) _Kernel_float_saved_ _At_(*FloatSave
 
 _Kernel_requires_resource_not_held_ (FloatState) _Kernel_acquires_resource_(FloatState)) FORCEINLINE NTSTATUS KeSaveFloatingPointState(_Out_ PKFLOATING_SAVE FloatSave)
 
 _Success_ (1) _Kernel_float_restored_ _At_(*FloatSave
 
 _Kernel_requires_resource_held_ (FloatState) _Kernel_releases_resource_(FloatState)) FORCEINLINE NTSTATUS KeRestoreFloatingPointState(_In_ PKFLOATING_SAVE FloatSave)
 
$endif $if (_NTDDK_) typedef struct DECLSPEC_ALIGN(16) _CONTEXT
 
FORCEINLINE PKPCR KeGetPcr (VOID)
 
FORCEINLINE ULONG KeGetCurrentProcessorNumber (VOID)
 

Variables

 KFLOATING_SAVE
 
PKFLOATING_SAVE
 
 CONTEXT
 

Macro Definition Documentation

#define APC_LEVEL   1

Referenced by KiCheckForApcDelivery().

#define CLOCK_LEVEL   13
#define CMCI_LEVEL   5

Referenced by __declspec().

#define CONTEXT_AMD64   0x100000
#define CONTEXT_CONTROL   (CONTEXT_AMD64 | 0x1L)
#define CONTEXT_DEBUG_REGISTERS   (CONTEXT_AMD64 | 0x10L)
#define CONTEXT_EXCEPTION_ACTIVE   0x8000000
#define CONTEXT_EXCEPTION_REPORTING   0x80000000
#define CONTEXT_EXCEPTION_REQUEST   0x40000000
#define CONTEXT_FLOATING_POINT   (CONTEXT_AMD64 | 0x8L)
#define CONTEXT_INTEGER   (CONTEXT_AMD64 | 0x2L)
#define CONTEXT_SEGMENTS   (CONTEXT_AMD64 | 0x4L)
#define CONTEXT_SERVICE_ACTIVE   0x10000000
#define CONTEXT_XSTATE   (CONTEXT_AMD64 | 0x20L)
#define DbgRaiseAssertionFailure   __int2c

Definition at line 164 of file ke.h.

Referenced by _assert().

#define DISPATCH_LEVEL   2

Referenced by _IRQL_requires_max_().

#define DRS_LEVEL   14
#define EFLAG_SELECT   (EFLAG_SIGN | EFLAG_ZERO)
#define EFLAG_SIGN   0x8000
#define EFLAG_ZERO   0x4000
#define EXCEPTION_EXECUTE_FAULT   8
#define EXCEPTION_READ_FAULT   0
#define EXCEPTION_WRITE_FAULT   1
#define FastFence   __faststorefence

Definition at line 50 of file ke.h.

Referenced by KeMemoryBarrier().

#define HIGH_LEVEL   15
#define INITIAL_FPCSR   0x027f
#define INITIAL_MXCSR   0x1f80
#define IPI_LEVEL   14
#define KeFlushIoBuffers (   _Mdl,
  _ReadOperation,
  _DmaOperation 
)
#define KeGetDcacheFillSize ( )    1L

Definition at line 46 of file ke.h.

#define KeQueryInterruptTime ( )    (*(volatile ULONG64*)SharedInterruptTime)

Definition at line 37 of file ke.h.

#define KeQuerySystemTime (   CurrentCount)    *(ULONG64*)(CurrentCount) = *(volatile ULONG64*)SharedSystemTime

Definition at line 40 of file ke.h.

#define KeQueryTickCount (   CurrentCount)    *(ULONG64*)(CurrentCount) = *(volatile ULONG64*)SharedTickCount

Definition at line 43 of file ke.h.

#define KeRaiseIrql (   a,
  b 
)    *(b) = KfRaiseIrql(a)

Definition at line 102 of file ke.h.

#define KERNEL_LARGE_STACK_COMMIT   KERNEL_STACK_SIZE
#define KERNEL_LARGE_STACK_SIZE   0x12000

Referenced by MmArmInitSystem().

#define KERNEL_MCA_EXCEPTION_STACK_SIZE   0x2000
#define KI_USER_SHARED_DATA   0xFFFFF78000000000ULL
#define LFENCE_ACQUIRE ( )    LoadFence()

Definition at line 54 of file ke.h.

Referenced by KeMemoryBarrier().

#define LoadFence   _mm_lfence

Definition at line 51 of file ke.h.

#define LOW_LEVEL   0
#define MemoryBarrier   __faststorefence

Definition at line 49 of file ke.h.

#define MemoryFence   _mm_mfence

Definition at line 52 of file ke.h.

#define PAGE_SHIFT   12L
#define PAGE_SIZE   0x1000
#define PASSIVE_LEVEL   0
#define PAUSE_PROCESSOR   YieldProcessor();
#define PCR_MAJOR_VERSION   1

Definition at line 278 of file ke.h.

Referenced by KiInitializePcr().

#define PCR_MINOR_VERSION   1

Definition at line 277 of file ke.h.

Referenced by KiInitializePcr().

#define POWER_LEVEL   14
#define PROFILE_LEVEL   15
#define SharedInterruptTime   (KI_USER_SHARED_DATA + 0x8)
#define SharedSystemTime   (KI_USER_SHARED_DATA + 0x14)
#define SharedTickCount   (KI_USER_SHARED_DATA + 0x320)

Referenced by BaseInitializeContext(), BasepCheckWebBladeHashes(), BasepIsImageVersionOk(), BasepIsProcessAllowed(), BaseProcessInitPostImport(), CmpInitializeMachineDependentConfiguration(), CreateProcessInternalW(), DisplayBootBitmap(), DosKRNLInitialize(), EngGetTickCount(), ExIsProcessorFeaturePresent(), ExpInitializeExecutive(), ExpLoadBootSymbols(), ExpSetTimeZoneInformation(), ExRefreshTimeZoneInformation(), FileTimeToLocalFileTime(), find_actctx_dll(), GetLargePageMinimum(), GetLocalTime(), GetSystemTime(), GetSystemTimeAsFileTime(), GetSystemVersionString(), GetTickCount(), GetTickCount64(), IopDeviceFsIoControl(), IopStartRamdisk(), IsProcessorFeaturePresent(), KdDisableDebugger(), KdDisableDebuggerWithLock(), KdEnableDebugger(), KdInitSystem(), KdpGetDebugMode(), KdpReceivePacketLeader(), KdReceivePacket(), KdSendPacket(), KeQueryInterruptTime(), KeQuerySystemTime(), KeSetSystemTime(), KeUpdateSystemTime(), KiInitializeCpu(), KiInitializeKernel(), KiInitializeKernelMachineDependent(), KiInitMachineDependent(), LdrpInit(), LdrpInitializeProcess(), LdrpInitSecurityCookie(), LdrShutdownProcess(), LdrShutdownThread(), LocalFileTimeToFileTime(), lookup_winsxs(), MmArmInitSystem(), MmLoadSystemImage(), Phase1InitializationDiscard(), PspLookupKernelUserEntryPoints(), PspUserThreadStartup(), RtlEncodeSystemPointer(), RtlGetNtProductType(), RtlGetTickCount(), RtlGetVersion(), SetLocalTime(), SimpleErrorChecks(), SmpCreateVolumeDescriptors(), SmpParseCommandLine(), SmpValidatePagingFileSizes(), UnhandledExceptionFilter(), and WTSGetActiveConsoleSessionId().

#define StoreFence   _mm_sfence

Definition at line 53 of file ke.h.

#define YieldProcessor   _mm_pause

Definition at line 48 of file ke.h.

Typedef Documentation

typedef struct _KPCR KPCR
typedef struct _KPCR * PKPCR

Definition at line 35 of file ke.h.

Definition at line 35 of file ke.h.

Function Documentation

$if ( _WDMDDK_  )

Kernel definitions for AMD64

Definition at line 1 of file ke.h.

31 {
32  ULONG Dummy;
struct _KFLOATING_SAVE KFLOATING_SAVE
struct _KFLOATING_SAVE * PKFLOATING_SAVE
unsigned int ULONG
Definition: retypes.h:1
$endif $if ( _NTDDK_  )

Definition at line 167 of file ke.h.

206  {
207  ULONG64 P1Home;
208  ULONG64 P2Home;
209  ULONG64 P3Home;
210  ULONG64 P4Home;
211  ULONG64 P5Home;
212  ULONG64 P6Home;
213  ULONG ContextFlags;
214  ULONG MxCsr;
215  USHORT SegCs;
216  USHORT SegDs;
217  USHORT SegEs;
218  USHORT SegFs;
219  USHORT SegGs;
220  USHORT SegSs;
221  ULONG EFlags;
222  ULONG64 Dr0;
223  ULONG64 Dr1;
224  ULONG64 Dr2;
225  ULONG64 Dr3;
226  ULONG64 Dr6;
227  ULONG64 Dr7;
228  ULONG64 Rax;
229  ULONG64 Rcx;
230  ULONG64 Rdx;
231  ULONG64 Rbx;
232  ULONG64 Rsp;
233  ULONG64 Rbp;
234  ULONG64 Rsi;
235  ULONG64 Rdi;
236  ULONG64 R8;
237  ULONG64 R9;
238  ULONG64 R10;
239  ULONG64 R11;
240  ULONG64 R12;
241  ULONG64 R13;
242  ULONG64 R14;
243  ULONG64 R15;
244  ULONG64 Rip;
245  union {
246  XMM_SAVE_AREA32 FltSave;
247  struct {
248  M128A Header[2];
249  M128A Legacy[8];
250  M128A Xmm0;
251  M128A Xmm1;
252  M128A Xmm2;
253  M128A Xmm3;
254  M128A Xmm4;
255  M128A Xmm5;
256  M128A Xmm6;
257  M128A Xmm7;
258  M128A Xmm8;
259  M128A Xmm9;
260  M128A Xmm10;
261  M128A Xmm11;
262  M128A Xmm12;
263  M128A Xmm13;
264  M128A Xmm14;
265  M128A Xmm15;
266  } DUMMYSTRUCTNAME;
267  } DUMMYUNIONNAME;
268  M128A VectorRegister[26];
269  ULONG64 VectorControl;
270  ULONG64 DebugControl;
271  ULONG64 LastBranchToRip;
272  ULONG64 LastBranchFromRip;
273  ULONG64 LastExceptionToRip;
274  ULONG64 LastExceptionFromRip;
275 } CONTEXT;
M128A
Definition: ketypes.h:903
#define DUMMYUNIONNAME
Definition: ntbasedef.h:32
Definition: Header.h:8
uint64_t ULONG64
Definition: typedefs.h:66
struct _CONTEXT CONTEXT
unsigned short USHORT
Definition: pedump.c:61
XSAVE_FORMAT XMM_SAVE_AREA32
Definition: ke.h:35
unsigned int ULONG
Definition: retypes.h:1
#define DUMMYSTRUCTNAME
Definition: ntbasedef.h:58
_Always_ ( _Post_satisfies_(return<=0)  )
_IRQL_requires_max_ ( HIGH_LEVEL  )

Definition at line 68 of file ke.h.

73 {
74  return (KIRQL)__readcr8();
75 }
__INTRIN_INLINE unsigned long __readcr8(void)
Definition: intrin_x86.h:1615
UCHAR KIRQL
Definition: env_spec_w32.h:591
_IRQL_requires_max_ ( DISPATCH_LEVEL  )

Definition at line 104 of file ke.h.

111 {
112  return KfRaiseIrql(DISPATCH_LEVEL);
113 }
#define DISPATCH_LEVEL
NTKERNELAPI KIRQL NTAPI KfRaiseIrql(IN KIRQL NewIrql)
Definition: pic.c:187
_Kernel_requires_resource_held_ ( FloatState  )

Definition at line 145 of file ke.h.

150 {
151  UNREFERENCED_PARAMETER(FloatSave);
152  return STATUS_SUCCESS;
153 }
#define STATUS_SUCCESS
Definition: contextmenu.cpp:55
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:315
_Kernel_requires_resource_not_held_ ( FloatState  )

Definition at line 133 of file ke.h.

138 {
139  UNREFERENCED_PARAMETER(FloatSave);
140  return STATUS_SUCCESS;
141 }
#define STATUS_SUCCESS
Definition: contextmenu.cpp:55
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:315
_Success_ ( )
FORCEINLINE PKTHREAD KeGetCurrentThread ( VOID  )

Definition at line 124 of file ke.h.

125 {
126  return (struct _KTHREAD *)__readgsqword(0x188);
127 }
FORCEINLINE PKPCR KeGetPcr ( VOID  )

Definition at line 318 of file ke.h.

Referenced by KeGetCurrentProcessorNumber(), KeGetCurrentThread(), KeQueryInterruptHandler(), and KeRegisterInterruptHandler().

319 {
320  return (PKPCR)__readgsqword(FIELD_OFFSET(KPCR, Self));
321 }
Definition: ke.h:280
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
FORCEINLINE VOID KeMemoryBarrier ( VOID  )

Definition at line 58 of file ke.h.

60 {
61  // FIXME: Do we really need lfence after the __faststorefence ?
62  FastFence();
64 }
#define LFENCE_ACQUIRE()
Definition: ke.h:54
#define FastFence
Definition: ke.h:50
FORCEINLINE KIRQL KeRaiseIrqlToSynchLevel ( VOID  )

Definition at line 117 of file ke.h.

118 {
119  return KfRaiseIrql(12); // SYNCH_LEVEL = IPI_LEVEL - 2
120 }
NTKERNELAPI KIRQL NTAPI KfRaiseIrql(IN KIRQL NewIrql)
Definition: pic.c:187

Variable Documentation

Definition at line 275 of file ke.h.

Definition at line 33 of file ke.h.

Definition at line 33 of file ke.h.