Partager via


EVT_UCX_USBDEVICE_ENDPOINT_ADD fonction de rappel (ucxusbdevice.h)

Implémentation du pilote client que UCX appelle pour ajouter un nouveau point de terminaison pour un périphérique USB.

Syntaxe

EVT_UCX_USBDEVICE_ENDPOINT_ADD EvtUcxUsbdeviceEndpointAdd;

NTSTATUS EvtUcxUsbdeviceEndpointAdd(
  [in]           UCXCONTROLLER UcxController,
  [in]           UCXUSBDEVICE UcxUsbDevice,
  [in]           PUSB_ENDPOINT_DESCRIPTOR UsbEndpointDescriptor,
  [in]           ULONG UsbEndpointDescriptorBufferLength,
  [in, optional] PUSB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR SuperSpeedEndpointCompanionDescriptor,
  [in]           PUCXENDPOINT_INIT UcxEndpointInit
)
{...}

Paramètres

[in] UcxController

Handle du contrôleur UCX reçu par le pilote client lors d’un appel précédent à la méthode UcxControllerCreate.

[in] UcxUsbDevice

Handle vers un objet UCX qui représente le périphérique USB.

[in] UsbEndpointDescriptor

Pointeur vers un emplacement contenant un descripteur USB pour le point de terminaison créé.

[in] UsbEndpointDescriptorBufferLength

Longueur en octets du descripteur.

[in, optional] SuperSpeedEndpointCompanionDescriptor

Descripteur supplémentaire pour un port super vitesse. Ce paramètre est facultatif et peut être NULL.

[in] UcxEndpointInit

Pointeur vers une structure opaque contenant des informations d’initialisation. Les rappels pour l’objet de point de terminaison sont associés à cette structure. Cette structure est gérée par UCX.

Valeur de retour

Si l’opération réussit, la fonction de rappel doit retourner STATUS_SUCCESS, ou une autre valeur d’état pour laquelle NT_SUCCESS(status) a la valeur TRUE. Sinon, il doit retourner une valeur d’état pour laquelle NT_SUCCESS(status) a la valeur FALSE.

Remarques

Le pilote client UCX inscrit cette fonction de rappel avec l’extension UCX (Host Controller Extension) USB en appelant la méthode UcxUsbDeviceCreate.

La fonction de rappel appelle UcxEndpointCreate pour créer un objet de point de terminaison et inscrire des fonctions de rappel d’objet de point de terminaison.

Ensuite, la fonction de rappel crée généralement une file d’attente WDF associée à l’objet de point de terminaison. La file d’attente ne reçoit aucune demande tant que l’extension de classe ne l’a pas démarrée.

Exemples

NTSTATUS
Endpoint_EvtUcxUsbDeviceEndpointAdd(
    UCXCONTROLLER                                   UcxController,
    UCXUSBDEVICE                                    UcxUsbDevice,
    PUSB_ENDPOINT_DESCRIPTOR                        UsbEndpointDescriptor,
    ULONG                                           UsbEndpointDescriptorBufferLength,
    PUSB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR   SuperSpeedEndpointCompanionDescriptor,
    PUCXENDPOINT_INIT                               UcxEndpointInit
)

{
    NTSTATUS                        status = STATUS_SUCCESS;

    UCX_ENDPOINT_EVENT_CALLBACKS    ucxEndpointEventCallbacks;
    WDF_OBJECT_ATTRIBUTES           objectAttributes;

    PUCX_CONTROLLER_CONTEXT         ucxControllerContext;

    UCXENDPOINT                     ucxEndpoint;
    PUCX_ENDPOINT_CONTEXT           ucxEndpointContext;

    WDF_IO_QUEUE_CONFIG             queueConfig;

    UNREFERENCED_PARAMETER(UsbEndpointDescriptor);
    UNREFERENCED_PARAMETER(UsbEndpointDescriptorBufferLength);
    UNREFERENCED_PARAMETER(SuperSpeedEndpointCompanionDescriptor);

    UCX_ENDPOINT_EVENT_CALLBACKS_INIT(&ucxEndpointEventCallbacks,
                                      Endpoint_EvtUcxEndpointPurge,
                                      Endpoint_EvtUcxEndpointStart,
                                      Endpoint_EvtUcxEndpointAbort,
                                      Endpoint_EvtUcxEndpointReset,
                                      Endpoint_EvtUcxEndpointOkToCancelTransfers,
                                      Endpoint_EvtUcxEndpointStaticStreamsAdd,
                                      Endpoint_EvtUcxEndpointStaticStreamsEnable,
                                      Endpoint_EvtUcxEndpointStaticStreamsDisable,
                                      Endpoint_EvtUcxEndpointEnableForwardProgress);

    UcxEndpointInitSetEventCallbacks(UcxEndpointInit, &ucxEndpointEventCallbacks);

    WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&objectAttributes, UCX_ENDPOINT_CONTEXT);

    ucxControllerContext = GetUcxControllerContext(UcxController);

    status = UcxEndpointCreate(UcxUsbDevice,
        &UcxEndpointInit,
        &objectAttributes,
        &ucxEndpoint);

    if (!NT_SUCCESS(status)) {
        DbgTrace(TL_ERROR, Endpoint, "UcxEndpoint Failed %!STATUS!", status);
        goto EvtUsbDeviceEndpointAddEnd;
    }

    DbgTrace(TL_INFO, Endpoint, "UcxEndpoint created");

    ucxEndpointContext = GetUcxEndpointContext(ucxEndpoint);

    ucxEndpointContext->IsDefault = FALSE;
    ucxEndpointContext->MaxPacketSize = MAX_PACKET_SIZE;

    WDF_IO_QUEUE_CONFIG_INIT(&queueConfig, WdfIoQueueDispatchManual);

    status = WdfIoQueueCreate(ucxControllerContext->WdfDevice,
        &queueConfig,
        WDF_NO_OBJECT_ATTRIBUTES,
        &ucxEndpointContext->IoQueue);

    if (!NT_SUCCESS(status)) {
        DbgTrace(TL_ERROR, Endpoint, "WdfIoQueueCreate Failed %!STATUS!", status);
        goto EvtUsbDeviceEndpointAddEnd;
    }

    UcxEndpointSetWdfIoQueue(ucxEndpoint, ucxEndpointContext->IoQueue);

EvtUsbDeviceEndpointAddEnd:

    return status;
}

Exigences

Exigence Valeur
plateforme cible Windows
version minimale de KMDF 1.0
version minimale de UMDF 2.0
d’en-tête ucxusbdevice.h (include Ucxclass.h)
IRQL PASSIVE_LEVEL

Voir aussi

UcxDefaultEndpointInitSetEventCallbacks

UcxEndpointCreate

UcxUsbDeviceCreate

WDF_IO_QUEUE_CONFIG_INIT

WdfIoQueueCreate