Función UfxEndpointCreate (ufxclient.h)

Crea un objeto de punto de conexión.

Sintaxis

NTSTATUS UfxEndpointCreate(
  [in]           UFXDEVICE              UfxDevice,
  [in, out]      PUFXENDPOINT_INIT      EndpointInit,
  [in, optional] PWDF_OBJECT_ATTRIBUTES Attributes,
  [in]           PWDF_IO_QUEUE_CONFIG   TransferQueueConfig,
  [in, optional] PWDF_OBJECT_ATTRIBUTES TransferQueueAttributes,
  [in]           PWDF_IO_QUEUE_CONFIG   CommandQueueConfig,
  [in, optional] PWDF_OBJECT_ATTRIBUTES CommandQueueAttributes,
  [out]          UFXENDPOINT            *UfxEndpoint
);

Parámetros

[in] UfxDevice

Identificador de un objeto de dispositivo UFX que creó el controlador mediante una llamada a UfxDeviceCreate.

[in, out] EndpointInit

Estructura opaca pasada por UFX en la llamada a EVT_UFX_DEVICE_ENDPOINT_ADD o EVT_UFX_DEVICE_DEFAULT_ENDPOINT_ADD.

[in, optional] Attributes

Puntero a la estructura de WDF_OBJECT_ATTRIBUTES asignada por el autor de la llamada. Esta estructura debe inicializarse con WDF_OBJECT_ATTRIBUTES_INIT o WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE. Este parámetro es opcional y puede ser WDF_NO_OBJECT_ATTRIBUTES.

[in] TransferQueueConfig

Puntero a una estructura de WDF_IO_QUEUE_CONFIG asignada por el autor de la llamada. Esta estructura debe inicializarse con WDF_IO_QUEUE_CONFIG_INIT.

[in, optional] TransferQueueAttributes

Puntero a la estructura de WDF_OBJECT_ATTRIBUTES asignada por el autor de la llamada. Esta estructura debe inicializarse con WDF_OBJECT_ATTRIBUTES_INIT o WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE. Este parámetro es opcional y puede ser WDF_NO_OBJECT_ATTRIBUTES.

[in] CommandQueueConfig

Puntero a una estructura de WDF_IO_QUEUE_CONFIG asignada por el autor de la llamada. Esta estructura debe inicializarse con WDF_IO_QUEUE_CONFIG_INIT.

[in, optional] CommandQueueAttributes

Puntero a la estructura de WDF_OBJECT_ATTRIBUTES asignada por el autor de la llamada. Esta estructura debe inicializarse con WDF_OBJECT_ATTRIBUTES_INIT o WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE. Este parámetro es opcional y puede ser WDF_NO_OBJECT_ATTRIBUTES.

[out] UfxEndpoint

Puntero a una ubicación que recibe un identificador de un objeto UFXENDPOINT.

Valor devuelto

Si la operación se realiza correctamente, el método devuelve STATUS_SUCCESS u otro valor de estado para el que NT_SUCCESS(status) es igual a TRUE. De lo contrario, devuelve un valor de estado para el que NT_SUCCESS(status) es igual a FALSE.

Comentarios

La cola de transferencia controla las siguientes E/STL relacionadas con las transferencias de puntos de conexión:

La cola de comandos controlará las siguientes E/STL:

En el ejemplo siguiente se muestra cómo crear un objeto UFXENDPOINT e inicializar su contexto.
NTSTATUS
UfxEndpointAdd (
    _In_ UFXDEVICE Device,
    _In_ PUSB_ENDPOINT_DESCRIPTOR Descriptor,
    _Inout_ PUFXENDPOINT_INIT EndpointInit
    )
