ReactOS 0.4.17-dev-1281-g065abb3
clientif.cpp File Reference
#include "ucx01000.h"
#include <debug.h>
Include dependency graph for clientif.cpp:

Go to the source code of this file.

Macros

#define NDEBUG
 
#define UCX_MAX_SELECT_PIPES   32
 
#define UCX_MAX_SELECT_INTERFACES   255
 
#define UCX_FAKE_TOTAL_BANDWIDTH   4000000
 
#define UCX_UHCI_OPTION_FLAGS   0x000002C3
 
#define UCX_EHCI_OPTION_FLAGS   0x00080A95
 

Functions

static BOOLEAN NTAPI UcxIsLowOrFullSpeed (_In_ UcxUsbDevice *Device)
 
static VOID USB_BUSIFFN UcxBusGetUsbdiVersion (_In_ PVOID Context, _Out_opt_ PUSBD_VERSION_INFORMATION VersionInformation, _Out_opt_ PULONG HcdCapabilities)
 
static NTSTATUS USB_BUSIFFN UcxBusQueryBusTime (_In_ PVOID Context, _Out_opt_ PULONG CurrentFrame)
 
static NTSTATUS USB_BUSIFFN UcxBusSubmitIsoOutUrb (_In_ PVOID Context, _In_ PURB Urb)
 
static NTSTATUS USB_BUSIFFN UcxBusQueryBusInformation (_In_ PVOID Context, _In_ ULONG Level, _Inout_ PVOID Buffer, _Out_ PULONG BufferLength, _Out_opt_ PULONG ActualLength)
 
static BOOLEAN USB_BUSIFFN UcxBusIsDeviceHighSpeed (_In_opt_ PVOID Context)
 
static NTSTATUS USB_BUSIFFN UcxBusEnumLogEntry (_In_ PVOID Context, _In_ ULONG DriverTag, _In_ ULONG EnumTag, _In_ ULONG P1, _In_ ULONG P2)
 
static NTSTATUS USB_BUSIFFN UcxBusQueryBusTimeEx (_In_opt_ PVOID Context, _Out_opt_ PULONG CurrentMicroFrame)
 
static NTSTATUS USB_BUSIFFN UcxBusQueryControllerType (_In_opt_ PVOID Context, _Out_opt_ PULONG HcdiOptionFlags, _Out_opt_ PUSHORT PciVendorId, _Out_opt_ PUSHORT PciDeviceId, _Out_opt_ PUCHAR PciClass, _Out_opt_ PUCHAR PciSubClass, _Out_opt_ PUCHAR PciRevisionId, _Out_opt_ PUCHAR PciProgIf)
 
NTSTATUS NTAPI UcxEvtQueryUsbdiInterface (_In_ WDFDEVICE Device, _In_ LPGUID InterfaceType, _Inout_ PINTERFACE ExposedInterface, _Inout_opt_ PVOID ExposedInterfaceSpecificData)
 
static VOID NTAPI UcxClientUnregister (_In_ USBD_CLIENT_HANDLE ClientHandle)
 
static NTSTATUS NTAPI UcxClientAllocUrb (_In_ USBD_CLIENT_HANDLE ClientHandle, _Outptr_ PURB *Urb)
 
static NTSTATUS NTAPI UcxClientAllocIsochUrb (_In_ USBD_CLIENT_HANDLE ClientHandle, _In_ ULONG NumberOfIsochPackets, _Outptr_ PURB *Urb)
 
static NTSTATUS NTAPI UcxClientSelectConfigXrbBuild (_In_ USBD_CLIENT_HANDLE ClientHandle, _In_ PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor, _In_ PUSBD_INTERFACE_LIST_ENTRY InterfaceList, _Outptr_ PURB *UrbOut)
 
static NTSTATUS NTAPI UcxClientSelectInterfaceXrbBuild (_In_ USBD_CLIENT_HANDLE ClientHandle, _In_ USBD_CONFIGURATION_HANDLE ConfigurationHandle, _In_ PUSBD_INTERFACE_LIST_ENTRY InterfaceEntry, _Outptr_ PURB *UrbOut)
 
static VOID NTAPI UcxClientReleaseUrb (_In_ PURB Urb)
 
static NTSTATUS NTAPI UcxClientOffloadSelectXrbAllocate (_In_ USBD_CLIENT_HANDLE ClientHandle, _In_ USBD_CONFIGURATION_HANDLE ConfigurationHandle, _Inout_ PUSBD_INTERFACE_LIST_ENTRY InterfaceEntry, _In_ ULONG OffloadedEndpoints, _Outptr_ PURB *Urb)
 
static NTSTATUS NTAPI UcxClientOffloadNotifyXrbAllocate (_In_ USBD_CLIENT_HANDLE ClientHandle, _In_ USBD_PIPE_HANDLE PipeHandle, _In_ ULONG Flags, _Outptr_ PURB *Urb)
 
static VOID NTAPI UcxFillClientInterface603 (_Inout_ UcxUsbdHandle *Handle, _Inout_ PUSBD_CLIENT_INTERFACE Interface)
 
NTSTATUS NTAPI UcxEvtQueryUsbdClientInterface (_In_ WDFDEVICE Device, _In_ LPGUID InterfaceType, _Inout_ PINTERFACE ExposedInterface, _Inout_opt_ PVOID ExposedInterfaceSpecificData)
 
 _IRQL_requires_ (PASSIVE_LEVEL) NTSTATUS UcxUsbdHandle
 Sends a synchronous IOCTL to the specified device object.
 
VOID NTAPI UcxDropLeakedUsbdHandles (_In_ UcxUsbDevice *Device)
 
BOOLEAN NTAPI UcxAnyUsbdHandleHasVerifier (_In_ UcxUsbDevice *Device)
 
static VOID NTAPI UcxDeleteXrbMemory (_In_ UcxXrbPreamble *Xrb)
 
static VOID NTAPI UcxFillInterfaceInformation (_Out_ PUSBD_INTERFACE_INFORMATION Info, _In_ PUSB_INTERFACE_DESCRIPTOR Descriptor, _In_ ULONG Pipes)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 10 of file clientif.cpp.

◆ UCX_EHCI_OPTION_FLAGS

#define UCX_EHCI_OPTION_FLAGS   0x00080A95

Definition at line 21 of file clientif.cpp.

◆ UCX_FAKE_TOTAL_BANDWIDTH

#define UCX_FAKE_TOTAL_BANDWIDTH   4000000

Definition at line 17 of file clientif.cpp.

◆ UCX_MAX_SELECT_INTERFACES

#define UCX_MAX_SELECT_INTERFACES   255

Definition at line 14 of file clientif.cpp.

◆ UCX_MAX_SELECT_PIPES

#define UCX_MAX_SELECT_PIPES   32

Definition at line 13 of file clientif.cpp.

◆ UCX_UHCI_OPTION_FLAGS

#define UCX_UHCI_OPTION_FLAGS   0x000002C3

Definition at line 20 of file clientif.cpp.

Function Documentation

◆ _IRQL_requires_()

_IRQL_requires_ ( PASSIVE_LEVEL  )

Sends a synchronous IOCTL to the specified device object.

