ReactOS 0.4.17-dev-1281-g065abb3
devconfig.cpp File Reference
#include "usbhub3.h"
#include "desccheck.h"
#include "devhcd.h"
#include <debug.h>
Include dependency graph for devconfig.cpp:

Go to the source code of this file.

Macros

#define NDEBUG
 
#define CLIENT_INTERVAL_CAP   6
 
#define BCD_USB_25   0x0250
 
#define COMPANION_LENGTH   6
 
#define SSP_COMPANION_LENGTH   8
 

Functions

static PURB NTAPI HubChildClientUrb (_In_ HubChild *Child)
 
static BOOLEAN NTAPI HubChildSettingFiltered (_In_ HubChild *Child, _In_ UCHAR InterfaceNumber, _In_ UCHAR AlternateSetting)
 
static VOID NTAPI HubChildFreeEndpointArrays (_In_ HubChild *Child)
 
static NTSTATUS NTAPI HubChildSizeEndpointArrays (_In_ HubChild *Child, _In_ ULONG Count)
 
VOID NTAPI HubChildCollectForDisable (_In_ HubChild *Child, _In_ HubInterface *Interface)
 
static NTSTATUS NTAPI HubAllocateConfiguration (_In_ PUSB_CONFIGURATION_DESCRIPTOR Source, _Out_ HubConfiguration **Result)
 
static NTSTATUS NTAPI HubAllocateInterface (_In_ PUSB_INTERFACE_DESCRIPTOR Descriptor, _In_ BOOLEAN HasAlternates, _Out_ HubInterface **Result)
 
static VOID NTAPI HubFreeConfiguration (_In_ HubChild *Child, _In_ HubConfiguration *Config)
 
FORCEINLINE BOOLEAN NTAPI HubTypeFits (_In_ PUCHAR Walk, _In_ PUCHAR End)
 
static VOID NTAPI HubPickCompanions (_In_ HubPipe *Pipe, _Inout_ PUSBD_PIPE_INFORMATION Client, _In_ PUCHAR Walk, _In_ PUCHAR End)
 
static NTSTATUS NTAPI HubChildInitPipes (_In_ HubChild *Child, _Inout_ PUSBD_INTERFACE_INFORMATION Info, _Inout_ HubInterface *Interface, _In_ PUCHAR Walk, _In_ PUCHAR End)
 
static BOOLEAN NTAPI HubInterfaceHasEndpointZero (_In_ HubInterface *Interface)
 
static BOOLEAN NTAPI HubConfigHasEndpointZero (_In_ HubConfiguration *Config)
 
static NTSTATUS NTAPI HubConfigCheckDuplicates (_In_ HubConfiguration *Config)
 
static NTSTATUS NTAPI HubInterfacesShareEndpoints (_In_ HubInterface *First, _In_ HubInterface *Second)
 
static VOID NTAPI HubChildRecordFailure (_In_ HubChild *Child, _In_ NTSTATUS Status)
 
static USBD_PIPE_HANDLE NTAPI HubChildExposePipe (_In_ HubChild *Child, _Inout_ HubPipe *Pipe)
 

Macro Definition Documentation

◆ BCD_USB_25

#define BCD_USB_25   0x0250

Definition at line 19 of file devconfig.cpp.

◆ CLIENT_INTERVAL_CAP

#define CLIENT_INTERVAL_CAP   6

Definition at line 16 of file devconfig.cpp.

◆ COMPANION_LENGTH

#define COMPANION_LENGTH   6

Definition at line 22 of file devconfig.cpp.

◆ NDEBUG

#define NDEBUG

Definition at line 12 of file devconfig.cpp.

◆ SSP_COMPANION_LENGTH

#define SSP_COMPANION_LENGTH   8

Definition at line 23 of file devconfig.cpp.

Function Documentation

◆ HubAllocateConfiguration()

static NTSTATUS NTAPI HubAllocateConfiguration ( _In_ PUSB_CONFIGURATION_DESCRIPTOR  Source,
_Out_ HubConfiguration **  Result 
)
static

Definition at line 170 of file devconfig.cpp.

