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

Go to the source code of this file.

Macros

#define NDEBUG
 
#define HUB_ROOT_PORT_MAX_SPEEDS   48
 
#define HUB_FORWARD_PROGRESS_CONTROL   4096
 
#define HUB_INTERFACE_CLASS   9
 
#define HUB_PROTOCOL_MULTI_TT   2
 

Functions

static VOID NTAPI HubSendUcxIoctl (_In_ HubFdo *Hub, _In_ WDFIOTARGET Target, _In_ ULONG IoControlCode, _In_ PVOID Payload, _In_ WDFREQUEST Request, _In_ PFN_WDF_REQUEST_COMPLETION_ROUTINE Completion)
 
static NTSTATUS NTAPI HubCreateUcxRequest (_In_ HubFdo *Hub, _In_ WDFIOTARGET Target, _Out_ WDFREQUEST *Request)
 
static VOID NTAPI HubIoctlComplete (_In_ WDFREQUEST Request, _In_ WDFIOTARGET Target, _In_ PWDF_REQUEST_COMPLETION_PARAMS Params, _In_ WDFCONTEXT Context)
 
static VOID NTAPI HubRoot20PortsComplete (_In_ WDFREQUEST Request, _In_ WDFIOTARGET Target, _In_ PWDF_REQUEST_COMPLETION_PARAMS Params, _In_ WDFCONTEXT Context)
 
static VOID NTAPI HubRoot30PortsComplete (_In_ WDFREQUEST Request, _In_ WDFIOTARGET Target, _In_ PWDF_REQUEST_COMPLETION_PARAMS Params, _In_ WDFCONTEXT Context)
 
static VOID NTAPI HubControllerHubInfoComplete (_In_ WDFREQUEST Request, _In_ WDFIOTARGET Target, _In_ PWDF_REQUEST_COMPLETION_PARAMS Params, _In_ WDFCONTEXT Context)
 
static VOID NTAPI HubRootHubInfoComplete (_In_ WDFREQUEST Request, _In_ WDFIOTARGET Target, _In_ PWDF_REQUEST_COMPLETION_PARAMS Params, _In_ WDFCONTEXT Context)
 
static BOOLEAN NTAPI HubHasMultiTtInterface (_In_ PUSB_CONFIGURATION_DESCRIPTOR Config)
 
 _IRQL_requires_ (PASSIVE_LEVEL) VOID NTAPI HubRequestReservedIo(_In_ HubFdo *Hub)
 Sends a synchronous IOCTL to the specified device object.
 

Variables

static EVT_WDF_REQUEST_COMPLETION_ROUTINE HubRootHubInfoComplete
 
static EVT_WDF_REQUEST_COMPLETION_ROUTINE HubIoctlComplete
 
static EVT_WDF_REQUEST_COMPLETION_ROUTINE HubRoot20PortsComplete
 
static EVT_WDF_REQUEST_COMPLETION_ROUTINE HubRoot30PortsComplete
 
static EVT_WDF_REQUEST_COMPLETION_ROUTINE HubControllerHubInfoComplete
 

Macro Definition Documentation

◆ HUB_FORWARD_PROGRESS_CONTROL

#define HUB_FORWARD_PROGRESS_CONTROL   4096

Definition at line 17 of file ucxlink.cpp.

◆ HUB_INTERFACE_CLASS

#define HUB_INTERFACE_CLASS   9

Definition at line 20 of file ucxlink.cpp.

◆ HUB_PROTOCOL_MULTI_TT

#define HUB_PROTOCOL_MULTI_TT   2

Definition at line 21 of file ucxlink.cpp.

◆ HUB_ROOT_PORT_MAX_SPEEDS

#define HUB_ROOT_PORT_MAX_SPEEDS   48

Definition at line 14 of file ucxlink.cpp.

◆ NDEBUG

#define NDEBUG

Definition at line 10 of file ucxlink.cpp.

Function Documentation

◆ _IRQL_requires_()

_IRQL_requires_ ( PASSIVE_LEVEL  )

