ReactOS 0.4.17-dev-1281-g065abb3
rootports.cpp File Reference
#include "xhcidrv.h"
#include <drivers/usb3/hubucx.h>
#include <debug.h>
Include dependency graph for rootports.cpp:

Go to the source code of this file.

Classes

struct  _XHCI_ROOTHUB_CONTEXT
 
struct  _XHCI_SPEED_LIST
 

Macros

#define NDEBUG
 

Typedefs

typedef struct _XHCI_ROOTHUB_CONTEXT XHCI_ROOTHUB_CONTEXT
 
typedef struct _XHCI_ROOTHUB_CONTEXT * PXHCI_ROOTHUB_CONTEXT
 
typedef struct _XHCI_SPEED_LIST XHCI_SPEED_LIST
 
typedef struct _XHCI_SPEED_LIST * PXHCI_SPEED_LIST
 

Enumerations

enum  : USHORT {
  FeatureHubLocalPowerChange = 0 , FeatureHubOverCurrentChange = 1 , FeaturePortEnable = 1 , FeaturePortSuspend = 2 ,
  FeaturePortReset = 4 , FeaturePortLinkState = 5 , FeaturePortPower = 8 , FeatureConnectChange = 16 ,
  FeatureEnableChange = 17 , FeatureSuspendChange = 18 , FeatureOverCurrentChange = 19 , FeatureResetChange = 20 ,
  FeaturePortTest = 21 , FeaturePortIndicator = 22 , FeatureU1Timeout = 23 , FeatureU2Timeout = 24 ,
  FeatureLinkStateChange = 25 , FeatureConfigErrorChange = 26 , FeatureRemoteWakeMask = 27 , FeatureWarmReset = 28 ,
  FeatureWarmResetChange = 29 , FeatureForceLinkPmAccept = 30
}
 

Functions

 WDF_DECLARE_CONTEXT_TYPE_WITH_NAME (XHCI_ROOTHUB_CONTEXT, XhciGetRootHubContext)
 
FORCEINLINE ULONG NTAPI XhciLinkState (_In_ ULONG PortSc)
 
FORCEINLINE ULONG NTAPI XhciPortSpeed (_In_ ULONG PortSc)
 
FORCEINLINE ULONG NTAPI XhciLinkWrite (_In_ ULONG State)
 
FORCEINLINE BOOLEAN NTAPI XhciPortActive (_In_ ULONG PortSc)
 
static PVOID NTAPI XhciRequestArgument (_In_ WDFREQUEST Request)
 
FORCEINLINE PUSB_DEFAULT_PIPE_SETUP_PACKET NTAPI XhciSetupOf (_In_ PURB Urb)
 
static PVOID NTAPI XhciTransferBuffer (_In_opt_ PVOID Buffer, _In_opt_ PMDL Mdl, _In_ ULONG Length, _In_ ULONG Needed)
 
static PVOID NTAPI XhciHubRequestBuffer (_In_ PURB Urb, _In_ ULONG Needed)
 
static VOID NTAPI XhciTraceBadRequest (_In_ PCSTR Callback, _In_ PURB Urb)
 
static VOID NTAPI XhciAddSpeed (_Inout_ PXHCI_SPEED_LIST List, _In_ ULONG Id, _In_ ULONG Exponent, _In_ ULONG Mantissa, _In_ ULONG Mode, _In_ ULONG Direction)
 

Variables

static const UCHAR HubRequestToHub = 0x20
 
static const UCHAR HubRequestFromHub = 0xA0
 
static const UCHAR HubRequestToPort = 0x23
 
static const UCHAR HubRequestFromPort = 0xA3
 
static const ULONG XhciResumeSignalMs = 50
 
static const ULONG XhciU3WaitSteps = 2400
 
static const ULONG XhciU0WaitSteps = 1200
 
static const ULONG XhciResumeWaitSteps = 1200
 
static const ULONG XhciPortGone = 0xFFFFFFFF
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 11 of file rootports.cpp.

Typedef Documentation

◆ PXHCI_ROOTHUB_CONTEXT

◆ PXHCI_SPEED_LIST

◆ XHCI_ROOTHUB_CONTEXT

◆ XHCI_SPEED_LIST

Enumeration Type Documentation

◆ anonymous enum

