24#if defined(EVENT_TRACING)
25#include "FxUsbInterface.tmh"
70 if (m_Settings !=
NULL) {
121 if (pPipes !=
NULL) {
122 for (
i = 0;
i < numPipes;
i++) {
123 if (pPipes[
i] !=
NULL) {
192 InterfaceInfo->InterfaceNumber,
235 while (pDescriptor !=
NULL) {
250 if (m_Settings ==
NULL) {
253 "Could not allocate memory for %d settings for bInterfaceNumber %d "
254 "(Protocol %d, Class %d, SubClass %d), %!STATUS!",
273 while (pDescriptor !=
NULL) {
281 "Interface Number %d does not have contiguous alternate settings,"
282 "expected %d settings, found alt setting %d, %!STATUS!",
303 "Interface Number %d does not have contiguous alternate settings,"
304 "expected consecutive %d settings, but alt setting %d missing "
328 m_Settings[
i].InterfaceDescriptor,
332 if (pRelativeEnd ==
NULL) {
350 m_Settings[
i].InterfaceDescriptor,
355 m_Settings[
i].InterfaceDescriptor->bNumEndpoints
361 "Interface Number %d does not have a valid endpoint descriptor,"
393#if (FX_CORE_MODE == FX_CORE_KERNEL_MODE)
395#elif (FX_CORE_MODE == FX_CORE_USER_MODE)
433 numEP =
entry.InterfaceDescriptor->bNumEndpoints;
437#if (FX_CORE_MODE == FX_CORE_KERNEL_MODE)
451#elif (FX_CORE_MODE == FX_CORE_USER_MODE)
458 urb.UmUrbSelectInterface.AlternateSetting =
SettingIndex;
465 urb.UmUrbInterfaceInformation.Hdr.InterfaceHandle =
m_WinUsbHandle;
469 urb.UmUrbInterfaceInformation.AlternateSetting =
SettingIndex;
474 interfaceDesc = &urb.UmUrbInterfaceInformation.UsbInterfaceDescriptor;
476 m_Settings[
SettingIndex].InterfaceDescriptorAlloc = *interfaceDesc;
524 "WDFUSBINTERFACE %p has interface num %d, select setting by "
525 "descriptor specified interface num %d, %!STATUS!",
612 UCHAR iPipe, numPipes;
623 "Failed to initialize FxSyncRequest");
652 if (
Urb->UrbSelectInterface.Hdr.
Length < interfaceStructSize) {
656 "Urb header length 0x%x is less than expected 0x%x"
657 "%!STATUS!",
Urb->UrbSelectInterface.Hdr.
Length, interfaceStructSize,
status
675 interfaceStructSize) /
697 if (ppPipes ==
NULL) {
701 "Unable to allocate memory %!STATUS!"
708 for (iPipe = 0; iPipe < numPipes; iPipe++) {
712 if (ppPipes[iPipe] ==
NULL) {
716 "Unable to allocate memory for the pipes %!STATUS!",
status);
720 pPipe = ppPipes[iPipe];
726 "Init pipe failed %!STATUS!",
status);
735 "Commit pipe failed %!STATUS!",
status);
768 if (ppPipes !=
NULL) {
771 for (iPipe = 0; iPipe < numPipes; iPipe++) {
772 if (ppPipes[iPipe] !=
NULL) {
813 ULONG defaultMaxTransferSize;
835 Urb->UrbSelectInterface.
Interface.NumberOfPipes = NumEndpoints;
837 for (
i = 0;
i < NumEndpoints;
i++) {
849 Urb->UrbSelectInterface.
Interface.Pipes[
i].MaximumTransferSize =
850 defaultMaxTransferSize;
882 UCHAR curEndpointIndex;
885 pInterfaceDesc =
NULL;
886 curEndpointIndex = 0;
887 endPointFound =
FALSE;
895 if (pInterfaceDesc ==
NULL) {
917 while (
pCur < pEnd) {
999 PipeInfo->MaximumPacketSize = EndpointDesc->wMaxPacketSize;
1000 PipeInfo->EndpointAddress = EndpointDesc->bEndpointAddress;
1001 PipeInfo->Interval = EndpointDesc->bInterval;
1077 sizeof(*UsbInterfaceDescriptor));
1082 sizeof(*UsbInterfaceDescriptor));
1110 "WDFUSBINTERFACE %p not configured, cannot retrieve configured "
1140 return m_Settings[
SettingIndex].InterfaceDescriptor->bNumEndpoints;
1165 return m_Settings[
i].InterfaceDescriptor;
_Must_inspect_result_ NTSTATUS SubmitSync(__in FxRequestBase *Request, __in_opt PWDF_REQUEST_SEND_OPTIONS Options=NULL, __out_opt PULONG Action=NULL)
_Must_inspect_result_ NTSTATUS Init(__in CfxDeviceBase *Device)
virtual VOID DeleteObject(VOID)
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
__drv_restoresIRQL KIRQL __in BOOLEAN Unlock
VOID MarkNoDeleteDDI(__in FxObjectLockState State=ObjectLock)
VOID DeleteFromFailedCreate(VOID)
_Must_inspect_result_ NTSTATUS Commit(__in_opt PWDF_OBJECT_ATTRIBUTES Attributes, __out_opt WDFOBJECT *ObjectHandle, __in_opt FxObject *Parent=NULL, __in BOOLEAN AssignDriverAsDefaultParent=TRUE)
VOID CleanupInterfacePipesAndDelete(__in FxUsbInterface *UsbInterface)
_Must_inspect_result_ NTSTATUS SendSyncUmUrb(__inout PUMURB Urb, __in ULONGLONG Time, __in_opt WDFREQUEST Request=NULL, __in_opt PWDF_REQUEST_SEND_OPTIONS Options=NULL)
VOID RemoveDeletedInterface(__in FxUsbInterface *Interface)
ULONG GetDefaultMaxTransferSize(VOID)
PUSB_CONFIGURATION_DESCRIPTOR m_ConfigDescriptor
USBD_CONFIGURATION_HANDLE m_ConfigHandle
FxUsbPipe ** m_ConfiguredPipes
ULONG DetermineDefaultMaxTransferSize(VOID)
_Must_inspect_result_ NTSTATUS SelectSettingByIndex(__in PWDF_OBJECT_ATTRIBUTES PipesAttributes, __in UCHAR SettingIndex)
VOID FormatSelectSettingUrb(__in_bcount(GET_SELECT_INTERFACE_REQUEST_SIZE(NumEndpoints)) PURB Urb, __in USHORT NumEndpoints, __in UCHAR SettingNumber)
VOID GetEndpointInformation(__in UCHAR SettingIndex, __in UCHAR PipeIndex, __in PWDF_USB_PIPE_INFORMATION PipeInfo)
VOID CleanUpAndDelete(__in BOOLEAN ClearDestroyCallback)
UCHAR m_CurAlternateSetting
VOID SetConfiguredPipes(__in FxUsbPipe **ppPipes)
FxUsbInterface(_In_ PFX_DRIVER_GLOBALS FxDriverGlobals, _In_ FxUsbDevice *UsbDevice, _In_ PUSB_INTERFACE_DESCRIPTOR InterfaceDescriptor)
VOID RemoveDeletedPipe(__in FxUsbPipe *Pipe)
WINUSB_INTERFACE_HANDLE m_WinUsbHandle
BOOLEAN IsInterfaceConfigured(VOID)
VOID CopyEndpointFieldsFromDescriptor(__in PWDF_USB_PIPE_INFORMATION PipeInfo, __in PUSB_ENDPOINT_DESCRIPTOR EndpointDesc, __in UCHAR SettingIndex)
VOID GetDescriptor(__in PUSB_INTERFACE_DESCRIPTOR UsbInterfaceDescriptor, __in UCHAR SettingIndex)
PUSB_INTERFACE_DESCRIPTOR GetSettingDescriptor(__in UCHAR Setting)
_Must_inspect_result_ NTSTATUS SelectSettingByDescriptor(__in PWDF_OBJECT_ATTRIBUTES PipesAttributes, __in PUSB_INTERFACE_DESCRIPTOR InterfaceDescriptor)
WDFUSBPIPE GetConfiguredPipe(__in UCHAR PipeIndex, __out_opt PWDF_USB_PIPE_INFORMATION PipeInfo)
NTSTATUS CheckAndSelectSettingByIndex(__in UCHAR SettingIndex)
UCHAR m_NumberOfConfiguredPipes
_Must_inspect_result_ NTSTATUS CreateSettings(VOID)
UCHAR GetConfiguredSettingIndex(VOID)
UCHAR GetNumEndpoints(__in UCHAR SettingIndex)
FxUsbDevice * m_UsbDevice
VOID SetInfo(__in PUSBD_INTERFACE_INFORMATION Interface)
VOID SetNumConfiguredPipes(__in UCHAR NumberOfPipes)
_Must_inspect_result_ NTSTATUS SelectSetting(__in PWDF_OBJECT_ATTRIBUTES PipesAttributes, __in PURB Urb)
NTSTATUS MakeAndConfigurePipes(__in PWDF_OBJECT_ATTRIBUTES PipesAttributes, __in UCHAR NumPipes)
static WDF_USB_PIPE_TYPE _UsbdPipeTypeToWdf(__in USBD_PIPE_TYPE UsbdPipeType)
VOID GetInformation(__out PWDF_USB_PIPE_INFORMATION PipeInformation)
VOID InitPipe(__in PUSBD_PIPE_INFORMATION PipeInfo, __in UCHAR InterfaceNumber, __in FxUsbInterface *UsbInterface)
WDFUSBPIPE GetHandle(VOID)
#define NT_SUCCESS(StatCode)
#define InitializeListHead(ListHead)
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
FxVerifierDbgBreakPoint(pFxDriverGlobals)
void FxPoolFree(__in_xcount(ptr is at an offset from AllocationStart) PVOID ptr)
return pUsbInterface GetConfiguredSettingIndex()
@ FxUsbPipeHighSpeedMaxTransferSize
@ FxUsbPipeControlMaxTransferSize
@ FxUsbPipeLowSpeedMaxTransferSize
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
#define _Must_inspect_result_
#define UNREFERENCED_PARAMETER(P)
#define TRACE_LEVEL_ERROR
#define RtlCopyMemory(Destination, Source, Length)
#define RtlZeroMemory(Destination, Length)
#define STATUS_INVALID_DEVICE_REQUEST
#define STATUS_INVALID_PARAMETER
#define STATUS_INSUFFICIENT_RESOURCES
#define UMURB_FUNCTION_SELECT_INTERFACE
#define UMURB_FUNCTION_GET_DESCRIPTOR_FROM_INTERFACE
#define USB_ENDPOINT_DESCRIPTOR_TYPE
struct _USB_INTERFACE_DESCRIPTOR * PUSB_INTERFACE_DESCRIPTOR
struct _USB_COMMON_DESCRIPTOR * PUSB_COMMON_DESCRIPTOR
struct _USB_ENDPOINT_DESCRIPTOR * PUSB_ENDPOINT_DESCRIPTOR
#define USB_INTERFACE_DESCRIPTOR_TYPE
struct _USBD_PIPE_INFORMATION USBD_PIPE_INFORMATION
enum _USBD_PIPE_TYPE USBD_PIPE_TYPE
#define GET_USBD_INTERFACE_SIZE(numEndpoints)
#define UsbBuildSelectInterfaceRequest(urb, length, configurationHandle, interfaceNumber, alternateSetting)
#define GET_SELECT_INTERFACE_REQUEST_SIZE(totalPipes)
_In_ PIO_STACK_LOCATION _In_ PURB Urb
PUSB_COMMON_DESCRIPTOR FxUsbFindDescriptorType(__in PVOID Buffer, __in size_t BufferLength, __in PVOID Start, __in LONG DescriptorType)
NTSTATUS FxUsbValidateDescriptorType(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PUSB_CONFIGURATION_DESCRIPTOR ConfigDescriptor, __in PVOID Start, __in PVOID End, __in LONG DescriptorType, __in size_t SizeToValidate, __in FxUsbValidateDescriptorOp Op, __in ULONG MaximumNumDescriptorsToValidate)
VOID FxFormatUsbRequest(__in FxRequestBase *Request, __in PURB Urb, __in FX_URB_TYPE FxUrbType, __drv_when(FxUrbType==FxUrbTypeUsbdAllocated, __in) __drv_when(FxUrbType !=FxUrbTypeUsbdAllocated, __in_opt) USBD_HANDLE UsbdHandle)
@ FxUsbValidateDescriptorOpAtLeast
FORCEINLINE LONGLONG WDF_REL_TIMEOUT_IN_SEC(_In_ ULONGLONG Time)
#define WDF_PTR_ADD_OFFSET(_ptr, _offset)
FORCEINLINE VOID WDF_REQUEST_SEND_OPTIONS_INIT(_Out_ PWDF_REQUEST_SEND_OPTIONS Options, _In_ ULONG Flags)
@ WDF_REQUEST_SEND_OPTION_IGNORE_TARGET_STATE
FORCEINLINE VOID WDF_REQUEST_SEND_OPTIONS_SET_TIMEOUT(_Inout_ PWDF_REQUEST_SEND_OPTIONS Options, _In_ LONGLONG Timeout)
_In_ WDFUSBINTERFACE _In_ UCHAR _Out_opt_ PWDF_USB_PIPE_INFORMATION PipeInfo
_In_ WDFUSBINTERFACE _In_ UCHAR _Out_ PUSB_INTERFACE_DESCRIPTOR InterfaceDescriptor
_In_ WDFUSBINTERFACE _In_ UCHAR PipeIndex
_Must_inspect_result_ _In_ WDFDEVICE _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFUSBDEVICE * UsbDevice
@ WDF_USB_DEVICE_TRAIT_AT_HIGH_SPEED
_In_ WDFUSBINTERFACE _In_ UCHAR _In_ UCHAR EndpointIndex
_Must_inspect_result_ _In_ WDFUSBINTERFACE _In_opt_ PWDF_OBJECT_ATTRIBUTES PipesAttributes
_In_ WDFUSBINTERFACE _In_ UCHAR SettingIndex
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList