ReactOS 0.4.16-dev-287-g2d3f3a1
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 | 0x40L)
 
#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)
 
FORCEINLINE ULONG KeGetCurrentProcessorIndex (VOID)
 
$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

◆ APC_LEVEL

#define APC_LEVEL   1

◆ CLOCK_LEVEL

#define CLOCK_LEVEL   13

◆ CMCI_LEVEL

#define CMCI_LEVEL   5

◆ CONTEXT_ALL

◆ CONTEXT_AMD64

#define CONTEXT_AMD64   0x100000

◆ CONTEXT_CONTROL

#define CONTEXT_CONTROL   (CONTEXT_AMD64 | 0x1L)

◆ CONTEXT_DEBUG_REGISTERS

#define CONTEXT_DEBUG_REGISTERS   (CONTEXT_AMD64 | 0x10L)

◆ CONTEXT_EXCEPTION_ACTIVE

#define CONTEXT_EXCEPTION_ACTIVE   0x8000000

◆ CONTEXT_EXCEPTION_REPORTING

#define CONTEXT_EXCEPTION_REPORTING   0x80000000

◆ CONTEXT_EXCEPTION_REQUEST

#define CONTEXT_EXCEPTION_REQUEST   0x40000000

◆ CONTEXT_FLOATING_POINT

#define CONTEXT_FLOATING_POINT   (CONTEXT_AMD64 | 0x8L)

◆ CONTEXT_FULL

◆ CONTEXT_INTEGER

#define CONTEXT_INTEGER   (CONTEXT_AMD64 | 0x2L)

◆ CONTEXT_SEGMENTS

#define CONTEXT_SEGMENTS   (CONTEXT_AMD64 | 0x4L)

◆ CONTEXT_SERVICE_ACTIVE

#define CONTEXT_SERVICE_ACTIVE   0x10000000

◆ CONTEXT_XSTATE

#define CONTEXT_XSTATE   (CONTEXT_AMD64 | 0x40L)

◆ DbgRaiseAssertionFailure

#define DbgRaiseAssertionFailure   __int2c

Definition at line 177 of file ke.h.

◆ DISPATCH_LEVEL

#define DISPATCH_LEVEL   2

◆ DRS_LEVEL

#define DRS_LEVEL   14

◆ EFLAG_SELECT

#define EFLAG_SELECT   (EFLAG_SIGN | EFLAG_ZERO)

◆ EFLAG_SIGN

#define EFLAG_SIGN   0x8000

◆ EFLAG_ZERO

#define EFLAG_ZERO   0x4000

◆ EXCEPTION_EXECUTE_FAULT

#define EXCEPTION_EXECUTE_FAULT   8

◆ EXCEPTION_READ_FAULT

#define EXCEPTION_READ_FAULT   0

◆ EXCEPTION_WRITE_FAULT

#define EXCEPTION_WRITE_FAULT   1

◆ FastFence

#define FastFence   __faststorefence

Definition at line 50 of file ke.h.

◆ HIGH_LEVEL

#define HIGH_LEVEL   15

◆ INITIAL_FPCSR

#define INITIAL_FPCSR   0x027f

◆ INITIAL_MXCSR

#define INITIAL_MXCSR   0x1f80

◆ IPI_LEVEL

#define IPI_LEVEL   14

◆ KeFlushIoBuffers

#define KeFlushIoBuffers (   _Mdl,
  _ReadOperation,
  _DmaOperation 
)

Definition at line 174 of file ke.h.

◆ KeGetDcacheFillSize

#define KeGetDcacheFillSize ( )    1L

Definition at line 46 of file ke.h.

◆ KeMemoryBarrierWithoutFence

#define KeMemoryBarrierWithoutFence ( )    _ReadWriteBarrier()

Definition at line 66 of file ke.h.

◆ KeQueryInterruptTime

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

Definition at line 37 of file ke.h.

◆ KeQuerySystemTime

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

Definition at line 40 of file ke.h.

◆ KeQueryTickCount

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

Definition at line 43 of file ke.h.

◆ KeRaiseIrql

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

Definition at line 102 of file ke.h.

◆ KERNEL_LARGE_STACK_COMMIT

#define KERNEL_LARGE_STACK_COMMIT   KERNEL_STACK_SIZE

◆ KERNEL_LARGE_STACK_SIZE

#define KERNEL_LARGE_STACK_SIZE   0x12000

◆ KERNEL_MCA_EXCEPTION_STACK_SIZE

#define KERNEL_MCA_EXCEPTION_STACK_SIZE   0x2000

◆ KERNEL_STACK_SIZE