anonymous enum : USHORT
Enumerator
FeatureHubLocalPowerChange 
FeatureHubOverCurrentChange 
FeaturePortEnable 
FeaturePortSuspend 
FeaturePortReset 
FeaturePortLinkState 
FeaturePortPower 
FeatureConnectChange 
FeatureEnableChange 
FeatureSuspendChange 
FeatureOverCurrentChange 
FeatureResetChange 
FeaturePortTest 
FeaturePortIndicator 
FeatureU1Timeout 
FeatureU2Timeout 
FeatureLinkStateChange 
FeatureConfigErrorChange 
FeatureRemoteWakeMask 
FeatureWarmReset 
FeatureWarmResetChange 
FeatureForceLinkPmAccept 

Definition at line 20 of file rootports.cpp.

21{
34 FeaturePortTest = 21,
44};
@ FeatureRemoteWakeMask
Definition: rootports.cpp:40
@ FeaturePortReset
Definition: rootports.cpp:26
@ FeatureWarmResetChange
Definition: rootports.cpp:42
@ FeaturePortTest
Definition: rootports.cpp:34
@ FeatureEnableChange
Definition: rootports.cpp:30
@ FeatureHubOverCurrentChange
Definition: rootports.cpp:23
@ FeatureOverCurrentChange
Definition: rootports.cpp:32
@ FeatureU2Timeout
Definition: rootports.cpp:37
@ FeaturePortEnable
Definition: rootports.cpp:24
@ FeaturePortPower
Definition: rootports.cpp:28
@ FeaturePortIndicator
Definition: rootports.cpp:35
@ FeatureU1Timeout
Definition: rootports.cpp:36
@ FeatureHubLocalPowerChange
Definition: rootports.cpp:22
@ FeatureConnectChange
Definition: rootports.cpp:29
@ FeatureWarmReset
Definition: rootports.cpp:41
@ FeatureConfigErrorChange
Definition: rootports.cpp:39
@ FeaturePortLinkState
Definition: rootports.cpp:27
@ FeaturePortSuspend
Definition: rootports.cpp:25
@ FeatureResetChange
Definition: rootports.cpp:33
@ FeatureForceLinkPmAccept
Definition: rootports.cpp:43
@ FeatureLinkStateChange
Definition: rootports.cpp:38
@ FeatureSuspendChange
Definition: rootports.cpp:31

Function Documentation

◆ WDF_DECLARE_CONTEXT_TYPE_WITH_NAME()

WDF_DECLARE_CONTEXT_TYPE_WITH_NAME ( XHCI_ROOTHUB_CONTEXT  ,
XhciGetRootHubContext   
)

◆ XhciAddSpeed()

static VOID NTAPI XhciAddSpeed ( _Inout_ PXHCI_SPEED_LIST  List,
_In_ ULONG  Id,
_In_ ULONG  Exponent,
_In_ ULONG  Mantissa,
_In_ ULONG  Mode,
_In_ ULONG  Direction 
)
static

Appends one sublink speed (Mode 1 asymmetric, Direction 1 TX); counts past capacity.

Definition at line 1962 of file rootports.cpp.

1969{
1970 if (List->Count < List->Capacity)
1971 {
1972 PUSB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED Speed = &List->Speeds[List->Count];
1973
1974 Speed->AsUlong32 = 0;
1975 Speed->SublinkSpeedAttrID = Id;
1976 Speed->LaneSpeedExponent = Exponent;
1977 Speed->SublinkTypeMode = Mode;
1978 Speed->SublinkTypeDir = Direction;
1979 Speed->LinkProtocol = (List->Minor != 0 && Id > 4) ? 1 : 0;
1980 Speed->LaneSpeedMantissa = Mantissa;
1981 }
1982
1983 List->Count++;
1984}
DWORD Id
_In_ ULONG Mode
Definition: hubbusif.h:303
WDF_EXTERN_C_START typedef _In_ WDFDEVICE _In_ WDFCONTEXT _In_ WDF_DMA_DIRECTION Direction
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550

Referenced by XhciRootHub::FillSpeeds().

◆ XhciHubRequestBuffer()

static PVOID NTAPI XhciHubRequestBuffer ( _In_ PURB  Urb,
_In_ ULONG  Needed 
)
static

Definition at line 151 of file rootports.cpp.

