Creating Device Objects in a Bus Driver
Each bus driver must create a framework device object when it discovers that a child device is connected to a parent device. The parent device is typically a bus, but it can also be a multifunction device for which each function requires a separate set of drivers (such as a sound card that supports digital audio and MIDI). The device objects that bus drivers create are called physical device objects (PDOs) because each represents an actual connection of one piece of hardware (the child) to another (the parent).
The process of identifying and reporting the devices that are connected to a bus is called bus enumeration.
For more information about bus enumeration, see Enumerating the Devices on a Bus.
A bus driver can call a set of framework device object initialization methods, which store information in the WDFDEVICE_INIT structure. Additionally, bus drivers can call framework PDO initialization methods.
Creating a framework device object for an enumerated child device typically includes the following steps:
Registering bus driver-specific callback functions.
Most bus drivers call WdfPdoInitSetEventCallbacks, because they must specify the system hardware resources that a device requires. For more information about specifying hardware resources, see Hardware Resources for Framework-Based Drivers. Additional callback functions can be registered if the device and driver support ejection.
Reporting device identification strings.
Bus drivers must report the device's identification strings by calling WdfPdoInitAssignDeviceID, WdfPdoInitAssignInstanceID, WdfPdoInitAddCompatibleID, and WdfPdoInitAddHardwareID for each type of string that the device supports. In addition, bus drivers that use version 1.9 or later of the framework can call WdfPdoInitAssignContainerID.
Reporting whether the bus driver can support the device in raw mode.
If the bus driver supports raw mode for the device, it must call WdfPdoInitAssignRawDevice.
Providing displayable text that describes the device.
Creating the device object.
The final step in creating a device object is to call WdfDeviceCreate.
Each bus driver is also the function driver for the bus adapter. Therefore, the driver must also provide an EvtDriverDeviceAdd callback function. This callback function creates a functional device object (FDO) for each bus adapter on the system. For more information about creating FDOs, see Creating Device Objects in a Function Driver.