ReactOS 0.4.17-dev-1281-g065abb3
UcxController Class Reference

#include <hostctl.h>

Collaboration diagram for UcxController:

Public Member Functions

VOID NeedsReset ()
 
VOID ResetComplete (_In_ PUCX_CONTROLLER_RESET_COMPLETE_INFO Info)
 
VOID SetFailed ()
 
NTSTATUS SetIdStrings (_In_ PUNICODE_STRING Manufacturer, _In_ PUNICODE_STRING ModelName, _In_ PUNICODE_STRING ModelNumber)
 
VOID NotifyTransportCharacteristicsChange (_In_ PUCX_CONTROLLER_TRANSPORT_CHARACTERISTICS Characteristics)
 
BOOLEAN BlockReset ()
 
VOID UnblockReset ()
 
VOID MarkResetInProgress ()
 
VOID MarkResetFinished ()
 
BOOLEAN IsResetInProgress () const
 
BOOLEAN HasFailed () const
 
NTSTATUS GetCurrentFrameNumber (_Out_ PULONG FrameNumber)
 
BOOLEAN QueryClearTtBufferOnCancel ()
 
BOOLEAN QueryStreamsSupported ()
 
VOID PostResetEvent (_In_ CrEvent Event)
 
VOID PrepareDevicesForReset ()
 
VOID NotifyDevicesResetDone ()
 
VOID PrepareForResetOperationDone ()
 
VOID WalkDevices (_In_ PFN_UCX_DEVICE_VISITOR Visitor, _In_opt_ PVOID Context, _In_ BOOLEAN IncludeDisconnected)
 
VOID Address0Release (_In_ UCXUSBDEVICE Hub)
 
NTSTATUS StopIdle (_Inout_ PUCXHUB_STOP_IDLE_CONTEXT Context)
 
VOID ResumeIdle (_Inout_ PUCXHUB_STOP_IDLE_CONTEXT Context)
 
VOID GetInfo (_Out_ PVOID Info, _In_ BOOLEAN Grown)
 
 _IRQL_requires_ (PASSIVE_LEVEL) NTSTATUS EnableForwardProgress(_In_ PUCXHUB_FORWARD_PROGRESS_INFO Info)
 
VOID QueueOnWorkerThread (_In_ UcxWorkItem *WorkItem)
 
BOOLEAN HasWorkerThread () const
 
PFN_UCX_HCD_GET_BANDWIDTH_INFORMATION HcdGetBandwidthInformation () const
 
PFN_UCX_HCD_ENABLE_FORWARD_PROGRESS HcdEnableForwardProgress () const
 
PFN_UCX_HCD_GET_DUMP_DATA HcdGetDumpData () const
 
PFN_UCX_HCD_FREE_DUMP_DATA HcdFreeDumpData () const
 

Static Public Member Functions

static _Must_inspect_result_ NTSTATUS Create (_In_ PUCX_DRIVER_GLOBALS Globals, _In_ WDFDEVICE Device, _In_ PUCX_CONTROLLER_CONFIG Config, _In_opt_ PWDF_OBJECT_ATTRIBUTES Attributes, _Out_ UCXCONTROLLER *Controller)
 
static UcxController * FromHandle (_In_ UCXCONTROLLER Handle)
 
static UcxController * FromFdo (_In_ WDFDEVICE Fdo)
 

Public Attributes

UCXCONTROLLER m_Handle
 
WDFDEVICE m_Fdo
 
UCX_CONTROLLER_CONFIG m_Config
 
LIST_ENTRY m_DriverListEntry
 
WDFQUEUE m_Address0Queue
 
WDFQUEUE m_DeviceMgmtQueue
 
WDFQUEUE m_TreePurgeQueue
 
WDFQUEUE m_PendDuringResetQueue
 
WDFQUEUE m_DefaultQueue
 
WDFSTRING m_HostControllerInterfaceName
 
UcxRootHub * m_RootHub
 
DEVICE_CAPABILITIES m_HcCaps
 
IO_CSQ m_AbortPipeCsq
 
KSPIN_LOCK m_AbortPipeCsqLock
 
KSPIN_LOCK m_TopologyLock
 
ULONG m_ChildDeviceCount
 
ULONG m_ChildEndpointCount
 
ControllerResetMachine m_ResetMachine
 
BOOLEAN m_ResetMachineReady
 
UcxWorkItem * m_ResetMachineWorkItem
 
KEVENT m_RootHubMayExitD0
 
KEVENT m_ResetCompleteProcessed
 
LONG m_DeviceContextsLost
 
LONG m_RootHubResetSeen
 
BOOLEAN m_WaitOnResetComplete
 
BOOLEAN m_RootHubInD0
 
KSPIN_LOCK m_ResetLock
 
ULONG m_ResetGeneration
 
LONG m_ResetBlockCount
 
BOOLEAN m_ResetInProgress
 
BOOLEAN m_ResetInitiated
 
LONG m_Failed
 
LONG m_PendingPrepareForReset
 
ULONG m_CachedFrameNumber
 
ULONG m_SyntheticFrame
 
BOOLEAN m_DriverVerifierEnabled
 
BOOLEAN m_ClearTtBufferOnAsyncCancel
 
KSPIN_LOCK m_WorkerLock
 
LIST_ENTRY m_WorkerItems
 
PKTHREAD m_WorkerThread
 
KEVENT m_WorkerWake
 
BOOLEAN m_WorkerParked
 
BOOLEAN m_WorkerExit
 
KMUTEX m_ForwardProgressMutex
 
BOOLEAN m_HcdReservedIoReady
 
LONG m_UsbdInterfaceCount
 
WDFREQUEST m_PendingTreePurge
 
LONG m_PendingTreePurgeEndpoints
 
UNICODE_STRING m_ManufacturerName
 
UNICODE_STRING m_ModelName
 
UNICODE_STRING m_ModelNumber
 

Private Member Functions

NTSTATUS Initialize (_In_ PUCX_DRIVER_GLOBALS Globals, _In_ WDFDEVICE Fdo, _In_ const UCX_CONTROLLER_CONFIG *Config)
 
NTSTATUS CreateQueues ()
 
NTSTATUS QueryHcCapabilities ()
 
NTSTATUS RegisterWmi ()
 
VOID Destroy ()
 
NTSTATUS StartWorkerThread ()
 

Static Private Attributes

static EVT_WDF_OBJECT_CONTEXT_DESTROY EvtDestroy
 
static KSTART_ROUTINE WorkerThreadRoutine
 
static UCXHUB_WORKITEM_ROUTINE ResetMachinePassiveRoutine
 

Friends

class ControllerResetMachine
 

Detailed Description

Definition at line 112 of file hostctl.h.

Member Function Documentation

◆ _IRQL_requires_()

UcxController::_IRQL_requires_ ( PASSIVE_LEVEL  )

◆ Address0Release()

VOID UcxController::Address0Release ( _In_ UCXUSBDEVICE  Hub)

Definition at line 647 of file hostctl.cpp.

649{
650 UcxAddress0QueueContext* Context = UcxGetAddress0QueueContext(m_Address0Queue);
651
652 /* A mismatched hub is only a checked build complaint; the release still happens */
653 NT_ASSERT(Context->OwnerHub == Hub);
655
656 Context->OwnerHub = NULL;
657 Context->OwnerDevice = NULL;
658
659 WdfIoQueueStart(m_Address0Queue);
660}
HubFdo * Hub
Definition: bootdev.cpp:261
WDFQUEUE m_Address0Queue
Definition: hostctl.h:293
#define NULL
Definition: types.h:112
_In_ PIRP _In_ PIO_COMPLETION_ROUTINE _In_ PVOID Context
Definition: kse.h:81
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:329
#define NT_ASSERT
Definition: rtlfuncs.h:3334

Referenced by UcxHubAddress0Release().

◆ BlockReset()

BOOLEAN UcxController::BlockReset ( )

Definition at line 507 of file hostctl.cpp.

508{
510
512 {
513 UnblockReset();
514 return FALSE;
515 }
516
517 return TRUE;
518}
#define InterlockedIncrement
Definition: armddk.h:53
BOOLEAN m_ResetInProgress
Definition: hostctl.h:328
LONG m_ResetBlockCount
Definition: hostctl.h:327
VOID UnblockReset()
Definition: hostctl.cpp:522
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117

Referenced by GetCurrentFrameNumber(), and UcxRootHub::PortChanged().

◆ Create()

_Must_inspect_result_ NTSTATUS UcxController::Create ( _In_ PUCX_DRIVER_GLOBALS  Globals,
_In_ WDFDEVICE  Device,
_In_ PUCX_CONTROLLER_CONFIG  Config,
_In_opt_ PWDF_OBJECT_ATTRIBUTES  Attributes,
_Out_ UCXCONTROLLER *  Controller 
)
static

Definition at line 41 of file hostctl.cpp.

47{
48 UCX_CONTROLLER_CONFIG FullConfig;
49 WDF_OBJECT_ATTRIBUTES FdoAttributes;
50 WDF_OBJECT_ATTRIBUTES UcxAttributes;
52 UcxFdoContext* FdoContext;
56
57 PAGED_CODE();
58
60 {
61 DPRINT1("Controller create rejected, config %p size %lu\n", Config, Config != NULL ? Config->Size : 0);
63 }
64
65 /* The two dump callbacks come as a pair */
66 if ((Config->Reserved3 == NULL) != (Config->Reserved4 == NULL))
67 {
68 DPRINT1("Controller create rejected, only one dump callback given\n");
70 }
71
72 if (Attributes != NULL && Attributes->ParentObject != NULL)
73 {
74 DPRINT1("Controller create rejected, HCD attributes name a parent\n");
76 }
77
78 /* Older configs are upgraded: fields the HCD did not know about stay zero */
79 UCX_CONTROLLER_CONFIG_INIT(&FullConfig, "");
80 RtlCopyMemory(&FullConfig, Config, Config->Size);
81 FullConfig.Size = sizeof(FullConfig);
82
84 Status = WdfObjectAllocateContext(Device, &FdoAttributes, (PVOID*)&FdoContext);
85 if (!NT_SUCCESS(Status))
86 {
87 DPRINT1("Controller FDO %p context allocation failed 0x%lx\n", Device, Status);
88 return Status;
89 }
90
92
95
96 /* The HCD's attributes come first when given; parent and level are UCX's choice */
97 Primary = (Attributes != NULL) ? Attributes : &UcxAttributes;
98 Primary->ParentObject = Device;
100
102 (Attributes != NULL) ? &UcxAttributes : NULL,
103 &Object);
104 if (!NT_SUCCESS(Status))
105 return Status;
106
107 Context = new (UcxGetControllerContext(Object)) UcxController();
108 Context->m_Handle = (UCXCONTROLLER)Object;
109 FdoContext->Controller = Context;
110
111 Status = Context->Initialize(Globals, Device, &FullConfig);
112 if (!NT_SUCCESS(Status))
113 {
115 return Status;
116 }
117
118 *Controller = Context->m_Handle;
119 DPRINT("Controller %p created on FDO %p, bus type %d\n", Context, Device, FullConfig.ParentBusType);
120 return STATUS_SUCCESS;
121}
#define PAGED_CODE()
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
static EVT_WDF_OBJECT_CONTEXT_DESTROY EvtDestroy
Definition: hostctl.h:377
UCXCONTROLLER m_Handle
Definition: hostctl.h:287
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
_In_ ULONG Attributes
Definition: dispmprt.h:1077
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
Status
Definition: gdiplustypes.h:24
static BOOLEAN NTAPI UcxIsAcceptedConfigSize(_In_ ULONG Size)
Definition: hostctl.cpp:31
_Must_inspect_result_ _In_ PUCXHUB_DEVICE_CREATE_INFO _Out_ UCXUSBDEVICE * Device
Definition: hubucx.h:258
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:73
UcxController * Controller
Definition: hostctl.h:100
UCX_CONTROLLER_PARENT_BUS_TYPE ParentBusType
WDFOBJECT ParentObject
Definition: wdfobject.h:130
WDF_EXECUTION_LEVEL ExecutionLevel
Definition: wdfobject.h:120
PFN_WDF_OBJECT_CONTEXT_DESTROY EvtDestroyCallback
Definition: wdfobject.h:115
#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
FORCEINLINE VOID NTAPI UCX_CONTROLLER_CONFIG_INIT(_Out_ PUCX_CONTROLLER_CONFIG Config, _In_ LPCSTR DeviceDescription)
_Must_inspect_result_ _In_ WDFDEVICE _In_ PUCX_CONTROLLER_CONFIG Config
_Must_inspect_result_ NTSTATUS NTAPI UcxCreateObjectWithTwoContexts(_In_ PWDF_OBJECT_ATTRIBUTES Primary, _In_opt_ PWDF_OBJECT_ATTRIBUTES Secondary, _Out_ WDFOBJECT *Object)
Definition: ucxutil.cpp:19
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
WdfObjectDelete(String)
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object
#define WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(_attributes, _contexttype)
Definition: wdfobject.h:170
@ WdfExecutionLevelPassive
Definition: wdfobject.h:54
FORCEINLINE NTSTATUS WdfObjectAllocateContext(_In_ WDFOBJECT Handle, _In_ PWDF_OBJECT_ATTRIBUTES ContextAttributes, _Outptr_opt_ PVOID *Context)
Definition: wdfobject.h:587

Referenced by UcxApiControllerCreate().

◆ CreateQueues()

NTSTATUS UcxController::CreateQueues ( )
private

Definition at line 58 of file hostqueues.cpp.

59{
63
64 /* One reserved request, always used when allocation fails */
67
70 1,
73 &Reserved,
75 if (!NT_SUCCESS(Status))
76 return Status;
77
78 UcxGetAddress0QueueContext(m_Address0Queue)->Controller = this;
79
84 NULL,
85 &Reserved,
87 if (!NT_SUCCESS(Status))
88 return Status;
89
92 1,
94 NULL,
95 &Reserved,
97 if (!NT_SUCCESS(Status))
98 return Status;
99
102 MAXULONG,
104 NULL,
105 NULL,
107 if (!NT_SUCCESS(Status))
108 return Status;
109
110 return UcxCreateControllerQueue(this,
112 MAXULONG,
114 NULL,
115 &Examine,
117}
WDFQUEUE m_DeviceMgmtQueue
Definition: hostctl.h:294
WDFQUEUE m_TreePurgeQueue
Definition: hostctl.h:295
UCX_CONTROLLER_CONFIG m_Config
Definition: hostctl.h:289
WDFQUEUE m_DefaultQueue
Definition: hostctl.h:297
WDFQUEUE m_PendDuringResetQueue
Definition: hostctl.h:296
EVT_WDF_IO_QUEUE_IO_INTERNAL_DEVICE_CONTROL UcxEvtTreePurgeIoInternalDeviceControl
Definition: devobj.h:362
EVT_WDF_IO_QUEUE_IO_INTERNAL_DEVICE_CONTROL UcxEvtDeviceMgmtIoInternalDeviceControl
Definition: devobj.h:361
EVT_WDF_IO_QUEUE_IO_INTERNAL_DEVICE_CONTROL UcxEvtPendDuringResetIoInternalDeviceControl
Definition: devobj.h:363
EVT_WDF_IO_QUEUE_IO_INTERNAL_DEVICE_CONTROL UcxEvtDefaultIoInternalDeviceControl
Definition: hostctl.h:398
EVT_WDF_IO_QUEUE_IO_INTERNAL_DEVICE_CONTROL UcxEvtAddress0IoInternalDeviceControl
Definition: hostctl.h:397
EVT_WDF_IO_WDM_IRP_FOR_FORWARD_PROGRESS UcxEvtDefaultQueueExamineIrp
Definition: hostctl.h:399
static NTSTATUS NTAPI UcxCreateControllerQueue(_In_ UcxController *Controller, _In_ WDF_IO_QUEUE_DISPATCH_TYPE Dispatch, _In_ ULONG PresentedRequests, _In_opt_ PFN_WDF_IO_QUEUE_IO_INTERNAL_DEVICE_CONTROL Handler, _In_opt_ PCWDF_OBJECT_CONTEXT_TYPE_INFO ContextType, _In_opt_ PWDF_IO_QUEUE_FORWARD_PROGRESS_POLICY Policy, _Out_ WDFQUEUE *Queue)
Definition: hostqueues.cpp:17
ULONG NumberOfPresentedDeviceMgmtEvtCallbacks
#define MAXULONG
Definition: typedefs.h:251
FORCEINLINE VOID WDF_IO_QUEUE_FORWARD_PROGRESS_POLICY_EXAMINE_INIT(_Out_ PWDF_IO_QUEUE_FORWARD_PROGRESS_POLICY Policy, _In_ ULONG TotalForwardProgressRequests, _In_ PFN_WDF_IO_WDM_IRP_FOR_FORWARD_PROGRESS EvtIoWdmIrpForForwardProgress)
Definition: wdfio.h:571
FORCEINLINE VOID WDF_IO_QUEUE_FORWARD_PROGRESS_POLICY_DEFAULT_INIT(_Out_ PWDF_IO_QUEUE_FORWARD_PROGRESS_POLICY Policy, _In_ ULONG TotalForwardProgressRequests)
Definition: wdfio.h:556
@ WdfIoQueueDispatchSequential
Definition: wdfio.h:78
@ WdfIoQueueDispatchParallel
Definition: wdfio.h:79
#define WDF_GET_CONTEXT_TYPE_INFO(_contexttype)
Definition: wdfobject.h:238
_Reserved_ PVOID Reserved
Definition: winddi.h:3974

Referenced by Initialize().

◆ Destroy()

VOID UcxController::Destroy ( )
private

Definition at line 364 of file hostctl.cpp.

365{
366 if (m_WorkerThread != NULL)
367 {
368 {
370
373 }
374
378 }
379
381 {
384 }
386
388
389 /* A create that failed early never linked the entry */
390 {
391 SpinLockGuard Guard(&UcxDriver.ControllerListLock);
392
394 {
396 UcxDriver.ControllerCount--;
397 }
399 }
400
402 {
405 }
406
410}
UNICODE_STRING m_ModelNumber
Definition: hostctl.h:358
LONG m_UsbdInterfaceCount
Definition: hostctl.h:349
PKTHREAD m_WorkerThread
Definition: hostctl.h:342
BOOLEAN m_WorkerExit
Definition: hostctl.h:345
KSPIN_LOCK m_WorkerLock
Definition: hostctl.h:340
UNICODE_STRING m_ModelName
Definition: hostctl.h:357
BOOLEAN m_ResetMachineReady
Definition: hostctl.h:315
UNICODE_STRING m_ManufacturerName
Definition: hostctl.h:356
KEVENT m_WorkerWake
Definition: hostctl.h:343
LIST_ENTRY m_DriverListEntry
Definition: hostctl.h:290
WDFSTRING m_HostControllerInterfaceName
Definition: hostctl.h:300
UcxWorkItem * m_ResetMachineWorkItem
Definition: hostctl.h:316
InitializeListHead & UcxDriver
Definition: driver.cpp:138
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
Definition: env_spec_w32.h:478
#define KeSetEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:476
static VOID NTAPI UcxFreeIdString(_Inout_ PUNICODE_STRING String)
Definition: hostctl.cpp:347
#define KernelMode
Definition: asm.h:38
FORCEINLINE BOOLEAN NTAPI UcxIsListEntryLinked(_In_ const LIST_ENTRY *Entry)
Definition: ucxutil.h:94
FORCEINLINE VOID NTAPI UcxClearListEntry(_Out_ PLIST_ENTRY Entry)
Definition: ucxutil.h:84
#define UCX_POOL_TAG
Definition: ucxutil.h:11
#define WdfObjectDereferenceWithTag(Handle, Tag)
Definition: wdfobject.h:829
#define IO_NO_INCREMENT
Definition: iotypes.h:598
@ Executive
Definition: ketypes.h:467
#define ObDereferenceObject
Definition: obfuncs.h:203

◆ FromFdo()

UcxController * UcxController::FromFdo ( _In_ WDFDEVICE  Fdo)
static

Definition at line 21 of file hostctl.cpp.

23{
24 return UcxGetFdoContext(Fdo)->Controller;
25}
_Must_inspect_result_ _In_ WDFDEVICE Fdo
Definition: wdffdo.h:461

Referenced by UcxEvtDefaultIoInternalDeviceControl(), UcxEvtTreePurgeIoInternalDeviceControl(), UcxEvtWmiNodeInfoQueryInstance(), and UcxHandleUserRequest().

◆ FromHandle()

UcxController * UcxController::FromHandle ( _In_ UCXCONTROLLER  Handle)
static

◆ GetCurrentFrameNumber()

NTSTATUS UcxController::GetCurrentFrameNumber ( _Out_ PULONG  FrameNumber)

Definition at line 564 of file hostctl.cpp.

566{
568 ULONG Frame;
569
571 {
572 DPRINT1("Controller %p has no frame number callback\n", this);
575 }
576
577 if (!BlockReset())
578 {
580 return STATUS_SUCCESS;
581 }
582
583 Frame = m_CachedFrameNumber;
585 UnblockReset();
586
587 if (!NT_SUCCESS(Status))
588 {
589 /* The caller still gets whatever the HCD left in the buffer */
590 DPRINT1("Controller %p frame number query failed 0x%lx\n", this, Status);
591 }
592 else if (Frame == MAXULONG)
593 {
594 /* All ones means the HCD is not in D0; report the cached frame */
595 DPRINT("Controller %p has no frame number, reporting cached frame %lu\n", this, m_CachedFrameNumber);
596 Frame = m_CachedFrameNumber;
597 }
598 else
599 {
600 m_CachedFrameNumber = Frame;
601 }
602
603 *FrameNumber = Frame;
604 return Status;
605}
BOOLEAN BlockReset()
Definition: hostctl.cpp:507
ULONG m_CachedFrameNumber
Definition: hostctl.h:333
#define STATUS_NOT_SUPPORTED
Definition: d3dkmdt.h:48
PFN_UCX_CONTROLLER_GET_CURRENT_FRAMENUMBER EvtControllerGetCurrentFrameNumber
uint32_t ULONG
Definition: typedefs.h:59
_Out_ PULONG FrameNumber
Definition: ucxcontroller.h:94

Referenced by UcxBusQueryBusTime().

◆ GetInfo()

VOID UcxController::GetInfo ( _Out_ PVOID  Info,
_In_ BOOLEAN  Grown 
)

Grown is TRUE for hubs that asked for the larger stack interface; they expect the V2 layout.

Definition at line 692 of file hostctl.cpp.

695{
698
699 if (Grown)
700 {
702
703 RtlZeroMemory(Out, sizeof(*Out));
704 Out->Type = m_Config.ParentBusType;
705 Pci = &Out->Pci;
706 Acpi = &Out->Acpi;
707 }
708 else
709 {
711
712 RtlZeroMemory(Out, sizeof(*Out));
713 Out->Type = m_Config.ParentBusType;
714 Pci = &Out->Pci;
715 Acpi = &Out->Acpi;
716 }
717
719 *Pci = m_Config.PciDeviceInfo;
721 *Acpi = m_Config.AcpiDeviceInfo;
722}
@ Out
struct _UCXHUB_CONTROLLER_INFO_V2 * PUCXHUB_CONTROLLER_INFO_V2
struct _UCXHUB_CONTROLLER_INFO * PUCXHUB_CONTROLLER_INFO
UCX_CONTROLLER_ACPI_INFORMATION AcpiDeviceInfo
UCX_CONTROLLER_PCI_INFORMATION PciDeviceInfo
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
@ UcxControllerParentBusTypePci
Definition: ucxcontroller.h:17
@ UcxControllerParentBusTypeAcpi
Definition: ucxcontroller.h:18
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:690

◆ HasFailed()

BOOLEAN UcxController::HasFailed ( ) const
inline

Definition at line 180 of file hostctl.h.

181 {
182 return m_Failed != 0;
183 }
LONG m_Failed
Definition: hostctl.h:330

◆ HasWorkerThread()

BOOLEAN UcxController::HasWorkerThread ( ) const
inline

Definition at line 255 of file hostctl.h.

256 {
257 return m_WorkerThread != NULL;
258 }

◆ HcdEnableForwardProgress()

PFN_UCX_HCD_ENABLE_FORWARD_PROGRESS UcxController::HcdEnableForwardProgress ( ) const
inline

Definition at line 269 of file hostctl.h.

270 {
271 return (PFN_UCX_HCD_ENABLE_FORWARD_PROGRESS)m_Config.Reserved2;
272 }

Referenced by _IRQL_requires_().

◆ HcdFreeDumpData()

PFN_UCX_HCD_FREE_DUMP_DATA UcxController::HcdFreeDumpData ( ) const
inline

Definition at line 281 of file hostctl.h.

282 {
283 return (PFN_UCX_HCD_FREE_DUMP_DATA)m_Config.Reserved4;
284 }

◆ HcdGetBandwidthInformation()

PFN_UCX_HCD_GET_BANDWIDTH_INFORMATION UcxController::HcdGetBandwidthInformation ( ) const
inline

Definition at line 263 of file hostctl.h.

264 {
266 }
NTSTATUS(NTAPI * PFN_UCX_HCD_GET_BANDWIDTH_INFORMATION)(_In_ UCXCONTROLLER Controller)
Definition: hostctl.h:17

◆ HcdGetDumpData()

PFN_UCX_HCD_GET_DUMP_DATA UcxController::HcdGetDumpData ( ) const
inline

Definition at line 275 of file hostctl.h.

276 {
277 return (PFN_UCX_HCD_GET_DUMP_DATA)m_Config.Reserved3;
278 }

◆ Initialize()

NTSTATUS UcxController::Initialize ( _In_ PUCX_DRIVER_GLOBALS  Globals,
_In_ WDFDEVICE  Fdo,
_In_ const UCX_CONTROLLER_CONFIG *  Config 
)
private

Definition at line 124 of file hostctl.cpp.

128{
129 PDEVICE_OBJECT FdoObject;
131
132 m_Fdo = Fdo;
133 m_Config = *Config;
135
139
140 FdoObject = WdfDeviceWdmGetDeviceObject(Fdo);
141
145
148
151
153 m_Failed = 0;
157
158 m_DriverVerifierEnabled = MmIsDriverVerifying(FdoObject->DriverObject) != 0 ||
159 (Globals->WdfDriverGlobals->DriverFlags & WdfVerifyOn) != 0;
160
162 if (!NT_SUCCESS(Status))
163 return Status;
164
173
174 Status = WdfDeviceCreateDeviceInterface(Fdo, &GUID_DEVINTERFACE_USB_HOST_CONTROLLER, NULL);
175 if (!NT_SUCCESS(Status))
176 {
177 DPRINT1("Controller %p host controller interface create failed 0x%lx\n", this, Status);
178 return Status;
179 }
180
181 {
183
185 StringAttributes.ParentObject = m_Handle;
186
188 if (!NT_SUCCESS(Status))
189 {
190 DPRINT1("Controller %p interface string create failed 0x%lx\n", this, Status);
191 return Status;
192 }
193
194 Status = WdfDeviceRetrieveDeviceInterfaceString(Fdo,
195 &GUID_DEVINTERFACE_USB_HOST_CONTROLLER,
196 NULL,
198 if (!NT_SUCCESS(Status))
199 {
200 DPRINT1("Controller %p interface name query failed 0x%lx\n", this, Status);
201 return Status;
202 }
203
204 /* Kept past the parent's cleanup; dropped in Destroy */
206 }
207
209 if (!NT_SUCCESS(Status))
210 return Status;
211
213 if (!NT_SUCCESS(Status))
214 {
215 DPRINT1("Controller %p WMI registration failed 0x%lx\n", this, Status);
216 return Status;
217 }
218
226
227 {
228 SpinLockGuard Guard(&UcxDriver.ControllerListLock);
229
230 InsertTailList(&UcxDriver.ControllerList, &m_DriverListEntry);
231 UcxDriver.ControllerCount++;
232 }
233
234 return STATUS_SUCCESS;
235}
VOID Initialize(_In_ UcxController *Controller)
Definition: crsm.cpp:80
WDFDEVICE m_Fdo
Definition: hostctl.h:288
KMUTEX m_ForwardProgressMutex
Definition: hostctl.h:346
KEVENT m_ResetCompleteProcessed
Definition: hostctl.h:319
NTSTATUS QueryHcCapabilities()
Definition: hostctl.cpp:239
BOOLEAN m_WaitOnResetComplete
Definition: hostctl.h:322
LIST_ENTRY m_WorkerItems
Definition: hostctl.h:341
ULONG m_ChildEndpointCount
Definition: hostctl.h:312
ControllerResetMachine m_ResetMachine
Definition: hostctl.h:314
KSPIN_LOCK m_AbortPipeCsqLock
Definition: hostctl.h:307
WDFREQUEST m_PendingTreePurge
Definition: hostctl.h:352
IO_CSQ m_AbortPipeCsq
Definition: hostctl.h:306
KSPIN_LOCK m_ResetLock
Definition: hostctl.h:325
KSPIN_LOCK m_TopologyLock
Definition: hostctl.h:310
BOOLEAN m_WorkerParked
Definition: hostctl.h:344
BOOLEAN m_HcdReservedIoReady
Definition: hostctl.h:347
LONG m_PendingTreePurgeEndpoints
Definition: hostctl.h:353
BOOLEAN m_DriverVerifierEnabled
Definition: hostctl.h:336
NTSTATUS RegisterWmi()
Definition: hostctl.cpp:289
KEVENT m_RootHubMayExitD0
Definition: hostctl.h:318
ULONG m_ChildDeviceCount
Definition: hostctl.h:311
NTSTATUS CreateQueues()
Definition: hostqueues.cpp:58
NTKERNELAPI NTSTATUS NTAPI IoCsqInitialize(_Out_ PIO_CSQ Csq, _In_ PIO_CSQ_INSERT_IRP CsqInsertIrp, _In_ PIO_CSQ_REMOVE_IRP CsqRemoveIrp, _In_ PIO_CSQ_PEEK_NEXT_IRP CsqPeekNextIrp, _In_ PIO_CSQ_ACQUIRE_LOCK CsqAcquireLock, _In_ PIO_CSQ_RELEASE_LOCK CsqReleaseLock, _In_ PIO_CSQ_COMPLETE_CANCELED_IRP CsqCompleteCanceledIrp)
Set up a CSQ struct to initialize the queue.
Definition: csq.c:103
LOGICAL NTAPI MmIsDriverVerifying(IN PDRIVER_OBJECT DriverObject)
Definition: drvmgmt.c:212
#define InsertTailList(ListHead, Entry)
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define KeInitializeSpinLock(sl)
Definition: env_spec_w32.h:604
IO_CSQ_REMOVE_IRP UcxCsqRemoveAbortIrp
Definition: hostctl.h:403
IO_CSQ_COMPLETE_CANCELED_IRP UcxCsqCompleteCanceledAbortIrp
Definition: hostctl.h:407
IO_CSQ_INSERT_IRP UcxCsqInsertAbortIrp
Definition: hostctl.h:402
IO_CSQ_RELEASE_LOCK UcxCsqReleaseAbortLock
Definition: hostctl.h:406
IO_CSQ_PEEK_NEXT_IRP UcxCsqPeekAbortIrp
Definition: hostctl.h:404
IO_CSQ_ACQUIRE_LOCK UcxCsqAcquireAbortLock
Definition: hostctl.h:405
#define UCXHUB_WORKITEM_NO_FLAGS
Definition: hubucx.h:211
@ NotificationEvent
@ SynchronizationEvent
VOID NTAPI KeInitializeMutex(IN PKMUTEX Mutex, IN ULONG Level)
Definition: mutex.c:67
static PUCXHUB_WORKITEM Allocate(_In_ UcxController *Controller, _In_ PDEVICE_OBJECT DeviceObject, _In_ ULONG Flags)
Definition: workitem.cpp:16
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
@ WdfVerifyOn
Definition: wdfdriver.h:53
FORCEINLINE VOID WDF_OBJECT_ATTRIBUTES_INIT(_Out_ PWDF_OBJECT_ATTRIBUTES Attributes)
Definition: wdfobject.h:147
#define WdfObjectReferenceWithTag(Handle, Tag)
Definition: wdfobject.h:806
WDF_EXTERN_C_START typedef _Must_inspect_result_ _In_opt_ PCUNICODE_STRING _In_opt_ PWDF_OBJECT_ATTRIBUTES StringAttributes
Definition: wdfstring.h:66

◆ IsResetInProgress()

BOOLEAN UcxController::IsResetInProgress ( ) const
inline

Definition at line 174 of file hostctl.h.

175 {
176 return m_ResetInProgress;
177 }

◆ MarkResetFinished()

VOID UcxController::MarkResetFinished ( )

Definition at line 551 of file hostctl.cpp.

552{
554
558
559 /* The controller's own reference comes back */
561}
BOOLEAN m_ResetInitiated
Definition: hostctl.h:329
ULONG m_ResetGeneration
Definition: hostctl.h:326

Referenced by ControllerResetMachine::MarkResetFinished().

◆ MarkResetInProgress()

VOID UcxController::MarkResetInProgress ( )

Definition at line 542 of file hostctl.cpp.

Referenced by ControllerResetMachine::MarkResetInProgress().

◆ NeedsReset()

VOID UcxController::NeedsReset ( )

Definition at line 415 of file hostctl.cpp.

416{
417 DPRINT1("Controller %p reports it needs a reset\n", this);
418 PostResetEvent(CrEvent::ControllerNeedsReset);
419}
VOID PostResetEvent(_In_ CrEvent Event)
Definition: hostctl.h:200

Referenced by UcxApiControllerNeedsReset().

◆ NotifyDevicesResetDone()

VOID UcxController::NotifyDevicesResetDone ( )

Definition at line 110 of file hostreset.cpp.

111{
112 UcxResetFanOut FanOut;
113
115 FanOut.Count = 0;
116 FanOut.MarkDeprogrammed = FALSE;
117
119 DPRINT("Controller %p reset done, notifying %lu endpoints\n", this, FanOut.Count);
120 UcxPostToCollectedEndpoints(&FanOut, EpEvent::ControllerResetDone);
121}
VOID WalkDevices(_In_ PFN_UCX_DEVICE_VISITOR Visitor, _In_opt_ PVOID Context, _In_ BOOLEAN IncludeDisconnected)
Definition: hostreset.cpp:74
static VOID NTAPI UcxPostToCollectedEndpoints(_Inout_ UcxResetFanOut *FanOut, _In_ EpEvent Event)
Definition: hostreset.cpp:55
static VOID NTAPI UcxCollectEndpointsForReset(_In_ UcxUsbDevice *Device, _In_opt_ PVOID Context)
Definition: hostreset.cpp:24
LIST_ENTRY Endpoints
Definition: hostreset.cpp:16
BOOLEAN MarkDeprogrammed
Definition: hostreset.cpp:18

Referenced by ControllerResetMachine::NotifyDevicesResetDone().

◆ NotifyTransportCharacteristicsChange()

VOID UcxController::NotifyTransportCharacteristicsChange ( _In_ PUCX_CONTROLLER_TRANSPORT_CHARACTERISTICS  Characteristics)

Definition at line 498 of file hostctl.cpp.

500{
501 UNREFERENCED_PARAMETER(Characteristics);
502}

Referenced by UcxApiControllerNotifyTransportCharacteristicsChange().

◆ PostResetEvent()

VOID UcxController::PostResetEvent ( _In_ CrEvent  Event)
inline

Definition at line 200 of file hostctl.h.

202 {
204 }
BOOLEAN SmPost(_In_ Event Ev)
Definition: smengine.h:370
_Check_return_ _In_ DXGK_EVENT_TYPE _In_ ULONG Event
Definition: dispmprt.h:1287

Referenced by NeedsReset(), PrepareDevicesForReset(), PrepareForResetOperationDone(), ResetComplete(), SetFailed(), and UnblockReset().

◆ PrepareDevicesForReset()

VOID UcxController::PrepareDevicesForReset ( )

Warns every endpoint of the reset; each acknowledges once idle.

Definition at line 86 of file hostreset.cpp.

87{
88 UcxResetFanOut FanOut;
89
91 FanOut.Count = 0;
92 FanOut.MarkDeprogrammed = TRUE;
93
95
96 /* Set before the first post so a synchronous ack cannot underflow it */
99
100 DPRINT("Controller %p preparing %lu endpoints for reset\n", this, FanOut.Count);
101
102 UcxPostToCollectedEndpoints(&FanOut, EpEvent::ControllerResetStarting);
103
104 if (FanOut.Count == 0)
105 PostResetEvent(CrEvent::DevicesReady);
106}
LONG m_PendingPrepareForReset
Definition: hostctl.h:331

Referenced by ControllerResetMachine::PrepareDevicesForReset().

◆ PrepareForResetOperationDone()

VOID UcxController::PrepareForResetOperationDone ( )

An endpoint finished preparing for the reset.

Definition at line 124 of file hostreset.cpp.

125{
127 PostResetEvent(CrEvent::DevicesReady);
128}
#define InterlockedDecrement
Definition: armddk.h:52

Referenced by EndpointMachine::AckControllerReset().

◆ QueryClearTtBufferOnCancel()

BOOLEAN UcxController::QueryClearTtBufferOnCancel ( )

Definition at line 610 of file hostctl.cpp.

611{
613
615 return FALSE;
616
618 m_Handle,
619 (PGUID)&GUID_USB_CAPABILITY_CLEAR_TT_BUFFER_ON_ASYNC_TRANSFER_CANCEL,
620 0,
621 NULL,
622 &ResultLength));
623}
PFN_UCX_CONTROLLER_QUERY_USB_CAPABILITY EvtControllerQueryUsbCapability
_In_ PGUID _In_ ULONG _Out_ PULONG ResultLength
Definition: ucxcontroller.h:83

◆ QueryHcCapabilities()

NTSTATUS UcxController::QueryHcCapabilities ( )
private

Synchronous IRP_MN_QUERY_CAPABILITIES down the FDO's stack.

Definition at line 239 of file hostctl.cpp.

240{
241 WDF_REQUEST_SEND_OPTIONS SendOptions;
244 WDFIOTARGET Target;
245 WDFREQUEST Request;
247
248 Target = WdfDeviceGetIoTarget(m_Fdo);
249
250 Status = WdfRequestCreate(WDF_NO_OBJECT_ATTRIBUTES, Target, &Request);
251 if (!NT_SUCCESS(Status))
252 {
253 DPRINT1("Controller %p capabilities request create failed 0x%lx\n", this, Status);
254 return Status;
255 }
256
257 /* PnP IRPs must start out as not supported */
259 Status = WdfRequestReuse(Request, &ReuseParams);
260 if (NT_SUCCESS(Status))
261 {
263 m_HcCaps.Size = sizeof(m_HcCaps);
264 m_HcCaps.Version = 1;
265 m_HcCaps.Address = MAXULONG;
266 m_HcCaps.UINumber = MAXULONG;
267
268 RtlZeroMemory(&Stack, sizeof(Stack));
269 Stack.MajorFunction = IRP_MJ_PNP;
270 Stack.MinorFunction = IRP_MN_QUERY_CAPABILITIES;
271 Stack.Parameters.DeviceCapabilities.Capabilities = &m_HcCaps;
272 WdfRequestWdmFormatUsingStackLocation(Request, &Stack);
273
274 /* A send that fails to go out still records its status in the request */
276 WdfRequestSend(Request, Target, &SendOptions);
277 Status = WdfRequestGetStatus(Request);
278 }
279
281
282 if (!NT_SUCCESS(Status))
283 DPRINT1("Controller %p query capabilities failed 0x%lx\n", this, Status);
284
285 return Status;
286}
#define IRP_MJ_PNP
Definition: cdrw_usr.h:52
DEVICE_CAPABILITIES m_HcCaps
Definition: hostctl.h:303
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFREQUEST Request
_Must_inspect_result_ FORCEINLINE BOOLEAN WdfRequestSend(_In_ WDFREQUEST Request, _In_ WDFIOTARGET Target, _In_opt_ PWDF_REQUEST_SEND_OPTIONS Options)
Definition: wdfrequest.h:677
_In_ WDFREQUEST _In_ PWDF_REQUEST_REUSE_PARAMS ReuseParams
Definition: wdfrequest.h:554
FORCEINLINE VOID WDF_REQUEST_SEND_OPTIONS_INIT(_Out_ PWDF_REQUEST_SEND_OPTIONS Options, _In_ ULONG Flags)
Definition: wdfrequest.h:409
@ WDF_REQUEST_SEND_OPTION_SYNCHRONOUS
Definition: wdfrequest.h:109
_In_ WDFIOTARGET Target
Definition: wdfrequest.h:306
@ WDF_REQUEST_REUSE_NO_FLAGS
Definition: wdfrequest.h:92
_In_ WDFREQUEST _In_ PIO_STACK_LOCATION Stack
Definition: wdfrequest.h:639
FORCEINLINE VOID WDF_REQUEST_REUSE_PARAMS_INIT(_Out_ PWDF_REQUEST_REUSE_PARAMS Params, _In_ ULONG Flags, _In_ NTSTATUS Status)
Definition: wdfrequest.h:364
#define WDF_NO_OBJECT_ATTRIBUTES
Definition: wdftypes.h:105
#define IRP_MN_QUERY_CAPABILITIES

Referenced by Initialize().

◆ QueryStreamsSupported()

BOOLEAN UcxController::QueryStreamsSupported ( )

Definition at line 626 of file hostctl.cpp.

627{
628 USHORT StreamCount = 0;
631
633 return FALSE;
634
636 (PGUID)&GUID_USB_CAPABILITY_STATIC_STREAMS,
637 sizeof(StreamCount),
638 &StreamCount,
639 &ResultLength);
640
641 return NT_SUCCESS(Status) && StreamCount > 0;
642}
unsigned short USHORT
Definition: pedump.c:61

Referenced by UcxHubStreamsSupported().

◆ QueueOnWorkerThread()

VOID UcxController::QueueOnWorkerThread ( _In_ UcxWorkItem *  WorkItem)

Definition at line 811 of file hostctl.cpp.

813{
815
816 InsertTailList(&m_WorkerItems, &WorkItem->ThreadQueueEntry);
818}
_In_opt_ PVOID _In_ PUCXHUB_WORKITEM WorkItem
Definition: hubucx.h:227

◆ RegisterWmi()

NTSTATUS UcxController::RegisterWmi ( )
private

Definition at line 289 of file hostctl.cpp.

290{
291 WDF_WMI_PROVIDER_CONFIG ProviderConfig;
293
294 WDF_WMI_PROVIDER_CONFIG_INIT(&ProviderConfig, &GUID_USB_WMI_NODE_INFO);
296 InstanceConfig.Register = TRUE;
297 InstanceConfig.EvtWmiInstanceQueryInstance = UcxEvtWmiNodeInfoQueryInstance;
298
300}
return WdfWmiInstanceCreate(Device, &Config, Attributes, Instance)
EVT_WDF_WMI_INSTANCE_QUERY_INSTANCE UcxEvtWmiNodeInfoQueryInstance
Definition: userreq.h:21
#define WDF_NO_HANDLE
Definition: wdftypes.h:107
FORCEINLINE VOID WDF_WMI_PROVIDER_CONFIG_INIT(_Out_ PWDF_WMI_PROVIDER_CONFIG Config, _In_ CONST GUID *Guid)
Definition: wdfwmi.h:205
FORCEINLINE VOID WDF_WMI_INSTANCE_CONFIG_INIT_PROVIDER_CONFIG(_Out_ PWDF_WMI_INSTANCE_CONFIG Config, _In_ PWDF_WMI_PROVIDER_CONFIG ProviderConfig)
Definition: wdfwmi.h:286
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_WMI_INSTANCE_CONFIG InstanceConfig
Definition: wdfwmi.h:476

