ReactOS  0.4.14-dev-323-g6fe6a88
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 
35 typedef 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 
46 extern NTKERNELAPI volatile KSYSTEM_TIME KeTickCount;
47 
48 #define YieldProcessor _mm_pause
49 
51 VOID
53 {
54  LONG Barrier, *Dummy = &Barrier;
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 
69 KIRQL
70 NTAPI
72 
75 VOID
79 #define KeLowerIrql(a) KfLowerIrql(a)
80 
85 KIRQL
89 #define KeRaiseIrql(a,b) *(b) = KfRaiseIrql(a)
90 
95 KIRQL
96 NTAPI
98 
100 KIRQL
101 NTAPI
103 
109 NTHALAPI
110 KIRQL
111 FASTCALL
114 #define KeAcquireSpinLock(a,b) *(b) = KfAcquireSpinLock(a)
115 
119 NTHALAPI
120 VOID
121 FASTCALL
125 #define KeReleaseSpinLock(a,b) KfReleaseSpinLock(a,b)
126 
131 VOID
132 FASTCALL
135 #define KeAcquireSpinLockAtDpcLevel(SpinLock) KefAcquireSpinLockAtDpcLevel(SpinLock)
136 
141 VOID
142 FASTCALL
145 #define KeReleaseSpinLockFromDpcLevel(SpinLock) KefReleaseSpinLockFromDpcLevel(SpinLock)
146 
147 NTSYSAPI
148 PKTHREAD
149 NTAPI
151 
152 _Always_(_Post_satisfies_(return<=0))
156 _At_(*FloatSave, _Kernel_requires_resource_not_held_(FloatState) _Kernel_acquires_resource_(FloatState))
158 NTSTATUS
159 NTAPI
161  _Out_ PKFLOATING_SAVE FloatSave);
162 
163 _Success_(1)
165 _At_(*FloatSave, _Kernel_requires_resource_held_(FloatState) _Kernel_releases_resource_(FloatState))
167 NTSTATUS
168 NTAPI
170  _In_ PKFLOATING_SAVE FloatSave);
171 
172 /* VOID
173  * KeFlushIoBuffers(
174  * IN PMDL Mdl,
175  * IN BOOLEAN ReadOperation,
176  * IN BOOLEAN DmaOperation)
177  */
178 #define KeFlushIoBuffers(_Mdl, _ReadOperation, _DmaOperation)
179 
180 /* x86 and x64 performs a 0x2C interrupt */
181 #define DbgRaiseAssertionFailure __int2c
182 
184 VOID
186  OUT PLARGE_INTEGER CurrentCount)
187 {
188  for (;;) {
189 #ifdef NONAMELESSUNION
190  CurrentCount->s.HighPart = KeTickCount.High1Time;
191  CurrentCount->s.LowPart = KeTickCount.LowPart;
192  if (CurrentCount->s.HighPart == KeTickCount.High2Time) break;
193 #else
194  CurrentCount->HighPart = KeTickCount.High1Time;
195  CurrentCount->LowPart = KeTickCount.LowPart;
196  if (CurrentCount->HighPart == KeTickCount.High2Time) break;
197 #endif
198  YieldProcessor();
199  }
200 }
201 #define KeQueryTickCount(CurrentCount) _KeQueryTickCount(CurrentCount)
202 
204 $if (_NTDDK_)
205 
206 #define PAUSE_PROCESSOR YieldProcessor();
207 
208 #define KERNEL_STACK_SIZE 12288
209 #define KERNEL_LARGE_STACK_SIZE 61440
210 #define KERNEL_LARGE_STACK_COMMIT 12288
211 
212 #define SIZE_OF_80387_REGISTERS 80
213 
214 #if !defined(RC_INVOKED)
215 
216 #define CONTEXT_i386 0x10000
217 #define CONTEXT_i486 0x10000
218 #define CONTEXT_CONTROL (CONTEXT_i386|0x00000001L)
219 #define CONTEXT_INTEGER (CONTEXT_i386|0x00000002L)
220 #define CONTEXT_SEGMENTS (CONTEXT_i386|0x00000004L)
221 #define CONTEXT_FLOATING_POINT (CONTEXT_i386|0x00000008L)
222 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_i386|0x00000010L)
223 #define CONTEXT_EXTENDED_REGISTERS (CONTEXT_i386|0x00000020L)
224 
225 #define CONTEXT_FULL (CONTEXT_CONTROL|CONTEXT_INTEGER|CONTEXT_SEGMENTS)
226 #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | \
227  CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS | \
228  CONTEXT_EXTENDED_REGISTERS)
229 
230 #define CONTEXT_XSTATE (CONTEXT_i386 | 0x00000040L)
231 
232 #endif /* !defined(RC_INVOKED) */
233 
234 typedef struct _FLOATING_SAVE_AREA {
237  ULONG TagWord;
245 
246 #include "pshpack4.h"
247 typedef struct _CONTEXT {
249  ULONG Dr0;
250  ULONG Dr1;
251  ULONG Dr2;
252  ULONG Dr3;
253  ULONG Dr6;
254  ULONG Dr7;
256  ULONG SegGs;
257  ULONG SegFs;
258  ULONG SegEs;
259  ULONG SegDs;
260  ULONG Edi;
261  ULONG Esi;
262  ULONG Ebx;
263  ULONG Edx;
264  ULONG Ecx;
265  ULONG Eax;
266  ULONG Ebp;
267  ULONG Eip;
268  ULONG SegCs;
269  ULONG EFlags;
270  ULONG Esp;
271  ULONG SegSs;
273 } CONTEXT;
274 #include "poppack.h"
275 
276 #define KeGetPcr() PCR
277 
278 #define PCR_MINOR_VERSION 1
279 #define PCR_MAJOR_VERSION 1
280 
281 typedef struct _KPCR {
282  union {
283  NT_TIB NtTib;
284  struct {
292  };
293  };
294  struct _KPCR *SelfPcr;
295  struct _KPRCB *Prcb;
296  KIRQL Irql;
297  ULONG IRR;
299  ULONG IDR;
301  struct _KIDTENTRY *IDT;
302  struct _KGDTENTRY *GDT;
303  struct _KTSS *TSS;
309  UCHAR Number;
313  ULONG KernelReserved[14];
315  ULONG HalReserved[16];
316 } KPCR, *PKPCR;
317 
319 ULONG
321 {
323 }
324 
325 $endif (_NTDDK_)
326 
327 
328 
329 
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
struct _EXCEPTION_REGISTRATION_RECORD * Used_ExceptionList
Definition: ke.h:285
PVOID Spare2
Definition: ke.h:287
ULONG LowPart
Definition: ketypes.h:910
#define YieldProcessor
Definition: ke.h:48
KIRQL Irql
Definition: ke.h:298
PVOID Used_StackBase
Definition: ke.h:286
struct _KFLOATING_SAVE KFLOATING_SAVE
#define _Must_inspect_result_
Definition: no_sal2.h:314
ULONG StallScaleFactor
Definition: ke.h:305
ULONG Esp
Definition: nt_native.h:1479
#define _Kernel_releases_resource_(kind)
Definition: no_sal2.h:663
ULONG Eip
Definition: nt_native.h:1476
#define NTHALAPI
Definition: ntoskrnl.h:40
FLOATING_SAVE_AREA FloatSave
Definition: nt_native.h:1446
struct _KFLOATING_SAVE * PKFLOATING_SAVE
#define _IRQL_saves_
Definition: no_sal2.h:655
$if(_WDMDDK_) typedef struct _KFLOATING_SAVE
Definition: ke.h:1
ULONG Ecx
Definition: nt_native.h:1467
LONG NTSTATUS
Definition: precomp.h:26
FORCEINLINE KIRQL KeRaiseIrqlToSynchLevel(VOID)
Definition: ke.h:117
ULONG IDR
Definition: ke.h:22
#define DISPATCH_LEVEL
_Requires_lock_not_held_ SpinLock _Acquires_lock_ SpinLock _IRQL_requires_min_(DISPATCH_LEVEL) NTKERNELAPI VOID FASTCALL KefAcquireSpinLockAtDpcLevel(_Inout_ PKSPIN_LOCK SpinLock)
#define _WDMDDK_
Definition: wdm.template.h:26
_Requires_lock_not_held_(Vcb->fcb_lock) _Acquires_shared_lock_(Vcb -> fcb_lock) static __inline void acquire_fcb_lock_shared(device_extension *Vcb)
Definition: btrfs_drv.h:934
ULONG SegGs
Definition: nt_native.h:1453
Definition: ke.h:280
KSPIN_LOCK * PKSPIN_LOCK
Definition: env_spec_w32.h:73
ULONG SegFs
Definition: nt_native.h:1454
ULONG SegDs
Definition: nt_native.h:1456
#define FASTCALL
Definition: nt_native.h:50
#define NTSYSAPI
Definition: ntoskrnl.h:14
_Kernel_requires_resource_held_(FloatState) _Kernel_releases_resource_(FloatState)) FORCEINLINE NTSTATUS KeRestoreFloatingPointState(_In_ PKFLOATING_SAVE FloatSave)
Definition: ke.h:145
ULONG Dr7
Definition: nt_native.h:1439
ULONG Dr3
Definition: nt_native.h:1437
ULONG SecondLevelCacheSize
Definition: ke.h:308
USHORT MinorVersion
Definition: ke.h:304
#define UNREFERENCED_LOCAL_VARIABLE(L)
Definition: ntbasedef.h:324
_In_ PKSERVICE_ROUTINE _In_opt_ PVOID _In_opt_ PKSPIN_LOCK SpinLock
Definition: iofuncs.h:798
FORCEINLINE ULONG KeGetCurrentProcessorNumber(VOID)
Definition: ke.h:325
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define _Acquires_lock_(lock)
Definition: no_sal2.h:677
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
long LONG
Definition: pedump.c:60
NTKERNELAPI KIRQL NTAPI KfRaiseIrql(IN KIRQL NewIrql)
Definition: pic.c:187
__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")
FORCEINLINE PRKTHREAD KeGetCurrentThread(VOID)
Definition: ke.h:284
PVOID Used_Self
Definition: ke.h:293
PVOID KdVersionBlock
Definition: ke.h:311
#define _Releases_lock_(a)
Definition: btrfs_drv.h:192
ULONG SegEs
Definition: nt_native.h:1455
ULONG Esi
Definition: nt_native.h:1464
ULONG Dr1
Definition: nt_native.h:1435
ULONG SegCs
Definition: nt_native.h:1477
ULONG Edx
Definition: nt_native.h:1466
#define FORCEINLINE
Definition: ntbasedef.h:221
#define _Out_
Definition: no_sal2.h:323
Definition: ketypes.h:789
#define _At_(target, annos)
Definition: no_sal2.h:11
#define NTKERNELAPI
#define _Kernel_float_restored_
Definition: no_sal2.h:659
ULONG IrrActive
Definition: ke.h:49
$endif(_WDMDDK_) $if(_NTDDK_) typedef struct _NEON128
Definition: ke.h:202
ULONG EFlags
Definition: nt_native.h:1478
ULONG Dr2
Definition: nt_native.h:1436
ULONG Ebx
Definition: nt_native.h:1465
ULONG VdmAlert
Definition: ke.h:312
USHORT MajorVersion
Definition: ke.h:303
ULONG ContextFlags
Definition: compat.h:331
#define KeRestoreFloatingPointState(x)
Definition: kmixer.h:33
struct _KGDTENTRY * GDT
Definition: ke.h:302
#define _Kernel_acquires_resource_(kind)
Definition: no_sal2.h:666
UCHAR RegisterArea[SIZE_OF_80387_REGISTERS]
Definition: nt_native.h:1390
_Kernel_requires_resource_not_held_(FloatState) _Kernel_acquires_resource_(FloatState)) FORCEINLINE NTSTATUS KeSaveFloatingPointState(_Out_ PKFLOATING_SAVE FloatSave)
Definition: ke.h:133
KAFFINITY SetMember
Definition: ke.h:57
LONG High1Time
Definition: ketypes.h:911
ecx edi ebx edx edi decl ecx esi eax jecxz decl eax andl eax esi movl eax
Definition: synth_sse3d.h:85
struct _KIDTENTRY * IDT
Definition: ke.h:301
#define _Notliteral_
Definition: no_sal2.h:315
ULONG HalReserved[16]
Definition: ke.h:309
VOID FASTCALL KfReleaseSpinLock(PKSPIN_LOCK SpinLock, KIRQL OldIrql)
Definition: spinlock.c:96
_Requires_lock_held_ SpinLock _Releases_lock_ SpinLock _IRQL_requires_(DISPATCH_LEVEL) NTHALAPI VOID FASTCALL KfReleaseSpinLock(_Inout_ PKSPIN_LOCK SpinLock
Definition: expool.c:1448
PPC_QUAL unsigned char __readfsbyte(const unsigned long Offset)
Definition: intrin_ppc.h:360
ULONG ContextSwitches
Definition: ke.h:289
#define _Inout_
Definition: no_sal2.h:244
* PFLOATING_SAVE_AREA
Definition: ke.h:244
_Always_(_Post_satisfies_(return<=0)) _Must_inspect_result_ _IRQL_requires_max_(DISPATCH_LEVEL) _Kernel_float_saved_ _At_(*FloatSave
unsigned char UCHAR
Definition: xmlstorage.h:181
#define _Kernel_float_saved_
Definition: no_sal2.h:660
NTKERNELAPI volatile KSYSTEM_TIME KeTickCount
Definition: clock.c:19
#define KeSaveFloatingPointState(x)
Definition: kmixer.h:32
struct _CONTEXT CONTEXT
struct _KPCR * SelfPcr
Definition: ke.h:294
NT_TIB NtTib
Definition: ke.h:284
_Success_(1) _Kernel_float_restored_ _At_(*FloatSave
ULONG Eax
Definition: nt_native.h:1468
_In_opt_ PENTER_STATE_SYSTEM_HANDLER _In_opt_ PVOID _In_ LONG _In_opt_ LONG volatile * Number
Definition: ntpoapi.h:204
_IRQL_requires_max_(HIGH_LEVEL) _IRQL_saves_ FORCEINLINE KIRQL KeGetCurrentIrql(VOID)
Definition: ke.h:68
UCHAR SecondLevelCacheAssociativity
Definition: ke.h:299
#define _In_
Definition: no_sal2.h:204
LONG High2Time
Definition: ketypes.h:912
struct _KTSS * TSS
Definition: ke.h:54
#define HIGH_LEVEL
ULONG SegSs
Definition: nt_native.h:1480
unsigned short USHORT
Definition: pedump.c:61
UCHAR Spare0
Definition: ke.h:310
ULONG_PTR KAFFINITY
Definition: compat.h:75
UCHAR SpareUnused
Definition: ke.h:59
#define MAXIMUM_SUPPORTED_EXTENSION
Definition: x86context.h:35
NTKERNELAPI VOID NTAPI KfLowerIrql(IN KIRQL NewIrql)
Definition: pic.c:232
UCHAR Number
Definition: ke.h:60
ULONG Dr6
Definition: nt_native.h:1438
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
struct _KPCR KPCR
#define _Post_satisfies_(a)
Definition: btrfs_drv.h:195
PVOID TssCopy
Definition: ke.h:288
ULONG Dr0
Definition: nt_native.h:1434
VOID FASTCALL KefReleaseSpinLockFromDpcLevel(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.c:259
NTKERNELAPI KIRQL NTAPI KeRaiseIrqlToDpcLevel(VOID)
Definition: pic.c:133
#define OUT
Definition: typedefs.h:39
KIRQL FASTCALL KfAcquireSpinLock(PKSPIN_LOCK SpinLock)
Definition: spinlock.c:85
unsigned int ULONG
Definition: retypes.h:1
VOID FASTCALL KefAcquireSpinLockAtDpcLevel(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.c:237
#define _IRQL_raises_(irql)
Definition: no_sal2.h:648
struct _KPCR * PKPCR
ULONG KernelReserved[15]
Definition: ke.h:307
FORCEINLINE VOID KeMemoryBarrier(VOID)
Definition: ke.h:58
UCHAR ExtendedRegisters[MAXIMUM_SUPPORTED_EXTENSION]
Definition: ke.h:272
FLOATING_SAVE_AREA
Definition: ke.h:244
#define SIZE_OF_80387_REGISTERS
ULONG IRR
Definition: ke.h:21
KAFFINITY SetMemberCopy
Definition: ke.h:290
#define _NTDDK_
ULONG Ebp
Definition: nt_native.h:1475
#define _Requires_lock_held_(a)
Definition: btrfs_drv.h:190
ULONG Edi
Definition: nt_native.h:1463
#define _IRQL_restores_
Definition: no_sal2.h:653
struct _KPRCB * Prcb
Definition: ke.h:19
_Requires_lock_held_ SpinLock _Releases_lock_ SpinLock _In_ _IRQL_restores_ KIRQL NewIrql
Definition: ke.h:114
FORCEINLINE VOID _KeQueryTickCount(OUT PLARGE_INTEGER CurrentCount)
Definition: ke.h:178