29#include "FxUsbDeviceKm.tmh"
38#define UCHAR_MAX (0xff)
44 __in ULONG USBDClientContractVersionForWdfClient
62 USBDClientContractVersionForWdfClient,
69 "USBD_CreateHandle failed, %!STATUS!",
status);
100 "Could not retrieve device descriptor, %!STATUS!",
status);
133 request.m_TrueRequest->ClearFieldsForReuse();
140 "Could not retrieve config descriptor size, %!STATUS!",
status);
151 "Could not retrieve config descriptor size, zero bytes transferred, "
164 "Could not retrieve config descriptor size, config.wTotalLength %d < "
165 "sizeof(config descriptor) (%d), %!STATUS!",
194 "Could not allocate %d bytes for config descriptor, %!STATUS!",
213 request.m_TrueRequest->ClearFieldsForReuse();
220 "Could not retrieve config descriptor, %!STATUS!",
status);
229 "Defective USB device reported two different config descriptor "
230 "wTotalLength values: %d and %d, %!STATUS!",
255 request.m_TrueRequest->ClearFieldsForReuse();
277 request.m_TrueRequest->ClearFieldsForReuse();
280 request.m_TrueRequest->GetSubmitFxIrp()->GetIrp(),
281 &USB_BUS_INTERFACE_USBDI_GUID,
286 request.m_TrueRequest->VerifierSetFormatted();
301 request.m_TrueRequest->ClearFieldsForReuse();
304 request.m_TrueRequest->GetSubmitFxIrp()->GetIrp(),
305 &USB_BUS_INTERFACE_USBDI_GUID,
310 request.m_TrueRequest->VerifierSetFormatted();
355 "Query Interface for bus returned error, %!STATUS!",
status);
390 "Failed to initialize FxSyncRequest");
445#pragma prefast(suppress: __WARNING_BUFFER_OVERFLOW, "this annotation change in usb.h is communicated to usb team")
455 if ((pDescriptor->
bLength & 0x1) ||
528 "WDFUSBDEVICE %p, Request %p, setting target failed, "
541 if (pContext ==
NULL) {
549 "FxUsbDeviceStringContext::AllocateUrb failed, %!STATUS!",
status);
559 Request->EnableContextDisposeNotification();
566 RequestBuffer->GetBufferLength());
599 bufferSize = RequestBuffer->GetBufferLength();
608 "Control transfer buffer is limited to 0xFFFF bytes in size, "
617 "WDFUSBDEVICE %p, Request %p, setting target failed, "
630 if (pContext ==
NULL) {
638 "FxUsbDeviceControlContext::AllocateUrb Failed, %!STATUS!",
status);
648 Request->EnableContextDisposeNotification();
654 if (RequestBuffer->HasMdl()) {
763 PVOID CapabilityBuffer,
780 "WDFUSBDEVICE must have been created using WdfUsbTargetDeviceCreateWithParameters, %!STATUS!",
789 (
PUCHAR) CapabilityBuffer,
795 "Could not retrieve capability %!GUID!, %!STATUS!",
839 sizeof(
Params->Types.SingleInterface));
846 "WDFUSBDEVICE %p cannot be auto configured for a single interface "
847 "since there are %d interfaces on the device, %!STATUS!",
863 "WDFUSBDEVICE %p could not retrieve AlternateSetting 0 for "
882 Params->Types.SingleInterface.NumberConfiguredPipes =
885 Params->Types.SingleInterface.ConfiguredUsbInterface =
928 Params->Types.MultiInterface.NumberOfConfiguredInterfaces = 0;
948 pList[
i].InterfaceDescriptor =
954 "WDFUSBDEVICE %p could not retrieve AlternateSetting 0 for "
967 UCHAR interfacePairsNum = 0;
980 for (
i = 0;
i <
Params->Types.MultiInterface.NumberInterfaces ;
i++) {
982 UCHAR interfaceNumber;
983 UCHAR altSettingIndex;
985 settingPair = &
Params->Types.MultiInterface.Pairs[
i];
1002 pList[interfacePairsNum].InterfaceDescriptor =
1014 "WDFUSBDEVICE %p could not retrieve "
1015 "AlternateSetting %d for "
1016 "bInterfaceNumber %d, returning %!STATUS!",
1018 altSettingIndex, interfaceNumber,
status);
1022 interfacePairsNum++;
1038 "WDFUSBDEVICE %p interface pairs set (%d) is not equal to actual "
1039 "# of interfaces (%d) reported by the device, %!STATUS!",
1060 &
Params->Types.MultiInterface.NumberOfConfiguredInterfaces);
1090 "Failed to initialize FxSyncRequest");
_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 SubmitSyncRequestIgnoreTargetState(__in FxRequestBase *Request, __in_opt PWDF_REQUEST_SEND_OPTIONS RequestOptions)
MdDeviceObject m_TargetDevice
MdDeviceObject m_InStackDevice
_Must_inspect_result_ NTSTATUS FormatIoctlRequest(__in FxRequestBase *Request, __in ULONG Ioctl, __in BOOLEAN Internal, __in FxRequestBuffer *InputBuffer, __in FxRequestBuffer *OutputBuffer, __in_opt FxFileObject *FileObject=NULL)
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
_Must_inspect_result_ NTSTATUS Reset(VOID)
USBD_PIPE_HANDLE m_ControlPipe
_Must_inspect_result_ NTSTATUS SelectConfig(__in PWDF_OBJECT_ATTRIBUTES PipesAttributes, __in PURB Urb, __in FX_URB_TYPE FxUrbType, __out_opt PUCHAR NumConfiguredInterfaces)
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)
PINTERFACE_DEREFERENCE m_BusInterfaceDereference
PUSB_BUSIFFN_QUERY_BUS_TIME m_QueryBusTime
USBD_VERSION_INFORMATION m_UsbdVersionInformation
ULONG GetDefaultMaxTransferSize(VOID)
PUSB_CONFIGURATION_DESCRIPTOR m_ConfigDescriptor
ULONG m_HcdPortCapabilities
_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)
PVOID m_BusInterfaceContext
_Must_inspect_result_ NTSTATUS GetInterfaceNumberFromInterface(__in WDFUSBINTERFACE UsbInterface, __out PUCHAR InterfaceNumber)
FX_URB_TYPE GetFxUrbTypeForRequest(__in FxRequestBase *Request)
_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)
USBD_HANDLE GetUSBDHandle(VOID)
PUSB_INTERFACE_DESCRIPTOR GetSettingDescriptor(__in UCHAR Setting)
WDFUSBINTERFACE GetHandle(VOID)
UCHAR GetNumConfiguredPipes(VOID)
#define STATUS_NOT_SUPPORTED
#define NT_SUCCESS(StatCode)
#define __drv_when(cond, annotes)
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
PFX_DRIVER_GLOBALS pFxDriverGlobals
return pObject GetObjectHandle()
void FxPoolFree(__in_xcount(ptr is at an offset from AllocationStart) PVOID ptr)
@ FX_RCT_USB_CONTROL_REQUEST
@ FX_RCT_USB_STRING_REQUEST
enum _FX_URB_TYPE FX_URB_TYPE
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
#define _Must_inspect_result_
#define __deref_out_range(x, y)
#define __out_bcount_part_opt(size, length)
#define STATUS_BUFFER_OVERFLOW
#define TRACE_LEVEL_ERROR
static VOID _FormatIrp(__in PIRP Irp, __in const GUID *InterfaceGuid, __out PINTERFACE Interface, __in USHORT InterfaceSize, __in USHORT InterfaceVersion, __in_opt PVOID InterfaceSpecificData=NULL)
virtual VOID StoreAndReferenceMemory(__in FxRequestBuffer *Buffer)
_URB_CONTROL_TRANSFER * m_Urb
_URB_CONTROL_TRANSFER m_UrbLegacy
__checkReturn NTSTATUS AllocateUrb(__in USBD_HANDLE USBDHandle)
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)
__checkReturn NTSTATUS AllocateUrb(__in USBD_HANDLE USBDHandle)
_URB_CONTROL_DESCRIPTOR_REQUEST m_UrbLegacy
_URB_CONTROL_DESCRIPTOR_REQUEST * m_Urb
VOID SetUsbType(__in WDF_USB_REQUEST_TYPE Type)
USBD_PIPE_HANDLE PipeHandle
ULONG TransferBufferLength
struct _URB_CONTROL_DESCRIPTOR_REQUEST UrbControlDescriptorRequest
PUSB_INTERFACE_DESCRIPTOR InterfaceDescriptor
PINTERFACE_DEREFERENCE InterfaceDereference
PUSB_BUSIFFN_GETUSBDI_VERSION GetUSBDIVersion
PUSB_BUSIFFN_IS_DEVICE_HIGH_SPEED IsDeviceHighSpeed
PUSB_BUSIFFN_QUERY_BUS_TIME QueryBusTime
WDFUSBINTERFACE UsbInterface
#define FIELD_OFFSET(t, f)
#define RtlCopyMemory(Destination, Source, Length)
#define RtlZeroMemory(Destination, Length)
#define STATUS_INVALID_PARAMETER
#define STATUS_UNSUCCESSFUL
#define STATUS_INVALID_DEVICE_STATE
#define STATUS_DEVICE_DATA_ERROR
#define STATUS_INSUFFICIENT_RESOURCES
#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
struct _USB_DEVICE_DESCRIPTOR USB_DEVICE_DESCRIPTOR
#define USB_STRING_DESCRIPTOR_TYPE
struct _USB_STRING_DESCRIPTOR USB_STRING_DESCRIPTOR
struct _USB_COMMON_DESCRIPTOR USB_COMMON_DESCRIPTOR
#define BMREQUEST_DEVICE_TO_HOST
#define USBD_TRANSFER_DIRECTION_IN
#define URB_FUNCTION_CONTROL_TRANSFER
#define USBD_SHORT_TRANSFER_OK
#define USBD_DEFAULT_PIPE_TRANSFER
#define URB_FUNCTION_GET_STATUS_FROM_DEVICE
#define USB_BUSIF_USBDI_VERSION_1
#define USB_BUSIF_USBDI_VERSION_0
#define UsbBuildGetDescriptorRequest(urb, length, descriptorType, descriptorIndex, languageId, transferBuffer, transferBufferMDL, transferBufferLength, link)
#define UsbBuildGetStatusRequest(urb, op, index, transferBuffer, transferBufferMDL, link)
struct _USBD_INTERFACE_LIST_ENTRY * PUSBD_INTERFACE_LIST_ENTRY
struct _USBD_INTERFACE_LIST_ENTRY USBD_INTERFACE_LIST_ENTRY
#define USBD_CLIENT_CONTRACT_VERSION_INVALID
#define IOCTL_INTERNAL_USB_RESET_PORT
NTSTATUS USBD_QueryUsbCapability(_In_ USBD_HANDLE USBDHandle, _In_ const GUID *CapabilityType, _In_ ULONG OutputBufferLength, _When_(OutputBufferLength==0, _Pre_null_) _When_(OutputBufferLength !=0 &&ResultLength==NULL, _Out_writes_bytes_(OutputBufferLength)) _When_(OutputBufferLength !=0 &&ResultLength !=NULL, _Out_writes_bytes_to_opt_(OutputBufferLength, *ResultLength)) PUCHAR OutputBuffer, _Out_opt_ _When_(ResultLength !=NULL, _Deref_out_range_(<=, OutputBufferLength)) PULONG ResultLength)
NTSTATUS USBD_CreateHandle(_In_ PDEVICE_OBJECT DeviceObject, _In_ PDEVICE_OBJECT TargetDeviceObject, _In_ ULONG USBDClientContractVersion, _In_ ULONG PoolTag, _Out_ USBD_HANDLE *USBDHandle)
PUSB_INTERFACE_DESCRIPTOR FxUsbParseConfigurationDescriptor(__in PUSB_CONFIGURATION_DESCRIPTOR ConfigDesc, __in UCHAR InterfaceNumber, __in UCHAR AlternateSetting)
PURB FxUsbCreateConfigRequest(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PUSB_CONFIGURATION_DESCRIPTOR ConfigDesc, __in PUSBD_INTERFACE_LIST_ENTRY InterfaceList, __in ULONG DefaultMaxPacketSize)
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)
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
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN _In_opt_ PVOID Tag
_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
_In_ WDFUSBINTERFACE _In_ UCHAR _Out_ PUSB_INTERFACE_DESCRIPTOR InterfaceDescriptor
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_ CONST GUID _In_ ULONG CapabilityBufferLength
@ 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
union _WDF_USB_CONTROL_SETUP_PACKET * PWDF_USB_CONTROL_SETUP_PACKET
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_SEND_OPTIONS _In_ PWDF_USB_CONTROL_SETUP_PACKET SetupPacket
_Must_inspect_result_ _In_ WDFUSBINTERFACE _In_opt_ PWDF_OBJECT_ATTRIBUTES PipesAttributes
_Reserved_ PVOID Reserved