#define KERNEL_STACK_SIZE   0x6000

◆ KI_USER_SHARED_DATA

#define KI_USER_SHARED_DATA   0xFFFFF78000000000ULL

◆ LFENCE_ACQUIRE

#define LFENCE_ACQUIRE ( )    LoadFence()

Definition at line 54 of file ke.h.

◆ LoadFence

#define LoadFence   _mm_lfence

Definition at line 51 of file ke.h.

◆ LOW_LEVEL

#define LOW_LEVEL   0

◆ MemoryBarrier

#define MemoryBarrier   __faststorefence

Definition at line 49 of file ke.h.

◆ MemoryFence

#define MemoryFence   _mm_mfence

Definition at line 52 of file ke.h.

◆ PAGE_SHIFT

#define PAGE_SHIFT   12L

◆ PAGE_SIZE

#define PAGE_SIZE   0x1000

◆ PASSIVE_LEVEL

#define PASSIVE_LEVEL   0

◆ PAUSE_PROCESSOR

#define PAUSE_PROCESSOR   YieldProcessor();

◆ PCR_MAJOR_VERSION

#define PCR_MAJOR_VERSION   1

Definition at line 291 of file ke.h.

◆ PCR_MINOR_VERSION

#define PCR_MINOR_VERSION   1

Definition at line 290 of file ke.h.

◆ POWER_LEVEL

#define POWER_LEVEL   14

◆ PROFILE_LEVEL

#define PROFILE_LEVEL   15

◆ SharedInterruptTime

#define SharedInterruptTime   (KI_USER_SHARED_DATA + 0x8)

◆ SharedSystemTime

#define SharedSystemTime   (KI_USER_SHARED_DATA + 0x14)

◆ SharedTickCount

#define SharedTickCount   (KI_USER_SHARED_DATA + 0x320)

◆ SharedUserData

◆ StoreFence

#define StoreFence   _mm_sfence

Definition at line 53 of file ke.h.

◆ YieldProcessor

#define YieldProcessor   _mm_pause

Definition at line 48 of file ke.h.

Typedef Documentation

◆ KPCR

typedef struct _KPCR KPCR

◆ PKPCR

typedef struct _KPCR * PKPCR

◆ PXMM_SAVE_AREA32

Definition at line 35 of file ke.h.

◆ XMM_SAVE_AREA32

Definition at line 35 of file ke.h.

Function Documentation

◆ $if() [1/2]

$endif $if ( _NTDDK_  )

Definition at line 180 of file ke.h.

