情報
要求されたトピックは次のとおりです。しかし、このトピックはこのライブラリには含まれていません。

EvtDevicePrepareHardware

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

構文

EVT_WDF_DEVICE_PREPARE_HARDWARE EvtDevicePrepareHardware;

NTSTATUS EvtDevicePrepareHardware(
  __in  WDFDEVICE Device,
  __in  WDFCMRESLIST ResourcesRaw,
  __in  WDFCMRESLIST ResourcesTranslated
)
{ ... }

パラメーター

Device [in]

A handle to a framework device object.

ResourcesRaw [in]

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.

ResourcesTranslated [in]

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.

戻り値

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.

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.

解説

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.

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

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.

The function type is declared in Wdfdevice.h, as follows.

typedef NTSTATUS
 (EVT_WDF_DEVICE_PREPARE_HARDWARE)(
    IN WDFDEVICE  Device,
    IN WDFCMRESLIST  ResourcesRaw,
    IN WDFCMRESLIST  ResourcesTranslated
    );

To define an EvtDevicePrepareHardware callback function that is named MyDevicePrepareHardware, you must first provide a function declaration that SDV and other verification tools require, as follows:

EVT_WDF_DEVICE_PREPARE_HARDWARE  MyDevicePrepareHardware;

Then, implement your callback function as follows:

NTSTATUS
 MyDevicePrepareHardware (
    IN WDFDEVICE  Device,
    IN WDFCMRESLIST  ResourcesRaw,
    IN WDFCMRESLIST  ResourcesTranslated
    )
 {...}

要件

バージョン

Supported by version 1.0 and later versions of KMDF.

ヘッダー

Wdfdevice.h (includeWdf.h)

IRQL

PASSIVE_LEVEL

参照

EvtDeviceReleaseHardware

 

 

コミュニティの追加

表示:
© 2014 Microsoft