13#define UCX_COMPOSITE_VERSION 0x100
14#define UCX_MAX_COMPOSITE_FUNCTIONS 255
15#define UCX_MAX_FORWARD_PROGRESS_SIZE (512 * 1024)
21 return UcxGetUsbDeviceContext(
Handle);
113 DPRINT1(
"UsbDevice object create failed under hub %p 0x%lx\n",
Init->ParentHub,
Status);
119 Device->m_Controller = ControllerContext;
121 Device->m_HubDeviceContext =
Init->HubDeviceContext;
125 Device->InitializeLists();
133 if (
Parent->m_Disconnected)
143 Device->m_ChildrenMayLeavePurge =
Parent->m_ChildrenMayLeavePurge;
144 Device->m_EndpointsMayLeavePurge =
Parent->m_ChildrenMayLeavePurge;
150 DPRINT1(
"UsbDevice %p not created, parent hub %p is disconnected\n",
Object,
Parent->m_Handle);
164UcxUsbDevice::EvtDestroy(
180 Device->m_Controller->m_ChildDeviceCount--;
229 DPRINT(
"UsbDevice %p remote wake request is being canceled\n",
m_Handle);
259 Path->Size =
sizeof(*Path);
260 Path->PortPathDepth = 1;
262 Path->TTHubDepth = 0;
267 ParentDepth =
Hub->m_Info.PortPath.PortPathDepth;
270 DPRINT1(
"Hub %p port %lu is too deep for a device, depth %lu\n",
Hub->m_Handle,
PortNumber, ParentDepth + 1);
275 Path->PortPathDepth = ParentDepth + 1;
282 Path->TTHubDepth = ParentDepth;
287 Path->TTHubDepth =
Hub->m_Info.PortPath.TTHubDepth;
288 Info->TtHub =
Hub->m_Info.TtHub;
312 Init.HubDeviceContext =
Info->HubDeviceContext;
314 Init.Info.DeviceSpeed =
Info->DeviceSpeed;
326 DPRINT1(
"Hub %p port %lu device add during controller reset 0x%lx\n",
Hub,
Info->PortNumber,
Status);
375 Stale.
Flink->Blink = &Stale;
376 Stale.
Blink->Flink = &Stale;
387 Endpoint->Post(EpEvent::StaleReplaced);
412 Child->WalkSubtree(Visitor,
Context, IncludeDisconnected);
481 Endpoint->Post(EpEvent::HubDisconnect);
545UcxUsbDevice::EnableForwardProgress(
548 ULONG ControlSize =
Info->ControlPipeMaxTransferSize;
550 PFN_UCX_HCD_ENDPOINT_ENABLE_FORWARD_PROGRESS
Enable;
559 DPRINT1(
"UsbDevice %p control forward progress size %lu too large\n",
m_Handle, ControlSize);
565 DPRINT1(
"UsbDevice %p control pipe forward progress already enabled\n",
m_Handle);
574 Pipe->ReservedIoActive)
576 DPRINT1(
"UsbDevice %p pipe %lu bad forward progress size %lu or already enabled\n",
583 if (ControlSize != 0 &&
590 DPRINT1(
"UsbDevice %p HCD has no forward progress callback for the control pipe\n",
m_Handle);
609 Enable =
Pipe->Endpoint->m_Callbacks.EnableForwardProgress;
612 DPRINT1(
"Endpoint %p HCD has no forward progress callback\n",
Pipe->Endpoint->m_Handle);
619 DPRINT1(
"Endpoint %p forward progress failed 0x%lx\n",
Pipe->Endpoint->m_Handle,
Status);
623 Pipe->ForwardProgressAllocatedByHcd =
TRUE;
624 Pipe->ReservedIoMaxBytes =
Info->Pipes[
Index].ReservedTransferLimit;
628 if (ControlSize != 0)
699 DPRINT1(
"UsbDevice %p is already registered as composite\n",
m_Handle);
710 Handles[
Index] = (USBD_FUNCTION_HANDLE)&Records[
Index];
737 DPRINT1(
"UsbDevice %p composite unregister without a registration\n",
m_Handle);
816UcxUsbDevice::EvtRemoteWakeCancel(
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 Parent
#define InterlockedExchange
const struct winhelp_callbacks Callbacks
BOOLEAN IsRootHub() const
static UcxController * FromHandle(_In_ UCXCONTROLLER Handle)
KSPIN_LOCK m_TopologyLock
UcxEndpointCallbacks m_Callbacks
UcxController * m_Controller
BOOLEAN m_ChildrenMayLeavePurge
VOID RemoteWakeNotification(_In_ ULONG Interface)
static UcxUsbDevice * FromHandle(_In_ UCXUSBDEVICE Handle)
LIST_ENTRY m_EndpointList
static EVT_WDF_REQUEST_CANCEL EvtRemoteWakeCancel
UcxEndpoint * m_DefaultEndpoint
VOID WalkSubtree(_In_ PFN_UCX_DEVICE_VISITOR Visitor, _In_opt_ PVOID Context, _In_ BOOLEAN IncludeDisconnected)
VOID RequestRemoteWakeNotification(_In_ WDFREQUEST Request)
LONG m_PendingNoPingResponse
static VOID InitSetEventCallbacks(_Inout_ PUCXUSBDEVICE_INIT Init, _In_ PUCX_USBDEVICE_EVENT_CALLBACKS Callbacks)
VOID InitializeAsRootHub(_In_ UCXROOTHUB Handle, _In_ UcxController *Controller)
WDFMEMORY m_FunctionsMemory
VOID DisconnectPort(_In_ ULONG PortNumber)
VOID SetFunctionData(_In_ WDFREQUEST Request)
LIST_ENTRY m_TrackingList
static _Must_inspect_result_ NTSTATUS Create(_In_ UCXCONTROLLER Controller, _Inout_ PUCXUSBDEVICE_INIT *Init, _In_opt_ PWDF_OBJECT_ATTRIBUTES Attributes, _Out_ UCXUSBDEVICE *UsbDevice)
BOOLEAN m_EndpointsMayLeavePurge
KSPIN_LOCK m_TrackingLock
VOID ReportNoPingResponseIfPending()
VOID SetPdo(_In_ PDEVICE_OBJECT Pdo)
LIST_ENTRY m_UsbdHandleList
KSPIN_LOCK m_RemoteWakeLock
UcxFunctionRecord * m_Functions
static EVT_WDF_OBJECT_CONTEXT_DESTROY EvtDestroy
UCXHUB_DEVICE_CONTEXT m_HubDeviceContext
VOID RegisterComposite(_In_ WDFREQUEST Request)
VOID UnregisterComposite(_In_ WDFREQUEST Request)
UcxRemoteWakeSlot m_RemoteWake
KSPIN_LOCK m_UsbdHandleLock
BOOLEAN m_StalePipeIoAllowed
LIST_ENTRY m_StaleEndpointList
UcxUsbDevice * m_ParentHub
static _Must_inspect_result_ NTSTATUS CreateFromHub(_In_ UCXUSBDEVICE Hub, _In_ PUCXHUB_DEVICE_CREATE_INFO Info, _Out_ UCXUSBDEVICE *UsbDevice)
VOID NTAPI UcxDropLeakedUsbdHandles(_In_ UcxUsbDevice *Device)
#define STATUS_NOT_SUPPORTED
_Inout_ HubConfiguration ** Slot
static ULONG64 NTAPI UcxSystemTimeNow(VOID)
#define UCX_COMPOSITE_VERSION
static VOID NTAPI UcxDisconnectVisitor(_In_ UcxUsbDevice *Device, _In_opt_ PVOID Context)
static BOOLEAN NTAPI UcxIsValidForwardProgressSize(_In_ ULONG Size)
#define UCX_MAX_FORWARD_PROGRESS_SIZE
static NTSTATUS NTAPI UcxBuildPortPath(_In_ UcxUsbDevice *Hub, _In_ ULONG PortNumber, _Inout_ PUCXUSBDEVICE_INFO Info)
#define UCX_MAX_COMPOSITE_FUNCTIONS
#define UCX_DEVICE_TYPE_ROOT_HUB
#define UCX_DEVICE_TYPE_HUB
#define NT_SUCCESS(StatCode)
static VOID Wake(_In_ UCHAR Csn)
#define _IRQL_requires_(irql)
#define RemoveEntryList(Entry)
#define InsertTailList(ListHead, Entry)
#define InsertHeadList(ListHead, Entry)
#define IsListEmpty(ListHead)
#define KeReleaseSpinLock(sl, irql)
#define KeAcquireSpinLock(sl, irql)
#define KeQuerySystemTime(t)
#define RemoveHeadList(ListHead)
#define InitializeListHead(ListHead)
#define KeInitializeSpinLock(sl)
_In_ UCXUSBDEVICE UsbDevice
VOID(NTAPI * PFN_UCX_DEVICE_VISITOR)(_In_ UcxUsbDevice *Device, _In_opt_ PVOID Context)
_Must_inspect_result_ _In_ PUCXHUB_DEVICE_CREATE_INFO _Out_ UCXUSBDEVICE * Device
_In_ UCXHUB_DEVICE_CONTEXT _In_ UCXENDPOINT Endpoint
_In_ UCXUSBDEVICE _In_ PDEVICE_OBJECT Pdo
struct _UCXHUB_FUNCTION_DATA * PUCXHUB_FUNCTION_DATA
_In_ PIRP _In_ PIO_COMPLETION_ROUTINE _In_ PVOID Context
#define _Must_inspect_result_
_In_ ULONGLONG _In_ ULONGLONG _In_ BOOLEAN Enable
#define KeAcquireSpinLockAtDpcLevel(SpinLock)
#define KeReleaseSpinLockFromDpcLevel(SpinLock)
PFN_UCX_HCD_ENDPOINT_ENABLE_FORWARD_PROGRESS EnableForwardProgress
static UcxPipe * FromHandle(_In_ USBD_PIPE_HANDLE Handle)
BOOLEAN ForwardProgressAllocatedByHcd
PREQUEST_REMOTE_WAKE_NOTIFICATION Params
struct _LIST_ENTRY * Blink
struct _LIST_ENTRY * Flink
USB_DEVICE_SPEED DeviceSpeed
PFN_WDF_OBJECT_CONTEXT_DESTROY EvtDestroyCallback
struct _LIST_ENTRY * PLIST_ENTRY
#define RtlCopyMemory(Destination, Source, Length)
#define RtlZeroMemory(Destination, Length)
#define CONTAINING_RECORD(address, type, field)
_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_ UCXUSBDEVICE _In_ ULONG Interface
#define MAX_USB_DEVICE_DEPTH
_Must_inspect_result_ NTSTATUS NTAPI UcxCreateObjectWithTwoContexts(_In_ PWDF_OBJECT_ATTRIBUTES Primary, _In_opt_ PWDF_OBJECT_ATTRIBUTES Secondary, _Out_ WDFOBJECT *Object)
FORCEINLINE BOOLEAN NTAPI UcxIsListEntryLinked(_In_ const LIST_ENTRY *Entry)
FORCEINLINE VOID NTAPI UcxClearListEntry(_Out_ PLIST_ENTRY Entry)
#define STATUS_INVALID_PARAMETER
#define STATUS_NO_SUCH_DEVICE
#define STATUS_INVALID_DEVICE_STATE
USBD_FUNCTION_HANDLE * PUSBD_FUNCTION_HANDLE
struct _REQUEST_REMOTE_WAKE_NOTIFICATION * PREQUEST_REMOTE_WAKE_NOTIFICATION
struct _REGISTER_COMPOSITE_DEVICE * PREGISTER_COMPOSITE_DEVICE
BOOL InitPointer(PPDEV ppdev)
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object
_In_ WDFCOLLECTION _In_ ULONG Index
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFDEVICE Child
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_ _Strict_type_match_ POOL_TYPE _In_opt_ ULONG _In_ _Out_ WDFMEMORY * Memory
FORCEINLINE VOID WDF_OBJECT_ATTRIBUTES_INIT(_Out_ PWDF_OBJECT_ATTRIBUTES Attributes)
#define WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(_attributes, _contexttype)
#define WdfObjectReference(Handle)
#define WdfObjectDereference(Handle)
_In_ WDFIOTARGET _In_ PWDF_REQUEST_COMPLETION_PARAMS Params
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql