WDF_USB_DEVICE_CREATE_CONFIG
WDF_USB_DEVICE_CREATE_CONFIG_INIT
WdfUsbTargetDeviceCreateIsochUrb method
WdfUsbTargetDeviceCreateUrb method
WdfUsbTargetDeviceCreateWithParameters method
WdfUsbTargetDeviceQueryUsbCapability method
Collapse the table of content
Expand the table of content
展開 最小化

WdfUsbTargetDeviceSelectConfig メソッド

The WdfUsbTargetDeviceSelectConfig method selects a USB configuration for a device, or it deconfigures the device.

構文

NTSTATUS WdfUsbTargetDeviceSelectConfig(
  [in]            WDFUSBDEVICE UsbDevice,
  [in, optional]  PWDF_OBJECT_ATTRIBUTES PipeAttributes,
  [in, out]       PWDF_USB_DEVICE_SELECT_CONFIG_PARAMS Params
);

パラメーター

UsbDevice [in]

A handle to a USB device object that was obtained from a previous call to WdfUsbTargetDeviceCreate.

PipeAttributes [in, optional]

A pointer to a caller-allocated WDF_OBJECT_ATTRIBUTES structure that contains attributes for new framework USB pipe objects that the framework creates for the device's interfaces. This parameter is optional and can be WDF_NO_OBJECT_ATTRIBUTES.

Params [in, out]

A pointer to a caller-allocated WDF_USB_DEVICE_SELECT_CONFIG_PARAMS structure that the caller and the framework use to specify configuration parameters.

戻り値

WdfUsbTargetDeviceSelectConfig returns the I/O target's completion status value if the operation succeeds. Otherwise, this method can return one of the following values:

リターン コード説明
STATUS_INVALID_PARAMETER

An invalid parameter was detected.

STATUS_INFO_LENGTH_MISMATCH

The Size member of the WDF_USB_DEVICE_SELECT_CONFIG_PARAMS structure that Params points to was incorrect.

STATUS_INSUFFICIENT_RESOURCES

A memory buffer could not be allocated.

 

This method also might return other NTSTATUS values.

A bug check occurs if the driver supplies an invalid object handle.

解説

Your driver can select a device configuration by using a WDF_USB_DEVICE_SELECT_CONFIG_PARAMS structure to specify USB descriptors, a URB, or handles to framework USB interface objects.

The framework creates a framework USB pipe object for each pipe that is associated with each interface in the configuration, after deleting any pipe objects that the framework might have previously created for the configuration. The framework uses alternate setting zero for each interface, unless the driver specifies a different alternate setting.

To obtain information about an interface's pipe objects, the driver can call WdfUsbInterfaceGetNumConfiguredPipes and WdfUsbInterfaceGetConfiguredPipe.

For more information about the WdfUsbTargetDeviceSelectConfig method and USB I/O targets, see USB I/O Targets.

注意  

You can use WdfUsbTargetDeviceSelectConfig to select only the first USB configuration listed in the descriptor list, but you can select multiple interfaces within this single configuration.

The following code example selects a configuration with a single, specified interface.

WDF_USB_DEVICE_SELECT_CONFIG_PARAMS  configParams;
NTSTATUS  status;

WDF_USB_DEVICE_SELECT_CONFIG_PARAMS_INIT_SINGLE_INTERFACE(&configParams);

status = WdfUsbTargetDeviceSelectConfig(
                                        UsbDevice,
                                        WDF_NO_OBJECT_ATTRIBUTES,
                                        &configParams
                                        );

The following code example selects a configuration with multiple interfaces, using alternate setting zero on all interfaces.

WDF_USB_DEVICE_SELECT_CONFIG_PARAMS  configParams;
PWDF_USB_INTERFACE_SETTING_PAIR settingPairs;
UCHAR numInterfaces;
NTSTATUS  status;

numInterfaces = WdfUsbTargetDeviceGetNumInterfaces(UsbDevice);

settingPairs = ExAllocatePoolWithTag(
    PagedPool,
    sizeof(WDF_USB_INTERFACE_SETTING_PAIR) * numInterfaces,
    MY_DRIVER_TAG
);

if (settingPairs == NULL){
    return STATUS_INSUFFICIENT_RESOURCES;
}

for (interfaceIndex = 0; interfaceIndex < numInterfaces; interfaceIndex++) {
        
    settingPairs[interfaceIndex].UsbInterface = 
                                    WdfUsbTargetDeviceGetInterface(
                                        UsbDevice,
                                        interfaceIndex);

    // Select alternate setting zero on all interfaces.
       
    settingPairs[interfaceIndex].SettingIndex = 0;
}

WDF_USB_DEVICE_SELECT_CONFIG_PARAMS_INIT_MULTIPLE_INTERFACES(
    &configParams,
    numInterfaces,
    settingPairs
);

status = WdfUsbTargetDeviceSelectConfig(
    UsbDevice,
    NULL,
    &configParams
);

if (!NT_SUCCESS(status)) {
    ExFreePoolWithTag(
        settingPairs,
        MY_DRIVER_TAG
    );
    return status;
}

要件

バージョン

Available in version 1.0 and later versions of KMDF.

ヘッダー

Wdfusb.h (includeWdfusb.h)

ライブラリ

Wdf<MajorVersionNumber>000.sys (see Framework Library Versions.)

IRQL

PASSIVE_LEVEL

参照

WDF_OBJECT_ATTRIBUTES
WDF_USB_DEVICE_SELECT_CONFIG_PARAMS
WDF_USB_DEVICE_SELECT_CONFIG_PARAMS_INIT_SINGLE_INTERFACE
WDF_USB_DEVICE_SELECT_CONFIG_PARAMS_INIT_MULTIPLE_INTERFACES
WdfUsbInterfaceGetConfiguredPipe
WdfUsbInterfaceGetNumConfiguredPipes
WdfUsbTargetDeviceCreate

 

 

コミュニティの追加

追加
表示:
© 2015 Microsoft