219 {
220 ULONG64 P1Home;
221 ULONG64 P2Home;
222 ULONG64 P3Home;
223 ULONG64 P4Home;
224 ULONG64 P5Home;
225 ULONG64 P6Home;
226 ULONG ContextFlags;
227 ULONG MxCsr;
228 USHORT SegCs;
229 USHORT SegDs;
230 USHORT SegEs;
231 USHORT SegFs;
232 USHORT SegGs;
233 USHORT SegSs;
234 ULONG EFlags;
235 ULONG64 Dr0;
236 ULONG64 Dr1;
237 ULONG64 Dr2;
238 ULONG64 Dr3;
239 ULONG64 Dr6;
240 ULONG64 Dr7;
241 ULONG64 Rax;
242 ULONG64 Rcx;
243 ULONG64 Rdx;
244 ULONG64 Rbx;
245 ULONG64 Rsp;
246 ULONG64 Rbp;
247 ULONG64 Rsi;
248 ULONG64 Rdi;
249 ULONG64 R8;
250 ULONG64 R9;
251 ULONG64 R10;
252 ULONG64 R11;
253 ULONG64 R12;
254 ULONG64 R13;
255 ULONG64 R14;
256 ULONG64 R15;
257 ULONG64 Rip;
258 union {
259 XMM_SAVE_AREA32 FltSave;
260 struct {
261 M128A Header[2];
262 M128A Legacy[8];
263 M128A Xmm0;
264 M128A Xmm1;
265 M128A Xmm2;
266 M128A Xmm3;
267 M128A Xmm4;
268 M128A Xmm5;
269 M128A Xmm6;
270 M128A Xmm7;
271 M128A Xmm8;
272 M128A Xmm9;
273 M128A Xmm10;
274 M128A Xmm11;
275 M128A Xmm12;
276 M128A Xmm13;
277 M128A Xmm14;
278 M128A Xmm15;
281 M128A VectorRegister[26];
282 ULONG64 VectorControl;
283 ULONG64 DebugControl;
284 ULONG64 LastBranchToRip;
285 ULONG64 LastBranchFromRip;
286 ULONG64 LastExceptionToRip;
287 ULONG64 LastExceptionFromRip;
288} CONTEXT;
@ R15
Definition: amd64_sup.c:13
@ R13
Definition: amd64_sup.c:13
@ R12
Definition: amd64_sup.c:13
@ R9
Definition: amd64_sup.c:13
@ R14
Definition: amd64_sup.c:13
@ R8
Definition: amd64_sup.c:13
@ R11
Definition: amd64_sup.c:13
@ R10
Definition: amd64_sup.c:13
Definition: Header.h:9
unsigned __int64 ULONG64
Definition: imports.h:198
#define DECLSPEC_ALIGN(x)
Definition: ntbasedef.h:259
#define DUMMYUNIONNAME
Definition: ntbasedef.h:32
#define DUMMYSTRUCTNAME
Definition: ntbasedef.h:58
unsigned short USHORT
Definition: pedump.c:61
XSAVE_FORMAT XMM_SAVE_AREA32
Definition: ke.h:35
CONTEXT
Definition: ke.h:288
uint32_t ULONG
Definition: typedefs.h:59
M128A
Definition: ketypes.h:937

◆ $if() [2/2]

$if ( _WDMDDK_  )

Kernel definitions for AMD64

Definition at line 1 of file ke.h.

31{
32 ULONG Dummy;
KFLOATING_SAVE
Definition: ke.h:33
* PKFLOATING_SAVE
Definition: ke.h:33

◆ _Always_()

_Always_ ( _Post_satisfies_(return<=0)  )

◆ _IRQL_requires_max_() [1/2]

_IRQL_requires_max_ ( DISPATCH_LEVEL  )

Definition at line 104 of file ke.h.

111{
113}
KIRQL FASTCALL KfRaiseIrql(IN KIRQL NewIrql)
Definition: pic.c:187
#define DISPATCH_LEVEL

◆ _IRQL_requires_max_() [2/2]

_IRQL_requires_max_ ( HIGH_LEVEL  )

Definition at line 68 of file ke.h.

73{
74 return (KIRQL)__readcr8();
75}
UCHAR KIRQL
Definition: env_spec_w32.h:591

◆ _Kernel_requires_resource_held_()

_Kernel_requires_resource_held_ ( FloatState  )

Definition at line 149 of file ke.h.

154{
155 UNREFERENCED_PARAMETER(FloatSave);
156 return STATUS_SUCCESS;
157}
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:325
#define STATUS_SUCCESS
Definition: shellext.h:65

◆ _Kernel_requires_resource_not_held_()

_Kernel_requires_resource_not_held_ ( FloatState  )

Definition at line 137 of file ke.h.

142{
143 UNREFERENCED_PARAMETER(FloatSave);
144 return STATUS_SUCCESS;
145}

◆ _Success_()

_Success_ ( )

◆ KeGetCurrentProcessorIndex()

FORCEINLINE ULONG KeGetCurrentProcessorIndex ( VOID  )

Definition at line 162 of file ke.h.

163{
164 return __readgsdword(0x1a4);
165}

Referenced by _FX_DRIVER_TRACKER_CACHE_AWARE::GetCurrentTrackedDriver(), and _FX_DRIVER_TRACKER_CACHE_AWARE::TrackDriver().

◆ KeGetCurrentProcessorNumber()

◆ KeGetCurrentThread()

FORCEINLINE PKTHREAD KeGetCurrentThread ( VOID  )

Definition at line 128 of file ke.h.

129{
130 return (struct _KTHREAD *)__readgsqword(0x188);
131}

◆ KeGetPcr()

FORCEINLINE PKPCR KeGetPcr ( VOID  )

Definition at line 331 of file ke.h.

332{
333 return (PKPCR)__readgsqword(FIELD_OFFSET(KPCR, Self));
334}
Definition: ke.h:294
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255

◆ KeMemoryBarrier()

◆ KeRaiseIrqlToSynchLevel()

FORCEINLINE KIRQL KeRaiseIrqlToSynchLevel ( VOID  )

Definition at line 117 of file ke.h.

118{
119#ifdef CONFIG_SMP
120 return KfRaiseIrql(12); // SYNCH_LEVEL = IPI_LEVEL - 2
121#else
122 return KfRaiseIrql(2); // SYNCH_LEVEL = DISPATCH_LEVEL
123#endif
124}

Variable Documentation

◆ CONTEXT

Definition at line 288 of file ke.h.

◆ KFLOATING_SAVE

Definition at line 33 of file ke.h.

◆ PKFLOATING_SAVE

Definition at line 33 of file ke.h.