154{
155 struct _URB_CONTROL_TRANSFER* Transfer = &Urb->UrbControlTransfer;
156
157 return XhciTransferBuffer(Transfer->TransferBuffer,
158 Transfer->TransferBufferMDL,
159 Transfer->TransferBufferLength,
160 Needed);
161}
static PVOID NTAPI XhciTransferBuffer(_In_opt_ PVOID Buffer, _In_opt_ PMDL Mdl, _In_ ULONG Length, _In_ ULONG Needed)
Definition: rootports.cpp:133
PMDL TransferBufferMDL
Definition: usb.h:484
ULONG TransferBufferLength
Definition: usb.h:482
PVOID TransferBuffer
Definition: usb.h:483
_In_opt_ PUSB_CONFIGURATION_DESCRIPTOR _Inout_ PUSBD_INTERFACE_LIST_ENTRY _Outptr_ PURB * Urb
Definition: usbdlib.h:333

Referenced by XhciRootHub::GetHubStatus(), XhciRootHub::GetPortErrorCount(), and XhciRootHub::GetPortStatus().

◆ XhciLinkState()

◆ XhciLinkWrite()

◆ XhciPortActive()

FORCEINLINE BOOLEAN NTAPI XhciPortActive ( _In_ ULONG  PortSc)

Powered, connected, enabled, no pending connect change and not SS.Disabled.

Definition at line 95 of file rootports.cpp.

97{
99
100 if ((PortSc & Needed) != Needed || (PortSc & XHCI_PORTSC_CSC))
101 return FALSE;
102
103 return XhciLinkState(PortSc) != PORT_LINK_STATE_DISABLED;
104}
#define FALSE
Definition: types.h:117
FORCEINLINE ULONG NTAPI XhciLinkState(_In_ ULONG PortSc)
Definition: rootports.cpp:66
uint32_t ULONG
Definition: typedefs.h:59
#define PORT_LINK_STATE_DISABLED
Definition: usb200.h:196
#define XHCI_PORTSC_PP
Definition: xhcihw.h:215
#define XHCI_PORTSC_CSC
Definition: xhcihw.h:221
#define XHCI_PORTSC_CCS
Definition: xhcihw.h:209
#define XHCI_PORTSC_PED
Definition: xhcihw.h:210

Referenced by XhciRootHub::ResuspendResumedPorts(), XhciRootHub::WaitForU3(), and XhciRootHub::WaitU0().

◆ XhciPortSpeed()

FORCEINLINE ULONG NTAPI XhciPortSpeed ( _In_ ULONG  PortSc)

Definition at line 75 of file rootports.cpp.

77{
79}
#define XHCI_PORTSC_SPEED_MASK
Definition: xhcihw.h:217
#define XHCI_PORTSC_SPEED_SHIFT
Definition: xhcihw.h:216

Referenced by XhciRootHub::GetPortStatus().

◆ XhciRequestArgument()

static PVOID NTAPI XhciRequestArgument ( _In_ WDFREQUEST  Request)
static

Definition at line 109 of file rootports.cpp.

111{
113
115 WdfRequestGetParameters(Request, &Parameters);
116 return Parameters.Parameters.Others.Arg1;
117}
_In_ HANDLE _In_ CONST PDXGKMDT_OPM_GET_INFO_PARAMETERS Parameters
Definition: dispmprt.h:321
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFREQUEST Request
FORCEINLINE VOID WDF_REQUEST_PARAMETERS_INIT(_Out_ PWDF_REQUEST_PARAMETERS Parameters)
Definition: wdfrequest.h:211

◆ XhciSetupOf()

Definition at line 122 of file rootports.cpp.

124{
125 /* Same offset in the plain and the _EX control transfer URBs */
126 return (PUSB_DEFAULT_PIPE_SETUP_PACKET)Urb->UrbControlTransfer.SetupPacket;
127}

Referenced by XhciRootHub::ClearHubFeature(), XhciRootHub::ClearPortFeature(), XhciRootHub::GetHubStatus(), XhciRootHub::GetPortErrorCount(), XhciRootHub::GetPortStatus(), XhciRootHub::SetPortFeature(), and XhciTraceBadRequest().

◆ XhciTraceBadRequest()

static VOID NTAPI XhciTraceBadRequest ( _In_ PCSTR  Callback,
_In_ PURB  Urb 
)
static

Definition at line 166 of file rootports.cpp.

