State Machines in the Framework
To keep track of each device's state, the framework uses a PnP state machine, a power state machine, and a power policy state machine. The framework creates an instance of each state machine for each device that is plugged into a system.
Very few drivers need to be aware of the state of a device's state machines. However, for the drivers that do need to know this information, the framework provides two sets of interfaces:
A set of driver-supplied event callback functions.
The driver can request that the framework call one of the following callback functions whenever one of the state machines enters or exits a particular state:
- EvtDevicePnpStateChange, which the driver registers by calling WdfDeviceInitRegisterPnpStateChangeCallback.
- EvtDevicePowerStateChange, which the driver registers by calling WdfDeviceInitRegisterPowerStateChangeCallback.
- EvtDevicePowerPolicyStateChange, which the driver registers by calling WdfDeviceInitRegisterPowerPolicyStateChangeCallback.
A set of methods that return the current state of the state machines.
The driver can call one of the following methods to determine the current state of one of the state machines for a particular device: