다음을 통해 공유


UfxDeviceCreate 함수(ufxclient.h)

UFX 디바이스 개체를 만들고, 이벤트 콜백 루틴을 등록하고, 컨트롤러와 관련된 기능을 지정합니다.

통사론

NTSTATUS UfxDeviceCreate(
                 WDFDEVICE                WdfDevice,
  [in]           PUFX_DEVICE_CALLBACKS    Callbacks,
  [in]           PUFX_DEVICE_CAPABILITIES Capabilities,
  [in, optional] PWDF_OBJECT_ATTRIBUTES   Attributes,
  [out]          UFXDEVICE                *UfxDevice
);

매개 변수

WdfDevice

WDF 디바이스 개체에 대한 핸들입니다.

[in] Callbacks

UFX 디바이스 개체와 연결할 드라이버 제공 콜백 루틴에 대한 포인터를 포함하는 형식 UFX_DEVICE_CALLBACKS 구조입니다.

[in] Capabilities

UFX_DEVICE_CAPABILITIES 구조체에 대한 포인터입니다.

[in, optional] Attributes

새 개체에 대한 드라이버 제공 특성을 포함하는 WDF_OBJECT_ATTRIBUTES 구조체에 대한 포인터입니다. 이 매개 변수는 선택 사항이며 WDF_NO_OBJECT_ATTRIBUTES수 있습니다.

[out] UfxDevice

새 UFX 디바이스 개체에 대한 핸들을 받는 위치에 대한 포인터입니다.

반환 값

작업이 성공하면 메서드는 STATUS_SUCCESS 반환하거나 NT_SUCCESS(status)가 TRUE인 다른 상태 값을 반환합니다. 그렇지 않으면 NT_SUCCESS(status)가 FALSE와 같은 상태 값을 반환합니다.

발언

클라이언트 드라이버는 UfxDeviceCreate호출하기 전에 WdfDeviceCreate 호출해야 합니다. 일반적으로 클라이언트 드라이버는 EvtDriverDeviceAdd 콜백 루틴에서 UfxDeviceCreate 호출합니다.

다음 코드 조각은 UfxDeviceCreate호출하는 방법을 보여 있습니다.

NTSTATUS
UfxDevice_DeviceCreate (
    _In_ WDFDEVICE WdfDevice
    )
/*++

Routine Description:

    Routine that registers with UFX and creates the UFX device object.

Arguments:

    WdfDevice - Wdf object representing the device.

Return Value:

    NTSTATUS.

--*/
{
    NTSTATUS Status;
    PCONTROLLER_CONTEXT ControllerContext;
    UFX_DEVICE_CALLBACKS UfxDeviceCallbacks;
    UFX_DEVICE_CAPABILITIES UfxDeviceCapabilities;
    PUFXDEVICE_CONTEXT UfxDeviceContext;
    UFXDEVICE UfxDevice;
    WDF_OBJECT_ATTRIBUTES Attributes;

    PAGED_CODE();

    TraceEntry();

    ControllerContext = DeviceGetControllerContext(WdfDevice);

    UFX_DEVICE_CAPABILITIES_INIT(&UfxDeviceCapabilities);
    UfxDeviceCapabilities.MaxSpeed = UsbSuperSpeed;
    UfxDeviceCapabilities.RemoteWakeSignalDelay = REMOTE_WAKEUP_TIMEOUT_INTERVAL_MS;
    
    //
    // Set bitmasks that define the IN and OUT endpoint numbers that are available on the controller
    //
    
    //
    // #### TODO: Set the IN endpoint mask here if not all endpoint addresses are supported ####
    //
    // For illustration purposes sample will set default control endpoint 0, 1-4, 8
    UfxDeviceCapabilities.InEndpointBitmap = 0x011F;
    
    //
    // #### TODO: Set the OUT endpoint mask here if not all endpoint addresses are supported ####
    //
    // For illustration purposes sample will set default control endpoint 0, 2-7
    //
    UfxDeviceCapabilities.OutEndpointBitmap = 0x00FD;

    //
    // Set the event callbacks for the ufxdevice
    //
    UFX_DEVICE_CALLBACKS_INIT(&UfxDeviceCallbacks);
    UfxDeviceCallbacks.EvtDeviceHostConnect = UfxDevice_EvtDeviceHostConnect;
    UfxDeviceCallbacks.EvtDeviceHostDisconnect = UfxDevice_EvtDeviceHostDisconnect;
    UfxDeviceCallbacks.EvtDeviceAddressed = UfxDevice_EvtDeviceAddressed;
    UfxDeviceCallbacks.EvtDeviceEndpointAdd = UfxDevice_EvtDeviceEndpointAdd;
    UfxDeviceCallbacks.EvtDeviceDefaultEndpointAdd = UfxDevice_EvtDeviceDefaultEndpointAdd;
    UfxDeviceCallbacks.EvtDeviceUsbStateChange = UfxDevice_EvtDeviceUsbStateChange;
    UfxDeviceCallbacks.EvtDevicePortChange = UfxDevice_EvtDevicePortChange;
    UfxDeviceCallbacks.EvtDevicePortDetect = UfxDevice_EvtDevicePortDetect;
    UfxDeviceCallbacks.EvtDeviceRemoteWakeupSignal = UfxDevice_EvtDeviceRemoteWakeupSignal;
    UfxDeviceCallbacks.EvtDeviceTestModeSet = UfxDevice_EvtDeviceTestModeSet;
    UfxDeviceCallbacks.EvtDeviceSuperSpeedPowerFeature = UfxDevice_EvtDeviceSuperSpeedPowerFeature;

    // Context associated with UFXDEVICE object
    WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&Attributes, UFXDEVICE_CONTEXT);
    Attributes.EvtCleanupCallback = UfxDevice_EvtCleanupCallback;

    // Create the UFXDEVICE object
    Status = UfxDeviceCreate(WdfDevice,
                             &UfxDeviceCallbacks,
                             &UfxDeviceCapabilities,
                             &Attributes,
                             &UfxDevice);

    ...

}

요구 사항

요구
지원되는 최소 클라이언트 Windows 10
대상 플랫폼 Windows
헤더 ufxclient.h
라이브러리 ufxstub.lib
IRQL PASSIVE_LEVEL