173{
175 WDFMEMORY Memory;
176 ULONG Size;
178
180 Size = max(Size, (ULONG)sizeof(*Config));
181
182 Status = WdfMemoryCreate(WDF_NO_OBJECT_ATTRIBUTES,
185 Size,
186 &Memory,
187 (PVOID*)&Config);
188 if (!NT_SUCCESS(Status))
189 {
190 DPRINT1("Configuration record of %lu bytes not allocated 0x%lx\n", Size, Status);
191 *Result = NULL;
192 return Status;
193 }
194
196 Config->Memory = Memory;
197 InitializeListHead(&Config->Interfaces);
198 RtlCopyMemory(&Config->Descriptor, Source, Source->wTotalLength);
199
200 *Result = Config;
201 return STATUS_SUCCESS;
202}
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define NonPagedPool
Definition: env_spec_w32.h:307
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
Status
Definition: gdiplustypes.h:24
#define HUB_TAG_DEVICE
Definition: hubutil.h:13
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3169
#define STATUS_SUCCESS
Definition: shellext.h:65
#define max(a, b)
Definition: svc.c:63
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFDEVICE _In_ PUCX_CONTROLLER_CONFIG Config
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4539
_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
_Must_inspect_result_ _In_ WDFIORESLIST _In_ PIO_RESOURCE_DESCRIPTOR Descriptor
Definition: wdfresource.h:342
#define WDF_NO_OBJECT_ATTRIBUTES
Definition: wdftypes.h:105
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409

Referenced by DeviceMachine::PrepareConfigLists().

◆ HubAllocateInterface()

static NTSTATUS NTAPI HubAllocateInterface ( _In_ PUSB_INTERFACE_DESCRIPTOR  Descriptor,
_In_ BOOLEAN  HasAlternates,
_Out_ HubInterface **  Result 
)
static

Definition at line 207 of file devconfig.cpp.

211{
213 WDFMEMORY Memory;
214 ULONG Size;
216
217 Size = FIELD_OFFSET(HubInterface, Pipes) + Descriptor->bNumEndpoints * sizeof(HubPipe);
218 Size = max(Size, (ULONG)sizeof(*Interface));
219
220 Status = WdfMemoryCreate(WDF_NO_OBJECT_ATTRIBUTES,
223 Size,
224 &Memory,
225 (PVOID*)&Interface);
226 if (!NT_SUCCESS(Status))
227 {
228 DPRINT1("Interface %u record not allocated 0x%lx\n", Descriptor->bInterfaceNumber, Status);
229 *Result = NULL;
230 return Status;
231 }
232
234 Interface->Memory = Memory;
235 Interface->Descriptor = Descriptor;
236 Interface->PipeCount = Descriptor->bNumEndpoints;
237 Interface->HasAlternateSettings = HasAlternates;
238 Interface->NeedsSetInterface = HasAlternates;
239
240 *Result = Interface;
241 return STATUS_SUCCESS;
242}
_In_ UCXUSBDEVICE _In_ ULONG Interface
Definition: ucxusbdevice.h:428

Referenced by DeviceMachine::PrepareConfigLists(), and DeviceMachine::PrepareInterfaceLists().

◆ HubChildClientUrb()

static PURB NTAPI HubChildClientUrb ( _In_ HubChild *  Child)
static

The client URB of the request the device machine is serving.

Definition at line 29 of file devconfig.cpp.

31{
33
35 WdfRequestGetParameters(Child->m_ClientRequest, &Params);
36 return (PURB)Params.Parameters.Others.Arg1;
37}
Definition: usb.h:565
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFDEVICE Child
Definition: wdffdo.h:536
_In_ WDFIOTARGET _In_ PWDF_REQUEST_COMPLETION_PARAMS Params
Definition: wdfrequest.h:308
FORCEINLINE VOID WDF_REQUEST_PARAMETERS_INIT(_Out_ PWDF_REQUEST_PARAMETERS Parameters)
Definition: wdfrequest.h:211

Referenced by DeviceMachine::PrepareConfigLists(), DeviceMachine::PrepareInterfaceLists(), DeviceMachine::SetConfigInfoInRequest(), and DeviceMachine::SetInterfaceInfoInRequest().

◆ HubChildCollectForDisable()