Referenced by Initialize().

◆ ResetComplete()

VOID UcxController::ResetComplete ( _In_ PUCX_CONTROLLER_RESET_COMPLETE_INFO  Info)

Definition at line 422 of file hostctl.cpp.

424{
425 if (Info->UcxControllerState == UcxControllerStateLost)
427
429
430 DPRINT("Controller %p reset complete, state %d\n", this, Info->UcxControllerState);
431 PostResetEvent(CrEvent::ControllerResetDone);
432
433 /* While the root hub is out of D0 the machine releases this thread when done */
436}
LONG m_RootHubResetSeen
Definition: hostctl.h:321
LONG m_DeviceContextsLost
Definition: hostctl.h:320
@ UcxControllerStateLost
Definition: ucxcontroller.h:24

Referenced by UcxApiControllerResetComplete().

◆ ResumeIdle()

VOID UcxController::ResumeIdle ( _Inout_ PUCXHUB_STOP_IDLE_CONTEXT  Context)

Definition at line 680 of file hostctl.cpp.

682{
683 if (!Context->PowerReferenceAcquired)
684 return;
685
687 Context->PowerReferenceAcquired = FALSE;
688}
#define WdfDeviceResumeIdle(Device)
Definition: wdfdevice.h:1983

Referenced by UcxHubAllowControllerIdle().

◆ SetFailed()

VOID UcxController::SetFailed ( )

Definition at line 439 of file hostctl.cpp.

