ReactOS  r76032
pic.c File Reference
#include <hal.h>
#include <debug.h>
Include dependency graph for pic.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

VOID HalpInitializeInterrupts (VOID)
 
ULONG HalGetInterruptSource (VOID)
 
KIRQL NTAPI KeGetCurrentIrql (VOID)
 
KIRQL NTAPI KeRaiseIrqlToDpcLevel (VOID)
 
KIRQL NTAPI KeRaiseIrqlToSynchLevel (VOID)
 
KIRQL FASTCALL KfRaiseIrql (IN KIRQL NewIrql)
 
VOID FASTCALL KfLowerIrql (IN KIRQL NewIrql)
 
VOID FASTCALL HalRequestSoftwareInterrupt (IN KIRQL Irql)
 
VOID FASTCALL HalClearSoftwareInterrupt (IN KIRQL Irql)
 
BOOLEAN NTAPI HalEnableSystemInterrupt (IN ULONG Vector, IN KIRQL Irql, IN KINTERRUPT_MODE InterruptMode)
 
VOID NTAPI HalDisableSystemInterrupt (IN ULONG Vector, IN KIRQL Irql)
 
BOOLEAN NTAPI HalBeginSystemInterrupt (IN KIRQL Irql, IN ULONG Vector, OUT PKIRQL OldIrql)
 
VOID NTAPI HalEndSystemInterrupt (IN KIRQL OldIrql, IN PKTRAP_FRAME TrapFrame)
 

Variables

ULONG HalpIrqlTable [HIGH_LEVEL+1]
 
UCHAR HalpMaskTable [HIGH_LEVEL+1]
 

Macro Definition Documentation

#define NDEBUG

Definition at line 12 of file pic.c.

Function Documentation

BOOLEAN NTAPI HalBeginSystemInterrupt ( IN KIRQL  Irql,
IN ULONG  Vector,
OUT PKIRQL  OldIrql 
)

Definition at line 321 of file pic.c.

Referenced by HalpClockInterruptHandler(), KiChainedDispatch(), KiInterruptDispatch(), KiInterruptDispatch3(), and KiUnexpectedInterruptTailHandler().

324 {
326  while (TRUE);
327  return FALSE;
328 }
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define UNIMPLEMENTED
Definition: debug.h:114
VOID FASTCALL HalClearSoftwareInterrupt ( IN KIRQL  Irql)

Definition at line 282 of file pic.c.

Referenced by KiApcInterrupt(), KiIdleLoop(), and KiInterruptHandler().

283 {
284  /* Clear software interrupt */
286 }
NTKERNELAPI VOID NTAPI WRITE_REGISTER_ULONG(IN PULONG Register, IN ULONG Value)
_Out_ PKIRQL Irql
Definition: csq.h:179
#define VIC_SOFT_INT_CLEAR
Definition: pl190.h:20
VOID NTAPI HalDisableSystemInterrupt ( IN ULONG  Vector,
IN KIRQL  Irql 
)

Definition at line 309 of file pic.c.

Referenced by HalpInitializeTsc(), KeDisconnectInterrupt(), and VideoPortDisableInterrupt().

311 {
313  while (TRUE);
314 }
#define TRUE
Definition: types.h:120
#define UNIMPLEMENTED
Definition: debug.h:114
BOOLEAN NTAPI HalEnableSystemInterrupt ( IN ULONG  Vector,
IN KIRQL  Irql,
IN KINTERRUPT_MODE  InterruptMode 
)

Definition at line 295 of file pic.c.

Referenced by HalInitSystem(), HalpEnableInterruptHandler(), HalpInitializeTsc(), KeConnectInterrupt(), and VideoPortEnableInterrupt().

298 {
300  while (TRUE);
301  return FALSE;
302 }
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define UNIMPLEMENTED
Definition: debug.h:114
VOID NTAPI HalEndSystemInterrupt ( IN KIRQL  OldIrql,
IN PKTRAP_FRAME  TrapFrame 
)

Definition at line 335 of file pic.c.

Referenced by KiEndInterrupt(), KiExitInterrupt(), and KiInterruptDispatch3().

337 {
339  while (TRUE);
340 }
#define TRUE
Definition: types.h:120
#define UNIMPLEMENTED
Definition: debug.h:114
ULONG HalGetInterruptSource ( VOID  )

Definition at line 108 of file pic.c.

Referenced by KiInterruptHandler().

