17#define XHCI_TAG_ENDPOINT 'eHCX'
20#define XHCI_EP_CANCEL_REPORTED 0x00000001
21#define XHCI_EP_FAILURE_REPORTED 0x00000002
22#define XHCI_EP_STREAM_HALT_PENDING 0x00000004
23#define XHCI_EP_STOPPED_HANDSHAKE 0x00000008
24#define XHCI_EP_STOPPED_RECEIVED 0x00000010
25#define XHCI_EP_HALT_RECEIVED 0x00000020
26#define XHCI_EP_IGNORE_STOPPED 0x00000040
27#define XHCI_EP_RESET_ACK_HANDSHAKE 0x00000080
28#define XHCI_EP_CLIENT_RESET_HANDSHAKE 0x00000100
31#define XHCI_VERIFY_CONTROL_DEQUEUE 0x00000080
32#define XHCI_VERIFY_RESET_ENDPOINT 0x00000100
33#define XHCI_VERIFY_CANCEL_DEQUEUE 0x00000200
34#define XHCI_VERIFY_STOP_EXHAUSTED 0x00000400
35#define XHCI_VERIFY_EVENT_CODE 0x00000800
36#define XHCI_VERIFY_STOP_ENDPOINT 0x00800000
37#define XHCI_VERIFY_DUPLICATE_EVENT 0x02000000
40#define XHCI_REASON_NO_LIVE_DUMP 0x0000
41#define XHCI_REASON_STOP_ERROR 0x1003
42#define XHCI_REASON_STOP_CONTEXT 0x1004
43#define XHCI_REASON_CONTROL_DEQUEUE 0x1005
44#define XHCI_REASON_CONTROL_RESET 0x1006
45#define XHCI_REASON_CANCEL_DEQUEUE 0x100A
46#define XHCI_REASON_EVENT_CODE 0x1010
47#define XHCI_REASON_DROP_FAILED 0x1017
48#define XHCI_REASON_CLIENT_DEQUEUE 0x101A
49#define XHCI_REASON_CLIENT_RESET 0x101B
50#define XHCI_REASON_STOP_ADD_FAILED 0x101D
51#define XHCI_REASON_EVENT_DATA_POINTER 0x101E
52#define XHCI_REASON_EVENT_POINTER 0x101F
53#define XHCI_REASON_DUPLICATE_POINTER 0x1020
54#define XHCI_REASON_STREAM_RECONFIGURE 0x1021
55#define XHCI_REASON_RECONFIGURE 0x1022
56#define XHCI_REASON_NOT_STOPPED 0x1023
58#define XHCI_RECLAIM_TAG reinterpret_cast<PVOID>(static_cast<ULONG_PTR>('lcRX'))
59#define XHCI_STOP_ATTEMPTS_MAX 20
60#define XHCI_CLEAR_STALL_TIMEOUT_MS 5000
61#define XHCI_CLEAR_STALL_STACK_SIZE 4
64#define XHCI_REQUEST_REUSE_MUST_COMPLETE 0x00000002
94 struct _URB_CONTROL_TRANSFER_EX
Urb;
324 DPRINT1(
"UcxEndpointCreate for endpoint 0x%02x failed 0x%lx\n",
371 DPRINT1(
"Endpoint %p state timer creation failed 0x%lx\n",
this,
Status);
378 if (IsochCompanion !=
NULL)
404 DPRINT1(
"Endpoint %p clear stall context creation failed 0x%lx\n",
this,
Status);
413 DPRINT1(
"Endpoint %p DCI %lu main ring creation failed 0x%lx\n",
this,
m_Dci,
Status);
422 DPRINT(
"Endpoint %p created, address 0x%02x DCI %lu type %lu\n",
505 if (Streams->ContextArray !=
NULL)
599 UsbEndpointDescriptor,
604 DPRINT1(
"Endpoint 0x%02x creation failed 0x%lx\n",
605 UsbEndpointDescriptor->bEndpointAddress,
Status);
614XhciEndpoint::Enable()
618 UCXSSTREAMS UcxStreams;
623 UcxStreams = UcxEndpointGetStaticStreamsReferenced(
m_Ucx,
this);
629 else if (UcxStreams ==
NULL)
652 Streams = XhciGetStreams(UcxStreams);
683 if (UcxStreams !=
NULL)
690XhciEndpoint::Disable()
696XhciEndpoint::Disable(
702 Pending =
static_cast<WDFREQUEST
>(
706 DPRINT1(
"Endpoint %p DCI %lu disabled with a client reset pending; completing it\n",
this,
m_Dci);
835 Esit =
Packet * (Burst + 1);
871 Context->MaxEsitPayloadLo = Esit & 0xFFFF;
872 Context->MaxEsitPayloadHi = (Esit >> 16) & 0xFF;
875 Context->AverageTrbLength = Esit / 2;
1042 Context->Dword2 &= ~XHCI_STREAM_EDTLA_MASK;
1046 Context->Dword3 &= ~XHCI_STREAM_EDTLA_MASK;
1110 if ((
Code ==
static_cast<ULONG>(XhciCompletionCode::TrbError)) ||
1111 (
Code ==
static_cast<ULONG>(XhciCompletionCode::UndefinedError)) ||
1114 DPRINT1(
"Endpoint %p DCI %lu transfer event with completion code %lu\n",
this,
m_Dci,
Code);
1129 if ((Pointer != 0) &&
1140 DPRINT1(
"Endpoint %p DCI %lu event data 0x%I64x matched no stream\n",
this,
m_Dci, Pointer);
1154 DPRINT1(
"Endpoint %p DCI %lu dropping a likely duplicate event at 0x%I64x\n",
1155 this,
m_Dci, Pointer);
1159 DPRINT1(
"Endpoint %p DCI %lu likely duplicate event at 0x%I64x\n",
this,
m_Dci, Pointer);
1164 DPRINT1(
"Endpoint %p DCI %lu event at 0x%I64x matched no stream\n",
this,
m_Dci, Pointer);
1170 DPRINT1(
"Endpoint %p DCI %lu stopped event at 0x%I64x matched no stream\n",
this,
m_Dci, Pointer);
1179 DPRINT1(
"Endpoint %p DCI %lu ignoring endpoint event code %lu\n",
this,
m_Dci,
Code);
1255 PostEvent(XepEvent::ControllerResetStarting);
1259XhciEndpoint::ControllerResetDone()
1262 PostEvent(XepEvent::ControllerResetDone);
1392 Data->Endpoint = Self;
1405 Taken =
static_cast<WDFREQUEST
>(
1442 DPRINT1(
"Endpoint %p forward progress enable failed 0x%lx\n", Self,
Status);
1473 Data->Endpoint = Self;
1480 DPRINT1(
"Endpoint %p no input context for the max packet size update\n", Self);
1486 InputAddress =
Data->InputContext->LogicalAddress.QuadPart;
1503 Data->Command.Trb.Dword[0] =
static_cast<ULONG>(InputAddress);
1504 Data->Command.Trb.Dword[1] =
static_cast<ULONG>(InputAddress >> 32);
1528 DPRINT1(
"Endpoint %p max packet size update lost with the controller\n", Self);
1530 else if (
Command->Code != XhciCompletionCode::Success)
1532 DPRINT1(
"Endpoint %p Evaluate Context failed with code %lu\n",
1557 UCXSSTREAMS UcxStreams;
1564 DPRINT1(
"Endpoint %p is not streams capable\n", Self);
1581 DPRINT1(
"Endpoint %p UcxStaticStreamsCreate failed 0x%lx\n", Self,
Status);
1585 Streams = XhciGetStreams(UcxStreams);
1595 DPRINT1(
"Endpoint %p stream %lu ring creation failed 0x%lx\n", Self, StreamId,
Status);
1599 Streams->
Entry[StreamId - 1].
Ring = Ring;
1629 Streams->Entry[
Index].Ring->Disable(
TRUE);
1661 WdfIoQueueDrain(MainQueue,
NULL,
NULL);
1662 WdfIoQueueGetState(MainQueue, &Queued, &Owned);
1663 if ((Queued != 0) || (Owned != 0))
1665 DPRINT1(
"Endpoint %p streams open with requests still on the main queue\n",
this);
1673 DPRINT1(
"Endpoint %p streams open with bad stream count %lu\n",
this, Streams->Count);
1679 XhciGetRequestData(
Request)->StreamsConfigure.Streams = Streams;
1682 if (Streams->ContextArray ==
NULL)
1684 DPRINT1(
"Endpoint %p no stream context array for %lu streams\n",
this, Streams->Count);
1694 Ring = Streams->Entry[
Index].Ring;
1698 DPRINT1(
"Endpoint %p stream %lu ring enable failed 0x%lx\n",
this,
Index + 1,
Status);
1712 if (Streams->ContextArray !=
NULL)
1715 Streams->ContextArray =
NULL;
1718 WdfIoQueueStart(MainQueue);
1742 DPRINT1(
"Endpoint %p streams open reconfigure failed 0x%lx\n", Self,
Status);
1785 XhciGetRequestData(
Request)->StreamsConfigure.Streams = Streams;
1791 DPRINT1(
"Endpoint %p no default stream record for the streams close\n",
this);
1802 DPRINT1(
"Endpoint %p main ring enable for the streams close failed 0x%lx\n",
this,
Status);
1844 DPRINT1(
"Endpoint %p streams close reconfigure failed 0x%lx\n", Self,
Status);
1867 Command->Trb.Dword[0] =
static_cast<ULONG>(DequeuePointer);
1868 Command->Trb.Dword[1] =
static_cast<ULONG>(DequeuePointer >> 32);
1906 if (EndpointContext !=
NULL)
1919 Command->Trb.Dword[0] =
static_cast<ULONG>(InputAddress);
1920 Command->Trb.Dword[1] =
static_cast<ULONG>(InputAddress >> 32);
1941 if (
Command->Code == XhciCompletionCode::Success)
1945 Self->
PostEvent(XepEvent::CommandSucceeded);
1949 DPRINT1(
"Endpoint %p DCI %lu in state %lu after a successful stop\n", Self, Self->
m_Dci,
State);
1955 if (
Command->Code == XhciCompletionCode::ContextStateError)
1961 Self->
PostEvent(XepEvent::StopFailedRunning);
1965 Self->
PostEvent(XepEvent::StopFailedStopped);
1971 Self->
PostEvent(XepEvent::StopFailedHalted);
1975 DPRINT1(
"Endpoint %p DCI %lu isoch endpoint halted on stop\n", Self, Self->
m_Dci);
1981 DPRINT1(
"Endpoint %p DCI %lu stop context error in state %lu\n", Self, Self->
m_Dci,
State);
1988 DPRINT1(
"Endpoint %p DCI %lu Stop Endpoint failed with code %lu\n",
2037 if (
Command->Code != XhciCompletionCode::Success)
2039 DPRINT1(
"Endpoint %p DCI %lu Set TR Dequeue Pointer after stop failed with code %lu\n",
2050 Self->
PostEvent(XepEvent::CommandSucceeded);
2067 if (
Command->Code != XhciCompletionCode::Success)
2069 DPRINT1(
"Endpoint %p DCI %lu Reset Endpoint failed with code %lu\n",
2095 if (
Command->Code != XhciCompletionCode::Success)
2097 DPRINT1(
"Endpoint %p DCI %lu Set TR Dequeue Pointer after reset failed with code %lu\n",
2106 Self->
PostEvent(XepEvent::CommandSucceeded);
2124 if (
Command->Code != XhciCompletionCode::Success)
2126 DPRINT1(
"Endpoint %p DCI %lu client Reset Endpoint failed with code %lu\n",
2190 if (
Command->Code != XhciCompletionCode::Success)
2192 DPRINT1(
"Endpoint %p DCI %lu Set TR Dequeue Pointer for the client reset failed with code %lu\n",
2205 Self->
PostEvent(XepEvent::CommandSucceeded);
2222 DPRINT1(
"Endpoint %p DCI %lu drop for the client reset failed with code %lu\n",
2268 if (
Command->Code != XhciCompletionCode::Success)
2270 DPRINT1(
"Endpoint %p DCI %lu add for the client reset failed with code %lu\n",
2277 Self->
PostEvent(XepEvent::CommandSucceeded);
2291 DPRINT1(
"Endpoint %p DCI %lu drop after stop failed with code %lu\n",
2324 if (
Command->Code != XhciCompletionCode::Success)
2326 DPRINT1(
"Endpoint %p DCI %lu add after stop failed with code %lu\n",
2342 struct _URB_CONTROL_TRANSFER_EX*
Urb;
2358 DPRINT1(
"Endpoint %p DCI %lu has no default endpoint for the clear stall\n",
this,
m_Dci);
2368 Urb->Hdr.Length =
sizeof(*Urb);
2369 Urb->Hdr.Function = URB_FUNCTION_CONTROL_TRANSFER_EX;
2388 Stack->Parameters.Others.Argument1 =
Urb;
2405 DPRINT1(
"Endpoint %p clear stall forward failed 0x%lx\n",
this,
Status);
2423 DPRINT1(
"Endpoint %p clear stall finished with 0x%lx\n", Self,
Irp->IoStatus.Status);
2425 Self->
PostEvent(XepEvent::CommandSucceeded);
2466 DPRINT1(
"Endpoint %p DCI %lu stop failed as halted but no halt event came\n", Ep, Ep->
m_Dci);
2470 DPRINT1(
"Endpoint %p DCI %lu got no stopped event after the stop\n", Ep, Ep->
m_Dci);
2474 DPRINT1(
"Endpoint %p DCI %lu expected events still missing after the stop\n", Ep, Ep->
m_Dci);
2478 DPRINT1(
"Endpoint %p DCI %lu expected events still missing after the halt\n", Ep, Ep->
m_Dci);
2521 Request =
static_cast<WDFREQUEST
>(
2531 DPRINT(
"Endpoint %p client reset completed with 0x%lx\n", Ep,
Status);
2550 Ep->
PostEvent(XepEvent::StoppedEventSeen);
2669 DPRINT1(
"Endpoint %p DCI %lu no input context for the client reset\n", Ep, Ep->
m_Dci);
2671 Ep->
PostEvent(XepEvent::BufferAllocFailed);
2703 DPRINT1(
"Endpoint %p DCI %lu no input context for the reconfigure after stop\n", Ep, Ep->
m_Dci);
2800 if (!
Controller->HasErrata(XhciErrata::EpStopContextErrorIsStopped))
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
#define InterlockedIncrement
#define InterlockedExchange
#define InterlockedDecrement
const struct winhelp_callbacks Callbacks
BOOLEAN SmPost(_In_ Event Ev)
XhciCommonBuffer m_Buffers
BOOLEAN HasErrata(_In_ XhciErrata Bit) const
PDEVICE_OBJECT m_WdmDevice
XhciCommandRing m_Commands
XhciRegisters m_Registers
static XhciController * FromUcx(_In_ UCXCONTROLLER UcxController)
VOID ReportStoppedEvent()
VOID NotifyRingsClientReset()
VOID UpdateDequeuePointers()
BOOLEAN StopAttemptsExhausted()
VOID StartTimer(_In_ ULONG Milliseconds)
VOID ReportTimeout(_In_ XEP_TIMEOUT Timeout)
VOID NotifyRingsReclaim()
VOID ReconfigureForReset()
VOID AckControllerReset()
VOID NotifyRingsReclaimOnCancel()
VOID Initialize(_In_ XhciEndpoint *Endpoint)
VOID CompleteResetRequestIfAllowed()
VOID CompleteResetRequest()
BOOLEAN OnPrimaryInterrupterOnly()
BOOLEAN CanResetAfterHalt()
VOID RequestControllerReset()
BOOLEAN IgnoresStopContextError()
VOID NotifyRingsStoppedEvent()
XhciEndpoint * m_Endpoint
BOOLEAN ShouldReconfigureForReset()
BOOLEAN DelaysFirstStop()
VOID DereferenceEndpoint()
BOOLEAN DoorbellRungSinceFill()
VOID ReconfigureAfterStop()
VOID RestartStreamQueues()
BOOLEAN IsControlEndpoint()
BOOLEAN NeedsContextRebuildAfterStop()
VOID NotifyRingsDrainEvents()
static VOID NTAPI ControlDequeueDone(_In_ XhciCommand *Command)
static EVT_WDF_OBJECT_CONTEXT_CLEANUP EvtStreamsCleanup
BOOLEAN m_ForwardProgress
PXHCI_ENDPOINT_CONTEXT InputEndpointContext(_In_ XhciDmaBuffer *Input) const
BOOLEAN UsesStreams() const
BOOLEAN IsStreamsCapable() const
static EVT_WDF_IO_QUEUE_STATE EvtPurgeDone
ULONG StreamTransferLength(_In_ ULONG StreamId) const
static EVT_WDF_OBJECT_CONTEXT_CLEANUP EvtCleanup
static EVT_WDF_IO_QUEUE_STATE EvtAbortDone
NTSTATUS CloseStreams(_In_ XhciStreams *Streams, _In_ WDFREQUEST Request)
XhciController * m_Controller
static XhciEndpoint * FromUcx(_In_ UCXENDPOINT Endpoint)
VOID FatalError(_In_ ULONG Reason)
static VOID NTAPI ClientDequeueDone(_In_ XhciCommand *Command)
BOOLEAN PostWhenAllRings(_In_ XepEvent Event)
VOID BuildEndpointConfigure(_In_ XhciDmaBuffer *Input, _In_opt_ const VOID *EndpointContext, _In_ BOOLEAN Drop, _In_ BOOLEAN Add, _Out_ XhciCommand *Command, _In_ PFN_XHCI_COMMAND_DONE Done)
ULONG TransferType() const
UCXENDPOINT Handle() const
ULONG StreamHaltedCode() const
static EVT_UCX_ENDPOINT_OK_TO_CANCEL_TRANSFERS EvtOkToCancel
VOID OnTransferCanceled()
static VOID NTAPI StopDone(_In_ XhciCommand *Command)
XhciDmaBuffer * m_StopInput
static EVT_UCX_ENDPOINT_STATIC_STREAMS_DISABLE EvtStreamsDisable
static EVT_WDF_TIMER EvtTimer
static VOID NTAPI StopAddDone(_In_ XhciCommand *Command)
BOOLEAN StreamCommandDone()
VOID OnTransferEvent(_In_ const XHCI_TRB *Event)
static VOID NTAPI DefaultUpdateDone(_In_ XhciCommand *Command)
static VOID NTAPI ResetConfigureDone(_In_ XhciCommand *Command)
const USB_ENDPOINT_DESCRIPTOR * Descriptor() const
static VOID NTAPI ResetDropDone(_In_ XhciCommand *Command)
PXHCI_STREAM_CONTEXT StreamContext(_In_ ULONG StreamId) const
static EVT_UCX_ENDPOINT_ABORT EvtAbort
static VOID NTAPI StreamsEnableDone(_In_ PVOID Context, _In_ NTSTATUS Status)
VOID OnHaltedCompletionCode(_In_ ULONG CompletionCode, _In_ BOOLEAN TransferFound)
VOID BuildContext(_Out_writes_bytes_(ContextSize) PVOID EndpointContext, _In_ ULONG ContextSize) const
XhciUsbDevice * Device() const
PENDPOINT_RESET ResetPayload() const
static VOID NTAPI CancelDequeueDone(_In_ XhciCommand *Command)
VOID OnExpectedEventsProcessed()
VOID PostCommandFailure()
static IO_COMPLETION_ROUTINE ClearStallDone
USHORT MaxPacketSize() const
USB_ENDPOINT_DESCRIPTOR m_Descriptor
BOOLEAN StreamRingEmpty(_In_ ULONG StreamId) const
static VOID NTAPI ClientResetDone(_In_ XhciCommand *Command)
static VOID NTAPI ControlResetDone(_In_ XhciCommand *Command)
USB_SUPERSPEEDPLUS_ISOCH_ENDPOINT_COMPANION_DESCRIPTOR m_IsochCompanion
NTSTATUS Initialize(_In_ XhciController *Controller, _In_ UCXUSBDEVICE UcxUsbDevice, _In_ UCXENDPOINT Endpoint, _In_ const USB_ENDPOINT_DESCRIPTOR *Descriptor, _In_opt_ const USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR *Companion, _In_opt_ const USB_SUPERSPEEDPLUS_ISOCH_ENDPOINT_COMPANION_DESCRIPTOR *IsochCompanion)
VOID ForEachRing(_In_ VOID(XhciTransferRing::*Action)())
ULONG OutputEndpointState() const
NTSTATUS CreateClearStall()
HaltClearBlock * m_ClearStall
BOOLEAN ShouldDropStoppedEvent() const
ULONG64 EndpointDequeuePointer() const
VOID BuildSetDequeue(_Out_ XhciCommand *Command, _In_ ULONG64 DequeuePointer, _In_ ULONG StreamId, _In_ PFN_XHCI_COMMAND_DONE Done)
static EVT_UCX_ENDPOINT_PURGE EvtPurge
WDFREQUEST volatile m_ResetRequest
static NTSTATUS NTAPI EvtEnableForwardProgress(_In_ UCXENDPOINT Endpoint, _In_ ULONG MaxTransferSize)
XhciController * Controller() const
VOID DequeueAfterStop(_In_ ULONG StreamId)
XhciTransferRing * m_MainRing
static EVT_UCX_DEFAULT_ENDPOINT_UPDATE EvtDefaultUpdate
static EVT_UCX_ENDPOINT_STATIC_STREAMS_ADD EvtStreamsAdd
static NTSTATUS Create(_In_ UCXCONTROLLER UcxController, _In_ UCXUSBDEVICE UcxUsbDevice, _In_ PUCXENDPOINT_INIT EndpointInit, _In_ const USB_ENDPOINT_DESCRIPTOR *Descriptor, _In_opt_ const USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR *Companion, _In_opt_ const USB_SUPERSPEEDPLUS_ISOCH_ENDPOINT_COMPANION_DESCRIPTOR *IsochCompanion)
XhciEndpointMachine m_Machine
XhciStreams * m_DefaultStreams
VOID OnTransfersReclaimed()
BOOLEAN AnyTransfersPending() const
XhciTransferRing * RingAt(_In_ ULONG Index) const
VOID DisableRings(_In_ BOOLEAN SlotDisabling)
XhciStreams * m_CurrentStreams
USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR m_Companion
ULONG MaxEsitPayload() const
VOID ResetStreamTransferLength(_In_ ULONG StreamId)
static EVT_UCX_ENDPOINT_START EvtStart
static VOID NTAPI StreamsDisableDone(_In_ PVOID Context, _In_ NTSTATUS Status)
VOID PostEvent(_In_ XepEvent Event)
ULONG64 StreamDequeuePointer(_In_ ULONG StreamId) const
VOID DequeueAfterReset(_In_ ULONG StreamId)
VOID DisableStreamRings(_In_ XhciStreams *Streams)
VOID FreeDefaultStreams(_In_opt_ XhciStreams *Streams)
static EVT_UCX_ENDPOINT_STATIC_STREAMS_ENABLE EvtStreamsEnable
VOID ControllerResetStarting()
static EVT_UCX_ENDPOINT_RESET EvtReset
static VOID NTAPI StopDropDone(_In_ XhciCommand *Command)
NTSTATUS OpenStreams(_In_ XhciStreams *Streams, _In_ WDFREQUEST Request)
ULONG SupportedStreams() const
ULONG ContextSize() const
VOID AllowReclaimOnCancel()
ULONG64 DequeuePointerValue() const
BOOLEAN OnTransferEvent(_In_ const XHCI_TRB *Event)
ULONG64 EnqueuePointer() const
static NTSTATUS Create(_In_ XhciEndpoint *Endpoint, _In_ WDFOBJECT Parent, _In_ ULONG StreamId, _Out_ XhciTransferRing **Ring)
VOID ConsumePendingEvents()
ULONG64 SegmentBase() const
BOOLEAN IsLikelyDuplicate(_In_ const XHCI_TRB *Event) const
BOOLEAN DoorbellRungSinceFill() const
VOID StoppedEventReceived()
const USB_DEVICE_DESCRIPTOR * DeviceDescriptor() const
static XhciUsbDevice * FromUcx(_In_ UCXUSBDEVICE UsbDevice)
PVOID OutputContext(_In_ ULONG Dci) const
USB_DEVICE_SPEED Speed() const
const USB_DEVICE_PORT_PATH * PortPath() const
ULONG ContextEntries() const
VOID(NTAPI * PFN_XHCI_COMMAND_DONE)(_In_ XhciCommand *Command)
_Inout_ HubConfiguration ** Slot
_In_ HANDLE _In_ CONST PDXGKMDT_OPM_GET_INFO_PARAMETERS Parameters
_Check_return_ _In_ DXGK_EVENT_TYPE _In_ ULONG Event
#define NT_SUCCESS(StatCode)
#define InterlockedExchangePointer(Target, Value)
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
#define KeInitializeEvent(pEvt, foo, foo2)
#define KeSetEvent(pEvt, foo, foo2)
#define XHCI_VERIFY_CANCEL_DEQUEUE
#define XHCI_REASON_CONTROL_RESET
#define XHCI_VERIFY_RESET_ENDPOINT
#define XHCI_REASON_RECONFIGURE
#define XHCI_REASON_STOP_ERROR
#define XHCI_REASON_CANCEL_DEQUEUE
#define XHCI_REASON_EVENT_DATA_POINTER
#define XHCI_EP_FAILURE_REPORTED
#define XHCI_REASON_STREAM_RECONFIGURE
#define XHCI_CLEAR_STALL_TIMEOUT_MS
#define XHCI_EP_STREAM_HALT_PENDING
#define XHCI_TAG_ENDPOINT
#define XHCI_EP_STOPPED_HANDSHAKE
#define XHCI_REASON_STOP_ADD_FAILED
#define XHCI_STOP_ATTEMPTS_MAX
#define XHCI_EP_CANCEL_REPORTED
#define XHCI_REASON_EVENT_CODE
#define XHCI_VERIFY_STOP_ENDPOINT
#define XHCI_EP_IGNORE_STOPPED
#define XHCI_REASON_NO_LIVE_DUMP
#define XHCI_EP_STOPPED_RECEIVED
static BOOLEAN NTAPI XhciIsHaltedCode(_In_ ULONG Code)
static ULONG NTAPI XhciMaxPrimaryStreams(_In_ ULONG Count)
#define XHCI_CLEAR_STALL_STACK_SIZE
#define XHCI_VERIFY_CONTROL_DEQUEUE
#define XHCI_REASON_CONTROL_DEQUEUE
static ULONG NTAPI XhciStreamsSize(_In_ ULONG Count)
static BOOLEAN NTAPI XhciIsStoppedCode(_In_ ULONG Code)
static ULONG NTAPI XhciStreamArrayBytes(_In_ ULONG MaxPrimary)
static XhciStreams *NTAPI XhciNewDefaultStreams(_In_ XhciEndpoint *Endpoint, _In_ XhciTransferRing *MainRing, _In_ ULONG ArrayMaxPrimary)
#define XHCI_REASON_CLIENT_DEQUEUE
#define XHCI_EP_HALT_RECEIVED
static PURB NTAPI XhciRequestUrb(_In_ WDFREQUEST Request)
#define XHCI_REASON_CLIENT_RESET
#define XHCI_REASON_DUPLICATE_POINTER
#define XHCI_VERIFY_STOP_EXHAUSTED
#define XHCI_EP_RESET_ACK_HANDSHAKE
#define XHCI_REASON_DROP_FAILED
#define XHCI_REASON_NOT_STOPPED
#define XHCI_VERIFY_DUPLICATE_EVENT
static ULONG NTAPI XhciEndpointCommandControl(_In_ enum XhciTrbType Type, _In_ ULONG Dci, _In_ ULONG SlotId)
#define XHCI_REASON_EVENT_POINTER
#define XHCI_REQUEST_REUSE_MUST_COMPLETE
#define XHCI_EP_CLIENT_RESET_HANDSHAKE
#define XHCI_VERIFY_EVENT_CODE
#define XHCI_REASON_STOP_CONTEXT
@ XepTimeoutDrainAfterStop
enum _XEP_TIMEOUT XEP_TIMEOUT
VOID NTAPI KeClearEvent(IN PKEVENT Event)
_Must_inspect_result_ _In_ FLT_CONTEXT_TYPE _In_ SIZE_T ContextSize
return pRequest Reuse(ReuseParams)
#define USB3_URB_RESERVED_RESOURCES
_Must_inspect_result_ _In_ UCXUSBDEVICE _In_ ULONG MaxPacketSize
_Must_inspect_result_ _In_ UCXUSBDEVICE _In_ ULONG _In_opt_ PUSB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR Companion
_In_ UCXHUB_DEVICE_CONTEXT _In_ UCXENDPOINT Endpoint
NTSTATUS NTAPI IoSetCompletionRoutineEx(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PIO_COMPLETION_ROUTINE CompletionRoutine, IN PVOID Context, IN BOOLEAN InvokeOnSuccess, IN BOOLEAN InvokeOnError, IN BOOLEAN InvokeOnCancel)
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
_In_ PIRP _In_ PIO_COMPLETION_ROUTINE _In_ PVOID Context
#define ExFreePoolWithTag(_P, _T)
PVOID PVOID PWCHAR PVOID USHORT PULONG Reason
static PVOID ExAllocatePoolZero(ULONG PoolType, SIZE_T NumberOfBytes, ULONG Tag)
_In_ NDIS_HANDLE _In_ PNDIS_PACKET Packet
#define _In_reads_bytes_(s)
#define _In_reads_opt_(s)
#define _Out_writes_bytes_(s)
#define UNREFERENCED_PARAMETER(P)
_In_ ULONG _In_ ULONG _In_ ULONG Length
PIRP NTAPI IoAllocateIrp(IN CCHAR StackSize, IN BOOLEAN ChargeQuota)
VOID NTAPI IoReuseIrp(IN OUT PIRP Irp, IN NTSTATUS Status)
VOID NTAPI IoFreeIrp(IN PIRP Irp)
_In_ ULONG MaxTransferSize
_In_ ULONG _In_ WDFMEMORY Input
#define STATUS_MORE_PROCESSING_REQUIRED
PHYSICAL_ADDRESS LogicalAddress
struct _URB_CONTROL_TRANSFER_EX Urb
volatile LONG UpdateCount
volatile LONG StreamsLeftToFlush
XhciDmaBuffer * ContextArray
UCXENDPOINT DefaultEndpoint
ENDPOINT_RESET_FLAGS Flags
struct _USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR::@4130::@4132 Isochronous
union _USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR::@4130 bmAttributes
struct _USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR::@4130::@4131 Bulk
BOOLEAN AutomaticSerialization
#define FIELD_OFFSET(t, f)
#define RtlCopyMemory(Destination, Source, Length)
#define RtlZeroMemory(Destination, Length)
_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
FORCEINLINE VOID NTAPI UCX_ENDPOINT_EVENT_CALLBACKS_INIT(_Out_ PUCX_ENDPOINT_EVENT_CALLBACKS Callbacks, _In_ PFN_UCX_ENDPOINT_PURGE EvtEndpointPurge, _In_ PFN_UCX_ENDPOINT_START EvtEndpointStart, _In_ PFN_UCX_ENDPOINT_ABORT EvtEndpointAbort, _In_ PFN_UCX_ENDPOINT_RESET EvtEndpointReset, _In_ PFN_UCX_ENDPOINT_OK_TO_CANCEL_TRANSFERS EvtEndpointOkToCancelTransfers, _In_ PFN_UCX_ENDPOINT_STATIC_STREAMS_ADD EvtEndpointStaticStreamsAdd, _In_ PFN_UCX_ENDPOINT_STATIC_STREAMS_ENABLE EvtEndpointStaticStreamsEnable, _In_ PFN_UCX_ENDPOINT_STATIC_STREAMS_DISABLE EvtEndpointStaticStreamsDisable)
@ FlagEndpointResetPreserveTransferState
FORCEINLINE VOID NTAPI UcxDefaultEndpointInitSetEventCallbacks(_Inout_ PUCXENDPOINT_INIT EndpointInit, _In_ PUCX_DEFAULT_ENDPOINT_EVENT_CALLBACKS EventCallbacks)
FORCEINLINE VOID NTAPI UcxEndpointInitSetEventCallbacks(_Inout_ PUCXENDPOINT_INIT EndpointInit, _In_ PUCX_ENDPOINT_EVENT_CALLBACKS EventCallbacks)
FORCEINLINE VOID NTAPI UCX_DEFAULT_ENDPOINT_EVENT_CALLBACKS_INIT(_Out_ PUCX_DEFAULT_ENDPOINT_EVENT_CALLBACKS Callbacks, _In_ PFN_UCX_ENDPOINT_PURGE EvtEndpointPurge, _In_ PFN_UCX_ENDPOINT_START EvtEndpointStart, _In_ PFN_UCX_ENDPOINT_ABORT EvtEndpointAbort, _In_ PFN_UCX_ENDPOINT_OK_TO_CANCEL_TRANSFERS EvtEndpointOkToCancelTransfers, _In_ PFN_UCX_DEFAULT_ENDPOINT_UPDATE EvtDefaultEndpointUpdate)
FORCEINLINE VOID NTAPI UcxEndpointSetWdfIoQueue(_In_ UCXENDPOINT Endpoint, _In_ WDFQUEUE WdfQueue)
_Must_inspect_result_ _In_ UCXUSBDEVICE _Inout_ PUCXENDPOINT_INIT * EndpointInit
_In_ ULONG NumberOfStreams
FORCEINLINE VOID NTAPI UcxStaticStreamsSetStreamInfo(_In_ UCXSSTREAMS StaticStreams, _In_ PSTREAM_INFO StreamInfo)
WDF_EXTERN_C_START struct _STREAM_INFO STREAM_INFO
FORCEINLINE VOID NTAPI STREAM_INFO_INIT(_Out_ PSTREAM_INFO StreamInfo, _In_ WDFQUEUE WdfQueue, _In_ ULONG StreamId)
_In_ UCXUSBDEVICE _In_ ULONG _In_opt_ PUSB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR SuperSpeedEndpointCompanionDescriptor
_In_ UCXUSBDEVICE _In_ ULONG UsbEndpointDescriptorBufferLength
#define STATUS_INVALID_PARAMETER
#define STATUS_NO_SUCH_DEVICE
#define STATUS_UNSUCCESSFUL
#define STATUS_INSUFFICIENT_RESOURCES
#define USB_ENDPOINT_TYPE_INTERRUPT
#define USB_FEATURE_ENDPOINT_STALL
#define USB_ENDPOINT_DESCRIPTOR_TYPE
#define USB_ENDPOINT_TYPE_CONTROL
#define BMREQUEST_HOST_TO_DEVICE
#define BMREQUEST_TO_ENDPOINT
#define USB_ENDPOINT_TYPE_ISOCHRONOUS
#define BMREQUEST_STANDARD
#define USB_REQUEST_CLEAR_FEATURE
#define USB_ENDPOINT_TYPE_MASK
#define USB_ENDPOINT_TYPE_BULK
#define USB_ENDPOINT_DIRECTION_IN(x)
enum _USB_DEVICE_SPEED USB_DEVICE_SPEED
#define USB_ENDPOINT_ADDRESS_MASK
#define USBD_STATUS_INTERNAL_HC_ERROR
#define USBD_STATUS_SUCCESS
#define USBD_STATUS_INSUFFICIENT_RESOURCES
#define USBD_STATUS_INVALID_PARAMETER
#define USBD_DEFAULT_PIPE_TRANSFER
_In_opt_ PUSB_CONFIGURATION_DESCRIPTOR _Inout_ PUSBD_INTERFACE_LIST_ENTRY _Outptr_ PURB * Urb
#define IOCTL_INTERNAL_USB_SUBMIT_URB
_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
FORCEINLINE LONGLONG WDF_REL_TIMEOUT_IN_MS(_In_ ULONGLONG Time)
_In_ PDEVICE_OBJECT DeviceObject
_Must_inspect_result_ _In_ WDFDEVICE _In_ PIRP _In_ WDFQUEUE Queue
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
_In_ UCHAR _In_ UCHAR _In_ ULONG Code
_In_ WDFIOTARGET _In_ _Strict_type_match_ WDF_IO_TARGET_SENT_IO_ACTION Action
#define WdfObjectDereferenceWithTag(Handle, Tag)
FORCEINLINE VOID WDF_OBJECT_ATTRIBUTES_INIT(_Out_ PWDF_OBJECT_ATTRIBUTES Attributes)
#define WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(_attributes, _contexttype)
#define WdfObjectReference(Handle)
#define WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(_contexttype, _castingfunction)
#define WdfObjectReferenceWithTag(Handle, Tag)
#define WdfObjectDereference(Handle)
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
@ WDF_REQUEST_REUSE_SET_NEW_IRP
FORCEINLINE VOID WDF_REQUEST_PARAMETERS_INIT(_Out_ PWDF_REQUEST_PARAMETERS Parameters)
_In_ WDFREQUEST _In_ PIO_STACK_LOCATION Stack
FORCEINLINE VOID WDF_REQUEST_REUSE_PARAMS_INIT(_Out_ PWDF_REQUEST_REUSE_PARAMS Params, _In_ ULONG Flags, _In_ NTSTATUS Status)
_Must_inspect_result_ _In_ WDFIORESLIST _In_ PIO_RESOURCE_DESCRIPTOR Descriptor
FORCEINLINE VOID WDF_TIMER_CONFIG_INIT(_Out_ PWDF_TIMER_CONFIG Config, _In_ PFN_WDF_TIMER EvtTimerFunc)
_In_ WDF_WMI_PROVIDER_CONTROL Control
static VOID FreeResources(VOID)
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
FORCEINLINE VOID IoSetNextIrpStackLocation(_Inout_ PIRP Irp)
#define IRP_MJ_INTERNAL_DEVICE_CONTROL
_In_ LARGE_INTEGER _In_ ULONG Period
#define XHCI_URB_NO_PROCESSOR
EVT_UCX_USBDEVICE_DEFAULT_ENDPOINT_ADD XhciEvtUsbDeviceDefaultEndpointAdd
EVT_UCX_USBDEVICE_ENDPOINT_ADD XhciEvtUsbDeviceEndpointAdd
#define XHCI_ENDPOINT_TYPE_CONTROL
#define XHCI_TRB_TYPE_SHIFT
FORCEINLINE ULONG64 NTAPI XhciTrbPointer(_In_ const XHCI_TRB *Trb)
#define XHCI_TRANSFER_EVENT_ED
#define XHCI_CMD_STREAM_ID_SHIFT
#define XHCI_TRB_ENDPOINT_SHIFT
#define XHCI_CMD_TRANSFER_STATE_PRESERVE
struct _XHCI_STREAM_CONTEXT XHCI_STREAM_CONTEXT
#define XHCI_TRB_SLOT_SHIFT
#define XHCI_ENDPOINT_STATE_STOPPED
#define XHCI_INPUT_CONTEXT_COUNT
#define XHCI_STREAM_EDTLA_MASK
#define XHCI_ENDPOINT_STATE_RUNNING
#define XHCI_ENDPOINT_STATE_HALTED
FORCEINLINE ULONG NTAPI XhciTrbCompletionCode(_In_ const XHCI_TRB *Trb)