Servicing an Interrupt (UMDF 1)

Warning

UMDF 2 is the latest version of UMDF and supersedes UMDF 1. All new UMDF drivers should be written using UMDF 2. No new features are being added to UMDF 1 and there is limited support for UMDF 1 on newer versions of Windows 10. Universal Windows drivers must use UMDF 2.

The archived UMDF 1 samples can be found in the Windows 11, version 22H2 - May 2022 Driver Samples Update.

For more info, see Getting Started with UMDF.

Servicing an interrupt consists of two steps:

  1. Saving volatile information (such as register contents) quickly, in an interrupt service routine.
  2. Processing the saved volatile information in a workitem routine.

When a device generates a hardware interrupt, the framework calls the driver's interrupt service routine (ISR), which framework-based drivers implement as an OnInterruptIsr callback function.

The OnInterruptIsr callback function, which runs at PASSIVE_LEVEL, must quickly save interrupt information, such as register contents, queue a workitem to process the data further, and return from the ISR to allow servicing of other interrupts if the interrupt line is shared. Because the UMDF driver's ISR runs at PASSIVE_LEVEL, handling PCI line-based interrupts is not recommended. These interrupts are typically shared between multiple devices, some of which might not accept ISR delays. However, you can handle PCI MSI interrupts in a UMDF driver. These interrupts have edge semantics and are not shared.

Typically, the OnInterruptIsr callback function schedules a workitem to process the saved information later. Framework-based drivers implement workitem routines as OnInterruptWorkItem callback functions.

Most drivers use a single OnInterruptWorkItem callback function for each type of interrupt. To schedule execution of an OnInterruptWorkItem callback function, a driver must call IWDFInterrupt::QueueWorkItemForIsr from within the OnInterruptIsr callback function.

If your driver creates multiple framework queue objects for each device, you might consider using a separate workitem object and OnWorkItem callback function for each queue. To schedule execution of an OnWorkItem callback function, the driver must first create one or more workitem objects by calling IWdfDevice3::CreateWorkItem, typically from the driver's IDriverEntry::OnDeviceAdd callback function. Then the driver's OnInterruptIsr callback function can call IWDFWorkItem::Enqueue.

Drivers typically complete I/O requests in their OnInterruptWorkItem or OnWorkItem callback functions.

For an example of a UMDF driver that handles interrupts, see the SpbAccelerometer sample driver, available starting in the Windows 8 WDK.