ReactOS 0.4.17-dev-1281-g065abb3
hubport.h
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS SuperSpeed USB Hub Driver
3 * LICENSE: MIT (https://spdx.org/licenses/MIT)
4 * PURPOSE: One downstream port of a hub
5 * COPYRIGHT: Copyright 2026 Justin Miller <justin.miller@reactos.org>
6 */
7
8#pragma once
9
10/* Port properties fixed at creation */
12{
13 Removable = 0x00000001,
14 AcpiUpcValid = 0x00000002,
15 AcpiPldValid = 0x00000004,
16 DebugCapable = 0x00000008,
17 IntegratedHub = 0x00000010,
18 InConnectorMap = 0x00000020,
19 Usb20LpmCapable = 0x00000040,
20 BeslCapable = 0x00000080,
21 EnhancedSuperSpeed = 0x00000100,
22 TypeCWithoutSwitch = 0x00000200
23};
24
25/* Port state flags, changed at run time */
27{
28 DeviceConnected = 0x00000001,
29 SupportsReattach = 0x00000002,
30 OverCurrentResetArmed = 0x00000004,
31 SsInactiveSeenForBoot = 0x00000008,
32 PendingRecoveryUpdate = 0x00000010,
33 PendingHubPowerReference = 0x00000020,
34
35 /* Bound to a USB4 host router name, which m_Usb4HostName holds */
36 Usb4Host = 0x00000040,
37
38 /* The port _DSM asks for U2 to stay off */
39 AcpiNoU2 = 0x00000080
40};
41
42/* Mux bookkeeping per port */
44{
45 PortChangePending = 0x00000001,
46 InterruptReference = 0x00000002,
47 PnpOperationPending = 0x00000004,
48 PowerReference = 0x00000008,
49 ResetPending = 0x00000010,
50 WdfPowerReference = 0x00000020
51};
52
53/* What a port GET_STATUS returns; 8 bytes on an enhanced SuperSpeed port */
55{
58};
59
60/* What creation copies in; built by CreateChildPorts */
62{
70};
71
72/* identity */
73
74/* HubConnectorId.Type */
75#define HUB_CONNECTOR_NONE 0
76#define HUB_CONNECTOR_ROOT 1
77#define HUB_CONNECTOR_ACPI 2
78
79/* Root port level plus five external hub tiers */
80#define HUB_CONNECTOR_MAX_PATH 6
81
84{
86
87 /* _PLD of an ACPI port, or the root hub number in the first ULONG */
89
90 /* External hub tiers between the root connector and this port */
92
93 /* Path[0] is the root port, Path[n] the port at tier n */
95
96 /* (GroupToken << 8) | GroupPosition from the _PLD; ACPI ports only */
98};
99
102{
107};
108
111{
136};
137
138C_ASSERT(sizeof(HubAcpiPld) == 16);
139
141{
142public:
145 static
146 HubPort*
147 Create(
148 _In_ HubFdo* Hub,
150
151 static
152 HubPort*
155
156 VOID
159 {
161 }
162
163 BOOLEAN
165 _In_ PortMuxFlag Flag) const
166 {
167 return (m_MuxFlags & (LONG)Flag) != 0;
168 }
169
170 VOID
173 {
175 }
176
177 VOID
180 {
182 }
183
184 BOOLEAN
186 _In_ PortFlag Flag) const
187 {
188 return (m_Flags & (LONG)Flag) != 0;
189 }
190
191 VOID
194 {
196 }
197
198 VOID
201 {
203 }
204
205 BOOLEAN
208 {
209 return (m_Info.Properties & (ULONG)Property) != 0;
210 }
211
212 USHORT
213 Number() const
214 {
215 return m_Info.PortNumber;
216 }
217
218 BOOLEAN
219 IsUsb30() const
220 {
221 return m_Info.Protocol == 0x300;
222 }
223
224public:
226
231
232 volatile LONG m_MuxFlags;
233 volatile LONG m_Flags;
234
235 /* Current device on the port, or NULL */
237
242
243 /* Last GET_STATUS: status and change words, then the USB 3 extended status */
253
257
258 /* identity */
259
260 /* ACPI description, valid with the AcpiUpcValid and AcpiPldValid properties */
263
264 /* _DSM interconnect type: 0 standard, 1 HSIC, 2 SSIC. Only traced */
266
267 /* Connector map key; registered while InConnectorMap is set */
269
270 /* Port number a serial less device on a Type-C connector without a switch is named by */
272
273 /* Integrated hub port: root USB 3 ports its child hub maps onto */
276
277 /* USB4 */
278
279 /* Escaped name of the USB4 host router the port belongs to, with PortFlag::Usb4Host */
280 WDFSTRING m_Usb4HostName;
281
282private:
283 static
284 VOID
285 NTAPI
288
289 static EVT_WDF_TIMER ResetPollFired;
290 static EVT_WDF_OBJECT_CONTEXT_CLEANUP EvtCleanup;
291 static EVT_WDF_OBJECT_CONTEXT_DESTROY EvtDestroy;
292 static UCXHUB_WORKITEM_ROUTINE MachineWorkItem;
293
294 friend class PortMachine;
295};
296
unsigned char BOOLEAN
Definition: actypes.h:127
@ Create
Definition: registry.c:563
HubFdo * Hub
Definition: bootdev.cpp:261
Definition: fdo.h:132
static UCXHUB_WORKITEM_ROUTINE MachineWorkItem
Definition: hubport.h:292
BOOLEAN HasMuxFlag(_In_ PortMuxFlag Flag) const
Definition: hubport.h:164
UCHAR m_OverCurrentCount
Definition: hubport.h:250
volatile LONG m_Flags
Definition: hubport.h:233
static EVT_WDF_TIMER ResetPollFired
Definition: hubport.h:289
BOOLEAN HasProperty(_In_ PortProperty Property) const
Definition: hubport.h:206
WDFSTRING m_Usb4HostName
Definition: hubport.h:280
HubChild * m_Child
Definition: hubport.h:236
static HubPort * FromObject(_In_ WDFOBJECT Object)
Definition: hubport.cpp:30
static EVT_WDF_OBJECT_CONTEXT_CLEANUP EvtCleanup
Definition: hubport.h:290
USHORT m_LastCompanionPort
Definition: hubport.h:275
USHORT m_ChangeAccumulator
Definition: hubport.h:246
HubConnectorId m_ConnectorId
Definition: hubport.h:268
VOID ClearMuxFlag(_In_ PortMuxFlag Flag)
Definition: hubport.h:178
USHORT Number() const
Definition: hubport.h:213
USHORT m_PreviousStatus
Definition: hubport.h:245
HubAcpiUpc m_AcpiUpc
Definition: hubport.h:261
VOID Post(_In_ PortEvent Event)
Definition: hubport.h:157
ULONG m_TotalResets
Definition: hubport.h:256
PortEvent m_LastChange
Definition: hubport.h:248
USHORT m_SelectedFeature
Definition: hubport.h:247
USHORT m_InstancePortNumber
Definition: hubport.h:271
LIST_ENTRY m_HubLink
Definition: hubport.h:230
_IRQL_requires_(PASSIVE_LEVEL) static HubPort *Create(_In_ HubFdo *Hub
static EVT_WDF_OBJECT_CONTEXT_DESTROY EvtDestroy
Definition: hubport.h:291
LARGE_INTEGER m_LastOverCurrentTime
Definition: hubport.h:251
ULONG m_LinkErrorCount
Definition: hubport.h:249
PortMachine m_Machine
Definition: hubport.h:225
BOOLEAN m_InitialConnectPowerReference
Definition: hubport.h:252
WDFOBJECT m_Object
Definition: hubport.h:227
volatile LONG m_MuxFlags
Definition: hubport.h:232
HubPortInfo m_Info
Definition: hubport.h:229
BOOLEAN IsUsb30() const
Definition: hubport.h:219
USB_CONNECTION_STATUS m_ConnectionStatus
Definition: hubport.h:254
USHORT m_InterconnectType
Definition: hubport.h:265
PUCXHUB_WORKITEM m_WorkItem
Definition: hubport.h:240
HubPortStatus m_Current
Definition: hubport.h:244
WDFTIMER m_ResetPollTimer
Definition: hubport.h:239
VOID SetMuxFlag(_In_ PortMuxFlag Flag)
Definition: hubport.h:171
VOID SetFlag(_In_ PortFlag Flag)
Definition: hubport.h:192
HubAcpiPld m_AcpiPld
Definition: hubport.h:262
USHORT m_FirstCompanionPort
Definition: hubport.h:274
VOID ClearFlag(_In_ PortFlag Flag)
Definition: hubport.h:199
HubControlRequest m_Control
Definition: hubport.h:241
BOOLEAN HasFlag(_In_ PortFlag Flag) const
Definition: hubport.h:185
ULONG m_D3ColdReconnectTimeout
Definition: hubport.h:255
HubFdo * m_Hub
Definition: hubport.h:228
HubTimer m_Timer
Definition: hubport.h:238
BOOLEAN SmPost(_In_ Event Ev)
Definition: smengine.h:370
_Check_return_ _In_ DXGK_EVENT_TYPE _In_ ULONG Event
Definition: dispmprt.h:1287
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
PortProperty
Definition: hubport.h:12
PortMuxFlag
Definition: hubport.h:44
#define HUB_CONNECTOR_MAX_PATH
Definition: hubport.h:80
PortFlag
Definition: hubport.h:27
@ SsInactiveSeenForBoot
@ SupportsReattach
@ DeviceConnected
@ OverCurrentResetArmed
@ PendingRecoveryUpdate
@ PendingHubPowerReference
#define InterlockedOr
Definition: interlocked.h:239
#define InterlockedAnd
Definition: interlocked.h:77
#define C_ASSERT(e)
Definition: intsafe.h:73
_In_ PIRP _In_ PIO_COMPLETION_ROUTINE _In_ PVOID Context
Definition: kse.h:81
unsigned __int64 ULONG64
Definition: imports.h:198
#define _Enum_is_bitflag_
Definition: no_sal2.h:404
#define _In_
Definition: no_sal2.h:158
long LONG
Definition: pedump.c:60
unsigned short USHORT
Definition: pedump.c:61
PortEvent
Definition: portsm.h:15
Definition: xml2sdb.h:103
ULONG Order
Definition: hubport.h:134
ULONG Ejectable
Definition: hubport.h:128
ULONG Dock
Definition: hubport.h:118
ULONG Bay
Definition: hubport.h:127
ULONG Height
Definition: hubport.h:116
ULONG HorizontalPosition
Definition: hubport.h:122
ULONG Width
Definition: hubport.h:115
ULONG UserVisible
Definition: hubport.h:117
ULONG GroupToken
Definition: hubport.h:125
ULONG Reference
Definition: hubport.h:132
ULONG OspmEjectionRequired
Definition: hubport.h:129
ULONG VerticalPosition
Definition: hubport.h:121
ULONG Shape
Definition: hubport.h:123
ULONG GroupPosition
Definition: hubport.h:126
ULONG Lid
Definition: hubport.h:119
ULONG Revision
Definition: hubport.h:112
ULONG GroupOrientation
Definition: hubport.h:124
ULONG Panel
Definition: hubport.h:120
ULONG CabinetNumber
Definition: hubport.h:130
ULONG CardCageNumber
Definition: hubport.h:131
ULONG Reserved
Definition: hubport.h:135
ULONG Rotation
Definition: hubport.h:133
ULONG IgnoreColor
Definition: hubport.h:113
ULONG Color
Definition: hubport.h:114
ULONG Reserved1
Definition: hubport.h:106
UCHAR ConnectorType
Definition: hubport.h:104
ULONG Reserved0
Definition: hubport.h:105
UCHAR Connectable
Definition: hubport.h:103
USHORT Depth
Definition: hubport.h:91
ULONG Type
Definition: hubport.h:85
UCHAR Location[16]
Definition: hubport.h:88
ULONG Path[HUB_CONNECTOR_MAX_PATH]
Definition: hubport.h:94
ULONG64 TypeCConnectorId
Definition: hubport.h:97
ULONG SspIsochBurstCount
Definition: hubport.h:67
ULONG TotalHubDepth
Definition: hubport.h:66
ULONG Properties
Definition: hubport.h:65
PUSB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED SublinkSpeedAttr
Definition: hubport.h:68
USHORT Protocol
Definition: hubport.h:64
USHORT PortNumber
Definition: hubport.h:63
ULONG SublinkSpeedAttrCount
Definition: hubport.h:69
USB_PORT_STATUS_AND_CHANGE StatusChange
Definition: hubport.h:56
ULONG ExtendedStatus
Definition: hubport.h:57
Definition: typedefs.h:120
unsigned char UCHAR
Definition: typedefs.h:53
#define NTAPI
Definition: typedefs.h:36
uint32_t ULONG
Definition: typedefs.h:59
enum _USB_CONNECTION_STATUS USB_CONNECTION_STATUS
_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_ WDFCOLLECTION _In_ WDFOBJECT Object
#define WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(_contexttype, _castingfunction)
Definition: wdfobject.h:350