ReactOS  r74431
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

#define APC_LEVEL   1

Definition at line 12 of file ke.h.

#define DISPATCH_LEVEL   2

Definition at line 13 of file ke.h.

#define HIGH_LEVEL   31

Definition at line 16 of file ke.h.

#define IPI_LEVEL   29

Definition at line 15 of file ke.h.

#define KeGetPcr ( )    PCR

Definition at line 25 of file ke.h.

Referenced by _HalpApcInterruptHandler(), _HalpDismissIrqGeneric(), _HalpDismissIrqLevel(), _HalpDispatchInterruptHandler(), ApicInitializeLocalApic(), ApicLowerIrql(), HalBeginSystemInterrupt(), HalClearSoftwareInterrupt(), HalDisableSystemInterrupt(), HalEnableSystemInterrupt(), HalEndSystemInterrupt(), HalInitializeProcessor(), HalInitSystem(), HalpBiosCall(), HalpBiosDisplayReset(), HalpBorrowTss(), HalpCalibrateStallExecution(), HalpDispatchInterrupt2(), HalpEnableInterruptHandler(), HalpEndSoftwareInterrupt2(), HalpExecuteIrqs(), HalpHardwareInterruptLevel(), HalpInitializeClock(), HalpInitializeInterrupts(), HalpInitializeTsc(), HalpInitProcessor(), HalpLowerIrql(), HalpRestoreIoPermissionsAndTask(), HalpReturnTss(), HalpSetupRealModeIoPermissionsAndTask(), HalpTrap06(), HalRequestSoftwareInterrupt(), KdbpCmdPcr(), KdbpCmdTss(), KdInitSystem(), Ke386CallBios(), Ke386GetGdtEntryThread(), Ke386IoSetAccessProcess(), Ke386QueryIoAccessMap(), Ke386SetIoAccessMap(), KeGetCurrentIrql(), KeGetCurrentPrcb(), KeI386VdmInitialize(), KeInitExceptions(), KeRaiseIrqlToDpcLevel(), KeRaiseIrqlToSynchLevel(), KeRosDumpTriageForBugZillaReport(), KeSetBaseGdtSelector(), KeSetGdtSelector(), KeStallExecutionProcessor(), KfLowerIrql(), KfRaiseIrql(), Ki386AdjustEsp0(), Ki386EnableXMMIExceptions(), KiCallbackReturnHandler(), KiCommonExit(), KiDecrementerTrap(), KiDispatchException(), KiDispatchInterrupt(), KiEnterInterruptTrap(), KiEnterTrap(), KiEnterV86Mode(), KiEnterV86Trap(), KiExitSystemCallDebugChecks(), KiExitV86Mode(), KiGetCacheInformation(), KiI386PentiumLockErrataFixup(), KiInitializeKernel(), KiInitializePcr(), KiInitializeSystem(), KiInitializeTss(), KiInterruptHandler(), KiSwapContext(), KiSwapContextEntry(), KiSwapContextExit(), KiSwapContextResume(), KiSwapProcess(), KiSystemService(), KiSystemServiceHandler(), KiTrap02(), KiUserModeCallout(), MiComputeColorInformation(), MiInitMachineDependent(), MpsTimerHandler(), NtCallbackReturn(), NtCurrentTeb(), NtRaiseException(), RtlpCaptureStackLimits(), and SetInterruptGate().

#define KeLowerIrql (   a)    KfLowerIrql(a)

Definition at line 40 of file ke.h.

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

Definition at line 41 of file ke.h.

#define PASSIVE_LEVEL   0

Definition at line 11 of file ke.h.

#define PROFILE_LEVEL   27

Definition at line 14 of file ke.h.

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

Definition at line 38 of file ke.h.

Typedef Documentation

typedef struct _KPCR KPCR
typedef ULONG PFN_NUMBER

Definition at line 8 of file ke.h.

typedef struct _KPCR * PKPCR
typedef ULONG * PPFN_NUMBER

Definition at line 8 of file ke.h.

typedef LONG * PSPFN_NUMBER

Definition at line 9 of file ke.h.

typedef LONG SPFN_NUMBER

Definition at line 9 of file ke.h.

Function Documentation

$if ( _WDMDDK_  )

Kernel definitions for AMD64

Kernel definitions for ARM

Kernel definitions for AMD64

Kernel definitions for ARM

Kernel definitions for x86

Definition at line 1 of file ke.h.

