다음을 통해 공유


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 구현을 UFX(USB 함수 클래스 확장)에 등록합니다.

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
헤더 ufxclient.h
IRQL PASSIVE_LEVEL

참고 항목

UfxDeviceCreate

UfxDeviceEventComplete