The PoRequestPowerIrp routine allocates a power IRP and sends it to the top driver in the device stack for the specified device.
NTSTATUS
PoRequestPowerIrp(
IN PDEVICE_OBJECT DeviceObject,
IN UCHAR MinorFunction,
IN POWER_STATE PowerState,
IN PREQUEST_POWER_COMPLETE CompletionFunction,
IN PVOID Context,
OUT PIRP *Irp OPTIONAL
);
For IRP_MN_WAIT_WAKE, specify the lowest (least-powered) system power state from which the device should be allowed to wake the system Possible values are SYSTEM_POWER_STATE enumerator values.
VOID
(*PREQUEST_POWER_COMPLETE) (
IN PDEVICE_OBJECT DeviceObject,
IN UCHAR MinorFunction,
IN POWER_STATE PowerState,
IN PVOID Context,
IN PIO_STATUS_BLOCK IoStatus
);
The callback parameters are as follows:
PoRequestPowerIrp returns one of the following:
Declared in wdm.h and ntddk.h. Include wdm.h or ntddk.h.
A driver calls PoRequestPowerIrp — not IoAllocateIrp — to allocate and send a power IRP that has minor IRP code IRP_MN_SET_POWER, IRP_MN_QUERY_POWER, or IRP_MN_WAIT_WAKE. (A driver must call IoAllocateIrp to send a power IRP with minor IRP code IRP_MN_POWER_SEQUENCE.)
A device power policy owner calls this routine to send a wait/wake, query, or set-power IRP.
If PoRequestPowerIrp returns a status value of STATUS_PENDING, the routine successfully allocated a device power IRP and sent it to the top of the device stack for the device. After the bus driver and all other drivers have completed the IRP, and the I/O Manager has called all IoCompletion routines set by drivers as they passed the IRP down the device stack, the CompletionFunction is called with the given Context. If PoRequestPowerIrp returns a status other than STATUS_PENDING, the routine did not send a device power IRP and the CompletionFunction is not called.
The CompletionFunction performs any additional tasks the sender of the IRP requires after all other drivers have completed the IRP. It need not free the IRP; the Power Manager does that. On Windows 98/Me, the CompletionFunction is always called at IRQL = PASSIVE_LEVEL, and drivers must complete IRPs at IRQL = PASSIVE_LEVEL. On Windows 2000 and later systems, the CompletionFunction can be called at IRQL = PASSIVE_LEVEL or IRQL = DISPATCH_LEVEL.
A device power policy owner calls PoRequestPowerIrp to send a device query- or set-power IRP when it receives a system query- or set-power IRP. The driver should set an IoCompletion routine in the system IRP and pass the system IRP to the next lower driver. The IoCompletion routine calls PoRequestPowerIrp to send the device IRP, passing the system IRP in the Context parameter. The Context parameter is subsequently passed to the CompletionFunction for the device IRP. In the CompletionFunction, the driver can complete the system IRP. For more information, see Sending IRP_MN_QUERY_POWER or IRP_MN_SET_POWER for Device Power States and Wait/Wake Callback Routines.
Drivers can use the returned Irp to cancel an IRP_MN_WAIT_WAKE IRP. Drivers requesting other power IRPs can pass NULL for this parameter.
Callers of PoRequestPowerIrp must be running at IRQL <= DISPATCH_LEVEL.
IoAllocateIrp, IO_STATUS_BLOCK, IRP, PoStartNextPowerIrp, IRP_MN_POWER_SEQUENCE, IRP_MN_SET_POWER, IRP_MN_QUERY_POWER, IRP_MN_WAIT_WAKE