169{
171
172 DPRINT1("Root hub %s: rejecting setup %02x %02x %04x %04x %04x\n",
173 Callback, Setup->bmRequestType.B, Setup->bRequest, Setup->wValue.W, Setup->wIndex.W, Setup->wLength);
174}
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn UINT32 *TableIdx UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER void *Data ACPI_OBJECT_HANDLER void **Data ACPI_STRING ACPI_OBJECT_LIST ACPI_BUFFER *ReturnObjectBuffer ACPI_DEVICE_INFO **ReturnBuffer ACPI_HANDLE ACPI_HANDLE ACPI_HANDLE *OutHandle ACPI_HANDLE *OutHandle void *Context void *Context ACPI_EVENT_HANDLER Handler UINT32 UINT32 ACPI_GPE_HANDLER void *Context UINT32 ACPI_NOTIFY_HANDLER void *Context ACPI_ADR_SPACE_TYPE ACPI_ADR_SPACE_HANDLER ACPI_ADR_SPACE_SETUP Setup
Definition: acpixf.h:834
#define DPRINT1
Definition: precomp.h:8
_In_ ULONG _In_ ULONG _In_opt_ DXGKCB_MIRACAST_SEND_MESSAGE_CALLBACK Callback
Definition: dispmprt.h:620
FORCEINLINE PUSB_DEFAULT_PIPE_SETUP_PACKET NTAPI XhciSetupOf(_In_ PURB Urb)
Definition: rootports.cpp:122

Referenced by XhciRootHub::ClearHubFeature(), XhciRootHub::ClearPortFeature(), XhciRootHub::GetHubStatus(), XhciRootHub::GetPortErrorCount(), XhciRootHub::GetPortStatus(), and XhciRootHub::SetPortFeature().

◆ XhciTransferBuffer()

static PVOID NTAPI XhciTransferBuffer ( _In_opt_ PVOID  Buffer,
_In_opt_ PMDL  Mdl,
_In_ ULONG  Length,
_In_ ULONG  Needed 
)
static

Data buffer of a transfer with room for Needed bytes, or NULL.

Definition at line 133 of file rootports.cpp.

138{
139 if (Length < Needed)
140 return NULL;
141
142 if (Buffer == NULL && Mdl != NULL)
144
145 return Buffer;
146}
Definition: bufpool.h:45
#define NULL
Definition: types.h:112
@ NormalPagePriority
Definition: imports.h:54
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
_In_ WDFDEVICE _In_ PVOID _In_opt_ PMDL Mdl
#define MmGetSystemAddressForMdlSafe(_Mdl, _Priority)

Referenced by XhciRootHub::InterruptTransfer(), and XhciHubRequestBuffer().

Variable Documentation

◆ HubRequestFromHub

const UCHAR HubRequestFromHub = 0xA0
static

Definition at line 16 of file rootports.cpp.

Referenced by XhciRootHub::GetHubStatus().

◆ HubRequestFromPort

const UCHAR HubRequestFromPort = 0xA3
static

Definition at line 18 of file rootports.cpp.

Referenced by XhciRootHub::GetPortErrorCount(), and XhciRootHub::GetPortStatus().

◆ HubRequestToHub

const UCHAR HubRequestToHub = 0x20
static

Definition at line 15 of file rootports.cpp.

Referenced by XhciRootHub::ClearHubFeature().

◆ HubRequestToPort

const UCHAR HubRequestToPort = 0x23
static

Definition at line 17 of file rootports.cpp.

Referenced by XhciRootHub::ClearPortFeature(), and XhciRootHub::SetPortFeature().

◆ XhciPortGone

◆ XhciResumeSignalMs

const ULONG XhciResumeSignalMs = 50
static

Definition at line 47 of file rootports.cpp.

Referenced by XhciRootHub::StartResumeTimer().

◆ XhciResumeWaitSteps

const ULONG XhciResumeWaitSteps = 1200
static

Definition at line 52 of file rootports.cpp.

Referenced by XhciRootHub::ResuspendResumedPorts().

◆ XhciU0WaitSteps

const ULONG XhciU0WaitSteps = 1200
static

Definition at line 51 of file rootports.cpp.

Referenced by XhciRootHub::WaitU0().

◆ XhciU3WaitSteps

const ULONG XhciU3WaitSteps = 2400
static

Definition at line 50 of file rootports.cpp.

Referenced by XhciRootHub::WaitForU3().