26#include "FxUsbDeviceUm.tmh"
45 "FxUsbDevice SubmitSync failed");
69 "Failed to initialize FxSyncRequest");
86 "FxUsbDevice SubmitSync failed");
97 __in ULONG USBDClientContractVersionForWdfClient
104 IWudfDeviceStack2* devstack2 =
NULL;
115 UCHAR deviceSpeed = 0;
128 "Failed to initialize FxSyncRequest");
132 status = request2.Initialize();
135 "Failed to initialize second FxSyncRequest");
142 "Failed to validate FxSyncRequest target");
146 status = request2.m_TrueRequest->ValidateTarget(
this);
149 "Failed to validate second FxSyncRequest target");
164 hr = devstack2->OpenUSBCommunicationChannel(
device,
165 device->GetAttachedDevice(),
215 "Could not retrieve config descriptor size, config.wTotalLength %d < "
216 "sizeof(config descriptor) (%d), %!STATUS!",
221 wTotalLength =
config.wTotalLength;
230 "Could not allocate %d bytes for config descriptor, %!STATUS!",
257 "Defective USB device reported two different config descriptor "
258 "wTotalLength values: %d and %d, %!STATUS!",
279 buf.SetBuffer(&deviceStatus,
sizeof(
USHORT));
313 if (deviceSpeed == 3) {
387 if ((pDescriptor->
bLength & 0x1) ||
459 "WDFUSBDEVICE %p, Request %p, setting target failed, "
470 if (pContext ==
NULL) {
484 RequestBuffer->GetBufferLength());
509 bufferSize = RequestBuffer->GetBufferLength();
518 "Control transfer buffer is limited to 0xFFFF bytes in size, "
527 "WDFUSBDEVICE %p, Request %p, setting target failed, "
537 if (pContext ==
NULL) {
596 PVOID CapabilityBuffer,
618 &GUID_USB_CAPABILITY_DEVICE_CONNECTION_HIGH_SPEED_COMPATIBLE,
627 &GUID_USB_CAPABILITY_DEVICE_CONNECTION_SUPER_SPEED_COMPATIBLE,
636 &GUID_USB_CAPABILITY_SELECTIVE_SUSPEND,
647 &GUID_USB_CAPABILITY_FUNCTION_SUSPEND,
698 sizeof(
Params->Types.SingleInterface));
705 "WDFUSBDEVICE %p cannot be auto configured for a single interface "
706 "since there are %d interfaces on the device, %!STATUS!",
718 "WDFUSBDEVICE %p could not retrieve AlternateSetting 0 for "
730 "WDFUSBDEVICE %p set AlternateSetting 0 for interface 0"
740 Params->Types.SingleInterface.ConfiguredUsbInterface =
743 Params->Types.SingleInterface.NumberConfiguredPipes =
781 Params->Types.MultiInterface.NumberOfConfiguredInterfaces = 0;
789 "WDFUSBDEVICE %p could not retrieve AlternateSetting 0 for "
801 "WDFUSBDEVICE %p set AlternateSetting 0 for bInterfaceNumber %d"
815 UCHAR interfacePairsNum = 0;
828 for (
i = 0;
i <
Params->Types.MultiInterface.NumberInterfaces ;
i++) {
830 UCHAR interfaceNumber;
831 UCHAR altSettingIndex;
833 settingPair = &
Params->Types.MultiInterface.Pairs[
i];
853 "WDFUSBDEVICE %p could not retrieve "
854 "AlternateSetting %d for "
855 "bInterfaceNumber %d, returning %!STATUS!",
857 altSettingIndex, interfaceNumber,
status);
872 "WDFUSBDEVICE %p set AlternateSetting %d for bInterfaceNumber %d"
890 "WDFUSBDEVICE %p interface pairs set (%d) is not equal to actual "
891 "# of interfaces (%d) reported by the device, %!STATUS!",
MdDeviceObject __inline GetDeviceObject(VOID)
IWudfDeviceStack2 * GetDeviceStack2(VOID)
_Must_inspect_result_ NTSTATUS SubmitSync(__in FxRequestBase *Request, __in_opt PWDF_REQUEST_SEND_OPTIONS Options=NULL, __out_opt PULONG Action=NULL)
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
CfxDeviceBase * m_DeviceBase
_Must_inspect_result_ NTSTATUS Reset(VOID)
WINUSB_INTERFACE_HANDLE m_WinUsbHandle
USB_DEVICE_DESCRIPTOR m_DeviceDescriptor
_Must_inspect_result_ NTSTATUS FormatStringRequest(__in FxRequestBase *Request, __in FxRequestBuffer *RequestBuffer, __in UCHAR StringIndex, __in USHORT LangID)
_Must_inspect_result_ NTSTATUS QueryUsbCapability(__in CONST GUID *CapabilityType, __in ULONG CapabilityBufferLength, __drv_when(CapabilityBufferLength==0, __out_opt) __drv_when(CapabilityBufferLength !=0 &&ResultLength==NULL, __out_bcount(CapabilityBufferLength)) __drv_when(CapabilityBufferLength !=0 &&ResultLength !=NULL, __out_bcount_part_opt(CapabilityBufferLength, *ResultLength)) PVOID CapabilityBuffer, __out_opt __drv_when(ResultLength !=NULL, __deref_out_range(<=, CapabilityBufferLength)) PULONG ResultLength)
_Must_inspect_result_ NTSTATUS SendSyncUmUrb(__inout PUMURB Urb, __in ULONGLONG Time, __in_opt WDFREQUEST Request=NULL, __in_opt PWDF_REQUEST_SEND_OPTIONS Options=NULL)
IWudfFile * m_pHostTargetFile
_Must_inspect_result_ NTSTATUS SendSyncRequest(__in FxSyncRequest *Request, __in ULONGLONG Time)
PUSB_CONFIGURATION_DESCRIPTOR m_ConfigDescriptor
FxWaitLockInternal m_InterfaceIterationLock
_Must_inspect_result_ NTSTATUS FormatControlRequest(__in FxRequestBase *Request, __in PWDF_USB_CONTROL_SETUP_PACKET Packet, __in FxRequestBuffer *RequestBuffer)
_Must_inspect_result_ NTSTATUS GetString(__in_ecount(*NumCharacters) PUSHORT String, __in PUSHORT NumCharacters, __in UCHAR StringIndex, __in_opt USHORT LangID, __in_opt WDFREQUEST Request=NULL, __in_opt PWDF_REQUEST_SEND_OPTIONS Options=NULL)
_Must_inspect_result_ NTSTATUS InitDevice(__in ULONG USBDClientContractVersionForWdfClient)
_Must_inspect_result_ NTSTATUS SelectConfigSingle(__in PWDF_OBJECT_ATTRIBUTES PipeAttributes, __in PWDF_USB_DEVICE_SELECT_CONFIG_PARAMS Params)
FxUsbInterface ** m_Interfaces
_Must_inspect_result_ NTSTATUS SelectConfigMulti(__in PWDF_OBJECT_ATTRIBUTES PipeAttributes, __in PWDF_USB_DEVICE_SELECT_CONFIG_PARAMS Params)
UCHAR GetInterfaceNumber(VOID)
PUSB_INTERFACE_DESCRIPTOR GetSettingDescriptor(__in UCHAR Setting)
WDFUSBINTERFACE GetHandle(VOID)
NTSTATUS CheckAndSelectSettingByIndex(__in UCHAR SettingIndex)
UCHAR GetNumConfiguredPipes(VOID)
NTSTATUS UpdatePipeAttributes(__in PWDF_OBJECT_ATTRIBUTES PipesAttributes)
CHECK_RETURN_IF_USER_MODE NTSTATUS Initialize()
#define STATUS_NOT_SUPPORTED
#define NT_SUCCESS(StatCode)
#define __drv_when(cond, annotes)
#define RtlCompareMemory(s1, s2, l)
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
PFX_DRIVER_GLOBALS pFxDriverGlobals
return pObject GetObjectHandle()
FxObjectHandleGetPtr(GetFxDriverGlobals(DriverGlobals), Fdo, FX_TYPE_DEVICE,(PVOID *)&pFdo)
void FxPoolFree(__in_xcount(ptr is at an offset from AllocationStart) PVOID ptr)
@ FX_RCT_USB_CONTROL_REQUEST
@ FX_RCT_USB_STRING_REQUEST
FxUsbInterface * pUsbInterface
GLenum GLuint GLenum GLsizei const GLchar * buf
GLuint GLsizei GLsizei * length
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
static PLARGE_INTEGER Time
#define _Must_inspect_result_
#define UNREFERENCED_PARAMETER(P)
#define __deref_out_range(x, y)
#define __out_bcount_part_opt(size, length)
#define STATUS_BUFFER_OVERFLOW
#define TRACE_LEVEL_ERROR
virtual VOID StoreAndReferenceMemory(__in FxRequestBuffer *Buffer)
VOID StoreAndReferenceMemory(__in FxUsbDevice *Device, __in FxRequestBuffer *Buffer, __in PWDF_USB_CONTROL_SETUP_PACKET SetupPacket)
VOID SetUrbInfo(__in UCHAR StringIndex, __in USHORT LangID)
_Must_inspect_result_ NTSTATUS AllocateDescriptor(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in size_t BufferSize)
VOID SetUsbType(__in WDF_USB_REQUEST_TYPE Type)
struct _UMURB_SELECT_INTERFACE UmUrbSelectInterface
struct _UMURB_CONTROL_TRANSFER UmUrbControlTransfer
struct _UMURB_HEADER UmUrbHeader
struct _UMURB_DESCRIPTOR_REQUEST UmUrbDescriptorRequest
WDFUSBINTERFACE UsbInterface
#define RtlCopyMemory(Destination, Source, Length)
#define RtlZeroMemory(Destination, Length)
#define STATUS_INVALID_PARAMETER
#define STATUS_UNSUCCESSFUL
#define STATUS_DEVICE_DATA_ERROR
#define STATUS_INSUFFICIENT_RESOURCES
#define UMURB_FUNCTION_RESET_PORT
#define USB_GETSTATUS_SELF_POWERED
struct _USB_CONFIGURATION_DESCRIPTOR * PUSB_CONFIGURATION_DESCRIPTOR
#define USB_CONFIGURATION_DESCRIPTOR_TYPE
struct _USB_STRING_DESCRIPTOR * PUSB_STRING_DESCRIPTOR
#define USB_DEVICE_DESCRIPTOR_TYPE
#define USB_CONFIG_REMOTE_WAKEUP
#define USB_STRING_DESCRIPTOR_TYPE
struct _USB_STRING_DESCRIPTOR USB_STRING_DESCRIPTOR
struct _USB_COMMON_DESCRIPTOR USB_COMMON_DESCRIPTOR
VOID FxUsbUmInitInformationUrb(__inout PUMURB UmUrb, __in WINUSB_INTERFACE_HANDLE WinUsbHandle, __in ULONG BufferLength, __in PVOID Buffer)
VOID FxUsbUmInitDescriptorUrb(__inout PUMURB UmUrb, __in WINUSB_INTERFACE_HANDLE WinUsbHandle, __in UCHAR DescriptorType, __in ULONG BufferLength, __in PVOID Buffer)
VOID FxUsbUmFormatRequest(__in FxRequestBase *Request, __in_xcount(Urb->Length) PUMURB_HEADER Urb, __in IWudfFile *HostFile, __in BOOLEAN Reuse)
VOID FxUsbUmInitControlTransferUrb(__inout PUMURB UmUrb, __in WINUSB_INTERFACE_HANDLE WinUsbHandle, __in ULONG BufferLength, __in PVOID Buffer)
BOOLEAN __inline FxBitArraySet(__inout_xcount((BitNumber/sizeof(UCHAR))+1) PUCHAR BitArray, __in UCHAR BitNumber)
_Must_inspect_result_ _In_ WDFDEVICE Device
FORCEINLINE LONGLONG WDF_REL_TIMEOUT_IN_SEC(_In_ ULONGLONG Time)
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG _Out_ PULONG ResultLength
_In_ PWDFDEVICE_INIT _In_ PWDF_REMOVE_LOCK_OPTIONS Options
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
FORCEINLINE VOID WDF_REQUEST_SEND_OPTIONS_INIT(_Out_ PWDF_REQUEST_SEND_OPTIONS Options, _In_ ULONG Flags)
_In_ WDFIOTARGET _In_ PWDF_REQUEST_COMPLETION_PARAMS Params
FORCEINLINE VOID WDF_REQUEST_SEND_OPTIONS_SET_TIMEOUT(_Inout_ PWDF_REQUEST_SEND_OPTIONS Options, _In_ LONGLONG Timeout)
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_opt_ PWDF_OBJECT_ATTRIBUTES PipeAttributes
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_ CONST GUID _In_ ULONG CapabilityBufferLength
FORCEINLINE VOID WDF_USB_CONTROL_SETUP_PACKET_INIT_GET_STATUS(_Out_ PWDF_USB_CONTROL_SETUP_PACKET Packet, _In_ WDF_USB_BMREQUEST_RECIPIENT BmRequestRecipient, _In_ USHORT Index)
@ WDF_USB_DEVICE_TRAIT_SELF_POWERED
@ WDF_USB_DEVICE_TRAIT_AT_HIGH_SPEED
@ WDF_USB_DEVICE_TRAIT_REMOTE_WAKE_CAPABLE
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_writes_opt_ NumCharacters PUSHORT _Inout_ PUSHORT NumCharacters
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_ CONST GUID * CapabilityType
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_writes_opt_ NumCharacters PUSHORT _Inout_ PUSHORT _In_ UCHAR StringIndex
@ WdfUsbRequestTypeDeviceControlTransfer
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_writes_opt_ NumCharacters PUSHORT _Inout_ PUSHORT _In_ UCHAR _In_opt_ USHORT LangID
@ WdfUsbTargetDeviceSelectConfigTypeMultiInterface
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_SEND_OPTIONS _In_ PWDF_USB_CONTROL_SETUP_PACKET SetupPacket