Parameters
[in]IoControlCodeThe IOCTL to send to the device.
[in]DeviceObjectPointer to the device object that will handle the IOCTL.
[in]InputBufferOptional pointer to a buffer containing input data for the IOCTL. When specified, the buffer should be at least of InputBufferLength size.
[in]InputBufferLengthSize in bytes, of the buffer pointed by InputBuffer.
[out]OutputBufferOptional pointer to a buffer that will receive output data from the IOCTL. When specified, the buffer should be at least of OutputBufferLength size.
[in]OutputBufferLengthSize in bytes, of the buffer pointed by OutputBuffer.
[in]FileObjectOptional pointer to a file object that may be necessary for the IOCTL.
Returns
An NTSTATUS code indicating success or failure of this function.
Note
Must be called at PASSIVE_LEVEL with all APCs enabled.

Definition at line 475 of file clientif.cpp.

481{
484 WDFMEMORY Memory;
487
488 PAGED_CODE();
489
490 if (Interface->Header.Size < sizeof(*Interface))
491 {
492 DPRINT1("USBD client interface size %u, expected at least %u\n",
493 Interface->Header.Size, (ULONG)sizeof(*Interface));
495 }
496
497 if (Interface->Header.Version < USBD_CLIENT_INTERFACE_VERSION)
498 {
499 DPRINT1("USBD client interface version %u is not supported\n", Interface->Header.Version);
501 }
502
503 if (Interface->DeviceObject == NULL || Interface->PoolTag == 0)
504 {
505 DPRINT1("USBD client registration with device object %p, tag 0x%lx\n",
506 Interface->DeviceObject, Interface->PoolTag);
508 }
509
511 Attributes.ParentObject = Device->m_Handle;
512
513 Status = WdfMemoryCreate(&Attributes, NonPagedPool, Interface->PoolTag, sizeof(*Handle), &Memory, &Buffer);
514 if (!NT_SUCCESS(Status))
515 {
516 DPRINT1("USBD handle allocation for device %p failed 0x%lx\n", Device, Status);
517 return Status;
518 }
519
520 /* The handle has to outlive the USB device it was registered against */
522
523 RtlZeroMemory(Buffer, sizeof(*Handle));
524 Handle = new (Buffer) UcxUsbdHandle();
525 Handle->m_ClientDeviceObject = Interface->DeviceObject;
526 Handle->m_PoolTag = Interface->PoolTag;
527 Handle->m_ContractVersion = Interface->ClientContractVersion;
528 Handle->m_ClientContext = Interface->ClientContext;
529 Handle->m_Device = Device;
530 Handle->m_Controller = Device->m_Controller;
531 Handle->m_Memory = Memory;
532 Handle->m_RootHub = RootHub;
533 Handle->m_RootHubPdo = RootHub->Pdo();
534 KeInitializeSpinLock(&Handle->m_XrbLock);
535 InitializeListHead(&Handle->m_XrbList);
536
537 if (Interface->VerifierEnabled != 0)
538 {
539 Handle->m_VerifierEnabled = TRUE;
540 Handle->m_VerifierFailRegistration = Interface->VerifierFailRegistration;
541 Handle->m_VerifierFailChainedMdl = Interface->VerifierFailChainedMdlSupport;
542 Handle->m_VerifierFailStaticStreamSupport = Interface->VerifierFailStaticStreamSupport;
543 Handle->m_VerifierStaticStreamCountOverride = Interface->VerifierStaticStreamCountOverride;
544 Handle->m_VerifierFailEnableStaticStreams = Interface->VerifierFailEnableStaticStreams;
545 }
546
547 Handle->m_TrackXrbs = Handle->m_VerifierEnabled || Device->m_Controller->m_DriverVerifierEnabled;
548
549 /* Not undone when the registration then fails */
550 if (Handle->m_VerifierEnabled)
551 Device->TrackStaleHandles();
552
553 if (UcxVerifierWantsFailure(Handle->m_VerifierFailRegistration))
554 {
555 DPRINT1("Verifier failed USBD client registration for device %p\n", Device);
558 return UcxRandomErrorStatus();
559 }
560
561 Interface->Header.Context = NULL;
562 Interface->Header.InterfaceReference = UcxInterfaceNoOp;
563 Interface->Header.InterfaceDereference = UcxInterfaceNoOp;
564 Interface->Handle = (USBD_CLIENT_HANDLE)Handle;
565 Interface->Unregister = UcxClientUnregister;
566 Interface->AllocUrb = UcxClientAllocUrb;
567 Interface->AllocIsochUrb = UcxClientAllocIsochUrb;
568 Interface->AllocSelectConfigUrb = UcxClientSelectConfigXrbBuild;
569 Interface->AllocSelectInterfaceUrb = UcxClientSelectInterfaceXrbBuild;
570 Interface->ReleaseUrb = UcxClientReleaseUrb;
571
573
574 ObReferenceObject(Handle->m_ClientDeviceObject);
575
576 {
577 SpinLockGuard Guard(&Device->m_UsbdHandleLock);
578
579 InsertTailList(&Device->m_UsbdHandleList, &Handle->m_DeviceLink);
580 }
581
582 InterlockedIncrement(&Device->m_Controller->m_UsbdInterfaceCount);
583 DPRINT("USBD client %p registered handle %p on device %p\n", Interface->DeviceObject, Handle, Device);
584 return STATUS_SUCCESS;
585}
#define PAGED_CODE()
#define InterlockedIncrement
Definition: armddk.h:53
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
Definition: bufpool.h:45
static NTSTATUS NTAPI UcxClientSelectConfigXrbBuild(_In_ USBD_CLIENT_HANDLE ClientHandle, _In_ PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor, _In_ PUSBD_INTERFACE_LIST_ENTRY InterfaceList, _Outptr_ PURB *UrbOut)
Definition: clientif.cpp:821
static NTSTATUS NTAPI UcxClientAllocUrb(_In_ USBD_CLIENT_HANDLE ClientHandle, _Outptr_ PURB *Urb)
Definition: clientif.cpp:737
static VOID NTAPI UcxClientReleaseUrb(_In_ PURB Urb)
Definition: clientif.cpp:965
static NTSTATUS NTAPI UcxClientAllocIsochUrb(_In_ USBD_CLIENT_HANDLE ClientHandle, _In_ ULONG NumberOfIsochPackets, _Outptr_ PURB *Urb)
Definition: clientif.cpp:773
static VOID NTAPI UcxClientUnregister(_In_ USBD_CLIENT_HANDLE ClientHandle)
Definition: clientif.cpp:1011
static NTSTATUS NTAPI UcxClientSelectInterfaceXrbBuild(_In_ USBD_CLIENT_HANDLE ClientHandle, _In_ USBD_CONFIGURATION_HANDLE ConfigurationHandle, _In_ PUSBD_INTERFACE_LIST_ENTRY InterfaceEntry, _Outptr_ PURB *UrbOut)
Definition: clientif.cpp:912
static VOID NTAPI UcxFillClientInterface603(_Inout_ UcxUsbdHandle *Handle, _Inout_ PUSBD_CLIENT_INTERFACE Interface)
Definition: clientif.cpp:422
#define STATUS_NOT_SUPPORTED
Definition: d3dkmdt.h:48
_In_ ULONG Attributes
Definition: dispmprt.h:1077
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define InsertTailList(ListHead, Entry)
#define NonPagedPool
Definition: env_spec_w32.h:307
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define KeInitializeSpinLock(sl)
Definition: env_spec_w32.h:604
ULONG Handle
Definition: gdb_input.c:15
Status
Definition: gdiplustypes.h:24
VOID NTAPI UcxInterfaceNoOp(_In_ PVOID Context)
_Must_inspect_result_ _In_ PUCXHUB_DEVICE_CREATE_INFO _Out_ UCXUSBDEVICE * Device
Definition: hubucx.h:258
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
#define DPRINT
Definition: sndvol32.h:73
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ UCXCONTROLLER _In_ PUCX_ROOTHUB_CONFIG _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ UCXROOTHUB * RootHub
Definition: ucxroothub.h:299
_In_ UCXUSBDEVICE _In_ ULONG Interface
Definition: ucxusbdevice.h:428
BOOLEAN NTAPI UcxVerifierWantsFailure(_In_ ULONG Setting)
Definition: ucxutil.cpp:71
NTSTATUS NTAPI UcxRandomErrorStatus(VOID)
Definition: ucxutil.cpp:93
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define USBD_CLIENT_INTERFACE_VERSION
Definition: usbdclient.h:18
WdfObjectDelete(String)
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_ _Strict_type_match_ POOL_TYPE _In_opt_ ULONG _In_ _Out_ WDFMEMORY * Memory
Definition: wdfmemory.h:169
FORCEINLINE VOID WDF_OBJECT_ATTRIBUTES_INIT(_Out_ PWDF_OBJECT_ATTRIBUTES Attributes)
Definition: wdfobject.h:147
#define WdfObjectReference(Handle)
Definition: wdfobject.h:803
#define WdfObjectDereference(Handle)
Definition: wdfobject.h:826
#define ObReferenceObject
Definition: obfuncs.h:204

