24#include "FxUsbInterface.tmh"
68 if (m_Settings !=
NULL) {
119 if (pPipes !=
NULL) {
120 for (
i = 0;
i < numPipes;
i++) {
121 if (pPipes[
i] !=
NULL) {
190 InterfaceInfo->InterfaceNumber,
233 while (pDescriptor !=
NULL) {
248 if (m_Settings ==
NULL) {
251 "Could not allocate memory for %d settings for bInterfaceNumber %d "
252 "(Protocol %d, Class %d, SubClass %d), %!STATUS!",
271 while (pDescriptor !=
NULL) {
279 "Interface Number %d does not have contiguous alternate settings,"
280 "expected %d settings, found alt setting %d, %!STATUS!",
301 "Interface Number %d does not have contiguous alternate settings,"
302 "expected consecutive %d settings, but alt setting %d missing "
326 m_Settings[
i].InterfaceDescriptor,
330 if (pRelativeEnd ==
NULL) {
348 m_Settings[
i].InterfaceDescriptor,
353 m_Settings[
i].InterfaceDescriptor->bNumEndpoints
359 "Interface Number %d does not have a valid endpoint descriptor,"
391#if (FX_CORE_MODE == FX_CORE_KERNEL_MODE)
393#elif (FX_CORE_MODE == FX_CORE_USER_MODE)
431 numEP =
entry.InterfaceDescriptor->bNumEndpoints;
435#if (FX_CORE_MODE == FX_CORE_KERNEL_MODE)
449#elif (FX_CORE_MODE == FX_CORE_USER_MODE)
456 urb.UmUrbSelectInterface.AlternateSetting =
SettingIndex;
463 urb.UmUrbInterfaceInformation.Hdr.InterfaceHandle =
m_WinUsbHandle;
467 urb.UmUrbInterfaceInformation.AlternateSetting =
SettingIndex;
472 interfaceDesc = &urb.UmUrbInterfaceInformation.UsbInterfaceDescriptor;
474 m_Settings[
SettingIndex].InterfaceDescriptorAlloc = *interfaceDesc;
522 "WDFUSBINTERFACE %p has interface num %d, select setting by "
523 "descriptor specified interface num %d, %!STATUS!",
610 UCHAR iPipe, numPipes;
621 "Failed to initialize FxSyncRequest");
628 const ULONG interfaceStructSize =
sizeof(Urb->UrbSelectInterface.Interface) -
639 Urb->UrbSelectInterface.Interface.AlternateSetting) {
650 if (Urb->UrbSelectInterface.Hdr.Length < interfaceStructSize) {
654 "Urb header length 0x%x is less than expected 0x%x"
655 "%!STATUS!", Urb->UrbSelectInterface.Hdr.Length, interfaceStructSize,
status
672 numPipes = (
UCHAR) ((Urb->UrbSelectInterface.Interface.Length -
673 interfaceStructSize) /
695 if (ppPipes ==
NULL) {
699 "Unable to allocate memory %!STATUS!"
706 for (iPipe = 0; iPipe < numPipes; iPipe++) {
710 if (ppPipes[iPipe] ==
NULL) {
714 "Unable to allocate memory for the pipes %!STATUS!",
status);
718 pPipe = ppPipes[iPipe];
724 "Init pipe failed %!STATUS!",
status);
733 "Commit pipe failed %!STATUS!",
status);
761 SetInfo(&Urb->UrbSelectInterface.Interface);
766 if (ppPipes !=
NULL) {
769 for (iPipe = 0; iPipe < numPipes; iPipe++) {
770 if (ppPipes[iPipe] !=
NULL) {
811 ULONG defaultMaxTransferSize;
830 Urb->UrbSelectInterface.Interface.Length =
833 Urb->UrbSelectInterface.Interface.NumberOfPipes = NumEndpoints;
835 for (
i = 0;
i < NumEndpoints;
i++) {
841 &Urb->UrbSelectInterface.Interface.Pipes[
i] <
843 Urb->UrbSelectInterface.Interface.Length)
846 Urb->UrbSelectInterface.Interface.Pipes[
i].PipeFlags = 0x0;
847 Urb->UrbSelectInterface.Interface.Pipes[
i].MaximumTransferSize =
848 defaultMaxTransferSize;
880 UCHAR curEndpointIndex;
883 pInterfaceDesc =
NULL;
884 curEndpointIndex = 0;
885 endPointFound =
FALSE;
892 if (pInterfaceDesc ==
NULL) {
914 while (
pCur < pEnd) {
996 PipeInfo->MaximumPacketSize = EndpointDesc->wMaxPacketSize;
997 PipeInfo->EndpointAddress = EndpointDesc->bEndpointAddress;
998 PipeInfo->Interval = EndpointDesc->bInterval;
1074 sizeof(*UsbInterfaceDescriptor));
1079 sizeof(*UsbInterfaceDescriptor));
1107 "WDFUSBINTERFACE %p not configured, cannot retrieve configured "
1137 return m_Settings[
SettingIndex].InterfaceDescriptor->bNumEndpoints;
1162 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 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)
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