Hi,
According to msdn, WdfInterruptCreate() can be called during EvtPrepareHardware starting KMDF 1.11
“Drivers typically call the WdfInterruptCreate method from an EvtDriverDeviceAdd callback function. Starting in KMDF version 1.11, drivers can call WdfInterruptCreate from EvtDevicePrepareHardware. If the driver calls WdfInterruptCreate from EvtDriverDeviceAdd, the InterruptRaw and InterruptTranslated members of the WDF_INTERRUPT_CONFIG structure must be NULL. If the driver calls WdfInterruptCreate from EvtDevicePrepareHardware, these members must both be valid.”
My device has many MSI-X interrupts, which I manage to configure correctly when calling from EvtDriverDeviceAdd. However, when trying to configure from EvtDevicePrepareHardware - the fucnction returns with STATUS_INVALID_DEVICE_STATE
Has anyone got any ideas? Help would be much appreceated
Code:
In EvtPrepareHardware()
for (i = 0; i < WdfCmResourceListGetCount(ResourcesTranslated); i++)
{
desc = WdfCmResourceListGetDescriptor(ResourcesTranslated, i);
…
…
switch (desc->Type) {
case CmResourceTypeInterrupt:
DEBUG_P(TRACE_LEVEL_VERBOSE, DBG_PNP, “PrepareHardware() CmResourceTypeInterrupt”);
status = InterruptCreate(pDevExt, WdfCmResourceListGetDescriptor(ResourcesRaw, i), desc);
break;
…
…
NTSTATUS InterruptCreate(IN PDEVICE_EXTENSION pDevExt, PCM_PARTIAL_RESOURCE_DESCRIPTOR Raw, PCM_PARTIAL_RESOURCE_DESCRIPTOR Translated)
{
NTSTATUS status = STATUS_SUCCESS;
WDF_INTERRUPT_CONFIG interruptConfig;
DEBUG_P(TRACE_LEVEL_VERBOSE, DBG_PNP, “InterruptCreate() NumInterruptsConfigured = %d”, pDevExt->NumInterruptsConfigured);
WDF_INTERRUPT_CONFIG_INIT(&interruptConfig, SdInterruptMSIIsr, SdEvtInterruptDpc);
// Setup Interrupt enable/disable routine callbacks
interruptConfig.EvtInterruptEnable = InterruptEnable;
interruptConfig.EvtInterruptDisable = InterruptDisable;
interruptConfig.InterruptRaw = Raw;
interruptConfig.InterruptRaw = Translated;
status = WdfInterruptCreate(pDevExt->Device, &interruptConfig, WDF_NO_OBJECT_ATTRIBUTES, &pDevExt->Interrupts[pDevExt->NumInterruptsConfigured]);
if (!NT_SUCCESS(status))
{
DEBUG_P(TRACE_LEVEL_WARNING, DBG_PNP, “InterruptCreate() WdfInterruptCreate failed 0x%x”, status);
}
else
{
pDevExt->NumInterruptsConfigured++;
}
//DEBUG_P(TRACE_LEVEL_INFORMATION, DBG_PNP, “InterruptCreate() created %d interrupts. Exit status = 0x%X”, pDevExt->NumInterruptsConfigured, status);
return status;
}
Thanks