◆ UcxAnyUsbdHandleHasVerifier()

BOOLEAN NTAPI UcxAnyUsbdHandleHasVerifier ( _In_ UcxUsbDevice *  Device)

TRUE when any client registered against the device runs with USB verifier.

Definition at line 646 of file clientif.cpp.

648{
650
651 for (Entry = Device->m_UsbdHandleList.Flink; Entry != &Device->m_UsbdHandleList; Entry = Entry->Flink)
652 {
653 if (CONTAINING_RECORD(Entry, UcxUsbdHandle, m_DeviceLink)->m_VerifierEnabled)
654 return TRUE;
655 }
656
657 return FALSE;
658}
PLIST_ENTRY Entry
Definition: devhcd.cpp:1262
#define FALSE
Definition: types.h:117
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

Referenced by UcxValidatePipeHandle().

◆ UcxBusEnumLogEntry()

static NTSTATUS USB_BUSIFFN UcxBusEnumLogEntry ( _In_ PVOID  Context,
_In_ ULONG  DriverTag,
_In_ ULONG  EnumTag,
_In_ ULONG  P1,
_In_ ULONG  P2 
)
static

Definition at line 168 of file clientif.cpp.

174{
176 UNREFERENCED_PARAMETER(DriverTag);
177 UNREFERENCED_PARAMETER(EnumTag);
180
181 return STATUS_SUCCESS;
182}
_In_ PIRP _In_ PIO_COMPLETION_ROUTINE _In_ PVOID Context
Definition: kse.h:81
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:329

Referenced by UcxEvtQueryUsbdiInterface().

◆ UcxBusGetUsbdiVersion()

static VOID USB_BUSIFFN UcxBusGetUsbdiVersion ( _In_ PVOID  Context,
_Out_opt_ PUSBD_VERSION_INFORMATION  VersionInformation,
_Out_opt_ PULONG  HcdCapabilities 
)
static

Definition at line 37 of file clientif.cpp.

41{
42 BOOLEAN Slow = UcxIsLowOrFullSpeed(UcxUsbDevice::FromHandle((UCXUSBDEVICE)Context));
43
44 if (HcdCapabilities != NULL)
45 *HcdCapabilities = 0;
46
47 if (VersionInformation != NULL)
48 {
49 VersionInformation->USBDI_Version = UCX_USBDI_VERSION;
50 VersionInformation->Supported_USB_Version = Slow ? 0x0110 : 0x0200;
51 }
52}
unsigned char BOOLEAN
Definition: actypes.h:127
static BOOLEAN NTAPI UcxIsLowOrFullSpeed(_In_ UcxUsbDevice *Device)
Definition: clientif.cpp:26
#define UCX_USBDI_VERSION
Definition: clientif.h:11

Referenced by UcxEvtQueryUsbdiInterface().

◆ UcxBusIsDeviceHighSpeed()

static BOOLEAN USB_BUSIFFN UcxBusIsDeviceHighSpeed ( _In_opt_ PVOID  Context)
static

Definition at line 156 of file clientif.cpp.

158{
159 if (Context == NULL)
160 return FALSE;
161
162 return !UcxIsLowOrFullSpeed(UcxUsbDevice::FromHandle((UCXUSBDEVICE)Context));
163}

Referenced by UcxEvtQueryUsbdiInterface().

◆ UcxBusQueryBusInformation()

static NTSTATUS USB_BUSIFFN UcxBusQueryBusInformation ( _In_ PVOID  Context,
_In_ ULONG  Level,
_Inout_ PVOID  Buffer,
_Out_ PULONG  BufferLength,
_Out_opt_ PULONG  ActualLength 
)
static

Definition at line 87 of file clientif.cpp.

93{
97 ULONG Needed;
98
99 /* An HCD that tracks bandwidth itself is not second guessed */
100 if (Controller->HcdGetBandwidthInformation() != NULL)
101 {
102 DPRINT1("Bus information query with HCD bandwidth tracking is not supported\n");
104 }
105
106 if (Level == 0)
107 {
108 if (ActualLength != NULL)
110
112 {
113 DPRINT("Bus information level 0 buffer too small, %lu bytes\n", *BufferLength);
115 }
116
119 ((PUSB_BUS_INFORMATION_LEVEL_0)Buffer)->ConsumedBandwidth = 0;
120 return STATUS_SUCCESS;
121 }
122
123 if (Level != 1)
124 {
125 DPRINT1("Bus information level %lu is not supported\n", Level);
127 }
128
129 WdfStringGetUnicodeString(Controller->m_HostControllerInterfaceName, &Name);
130
131 /* The WCHAR already inside the structure is not subtracted */
132 Needed = sizeof(USB_BUS_INFORMATION_LEVEL_1) + Name.Length;
133 if (ActualLength != NULL)
134 *ActualLength = Needed;
135
136 if (*BufferLength < Needed)
137 {
138 DPRINT("Bus information level 1 needs %lu bytes, got %lu\n", Needed, *BufferLength);
140 }
141
142 *BufferLength = Needed;
145 Level1->ConsumedBandwidth = 0;
146 Level1->ControllerNameLength = Name.Length;
147 RtlCopyMemory(Level1->ControllerNameUnicodeString, Name.Buffer, Name.Length);
148
149 return STATUS_SUCCESS;
150}
UcxController * m_Controller
Definition: devobj.h:216
static UcxUsbDevice * FromHandle(_In_ UCXUSBDEVICE Handle)
Definition: devobj.cpp:18
#define UCX_FAKE_TOTAL_BANDWIDTH
Definition: clientif.cpp:17
LPWSTR Name
Definition: desk.c:124
_In_ ULONG _In_ UCHAR Level
Definition: dispmprt.h:1329
if(dx< 0)
Definition: linetemp.h:194
WCHAR ControllerNameUnicodeString[1]
Definition: usbbusif.h:54
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
_Must_inspect_result_ _In_ WDFDEVICE _In_ PUCX_CONTROLLER_CONFIG _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ UCXCONTROLLER * Controller
struct _USB_BUS_INFORMATION_LEVEL_0 * PUSB_BUS_INFORMATION_LEVEL_0
struct _USB_BUS_INFORMATION_LEVEL_1 * PUSB_BUS_INFORMATION_LEVEL_1
struct _USB_BUS_INFORMATION_LEVEL_0 USB_BUS_INFORMATION_LEVEL_0
struct _USB_BUS_INFORMATION_LEVEL_1 USB_BUS_INFORMATION_LEVEL_1
ULONG ActualLength
Definition: userreq.cpp:702
WdfStringGetUnicodeString(Original, &Name)
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
Definition: wdfdevice.h:3777