Sends a synchronous IOCTL to the specified device object.

Parameters
[in]IoControlCodeThe IOCTL to send to the device.
[in]DeviceObjectPointer to the device object that will handle the IOCTL.
[in]InputBufferOptional pointer to a buffer containing input data for the IOCTL. When specified, the buffer should be at least of InputBufferLength size.
[in]InputBufferLengthSize in bytes, of the buffer pointed by InputBuffer.
[out]OutputBufferOptional pointer to a buffer that will receive output data from the IOCTL. When specified, the buffer should be at least of OutputBufferLength size.
[in]OutputBufferLengthSize in bytes, of the buffer pointed by OutputBuffer.
[in]FileObjectOptional pointer to a file object that may be necessary for the IOCTL.
Returns
An NTSTATUS code indicating success or failure of this function.
Note
Must be called at PASSIVE_LEVEL with all APCs enabled.

Nothing is found unless the PCI bus driver publishes the properties.

The root hub name without its prefix; NULL when the PDO has no name.

Grows a private buffer to what the helper asks for.

Lets KMDF handle the IRP, then hands it back here still uncompleted.

Waits for the device machine to answer a PnP or power event; returns the PnP status.

Deletes the UCX endpoints of the disabled pipes, then the interface record.

One 4 byte value; the registry type is not checked.

Reread whenever user experience settings change; the open status is returned.

Sends a synchronous IOCTL to the specified device object.

STATUS_SUCCESS when the caller's token is an administrator's.

Sends a synchronous IOCTL to the specified device object.

Reads one value of a walk. A missing value only clears Present; FALSE means stop.

Reads up to Size bytes of a value into a zeroed buffer; the type is not checked.

Writes a REG_BINARY value into the device's usbflags subkey.

Sets or clears ExtPropertiesInstalled from ExtPropDescSemaphore in the hardware key.

Fails only when a port cannot be bound to the USB4 host router its ACPI node names.

Assigns device, hardware, compatible, container and instance ids to a new child PDO.

Answers IRP_MN_QUERY_DEVICE_TEXT on a child PDO; always completes the IRP.

Takes the connector map lock, needed around HubConnectorFindCompanion.

Device hardware key values read at PDO prepare hardware.

Saves the MS OS 2.0 set info in usbflags when the set asks for alternate enumeration.

MsOs20Flags and EnumerationRetryCount, written at PDO start.

Rereads the UXD record; UpdateRequired says whether the device id changes.

Replacement PnP id of a UXD reserved device, or an empty String. Always succeeds.

Telemetry values under the device's Ceip subkey.

BootPathSurpriseRemovalCount + 1.

This machine's dual role features for a dual role partner.

Tells UCX the WDM PDO of the device; call right after the child PDO was created.

IOCTL_INTERNAL_USB_GET_CONTROLLER_NAME: Argument1 and its length Argument2.

IOCTL_INTERNAL_USB_GET_BUS_INFO for the device: the 16 byte USB_BUS_NOTIFICATION at Argument1.

Registers the GUID_USB_WMI_NODE_INFO instance of a child PDO (not for hubs or composites).

Registers the boot device surprise removal event on an external, non hub boot PDO.

Fires the boot device surprise removal event, if one is registered.

Sends a synchronous IOCTL to the specified device object.

Publishes "<port>#<host>" for every bound port on the hub's PDO. QUIRK: with no bound port an older value is left in place.

Binds USB 3 ports to the host routers named by the USB4 DVSEC; an earlier ACPI mapping wins.

Waits on a PnP handshake event with no timeout, printing a watchdog line every minute so a stuck machine is visible in the debugger.

Copies up to Size bytes of a device property; a failed query leaves the field zero.

Only the controller name length is real; both bandwidth fields read 0.

The answer overlays a USB_HUB_NAME on TotalSize, so TotalSize comes back as the name length + 4.

Evaluates a method without arguments into Output.

Definition at line 481 of file ucxlink.cpp.