VOID NTAPI HubChildCollectForDisable ( _In_ HubChild *  Child,
_In_ HubInterface *  Interface 
)

Enabled pipes go to the disable list as PendingDisable, disabled ones stay unchanged.

Definition at line 132 of file devconfig.cpp.

135{
136 HubPipe* Pipe;
137 ULONG Index;
138
139 for (Index = 0; Index < Interface->PipeCount; Index++)
140 {
141 Pipe = &Interface->Pipes[Index];
142
143 switch (Pipe->State)
144 {
147 Child->m_EndpointsToDisable[Child->m_DisableCount++] = Pipe->Endpoint;
148 break;
149
151 Child->m_EndpointsUnchanged[Child->m_UnchangedCount++] = Pipe->Endpoint;
152 break;
153
155 break;
156
157 default:
158 DPRINT1("Device %p pipe %lu in unexpected state %u\n", Child, Index, (UCHAR)Pipe->State);
159 ASSERT(FALSE);
160 break;
161 }
162 }
163}
#define FALSE
Definition: types.h:117
#define ASSERT(a)
Definition: mode.c:44
unsigned char UCHAR
Definition: typedefs.h:53
_In_ WDFCOLLECTION _In_ ULONG Index
_In_ WDFUSBPIPE Pipe
Definition: wdfusb.h:1741

Referenced by DeviceMachine::DisableAllEndpoints(), DeviceMachine::DisableNewInterfaceEndpoints(), DeviceMachine::PrepareConfigLists(), and DeviceMachine::PrepareInterfaceLists().

◆ HubChildExposePipe()

static USBD_PIPE_HANDLE NTAPI HubChildExposePipe ( _In_ HubChild *  Child,
_Inout_ HubPipe *  Pipe 
)
static

Definition at line 923 of file devconfig.cpp.

926{
927 PUCXHUB_STACK_INTERFACE Stack = &Child->m_Hub->m_Stack;
928
929 Pipe->PipeHandle = Stack->EndpointGetPipeHandle(Pipe->Endpoint);
930 if (Pipe->PipeHandle == NULL)
931 DPRINT1("Endpoint 0x%x has no pipe handle\n", Pipe->Descriptor->bEndpointAddress);
932
933 Stack->MarkEndpointClientOwned(Pipe->Endpoint);
934 return Pipe->PipeHandle;
935}
PFN_UCXHUB_ENDPOINT_PIPE_HANDLE EndpointGetPipeHandle
Definition: hubucx.h:443
_In_ WDFREQUEST _In_ PIO_STACK_LOCATION Stack
Definition: wdfrequest.h:639

Referenced by DeviceMachine::SetConfigInfoInRequest(), and DeviceMachine::SetInterfaceInfoInRequest().

◆ HubChildFreeEndpointArrays()

static VOID NTAPI HubChildFreeEndpointArrays ( _In_ HubChild *  Child)
static

Definition at line 70 of file devconfig.cpp.

72{
73 UCXENDPOINT** Arrays[] = { &Child->m_EndpointsToEnable,
74 &Child->m_EndpointsUnchanged,
75 &Child->m_EndpointsToDisable };
77
78 Child->m_EndpointArrayCapacity = 0;
79
80 for (Index = 0; Index < RTL_NUMBER_OF(Arrays); Index++)
81 {
82 if (*Arrays[Index] != NULL)
83 {
85 *Arrays[Index] = NULL;
86 }
87 }
88}
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109

Referenced by HubChildSizeEndpointArrays().

◆ HubChildInitPipes()

static NTSTATUS NTAPI HubChildInitPipes ( _In_ HubChild *  Child,
_Inout_ PUSBD_INTERFACE_INFORMATION  Info,
_Inout_ HubInterface *  Interface,
_In_ PUCHAR  Walk,
_In_ PUCHAR  End 
)
static

Definition at line 328 of file devconfig.cpp.

