Muokkaa

Jaa


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:

If the driver encounters an error while initializing the WDFDEVICE_INIT structure that it obtained from WdfPdoInitAllocate, the driver must call WdfDeviceInitFree instead of WdfDeviceCreate.

After the bus driver has created the device object, it typically calls WdfDeviceSetPnpCapabilities and WdfDeviceSetPowerCapabilities to report the device's Plug and Play and power capabilities.

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.