486{
490
491 PAGED_CODE();
492
493 RtlZeroMemory(&Info, sizeof(Info));
494 Info.Version = 1;
495 Info.Size = sizeof(Info);
496 Info.Device = Hub->UsbDevice();
497 Info.ControlPipeMaxTransferSize = HUB_FORWARD_PROGRESS_CONTROL;
498 Info.NumberOfPipes = 1;
499 Info.Pipes[0].PipeHandle = Hub->m_Interrupt.Pipe;
500 Info.Pipes[0].ReservedTransferLimit = Hub->IsRootHub() ? Hub->m_Interrupt.BitmapMaxBytes
502
504
505 Status = WdfIoTargetSendInternalIoctlOthersSynchronously(Hub->m_RootHubTarget,
506 NULL,
508 &Argument,
509 NULL,
510 NULL,
511 NULL,
512 NULL);
513 if (!NT_SUCCESS(Status))
514 DPRINT1("Hub %p forward progress notification failed 0x%lx\n", Hub, Status);
515}
#define PAGED_CODE()
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
HubFdo * Hub
Definition: bootdev.cpp:261
WDFIOTARGET m_RootHubTarget
Definition: fdo.h:368
HubInterruptRequest m_Interrupt
Definition: fdo.h:414
UCXUSBDEVICE UsbDevice() const
Definition: fdo.h:180
USHORT m_InterruptMaxPacket
Definition: fdo.h:429
BOOLEAN IsRootHub() const
Definition: fdo.h:174
_Check_return_ _In_ DXGK_EVENT_TYPE _In_ ULONG _In_ PVOID Argument
Definition: dispmprt.h:1288
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
Status
Definition: gdiplustypes.h:24
#define IOCTL_UCXHUB_NOTIFY_FORWARD_PROGRESS
Definition: hubucx.h:69
USBD_PIPE_HANDLE Pipe
Definition: hubreq.h:72
ULONG BitmapMaxBytes
Definition: hubreq.h:79
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:690
FORCEINLINE VOID WDF_MEMORY_DESCRIPTOR_INIT_BUFFER(_Out_ PWDF_MEMORY_DESCRIPTOR Descriptor, _In_ PVOID Buffer, _In_ ULONG BufferLength)
Definition: wdfmemory.h:102

◆ HubControllerHubInfoComplete()

static VOID NTAPI HubControllerHubInfoComplete ( _In_ WDFREQUEST  Request,
_In_ WDFIOTARGET  Target,
_In_ PWDF_REQUEST_COMPLETION_PARAMS  Params,
_In_ WDFCONTEXT  Context 
)
static

Definition at line 137 of file ucxlink.cpp.

142{
143 if (!NT_SUCCESS(Params->IoStatus.Status))
144 DPRINT1("Hub %p hub info update in UCX failed 0x%lx\n", Context, Params->IoStatus.Status);
145
147}
_In_ PIRP _In_ PIO_COMPLETION_ROUTINE _In_ PVOID Context
Definition: kse.h:81
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFREQUEST Request
_In_ WDFIOTARGET Target
Definition: wdfrequest.h:306
_In_ WDFIOTARGET _In_ PWDF_REQUEST_COMPLETION_PARAMS Params
Definition: wdfrequest.h:308

◆ HubCreateUcxRequest()

static NTSTATUS NTAPI HubCreateUcxRequest ( _In_ HubFdo *  Hub,
_In_ WDFIOTARGET  Target,
_Out_ WDFREQUEST *  Request 
)
static

Definition at line 68 of file ucxlink.cpp.

72{
75
77 Attributes.ParentObject = Hub->m_Device;
78
79 *Request = NULL;
80 Status = WdfRequestCreate(&Attributes, Target, Request);
81 if (!NT_SUCCESS(Status))
82 DPRINT1("Hub %p UCX request create failed 0x%lx\n", Hub, Status);
83
84 return Status;
85}
WDFDEVICE m_Device
Definition: fdo.h:349
_In_ ULONG Attributes
Definition: dispmprt.h:1077
FORCEINLINE VOID WDF_OBJECT_ATTRIBUTES_INIT(_Out_ PWDF_OBJECT_ATTRIBUTES Attributes)
Definition: wdfobject.h:147

