EVT_UFX_DEVICE_ENDPOINT_ADD funzione di callback (ufxclient.h)

Implementazione del driver client per creare un oggetto endpoint predefinito.

Sintassi

EVT_UFX_DEVICE_ENDPOINT_ADD EvtUfxDeviceEndpointAdd;

NTSTATUS EvtUfxDeviceEndpointAdd(
  [in]      UFXDEVICE unnamedParam1,
  [in]      const PUSB_ENDPOINT_DESCRIPTOR unnamedParam2,
  [in, out] PUFXENDPOINT_INIT unnamedParam3
)
{...}

Parametri

[in] unnamedParam1

Handle a un oggetto dispositivo USB ricevuto dal driver client in una chiamata precedente a UfxDeviceCreate.

[in] unnamedParam2

Puntatore a una struttura USB_ENDPOINT_DESCRIPTOR contenente i dati del descrittore.

[in, out] unnamedParam3

Puntatore a una struttura UFXENDPOINT_INIT opaca che contiene il descrittore dell'endpoint necessario per creare un oggetto endpoint.

Valore restituito

Se l'operazione ha esito positivo, la funzione di callback deve restituire STATUS_SUCCESS o un altro valore di stato per cui NT_SUCCESS(status) è TRUE. In caso contrario, deve restituire un valore di stato per il quale NT_SUCCESS(status) è uguale a FALSE.

Commenti

Il driver client per il controller host della funzione registra l'implementazione EVT_UFX_DEVICE_ENDPOINT_ADD con l'estensione della classe di funzione USB (UFX) chiamando il metodo UfxDeviceCreate .

Per creare l'endpoint, è previsto che il driver client inizializzi gli attributi delle code di trasferimento e comando dell'endpoint e quindi chiami UfxEndpointCreate per creare l'endpoint.

Il driver client indica il completamento di questo evento chiamando il metodo UfxDeviceEventComplete .

Esempio

EVT_UFX_DEVICE_ENDPOINT_ADD UfxDevice_EvtDeviceEndpointAdd;

NTSTATUS
UfxDevice_EvtDeviceEndpointAdd (
    _In_ UFXDEVICE UfxDevice,
    _In_ const PUSB_ENDPOINT_DESCRIPTOR EndpointDescriptor,
    _Inout_ PUFXENDPOINT_INIT EndpointInit
    )
/*++

Routine Description:

    EvtDeviceEndpointAdd handler for the UFXDEVICE object.
    Creates UFXENDPOINT object corresponding to the newly reported endpoint.

Arguments:

    UfxDevice - UFXDEVICE object representing the device.

    EndpointDescriptor - Cosntant Pointer to Endpoint descriptor for the
        newly reported endpoint.

    EndpointInit - Pointer to the Opaque UFXENDPOINT_INIT object

Return Value:

    STATUS_SUCCESS on success, or an appropirate NTSTATUS message on failure.

--*/
{
    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();


    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);


    Status = WdfCollectionAdd(DeviceContext->Endpoints, Endpoint);


    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;

    //
    // This can happen if we're handling a SetInterface command.
    //
    if (DeviceContext->UsbState == UsbfnDeviceStateConfigured) {
        UfxEndpointConfigure(Endpoint);
    }

    Status = WdfIoQueueReadyNotify(
                 UfxEndpointGetTransferQueue(Endpoint),
                 TransferReadyNotify,
                 Endpoint);

End:
    TraceExit();
    return Status;
}

Requisiti

Requisito Valore
Piattaforma di destinazione Windows
Versione KMDF minima 1.0
Versione UMDF minima 2,0
Intestazione ufxclient.h
IRQL PASSIVE_LEVEL

Vedi anche

UfxDeviceCreate

UfxDeviceEventComplete