ReactOS 0.4.17-dev-1281-g065abb3
rootports.h
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS xHCI Host Controller Driver
3 * LICENSE: MIT (https://spdx.org/licenses/MIT)
4 * PURPOSE: Root hub ports and the UCX root hub callbacks
5 * COPYRIGHT: Copyright 2026 Justin Miller <justin.miller@reactos.org>
6 */
7
8#pragma once
9
10class XhciController;
11
14{
15public:
18 Create(
20
23 VOID Release();
24 VOID D0Entry();
26 VOID D0Exit();
29
30 ULONG PortCount() const;
32
33 /* From the interrupter DPC */
34 VOID
36 _In_ const XHCI_TRB* Event);
37
38
40 VOID
42 _In_ BOOLEAN Arm);
43
46
47 /* Services for the usbdevice module */
48 VOID
51 _In_ ULONG SlotId,
53 VOID
56 _In_ ULONG SlotId);
57 VOID
60 _In_ ULONG Milliseconds);
61 VOID
64
68 _In_ ULONG PortNumber) const;
69
71 UCHAR
73 _In_ ULONG PortNumber) const;
74
75private:
77 struct Port
78 {
101 };
102
104 enum class Outcome : ULONG
105 {
106 Ok,
107 Stall,
108 Gone,
109 Halted,
111 };
112
113 static EVT_UCX_ROOTHUB_CONTROL_URB EvtClearHubFeature;
114 static EVT_UCX_ROOTHUB_CONTROL_URB EvtClearPortFeature;
115 static EVT_UCX_ROOTHUB_CONTROL_URB EvtGetHubStatus;
116 static EVT_UCX_ROOTHUB_CONTROL_URB EvtGetPortStatus;
117 static EVT_UCX_ROOTHUB_CONTROL_URB EvtSetHubFeature;
118 static EVT_UCX_ROOTHUB_CONTROL_URB EvtSetPortFeature;
119 static EVT_UCX_ROOTHUB_CONTROL_URB EvtGetPortErrorCount;
120 static EVT_UCX_ROOTHUB_INTERRUPT_TX EvtInterruptTransfer;
121 static EVT_UCX_ROOTHUB_GET_INFO EvtGetInfo;
122 static EVT_UCX_ROOTHUB_GET_20PORT_INFO EvtGet20PortInfo;
123 static EVT_UCX_ROOTHUB_GET_30PORT_INFO EvtGet30PortInfo;
124 static KDEFERRED_ROUTINE ResumeTimerDpc;
125
126 static XhciRootHub*
127 FromUcx(
128 _In_ UCXROOTHUB UcxRootHub);
129 static VOID
131 _In_ WDFREQUEST Request,
132 _In_ PURB Urb,
134
137 _In_ ULONG Capability,
139
140 Port*
141 PortAt(
142 _In_ ULONG PortNumber) const;
143 ULONG
145 _In_ const Port* P) const;
146 ULONG
148 _In_ Port* P,
149 _In_ ULONG Keep,
150 _In_ ULONG Set);
151 ULONG
153 _In_ Port* P,
154 _In_ ULONG Keep,
155 _In_ ULONG Set);
156 VOID
158 _In_ Port* P,
161 _In_ ULONG Set);
162 VOID
164 _In_ Port* P);
165 BOOLEAN
167 _In_ const Port* P) const;
168 VOID
170 _In_ Port* P);
171 BOOLEAN
173 _In_ Port* P,
176 WaitForU3(
177 _In_ Port* P,
178 _In_ BOOLEAN RepeatRequest);
180 WaitU0(
181 _In_ Port* P);
182 VOID
184 _In_ Port* P);
185 VOID
187 BOOLEAN
189 _In_ const Port* P) const;
190
191 Outcome
192 CheckRunning();
193 Outcome
195 _In_ PURB Urb);
196 Outcome
198 _In_ PURB Urb);
199 Outcome
201 _In_ PURB Urb);
202 Outcome
204 _In_ PURB Urb);
205 Outcome
207 _In_ Port* P,
210 Outcome
212 _In_ Port* P,
215 Outcome
217 _In_ PURB Urb);
218 Outcome
220 _In_ Port* P,
223 Outcome
225 _In_ Port* P,
228 Outcome
230 _In_ Port* P,
231 _In_ UCHAR LinkState);
232 Outcome
234 _In_ PURB Urb);
235 Outcome
237 _In_ PURB Urb);
240 _In_ const Port* P,
242
244 UCXROOTHUB m_Ucx;
255};
unsigned char BOOLEAN
Definition: actypes.h:127
LONG NTSTATUS
Definition: precomp.h:26
@ Create
Definition: registry.c:563
_In_ ULONG const Usable
Definition: cdrom.h:1084
_In_ ULONG const _In_ FEATURE_NUMBER const Feature
Definition: cdrom.h:1077
NTSTATUS Prepare()
Definition: rootports.cpp:314
VOID Release()
Definition: rootports.cpp:404
static XhciRootHub * FromUcx(_In_ UCXROOTHUB UcxRootHub)
Definition: rootports.cpp:179
VOID ResuspendResumedPorts()
Definition: rootports.cpp:775
Outcome GetPortStatus(_In_ PURB Urb)
Definition: rootports.cpp:1284
BOOLEAN AcknowledgeResume(_In_ Port *P, _In_ BOOLEAN PowerUp)
Definition: rootports.cpp:582
NTSTATUS WaitForU3(_In_ Port *P, _In_ BOOLEAN RepeatRequest)
Definition: rootports.cpp:650
Outcome GetHubStatus(_In_ PURB Urb)
Definition: rootports.cpp:1255
Outcome SetUsb30LinkState(_In_ Port *P, _In_ UCHAR LinkState)
Definition: rootports.cpp:1783
BOOLEAN IsPortConnected(_In_ const Port *P) const
Definition: rootports.cpp:519
static EVT_UCX_ROOTHUB_INTERRUPT_TX EvtInterruptTransfer
Definition: rootports.h:120
USHORT m_Usb30PortCount
Definition: rootports.h:249
VOID SignalPortChange()
Definition: rootports.cpp:956
USHORT m_U1ExitLatency
Definition: rootports.h:250
USHORT HighestUsbVersion() const
Definition: rootports.cpp:972
VOID Update20HardwareLpm(_In_ ULONG PortNumber, _In_ ULONG SlotId, _In_ const USBDEVICE_UPDATE_20_HARDWARE_LPM_PARAMETERS *Parameters)
Definition: rootports.cpp:1075
Outcome ClearUsb20PortFeature(_In_ Port *P, _In_ USHORT Feature, _In_ UCHAR Value)
Definition: rootports.cpp:1462
VOID ClearUsb20LpmLocked(_In_ Port *P)
Definition: rootports.cpp:486
static KDEFERRED_ROUTINE ResumeTimerDpc
Definition: rootports.h:124
static VOID CompleteHubRequest(_In_ WDFREQUEST Request, _In_ PURB Urb, _In_ Outcome Result)
Definition: rootports.cpp:1172
VOID OnPortStatusChangeEvent(_In_ const XHCI_TRB *Event)
Definition: rootports.cpp:1044
Outcome InterruptTransfer(_In_ PURB Urb)
Definition: rootports.cpp:1870
ULONG m_DebugCapability
Definition: rootports.h:247
ULONG ReadPortSc(_In_ const Port *P) const
Definition: rootports.cpp:440
ULONG PortCount() const
Definition: rootports.cpp:965
VOID SetWakeEnables(_In_ BOOLEAN Arm)
Definition: rootports.cpp:936
Outcome ClearUsb30PortFeature(_In_ Port *P, _In_ USHORT Feature, _In_ UCHAR Value)
Definition: rootports.cpp:1546
ULONG UpdatePortSc(_In_ Port *P, _In_ ULONG Keep, _In_ ULONG Set)
Definition: rootports.cpp:460
ULONG m_PortCount
Definition: rootports.h:246
BOOLEAN m_PortScTunnelValid
Definition: rootports.h:253
USHORT m_Usb20PortCount
Definition: rootports.h:248
BOOLEAN m_AwaitingStatusRead
Definition: rootports.h:252
NTSTATUS ParseProtocol(_In_ ULONG Capability, _Out_ PBOOLEAN Usable)
Definition: rootports.cpp:235
VOID DisableLpmForSlot(_In_ ULONG PortNumber, _In_ ULONG SlotId)
Definition: rootports.cpp:1118
BOOLEAN IsUsb20Port(_In_ ULONG PortNumber) const
Definition: rootports.cpp:995
UCXROOTHUB m_Ucx
Definition: rootports.h:244
VOID StartResumeTimer(_In_ Port *P)
Definition: rootports.cpp:536
Port * m_Ports
Definition: rootports.h:245
Outcome SetUsb20PortFeature(_In_ Port *P, _In_ USHORT Feature, _In_ UCHAR Value)
Definition: rootports.cpp:1644
BOOLEAN IsHiddenDebugPort(_In_ const Port *P) const
Definition: rootports.cpp:503
static EVT_UCX_ROOTHUB_CONTROL_URB EvtClearPortFeature
Definition: rootports.h:114
Port * PortAt(_In_ ULONG PortNumber) const
Definition: rootports.cpp:430
VOID D0Entry()
Definition: rootports.cpp:844
static EVT_UCX_ROOTHUB_CONTROL_URB EvtGetPortErrorCount
Definition: rootports.h:119
static EVT_UCX_ROOTHUB_GET_20PORT_INFO EvtGet20PortInfo
Definition: rootports.h:122
static EVT_UCX_ROOTHUB_CONTROL_URB EvtSetHubFeature
Definition: rootports.h:117
Outcome SetUsb30PortFeature(_In_ Port *P, _In_ USHORT Feature, _In_ UCHAR Value)
Definition: rootports.cpp:1710
VOID PostReset()
Definition: rootports.cpp:914
Outcome CheckRunning()
Definition: rootports.cpp:1215
Outcome ClearPortFeature(_In_ PURB Urb)
Definition: rootports.cpp:1421
NTSTATUS WaitU0(_In_ Port *P)
Definition: rootports.cpp:701
ULONG m_FirstUsb30Port
Definition: rootports.h:254
VOID D0Exit()
Definition: rootports.cpp:877
static EVT_UCX_ROOTHUB_GET_30PORT_INFO EvtGet30PortInfo
Definition: rootports.h:123
VOID ArmPortResumeTimer(_In_ ULONG PortNumber, _In_ ULONG Milliseconds)
Definition: rootports.cpp:1140
Outcome ClearHubFeature(_In_ PURB Urb)
Definition: rootports.cpp:1236
static EVT_UCX_ROOTHUB_CONTROL_URB EvtGetHubStatus
Definition: rootports.h:115
UCHAR QueryTunnelState(_In_ ULONG PortNumber) const
Definition: rootports.cpp:1005
static EVT_UCX_ROOTHUB_CONTROL_URB EvtSetPortFeature
Definition: rootports.h:118
VOID SuspendPort(_In_ Port *P)
Definition: rootports.cpp:760
VOID DisarmPortResumeTimer(_In_ ULONG PortNumber)
Definition: rootports.cpp:1156
static EVT_UCX_ROOTHUB_CONTROL_URB EvtClearHubFeature
Definition: rootports.h:113
XhciController * m_Controller
Definition: rootports.h:243
USHORT m_U2ExitLatency
Definition: rootports.h:251
static EVT_UCX_ROOTHUB_CONTROL_URB EvtGetPortStatus
Definition: rootports.h:116
static EVT_UCX_ROOTHUB_GET_INFO EvtGetInfo
Definition: rootports.h:121
Outcome GetPortErrorCount(_In_ PURB Urb)
Definition: rootports.cpp:1826
VOID OnHostLost()
Definition: rootports.cpp:921
VOID PostInterruptsEntry()
Definition: rootports.cpp:867
Outcome SetPortFeature(_In_ PURB Urb)
Definition: rootports.cpp:1603
VOID UpdatePortReg(_In_ Port *P, _In_ ULONG Offset, _In_ ULONG Clear, _In_ ULONG Set)
Definition: rootports.cpp:472
NTSTATUS FillSpeeds(_In_ const Port *P, _Inout_ PROOTHUB_30PORT_INFO_EX Entry) const
Definition: rootports.cpp:1991
ULONG UpdatePortScLocked(_In_ Port *P, _In_ ULONG Keep, _In_ ULONG Set)
Definition: rootports.cpp:448
PLIST_ENTRY Entry
Definition: devhcd.cpp:1262
_In_ HANDLE _In_ CONST PDXGKMDT_OPM_GET_INFO_PARAMETERS Parameters
Definition: dispmprt.h:321
_Check_return_ _In_ DXGK_EVENT_TYPE _In_ ULONG Event
Definition: dispmprt.h:1287
#define P(row, col)
ULONG KSPIN_LOCK
Definition: env_spec_w32.h:72
_In_ ULONG PortNumber
Definition: hubucx.h:272
static void Clear(void)
Definition: treeview.c:388
#define _Inout_
Definition: no_sal2.h:162
#define _Out_
Definition: no_sal2.h:160
#define _In_
Definition: no_sal2.h:158
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
static BOOL Set
Definition: pageheap.c:10
long LONG
Definition: pedump.c:60
unsigned short USHORT
Definition: pedump.c:61
BOOLEAN IntegratedHub
Definition: rootports.h:95
ULONG ResumeOverrideMs
Definition: rootports.h:86
BOOLEAN HighSpeedOnly
Definition: rootports.h:94
KSPIN_LOCK Lock
Definition: rootports.h:79
KTIMER ResumeTimer
Definition: rootports.h:80
LONG ResumeOverrideCount
Definition: rootports.h:85
BOOLEAN ResumeHandled
Definition: rootports.h:97
BOOLEAN Removable
Definition: rootports.h:96
BOOLEAN TimerReady
Definition: rootports.h:100
UCHAR LpmCapabilities
Definition: rootports.h:91
BOOLEAN LpmDirty
Definition: rootports.h:98
XhciRootHub * Hub
Definition: rootports.h:82
BOOLEAN LpmEnabled
Definition: rootports.h:99
Definition: ketypes.h:767
Definition: usb.h:565
unsigned char UCHAR
Definition: typedefs.h:53
unsigned char * PBOOLEAN
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFDEVICE _In_ PUCX_CONTROLLER_CONFIG _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ UCXCONTROLLER * Controller
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFREQUEST Request
_In_opt_ PUSB_CONFIGURATION_DESCRIPTOR _Inout_ PUSBD_INTERFACE_LIST_ENTRY _Outptr_ PURB * Urb
Definition: usbdlib.h:333
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413
_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