Referenced by HubMachine::GetRootHub20Ports(), HubMachine::GetRootHub30Ports(), HubMachine::GetRootHubInfo(), and HubMachine::UpdateControllerHubInfo().

◆ HubHasMultiTtInterface()

static BOOLEAN NTAPI HubHasMultiTtInterface ( _In_ PUSB_CONFIGURATION_DESCRIPTOR  Config)
static

Definition at line 388 of file ucxlink.cpp.

390{
392 PUCHAR End = Current + Config->wTotalLength;
395
396 while (Current + sizeof(*Common) <= End)
397 {
399 if (Common->bLength == 0)
400 break;
401
403 Current + sizeof(*Interface) <= End)
404 {
406 if (Interface->bInterfaceClass == HUB_INTERFACE_CLASS &&
407 Interface->bInterfaceProtocol == HUB_PROTOCOL_MULTI_TT)
408 {
409 return TRUE;
410 }
411 }
412
413 Current += Common->bLength;
414 }
415
416 return FALSE;
417}
PUCHAR End
Definition: desccheck.cpp:2229
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
HubUxdSettings Current
unsigned char * PUCHAR
Definition: typedefs.h:53
_Must_inspect_result_ _In_ WDFDEVICE _In_ PUCX_CONTROLLER_CONFIG Config
_In_ UCXUSBDEVICE _In_ ULONG Interface
Definition: ucxusbdevice.h:428
struct _USB_INTERFACE_DESCRIPTOR * PUSB_INTERFACE_DESCRIPTOR
struct _USB_COMMON_DESCRIPTOR * PUSB_COMMON_DESCRIPTOR
#define USB_INTERFACE_DESCRIPTOR_TYPE
Definition: usb100.h:52

Referenced by HubMachine::UpdateControllerHubInfo().

◆ HubIoctlComplete()

static VOID NTAPI HubIoctlComplete ( _In_ WDFREQUEST  Request,
_In_ WDFIOTARGET  Target,
_In_ PWDF_REQUEST_COMPLETION_PARAMS  Params,
_In_ WDFCONTEXT  Context 
)
static

Definition at line 90 of file ucxlink.cpp.

95{
97
99
102}
Definition: fdo.h:132
VOID Post(_In_ HubEvent Event)
Definition: fdo.h:194
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:329
WdfObjectDelete(String)

◆ HubRoot20PortsComplete()

static VOID NTAPI HubRoot20PortsComplete ( _In_ WDFREQUEST  Request,
_In_ WDFIOTARGET  Target,
_In_ PWDF_REQUEST_COMPLETION_PARAMS  Params,
_In_ WDFCONTEXT  Context 
)
static

Definition at line 107 of file ucxlink.cpp.

112{
113 if (!NT_SUCCESS(Params->IoStatus.Status))
114 DPRINT1("Hub %p root hub 2.0 port info failed 0x%lx\n", Context, Params->IoStatus.Status);
115
117}

◆ HubRoot30PortsComplete()

static VOID NTAPI HubRoot30PortsComplete ( _In_ WDFREQUEST  Request,
_In_ WDFIOTARGET  Target,
_In_ PWDF_REQUEST_COMPLETION_PARAMS  Params,
_In_ WDFCONTEXT  Context 
)
static

Definition at line 122 of file ucxlink.cpp.

127{
128 if (!NT_SUCCESS(Params->IoStatus.Status))
129 DPRINT1("Hub %p root hub 3.0 port info failed 0x%lx\n", Context, Params->IoStatus.Status);
130
132}

◆ HubRootHubInfoComplete()

static VOID NTAPI HubRootHubInfoComplete ( _In_ WDFREQUEST  Request,
_In_ WDFIOTARGET  Target,
_In_ PWDF_REQUEST_COMPLETION_PARAMS  Params,
_In_ WDFCONTEXT  Context 
)
static

Definition at line 160 of file ucxlink.cpp.