/*++
Routine Description:

    Creates a UFXENDPOINT object, and initializes its contexts.

Parameters Description:

    Device - UFXDEVICE associated with the endpoint.

    Descriptor - Endpoint descriptor for this endpoint.

    EndpointInit - Opaque structure from UFX.

Return Value:

    STATUS_SUCCESS if successful, appropriate NTSTATUS message otherwise.
--*/
{
    NTSTATUS Status;
    WDF_OBJECT_ATTRIBUTES Attributes;
    WDF_IO_QUEUE_CONFIG TransferQueueConfig;
    WDF_OBJECT_ATTRIBUTES TransferQueueAttributes;
    WDF_IO_QUEUE_CONFIG CommandQueueConfig;
    WDF_OBJECT_ATTRIBUTES CommandQueueAttributes;
    UFXENDPOINT Endpoint;
    PUFXENDPOINT_CONTEXT EpContext;
    PUFXDEVICE_CONTEXT DeviceContext;
    UFX_ENDPOINT_CALLBACKS Callbacks;
    PENDPOINT_QUEUE_CONTEXT QueueContext;
    WDFQUEUE Queue;

    TraceEntry();

    DeviceContext = UfxDeviceGetContext(Device);

    WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&Attributes, UFXENDPOINT_CONTEXT);
    Attributes.ExecutionLevel = WdfExecutionLevelPassive;
    Attributes.EvtCleanupCallback = UfxEndpoint_Cleanup;

    //
    // Note: Execution level needs to be passive to avoid deadlocks with WdfRequestComplete.
    //
    WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&TransferQueueAttributes, ENDPOINT_QUEUE_CONTEXT);
    TransferQueueAttributes.ExecutionLevel = WdfExecutionLevelPassive;
    
    WDF_IO_QUEUE_CONFIG_INIT(&TransferQueueConfig, WdfIoQueueDispatchManual);
    TransferQueueConfig.AllowZeroLengthRequests = TRUE;
    TransferQueueConfig.EvtIoStop = EndpointQueue_EvtIoStop;

    WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&CommandQueueAttributes, ENDPOINT_QUEUE_CONTEXT);
    CommandQueueAttributes.ExecutionLevel = WdfExecutionLevelPassive;

    WDF_IO_QUEUE_CONFIG_INIT(&CommandQueueConfig, WdfIoQueueDispatchSequential);
    CommandQueueConfig.EvtIoInternalDeviceControl = EvtEndpointCommandQueue;

    UFX_ENDPOINT_CALLBACKS_INIT(&Callbacks);
    UfxEndpointInitSetEventCallbacks(EndpointInit, &Callbacks);

    Status = UfxEndpointCreate(
                 Device,
                 EndpointInit,
                 &Attributes,
                 &TransferQueueConfig,
                 &TransferQueueAttributes,
                 &CommandQueueConfig,
                 &CommandQueueAttributes,
                 &Endpoint);
    CHK_NT_MSG(Status, "Failed to create ufxendpoint!");

    Status = WdfCollectionAdd(DeviceContext->Endpoints, Endpoint);
    CHK_NT_MSG(Status, "Failed to add endpoint to collection!");

    EpContext = UfxEndpointGetContext(Endpoint);
    EpContext->UfxDevice = Device;
    EpContext->WdfDevice = DeviceContext->FdoWdfDevice;
    RtlCopyMemory(&EpContext->Descriptor, Descriptor, sizeof(*Descriptor));

    Queue = UfxEndpointGetTransferQueue(Endpoint);
    QueueContext = EndpointQueueGetContext(Queue);
    QueueContext->Endpoint = Endpoint;

    Queue = UfxEndpointGetCommandQueue(Endpoint);
    QueueContext = EndpointQueueGetContext(Queue);
    QueueContext->Endpoint = Endpoint;

    Status = TransferInitialize(Endpoint);
    CHK_NT_MSG(Status, "Failed to initialize endpoint transfers");
    
    //
    // This can happen if we're handling a SetInterface command.
    //
    if (DeviceContext->UsbState == UsbfnDeviceStateConfigured) {
        UfxEndpointConfigure(Endpoint);
    }

    Status = WdfIoQueueReadyNotify(
                 UfxEndpointGetTransferQueue(Endpoint),
                 TransferReadyNotify,
                 Endpoint);
    CHK_NT_MSG(Status, "Failed to register ready notify");

End:
    TraceExit();
    return Status;
}

Requisitos

Requisito Value
Cliente mínimo compatible Windows 10
Plataforma de destino Windows
Encabezado ufxclient.h
Library ufxstub.lib
IRQL PASSIVE_LEVEL