ReactOS 0.4.16-dev-329-g9223134
ke.h File Reference

Go to the source code of this file.

Classes

struct  _KFLOATING_SAVE
 
struct  _KPCR_TIB
 
struct  _KPCR
 

Macros

#define PASSIVE_LEVEL   0
 
#define LOW_LEVEL   0
 
#define APC_LEVEL   1
 
#define DISPATCH_LEVEL   2
 
#define PROFILE_LEVEL   27
 
#define CLOCK1_LEVEL   28
 
#define CLOCK2_LEVEL   28
 
#define IPI_LEVEL   29
 
#define POWER_LEVEL   30
 
#define HIGH_LEVEL   31
 
#define PCR_MINOR_VERSION   1
 
#define PCR_MAJOR_VERSION   1
 
#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 _KFLOATING_SAVE KFLOATING_SAVE
 
typedef struct _KFLOATING_SAVEPKFLOATING_SAVE
 
typedef struct _KPCR_TIB KPCR_TIB
 
typedef struct _KPCR_TIBPKPCR_TIB
 
typedef struct _KPCR KPCR
 
typedef struct _KPCRPKPCR
 

Functions

 $if (_WDMDDK_) typedef ULONG PFN_COUNT
 
FORCEINLINE ULONG NTAPI KeGetCurrentProcessorNumber (VOID)
 
NTHALAPI VOID FASTCALL KfLowerIrql (IN KIRQL NewIrql)
 
NTHALAPI KIRQL FASTCALL KfRaiseIrql (IN KIRQL NewIrql)
 
NTHALAPI KIRQL NTAPI KeRaiseIrqlToDpcLevel (VOID)
 
NTHALAPI KIRQL NTAPI KeRaiseIrqlToSynchLevel (VOID)
 

Macro Definition Documentation

◆ APC_LEVEL

#define APC_LEVEL   1

◆ CLOCK1_LEVEL

#define CLOCK1_LEVEL   28

◆ CLOCK2_LEVEL

#define CLOCK2_LEVEL   28

◆ DISPATCH_LEVEL

#define DISPATCH_LEVEL   2

◆ HIGH_LEVEL

#define HIGH_LEVEL   31

◆ IPI_LEVEL

#define IPI_LEVEL   29

◆ KeGetPcr

#define KeGetPcr ( )    PCR

Definition at line 64 of file ke.h.

◆ KeLowerIrql

#define KeLowerIrql (   a)    KfLowerIrql(a)

Definition at line 87 of file ke.h.

◆ KeRaiseIrql

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

Definition at line 94 of file ke.h.

◆ LOW_LEVEL

#define LOW_LEVEL   0

◆ PASSIVE_LEVEL

#define PASSIVE_LEVEL   0

◆ PCR_MAJOR_VERSION

#define PCR_MAJOR_VERSION   1

Definition at line 42 of file ke.h.

◆ PCR_MINOR_VERSION

#define PCR_MINOR_VERSION   1

Definition at line 41 of file ke.h.

◆ POWER_LEVEL

#define POWER_LEVEL   30

◆ PROFILE_LEVEL

#define PROFILE_LEVEL   27

◆ YieldProcessor

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

Definition at line 66 of file ke.h.

Typedef Documentation

◆ KFLOATING_SAVE

◆ KPCR

typedef struct _KPCR KPCR

◆ KPCR_TIB

◆ PFN_NUMBER

typedef ULONG PFN_NUMBER

Definition at line 20 of file ke.h.

◆ PKFLOATING_SAVE

◆ PKPCR

typedef struct _KPCR * PKPCR

◆ PKPCR_TIB

◆ PPFN_NUMBER

typedef ULONG * PPFN_NUMBER

Definition at line 20 of file ke.h.

◆ PSPFN_NUMBER

typedef LONG * PSPFN_NUMBER

Definition at line 21 of file ke.h.

◆ SPFN_NUMBER

typedef LONG SPFN_NUMBER

Definition at line 21 of file ke.h.

Function Documentation

◆ $if()

$if ( _WDMDDK_  )

Kernel definitions for PPC

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()

FORCEINLINE ULONG NTAPI KeGetCurrentProcessorNumber ( VOID  )

Definition at line 71 of file ke.h.

72{
74 __asm__ __volatile__ (
75 "lwz %0, %c1(12)\n"
76 : "=r" (Number)
77 : "i" (FIELD_OFFSET(KPCR, Number))
78 );
79 return Number;
80}
_In_opt_ PENTER_STATE_SYSTEM_HANDLER _In_opt_ PVOID _In_ LONG _In_opt_ LONG volatile * Number
Definition: ntpoapi.h:207
__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")
Definition: ke.h:294
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255

◆ KeRaiseIrqlToDpcLevel()

NTHALAPI 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
KIRQL Irql
Definition: ke.h:311

◆ KeRaiseIrqlToSynchLevel()

NTHALAPI 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()

NTHALAPI VOID FASTCALL 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

Referenced by HalpGrowMapBufferWorker(), KeLowerIrql(), KeQueryPerformanceCounter(), KeReleaseInStackQueuedSpinLock(), KeReleaseQueuedSpinLock(), KiChainedDispatch(), KiCheckForApcDelivery(), KiExitV86Trap(), KiInitializeSystem(), and KiThreadStartup().

◆ KfRaiseIrql()

NTHALAPI KIRQL FASTCALL 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

Referenced by _IRQL_requires_max_(), _Requires_lock_not_held_(), HalInitSystem(), HalpGrowMapBufferWorker(), KeAcquireInStackQueuedSpinLock(), KeAcquireInStackQueuedSpinLockRaiseToSynch(), KeAcquireQueuedSpinLock(), KeAcquireQueuedSpinLockRaiseToSynch(), KeAcquireSpinLockRaiseToSynch(), KeQueryPerformanceCounter(), KeRaiseIrql(), KeRaiseIrqlToDpcLevel(), KeRaiseIrqlToSynchLevel(), KeSynchronizeExecution(), KfAcquireSpinLock(), KiAcquireDispatcherLock(), KiChainedDispatch(), KiCheckForApcDelivery(), KiExitV86Trap(), KiIdleLoop(), KiInitializeKernel(), KiInitializeSystem(), KiInterruptHandler(), KiSystemStartup(), KiSystemStartupBootStack(), and KxRaiseIrql().