165{
167 BOOLEAN Succeeded = NT_SUCCESS(Params->IoStatus.Status);
168
170
171 if (Succeeded)
172 {
176 DPRINT("Hub %p root hub has %u 2.0 and %u 3.0 ports\n",
178 }
179 else
180 {
181 DPRINT1("Hub %p root hub info failed 0x%lx\n", Hub, Params->IoStatus.Status);
182 }
183
186}
unsigned char BOOLEAN
Definition: actypes.h:127
UCXHUB_ROOTHUB_INFO m_RootHubInfo
Definition: fdo.h:374
HubParentInfo m_ParentInfo
Definition: fdo.h:360
#define DPRINT
Definition: sndvol32.h:73
USHORT U2ExitLatency
Definition: fdo.h:91
USHORT U1ExitLatency
Definition: fdo.h:90
USHORT MaxU2ExitLatency
Definition: ucxroothub.h:44
USHORT MaxU1ExitLatency
Definition: ucxroothub.h:43
USHORT NumberOf20Ports
Definition: ucxroothub.h:41
USHORT NumberOf30Ports
Definition: ucxroothub.h:42
ROOTHUB_INFO Info
Definition: hubucx.h:119
USBD_PIPE_HANDLE InterruptPipe
Definition: hubucx.h:120

◆ HubSendUcxIoctl()

static VOID NTAPI HubSendUcxIoctl ( _In_ HubFdo *  Hub,
_In_ WDFIOTARGET  Target,
_In_ ULONG  IoControlCode,
_In_ PVOID  Payload,
_In_ WDFREQUEST  Request,
_In_ PFN_WDF_REQUEST_COMPLETION_ROUTINE  Completion 
)
static

Definition at line 36 of file ucxlink.cpp.

43{
46
47 RtlZeroMemory(&Stack, sizeof(Stack));
49 Stack.Parameters.DeviceIoControl.IoControlCode = IoControlCode;
50 Stack.Parameters.Others.Argument1 = Payload;
51 WdfRequestWdmFormatUsingStackLocation(Request, &Stack);
52
53 WdfRequestSetCompletionRoutine(Request, Completion, Hub);
54
56 return;
57
58 Status = WdfRequestGetStatus(Request);
59 DPRINT1("Hub %p UCX request 0x%lx not sent 0x%lx\n", Hub, IoControlCode, Status);
60
63}
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFREQUEST _In_ size_t _In_ size_t _In_ ULONG IoControlCode
_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_ PIO_STACK_LOCATION Stack
Definition: wdfrequest.h:639
#define WDF_NO_SEND_OPTIONS
Definition: wdftypes.h:109
#define IRP_MJ_INTERNAL_DEVICE_CONTROL

Referenced by HubMachine::GetRootHub20Ports(), HubMachine::GetRootHub30Ports(), HubMachine::GetRootHubInfo(), and HubMachine::UpdateControllerHubInfo().

Variable Documentation

◆ HubControllerHubInfoComplete

EVT_WDF_REQUEST_COMPLETION_ROUTINE HubControllerHubInfoComplete
static

Definition at line 27 of file ucxlink.cpp.

Referenced by HubMachine::UpdateControllerHubInfo().

◆ HubIoctlComplete

EVT_WDF_REQUEST_COMPLETION_ROUTINE HubIoctlComplete
static

◆ HubRoot20PortsComplete

EVT_WDF_REQUEST_COMPLETION_ROUTINE HubRoot20PortsComplete
static

Definition at line 25 of file ucxlink.cpp.

Referenced by HubMachine::GetRootHub20Ports().

◆ HubRoot30PortsComplete

EVT_WDF_REQUEST_COMPLETION_ROUTINE HubRoot30PortsComplete
static

Definition at line 26 of file ucxlink.cpp.

Referenced by HubMachine::GetRootHub30Ports().

◆ HubRootHubInfoComplete

EVT_WDF_REQUEST_COMPLETION_ROUTINE HubRootHubInfoComplete
static

Definition at line 23 of file ucxlink.cpp.

Referenced by HubMachine::GetRootHubInfo().