334{
337 HubPipe* Pipe;
339 ULONG Index;
340
341 for (Index = 0; Index < Info->NumberOfPipes; Index++)
342 {
343 Client = &Info->Pipes[Index];
344 Pipe = &Interface->Pipes[Index];
345
346 if (Walk >= End)
347 {
348 DPRINT1("Device %p interface %u has fewer than %lu endpoint descriptors\n",
349 Child, Info->InterfaceNumber, Info->NumberOfPipes);
350 return STATUS_UNSUCCESSFUL;
351 }
352
353 Pipe->PipeFlags = Client->PipeFlags;
355
356 if (!HubTypeFits(Walk, End))
357 {
358 DPRINT1("Device %p interface %u descriptor runs past the configuration\n", Child, Info->InterfaceNumber);
359 return STATUS_UNSUCCESSFUL;
360 }
361
362 while (((PUSB_COMMON_DESCRIPTOR)Walk)->bDescriptorType != USB_ENDPOINT_DESCRIPTOR_TYPE)
363 {
364 if (Walk[0] == 0)
365 {
366 DPRINT1("Device %p interface %u has a zero length descriptor\n", Child, Info->InterfaceNumber);
367 return STATUS_UNSUCCESSFUL;
368 }
369
370 Walk += Walk[0];
371 if (!HubTypeFits(Walk, End))
372 {
373 DPRINT1("Device %p interface %u has fewer than %lu endpoint descriptors\n",
374 Child, Info->InterfaceNumber, Info->NumberOfPipes);
375 return STATUS_UNSUCCESSFUL;
376 }
377 }
378
379 if (Walk + sizeof(USB_ENDPOINT_DESCRIPTOR) > End)
380 {
381 DPRINT1("Device %p interface %u endpoint descriptor runs past the configuration\n",
382 Child, Info->InterfaceNumber);
383 return STATUS_UNSUCCESSFUL;
384 }
385
387
388 /* The cached copy is what UCX sees, so the override goes there */
389 if (Pipe->PipeFlags & USBD_PF_CHANGE_MAX_PACKET)
390 Endpoint->wMaxPacketSize = Client->MaximumPacketSize;
391
392 Pipe->Descriptor = Endpoint;
393 Pipe->BytesToEnd = (ULONG)(End - Walk);
394
395 Packet = Endpoint->wMaxPacketSize;
396 if (Child->m_DeviceDescriptor.bcdUSB < BCD_USB_25)
397 Packet = (USHORT)((Packet & 0x7FF) * (((Packet >> 11) & 3) + 1));
398
399 Client->MaximumPacketSize = Packet;
400 Client->Interval = min(Endpoint->bInterval, CLIENT_INTERVAL_CAP);
401 Client->EndpointAddress = Endpoint->bEndpointAddress;
402 Client->PipeType = (USBD_PIPE_TYPE)(Endpoint->bmAttributes & USB_ENDPOINT_TYPE_MASK);
403
404 if (Client->MaximumPacketSize == 0)
405 Pipe->ZeroBandwidth = TRUE;
406
407 if (Endpoint->bLength == 0)
408 {
409 DPRINT1("Device %p endpoint 0x%x has a zero length\n", Child, Endpoint->bEndpointAddress);
410 return STATUS_UNSUCCESSFUL;
411 }
412
413 Walk += Endpoint->bLength;
415 }
416
417 return STATUS_SUCCESS;
418}
PUCHAR End
Definition: desccheck.cpp:2229
BosWalk Walk
Definition: desccheck.cpp:2225
#define BCD_USB_25
Definition: devconfig.cpp:19
FORCEINLINE BOOLEAN NTAPI HubTypeFits(_In_ PUCHAR Walk, _In_ PUCHAR End)
Definition: devconfig.cpp:269
#define CLIENT_INTERVAL_CAP
Definition: devconfig.cpp:16
static VOID NTAPI HubPickCompanions(_In_ HubPipe *Pipe, _Inout_ PUSBD_PIPE_INFORMATION Client, _In_ PUCHAR Walk, _In_ PUCHAR End)
Definition: devconfig.cpp:280
#define TRUE
Definition: types.h:120
_In_ UCXHUB_DEVICE_CONTEXT _In_ UCXENDPOINT Endpoint
Definition: hubucx.h:238
#define min(a, b)
Definition: monoChain.cc:55
_In_ NDIS_HANDLE _In_ PNDIS_PACKET Packet
Definition: ndis.h:1549
unsigned short USHORT
Definition: pedump.c:61
Definition: client.c:31
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define USB_ENDPOINT_DESCRIPTOR_TYPE
Definition: usb100.h:53
struct _USB_ENDPOINT_DESCRIPTOR * PUSB_ENDPOINT_DESCRIPTOR
#define USB_ENDPOINT_TYPE_MASK
Definition: usb100.h:61
enum _USBD_PIPE_TYPE USBD_PIPE_TYPE
#define USBD_PF_CHANGE_MAX_PACKET
Definition: usb.h:281
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:690

