ReactOS 0.4.15-dev-8219-ge8b88cf
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 PROFILE_LEVEL 27
11#define CLOCK1_LEVEL 28
12#define CLOCK2_LEVEL 28
13#define IPI_LEVEL 29
14#define POWER_LEVEL 30
15#define HIGH_LEVEL 31
16#define CLOCK_LEVEL CLOCK2_LEVEL
17
18#define KIP0PCRADDRESS 0xffdff000
19#define KI_USER_SHARED_DATA 0xffdf0000
20#define SharedUserData ((KUSER_SHARED_DATA * CONST)KI_USER_SHARED_DATA)
21
22#define PAGE_SIZE 0x1000
23#define PAGE_SHIFT 12L
24#define KeGetDcacheFillSize() 1L
25
26#define EFLAG_SIGN 0x8000
27#define EFLAG_ZERO 0x4000
28#define EFLAG_SELECT (EFLAG_SIGN | EFLAG_ZERO)
29
30#define RESULT_NEGATIVE ((EFLAG_SIGN & ~EFLAG_ZERO) & EFLAG_SELECT)
31#define RESULT_ZERO ((~EFLAG_SIGN & EFLAG_ZERO) & EFLAG_SELECT)
32#define RESULT_POSITIVE ((~EFLAG_SIGN & ~EFLAG_ZERO) & EFLAG_SELECT)
33
34
35typedef struct _KFLOATING_SAVE {
36 ULONG ControlWord;
37 ULONG StatusWord;
38 ULONG ErrorOffset;
39 ULONG ErrorSelector;
40 ULONG DataOffset;
41 ULONG DataSelector;
42 ULONG Cr0NpxState;
43 ULONG Spare1;
45
47
48#define YieldProcessor _mm_pause
49
51VOID
53{
54 LONG Barrier, *Dummy = &Barrier;
55 (VOID)Dummy;
56
57#if defined(__GNUC__)
58 __asm__ __volatile__ ("xchg %%eax, %0" : : "m" (Barrier) : "%eax");
59#elif defined(_MSC_VER)
60 __asm xchg [Barrier], eax
61#endif
62}
63
64#define KeMemoryBarrierWithoutFence() _ReadWriteBarrier()
65
72
75VOID
79#define KeLowerIrql(a) KfLowerIrql(a)
80
89#define KeRaiseIrql(a,b) *(b) = KfRaiseIrql(a)
90
98
100KIRQL
101NTAPI
103
110KIRQL
114#define KeAcquireSpinLock(a,b) *(b) = KfAcquireSpinLock(a)
115
120VOID
125#define KeReleaseSpinLock(a,b) KfReleaseSpinLock(a,b)
126
131VOID
135#define KeAcquireSpinLockAtDpcLevel(SpinLock) KefAcquireSpinLockAtDpcLevel(SpinLock)
136
141VOID
145#define KeReleaseSpinLockFromDpcLevel(SpinLock) KefReleaseSpinLockFromDpcLevel(SpinLock)
146
149NTAPI
151
159NTAPI
161 _Out_ PKFLOATING_SAVE FloatSave);
162
165_At_(*FloatSave, _Kernel_requires_resource_held_(FloatState) _Kernel_releases_resource_(FloatState))
168NTAPI
170 _In_ PKFLOATING_SAVE FloatSave);
171
172#if (NTDDI_VERSION >= NTDDI_WIN7)
174ULONG
175NTAPI
177{
178 return __readfsbyte(0x51);
179}
180#endif
181
182/* VOID
183 * KeFlushIoBuffers(
184 * IN PMDL Mdl,
185 * IN BOOLEAN ReadOperation,
186 * IN BOOLEAN DmaOperation)
187 */
188#define KeFlushIoBuffers(_Mdl, _ReadOperation, _DmaOperation)
189
190/* x86 and x64 performs a 0x2C interrupt */
191#define DbgRaiseAssertionFailure __int2c
192
194VOID
196 OUT PLARGE_INTEGER CurrentCount)
197{
198 for (;;) {
199#ifdef NONAMELESSUNION
200 CurrentCount->s.HighPart = KeTickCount.High1Time;
201 CurrentCount->s.LowPart = KeTickCount.LowPart;
202 if (CurrentCount->s.HighPart == KeTickCount.High2Time) break;
203#else
204 CurrentCount->HighPart = KeTickCount.High1Time;
205 CurrentCount->LowPart = KeTickCount.LowPart;
206 if (CurrentCount->HighPart == KeTickCount.High2Time) break;
207#endif
209 }
210}
211#define KeQueryTickCount(CurrentCount) _KeQueryTickCount(CurrentCount)
212
214$if (_NTDDK_)
215
216#define PAUSE_PROCESSOR YieldProcessor();
217
218#define KERNEL_STACK_SIZE 12288
219#define KERNEL_LARGE_STACK_SIZE 61440
220#define KERNEL_LARGE_STACK_COMMIT 12288
221
222#define SIZE_OF_80387_REGISTERS 80
223
224#if !defined(RC_INVOKED)
225
226#define CONTEXT_i386 0x10000
227#define CONTEXT_i486 0x10000
228#define CONTEXT_CONTROL (CONTEXT_i386|0x00000001L)
229#define CONTEXT_INTEGER (CONTEXT_i386|0x00000002L)
230#define CONTEXT_SEGMENTS (CONTEXT_i386|0x00000004L)
231#define CONTEXT_FLOATING_POINT (CONTEXT_i386|0x00000008L)
232#define CONTEXT_DEBUG_REGISTERS (CONTEXT_i386|0x00000010L)
233#define CONTEXT_EXTENDED_REGISTERS (CONTEXT_i386|0x00000020L)
234
235#define CONTEXT_FULL (CONTEXT_CONTROL|CONTEXT_INTEGER|CONTEXT_SEGMENTS)
236#define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | \
237 CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS | \
238 CONTEXT_EXTENDED_REGISTERS)
239
240#define CONTEXT_XSTATE (CONTEXT_i386 | 0x00000040L)
241
242#endif /* !defined(RC_INVOKED) */
243
244typedef struct _FLOATING_SAVE_AREA {
255
256#include "pshpack4.h"
257typedef struct _CONTEXT {
259 ULONG Dr0;
260 ULONG Dr1;
261 ULONG Dr2;
262 ULONG Dr3;
263 ULONG Dr6;
264 ULONG Dr7;
266 ULONG SegGs;
267 ULONG SegFs;
268 ULONG SegEs;
269 ULONG SegDs;
270 ULONG Edi;
271 ULONG Esi;
272 ULONG Ebx;
273 ULONG Edx;
274 ULONG Ecx;
275 ULONG Eax;
276 ULONG Ebp;
277 ULONG Eip;
278 ULONG SegCs;
280 ULONG Esp;
281 ULONG SegSs;
284#include "poppack.h"
285
286#define PCR_MINOR_VERSION 1
287#define PCR_MAJOR_VERSION 1
288
289typedef struct _KPCR {
290 union {
292 struct {
300 };
301 };
302 struct _KPCR *SelfPcr;
303 struct _KPRCB *Prcb;
304 KIRQL Irql;
305 ULONG IRR;
307 ULONG IDR;
311 struct _KTSS *TSS;
323 ULONG HalReserved[16];
325
326/* NOTE: This macro is not exposed in the DDK/WDK for _M_IX86.
327 * If it were, this would be its definition. */
328#if 0
329// #define KeGetPcr() ((PKPCR)__readfsdword(FIELD_OFFSET(KPCR, SelfPcr)))
331PKPCR
333{
334 return (PKPCR)__readfsdword(FIELD_OFFSET(KPCR, SelfPcr));
335}
336#endif
337
338#if (NTDDI_VERSION >= NTDDI_WIN7)
339_CRT_DEPRECATE_TEXT("KeGetCurrentProcessorNumber is deprecated. Use KeGetCurrentProcessorNumberEx or KeGetCurrentProcessorIndex instead.")
340#endif
342ULONG
344{
346}
347
348/* Macros for kernel-mode run-time checks of X86 system architecture */
349#ifdef IsNEC_98
350#undef IsNEC_98
351#endif
352#define IsNEC_98 (SharedUserData->AlternativeArchitecture == NEC98x86)
353
354#ifdef IsNotNEC_98
355#undef IsNotNEC_98
356#endif
357#define IsNotNEC_98 (SharedUserData->AlternativeArchitecture != NEC98x86)
358
359#ifdef SetNEC_98
360#undef SetNEC_98
361#endif
362#define SetNEC_98 (SharedUserData->AlternativeArchitecture = NEC98x86)
363
364#ifdef SetNotNEC_98
365#undef SetNotNEC_98
366#endif
367#define SetNotNEC_98 (SharedUserData->AlternativeArchitecture = StandardDesign)
368
#define VOID
Definition: acefi.h:82
LONG NTSTATUS
Definition: precomp.h:26
#define NTSYSAPI
Definition: ntoskrnl.h:12
#define _Acquires_lock_(lock)
#define _Requires_lock_held_(lock)
#define _Requires_lock_not_held_(lock)
#define _Releases_lock_(lock)
#define _CRT_DEPRECATE_TEXT(_Text)
Definition: crtdefs.h:202
ULONG_PTR KAFFINITY
Definition: compat.h:85
#define _Kernel_float_restored_
Definition: driverspecs.h:240
#define _Kernel_requires_resource_held_(kind)
Definition: driverspecs.h:245
#define _IRQL_requires_min_(irql)
Definition: driverspecs.h:231
#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_requires_(irql)
Definition: driverspecs.h:229
#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
KSPIN_LOCK * PKSPIN_LOCK
Definition: env_spec_w32.h:73
#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
VOID FASTCALL KfLowerIrql(IN KIRQL NewIrql)
Definition: pic.c:232
KIRQL FASTCALL KfRaiseIrql(IN KIRQL NewIrql)
Definition: pic.c:187
KIRQL FASTCALL KfAcquireSpinLock(PKSPIN_LOCK SpinLock)
Definition: spinlock.c:85
VOID FASTCALL KfReleaseSpinLock(PKSPIN_LOCK SpinLock, KIRQL OldIrql)
Definition: spinlock.c:96
#define KeGetCurrentThread
Definition: hal.h:55
PPC_QUAL unsigned char __readfsbyte(const unsigned long Offset)
Definition: intrin_ppc.h:360
PPC_QUAL unsigned long __readfsdword(const unsigned long Offset)
Definition: intrin_ppc.h:382
#define KeSaveFloatingPointState(x)
Definition: kmixer.h:32
#define KeRestoreFloatingPointState(x)
Definition: kmixer.h:33
#define _Success_(expr)
Definition: ms_sal.h:259
#define _Inout_
Definition: ms_sal.h:378
#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 FASTCALL
Definition: nt_native.h:50
#define SIZE_OF_80387_REGISTERS
Definition: nt_native.h:1356
#define _NTDDK_
NTKERNELAPI volatile KSYSTEM_TIME KeTickCount
Definition: clock.c:19
#define NTHALAPI
Definition: ntoskrnl.h:40
VOID FASTCALL KefReleaseSpinLockFromDpcLevel(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.c:265
VOID FASTCALL KefAcquireSpinLockAtDpcLevel(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.c:243
_In_opt_ PENTER_STATE_SYSTEM_HANDLER _In_opt_ PVOID _In_ LONG _In_opt_ LONG volatile * Number
Definition: ntpoapi.h:207
long LONG
Definition: pedump.c:60
unsigned short USHORT
Definition: pedump.c:61
__asm__(".p2align 4, 0x90\n" ".seh_proc __seh2_global_filter_func\n" "__seh2_global_filter_func:\n" "\tsub %rbp, %rax\n" "\tpush %rbp\n" "\t.seh_pushreg %rbp\n" "\tsub $32, %rsp\n" "\t.seh_stackalloc 32\n" "\t.seh_endprologue\n" "\tsub %rax, %rdx\n" "\tmov %rdx, %rbp\n" "\tjmp *%r8\n" "__seh2_global_filter_func_exit:\n" "\t.p2align 4\n" "\tadd $32, %rsp\n" "\tpop %rbp\n" "\tret\n" "\t.seh_endproc")
#define YieldProcessor
Definition: ke.h:48
FORCEINLINE ULONG KeGetCurrentProcessorNumber(VOID)
Definition: ke.h:341
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
CONTEXT
Definition: ke.h:288
$endif(_WDMDDK_) $if(_NTDDK_) typedef struct _NEON128
Definition: ke.h:202
FORCEINLINE VOID _KeQueryTickCount(OUT PLARGE_INTEGER CurrentCount)
Definition: ke.h:178
_Requires_lock_held_ SpinLock _Releases_lock_ SpinLock _In_ _IRQL_restores_ KIRQL NewIrql
Definition: ke.h:114
* PFLOATING_SAVE_AREA
Definition: ke.h:254
FLOATING_SAVE_AREA
Definition: ke.h:254
ULONG Esp
Definition: nt_native.h:1479
ULONG SegFs
Definition: nt_native.h:1454
ULONG Dr3
Definition: nt_native.h:1437
ULONG Dr1
Definition: nt_native.h:1435
ULONG Edx
Definition: nt_native.h:1466
ULONG Esi
Definition: nt_native.h:1464
ULONG Ebp
Definition: nt_native.h:1475
ULONG ContextFlags
Definition: nt_native.h:1426
ULONG Dr6
Definition: nt_native.h:1438
ULONG SegSs
Definition: nt_native.h:1480
ULONG Ecx
Definition: nt_native.h:1467
ULONG Dr0
Definition: nt_native.h:1434
ULONG Eip
Definition: nt_native.h:1476
ULONG SegCs
Definition: nt_native.h:1477
ULONG SegDs
Definition: nt_native.h:1456
ULONG EFlags
Definition: nt_native.h:1478
ULONG SegGs
Definition: nt_native.h:1453
ULONG Dr2
Definition: nt_native.h:1436
UCHAR ExtendedRegisters[MAXIMUM_SUPPORTED_EXTENSION]
Definition: ke.h:282
ULONG Eax
Definition: nt_native.h:1468
FLOATING_SAVE_AREA FloatSave
Definition: nt_native.h:1446
ULONG SegEs
Definition: nt_native.h:1455
ULONG Ebx
Definition: nt_native.h:1465
ULONG Edi
Definition: nt_native.h:1463
ULONG Dr7
Definition: nt_native.h:1439
UCHAR RegisterArea[SIZE_OF_80387_REGISTERS]
Definition: nt_native.h:1390
Definition: ke.h:294
PVOID Used_StackBase
Definition: ke.h:294
ULONG StallScaleFactor
Definition: ke.h:318
ULONG IDR
Definition: ke.h:23
struct _EXCEPTION_REGISTRATION_RECORD * Used_ExceptionList
Definition: ke.h:293
PVOID TssCopy
Definition: ke.h:296
struct _KTSS * TSS
Definition: ke.h:55
PVOID Used_Self
Definition: ke.h:306
USHORT MinorVersion
Definition: ke.h:317
struct _KPRCB * Prcb
Definition: ke.h:20
struct _KGDTENTRY * GDT
Definition: ke.h:310
ULONG IRR
Definition: ke.h:22
UCHAR SecondLevelCacheAssociativity
Definition: ke.h:312
ULONG ContextSwitches
Definition: ke.h:297
ULONG SecondLevelCacheSize
Definition: ke.h:321
ULONG KernelReserved[15]
Definition: ke.h:320
struct _KIDTENTRY * IDT
Definition: ke.h:309
ULONG IrrActive
Definition: ke.h:50
PVOID KdVersionBlock
Definition: ke.h:324
UCHAR Number
Definition: ke.h:61
PVOID Spare2
Definition: ke.h:295
KAFFINITY SetMemberCopy
Definition: ke.h:298
NT_TIB NtTib
Definition: ke.h:297
UCHAR Spare0
Definition: ke.h:318
USHORT MajorVersion
Definition: ke.h:316
struct _KPCR * SelfPcr
Definition: ke.h:302
ULONG VdmAlert
Definition: ke.h:320
KAFFINITY SetMember
Definition: ke.h:58
UCHAR SpareUnused
Definition: ke.h:60
ULONG HalReserved[16]
Definition: ke.h:322
KIRQL Irql
Definition: ke.h:311
LONG High1Time
Definition: ketypes.h:930
LONG High2Time
Definition: ketypes.h:931
ULONG LowPart
Definition: ketypes.h:929
Definition: ketypes.h:844
ecx edi movl ebx edx edi decl ecx esi eax jecxz decl eax andl eax esi movl eax
Definition: synth_sse3d.h:85
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define NTAPI
Definition: typedefs.h:36
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFSPINLOCK * SpinLock
Definition: wdfsync.h:228
#define FORCEINLINE
Definition: wdftypes.h:67
#define _WDMDDK_
Definition: wdm.template.h:26
#define NTKERNELAPI
#define MAXIMUM_SUPPORTED_EXTENSION
Definition: x86context.h:35
unsigned char UCHAR
Definition: xmlstorage.h:181