Referenced by UcxEvtQueryUsbdiInterface().

◆ UcxBusQueryBusTime()

static NTSTATUS USB_BUSIFFN UcxBusQueryBusTime ( _In_ PVOID  Context,
_Out_opt_ PULONG  CurrentFrame 
)
static

Definition at line 57 of file clientif.cpp.

60{
61 if (CurrentFrame == NULL)
62 {
63 DPRINT1("QueryBusTime called without a frame pointer\n");
65 }
66
67 return UcxUsbDevice::FromHandle((UCXUSBDEVICE)Context)->m_Controller->GetCurrentFrameNumber(CurrentFrame);
68}
NTSTATUS GetCurrentFrameNumber(_Out_ PULONG FrameNumber)
Definition: hostctl.cpp:564

Referenced by UcxEvtQueryUsbdiInterface().

◆ UcxBusQueryBusTimeEx()

static NTSTATUS USB_BUSIFFN UcxBusQueryBusTimeEx ( _In_opt_ PVOID  Context,
_Out_opt_ PULONG  CurrentMicroFrame 
)
static

Definition at line 188 of file clientif.cpp.

191{
192 if (CurrentMicroFrame == NULL)
193 {
194 DPRINT1("QueryBusTimeEx called without a microframe pointer\n");
196 }
197
198 if (UcxIsLowOrFullSpeed(UcxUsbDevice::FromHandle((UCXUSBDEVICE)Context)))
199 {
200 DPRINT("QueryBusTimeEx is not supported for low or full speed device %p\n", Context);
202 }
203
204 *CurrentMicroFrame = 0;
205 return STATUS_SUCCESS;
206}

Referenced by UcxEvtQueryUsbdiInterface().

◆ UcxBusQueryControllerType()

static NTSTATUS USB_BUSIFFN UcxBusQueryControllerType ( _In_opt_ PVOID  Context,
_Out_opt_ PULONG  HcdiOptionFlags,
_Out_opt_ PUSHORT  PciVendorId,
_Out_opt_ PUSHORT  PciDeviceId,
_Out_opt_ PUCHAR  PciClass,
_Out_opt_ PUCHAR  PciSubClass,
_Out_opt_ PUCHAR  PciRevisionId,
_Out_opt_ PUCHAR  PciProgIf 
)
static

Answers as the USB 2.0 era controller a client of this speed would have seen.

Definition at line 212 of file clientif.cpp.

221{
223 const UCX_CONTROLLER_PCI_INFORMATION* Pci = &Device->m_Controller->m_Config.PciDeviceInfo;
225
226 if (HcdiOptionFlags != NULL)
227 *HcdiOptionFlags = Slow ? UCX_UHCI_OPTION_FLAGS : UCX_EHCI_OPTION_FLAGS;
228 if (PciVendorId != NULL)
229 *PciVendorId = (USHORT)Pci->VendorId;
230 if (PciDeviceId != NULL)
231 *PciDeviceId = (USHORT)Pci->DeviceId;
232 if (PciClass != NULL)
233 *PciClass = PCI_CLASS_SERIAL_BUS_CTLR;
234 if (PciSubClass != NULL)
235 *PciSubClass = PCI_SUBCLASS_SB_USB;
236 if (PciRevisionId != NULL)
237 *PciRevisionId = (UCHAR)Pci->RevisionId;
238 if (PciProgIf != NULL)
239 *PciProgIf = Slow ? 0x00 : 0x20;
240
241 return STATUS_SUCCESS;
242}
#define UCX_UHCI_OPTION_FLAGS
Definition: clientif.cpp:20
#define UCX_EHCI_OPTION_FLAGS
Definition: clientif.cpp:21
unsigned short USHORT
Definition: pedump.c:61
unsigned char UCHAR
Definition: typedefs.h:53
#define PCI_SUBCLASS_SB_USB
Definition: iotypes.h:4223
#define PCI_CLASS_SERIAL_BUS_CTLR
Definition: iotypes.h:4130

Referenced by UcxEvtQueryUsbdiInterface().

◆ UcxBusSubmitIsoOutUrb()

static NTSTATUS USB_BUSIFFN UcxBusSubmitIsoOutUrb ( _In_ PVOID  Context,
_In_ PURB  Urb 
)
static

Definition at line 73 of file clientif.cpp.

76{
78
79 DPRINT1("SubmitIsoOutUrb is not supported, URB %p\n", Urb);
82}
_In_opt_ PUSB_CONFIGURATION_DESCRIPTOR _Inout_ PUSBD_INTERFACE_LIST_ENTRY _Outptr_ PURB * Urb
Definition: usbdlib.h:333
#define NT_ASSERT
Definition: rtlfuncs.h:3334

Referenced by UcxEvtQueryUsbdiInterface().

◆ UcxClientAllocIsochUrb()

static NTSTATUS NTAPI UcxClientAllocIsochUrb ( _In_ USBD_CLIENT_HANDLE  ClientHandle,
_In_ ULONG  NumberOfIsochPackets,
_Outptr_ PURB *  Urb 
)
static

Definition at line 773 of file clientif.cpp.

777{
779 UcxXrbPreamble* Xrb;
781
782 *Urb = NULL;
783
786 &Xrb);
787 if (!NT_SUCCESS(Status))
788 return Status;
789
790 Handle->TrackXrb(Xrb);
791 *Urb = UcxUrbFromXrb(Xrb);
792 return STATUS_SUCCESS;
793}
static UcxUsbdHandle * FromClientHandle(_In_ USBD_CLIENT_HANDLE Handle)
Definition: clientif.h:30
FORCEINLINE PURB NTAPI UcxUrbFromXrb(_In_ UcxXrbPreamble *Xrb)
Definition: clientxrb.h:69
#define UCX_XRB_KIND_ISO_PACKETS
Definition: clientxrb.h:16
#define GET_ISO_URB_SIZE(n)
Definition: usbdlib.h:152
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_ ULONG NumberOfIsochPackets
Definition: wdfusb.h:1703

Referenced by _IRQL_requires_(), and UcxFillClientInterface603().

◆ UcxClientAllocUrb()

static NTSTATUS NTAPI UcxClientAllocUrb ( _In_ USBD_CLIENT_HANDLE  ClientHandle,
_Outptr_ PURB *  Urb 
)
static

