Export (0) Print
Expand All

PoSetPowerState routine

The PoSetPowerState routine notifies the system of a change in the device power state for a device.

Syntax


POWER_STATE PoSetPowerState(
  _In_  PDEVICE_OBJECT DeviceObject,
  _In_  POWER_STATE_TYPE Type,
  _In_  POWER_STATE State
);

Parameters

DeviceObject [in]

A pointer to the target DEVICE_OBJECT.

Type [in]

Indicates a POWER_STATE_TYPE value. Drivers must specify DevicePowerState.

State [in]

Specifies the power state to be set. Drivers must specify a DEVICE_POWER_STATE value.

Return value

On Windows 2000 and later versions of the operating system, PoSetPowerState returns the previous power state. On Windows 98/Me, PoSetPowerState returns the state passed in State.

Remarks

PoSetPowerState notifies the power manager of the new power state for a device. Each driver in a device stack (filter, function, and bus drivers) must call PoSetPowerState to inform the power manager of a change in the power state of its corresponding device object. For example:

  • A driver calls this routine after receiving a device set-power request and before calling PoStartNextPowerIrp. When handling a PnP IRP_MN_START_DEVICE request, the driver should call PoSetPowerState to notify the power manager that the device is in the D0 state.

  • If the device is powering down, the driver must call PoSetPowerState before leaving the D0 state. In addition, the driver must be able to process client requests before PoSetPowerState returns.

  • If the device is powering up, the driver must call PoSetPowerState after the device is successfully put into the D0 state.

For more information about powering a device up and down, see Handling IRP_MN_SET_POWER for Device Power States.

Callers of PoSetPowerState must be running at IRQL <= APC_LEVEL except when setting state to D0. When setting state to D0, callers can be running at IRQL <= DISPATCH_LEVEL.

Requirements

Version

Available starting with Windows 2000.

Header

Wdm.h (include Wdm.h, Ntddk.h, or Ntifs.h)

Library

Ntoskrnl.lib

IRQL

See Remarks section.

See also

IRP_MN_START_DEVICE
PoStartNextPowerIrp

 

 

Send comments about this topic to Microsoft

Show:
© 2014 Microsoft