RE: WdfInterruptCreate STATUS_INVALID_DEVICE_STATE error

Hi,

I am testing my first kmdf driver on XP system. It is a general PCI
driver. In EvtDeviceAdd, I only configure a file object for the device.
I only configure EvtDevicePrepareHardware callback function. After
creating the device, the DeviceAdd returned with no error.

In EvtDevicePrepareHardware function, I got all memory and interrupt
resources. The memory map is fine. I configure an interrupt service
routing and a Dpc for the interrupt. But the WdfInterruptCreate call
returns a STATUS_INVALID_DEVICE_STATE error. According the document,
the error is " WdfInterruptCreate was called after the device was
started". I am not sure what I did wrong. What is the possibility
causing this error?

Thanks for the help.

Bob Bao

!wdflogdump

Will tell you exactly what you are doing wrong. The docs are telling you as well. you need to create the WDFINTERRUPT in EvtDriverDeviceAdd

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Bob Bao
Sent: Friday, October 10, 2008 10:01 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] WdfInterruptCreate STATUS_INVALID_DEVICE_STATE error

Hi,

I am testing my first kmdf driver on XP system. It is a general PCI
driver. In EvtDeviceAdd, I only configure a file object for the device.
I only configure EvtDevicePrepareHardware callback function. After
creating the device, the DeviceAdd returned with no error.

In EvtDevicePrepareHardware function, I got all memory and interrupt
resources. The memory map is fine. I configure an interrupt service
routing and a Dpc for the interrupt. But the WdfInterruptCreate call
returns a STATUS_INVALID_DEVICE_STATE error. According the document,
the error is " WdfInterruptCreate was called after the device was
started". I am not sure what I did wrong. What is the possibility
causing this error?

Thanks for the help.

Bob Bao


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Bob Bao wrote:

I am testing my first kmdf driver on XP system. It is a general PCI
driver. In EvtDeviceAdd, I only configure a file object for the device.
I only configure EvtDevicePrepareHardware callback function. After
creating the device, the DeviceAdd returned with no error.

In EvtDevicePrepareHardware function, I got all memory and interrupt
resources. The memory map is fine. I configure an interrupt service
routing and a Dpc for the interrupt. But the WdfInterruptCreate call
returns a STATUS_INVALID_DEVICE_STATE error. According the document,
the error is " WdfInterruptCreate was called after the device was
started". I am not sure what I did wrong. What is the possibility
causing this error?

As the doc says, WdfInterruptCreate should be called from EvtDeviceAdd.
Just that simple. WdfInterruptCreate does not connect to the interrupt,
it merely declares to the framework that “this driver will need some
interrupt handling.” That’s why it has to happen so early. The
framework will intercept the CmResourceInterrupt resource and handle the
interrupt connection before it calls your PrepareHardware function. By
the, it’s too late.

The framework will call your EvtEnableInterrupt and EvtDisableInterrupt
callbacks to give you an opportunity to turn the hardware interrupt on
and off.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Thanks Tim. The problem is solved.

Bob Bao

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Tim Roberts
Sent: Friday, October 10, 2008 12:25 PM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] WdfInterruptCreate STATUS_INVALID_DEVICE_STATE
error

Bob Bao wrote:

I am testing my first kmdf driver on XP system. It is a general PCI
driver. In EvtDeviceAdd, I only configure a file object for the
device.
I only configure EvtDevicePrepareHardware callback function. After
creating the device, the DeviceAdd returned with no error.

In EvtDevicePrepareHardware function, I got all memory and interrupt
resources. The memory map is fine. I configure an interrupt service
routing and a Dpc for the interrupt. But the WdfInterruptCreate call
returns a STATUS_INVALID_DEVICE_STATE error. According the document,
the error is " WdfInterruptCreate was called after the device was
started". I am not sure what I did wrong. What is the possibility
causing this error?

As the doc says, WdfInterruptCreate should be called from EvtDeviceAdd.
Just that simple. WdfInterruptCreate does not connect to the interrupt,
it merely declares to the framework that “this driver will need some
interrupt handling.” That’s why it has to happen so early. The
framework will intercept the CmResourceInterrupt resource and handle the
interrupt connection before it calls your PrepareHardware function. By
the, it’s too late.

The framework will call your EvtEnableInterrupt and EvtDisableInterrupt
callbacks to give you an opportunity to turn the hardware interrupt on
and off.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer