EVT_UFX_DEVICE_USB_STATE_CHANGE funzione di callback (ufxclient.h)

Implementazione del driver client per aggiornare lo stato del dispositivo USB.

Sintassi

EVT_UFX_DEVICE_USB_STATE_CHANGE EvtUfxDeviceUsbStateChange;

void EvtUfxDeviceUsbStateChange(
  [in] UFXDEVICE unnamedParam1,
  [in] USBFN_DEVICE_STATE unnamedParam2
)
{...}

Parametri

[in] unnamedParam1

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

[in] unnamedParam2

Flag tipizzato USBFN_DEVICE_STATE che indica lo stato del dispositivo USB.

Valore restituito

nessuno

Osservazioni

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

UFX richiama questo callback di evento per informare il driver client sul nuovo stato del dispositivo.

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

Esempio


EVT_UFX_DEVICE_USB_STATE_CHANGE UfxDevice_EvtDeviceUsbStateChange;

VOID
UfxDevice_EvtDeviceUsbStateChange (
    _In_ UFXDEVICE UfxDevice,
    _In_ USBFN_DEVICE_STATE NewState
)
/*++

Routine Description:

    EvtDeviceUsbStateChange handler for the UFXDEVICE object.

Arguments:

    UfxDevice - UFXDEVICE object representing the device.

    NewState - The new device state.

--*/
{
    NTSTATUS Status;
    PUFXDEVICE_CONTEXT Context;
    PCONTROLLER_CONTEXT ControllerContext;
    ULONG EpIndex;
    USBFN_DEVICE_STATE OldState;
 
    PAGED_CODE();

    TraceEntry();

    Context = UfxDeviceGetContext(UfxDevice);
    ControllerContext = DeviceGetControllerContext(Context->FdoWdfDevice);
    OldState = Context->UsbState;

    TraceInformation("New STATE: %d", NewState);

    Status = UfxDeviceStopOrResumeIdle(UfxDevice, NewState, Context->UsbPort);
    LOG_NT_MSG(Status, "Failed to stop or resume idle");

    WdfWaitLockAcquire(ControllerContext->InitializeDefaultEndpointLock, NULL);
    if (ControllerContext->InitializeDefaultEndpoint == TRUE) {
        //
        // Reset endpoint 0. This is the last part of soft reset, which was postponed
        // until now, since we need to make sure EP0 is created by UFX.
        //
        DeviceInitializeDefaultEndpoint(Context->FdoWdfDevice);
        ControllerContext->InitializeDefaultEndpoint = FALSE;
    }
    WdfWaitLockRelease(ControllerContext->InitializeDefaultEndpointLock);

    if (NewState == UsbfnDeviceStateConfigured && OldState != UsbfnDeviceStateSuspended) {

        for (EpIndex = 1; EpIndex < WdfCollectionGetCount(Context->Endpoints); EpIndex++) {
            UfxEndpointConfigure(WdfCollectionGetItem(Context->Endpoints, EpIndex));
        }

        // 
        // #### TODO: Insert code to allow the controller to accept U1/U2, if supported ####
        //
       
    }


    if (NewState == UsbfnDeviceStateDetached) {
        KeSetEvent(&ControllerContext->DetachEvent,
                   IO_NO_INCREMENT,
                   FALSE);
    }

    UfxDeviceEventComplete(UfxDevice, STATUS_SUCCESS);
    TraceExit();
}

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