15#define DESC_FIRST_READ_KEEP 8
18#define DESC_SLOW_ENUM_VENDOR 0x13FE
19#define DESC_SLOW_ENUM_PRODUCT 0x5200
22#define DESC_CLASS_MISCELLANEOUS 0xEF
23#define DESC_SUBCLASS_COMMON 0x02
24#define DESC_PROTOCOL_IAD 0x01
27#define DESC_SUBCLASS_SCSI 0x06
28#define DESC_PROTOCOL_UAS 0x62
31#define DESC_MODE_CONFIGURED 3
40 Child->m_DeviceDescriptor.bcdUSB,
43 Child->m_Port->m_Info.SspIsochBurstCount,
44 Child->m_ValidationBits);
76 DPRINT1(
"Device %p first device descriptor read returned %lu bytes\n",
Child,
Bytes);
92 Child->m_Hacks |= (
ULONG)ChildHack::AlwaysSecondReset;
123 Child->SetProperty(ChildProperty::HasBillboard);
146 if (
Device->bNumConfigurations != 1 ||
Config->bNumInterfaces <= 1)
149 if (
Device->bDeviceClass == 0)
189 Child->m_DeviceDescriptor.bcdUSB <= 0x0200 ||
207 Child->m_CompatIdInterface = Uas;
237 Child->SetState(ChildState::ConfigurationValid);
241 if (
Child->m_DeviceDescriptor.bNumConfigurations > 1)
245 Child->SetProperty(ChildProperty::IsComposite);
255 DPRINT1(
"Device %p no memory for a %u byte configuration\n",
Child,
Header->wTotalLength);
266 if (
Child->HasProperty(ChildProperty::IsHub) &&
Child->HasProperty(ChildProperty::IsComposite))
270 Child->SetProperty(ChildProperty::RemoteWakeCapable);
272 if (
Child->HasHack(ChildHack::BlockedDevice))
274 DPRINT1(
"Device %p is marked incompatible, enumeration fails\n",
Child);
339 if (Caps->bLength <=
First)
342 Room = (Caps->bLength -
First) /
sizeof(Caps->AlternateMode[0]);
343 return (
UCHAR)
min(Room, (
ULONG)Caps->bNumberOfAlternateModes);
353 if (Billboard ==
NULL)
377 if (Billboard ==
NULL)
379 DPRINT1(
"Device %p no memory for the billboard record\n",
Child);
387 Caps->bNumberOfAlternateModes *
sizeof(Caps->AlternateMode[0]);
395 DPRINT1(
"Device %p no memory for a %lu byte billboard copy\n",
Child,
Size);
401 Child->m_Billboard = Billboard;
413 ULONG Count = Caps->bmAttributes.SublinkSpeedAttrCount + 1;
414 ULONG Room = (Caps->bLength >
First) ? (Caps->bLength -
First) /
sizeof(Caps->bmSublinkSpeedAttr[0]) : 0;
421 Size =
Count *
sizeof(Caps->bmSublinkSpeedAttr[0]);
459 HubQueryLocalDualRoleFeatures(&
Child->m_DualRoleLocalFeatures);
478 if (
Child->m_MsOs20SetInfo.bAltEnumCode != 0 && !
Child->m_AltEnumCached)
480 Child->m_MsOsVendorCode =
Child->m_MsOs20SetInfo.bVendorCode;
512 DPRINT1(
"SuperSpeedPlus capability runs past the BOS, ignored\n");
522 DPRINT1(
"Billboard capability runs past the BOS, ignored\n");
528 DPRINT1(
"Container id capability runs past the BOS, ignored\n");
534 DPRINT1(
"Platform features capability runs past the BOS, ignored\n");
540 DPRINT1(
"MS OS 2.0 set info runs past the BOS, ignored\n");
569 &
Child->m_U1ExitLatency,
570 &
Child->m_U2ExitLatency,
574 if (!
Valid && !
Child->HasHack(ChildHack::IgnoreBosValidationFailure))
581 DPRINT1(
"Device %p BOS is invalid, kept because of its errata\n",
Child);
586 Child->SetProperty(ChildProperty::LtmCapable);
588 Child->SetProperty(ChildProperty::Usb20LpmCapable);
589 if (
Lpm.BeslAndAltHird)
590 Child->SetProperty(ChildProperty::BeslCapable);
592 Child->SetProperty(ChildProperty::ChargingPolicySupported);
603 Child->SetProperty(ChildProperty::ContainerIdFromBos);
604 if (!
Child->HasProperty(ChildProperty::ContainerIdKnown))
612 HubCacheDualRole(
Child,
Info.PlatformFeatures);
614 if (!SetInfoKnown &&
Info.MsOs20SetInfo !=
NULL)
651 if (Billboard ==
NULL)
677 DPRINT(
"Device %p billboard URL string read\n",
Child);
694 Billboard->ModeSuccess =
TRUE;
696 Billboard->ModeError =
TRUE;
706 if (Billboard ==
NULL)
741 DPRINT1(
"Device %p alternate mode string check without a current mode\n",
Child);
780 Child->m_EnumMessageId = BadReason;
841 Child->m_MsOsVendorCode =
Child->m_MsOsString.bVendorCode;
876 Child->SetProperty(ChildProperty::ContainerIdKnown);
909 DPRINT1(
"Device %p has no extended configuration buffer\n",
Child);
938 DPRINT1(
"Device %p has no MS OS 2.0 set buffer\n",
Child);
945 if (!HubDescCheckMsOs20Set(&
Context,
947 Child->m_MsOs20SetLength,
948 &
Child->m_MsOs20SetInfo,
956 Child->SetProperty(ChildProperty::IsComposite);
958 Resume =
Child->m_MsOs20.ResumeTime;
982 Child->m_SublinkSpeedAttrCount = 0;
static _Out_opt_ PULONGLONG Start
BOOLEAN BosQuerySkipped()
BOOLEAN MsOsDescriptorValid()
BOOLEAN IgnoreDescriptorError()
BOOLEAN ProductNameValid()
BOOLEAN AltModeStringWanted()
BOOLEAN BillboardStringWanted()
BOOLEAN ContainerIdKnown()
BOOLEAN ConfigLongerThanRead()
BOOLEAN ContainerIdHeaderValid()
BOOLEAN ExtendedConfigHeaderValid()
BOOLEAN BillboardStringValid()
BOOLEAN ExtendedConfigValid()
BOOLEAN FirstDescriptorValid()
BOOLEAN DeviceDescriptorValid()
BOOLEAN AltModeStringValid()
BOOLEAN LanguageIdsValid()
BOOLEAN ConfigDescriptorValid()
PUSB_STRING_DESCRIPTOR m_LanguageIds
USB_DEVICE_DESCRIPTOR m_DeviceDescriptor
HubBillboardInfo * m_Billboard
VOID SetProperty(_In_ ChildProperty Flag)
UCHAR m_ScratchBuffer[256]
USB_DEVICE_QUALIFIER_DESCRIPTOR m_Qualifier
PUSB_STRING_DESCRIPTOR m_ProductString
BOOLEAN HasHack(_In_ ChildHack Flag) const
BOOLEAN NTAPI HubDescCheckMsOsString(_In_ const HubDescContext *Context, _In_ const HubMsOsString *Descriptor)
BOOLEAN NTAPI HubDescCheckConfiguration(_In_ const HubDescContext *Context, _In_reads_bytes_opt_(Length) PUSB_CONFIGURATION_DESCRIPTOR Descriptor, _In_ ULONG Length, _Out_opt_ PBOOLEAN SupportsStreams)
VOID NTAPI HubDescLog(_In_ const HubDescContext *Context, _In_ HubDescCode Code, _In_ BOOLEAN Warning)
BOOLEAN NTAPI HubDescCheckMsOsExtConfigHeader(_In_ const HubDescContext *Context, _In_reads_bytes_(Length) const HubMsOsExtConfigHeader *Descriptor, _In_ ULONG Length)
BOOLEAN NTAPI HubDescCheckDevice(_In_ const HubDescContext *Context, _In_reads_bytes_opt_(Length) PUSB_DEVICE_DESCRIPTOR Descriptor, _In_ ULONG Length, _Inout_opt_ PBOOLEAN IsBillboard)
_In_ ULONG _In_ const HubMsOs20SetInfo * SetInfo
VOID NTAPI HubDescInitDeviceContext(_Out_ HubDescContext *Context, _In_ USHORT BcdUsb, _In_ USB_DEVICE_SPEED Speed, _In_ BOOLEAN Win8Behavior, _In_ ULONG SspIsochBurstCount, _In_opt_ PULONG Bitmap)
BOOLEAN NTAPI HubDescCheckMsOsContainerId(_In_ const HubDescContext *Context, _In_reads_bytes_(Length) const HubMsOsContainerId *Descriptor, _In_ ULONG Length)
BOOLEAN NTAPI HubDescCheckMsOsContainerIdHeader(_In_ const HubDescContext *Context, _In_reads_bytes_(Length) const HubMsOsHeader *Descriptor, _In_ ULONG Length)
BOOLEAN NTAPI HubDescCheckString(_In_ const HubDescContext *Context, _In_reads_bytes_(Length) PUSB_STRING_DESCRIPTOR Descriptor, _In_ ULONG Length, _Out_opt_ PULONG AdjustedLength)
PUSB_INTERFACE_DESCRIPTOR NTAPI HubDescFindInterface(_In_ PUSB_CONFIGURATION_DESCRIPTOR Config, _In_ PVOID Position, _In_ LONG Number, _In_ LONG Alternate, _In_ LONG Class, _In_ LONG SubClass, _In_ LONG Protocol, _Out_opt_ PBOOLEAN HasAlternates)
_In_ ULONG _Out_opt_ HubBosInfo _Out_opt_ PUSHORT _Out_opt_ PUSHORT _Inout_opt_ PBOOLEAN _Inout_opt_ HubLpmInfo * Lpm
BOOLEAN NTAPI HubDescCheckMsOsExtConfig(_In_ const HubDescContext *Context, _In_reads_bytes_(sizeof(HubMsOsExtConfig)) const HubMsOsExtConfig *Descriptor, _In_ ULONG Length)
BOOLEAN NTAPI HubDescCheckBosHeader(_In_ const HubDescContext *Context, _In_reads_bytes_opt_(Length) PUSB_BOS_DESCRIPTOR Descriptor, _In_ ULONG Length)
#define HUB_MSOS20_ALT_ENUM
#define HUB_BOS_SUPERSPEED_CAPABLE
#define HUB_BOS_CHARGING_POLICY
#define HUB_MSOS20_SET_INFO
static BOOLEAN NTAPI HubCacheSublinkSpeeds(_In_ HubChild *Child, _In_ PUSB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_USB_DESCRIPTOR Caps)
#define DESC_CLASS_MISCELLANEOUS
HubPublishDualRolePartner(Child->m_Port, TRUE, Child->m_DualRolePartnerFeatures)
VOID NTAPI HubDeviceDescContext(_In_ HubChild *Child, _Out_ HubDescContext *Context)
static VOID NTAPI HubSetSqmFlag(_In_ HubChild *Child, _In_ ChildSqm Flag)
VOID NTAPI HubReleaseTransferState(_In_ HubChild *Child)
static VOID NTAPI HubDropCapsPastEnd(_Inout_ HubBosInfo *Info, _In_ const UCHAR *End)
#define DESC_SUBCLASS_COMMON
static VOID NTAPI HubPickCompatIdInterface(_In_ HubChild *Child, _In_ PUSB_CONFIGURATION_DESCRIPTOR Config)
HubQueryLocalDualRoleFeatures & Child
static VOID NTAPI HubNoteAltMode(_In_ HubBillboardInfo *Billboard)
#define DESC_MODE_CONFIGURED
#define DESC_SLOW_ENUM_PRODUCT
VOID NTAPI HubFreeBillboardInfo(_In_ HubChild *Child)
static BOOLEAN NTAPI HubBosSpanFits(_In_ const VOID *Start, _In_ ULONG Length, _In_ const UCHAR *End)
static BOOLEAN NTAPI HubCacheString(_In_ HubChild *Child, _In_ ULONG BadReason, _Outptr_result_maybenull_ PUSB_STRING_DESCRIPTOR *Cache)
#define DESC_PROTOCOL_UAS
static BOOLEAN NTAPI HubIsCompositeLayout(_In_ const USB_DEVICE_DESCRIPTOR *Device, _In_ const USB_CONFIGURATION_DESCRIPTOR *Config)
#define DESC_FIRST_READ_KEEP
static VOID NTAPI HubKeepBillboardData(_In_ HubChild *Child, _In_ PUSB_DEVICE_CAPABILITY_BILLBOARD_DESCRIPTOR Caps)
static UCHAR NTAPI HubBillboardModeCount(_In_ PUSB_DEVICE_CAPABILITY_BILLBOARD_DESCRIPTOR Caps)
static VOID NTAPI HubCacheMsOs20SetInfoFromBos(_In_ HubChild *Child, _In_ const HubMsOs20SetInfo *SetInfo)
#define DESC_PROTOCOL_IAD
#define DESC_SLOW_ENUM_VENDOR
#define DESC_SUBCLASS_SCSI
_In_ BOOLEAN _In_ ULONG Features
FORCEINLINE ULONG NTAPI HubDeviceBytesReturned(_In_ HubChild *Child)
_In_ D3DDDI_VIDEO_PRESENT_TARGET_ID _In_ ULONG _In_ ULONG Flags
#define _IRQL_requires_(irql)
#define ExAllocatePoolWithTag(hernya, size, tag)
#define HUB_BILLBOARD_NO_MODE
@ UseWin8DescriptorValidation
#define HUB_ENUM_BAD_LANGUAGE_IDS
#define HUB_ENUM_DEVICE_DESCRIPTOR_FAILED
#define HUB_ENUM_BAD_DEVICE_DESCRIPTOR
#define HUB_ENUM_INCOMPATIBLE
#define HUB_ENUM_BAD_MSOS_EXT_CONFIG
#define HUB_ENUM_BAD_BILLBOARD_URL
#define HUB_ENUM_BAD_CONFIG_DESCRIPTOR
#define HUB_ENUM_BAD_QUALIFIER
#define HUB_ENUM_BAD_MSOS_CONTAINER_ID
#define HUB_ENUM_BAD_PRODUCT_STRING
#define HUB_ENUM_BAD_MSOS20_SET
#define HUB_ENUM_BAD_ALT_MODE_STRING
_Must_inspect_result_ _In_ PUCXHUB_DEVICE_CREATE_INFO _Out_ UCXUSBDEVICE * Device
_In_ PIRP _In_ PIO_COMPLETION_ROUTINE _In_ PVOID Context
#define ExFreePoolWithTag(_P, _T)
static PVOID ExAllocatePoolZero(ULONG PoolType, SIZE_T NumberOfBytes, ULONG Tag)
#define _Outptr_result_maybenull_
_In_ ULONG _In_ ULONG _In_ ULONG Length
PUSB_DEVICE_CAPABILITY_BILLBOARD_DESCRIPTOR Descriptor
UCHAR bResumeSignalingTime
UCHAR bResumeRecoveryTime
struct _USB_DEVICE_CAPABILITY_BILLBOARD_DESCRIPTOR::@4127 AlternateMode[1]
#define FIELD_OFFSET(t, f)
#define RtlCopyMemory(Destination, Source, Length)
#define RtlZeroMemory(Destination, Length)
_Must_inspect_result_ _In_ WDFDEVICE _In_ PUCX_CONTROLLER_CONFIG Config
_In_ UCXUSBDEVICE _In_ ULONG Interface
#define USB_DEVICE_CLASS_STORAGE
struct _USB_CONFIGURATION_DESCRIPTOR * PUSB_CONFIGURATION_DESCRIPTOR
#define USB_CONFIGURATION_DESCRIPTOR_TYPE
struct _USB_STRING_DESCRIPTOR * PUSB_STRING_DESCRIPTOR
#define USB_CONFIG_REMOTE_WAKEUP
struct _USB_DEVICE_DESCRIPTOR * PUSB_DEVICE_DESCRIPTOR
#define USB_DEVICE_CLASS_HUB
enum _USB_DEVICE_SPEED USB_DEVICE_SPEED
struct _USB_DEVICE_CAPABILITY_BILLBOARD_DESCRIPTOR * PUSB_DEVICE_CAPABILITY_BILLBOARD_DESCRIPTOR
struct _USB_BOS_DESCRIPTOR * PUSB_BOS_DESCRIPTOR
union _USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED * PUSB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFDEVICE Child
_Must_inspect_result_ _In_ WDFIORESLIST _In_ PIO_RESOURCE_DESCRIPTOR Descriptor