ReactOS 0.4.15-dev-7918-g2a2556c
ke.h
Go to the documentation of this file.
4/* Interrupt request levels */
5#define PASSIVE_LEVEL 0
6#define LOW_LEVEL 0
7#define APC_LEVEL 1
8#define DISPATCH_LEVEL 2
9#define CMCI_LEVEL 5
10#define CLOCK_LEVEL 13
11#define IPI_LEVEL 14
12#define DRS_LEVEL 14
13#define POWER_LEVEL 14
14#define PROFILE_LEVEL 15
15#define HIGH_LEVEL 15
16
17#define KI_USER_SHARED_DATA 0xFFFFF78000000000ULL
18#define SharedUserData ((KUSER_SHARED_DATA * const)KI_USER_SHARED_DATA)
19#define SharedInterruptTime (KI_USER_SHARED_DATA + 0x8)
20#define SharedSystemTime (KI_USER_SHARED_DATA + 0x14)
21#define SharedTickCount (KI_USER_SHARED_DATA + 0x320)
22
23#define PAGE_SIZE 0x1000
24#define PAGE_SHIFT 12L
25
26#define EFLAG_SIGN 0x8000
27#define EFLAG_ZERO 0x4000
28#define EFLAG_SELECT (EFLAG_SIGN | EFLAG_ZERO)
29
30typedef struct _KFLOATING_SAVE
31{
34
36
37#define KeQueryInterruptTime() \
38 (*(volatile ULONG64*)SharedInterruptTime)
39
40#define KeQuerySystemTime(CurrentCount) \
41 *(ULONG64*)(CurrentCount) = *(volatile ULONG64*)SharedSystemTime
42
43#define KeQueryTickCount(CurrentCount) \
44 *(ULONG64*)(CurrentCount) = *(volatile ULONG64*)SharedTickCount
45
46#define KeGetDcacheFillSize() 1L
47
48#define YieldProcessor _mm_pause
49#define MemoryBarrier __faststorefence
50#define FastFence __faststorefence
51#define LoadFence _mm_lfence
52#define MemoryFence _mm_mfence
53#define StoreFence _mm_sfence
54#define LFENCE_ACQUIRE() LoadFence()
55
57VOID
59 VOID)
60{
61 // FIXME: Do we really need lfence after the __faststorefence ?
62 FastFence();
64}
65
66#define KeMemoryBarrierWithoutFence() _ReadWriteBarrier()
67
73{
74 return (KIRQL)__readcr8();
75}
76
79VOID
82{
83 //ASSERT((KIRQL)__readcr8() >= NewIrql);
84 __writecr8(NewIrql);
85}
86
94{
96
97 OldIrql = (KIRQL)__readcr8();
98 //ASSERT(OldIrql <= NewIrql);
99 __writecr8(NewIrql);
100 return OldIrql;
101}
102#define KeRaiseIrql(a,b) *(b) = KfRaiseIrql(a)
103
108KIRQL
110 VOID)
111{
113}
114
116KIRQL
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}
125
129{
130 return (struct _KTHREAD *)__readgsqword(0x188);
131}
132
141 _Out_ PKFLOATING_SAVE FloatSave)
142{
143 UNREFERENCED_PARAMETER(FloatSave);
144 return STATUS_SUCCESS;
145}
146
153 _In_ PKFLOATING_SAVE FloatSave)
154{
155 UNREFERENCED_PARAMETER(FloatSave);
156 return STATUS_SUCCESS;
157}
158
159#if (NTDDI_VERSION >= NTDDI_WIN7)
161ULONG
163{
164 return __readgsdword(0x1a4);
165}
166#endif
167
168/* VOID
169 * KeFlushIoBuffers(
170 * IN PMDL Mdl,
171 * IN BOOLEAN ReadOperation,
172 * IN BOOLEAN DmaOperation)
173 */
174#define KeFlushIoBuffers(_Mdl, _ReadOperation, _DmaOperation)
175
176/* x86 and x64 performs a 0x2C interrupt */
177#define DbgRaiseAssertionFailure __int2c
178
179$endif /* _WDMDDK_ */
181
182#define PAUSE_PROCESSOR YieldProcessor();
183
184#define KERNEL_STACK_SIZE 0x6000
185#define KERNEL_LARGE_STACK_SIZE 0x12000
186#define KERNEL_LARGE_STACK_COMMIT KERNEL_STACK_SIZE
187
188#define KERNEL_MCA_EXCEPTION_STACK_SIZE 0x2000
189
190#define EXCEPTION_READ_FAULT 0
191#define EXCEPTION_WRITE_FAULT 1
192#define EXCEPTION_EXECUTE_FAULT 8
193
194#if !defined(RC_INVOKED)
195
196#define CONTEXT_AMD64 0x100000
197
198#define CONTEXT_CONTROL (CONTEXT_AMD64 | 0x1L)
199#define CONTEXT_INTEGER (CONTEXT_AMD64 | 0x2L)
200#define CONTEXT_SEGMENTS (CONTEXT_AMD64 | 0x4L)
201#define CONTEXT_FLOATING_POINT (CONTEXT_AMD64 | 0x8L)
202#define CONTEXT_DEBUG_REGISTERS (CONTEXT_AMD64 | 0x10L)
203
204#define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT)
205#define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS)
206
207#define CONTEXT_XSTATE (CONTEXT_AMD64 | 0x40L)
208
209#define CONTEXT_EXCEPTION_ACTIVE 0x8000000
210#define CONTEXT_SERVICE_ACTIVE 0x10000000
211#define CONTEXT_EXCEPTION_REQUEST 0x40000000
212#define CONTEXT_EXCEPTION_REPORTING 0x80000000
213
214#endif /* !defined(RC_INVOKED) */
215
216#define INITIAL_MXCSR 0x1f80
217#define INITIAL_FPCSR 0x027f
218
219typedef struct DECLSPEC_ALIGN(16) _CONTEXT {
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;
289
290#define PCR_MINOR_VERSION 1
291#define PCR_MAJOR_VERSION 1
292
293typedef struct _KPCR
294{
295 _ANONYMOUS_UNION union
296 {
298 _ANONYMOUS_STRUCT struct
299 {
303 struct _KPCR *Self;
307 };
308 };
328
330PKPCR
332{
333 return (PKPCR)__readgsqword(FIELD_OFFSET(KPCR, Self));
334}
335
336#if (NTDDI_VERSION >= NTDDI_WIN7)
337_CRT_DEPRECATE_TEXT("KeGetCurrentProcessorNumber is deprecated. Use KeGetCurrentProcessorNumberEx or KeGetCurrentProcessorIndex instead.")
338#endif
340ULONG
342{
343 return __readgsbyte(0x184);
344}
345
346$endif /* _NTDDK_ */
@ 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
LONG NTSTATUS
Definition: precomp.h:26
Definition: Header.h:9
#define _CRT_DEPRECATE_TEXT(_Text)
Definition: crtdefs.h:202
#define _Kernel_float_restored_
Definition: driverspecs.h:240
#define _Kernel_requires_resource_held_(kind)
Definition: driverspecs.h:245
#define _Kernel_requires_resource_not_held_(kind)
Definition: driverspecs.h:246
#define _IRQL_requires_max_(irql)
Definition: driverspecs.h:230
#define _IRQL_restores_
Definition: driverspecs.h:233
#define _Kernel_releases_resource_(kind)
Definition: driverspecs.h:244
#define _IRQL_saves_
Definition: driverspecs.h:235
#define _IRQL_raises_(irql)
Definition: driverspecs.h:228
#define _Kernel_acquires_resource_(kind)
Definition: driverspecs.h:247
#define _Kernel_float_saved_
Definition: driverspecs.h:241
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
IN OUT PLONG IN OUT PLONG Addend IN OUT PLONG IN LONG IN OUT PLONG IN LONG Increment KeRaiseIrqlToDpcLevel
Definition: CrNtStubs.h:68
KIRQL FASTCALL KfRaiseIrql(IN KIRQL NewIrql)
Definition: pic.c:187
#define KeGetCurrentThread
Definition: hal.h:55
#define KeSaveFloatingPointState(x)
Definition: kmixer.h:32
#define KeRestoreFloatingPointState(x)
Definition: kmixer.h:33
unsigned __int64 ULONG64
Definition: imports.h:198
#define _Success_(expr)
Definition: ms_sal.h:259
#define _Notliteral_
Definition: ms_sal.h:554
#define _Always_(annos)
Definition: ms_sal.h:270
#define _At_(target, annos)
Definition: ms_sal.h:244
#define _Must_inspect_result_
Definition: ms_sal.h:558
#define _Out_
Definition: ms_sal.h:345
#define _In_
Definition: ms_sal.h:308
#define _Post_satisfies_(cond)
Definition: ms_sal.h:588
#define KeGetPcr()
Definition: ketypes.h:81
#define DECLSPEC_ALIGN(x)
Definition: ntbasedef.h:251
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define DUMMYUNIONNAME
Definition: ntbasedef.h:32
#define DUMMYSTRUCTNAME
Definition: ntbasedef.h:58
#define _ANONYMOUS_UNION
Definition: ntbasedef.h:30
#define _ANONYMOUS_STRUCT
Definition: ntbasedef.h:56
#define _NTDDK_
unsigned short USHORT
Definition: pedump.c:61
#define LFENCE_ACQUIRE()
Definition: ke.h:54
XSAVE_FORMAT XMM_SAVE_AREA32
Definition: ke.h:35
FORCEINLINE ULONG KeGetCurrentProcessorNumber(VOID)
Definition: ke.h:341
XSAVE_FORMAT * PXMM_SAVE_AREA32
Definition: ke.h:35
KFLOATING_SAVE
Definition: ke.h:33
FORCEINLINE ULONG KeGetCurrentProcessorIndex(VOID)
Definition: ke.h:162
FORCEINLINE KIRQL KeRaiseIrqlToSynchLevel(VOID)
Definition: ke.h:117
$if(_WDMDDK_) typedef struct _KFLOATING_SAVE
Definition: ke.h:1
struct _KPCR KPCR
#define HIGH_LEVEL
FORCEINLINE VOID KeMemoryBarrier(VOID)
Definition: ke.h:58
* PKFLOATING_SAVE
Definition: ke.h:33
struct _KPCR * PKPCR
#define FastFence
Definition: ke.h:50
CONTEXT
Definition: ke.h:288
$endif(_WDMDDK_) $if(_NTDDK_) typedef struct _NEON128
Definition: ke.h:202
_Requires_lock_held_ SpinLock _Releases_lock_ SpinLock _In_ _IRQL_restores_ KIRQL NewIrql
Definition: ke.h:114
#define STATUS_SUCCESS
Definition: shellext.h:65
ULONG Dummy
Definition: ke.h:25
Definition: ke.h:294
ULONG StallScaleFactor
Definition: ke.h:318
ULONG64 Unused[2]
Definition: ke.h:310
struct _KPRCB * CurrentPrcb
Definition: ke.h:304
PVOID Used_Self
Definition: ke.h:306
ULONG64 UserRsp
Definition: ke.h:302
USHORT MinorVersion
Definition: ke.h:317
PVOID Unused1[3]
Definition: ke.h:319
union _KIDTENTRY64 * IdtBase
Definition: ke.h:309
UCHAR SecondLevelCacheAssociativity
Definition: ke.h:312
UCHAR Fill0
Definition: ke.h:314
ULONG SecondLevelCacheSize
Definition: ke.h:321
struct _KTSS64 * TssBase
Definition: ke.h:301
ULONG PcrAlign1[24]
Definition: ke.h:326
ULONG KernelReserved[15]
Definition: ke.h:320
PVOID KdVersionBlock
Definition: ke.h:324
NT_TIB NtTib
Definition: ke.h:297
PVOID Unused3
Definition: ke.h:325
USHORT MajorVersion
Definition: ke.h:316
UCHAR ObsoleteNumber
Definition: ke.h:313
union _KGDTENTRY64 * GdtBase
Definition: ke.h:300
ULONG Unused2
Definition: ke.h:323
struct _KPCR * Self
Definition: ke.h:303
PKSPIN_LOCK_QUEUE LockArray
Definition: ke.h:305
ULONG Unused0[3]
Definition: ke.h:315
ULONG HalReserved[16]
Definition: ke.h:322
KIRQL Irql
Definition: ke.h:311
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
uint32_t ULONG
Definition: typedefs.h:59
#define FORCEINLINE
Definition: wdftypes.h:67
#define _WDMDDK_
Definition: wdm.template.h:26
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:778
XSAVE_FORMAT
Definition: ketypes.h:963
M128A
Definition: ketypes.h:937
unsigned char UCHAR
Definition: xmlstorage.h:181