ReactOS  0.4.14-dev-49-gfb4591c
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 CLOCK_LEVEL 13
10 #define IPI_LEVEL 14
11 #define DRS_LEVEL 14
12 #define POWER_LEVEL 14
13 #define PROFILE_LEVEL 15
14 #define HIGH_LEVEL 15
15 
16 #define KIP0PCRADDRESS 0xFFDFF000
17 #define KI_USER_SHARED_DATA 0xFFFF9000
18 #define SharedUserData ((KUSER_SHARED_DATA * const)KI_USER_SHARED_DATA)
19 
20 #define PAGE_SIZE 0x1000
21 #define PAGE_SHIFT 12L
22 
23 typedef struct _KFLOATING_SAVE
24 {
27 
28 extern NTKERNELAPI volatile KSYSTEM_TIME KeTickCount;
29 
31 VOID
33  VOID)
34 {
36  __yield();
37 }
38 
39 #define MemoryBarrier() __dmb(_ARM_BARRIER_SY)
40 #define PreFetchCacheLine(l,a) __prefetch((const void *) (a))
41 #define PrefetchForWrite(p) __prefetch((const void *) (p))
42 #define ReadForWriteAccess(p) (*(p))
43 
45 VOID
47  VOID)
48 {
50  MemoryBarrier();
51 }
52 
53 #define KeMemoryBarrierWithoutFence() _ReadWriteBarrier()
54 
58 KIRQL
59 NTAPI
61  VOID);
62 
65 VOID
69 #define KeLowerIrql(a) KfLowerIrql(a)
70 
75 KIRQL
79 #define KeRaiseIrql(a,b) *(b) = KfRaiseIrql(a)
80 
85 KIRQL
86 NTAPI
88 
90 KIRQL
91 NTAPI
93 
100 KIRQL
101 FASTCALL
104 #define KeAcquireSpinLock(a,b) *(b) = KfAcquireSpinLock(a)
105 
109 NTHALAPI
110 VOID
111 FASTCALL
115 #define KeReleaseSpinLock(a,b) KfReleaseSpinLock(a,b)
116 
121 VOID
122 FASTCALL
125 #define KeAcquireSpinLockAtDpcLevel(SpinLock) KefAcquireSpinLockAtDpcLevel(SpinLock)
126 
131 VOID
132 FASTCALL
135 #define KeReleaseSpinLockFromDpcLevel(SpinLock) KefReleaseSpinLockFromDpcLevel(SpinLock)
136 
137 NTSYSAPI
138 PKTHREAD
139 NTAPI
141 
142 _Always_(_Post_satisfies_(return<=0))
148 NTSTATUS
150  _Out_ PKFLOATING_SAVE FloatSave)
151 {
152  UNREFERENCED_PARAMETER(FloatSave);
153  return STATUS_SUCCESS;
154 }
155 
156 _Success_(1)
160 NTSTATUS
162  _In_ PKFLOATING_SAVE FloatSave)
163 {
164  UNREFERENCED_PARAMETER(FloatSave);
165  return STATUS_SUCCESS;
166 }
167 
168 VOID
170  _In_ PMDL Mdl,
171  _In_ BOOLEAN ReadOperation,
172  _In_ BOOLEAN DmaOperation);
173 
174 #define DbgRaiseAssertionFailure() __emit(0xdefc)
175 
177 VOID
179  OUT PLARGE_INTEGER CurrentCount)
180 {
181  for (;;) {
182 #ifdef NONAMELESSUNION
183  CurrentCount->s.HighPart = KeTickCount.High1Time;
184  CurrentCount->s.LowPart = KeTickCount.LowPart;
185  if (CurrentCount->s.HighPart == KeTickCount.High2Time) break;
186 #else
187  CurrentCount->HighPart = KeTickCount.High1Time;
188  CurrentCount->LowPart = KeTickCount.LowPart;
189  if (CurrentCount->HighPart == KeTickCount.High2Time) break;
190 #endif
191  YieldProcessor();
192  }
193 }
194 #define KeQueryTickCount(CurrentCount) _KeQueryTickCount(CurrentCount)
195 
196 #define CP15_PMSELR 15, 0, 9, 12, 5 /* Event Counter Selection Register */
197 #define CP15_PMXEVCNTR 15, 0, 9, 13, 2 /* Event Count Register */
198 #define CP15_TPIDRURW 15, 0, 13, 0, 2 /* Software Thread ID Register, UsRW */
199 #define CP15_TPIDRURO 15, 0, 13, 0, 3 /* Software Thread ID Register, UsRO */
200 #define CP15_TPIDRPRW 15, 0, 13, 0, 4 /* Software Thread ID Register, Kernel */
201 
203 $if (_NTDDK_)
204 
205 #define PAUSE_PROCESSOR __yield();
206 
207 #define KERNEL_STACK_SIZE 0x3000
208 #define KERNEL_LARGE_STACK_SIZE 0xF000
209 #define KERNEL_LARGE_STACK_COMMIT KERNEL_STACK_SIZE
210 
211 #define KERNEL_MCA_EXCEPTION_STACK_SIZE 0x2000
212 
213 #define EXCEPTION_READ_FAULT 0
214 #define EXCEPTION_WRITE_FAULT 1
215 #define EXCEPTION_EXECUTE_FAULT 8
216 
217 /* The following flags control the contents of the CONTEXT structure. */
218 #define CONTEXT_ARM 0x200000L
219 #define CONTEXT_CONTROL (CONTEXT_ARM | 0x00000001L)
220 #define CONTEXT_INTEGER (CONTEXT_ARM | 0x00000002L)
221 #define CONTEXT_FLOATING_POINT (CONTEXT_ARM | 0x00000004L)
222 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_ARM | 0x00000008L)
223 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT)
224 
225 typedef struct _NEON128
226 {
227  ULONGLONG Low;
228  LONGLONG High;
230 
231 #define ARM_MAX_BREAKPOINTS 8
232 #define ARM_MAX_WATCHPOINTS 1
233 
234 typedef struct _CONTEXT
235 {
236  /* The flags values within this flag control the contents of
237  a CONTEXT record.
238 
239  If the context record is used as an input parameter, then
240  for each portion of the context record controlled by a flag
241  whose value is set, it is assumed that that portion of the
242  context record contains valid context. If the context record
243  is being used to modify a thread's context, then only that
244  portion of the threads context will be modified.
245 
246  If the context record is used as an IN OUT parameter to capture
247  the context of a thread, then only those portions of the thread's
248  context corresponding to set flags will be returned.
249 
250  The context record is never used as an OUT only parameter. */
252 
253  /* This section is specified/returned if the ContextFlags word contains
254  the flag CONTEXT_INTEGER. */
255  ULONG R0;
256  ULONG R1;
257  ULONG R2;
258  ULONG R3;
259  ULONG R4;
260  ULONG R5;
261  ULONG R6;
262  ULONG R7;
263  ULONG R8;
264  ULONG R9;
265  ULONG R10;
268 
269  ULONG Sp;
270  ULONG Lr;
271  ULONG Pc;
272  ULONG Cpsr;
273 
274  /* Floating Point/NEON Registers */
277  union
278  {
279  NEON128 Q[16];
281  ULONG S[32];
282  } DUMMYUNIONNAME;
283 
284  /* Debug registers */
289 
291 } CONTEXT;
292 
293 #define PCR_MINOR_VERSION 1
294 #define PCR_MAJOR_VERSION 1
295 
296 typedef struct _KPCR
297 {
298  _ANONYMOUS_UNION union
299  {
300  NT_TIB NtTib;
301  _ANONYMOUS_STRUCT struct
302  {
305  struct _KPCR *Self;
306  struct _KPRCB *CurrentPrcb;
309  };
310  };
313  ULONG Unused0[3];
317  PVOID Unused1[3];
318  ULONG KernelReserved[15];
320  _ANONYMOUS_UNION union
321  {
322  USHORT SoftwareInterruptPending; // Software Interrupt Pending Flag
323  struct
324  {
325  UCHAR ApcInterrupt; // 0x01 if APC int pending
326  UCHAR DispatchInterrupt; // 0x01 if dispatch int pending
327  };
328  };
330  ULONG HalReserved[32];
332  PVOID Unused3;
333  ULONG PcrAlign1[8];
334 } KPCR, *PKPCR;
335 
336 #define CP15_PCR_RESERVED_MASK 0xFFF
337 //#define KIPCR() ((ULONG_PTR)(_MoveFromCoprocessor(CP15_TPIDRPRW)) & ~CP15_PCR_RESERVED_MASK)
338 
340 PKPCR
342  VOID)
343 {
344  return (PKPCR)(_MoveFromCoprocessor(CP15_TPIDRPRW) & ~CP15_PCR_RESERVED_MASK);
345 }
346 
347 #if (NTDDI_VERSION < NTDDI_WIN7) || !defined(NT_PROCESSOR_GROUPS)
349 ULONG
351  VOID)
352 
353 {
354  return *((PUCHAR)KeGetPcr() + 0x580);
355 }
356 #endif /* (NTDDI_VERSION < NTDDI_WIN7) || !defined(NT_PROCESSOR_GROUPS) */
357 
358 $endif
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
PKSPIN_LOCK_QUEUE LockArray
Definition: ke.h:292
ULONG LowPart
Definition: ketypes.h:910
#define MemoryBarrier()
Definition: ke.h:39
struct _KPCR * Self
Definition: ke.h:290
struct _KFLOATING_SAVE KFLOATING_SAVE
USHORT SoftwareInterruptPending
Definition: ke.h:322
#define _Must_inspect_result_
Definition: no_sal2.h:314
ULONG StallScaleFactor
Definition: ke.h:305
void __dmb(unsigned int Type)
#define _ReadWriteBarrier()
Definition: intrin_arm.h:36
#define _Kernel_releases_resource_(kind)
Definition: no_sal2.h:663
PVOID Unused3
Definition: ke.h:312
#define NTHALAPI
Definition: ntoskrnl.h:39
UCHAR ApcInterrupt
Definition: ke.h:325
struct _KFLOATING_SAVE * PKFLOATING_SAVE
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define _IRQL_saves_
Definition: no_sal2.h:655
#define _ANONYMOUS_UNION
Definition: ntbasedef.h:30
$if(_WDMDDK_) typedef struct _KFLOATING_SAVE
Definition: ke.h:1
unsigned char * PUCHAR
Definition: retypes.h:3
LONG NTSTATUS
Definition: precomp.h:26
FORCEINLINE KIRQL KeRaiseIrqlToSynchLevel(VOID)
Definition: ke.h:117
ULONG R6
Definition: compat.h:341
ULONG R0
Definition: compat.h:335
_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
#define ARM_MAX_BREAKPOINTS
Definition: ke.h:231
Definition: strmini.h:380
VOID KeFlushIoBuffers(_In_ PMDL Mdl, _In_ BOOLEAN ReadOperation, _In_ BOOLEAN DmaOperation)
Definition: cpu.c:191
_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:923
union _CONTEXT::@3548 DUMMYUNIONNAME
Definition: ke.h:280
KSPIN_LOCK * PKSPIN_LOCK
Definition: env_spec_w32.h:73
Definition: movable.cpp:7
#define FASTCALL
Definition: nt_native.h:50
#define NTSYSAPI
Definition: ntoskrnl.h:14
ULONG Wcr[ARM_MAX_WATCHPOINTS]
Definition: ke.h:288
_Kernel_requires_resource_held_(FloatState) _Kernel_releases_resource_(FloatState)) FORCEINLINE NTSTATUS KeRestoreFloatingPointState(_In_ PKFLOATING_SAVE FloatSave)
Definition: ke.h:145
ULONG SecondLevelCacheSize
Definition: ke.h:308
USHORT MinorVersion
Definition: ke.h:304
_In_ PKSERVICE_ROUTINE _In_opt_ PVOID _In_opt_ PKSPIN_LOCK SpinLock
Definition: iofuncs.h:798
FORCEINLINE VOID YieldProcessor(VOID)
Definition: ke.h:32
FORCEINLINE ULONG KeGetCurrentProcessorNumber(VOID)
Definition: ke.h:325
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define HIGH_LEVEL
#define _Acquires_lock_(lock)
Definition: no_sal2.h:677
ULONG R8
Definition: compat.h:343
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
NTKERNELAPI KIRQL NTAPI KfRaiseIrql(IN KIRQL NewIrql)
Definition: pic.c:187
FORCEINLINE PRKTHREAD KeGetCurrentThread(VOID)
Definition: ke.h:284
PVOID Used_Self
Definition: ke.h:293
PVOID KdVersionBlock
Definition: ke.h:311
__INTRIN_INLINE void __yield(void)
Definition: intrin_arm.h:38
#define _Releases_lock_(a)
Definition: btrfs_drv.h:186
#define ARM_MAX_WATCHPOINTS
Definition: ke.h:232
unsigned char BOOLEAN
#define FORCEINLINE
Definition: ntbasedef.h:221
#define _Out_
Definition: no_sal2.h:323
#define _At_(target, annos)
Definition: no_sal2.h:11
ULONG R9
Definition: compat.h:344
#define NTKERNELAPI
#define _Kernel_float_restored_
Definition: no_sal2.h:659
_Reserved_ PVOID Reserved
Definition: winddi.h:3974
ULONG R1
Definition: compat.h:336
$endif(_WDMDDK_) $if(_NTDDK_) typedef struct _NEON128
Definition: ke.h:202
USHORT InterruptPad
Definition: ke.h:329
#define CP15_PCR_RESERVED_MASK
Definition: ke.h:336
ULONG R4
Definition: compat.h:339
USHORT MajorVersion
Definition: ke.h:303
ULONG ContextFlags
Definition: compat.h:331
ULONG Fpscr
Definition: ke.h:275
#define KeRestoreFloatingPointState(x)
Definition: kmixer.h:33
#define _Kernel_acquires_resource_(kind)
Definition: no_sal2.h:666
int64_t LONGLONG
Definition: typedefs.h:66
ULONG TibPad0[2]
Definition: ke.h:303
struct _KPRCB * CurrentPrcb
Definition: ke.h:291
_Kernel_requires_resource_not_held_(FloatState) _Kernel_acquires_resource_(FloatState)) FORCEINLINE NTSTATUS KeSaveFloatingPointState(_Out_ PKFLOATING_SAVE FloatSave)
Definition: ke.h:133
LONG High1Time
Definition: ketypes.h:911
UCHAR DispatchInterrupt
Definition: ke.h:326
#define _Notliteral_
Definition: no_sal2.h:315
ULONG HalReserved[16]
Definition: ke.h:309
ULONG R11
Definition: ke.h:266
VOID FASTCALL KfReleaseSpinLock(PKSPIN_LOCK SpinLock, KIRQL OldIrql)
Definition: spinlock.c:96
uint64_t ULONGLONG
Definition: typedefs.h:65
_Requires_lock_held_ SpinLock _Releases_lock_ SpinLock _IRQL_requires_(DISPATCH_LEVEL) NTHALAPI VOID FASTCALL KfReleaseSpinLock(_Inout_ PKSPIN_LOCK SpinLock
Definition: expool.c:1456
ULONG Bvr[ARM_MAX_BREAKPOINTS]
Definition: ke.h:285
NEON128 Q[16]
Definition: ke.h:279
#define _Inout_
Definition: no_sal2.h:244
_Always_(_Post_satisfies_(return<=0)) _Must_inspect_result_ _IRQL_requires_max_(DISPATCH_LEVEL) _Kernel_float_saved_ _At_(*FloatSave
Definition: strmini.h:378
unsigned char UCHAR
Definition: xmlstorage.h:181
#define _Kernel_float_saved_
Definition: no_sal2.h:660
#define CP15_TPIDRPRW
Definition: ke.h:200
NTKERNELAPI volatile KSYSTEM_TIME KeTickCount
Definition: clock.c:19
#define KeSaveFloatingPointState(x)
Definition: kmixer.h:32
PVOID Unused1[3]
Definition: ke.h:306
struct _CONTEXT CONTEXT
#define DISPATCH_LEVEL
NT_TIB NtTib
Definition: ke.h:284
_Success_(1) _Kernel_float_restored_ _At_(*FloatSave
ULONG Padding2[2]
Definition: ke.h:290
#define _ANONYMOUS_STRUCT
Definition: ntbasedef.h:56
_IRQL_requires_max_(HIGH_LEVEL) _IRQL_saves_ FORCEINLINE KIRQL KeGetCurrentIrql(VOID)
Definition: ke.h:68
FORCEINLINE PKPCR KeGetPcr(VOID)
Definition: ke.h:318
UCHAR SecondLevelCacheAssociativity
Definition: ke.h:299
#define _In_
Definition: no_sal2.h:204
LONG High2Time
Definition: ketypes.h:912
unsigned short USHORT
Definition: pedump.c:61
KIRQL CurrentIrql
Definition: ke.h:311
ULONG Cpsr
Definition: compat.h:353
NTKERNELAPI VOID NTAPI KfLowerIrql(IN KIRQL NewIrql)
Definition: pic.c:232
ULONG R5
Definition: compat.h:340
struct _KPCR KPCR
ULONG Wvr[ARM_MAX_WATCHPOINTS]
Definition: ke.h:287
ULONG R7
Definition: compat.h:342
ULONG R12
Definition: ke.h:267
#define _Post_satisfies_(a)
Definition: btrfs_drv.h:189
PVOID Spare1
Definition: ke.h:304
ULONGLONG D[32]
Definition: ke.h:280
ULONG Unused0[3]
Definition: ke.h:302
VOID FASTCALL KefReleaseSpinLockFromDpcLevel(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.c:259
NTKERNELAPI KIRQL NTAPI KeRaiseIrqlToDpcLevel(VOID)
Definition: pic.c:133
ULONG PcrAlign1[24]
Definition: ke.h:313
#define OUT
Definition: typedefs.h:39
KIRQL FASTCALL KfAcquireSpinLock(PKSPIN_LOCK SpinLock)
Definition: spinlock.c:85
unsigned int ULONG
Definition: retypes.h:1
ULONG Sp
Definition: compat.h:350
ULONG Padding
Definition: ke.h:276
VOID FASTCALL KefAcquireSpinLockAtDpcLevel(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.c:237
NEON128
Definition: ke.h:229
ULONG R10
Definition: compat.h:345
#define _IRQL_raises_(irql)
Definition: no_sal2.h:648
struct _KPCR * PKPCR
ULONG KernelReserved[15]
Definition: ke.h:307
ULONG R2
Definition: compat.h:337
FORCEINLINE VOID KeMemoryBarrier(VOID)
Definition: ke.h:58
ULONG Pc
Definition: compat.h:352
return STATUS_SUCCESS
Definition: btrfs.c:2966
ULONG R3
Definition: compat.h:338
ULONG Bcr[ARM_MAX_BREAKPOINTS]
Definition: ke.h:286
* PNEON128
Definition: ke.h:229
#define _NTDDK_
#define _Requires_lock_held_(a)
Definition: btrfs_drv.h:184
#define _IRQL_restores_
Definition: no_sal2.h:653
ULONG Lr
Definition: compat.h:351
_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