Definition at line 737 of file clientif.cpp.

740{
743 UcxXrbPreamble* Xrb;
745
746 *Urb = NULL;
747
748 Status = Handle->AllocateXrb(sizeof(UcxXrbPreamble) + sizeof(URB), UCX_XRB_KIND_PLAIN, &Xrb);
749 if (!NT_SUCCESS(Status))
750 return Status;
751
752 /* Carries the HCD's request context like every other request it gets */
753 RequestAttributes = Handle->m_RootHub->m_Config.WdfRequestAttributes;
754 RequestAttributes.ParentObject = Handle->m_RootHubPdo;
755
756 Status = WdfRequestCreate(&RequestAttributes, NULL, &Xrb->Request);
757 if (!NT_SUCCESS(Status))
758 {
759 DPRINT1("XRB request creation for handle %p failed 0x%lx\n", Handle, Status);
761 return Status;
762 }
763
764 Handle->TrackXrb(Xrb);
765 *Urb = UcxUrbFromXrb(Xrb);
766 return STATUS_SUCCESS;
767}
static VOID NTAPI UcxDeleteXrbMemory(_In_ UcxXrbPreamble *Xrb)
Definition: clientif.cpp:707
#define UCX_XRB_KIND_PLAIN
Definition: clientxrb.h:13
WDFREQUEST Request
Definition: clientxrb.h:41
Definition: usb.h:565
_In_ PWDFDEVICE_INIT _In_ PWDF_OBJECT_ATTRIBUTES RequestAttributes
Definition: wdfdevice.h:3437

Referenced by _IRQL_requires_().

◆ UcxClientOffloadNotifyXrbAllocate()

static NTSTATUS NTAPI UcxClientOffloadNotifyXrbAllocate ( _In_ USBD_CLIENT_HANDLE  ClientHandle,
_In_ USBD_PIPE_HANDLE  PipeHandle,
_In_ ULONG  Flags,
_Outptr_ PURB *  Urb 
)
static

Definition at line 404 of file clientif.cpp.

409{
410 UNREFERENCED_PARAMETER(ClientHandle);
411 UNREFERENCED_PARAMETER(PipeHandle);
413
414 *Urb = NULL;
416}
_In_ D3DDDI_VIDEO_PRESENT_TARGET_ID _In_ ULONG _In_ ULONG Flags
Definition: dispmprt.h:245

Referenced by UcxFillClientInterface603().

◆ UcxClientOffloadSelectXrbAllocate()

static NTSTATUS NTAPI UcxClientOffloadSelectXrbAllocate ( _In_ USBD_CLIENT_HANDLE  ClientHandle,
_In_ USBD_CONFIGURATION_HANDLE  ConfigurationHandle,
_Inout_ PUSBD_INTERFACE_LIST_ENTRY  InterfaceEntry,
_In_ ULONG  OffloadedEndpoints,
_Outptr_ PURB *  Urb 
)
static

Definition at line 384 of file clientif.cpp.

390{
391 UNREFERENCED_PARAMETER(ClientHandle);
393 UNREFERENCED_PARAMETER(InterfaceEntry);
394 UNREFERENCED_PARAMETER(OffloadedEndpoints);
395
396 /* No controller here offers endpoint offload */
397 *Urb = NULL;
399}
_Must_inspect_result_ _Out_ PNDIS_STATUS _Out_ PNDIS_HANDLE ConfigurationHandle
Definition: ndis.h:3945

Referenced by UcxFillClientInterface603().

◆ UcxClientReleaseUrb()

static VOID NTAPI UcxClientReleaseUrb ( _In_ PURB  Urb)
static

Definition at line 965 of file clientif.cpp.

967{
970
971 if (Xrb->Signature != UCX_XRB_SIGNATURE)
972 {
973 DPRINT1("Freeing corrupted XRB for URB %p\n", Urb);
976 0,
977 (ULONG_PTR)Urb,
978 (ULONG_PTR)Handle->m_ClientDeviceObject);
979 }
980
981 if (Xrb->State != UCX_XRB_IDLE)
982 {
983 DPRINT1("Freeing URB %p while it is still active\n", Urb);
986 0,
987 (ULONG_PTR)Urb,
988 (ULONG_PTR)Handle->m_ClientDeviceObject);
989 }
990
991 if (Handle->m_TrackXrbs)
992 {
993 SpinLockGuard Guard(&Handle->m_XrbLock);
994
997 }
998
999 if (Xrb->Request != NULL)
1000 {
1002 Xrb->Request = NULL;
1003 }
1004
1005 UcxDeleteXrbMemory(Xrb);
1006}
DECLSPEC_NORETURN VOID NTAPI KeBugCheckEx(IN ULONG BugCheckCode, IN ULONG_PTR BugCheckParameter1, IN ULONG_PTR BugCheckParameter2, IN ULONG_PTR BugCheckParameter3, IN ULONG_PTR BugCheckParameter4)
Definition: debug.c:485
#define UCX_XRB_SIGNATURE
Definition: clientxrb.h:11
FORCEINLINE UcxXrbPreamble *NTAPI UcxXrbFromUrb(_In_ PURB Urb)
Definition: clientxrb.h:60
#define UCX_USB3_ACTIVE_URB_REUSED
Definition: clientxrb.h:23
#define UCX_BUGCHECK_USB3
Definition: clientxrb.h:22
#define UCX_USB3_XRB_CORRUPTED
Definition: clientxrb.h:24
#define UCX_XRB_IDLE
Definition: clientxrb.h:18
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
ULONG Signature
Definition: clientxrb.h:47
LIST_ENTRY TrackingLink
Definition: clientxrb.h:42
UcxUsbdHandle * Handle
Definition: clientxrb.h:39
uint32_t ULONG_PTR
Definition: typedefs.h:65
FORCEINLINE VOID NTAPI UcxClearListEntry(_Out_ PLIST_ENTRY Entry)
Definition: ucxutil.h:84

Referenced by _IRQL_requires_().

◆ UcxClientSelectConfigXrbBuild()

static NTSTATUS NTAPI UcxClientSelectConfigXrbBuild ( _In_ USBD_CLIENT_HANDLE  ClientHandle,
_In_ PUSB_CONFIGURATION_DESCRIPTOR  ConfigurationDescriptor,
_In_ PUSBD_INTERFACE_LIST_ENTRY  InterfaceList,
_Outptr_ PURB *  UrbOut 
)
static

Definition at line 821 of file clientif.cpp.