Referenced by DeviceMachine::PrepareConfigLists(), and DeviceMachine::PrepareInterfaceLists().

◆ HubChildRecordFailure()

static VOID NTAPI HubChildRecordFailure ( _In_ HubChild *  Child,
_In_ NTSTATUS  Status 
)
static

Definition at line 544 of file devconfig.cpp.

547{
548 Child->m_LastNtStatus = Status;
549 if (Child->m_LastUsbdStatus == 0)
550 Child->m_LastUsbdStatus = HubNtStatusToUsbd(Status);
551}
USBD_STATUS NTAPI HubNtStatusToUsbd(_In_ NTSTATUS Status)
Definition: childpdo.cpp:190

Referenced by DeviceMachine::PrepareConfigLists(), and DeviceMachine::PrepareInterfaceLists().

◆ HubChildSettingFiltered()

static BOOLEAN NTAPI HubChildSettingFiltered ( _In_ HubChild *  Child,
_In_ UCHAR  InterfaceNumber,
_In_ UCHAR  AlternateSetting 
)
static

Definition at line 43 of file devconfig.cpp.

47{
48 PULONG Filter = (PULONG)Child->m_AlternateSettingFilter;
49 PUCHAR Pairs;
51
52 if (Filter == NULL)
53 return FALSE;
54
55 Pairs = (PUCHAR)(Filter + 1);
56 for (Index = 0; Index < *Filter; Index++)
57 {
58 if (Pairs[Index * 2] == InterfaceNumber && Pairs[Index * 2 + 1] == AlternateSetting)
59 return TRUE;
60 }
61
62 return FALSE;
63}
HubAltSettingFilter * Filter
if(dx< 0)
Definition: linetemp.h:194
uint32_t * PULONG
Definition: typedefs.h:59
unsigned char * PUCHAR
Definition: typedefs.h:53
_In_ PVOID _In_ LONG _In_ LONG AlternateSetting
Definition: usbdlib.h:197
_In_ PVOID _In_ LONG InterfaceNumber
Definition: usbdlib.h:196

Referenced by DeviceMachine::PrepareConfigLists(), and DeviceMachine::PrepareInterfaceLists().

◆ HubChildSizeEndpointArrays()

static NTSTATUS NTAPI HubChildSizeEndpointArrays ( _In_ HubChild *  Child,
_In_ ULONG  Count 
)
static

Definition at line 94 of file devconfig.cpp.

