MacInterruptServiceRoutine

BOOLEAN
   MacInterruptServiceRoutine(
       IN PVOID InterruptContext
       );

MacInterruptServiceRoutine is a full-NIC driver’s ISR, called when the NIC generates an interrupt.

Parameters

InterruptContext

Points to the context that the NIC driver associates with the interrupt. The NIC driver provided this context area (MacAdapterContext) when it called NdisInitializeInterrupt during initialization.

Return Value

MacInterruptServiceRoutine returns TRUE if its NIC generated the interrupt. TRUE also tells NDIS to queue a call to MacDeferredProcessingRoutine, so drivers of NICs that do not share IRQs always return TRUE from their ISRs.

Comments

If the driver called NdisInitializeInterrupt with the InterruptMode set to NdisInterruptLevelSensitive, its MacInterruptServiceRoutine must dismiss the interrupt on the NIC before it returns control. Otherwise, the interrupt remains active, and NDIS calls MacInterruptServiceRoutine repeatedly until the interrupt is dismissed on the NIC.

If the NIC shares an IRQ with other devices, MacInterruptServiceRoutine first determines whether its NIC generated the interrupt and returns FALSE immediately if another device generated the interrupt. Otherwise, MacInterruptServiceRoutine preserves enough state about the operation that caused the interrupt for the driver’s MacDeferredProcessingRoutine to complete the operation.

In other words, a NIC driver does the absolute minimum amount of work in its ISR. When this function returns control, NDIS calls the driver’s MacDeferredProcessingRoutine as soon as possible to complete interrupt processing at a lower hardware priority.

MacInterruptServiceRoutine runs at the DIRQL assigned by the system when the driver called NdisInitializeInterrupt. Consequently, MacInterruptServiceRoutine can call only a small subset of NDIS library functions, while the driver’s MacDeferredProcessingRoutine can call any system-supplied function that is safe to call from IRQL <= DISPATCH_LEVEL.

Because it runs at DIRQL, MacInterruptServiceRoutine can preempt any code that runs at lower IRQL, including most functions in the NDIS library and in the NIC driver itself. If a NIC interrupt can occur while a nonISR NIC driver function is accessing resources that MacInterruptServiceRoutine also could access if an interrupt occurs, the nonISR function must call NdisSynchronizeWithInterrupt to synchronize its access with the ISR.

MacInterruptServiceRoutine runs at DIRQL, which is > DISPATCH_LEVEL.

See Also

MacAddAdapter, MacDeferredProcessingRoutine, MacSynchronizeFunction, MiniportISR, NdisAcquireSpinLock, NdisInitializeInterrupt, NdisReleaseSpinLock, NdisSynchronizeWithInterrupt