109 {
110  ULONG InterruptStatus;
111 
112  /* Get the interrupt status, and return the highest bit set */
113  InterruptStatus = READ_REGISTER_ULONG(VIC_INT_STATUS);
114  return 31 - _clz(InterruptStatus);
115 }
NTKERNELAPI ULONG NTAPI READ_REGISTER_ULONG(IN PULONG Register)
#define VIC_INT_STATUS
Definition: pl190.h:16
#define _clz(a)
Definition: intrin_arm.h:398
unsigned int ULONG
Definition: retypes.h:1
VOID HalpInitializeInterrupts ( VOID  )

Definition at line 93 of file pic.c.

Referenced by HalInitSystem().

94 {
95  PKIPCR Pcr = (PKIPCR)KeGetPcr();
96 
97  /* Fill out the IRQL mappings */
98  RtlCopyMemory(Pcr->IrqlTable, HalpIrqlTable, sizeof(Pcr->IrqlTable));
99  RtlCopyMemory(Pcr->IrqlMask, HalpMaskTable, sizeof(Pcr->IrqlMask));
100 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
struct _KIPCR * PKIPCR
#define KeGetPcr()
Definition: ke.h:25
UCHAR HalpMaskTable[HIGH_LEVEL+1]
Definition: pic.c:55
UCHAR IrqlMask[32]
Definition: ketypes.h:545
ULONG HalpIrqlTable[HIGH_LEVEL+1]
Definition: pic.c:19
UCHAR IrqlTable[9]
Definition: ketypes.h:546
VOID FASTCALL HalRequestSoftwareInterrupt ( IN KIRQL  Irql)

Definition at line 271 of file pic.c.

Referenced by KeDetachProcess(), KeFlushQueuedDpcs(), KeInsertQueueDpc(), KeSetTimerEx(), KeUnstackDetachProcess(), KeUpdateRunTime(), KiCheckForKernelApcDelivery(), KiCheckForTimerExpiration(), KiCompleteTimer(), KiExitDispatcher(), KiInsertQueueApc(), KiIpiServiceRoutine(), KiSwapContextExit(), and KiSwapContextResume().

272 {
273  /* Force a software interrupt */
275 }
NTKERNELAPI VOID NTAPI WRITE_REGISTER_ULONG(IN PULONG Register, IN ULONG Value)
_Out_ PKIRQL Irql
Definition: csq.h:179
#define VIC_SOFT_INT
Definition: pl190.h:19
KIRQL NTAPI KeGetCurrentIrql ( VOID  )

Definition at line 122 of file pic.c.

123 {
124  /* Return the IRQL */
125  return KeGetPcr()->Irql;
126 }
#define KeGetPcr()
Definition: ke.h:25
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
KIRQL NTAPI KeRaiseIrqlToSynchLevel ( VOID  )

Definition at line 156 of file pic.c.

Referenced by __declspec(), KeDelayExecutionThread(), KeFlushEntireTb(), KeQueryBasePriorityThread(), KeRemoveQueue(), KeSignalGateBoostPriority(), KeWaitForMultipleObjects(), KeWaitForSingleObject(), KiQuantumEnd(), KiRetireDpcList(), and NtYieldExecution().

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
VOID FASTCALL KfLowerIrql ( IN KIRQL  NewIrql)

Definition at line 232 of file pic.c.

Referenced by HalpGrowMapBufferWorker(), KeQueryPerformanceCounter(), KiChainedDispatch(), KiDecrementerTrap(), KiExitV86Trap(), KiInitializeKernel(), KiInitializeSystem(), and KiThreadStartup().

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
KIRQL FASTCALL KfRaiseIrql ( IN KIRQL  NewIrql)

Definition at line 187 of file pic.c.

Referenced by HalInitSystem(), HalpGrowMapBufferWorker(), KeQueryPerformanceCounter(), KeSynchronizeExecution(), KiAcquireDispatcherLock(), KiChainedDispatch(), KiDecrementerTrap(), KiDpcInterruptHandler(), KiExitV86Trap(), KiIdleLoop(), KiInitializeKernel(), KiInitializeSystem(), KiInterruptHandler(), KiSystemStartup(), KiSystemStartupBootStack(), and KiSystemStartupReal().

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

Variable Documentation

ULONG HalpIrqlTable[HIGH_LEVEL+1]

Definition at line 19 of file pic.c.

Referenced by HalpInitializeInterrupts().

UCHAR HalpMaskTable[HIGH_LEVEL+1]

Definition at line 55 of file pic.c.

Referenced by HalpInitializeInterrupts().