Table of contents
Collapse the table of content
Expand the table of content

Reporting Device Powered On When System Returns to S0

Last Updated: 7/30/2016

[Applies to KMDF only]

When the system returns to its working (S0) state from a low-power state, the PnP manager sends a system set-power IRP (IRP_MN_SET_POWER) to return the device to its working (D0) state. WDF handles the system set-power IRP. However, because in the multi-component scenario the driver has directly registered with the power management framework (PoFx), the driver must call PoFxReportDevicePoweredOn when the device has completed the transition to its fully on (D0) power state. The driver can accomplish this by registering a WDM preprocess routine to receive notification when a system set-power IRP arrives.

The driver can use the following procedure:

  1. Call WdfDeviceInitAssignWdmIrpPreprocessCallback to register a EvtDeviceWdmIrpPreprocess callback function for IRP_MN_SET_POWER. In the callback, the driver sets a flag in its device extension to indicate that it needs to call PoFxReportDevicePoweredOn from its next EvtDeviceD0Entry callback.
  2. In EvtDeviceD0Entry, if the flag is set, the driver clears the flag and calls PoFxReportDevicePoweredOn.
  3. The driver also checks the flag in EvtDeviceSelfManagedIoFlush. If the flag is set, the device failed to return to D0 and the device has been removed. In this case, the driver calls PoFxReportDevicePoweredOn and then unregisters with the power framework.
© 2017 Microsoft