Bewerken

Delen via


EVT_WDF_DEVICE_PREPARE_HARDWARE callback function (wdfdevice.h)

[Applies to KMDF and UMDF]

A driver's EvtDevicePrepareHardware event callback function performs any operations that are needed to make a device accessible to the driver.

Syntax

EVT_WDF_DEVICE_PREPARE_HARDWARE EvtWdfDevicePrepareHardware;

NTSTATUS EvtWdfDevicePrepareHardware(
  [in] WDFDEVICE Device,
  [in] WDFCMRESLIST ResourcesRaw,
  [in] WDFCMRESLIST ResourcesTranslated
)
{...}

Parameters

[in] Device

A handle to a framework device object.

[in] ResourcesRaw

A handle to a framework resource-list object that identifies the raw hardware resources that the Plug and Play manager has assigned to the device.

[in] ResourcesTranslated

A handle to a framework resource-list object that identifies the translated hardware resources that the Plug and Play manager has assigned to the device.

Return value

If the EvtDevicePrepareHardware callback function encounters no errors, it must return STATUS_SUCCESS or another status value for which NT_SUCCESS(status) equals TRUE. Otherwise, it must return a status value for which NT_SUCCESS(status) equals FALSE. Do not return STATUS_NOT_SUPPORTED.

If NT_SUCCESS(status) equals FALSE, the framework calls the driver's EvtDeviceReleaseHardware callback function.

For more information about this callback function's return values, see Reporting Device Failures.

Remarks

To register an EvtDevicePrepareHardware callback function, a driver must call WdfDeviceInitSetPnpPowerEventCallbacks.

If the driver has registered an EvtDevicePrepareHardware callback function for a device, the framework calls the function after the Plug and Play manager has assigned hardware resources to the device and after the device has entered its uninitialized D0 state. (The Plug and Play manager always starts a parent device before it starts that device's child devices.)

The framework calls the driver's EvtDevicePrepareHardware callback function before calling the driver's EvtDeviceD0Entry callback function.

The EvtDevicePrepareHardware callback function accesses the device's raw and translated hardware resources by using the ResourcesRaw and ResourcesTranslated handles that it receives. The callback function can call WdfCmResourceListGetCount and WdfCmResourceListGetDescriptor to traverse the resource lists. This callback function cannot modify the resource lists.

For more information about resource lists and the order in which the resources appear, see raw and translated hardware resources.

Typically, your driver's EvtDevicePrepareHardware callback function does the following, if necessary:

  • Maps physical memory addresses to virtual addresses so the driver can access memory that is assigned to the device
  • Determines the device's revision number
  • Configures USB devices
  • Obtains driver-defined interfaces from other drivers
Optionally, your driver's EvtDevicePrepareHardware callback function might queue a work item to complete any other time-intensive configuration tasks. Using a work item for such operations can help ensure that your device's start up time does not increase the system boot time. For more information, see Using Framework Work Items.

Typically, all other hardware initialization operations, including loading firmware, should take place each time that the device enters its working (D0) state and should therefore take place in the driver's EvtDeviceD0Entry callback function.

The ResourcesRaw and ResourcesTranslated handles that the EvtDevicePrepareHardware callback function receives remain valid until the driver's EvtDeviceReleaseHardware callback function returns.

For more information about hardware resources, see Hardware Resources for Framework-Based Drivers.

For more information about when the framework calls this callback function, see PnP and Power Management Scenarios.

For more information about drivers that provide this callback function, see Supporting PnP and Power Management in Function Drivers.

Requirements

Requirement Value
Target Platform Universal
Minimum KMDF version 1.0
Minimum UMDF version 2.0
Header wdfdevice.h (include Wdf.h)
IRQL PASSIVE_LEVEL

See also

EvtDeviceReleaseHardware