31 {
32  ULONG Dummy;
struct _KFLOATING_SAVE KFLOATING_SAVE
struct _KFLOATING_SAVE * PKFLOATING_SAVE
unsigned int ULONG
Definition: retypes.h:1
static __inline ULONG NTAPI KeGetCurrentProcessorNumber ( VOID  )
static

Definition at line 33 of file ke.h.

34 {
35  return 0;
36 }
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 }
KIRQL Irql
Definition: ke.h:298
Definition: ke.h:280
#define KeGetPcr()
Definition: ke.h:25
UCHAR KIRQL
Definition: env_spec_w32.h:591
VOID NTAPI KeBugCheck(ULONG BugCheckCode)
Definition: bug.c:1469
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
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,
172  SYNCH_LEVEL,
173  0,
174  1);
175  }
176 #endif
177 
178  /* Return the previous value */
179  return CurrentIrql;
180 }
KIRQL Irql
Definition: ke.h:298
Definition: ke.h:280
#define KeGetPcr()
Definition: ke.h:25
UCHAR KIRQL
Definition: env_spec_w32.h:591
#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:90
NTKERNELAPI VOID NTAPI KfLowerIrql ( IN KIRQL  NewIrql)

Definition at line 232 of file pic.c.

Referenced by KiCheckForApcDelivery().

233 {
235  PKIPCR Pcr = (PKIPCR)KeGetPcr();
236  ULONG InterruptMask;
237 
238  /* Disableinterrupts */
239  Flags = KeArmStatusRegisterGet();
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 */
253  WRITE_REGISTER_ULONG(VIC_INT_CLEAR, 0xFFFFFFFF);
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 }
#define VIC_INT_ENABLE
Definition: pl190.h:17
#define VIC_INT_CLEAR
Definition: pl190.h:18
NTKERNELAPI VOID NTAPI WRITE_REGISTER_ULONG(IN PULONG Register, IN ULONG Value)
void __cdecl _enable(void)
Definition: intrin_arm.h:373
struct _KIPCR * PKIPCR
KIRQL Irql
Definition: ketypes.h:871
#define KeGetPcr()
Definition: ke.h:25
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
FORCEINLINE ARM_STATUS_REGISTER KeArmStatusRegisterGet(VOID)
Definition: intrin_i.h:122
VOID NTAPI KeBugCheck(ULONG BugCheckCode)
Definition: bug.c:1469
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
#define HIGH_LEVEL
Definition: env_spec_w32.h:703
UCHAR IrqlTable[9]
Definition: ketypes.h:546
void __cdecl _disable(void)
Definition: intrin_arm.h:365
unsigned int ULONG
Definition: retypes.h:1
_Requires_lock_held_ SpinLock _Releases_lock_ SpinLock _In_ _IRQL_restores_ KIRQL NewIrql
Definition: ke.h:114
NTKERNELAPI KIRQL NTAPI KfRaiseIrql ( IN KIRQL  NewIrql)

Definition at line 187 of file pic.c.

Referenced by _IRQL_requires_max_(), KeRaiseIrqlToSynchLevel(), and KiCheckForApcDelivery().

188 {
190  PKIPCR Pcr = (PKIPCR)KeGetPcr();
191  KIRQL CurrentIrql;
192  ULONG InterruptMask;
193 
194  /* Disable interrupts */
195  Flags = KeArmStatusRegisterGet();
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 */
211  WRITE_REGISTER_ULONG(VIC_INT_CLEAR, 0xFFFFFFFF);
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 VIC_INT_ENABLE
Definition: pl190.h:17
#define VIC_INT_CLEAR
Definition: pl190.h:18
NTKERNELAPI VOID NTAPI WRITE_REGISTER_ULONG(IN PULONG Register, IN ULONG Value)
void __cdecl _enable(void)
Definition: intrin_arm.h:373
struct _KIPCR * PKIPCR
KIRQL Irql
Definition: ketypes.h:871
#define KeGetPcr()
Definition: ke.h:25
UCHAR KIRQL
Definition: env_spec_w32.h:591
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
FORCEINLINE ARM_STATUS_REGISTER KeArmStatusRegisterGet(VOID)
Definition: intrin_i.h:122
VOID NTAPI KeBugCheck(ULONG BugCheckCode)
Definition: bug.c:1469
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
UCHAR IrqlTable[9]
Definition: ketypes.h:546
void __cdecl _disable(void)
Definition: intrin_arm.h:365
unsigned int ULONG
Definition: retypes.h:1
_Requires_lock_held_ SpinLock _Releases_lock_ SpinLock _In_ _IRQL_restores_ KIRQL NewIrql
Definition: ke.h:114