97{
98 UCXENDPOINT* Fresh[3];
100
101 Child->m_EnableCount = 0;
102 Child->m_DisableCount = 0;
103 Child->m_UnchangedCount = 0;
104
105 if (Count <= Child->m_EndpointArrayCapacity)
106 return STATUS_SUCCESS;
107
108 for (Index = 0; Index < RTL_NUMBER_OF(Fresh); Index++)
109 {
110 Fresh[Index] = (UCXENDPOINT*)ExAllocatePoolZero(NonPagedPool,
111 Count * sizeof(UCXENDPOINT),
113 if (Fresh[Index] == NULL)
114 {
115 DPRINT1("Device %p no memory for %lu endpoint handles\n", Child, Count);
116 while (Index-- != 0)
119 }
120 }
121
123 Child->m_EndpointsToEnable = Fresh[0];
124 Child->m_EndpointsUnchanged = Fresh[1];
125 Child->m_EndpointsToDisable = Fresh[2];
126 Child->m_EndpointArrayCapacity = Count;
127 return STATUS_SUCCESS;
128}
static VOID NTAPI HubChildFreeEndpointArrays(_In_ HubChild *Child)
Definition: devconfig.cpp:70
static PVOID ExAllocatePoolZero(ULONG PoolType, SIZE_T NumberOfBytes, ULONG Tag)
Definition: precomp.h:45
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
USHORT Count
Definition: userreq.cpp:200

Referenced by DeviceMachine::PrepareConfigLists(), DeviceMachine::PrepareInterfaceLists(), and DeviceMachine::PrepareListsForReset().

◆ HubConfigCheckDuplicates()

static NTSTATUS NTAPI HubConfigCheckDuplicates ( _In_ HubConfiguration *  Config)
static

Definition at line 463 of file devconfig.cpp.

465{
466 USHORT Seen[3] = { 0, 0, 0 };
470 USHORT Bit;
471 ULONG Map;
472 ULONG Index;
473
474 for (Entry = Config->Interfaces.Flink; Entry != &Config->Interfaces; Entry = Entry->Flink)
475 {
477
478 for (Index = 0; Index < Interface->PipeCount; Index++)
479 {
480 if (Interface->Pipes[Index].ZeroBandwidth)
481 continue;
482
483 Endpoint = Interface->Pipes[Index].Descriptor;
484 Bit = (USHORT)(1 << (Endpoint->bEndpointAddress & USB_ENDPOINT_ADDRESS_MASK));
485
487 Map = 0;
488 else if (USB_ENDPOINT_DIRECTION_IN(Endpoint->bEndpointAddress))
489 Map = 1;
490 else
491 Map = 2;
492
493 if ((Seen[0] | Seen[Map]) & Bit)
494 {
495 DPRINT1("Configuration %p uses endpoint 0x%x twice\n", Config, Endpoint->bEndpointAddress);
496 return STATUS_UNSUCCESSFUL;
497 }
498
499 Seen[Map] |= Bit;
500 }
501 }
502
503 return STATUS_SUCCESS;
504}
PLIST_ENTRY Entry
Definition: devhcd.cpp:1262
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
#define USB_ENDPOINT_TYPE_CONTROL
Definition: usb100.h:62
#define USB_ENDPOINT_DIRECTION_IN(x)
Definition: usb100.h:76
#define USB_ENDPOINT_ADDRESS_MASK
Definition: usb300.h:64

Referenced by DeviceMachine::PrepareConfigLists().

◆ HubConfigHasEndpointZero()

static BOOLEAN NTAPI HubConfigHasEndpointZero ( _In_ HubConfiguration *  Config)
static

Definition at line 442 of file devconfig.cpp.

444{
446
447 for (Entry = Config->Interfaces.Flink; Entry != &Config->Interfaces; Entry = Entry->Flink)
448 {
450 return TRUE;
451 }
452
453 return FALSE;
454}
static BOOLEAN NTAPI HubInterfaceHasEndpointZero(_In_ HubInterface *Interface)
Definition: devconfig.cpp:425

Referenced by DeviceMachine::PrepareConfigLists().

◆ HubFreeConfiguration()

static VOID NTAPI HubFreeConfiguration ( _In_ HubChild *  Child,
_In_ HubConfiguration *  Config 
)
static

Definition at line 248 of file devconfig.cpp.

251{
253
254 while (!IsListEmpty(&Config->Interfaces))
255 {
256 Entry = RemoveHeadList(&Config->Interfaces);
257 HubChildDeleteInterface(Child, CONTAINING_RECORD(Entry, HubInterface, Link));
258 }
259
260 WdfObjectDelete(Config->Memory);
261}
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
#define RemoveHeadList(ListHead)
Definition: env_spec_w32.h:964
WdfObjectDelete(String)

Referenced by DeviceMachine::PrepareConfigLists().

◆ HubInterfaceHasEndpointZero()

static BOOLEAN NTAPI HubInterfaceHasEndpointZero ( _In_ HubInterface *  Interface)
static

Definition at line 425 of file devconfig.cpp.

427{
428 ULONG Index;
429
430 for (Index = 0; Index < Interface->PipeCount; Index++)
431 {
432 if ((Interface->Pipes[Index].Descriptor->bEndpointAddress & USB_ENDPOINT_ADDRESS_MASK) == 0)
433 return TRUE;
434 }
435
436 return FALSE;
437}

Referenced by HubConfigHasEndpointZero(), and DeviceMachine::PrepareInterfaceLists().

◆ HubInterfacesShareEndpoints()

static NTSTATUS NTAPI HubInterfacesShareEndpoints ( _In_ HubInterface *  First,
_In_ HubInterface *  Second 
)
static

Definition at line 509 of file devconfig.cpp.

512{
515 ULONG I, J;
516
517 for (I = 0; I < First->PipeCount; I++)
518 {
519 A = First->Pipes[I].Descriptor;
520
521 for (J = 0; J < Second->PipeCount; J++)
522 {
523 B = Second->Pipes[J].Descriptor;
524
525 if (A->bEndpointAddress == B->bEndpointAddress &&
526 A->wMaxPacketSize != 0 &&
527 B->wMaxPacketSize != 0)
528 {
529 DPRINT1("Endpoint 0x%x shared by interface %u alternate %u and interface %u alternate %u\n",
530 A->bEndpointAddress,
531 First->Descriptor->bInterfaceNumber, First->Descriptor->bAlternateSetting,
532 Second->Descriptor->bInterfaceNumber, Second->Descriptor->bAlternateSetting);
534 }
535 }
536 }
537
538 return STATUS_SUCCESS;
539}
WCHAR Second[]
Definition: FormatMessage.c:12
WCHAR First[]
Definition: FormatMessage.c:11
Definition: ehthrow.cxx:93
Definition: ehthrow.cxx:54
#define A(row, col)
#define B(row, col)
#define I(s)
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135

Referenced by DeviceMachine::PrepareInterfaceLists().

◆ HubPickCompanions()

static VOID NTAPI HubPickCompanions ( _In_ HubPipe *  Pipe,
_Inout_ PUSBD_PIPE_INFORMATION  Client,
_In_ PUCHAR  Walk,
_In_ PUCHAR  End 
)
static

Definition at line 280 of file devconfig.cpp.

285{
288
289 if (!HubTypeFits(Walk, End))
290 return;
291
294 Companion->bLength == 0 ||
296 {
297 return;
298 }
299
300 Pipe->Companion = Companion;
301
302 if ((Pipe->Descriptor->bmAttributes & USB_ENDPOINT_TYPE_MASK) != USB_ENDPOINT_TYPE_ISOCHRONOUS)
303 return;
304
305 if (!Pipe->ZeroBandwidth)
306 Client->MaximumPacketSize = Companion->wBytesPerInterval;
307
308 if (!Companion->bmAttributes.Isochronous.SspCompanion)
309 return;
310
311 Walk += Companion->bLength;
312 if (!HubTypeFits(Walk, End))
313 return;
314
317 SspCompanion->bLength != 0 &&
319 {
320 Pipe->IsochCompanion = SspCompanion;
321 }
322}
#define COMPANION_LENGTH
Definition: devconfig.cpp:22
#define SSP_COMPANION_LENGTH
Definition: devconfig.cpp:23
_Must_inspect_result_ _In_ UCXUSBDEVICE _In_ ULONG _In_opt_ PUSB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR Companion
Definition: hubucx.h:308
#define USB_ENDPOINT_TYPE_ISOCHRONOUS
Definition: usb100.h:63
#define USB_SUPERSPEEDPLUS_ISOCH_ENDPOINT_COMPANION_DESCRIPTOR_TYPE
Definition: usb300.h:20
#define USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR_TYPE
Definition: usb300.h:19
struct _USB_SUPERSPEEDPLUS_ISOCH_ENDPOINT_COMPANION_DESCRIPTOR * PUSB_SUPERSPEEDPLUS_ISOCH_ENDPOINT_COMPANION_DESCRIPTOR
struct _USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR * PUSB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR

Referenced by HubChildInitPipes().

◆ HubTypeFits()

FORCEINLINE BOOLEAN NTAPI HubTypeFits ( _In_ PUCHAR  Walk,
_In_ PUCHAR  End 
)

Definition at line 269 of file devconfig.cpp.

272{
273 return Walk + 1 < End;
274}

Referenced by HubChildInitPipes(), and HubPickCompanions().