Supporting Ejectable Devices

Ejectable devices are devices that can be inserted into a docking station and ejected from the docking station. Typically, an ejectable device's bus power must be disabled before the device can be removed.

If a device is ejectable, the bus driver for the device's bus must set the EjectSupported member in the device's WDF_DEVICE_PNP_CAPABILITIES structure.

When a bus driver determines that one of its enumerated child devices is about to be ejected, it calls either WdfPdoRequestEject or WdfChildListRequestChildEject. For example, the bus driver might detect that a user has pressed an eject button.

When a driver calls WdfChildListRequestChildEject or WdfPdoRequestEject, the PnP manager uses the orderly removal scenario to inform the device's drivers that the device is being removed. After the framework has called the EvtDeviceReleaseHardware callback function in the bus driver for the device's bus, the framework calls the bus driver's EvtDeviceEject callback function, which performs any operations that are necessary to physically eject the device.

If ejecting your device causes additional devices to also be ejected, your bus driver can maintain a list of ejection relations. When a user removes your device, the PnP manager informs the drivers of devices in the list that their devices are also being removed. To maintain a list of ejection relations, a bus driver can use the WdfPdoAddEjectionRelationsPhysicalDevice, WdfPdoRemoveEjectionRelationsPhysicalDevice, and WdfPdoClearEjectionRelationsDevices methods.

If a device can be locked in its docking station, the bus driver must set the LockSupported member in the device's WDF_DEVICE_PNP_CAPABILITIES structure. The bus driver must also provide an EvtDeviceSetLock callback function, which locks the device to disable ejection or unlocks the device to enable ejection.