Tech Support > Microsoft Windows > Drivers > Need help on Power IRPs
Need help on Power IRPs
Posted by pavanchebbi@gmail.com on May 3rd, 2006


Hi All,
I am facing a problem when I am handling power IRPs. The problem is
that, when the system goes to standby, the dispatch routine for the
Power IRP is called twice and the second time the system crashes with a
blue screen with an unknown error.

I simply pass the IRP down to the next lower driver in the dispatch
routine. The code to pass the IRP down to the next lower driver is
similar to the one given in Toaster sample given with the DDK.
I use the following code.

PoStartNextPowerIrp(Irp);
IoSkipCurrentIrpStackLocation(Irp);
fdoData = (PFDO_DATA) DeviceObject->DeviceExtension;
status = PoCallDriver(fdoData->NextLowerDriver, Irp);
return status;


I'd be glad if anybody would tell why the dispatch routine is being
called twice when the system goes to standby.

Also, do we have to do the following when the IRP is being passed to
the lower driver? It is not done in the Toaster sample.
IoMarkIrpPending(...);
IoSetCompletionRoutine(...);

Thanks in advance,
Pavan.

Posted by genob on May 3rd, 2006


The kernel should send an IRP_MN_QUERY_POWER which will tell your
driver which power state is being requested.

You can then clean up anything there and then pass the irp down the
stack.

I usually request the next power irp during the completion event
meaning I don't call PoStartNextPowerIrp() until the IRP is on it's
way back up the stack (completion routine).

The next kernel dispatch call should be IRP_MN_SET_POWER which will
tell your driver which power state it's going into. Here you can then
start requesting device power states by calling PoRequestPowerIrp()
setting the device power state.

I use the set completion code because it gives you a chance to follow
the IRP back up the stack during power transitions.

If you don't want your device to do anything power related, then you
can just simply pass the power irp's to the lower driver and do
nothing. A lot of the ms examples do just that.

If you check out Walter Oney's book ("Programming the MS Windows
Driver Model") he talks about the different power states. I used that
a while back in conjunction with the DDK documents to get a good grasp
on power management.

It was definitely complicated at first...

geno


On 3 May 2006 03:35:32 -0700, in
microsoft.public.development.device.drivers you wrote:


On 3 May 2006 03:35:32 -0700, pavanchebbi@gmail.com wrote:


Posted by Doron Holan [MS] on May 4th, 2006


i would suggest that you highly consider KMDF for your driver and do not
write a WDM driver from scratch. you can get it from
http://www.microsoft.com/whdc/driver/wdf/KMDF_pkg.mspx. you will not have
to worry about any pnp or power code, just the code you need to write to
make your driver functional.

d

--
Please do not send e-mail directly to this alias. this alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.


<pavanchebbi@gmail.com> wrote in message
news:1146652532.293542.312800@i40g2000cwc.googlegr oups.com...



Similar Posts