Muokkaa

Jaa


Creating an Interrupt Object (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.

A UMDF driver that handles a device's hardware interrupts must create a framework interrupt object for each interrupt that each device can support.

Typically, a driver creates framework interrupt objects in IDriverEntry::OnDeviceAdd. However, you can also create interrupt objects in IPnpCallbackHardware2::OnPrepareHardware.

To create a framework interrupt object, your driver must initialize a WUDF_INTERRUPT_CONFIG structure and pass it to the IWDFDevice3::CreateInterrupt method. This method registers the following driver-supplied event callback functions:

OnInterruptEnable
Enables a hardware interrupt.

OnInterruptDisable
Disables a hardware interrupt.

OnInterruptIsr
The interrupt service routine (ISR) for the interrupt.

OnInterruptWorkItem
The worker routine for the interrupt.

Optionally, the driver can call IWDFInterrupt::SetPolicy or IWDFInterrupt::SetExtendedPolicy to specify additional interrupt parameters.

The framework calls the driver's IDriverEntry::OnDeviceAdd callback function before the Plug and Play (PnP) manager has assigned system resources, such as interrupt vectors, to the device. After the PnP manager assigns resources, the framework stores interrupt resources in the device's interrupt object. (Drivers that don't support Plug and Play cannot use interrupt objects.)

Message-signaled interrupts (MSIs) are supported in Windows Vista and later versions of the operating system. To enable the operating system to support MSIs for your device, your driver's INF file must set some values in the registry. For information about how to set these values, see Enabling Message-Signaled Interrupts in the Registry.

If a device can support a certain number of MSI messages, the PnP manager will try to assign that number of messages to the device. If the PnP manager cannot assign all of the messages that the device can support, it will assign only one message to the device.

Your driver should create a framework interrupt object for each interrupt vector or MSI message that the device can support. If the PnP manager doesn't grant the device all of the interrupt resources that the device can support, the extra interrupt objects won't be used, and their callback functions won't be called.