The PnP Manager Redistributes System Resources
If a user adds a device to a system, and if the device requires system resources that the PnP manager has already assigned to another device, the PnP manager attempts to reassign resources.
During this process, the PnP manager stops devices and takes them out of their working (D0) states. It then delivers new resource lists to the devices so that they can restart, using the new resources.
When redistributing resources, the PnP manager will not alter a device's resource assignment if one of the device's drivers has:
Called WdfDeviceSetSpecialFileSupport and a special file is open on the device.
Called WdfDeviceSetStaticStopRemove.
Supplied an EvtDeviceQueryStop callback function, and the callback function has vetoed the reassignment.
Power-Down Sequence
For each function and filter driver that supports the device being stopped, the framework does the following, in sequence, one driver at a time, starting with the driver that is highest in the driver stack:
If the driver is using self-managed I/O, the framework calls the driver's EvtDeviceSelfManagedIoSuspend callback function.
The framework stops all of the device's power-managed I/O queues.
If the hardware and driver support DMA, the framework calls the driver's EvtDmaEnablerSelfManagedIoStop, EvtDmaEnablerFlush, and EvtDmaEnablerDisable callback functions for each DMA channel that was created.
Calls the driver's EvtDeviceD0ExitPreInterruptsDisabled and EvtInterruptDisable callback functions (if they exist) so that the driver can disable device interrupts.
The framework calls the driver's EvtDeviceD0Exit callback function (if it exists).
The framework calls the driver's EvtDeviceReleaseHardware callback function (if it exists) passing the list of hardware resources that the PnP manager has assigned to the device.
The bus driver is the lowest driver in the stack and is called last. When the framework calls the bus driver's EvtDeviceD0Exit callback function, it passes a handle to the framework device object representing the device's PDO and a TargetState value of WdfPowerDeviceD3Final. The bus driver can control when the framework calls its EvtDeviceReleaseHardware callback function by calling WdfDeviceInitSetReleaseHardwareOrderOnFailure.
Power-Up Sequence
The first driver called is the bus driver. When the framework calls the bus driver's EvtDeviceD0Entry callback function, the callback function restores the device (a child device of the bus) to its working (D0) state.
For each function and filter driver that supports the device, the framework does the following, in sequence, one driver at a time, starting with the driver that is lowest in the driver stack:
The framework calls the driver's EvtDevicePrepareHardware callback function (if it exists), passing the list of hardware resources that the PnP manager has assigned to the device.
The framework calls the driver's EvtDeviceD0Entry callback function (if it exists).
The framework calls the driver's EvtInterruptEnable and EvtDeviceD0EntryPostInterruptsEnabled callback functions (if they exist) so that the driver can enable device interrupts.
If the hardware and driver support DMA, the framework calls the driver's EvtDmaEnablerFill, EvtDmaEnablerEnable, and EvtDmaEnablerSelfManagedIoStart callback functions for each DMA channel that was created.
The framework calls the driver's EvtChildListScanForChildren callback function (if it exists).
The framework restarts all of the device's power-managed I/O queues.
If the driver is using self-managed I/O, the framework calls the driver's EvtDeviceSelfManagedIoRestart callback function.