EVT_UFX_DEVICE_USB_STATE_CHANGE コールバック関数 (ufxclient.h)

USB デバイスの状態を更新するためのクライアント ドライバーの実装。

構文

EVT_UFX_DEVICE_USB_STATE_CHANGE EvtUfxDeviceUsbStateChange;

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

パラメーター

[in] unnamedParam1

UfxDeviceCreate の前回の呼び出しでクライアント ドライバーが受信した USB デバイス オブジェクトへのハンドル。

[in] unnamedParam2

USB デバイスの状態を示すUSBFN_DEVICE_STATE型指定フラグ。

戻り値

なし

解説

関数ホスト コントローラーのクライアント ドライバーは、UfxDeviceCreate メソッドを呼び出して、そのEVT_UFX_DEVICE_USB_STATE_CHANGE実装を USB 関数クラス拡張機能 (UFX) に登録します。

UFX は、このイベント コールバックを呼び出して、デバイスの新しい状態についてクライアント ドライバーに通知します。

クライアント ドライバーは、 UfxDeviceEventComplete メソッドを呼び出すことによって、このイベントの完了を示します。


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

要件

要件
対象プラットフォーム Windows
最小 KMDF バージョン 1.0
最小 UMDF バージョン 2.0
Header ufxclient.h
IRQL PASSIVE_LEVEL

こちらもご覧ください

UfxDeviceCreate

UfxDeviceEventComplete