826{
828 BOOLEAN Strict = Handle->m_ContractVersion >= USBD_CLIENT_CONTRACT_VERSION_602;
831 UcxXrbPreamble* Xrb;
832 PUCHAR End;
833 ULONG Interfaces = 0;
834 ULONG Pipes = 0;
835 USHORT Size;
836 PURB Urb;
838
839 *UrbOut = NULL;
840
841 /* Sizes add up in 16 bits, as the structure lengths are 16 bit */
842 Size = (USHORT)(sizeof(UcxXrbPreamble) + sizeof(struct _URB_SELECT_CONFIGURATION) -
844
845 for (Entry = InterfaceList; Entry->InterfaceDescriptor != NULL; Entry++)
846 {
847 Pipes += Entry->InterfaceDescriptor->bNumEndpoints;
848 if (Pipes > UCX_MAX_SELECT_PIPES)
849 {
850 DPRINT1("Select config for handle %p has too many pipes\n", Handle);
852 }
853
854 if (Strict && Entry->Interface != NULL)
855 {
856 DPRINT1("Select config entry %p for handle %p already has an interface\n", Entry, Handle);
858 }
859
860 Size += (USHORT)GET_USBD_INTERFACE_SIZE(Entry->InterfaceDescriptor->bNumEndpoints);
861
862 if (Interfaces++ > UCX_MAX_SELECT_INTERFACES)
863 {
864 DPRINT1("Select config for handle %p has too many interfaces\n", Handle);
866 }
867 }
868
869 if (Strict && Entry->Interface != NULL)
870 {
871 DPRINT1("Select config list end %p for handle %p has an interface\n", Entry, Handle);
873 }
874
875 Status = Handle->AllocateXrb(Size, UCX_XRB_KIND_CONFIG, &Xrb);
876 if (!NT_SUCCESS(Status))
877 return Status;
878
879 Urb = UcxUrbFromXrb(Xrb);
880 End = (PUCHAR)Xrb + Size;
881 Info = &Urb->UrbSelectConfiguration.Interface;
882
883 for (Entry = InterfaceList; Entry->InterfaceDescriptor != NULL; Entry++)
884 {
885 /* The descriptor may have changed since it was sized */
886 ULONG EntryPipes = Entry->InterfaceDescriptor->bNumEndpoints;
887
888 if ((PUCHAR)Info + GET_USBD_INTERFACE_SIZE(EntryPipes) > End)
889 {
890 DPRINT1("Interface descriptor %p grew while building select config\n", Entry->InterfaceDescriptor);
893 }
894
895 UcxFillInterfaceInformation(Info, Entry->InterfaceDescriptor, EntryPipes);
896 Entry->Interface = Info;
898 }
899
900 Urb->UrbHeader.Length = (USHORT)(Size - sizeof(UcxXrbPreamble));
901 Urb->UrbHeader.Function = URB_FUNCTION_SELECT_CONFIGURATION;
902 Urb->UrbSelectConfiguration.ConfigurationDescriptor = ConfigurationDescriptor;
903
904 Handle->TrackXrb(Xrb);
905 *UrbOut = Urb;
906 return STATUS_SUCCESS;
907}
#define UCX_MAX_SELECT_INTERFACES
Definition: clientif.cpp:14
#define UCX_MAX_SELECT_PIPES
Definition: clientif.cpp:13
static VOID NTAPI UcxFillInterfaceInformation(_Out_ PUSBD_INTERFACE_INFORMATION Info, _In_ PUSB_INTERFACE_DESCRIPTOR Descriptor, _In_ ULONG Pipes)
Definition: clientif.cpp:799
#define UCX_XRB_KIND_CONFIG
Definition: clientxrb.h:14
PUCHAR End
Definition: desccheck.cpp:2229
Definition: usbdlib.h:7
unsigned char * PUCHAR
Definition: typedefs.h:53
struct _USBD_INTERFACE_INFORMATION * PUSBD_INTERFACE_INFORMATION
#define URB_FUNCTION_SELECT_CONFIGURATION
Definition: usb.h:86
_In_opt_ PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor
Definition: usbdlib.h:331
#define GET_USBD_INTERFACE_SIZE(numEndpoints)
Definition: usbdlib.h:148
#define USBD_CLIENT_CONTRACT_VERSION_602
Definition: usbdlib.h:100
_In_ PUSBD_INTERFACE_LIST_ENTRY InterfaceList
Definition: usbdlib.h:208
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:690
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4539
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList

Referenced by _IRQL_requires_().

◆ UcxClientSelectInterfaceXrbBuild()

static NTSTATUS NTAPI UcxClientSelectInterfaceXrbBuild ( _In_ USBD_CLIENT_HANDLE  ClientHandle,
_In_ USBD_CONFIGURATION_HANDLE  ConfigurationHandle,
_In_ PUSBD_INTERFACE_LIST_ENTRY  InterfaceEntry,
_Outptr_ PURB *  UrbOut 
)
static

Definition at line 912 of file clientif.cpp.

917{
920 UcxXrbPreamble* Xrb;
921 ULONG Pipes;
922 USHORT Size;
923 PURB Urb;
925
926 *UrbOut = NULL;
927
928 if (InterfaceEntry->InterfaceDescriptor == NULL || InterfaceEntry->Interface != NULL)
929 {
930 DPRINT1("Select interface entry %p for handle %p is malformed\n", InterfaceEntry, Handle);
932 }
933
934 Pipes = InterfaceEntry->InterfaceDescriptor->bNumEndpoints;
935 if (Pipes > UCX_MAX_SELECT_PIPES)
936 {
937 DPRINT1("Select interface for handle %p has %lu pipes\n", Handle, Pipes);
939 }
940
941 /* With no pipes this is shorter than the URB structure, like the public macro */
943
944 Status = Handle->AllocateXrb(Size, UCX_XRB_KIND_ALT_SETTING, &Xrb);
945 if (!NT_SUCCESS(Status))
946 return Status;
947
948 Urb = UcxUrbFromXrb(Xrb);
949 Info = &Urb->UrbSelectInterface.Interface;
950 UcxFillInterfaceInformation(Info, InterfaceEntry->InterfaceDescriptor, Pipes);
951 InterfaceEntry->Interface = Info;
952
953 Urb->UrbHeader.Length = (USHORT)(Size - sizeof(UcxXrbPreamble));
954 Urb->UrbHeader.Function = URB_FUNCTION_SELECT_INTERFACE;
955 Urb->UrbSelectInterface.ConfigurationHandle = ConfigurationHandle;
956
957 Handle->TrackXrb(Xrb);
958 *UrbOut = Urb;
959 return STATUS_SUCCESS;
960}
#define UCX_XRB_KIND_ALT_SETTING
Definition: clientxrb.h:15
#define URB_FUNCTION_SELECT_INTERFACE
Definition: usb.h:87
#define GET_SELECT_INTERFACE_REQUEST_SIZE(totalPipes)
Definition: usbdlib.h:144

Referenced by _IRQL_requires_().

◆ UcxClientUnregister()

static VOID NTAPI UcxClientUnregister ( _In_ USBD_CLIENT_HANDLE  ClientHandle)
static

Definition at line 1011 of file clientif.cpp.

1013{
1015}
VOID Unregister()
Definition: clientif.cpp:589

Referenced by _IRQL_requires_().

◆ UcxDeleteXrbMemory()

static VOID NTAPI UcxDeleteXrbMemory ( _In_ UcxXrbPreamble *  Xrb)
static

Definition at line 707 of file clientif.cpp.

709{
710 WDFMEMORY Memory = Xrb->Memory;
711 UcxUsbdHandle* Handle = Xrb->Handle;
712 WDFMEMORY HandleMemory = Handle->m_Memory;
713
714 /* After unregister KMDF already deleted it along with the handle storage */
715 if (!Handle->m_Unregistered)
717
719 WdfObjectDereference(HandleMemory);
720}

Referenced by UcxClientAllocUrb(), UcxClientReleaseUrb(), and UcxClientSelectConfigXrbBuild().

◆ UcxDropLeakedUsbdHandles()

VOID NTAPI UcxDropLeakedUsbdHandles ( _In_ UcxUsbDevice *  Device)

At device delete: what clients failed to unregister.

Definition at line 615 of file clientif.cpp.

617{
618 BOOLEAN Verifying = Device->m_Controller->m_DriverVerifierEnabled;
621
622 SpinLockGuard Guard(&Device->m_UsbdHandleLock);
623
624 for (Entry = Device->m_UsbdHandleList.Flink; Entry != &Device->m_UsbdHandleList; Entry = Entry->Flink)
625 {
627
628 DPRINT1("USBD handle %p of client %p leaked on device %p\n", Handle, Handle->m_ClientDeviceObject, Device);
629
630 if (Verifying || Handle->m_VerifierEnabled)
631 {
635 (ULONG_PTR)Handle->m_ClientDeviceObject,
636 0);
637 }
638
639 ObDereferenceObject(Handle->m_ClientDeviceObject);
640 Handle->m_Orphaned = TRUE;
641 }
642}
#define UCX_USB3_HANDLE_LEAKED
Definition: clientxrb.h:29
#define ObDereferenceObject
Definition: obfuncs.h:203

