ReactOS 0.4.16-dev-197-g92996da
ke.h File Reference

Go to the source code of this file.

Classes

struct  _KPCR
 
struct  _KFLOATING_SAVE
 

Macros

#define PASSIVE_LEVEL   0
 
#define APC_LEVEL   1
 
#define DISPATCH_LEVEL   2
 
#define PROFILE_LEVEL   27
 
#define IPI_LEVEL   29
 
#define HIGH_LEVEL   31
 
#define KeGetPcr()   PCR
 
#define YieldProcessor()   __asm__ __volatile__("nop");
 
#define KeLowerIrql(a)   KfLowerIrql(a)
 
#define KeRaiseIrql(a, b)   *(b) = KfRaiseIrql(a)
 

Typedefs

typedef ULONG PFN_NUMBER
 
typedef ULONGPPFN_NUMBER
 
typedef LONG SPFN_NUMBER
 
typedef LONGPSPFN_NUMBER
 
typedef struct _KPCR KPCR
 
typedef struct _KPCRPKPCR
 
typedef struct _KFLOATING_SAVE KFLOATING_SAVE
 
typedef struct _KFLOATING_SAVEPKFLOATING_SAVE
 

Functions

 $if (_WDMDDK_) typedef ULONG PFN_COUNT
 
static __inline ULONG NTAPI KeGetCurrentProcessorNumber (VOID)
 
NTKERNELAPI VOID NTAPI KfLowerIrql (IN KIRQL NewIrql)
 
NTKERNELAPI KIRQL NTAPI KfRaiseIrql (IN KIRQL NewIrql)
 
NTKERNELAPI KIRQL NTAPI KeRaiseIrqlToDpcLevel (VOID)
 
NTKERNELAPI KIRQL NTAPI KeRaiseIrqlToSynchLevel (VOID)
 

Macro Definition Documentation

◆ APC_LEVEL

#define APC_LEVEL   1

Definition at line 13 of file ke.h.

◆ DISPATCH_LEVEL

#define DISPATCH_LEVEL   2

Definition at line 14 of file ke.h.

◆ HIGH_LEVEL

#define HIGH_LEVEL   31

Definition at line 17 of file ke.h.

◆ IPI_LEVEL

#define IPI_LEVEL   29

Definition at line 16 of file ke.h.

◆ KeGetPcr

#define KeGetPcr ( )    PCR

Definition at line 26 of file ke.h.

◆ KeLowerIrql

#define KeLowerIrql (   a)    KfLowerIrql(a)

Definition at line 41 of file ke.h.

◆ KeRaiseIrql

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

Definition at line 42 of file ke.h.

◆ PASSIVE_LEVEL

#define PASSIVE_LEVEL   0

Definition at line 12 of file ke.h.

◆ PROFILE_LEVEL

#define PROFILE_LEVEL   27

Definition at line 15 of file ke.h.

◆ YieldProcessor

#define YieldProcessor ( )    __asm__ __volatile__("nop");

Definition at line 39 of file ke.h.

Typedef Documentation

◆ KFLOATING_SAVE

◆ KPCR

typedef struct _KPCR KPCR

◆ PFN_NUMBER

typedef ULONG PFN_NUMBER

Definition at line 9 of file ke.h.

◆ PKFLOATING_SAVE

◆ PKPCR

typedef struct _KPCR * PKPCR

◆ PPFN_NUMBER

typedef ULONG * PPFN_NUMBER

Definition at line 9 of file ke.h.

◆ PSPFN_NUMBER

typedef LONG * PSPFN_NUMBER

Definition at line 10 of file ke.h.

◆ SPFN_NUMBER

typedef LONG SPFN_NUMBER

Definition at line 10 of file ke.h.

Function Documentation

◆ $if()

$if ( _WDMDDK_  )

Kernel definitions for MIPS

Kernel definitions for AMD64

Kernel definitions for ARM

Kernel definitions for ARM64

Kernel definitions for AMD64

Kernel definitions for ARM

Kernel definitions for x86

Definition at line 1 of file ke.h.

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

◆ KeGetCurrentProcessorNumber()

static __inline ULONG NTAPI KeGetCurrentProcessorNumber ( VOID  )
static

Definition at line 34 of file ke.h.

35{
36 return 0;
37}

◆ KeRaiseIrqlToDpcLevel()

NTKERNELAPI KIRQL NTAPI KeRaiseIrqlToDpcLevel ( VOID  )

Definition at line 133 of file pic.c.

134{
135 PKPCR Pcr = KeGetPcr();
136 KIRQL CurrentIrql;
137
138 /* Save and update IRQL */
139 CurrentIrql = Pcr->Irql;
140 Pcr->Irql = DISPATCH_LEVEL;
141
142#ifdef IRQL_DEBUG
143 /* Validate correct raise */
144 if (CurrentIrql > DISPATCH_LEVEL) KeBugCheck(IRQL_NOT_GREATER_OR_EQUAL);
145#endif
146
147 /* Return the previous value */
148 return CurrentIrql;
149}
DECLSPEC_NORETURN VOID NTAPI KeBugCheck(ULONG BugCheckCode)
Definition: bug.c:1430
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
#define KeGetPcr()
Definition: ketypes.h:81
Definition: ke.h:294
KIRQL Irql
Definition: ke.h:311

