Logo
programming4us
programming4us
programming4us
programming4us
Home
programming4us
XP
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server
programming4us
Windows Phone
 
programming4us
Windows 7

Plug and Play and Power Management : Device Enumeration and Startup (part 2) - Device Power-Down and Removal

- Windows 10 Product Activation Keys Free 2019
- How to active Windows 8 without product key
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
6/14/2013 5:17:23 PM

2.3. Device Power-Down and Removal

KMDF can remove a device from the operational state for several reasons:

  • To put the device in a low-power state because it is idle or the system is entering a sleep state.

  • To rebalance resources.

  • To remove the device after the user has requested an orderly removal.

  • To disable the device in response to the user’s request in Device Manager.

As in enumeration and power-up, the sequence of callbacks depends on the driver’s role in device management.

2.3.1. Power-Down and Removal Sequence for a Function or Filter Driver Object

The following shows the sequence of callbacks that are involved in power-down and removal for an FDO or filter DO. The sequence starts at the top of the figure with an operational device that is in the working power state (DO).

Device Operational

Suspend self-managed I/O, if driver supports itEvtDeviceSelfManagedIoSuspend
Stop power-managed queuesEvtIoStop
Arm wake signal, if driver supports itEvtDeviceArmWakeFromSx EvtDeviceArmWakeFromSO (called only during transitions to low power, not during resource rebalance or device removal)
Disable DMA, if driver supports itEvtDmaEnablerSelfManagedIoStop

EvtDmaEnablerDisable

EvtDmaEnableFlush
Disconnect interruptsEvtDeviceDOExitPreInterruptsDisabled EvtInterruptDisable
Notify driver of state changeEvtDeviceDOExit

Stop here if transitioning to low-power state

Release hardwareEvtDeviceReleaseHardware

Stop here if rebalancing resources

Purge power-managed queuesEvtIoStop
Flush I/O buffers, if driver supports self-managed I/OEvtDeviceSelfManagedIoFlush
Purge non-power-managed queuesEvtIoStop
Clean up I/O buffers, if driver supports self-managed I/OEvtDeviceSelfManagedIoCleanup
Delete device object’s context areaEvtCleanupContext EvtDestroyContext

Device Removed


As the preceding example shows, the KMDF power-down and removal sequence involves calling the corresponding “undo” callbacks in the reverse order from which KMDF called the functions that are involved in making the device operational.

2.3.2. Power-Down and Removal Sequence for a Physical Device Object

The following example shows the callbacks involved in power-down and removal for a PDO.

Device Operational

Enable wake signal, if driver supports it (called only during transitions to lower power, not during resource rebalance or device removal)EvtDeviceEnableWakeAtBus
Suspend self-managed I/O, if driver supports itEvtDeviceSelfManagedIoSuspend
Stop power-managed queuesEvtIoStop
Disable DMA, if driver supports itEvtDmaEnablerSelfManagedIoStop

EvtDmaEnablerDisable

EvtDmaEnableFlush
Disconnect interruptsEvtDeviceDOExitPreInterruptsDisabled EvtInterruptDisable
Notify driver of state changeEvtDeviceDOExit
Disable wake signal, if it is enabledEvtDeviceDisableWakeAtBus (called only during device removal)

Stop here if transitioning to low-power state

Release hardwareEvtDeviceReleaseHardware
Stop here if rebalancing resources 
Purge power-managed I/O queuesEvtIoStop
Flush I/O buffers, if driver supportsEvtDeviceSelfManagedIoFlush

Stop here if device is still physically present

Purge non-power-managed I/OEvtIoStop
Clean up I/O buffers, if driver supports self-managed I/OEvtDeviceSelfManagedIoCleanup
Delete device object’s context areaEvtCleanupContext EvtDestroyContext

Device Physically Removed


KMDF does not physically delete the PDO until the device is physically removed from the system. For example, if a user disables the device in Device Manager or uses the Safely Remove Hardware utility to stop the device but does not physically remove it, KMDF retains the PDO. If the device is later re-enabled, KMDF uses the EvtDevicePrepareHardware callback, as previously shown in section 7.2.2, “Startup Sequence for a Physical Device Object.”