Referenced by UcxUsbDevice::DeleteFromHub().

◆ UcxEvtQueryUsbdClientInterface()

NTSTATUS NTAPI UcxEvtQueryUsbdClientInterface ( _In_ WDFDEVICE  Device,
_In_ LPGUID  InterfaceType,
_Inout_ PINTERFACE  ExposedInterface,
_Inout_opt_ PVOID  ExposedInterfaceSpecificData 
)

Definition at line 457 of file clientif.cpp.

462{
463 UcxRootHub* RootHub = UcxGetRootHubPdoContext(Device)->RootHub;
465
467
469 ? UcxUsbDevice::FromHandle((UCXUSBDEVICE)ExposedInterfaceSpecificData)
470 : RootHub->Device();
471
472 return UcxUsbdHandle::CreateFromQuery(RootHub, UsbDevice, (PUSBD_CLIENT_INTERFACE)ExposedInterface);
473}
_In_ UCXUSBDEVICE UsbDevice
Definition: hostctl.h:31
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID InterfaceType
Definition: wdffdo.h:463
WDF_EXTERN_C_START typedef _In_ LPGUID _Inout_ PINTERFACE ExposedInterface
WDF_EXTERN_C_START typedef _In_ LPGUID _Inout_ PINTERFACE _Inout_opt_ PVOID ExposedInterfaceSpecificData

◆ UcxEvtQueryUsbdiInterface()

NTSTATUS NTAPI UcxEvtQueryUsbdiInterface ( _In_ WDFDEVICE  Device,
_In_ LPGUID  InterfaceType,
_Inout_ PINTERFACE  ExposedInterface,
_Inout_opt_ PVOID  ExposedInterfaceSpecificData 
)

The header always reports the last level that fit, even on failure.

Definition at line 247 of file clientif.cpp.

252{
254 USHORT RequestedSize = ExposedInterface->Size;
255 USHORT RequestedVersion = ExposedInterface->Version;
256 USHORT FilledSize = 0;
257 USHORT FilledVersion = 0;
259 UCXUSBDEVICE BusContext;
260
262
263 /* A query without one is for the root hub itself */
265 ? (UCXUSBDEVICE)ExposedInterfaceSpecificData
266 : (UCXUSBDEVICE)UcxGetRootHubPdoContext(Device)->RootHub->m_Handle;
267
268 if (RequestedSize < sizeof(USB_BUS_INTERFACE_USBDI_V0))
269 {
271 }
272 else
273 {
274 Bus->BusContext = BusContext;
281 FilledSize = sizeof(USB_BUS_INTERFACE_USBDI_V0);
282 FilledVersion = USB_BUSIF_USBDI_VERSION_0;
283
284 if (RequestedVersion >= USB_BUSIF_USBDI_VERSION_1)
285 {
286 if (RequestedSize < sizeof(USB_BUS_INTERFACE_USBDI_V1))
288 else
289 {
291 FilledSize = sizeof(USB_BUS_INTERFACE_USBDI_V1);
292 FilledVersion = USB_BUSIF_USBDI_VERSION_1;
293 }
294 }
295
296 if (NT_SUCCESS(Status) && RequestedVersion >= USB_BUSIF_USBDI_VERSION_2)
297 {
298 if (RequestedSize < sizeof(USB_BUS_INTERFACE_USBDI_V2))
300 else
301 {
303 FilledSize = sizeof(USB_BUS_INTERFACE_USBDI_V2);
304 FilledVersion = USB_BUSIF_USBDI_VERSION_2;
305 }
306 }
307
308 /* Anything newer is served as version 3 */
309 if (NT_SUCCESS(Status) && RequestedVersion >= USB_BUSIF_USBDI_VERSION_3)
310 {
311 if (RequestedSize < sizeof(USB_BUS_INTERFACE_USBDI_V3))
313 else
314 {
317 FilledSize = sizeof(USB_BUS_INTERFACE_USBDI_V3);
318 FilledVersion = USB_BUSIF_USBDI_VERSION_3;
319 }
320 }
321 }
322
323 if (!NT_SUCCESS(Status))
324 {
325 DPRINT1("USBDI interface query size %u version %u failed 0x%lx, served version %u\n",
326 RequestedSize, RequestedVersion, Status, FilledVersion);
327 }
328
329 ExposedInterface->Size = FilledSize;
330 ExposedInterface->Version = FilledVersion;
331 return Status;
332}
static NTSTATUS USB_BUSIFFN UcxBusEnumLogEntry(_In_ PVOID Context, _In_ ULONG DriverTag, _In_ ULONG EnumTag, _In_ ULONG P1, _In_ ULONG P2)
Definition: clientif.cpp:168
static NTSTATUS USB_BUSIFFN UcxBusQueryBusInformation(_In_ PVOID Context, _In_ ULONG Level, _Inout_ PVOID Buffer, _Out_ PULONG BufferLength, _Out_opt_ PULONG ActualLength)
Definition: clientif.cpp:87
static NTSTATUS USB_BUSIFFN UcxBusQueryBusTimeEx(_In_opt_ PVOID Context, _Out_opt_ PULONG CurrentMicroFrame)
Definition: clientif.cpp:188
static VOID USB_BUSIFFN UcxBusGetUsbdiVersion(_In_ PVOID Context, _Out_opt_ PUSBD_VERSION_INFORMATION VersionInformation, _Out_opt_ PULONG HcdCapabilities)
Definition: clientif.cpp:37
static NTSTATUS USB_BUSIFFN UcxBusQueryControllerType(_In_opt_ PVOID Context, _Out_opt_ PULONG HcdiOptionFlags, _Out_opt_ PUSHORT PciVendorId, _Out_opt_ PUSHORT PciDeviceId, _Out_opt_ PUCHAR PciClass, _Out_opt_ PUCHAR PciSubClass, _Out_opt_ PUCHAR PciRevisionId, _Out_opt_ PUCHAR PciProgIf)
Definition: clientif.cpp:212
static NTSTATUS USB_BUSIFFN UcxBusSubmitIsoOutUrb(_In_ PVOID Context, _In_ PURB Urb)
Definition: clientif.cpp:73
static NTSTATUS USB_BUSIFFN UcxBusQueryBusTime(_In_ PVOID Context, _Out_opt_ PULONG CurrentFrame)
Definition: clientif.cpp:57
static BOOLEAN USB_BUSIFFN UcxBusIsDeviceHighSpeed(_In_opt_ PVOID Context)
Definition: clientif.cpp:156
_In_ PVOID BusContext
Definition: devhcd.cpp:1395
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
PINTERFACE_REFERENCE InterfaceReference
Definition: usbbusif.h:148
PUSB_BUSIFFN_SUBMIT_ISO_OUT_URB SubmitIsoOutUrb
Definition: usbbusif.h:152
PUSB_BUSIFFN_QUERY_CONTROLLER_TYPE QueryControllerType
Definition: usbbusif.h:157
PUSB_BUSIFFN_QUERY_BUS_TIME QueryBusTime
Definition: usbbusif.h:151
PINTERFACE_DEREFERENCE InterfaceDereference
Definition: usbbusif.h:149
PUSB_BUSIFFN_GETUSBDI_VERSION GetUSBDIVersion
Definition: usbbusif.h:150
PUSB_BUSIFFN_IS_DEVICE_HIGH_SPEED IsDeviceHighSpeed
Definition: usbbusif.h:154
PUSB_BUSIFFN_QUERY_BUS_TIME_EX QueryBusTimeEx
Definition: usbbusif.h:156
PUSB_BUSIFFN_QUERY_BUS_INFORMATION QueryBusInformation
Definition: usbbusif.h:153
PUSB_BUSIFFN_ENUM_LOG_ENTRY EnumLogEntry
Definition: usbbusif.h:155
struct _USB_BUS_INTERFACE_USBDI_V3 * PUSB_BUS_INTERFACE_USBDI_V3
#define USB_BUSIF_USBDI_VERSION_1
Definition: usbbusif.h:74
struct _USB_BUS_INTERFACE_USBDI_V3 USB_BUS_INTERFACE_USBDI_V3
struct _USB_BUS_INTERFACE_USBDI_V1 USB_BUS_INTERFACE_USBDI_V1
#define USB_BUSIF_USBDI_VERSION_0
Definition: usbbusif.h:73
struct _USB_BUS_INTERFACE_USBDI_V0 USB_BUS_INTERFACE_USBDI_V0
#define USB_BUSIF_USBDI_VERSION_2
Definition: usbbusif.h:75
#define USB_BUSIF_USBDI_VERSION_3
Definition: usbbusif.h:76
struct _USB_BUS_INTERFACE_USBDI_V2 USB_BUS_INTERFACE_USBDI_V2

