power management problem in win2k kernel driver

I have a win2k kernel mode driver for a PCMCIA card. I use IBM laptop to
test my driver. The card works fine in normal power status. But when I put
the laptop into StandBy then wake it up, the card doesn’t work anyway. I add
the power management code in the driver according to toaster code in win2k
DDK. With the debugger, I can see the changes of system power during power
transition: PowerSystemWorking->PowerSystemSleeping1->PowerSystemWorking.
But the device power state is always PowerDeviceUnspecified.

In response to IRP_MN_QUERY_CAPABILITIES, I only read device capabilities.

The hardware of this card doesn’t support low power state. The PCMCIA
adaptor is ACPI compatible.

Your driver is responsible for setting the device power state, typically
in response to changes in the system power state.

So, when you see the system go from S1 (actually any of the sleeping
states) to S0, your driver should build and send an IRP_MN_SET_POWER using
PoRequestPowerIrp. You’ll need to do similar in response to an
IRP_MN_QUERY_POWER for the system power state, and powering your device
down will require some logic as well. It’s more complicated that this
paragraph might otherwise lead you to believe, so to get it all correct,
consult the DDK docs chapter on power management heavily. Even if you’re
not targetting XP, I’d recommend looking at the XP DDK docs - they do a
pretty good job of explaining the details.

I believe the toaster sample in the XP DDK actually demonstrates all of
this, also.

Actually, I would go with Walter Oney’s suggestion and copy and paste
someone else’s already working and tested power code. This is really tough
to get right.

I might even take it a step further and suggest you buy a toolkit to help
you write your driver, but I work for BSquare a maker of WinDK, so I am
biased obviously :slight_smile:


Bill McKenzie

wrote in message news:xxxxx@ntdev…
>
> Your driver is responsible for setting the device power state, typically
> in response to changes in the system power state.
>
> So, when you see the system go from S1 (actually any of the sleeping
> states) to S0, your driver should build and send an IRP_MN_SET_POWER using
> PoRequestPowerIrp. You’ll need to do similar in response to an
> IRP_MN_QUERY_POWER for the system power state, and powering your device
> down will require some logic as well. It’s more complicated that this
> paragraph might otherwise lead you to believe, so to get it all correct,
> consult the DDK docs chapter on power management heavily. Even if you’re
> not targetting XP, I’d recommend looking at the XP DDK docs - they do a
> pretty good job of explaining the details.
>
> I believe the toaster sample in the XP DDK actually demonstrates all of
> this, also.
>
>