440{
441 if (InterlockedCompareExchange(&m_Failed, 1, 0) != 0)
442 return;
443
444 DPRINT1("Controller %p marked failed by the HCD\n", this);
445
446 /* Tear the tree down first so the purges recurse on one stack */
448
449 PostResetEvent(CrEvent::ControllerLost);
450}
UcxRootHub * m_RootHub
Definition: hostctl.h:302
UcxUsbDevice * Device() const
Definition: rhub.h:71
VOID DisconnectPort(_In_ ULONG PortNumber)
Definition: devobj.cpp:440
#define InterlockedCompareExchange
Definition: interlocked.h:119

Referenced by UcxApiControllerSetFailed().

◆ SetIdStrings()

NTSTATUS UcxController::SetIdStrings ( _In_ PUNICODE_STRING  Manufacturer,
_In_ PUNICODE_STRING  ModelName,
_In_ PUNICODE_STRING  ModelNumber 
)

Definition at line 453 of file hostctl.cpp.

457{
459
460 /* Only a non empty manufacturer counts as already set */
461 if (m_ManufacturerName.Length != 0)
462 {
463 DPRINT1("Controller %p ID strings already set\n", this);
465 }
466
467 if (!UcxIsValidIdString(Manufacturer) || !UcxIsValidIdString(ModelName) || !UcxIsValidIdString(ModelNumber))
468 {
469 DPRINT1("Controller %p ID strings malformed\n", this);
471 }
472
473 /* An earlier call with an empty manufacturer may have left copies behind */
477
478 Status = UcxCopyIdString(Manufacturer, &m_ManufacturerName);
479 if (NT_SUCCESS(Status))
480 Status = UcxCopyIdString(ModelName, &m_ModelName);
481 if (NT_SUCCESS(Status))
482 Status = UcxCopyIdString(ModelNumber, &m_ModelNumber);
483
484 if (!NT_SUCCESS(Status))
485 {
486 DPRINT1("Controller %p ID string copy failed 0x%lx\n", this, Status);
490 return Status;
491 }
492
493 return STATUS_SUCCESS;
494}
static BOOLEAN NTAPI UcxIsValidIdString(_In_opt_ PCUNICODE_STRING String)
Definition: hostctl.cpp:306
static NTSTATUS NTAPI UcxCopyIdString(_In_ PCUNICODE_STRING Source, _Out_ PUNICODE_STRING Copy)
Definition: hostctl.cpp:322

Referenced by UcxApiControllerSetIdStrings().

◆ StartWorkerThread()

NTSTATUS UcxController::StartWorkerThread ( )
private

Definition at line 772 of file hostctl.cpp.

773{
775 HANDLE ThreadHandle;
777
779
780 Status = PsCreateSystemThread(&ThreadHandle,
783 NULL,
784 NULL,
786 this);
787 if (!NT_SUCCESS(Status))
788 {
789 DPRINT1("Controller %p system thread create failed 0x%lx\n", this, Status);
790 return Status;
791 }
792
793 Status = ObReferenceObjectByHandle(ThreadHandle,
794 0,
795 NULL,
798 NULL);
799 ZwClose(ThreadHandle);
800
801 if (!NT_SUCCESS(Status))
802 {
803 DPRINT1("Controller %p system thread reference failed 0x%lx\n", this, Status);
805 }
806
807 return Status;
808}
static KSTART_ROUTINE WorkerThreadRoutine
Definition: hostctl.h:386
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
ZwClose(Handle)
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:115
#define THREAD_ALL_ACCESS
Definition: nt_native.h:1342
NTSTATUS NTAPI PsCreateSystemThread(OUT PHANDLE ThreadHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, IN HANDLE ProcessHandle, IN PCLIENT_ID ClientId, IN PKSTART_ROUTINE StartRoutine, IN PVOID StartContext)
Definition: thread.c:626
NTSTATUS NTAPI ObReferenceObjectByHandle(IN HANDLE Handle, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode, OUT PVOID *Object, OUT POBJECT_HANDLE_INFORMATION HandleInformation OPTIONAL)
Definition: obref.c:493
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231

Referenced by _IRQL_requires_().

◆ StopIdle()

NTSTATUS UcxController::StopIdle ( _Inout_ PUCXHUB_STOP_IDLE_CONTEXT  Context)

Definition at line 663 of file hostctl.cpp.

665{
667
668 PAGED_CODE();
669
671 if (NT_SUCCESS(Status))
672 Context->PowerReferenceAcquired = TRUE;
673 else
674 DPRINT1("Controller %p stop idle failed 0x%lx\n", this, Status);
675
676 return Status;
677}
#define WdfDeviceStopIdle(Device, WaitForD0)
Definition: wdfdevice.h:1977

Referenced by UcxHubBlockControllerIdle().

◆ UnblockReset()

VOID UcxController::UnblockReset ( )

Drops a reset reference; the last one during a reset tells the machine once.

Definition at line 522 of file hostctl.cpp.

523{
524 ULONG Generation = m_ResetGeneration;
525
527 return;
528
529 {
531
532 if (m_ResetInitiated || Generation != m_ResetGeneration)
533 return;
534
536 }
537
538 PostResetEvent(CrEvent::ResetBlocksCleared);
539}

Referenced by BlockReset(), ControllerResetMachine::DropResetBlock(), GetCurrentFrameNumber(), and UcxRootHub::PortChanged().

◆ WalkDevices()

VOID UcxController::WalkDevices ( _In_ PFN_UCX_DEVICE_VISITOR  Visitor,
_In_opt_ PVOID  Context,
_In_ BOOLEAN  IncludeDisconnected 
)

Definition at line 74 of file hostreset.cpp.

78{
80
81 m_RootHub->Device()->WalkSubtree(Visitor, Context, IncludeDisconnected);
82}
VOID WalkSubtree(_In_ PFN_UCX_DEVICE_VISITOR Visitor, _In_opt_ PVOID Context, _In_ BOOLEAN IncludeDisconnected)
Definition: devobj.cpp:396

Referenced by NotifyDevicesResetDone(), and PrepareDevicesForReset().

Friends And Related Function Documentation

◆ ControllerResetMachine

Definition at line 391 of file hostctl.h.

Member Data Documentation

◆ EvtDestroy

VOID UcxController::EvtDestroy
staticprivate

Definition at line 377 of file hostctl.h.

Referenced by Create().

◆ m_AbortPipeCsq

IO_CSQ UcxController::m_AbortPipeCsq

◆ m_AbortPipeCsqLock

KSPIN_LOCK UcxController::m_AbortPipeCsqLock

Definition at line 307 of file hostctl.h.

Referenced by Initialize().

◆ m_Address0Queue

WDFQUEUE UcxController::m_Address0Queue

Definition at line 293 of file hostctl.h.

Referenced by Address0Release(), and CreateQueues().

◆ m_CachedFrameNumber

ULONG UcxController::m_CachedFrameNumber

Definition at line 333 of file hostctl.h.

Referenced by GetCurrentFrameNumber().

◆ m_ChildDeviceCount

ULONG UcxController::m_ChildDeviceCount

Definition at line 311 of file hostctl.h.

Referenced by UcxRootHub::Create(), UcxUsbDevice::Create(), and Initialize().

◆ m_ChildEndpointCount

ULONG UcxController::m_ChildEndpointCount

Definition at line 312 of file hostctl.h.

Referenced by Initialize().

◆ m_ClearTtBufferOnAsyncCancel

BOOLEAN UcxController::m_ClearTtBufferOnAsyncCancel

Definition at line 337 of file hostctl.h.

Referenced by UcxEndpoint::Initialize().

◆ m_Config

◆ m_DefaultQueue

WDFQUEUE UcxController::m_DefaultQueue

Definition at line 297 of file hostctl.h.

Referenced by CreateQueues().

◆ m_DeviceContextsLost

LONG UcxController::m_DeviceContextsLost