◆ KeRaiseIrqlToSynchLevel()

NTKERNELAPI KIRQL NTAPI KeRaiseIrqlToSynchLevel ( VOID  )

Definition at line 156 of file pic.c.

157{
158 PKPCR Pcr = KeGetPcr();
159 KIRQL CurrentIrql;
160
161 /* Save and update IRQL */
162 CurrentIrql = Pcr->Irql;
163 Pcr->Irql = SYNCH_LEVEL;
164
165#ifdef IRQL_DEBUG
166 /* Validate correct raise */
167 if (CurrentIrql > SYNCH_LEVEL)
168 {
169 /* Crash system */
170 KeBugCheckEx(IRQL_NOT_GREATER_OR_EQUAL,
171 CurrentIrql,
173 0,
174 1);
175 }
176#endif
177
178 /* Return the previous value */
179 return CurrentIrql;
180}
#define SYNCH_LEVEL
Definition: env_spec_w32.h:704
VOID NTAPI KeBugCheckEx(_In_ ULONG BugCheckCode, _In_ ULONG_PTR BugCheckParameter1, _In_ ULONG_PTR BugCheckParameter2, _In_ ULONG_PTR BugCheckParameter3, _In_ ULONG_PTR BugCheckParameter4)
Definition: rtlcompat.c:108

◆ KfLowerIrql()

NTKERNELAPI VOID NTAPI KfLowerIrql ( IN KIRQL  NewIrql)

Definition at line 232 of file pic.c.

233{
235 PKPCR Pcr = KeGetPcr();
236 ULONG InterruptMask;
237
238 /* Disableinterrupts */
240 _disable();
241
242#ifdef IRQL_DEBUG
243 /* Validate correct lower */
244 if (OldIrql > Pcr->Irql)
245 {
246 /* Crash system */
247 Pcr->Irql = HIGH_LEVEL;
248 KeBugCheck(IRQL_NOT_LESS_OR_EQUAL);
249 }
250#endif
251
252 /* Clear interrupts associated to the old IRQL */
254
255 /* Set the new interrupt mask */
256 InterruptMask = Pcr->IrqlTable[NewIrql];
257 WRITE_REGISTER_ULONG(VIC_INT_ENABLE, InterruptMask);
258
259 /* Save the new IRQL and restore interrupt state */
260 Pcr->Irql = NewIrql;
261 if (!Flags.IrqDisable) _enable();
262}
FORCEINLINE ARM_STATUS_REGISTER KeArmStatusRegisterGet(VOID)
Definition: intrin_i.h:122
#define WRITE_REGISTER_ULONG(r, v)
Definition: arm.h:27
#define HIGH_LEVEL
Definition: env_spec_w32.h:703
void __cdecl _disable(void)
Definition: intrin_arm.h:365
void __cdecl _enable(void)
Definition: intrin_arm.h:373
#define VIC_INT_ENABLE
Definition: pl190.h:17
#define VIC_INT_CLEAR
Definition: pl190.h:18
_Requires_lock_held_ SpinLock _Releases_lock_ SpinLock _In_ _IRQL_restores_ KIRQL NewIrql
Definition: ke.h:114
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:778

◆ KfRaiseIrql()

NTKERNELAPI KIRQL NTAPI KfRaiseIrql ( IN KIRQL  NewIrql)

Definition at line 187 of file pic.c.

188{
190 PKPCR Pcr = KeGetPcr();
191 KIRQL CurrentIrql;
192 ULONG InterruptMask;
193
194 /* Disable interrupts */
196 _disable();
197
198 /* Read current IRQL */
199 CurrentIrql = Pcr->Irql;
200
201#ifdef IRQL_DEBUG
202 /* Validate correct raise */
203 if (CurrentIrql > NewIrql)
204 {
205 /* Crash system */
206 Pcr->Irql = PASSIVE_LEVEL;
207 KeBugCheck(IRQL_NOT_GREATER_OR_EQUAL);
208 }
209#endif
210 /* Clear interrupts associated to the old IRQL */
212
213 /* Set the new interrupt mask */
214 InterruptMask = Pcr->IrqlTable[NewIrql];
215 WRITE_REGISTER_ULONG(VIC_INT_ENABLE, InterruptMask);
216
217 /* Set new IRQL */
218 Pcr->Irql = NewIrql;
219
220 /* Restore interrupt state */
221 if (!Flags.IrqDisable) _enable();
222
223 /* Return old IRQL */
224 return CurrentIrql;
225}
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693