◆ UcxFillClientInterface603()

static VOID NTAPI UcxFillClientInterface603 ( _Inout_ UcxUsbdHandle *  Handle,
_Inout_ PUSBD_CLIENT_INTERFACE  Interface 
)
static

Answers the parts of a version 0x603 request that fit in its size, and reports what was filled.

Definition at line 422 of file clientif.cpp.

425{
427 USHORT Size = sizeof(*Interface);
429
430 if (Interface->Header.Version >= USBD_CLIENT_INTERFACE_VERSION_603 &&
432 {
434 if (Handle->m_VerifierEnabled)
435 Handle->m_VerifierFailSecureTransfer = Extended->VerifierFailSecureTransferSupport;
436
439
440 if (Interface->Header.Size >= sizeof(*Extended))
441 {
444 if (Handle->m_VerifierEnabled)
445 Handle->m_VerifierFailEndpointOffload = Extended->VerifierFailEndpointOffload;
446
447 Size = sizeof(*Extended);
448 }
449 }
450
451 Interface->Header.Size = Size;
452 Interface->Header.Version = Version;
453}
static NTSTATUS NTAPI UcxClientOffloadSelectXrbAllocate(_In_ USBD_CLIENT_HANDLE ClientHandle, _In_ USBD_CONFIGURATION_HANDLE ConfigurationHandle, _Inout_ PUSBD_INTERFACE_LIST_ENTRY InterfaceEntry, _In_ ULONG OffloadedEndpoints, _Outptr_ PURB *Urb)
Definition: clientif.cpp:384
static NTSTATUS NTAPI UcxClientOffloadNotifyXrbAllocate(_In_ USBD_CLIENT_HANDLE ClientHandle, _In_ USBD_PIPE_HANDLE PipeHandle, _In_ ULONG Flags, _Outptr_ PURB *Urb)
Definition: clientif.cpp:404
PFN_USBD_CLIENT_OFFLOAD_SELECT_XRB_ALLOCATE OffloadSelectInterfaceXrbAllocate
Definition: usbdclient.h:130
PFN_USBD_CLIENT_OFFLOAD_NOTIFY_XRB_ALLOCATE OffloadNotificationXrbAllocate
Definition: usbdclient.h:132
PFN_USBD_CLIENT_ISOCH_XRB_ALLOCATE SecureIsochXrbAllocate
Definition: usbdclient.h:126
#define USBD_CLIENT_INTERFACE_VERSION_603
Definition: usbdclient.h:100
struct _USBD_CLIENT_INTERFACE_603 * PUSBD_CLIENT_INTERFACE_603
#define USBD_CLIENT_INTERFACE_603_SIZE_SECURE
Definition: usbdclient.h:136
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE _In_ USHORT _In_ USHORT Version
Definition: wdffdo.h:469

Referenced by _IRQL_requires_().

◆ UcxFillInterfaceInformation()

static VOID NTAPI UcxFillInterfaceInformation ( _Out_ PUSBD_INTERFACE_INFORMATION  Info,
_In_ PUSB_INTERFACE_DESCRIPTOR  Descriptor,
_In_ ULONG  Pipes 
)
static

Lays out one interface information block for a select request.

Definition at line 799 of file clientif.cpp.

803{
804 ULONG Index;
805
806 Info->InterfaceNumber = Descriptor->bInterfaceNumber;
807 Info->AlternateSetting = Descriptor->bAlternateSetting;
808 Info->NumberOfPipes = Pipes;
809 Info->Length = (USHORT)GET_USBD_INTERFACE_SIZE(Pipes);
810
811 for (Index = 0; Index < Pipes; Index++)
812 {
813 Info->Pipes[Index].MaximumTransferSize = MAXULONG;
814 Info->Pipes[Index].PipeFlags = 0;
815 }
816}
#define MAXULONG
Definition: typedefs.h:251
_In_ WDFCOLLECTION _In_ ULONG Index
_Must_inspect_result_ _In_ WDFIORESLIST _In_ PIO_RESOURCE_DESCRIPTOR Descriptor
Definition: wdfresource.h:342

Referenced by UcxClientSelectConfigXrbBuild(), and UcxClientSelectInterfaceXrbBuild().

◆ UcxIsLowOrFullSpeed()

static BOOLEAN NTAPI UcxIsLowOrFullSpeed ( _In_ UcxUsbDevice *  Device)
static

Definition at line 26 of file clientif.cpp.

28{
29 return Device->Speed() == UsbLowSpeed || Device->Speed() == UsbFullSpeed;
30}
@ UsbLowSpeed
Definition: usb200.h:42
@ UsbFullSpeed
Definition: usb200.h:43

Referenced by UcxBusGetUsbdiVersion(), UcxBusIsDeviceHighSpeed(), UcxBusQueryBusTimeEx(), and UcxBusQueryControllerType().