Definition at line 320 of file hostctl.h.

Referenced by UcxRootHub::FinishPortResetRequest(), and ResetComplete().

◆ m_DeviceMgmtQueue

WDFQUEUE UcxController::m_DeviceMgmtQueue

Definition at line 294 of file hostctl.h.

Referenced by CreateQueues().

◆ m_DriverListEntry

LIST_ENTRY UcxController::m_DriverListEntry

Definition at line 290 of file hostctl.h.

Referenced by Destroy(), and Initialize().

◆ m_DriverVerifierEnabled

BOOLEAN UcxController::m_DriverVerifierEnabled

Definition at line 336 of file hostctl.h.

Referenced by Initialize(), and UcxStaticStreams::SetStreamInfo().

◆ m_Failed

LONG UcxController::m_Failed

Definition at line 330 of file hostctl.h.

Referenced by HasFailed(), Initialize(), and SetFailed().

◆ m_Fdo

WDFDEVICE UcxController::m_Fdo

◆ m_ForwardProgressMutex

KMUTEX UcxController::m_ForwardProgressMutex

Definition at line 346 of file hostctl.h.

Referenced by _IRQL_requires_(), and Initialize().

◆ m_Handle

◆ m_HcCaps

DEVICE_CAPABILITIES UcxController::m_HcCaps

Definition at line 303 of file hostctl.h.

Referenced by UcxRootHub::BuildPowerCapabilities(), and QueryHcCapabilities().

◆ m_HcdReservedIoReady

BOOLEAN UcxController::m_HcdReservedIoReady

Definition at line 347 of file hostctl.h.

Referenced by _IRQL_requires_(), and Initialize().

◆ m_HostControllerInterfaceName

WDFSTRING UcxController::m_HostControllerInterfaceName

Definition at line 300 of file hostctl.h.

Referenced by Destroy(), and Initialize().

◆ m_ManufacturerName

UNICODE_STRING UcxController::m_ManufacturerName

Definition at line 356 of file hostctl.h.

Referenced by Destroy(), and SetIdStrings().

◆ m_ModelName

UNICODE_STRING UcxController::m_ModelName

Definition at line 357 of file hostctl.h.

Referenced by Destroy(), and SetIdStrings().

◆ m_ModelNumber

UNICODE_STRING UcxController::m_ModelNumber

Definition at line 358 of file hostctl.h.

Referenced by Destroy(), and SetIdStrings().

◆ m_PendDuringResetQueue

◆ m_PendingPrepareForReset

LONG UcxController::m_PendingPrepareForReset

Definition at line 331 of file hostctl.h.

Referenced by PrepareDevicesForReset(), and PrepareForResetOperationDone().

◆ m_PendingTreePurge

WDFREQUEST UcxController::m_PendingTreePurge

Definition at line 352 of file hostctl.h.

Referenced by Initialize().

◆ m_PendingTreePurgeEndpoints

LONG UcxController::m_PendingTreePurgeEndpoints

Definition at line 353 of file hostctl.h.

Referenced by Initialize().

◆ m_ResetBlockCount

LONG UcxController::m_ResetBlockCount

Definition at line 327 of file hostctl.h.

Referenced by BlockReset(), Initialize(), MarkResetFinished(), and UnblockReset().

◆ m_ResetCompleteProcessed

KEVENT UcxController::m_ResetCompleteProcessed

◆ m_ResetGeneration

ULONG UcxController::m_ResetGeneration

Definition at line 326 of file hostctl.h.

Referenced by MarkResetFinished(), and UnblockReset().

◆ m_ResetInitiated

BOOLEAN UcxController::m_ResetInitiated

Definition at line 329 of file hostctl.h.

Referenced by MarkResetFinished(), MarkResetInProgress(), and UnblockReset().

◆ m_ResetInProgress

BOOLEAN UcxController::m_ResetInProgress

Definition at line 328 of file hostctl.h.

Referenced by BlockReset(), IsResetInProgress(), MarkResetFinished(), and MarkResetInProgress().

◆ m_ResetLock

KSPIN_LOCK UcxController::m_ResetLock

Definition at line 325 of file hostctl.h.

Referenced by Initialize(), MarkResetFinished(), MarkResetInProgress(), and UnblockReset().

◆ m_ResetMachine

ControllerResetMachine UcxController::m_ResetMachine

Definition at line 314 of file hostctl.h.

Referenced by Initialize(), and PostResetEvent().

◆ m_ResetMachineReady

BOOLEAN UcxController::m_ResetMachineReady

Definition at line 315 of file hostctl.h.

Referenced by Destroy(), and Initialize().

◆ m_ResetMachineWorkItem

UcxWorkItem* UcxController::m_ResetMachineWorkItem

Definition at line 316 of file hostctl.h.

Referenced by Destroy(), Initialize(), and ControllerResetMachine::QueuePassiveWork().

◆ m_RootHub

◆ m_RootHubInD0

BOOLEAN UcxController::m_RootHubInD0

Definition at line 323 of file hostctl.h.

Referenced by UcxEndpoint::CloseStaticStreams().

◆ m_RootHubMayExitD0

KEVENT UcxController::m_RootHubMayExitD0

Definition at line 318 of file hostctl.h.

Referenced by ControllerResetMachine::AllowRootHubPowerDown(), and Initialize().

◆ m_RootHubResetSeen

LONG UcxController::m_RootHubResetSeen

Definition at line 321 of file hostctl.h.

Referenced by UcxRootHub::FinishPortResetRequest(), and ResetComplete().

◆ m_SyntheticFrame

ULONG UcxController::m_SyntheticFrame

Definition at line 334 of file hostctl.h.

◆ m_TopologyLock

◆ m_TreePurgeQueue

WDFQUEUE UcxController::m_TreePurgeQueue

Definition at line 295 of file hostctl.h.

Referenced by CreateQueues().

◆ m_UsbdInterfaceCount

LONG UcxController::m_UsbdInterfaceCount

Definition at line 349 of file hostctl.h.

Referenced by Destroy(), and UcxUsbdHandle::Unregister().

◆ m_WaitOnResetComplete

◆ m_WorkerExit

BOOLEAN UcxController::m_WorkerExit

Definition at line 345 of file hostctl.h.

Referenced by Destroy().

◆ m_WorkerItems

LIST_ENTRY UcxController::m_WorkerItems

Definition at line 341 of file hostctl.h.

Referenced by Initialize(), and QueueOnWorkerThread().

◆ m_WorkerLock

KSPIN_LOCK UcxController::m_WorkerLock

Definition at line 340 of file hostctl.h.

Referenced by Destroy(), Initialize(), and QueueOnWorkerThread().

◆ m_WorkerParked

BOOLEAN UcxController::m_WorkerParked

Definition at line 344 of file hostctl.h.

Referenced by Initialize().

◆ m_WorkerThread

PKTHREAD UcxController::m_WorkerThread

Definition at line 342 of file hostctl.h.

Referenced by _IRQL_requires_(), Destroy(), HasWorkerThread(), and StartWorkerThread().

◆ m_WorkerWake

KEVENT UcxController::m_WorkerWake

Definition at line 343 of file hostctl.h.

Referenced by Destroy(), Initialize(), and QueueOnWorkerThread().

◆ ResetMachinePassiveRoutine

VOID NTAPI UcxController::ResetMachinePassiveRoutine
staticprivate

Definition at line 389 of file hostctl.h.

Referenced by ControllerResetMachine::QueuePassiveWork().

◆ WorkerThreadRoutine

VOID NTAPI UcxController::WorkerThreadRoutine
staticprivate

Runs work items the worker pool could not take, so paging I/O keeps moving.

Definition at line 386 of file hostctl.h.

Referenced by StartWorkerThread().


The documentation for this class was generated from the following files: