Frank van Eijkelenburg wrote:
Thanks for your responses. I have some experience with WDM drivers,
but not with KMDF driver. In which way is the KMDF implementation
really different from the WDM implementation? And why would it solve
my problem? I guess in the KMDF way of working you also need a certain
basic functionality to implement, since the OS does not know anything
about a custom card.
There has never been a WDM driver that handled power correctly. KMDF
brings you the proper state transitions.
The rule is that, when you get a power state transition request, you
need to do whatever is necessary to survive that transition. If you
have state that will be lost in an S0->S3 transition, you have to save
it. The PCI bus driver can help you with that; if it knows that your
device is making a D0->D3 transition, it will lose its configuration
space. Thus, when it sees that you are making a D3->D0 transition, it
will restore that space.
The KEY is that here is that it is up to the driver to say what D
transitions it is making. So, when you get an S0->S3 transition, if
your device responds to that by going into D3, then YOU need to create a
D0->D3 request and send it to yourself. Then, when you get an S3->S0
request, YOU need to create a D3->D0 request and send it to yourself.
That D3->D0 request gets forwarded down to the PCI bus driver, which
responds by restoring your configuration state.
It does that because it doesn’t KNOW exactly when you go into D3. For
example, a stupid device might go into D3 when it sees a transition to
S1. A device with an onboard battery might not need to go into D3 at
all. It can’t assume.
KMDF handles those transitions automatically, based on your
query_capabilities response.
When I look at the pcidrv example that comes with the WDK, I see that
incoming IRPs are queued when the device is going to state D3. Is this
required?
Can you handle I/O requests while you are in D3, when your device isn’t
responding? Few drivers can do so.
Again, this is something KMDF handles this for you automatically.
In my case the only thing I want is being able to communicate with my
card after getting back to S0. It is not necessary if there was an
application running (which communicates with the card) before going to
state S3 that it automatically continue. In other words, I can make a
requirement to the user that it must close all applications which uses
the card before it goes to state S3.
No, you can’t. Not really. Users don’t follow instructions. Batteries
die at inconvenient times. Lids close. Power timers expire. Systems
need to survive that. When a user’s app crashes after awaking, they
don’t blame your hardware. They blame Windows.
Is it enough to forward power IRPs to the lower level drivers and fill
the record with capabilities correctly (in IRP_MN_QUERY_CAPABILITIES
as you suggested)?
No, it’s not enough. You still have to create the D transition requests
yourself. (KMDF will do that.)
Can you point me to an example how I have to react at
IRP_MN_QUERY_CAPABILITIES? Which fields should I use in the
DEVICE_CAPABILITIES structure to tell the system I go to D3 when the
system enters S3 state (is this the DeviceState field of the
structure)? For a lot of fields the documentation indicates it should
not written by the driver.
In the 7600 WDK, look at
src\general\toaster\wdm\func\featured2\power.c. It’s not correct, but
it’s close. You’ll see ToasterQueueCorrespondingDeviceIrp queues up a
device transition request corresponding to the current system transition
notice.
Again, by far your best choice would be to switch to KMDF. Really.
As you can see a lot of questions. I hope you have a little patience
with me. Writing/debugging drivers is not a daily business for me.
Patience is not one of the virtues of this mailing list. A thick skin
is a valuable asset while visiting here.
–
Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.