2.3.3. Surprise-Removal Sequence

If the user removes the device without warning, by simply unplugging it without using Device Manager or the Safely Remove Hardware utility, the device is considered surprise removed. When this occurs, KMDF follows a slightly different removal sequence. It also follows the surprise-removal sequence if another driver calls IoInvalidateDeviceState on the device, even if the device is still physically present.

In the surprise-removal sequence, KMDF calls the EvtDeviceSurpriseRemoval callback before calling any of the other callbacks in the removal sequence. When the sequence is complete, KMDF destroys the device object.

Drivers for all removable devices must ensure that the callbacks in both the shutdown and startup paths can handle failure, particularly failures caused by the removal of the hardware. Any attempts to access the hardware should not wait indefinitely, but should be subject to time-outs or a watchdog timer.

The following example shows the surprise-removal sequence.

Device Removal

Notify driver that device has been surprise removedEvtDeviceSurpriseRemoval
Suspend self-managed I/O (called only if the device was in the working state at removal)EvtDeviceSelfManagedIoSuspend
Stop power-managed queues (called only if the device was in the working state at removal)EvtIoStop
Disable DMA, if driver supports it (called only if the device was in the working state at removal)EvtDmaEnablerSelfManagedIoStop EvtDmaEnablerDisable EvtDmaEnablerFlush
Disconnect interrupts (called only if the device was in the working state at removal)EvtDeviceDOExitPreInterruptsDisabled EvtInterruptDisable
Notify driver of state change (called only if the device was in the working state at removal)EvtDeviceDOExit
Release hardwareEvtDeviceReleaseHardware
Purge power-managed queuesEvtIoStop
Flush and clean up I/O buffers, if driver supports self-managed I/OEvtDeviceSelfManagedIoFlush
Purge non-power-managed queuesEvtIoStop
Clean up I/O buffers, if driver supports self-managed I/OEvtDeviceSelfManagedIoCleanup
Delete device object’s context areaEvtCleanupContext EvtDestroyContext

Removal Processing Complete


If the device was not in the working state when it was removed, KMDF calls the EvtDeviceReleaseHardware event callback immediately after EvtDeviceSurpriseRemoval. It omits the intervening steps, which were already performed when the device exited from the working state.

Other -----------------
- Evaluating Applications for Windows 7 Compatibility : Deploying XP Mode
- Configuring Startup and Troubleshooting Startup Issues : The Process of Troubleshooting Startup (part 3) - Troubleshooting Startup Problems After Logon
- Configuring Startup and Troubleshooting Startup Issues : The Process of Troubleshooting Startup (part 2) - Startup Troubleshooting After the Starting Windows Logo Appears
- Configuring Startup and Troubleshooting Startup Issues : The Process of Troubleshooting Startup (part 1) - Startup Troubleshooting Before the Starting Windows Logo Appears
- Configuring Startup and Troubleshooting Startup Issues : Important Startup Files, How to Configure Startup Settings
- Managing Windows 7 : Managing Navigational and Editing Flicks
- Managing Windows 7 : Configuring a Pen or Touch Computer, Managing Pen Settings
- Configuring Startup and Troubleshooting Startup Issues : Understanding the Startup Process
- Configuring Startup and Troubleshooting Startup Issues : What's New with Windows Startup
- Windows 7 Mobility Features : Using Windows 7 with a Netbook
 
 
Top 10
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
Popular tags
Microsoft Access Microsoft Excel Microsoft OneNote Microsoft PowerPoint Microsoft Project Microsoft Visio Microsoft Word Active Directory Biztalk Exchange Server Microsoft LynC Server Microsoft Dynamic Sharepoint Sql Server Windows Server 2008 Windows Server 2012 Windows 7 Windows 8 windows Phone 7 windows Phone 8
programming4us programming4us
Celebrity Style, Fashion Trends, Beauty and Makeup Tips.
 
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server