13#define NDEBUG_USBPORT_CORE
14#define NDEBUG_USBPORT_QUEUE
15#define NDEBUG_USBPORT_URB
32 &
Irp->Tail.Overlay.ListEntry);
55 DPRINT_QUEUE(
"USBPORT_PeekNextIdleIrp: Irp - %p, PeekContext - %p\n",
67 NextEntry =
Irp->Tail.Overlay.ListEntry.
Flink;
71 NextEntry = ListHead->
Flink;
74 while (NextEntry != ListHead)
78 Tail.Overlay.ListEntry);
83 NextEntry = NextEntry->
Flink;
128 DPRINT_QUEUE(
"USBPORT_CompleteCanceledIdleIrp: ... \n");
137 Irp->IoStatus.Information = 0;
155 &
Irp->Tail.Overlay.ListEntry);
178 DPRINT_QUEUE(
"USBPORT_PeekNextBadRequest: Irp - %p, PeekContext - %p\n",
190 NextEntry =
Irp->Tail.Overlay.ListEntry.
Flink;
194 NextEntry = ListHead->
Flink;
197 while (NextEntry != ListHead)
201 Tail.Overlay.ListEntry);
206 NextEntry = NextEntry->
Flink;
260 Irp->IoStatus.Information = 0;
271 DPRINT_CORE(
"USBPORT_InsertIrpInTable: IrpTable - %p, Irp - %p\n",
279 for (ix = 0; ix < 0x200; ix++)
281 if (IrpTable->irp[ix] ==
NULL)
283 IrpTable->irp[ix] =
Irp;
287 DPRINT_CORE(
"USBPORT_InsertIrpInTable: ix - %x\n", ix);
303 if (IrpTable->LinkNextTable ==
NULL)
310 IrpTable = IrpTable->LinkNextTable;
321 DPRINT_CORE(
"USBPORT_RemoveIrpFromTable: IrpTable - %p, Irp - %p\n",
329 for (ix = 0; ix < 0x200; ix++)
331 if (IrpTable->irp[ix] ==
Irp)
333 IrpTable->irp[ix] =
NULL;
337 DPRINT_CORE(
"USBPORT_RemoveIrpFromTable: ix - %x\n", ix);
344 if (IrpTable->LinkNextTable ==
NULL)
347 IrpTable = IrpTable->LinkNextTable;
351 DPRINT1(
"USBPORT_RemoveIrpFromTable: return NULL. ix - %x\n", ix);
389 DPRINT_CORE(
"USBPORT_FindUrbInIrpTable: IrpTable - %p, Urb - %p, Irp - %p\n",
398 for (ix = 0; ix < 0x200; ix++)
400 irp = IrpTable->irp[ix];
426 IrpTable = IrpTable->LinkNextTable;
439 DPRINT_CORE(
"USBPORT_FindIrpInTable: IrpTable - %p, Irp - %p\n",
447 for (ix = 0; ix < 0x200; ix++)
449 irp = IrpTable->irp[ix];
457 IrpTable = IrpTable->LinkNextTable;
459 while (IrpTable->LinkNextTable);
461 DPRINT_CORE(
"USBPORT_FindIrpInTable: Not found!!!\n");
490 DPRINT_CORE(
"USBPORT_CancelPendingTransferIrp: DeviceObject - %p, Irp - %p\n",
565 DPRINT_CORE(
"USBPORT_CancelActiveTransferIrp: irp - %p, Urb - %p, Transfer - %p\n",
616 DPRINT_CORE(
"USBPORT_FlushAbortList: Endpoint - %p\n", Endpoint);
625 Endpoint->EndpointOldIrql);
629 Entry = Endpoint->PendingTransferList.Flink;
631 while (
Entry &&
Entry != &Endpoint->PendingTransferList)
639 DPRINT_CORE(
"USBPORT_FlushAbortList: Aborted PendingTransfer - %p\n",
643 Endpoint->EndpointOldIrql);
650 Entry = Endpoint->TransferList.Flink;
652 while (
Entry &&
Entry != &Endpoint->TransferList)
660 DPRINT_CORE(
"USBPORT_FlushAbortList: Aborted ActiveTransfer - %p\n",
664 Endpoint->EndpointOldIrql);
671 AbortList = &Endpoint->AbortList;
679 Tail.Overlay.ListEntry);
693 Tail.Overlay.ListEntry);
707 Irp->IoStatus.Information = 0;
725 FdoDevice = Endpoint->FdoDevice;
743 DPRINT(
"USBPORT_FlushCancelList: Irp - %p\n",
Irp);
798 DPRINT_CORE(
"USBPORT_FlushPendingTransfers: Endpoint - %p\n", Endpoint);
800 FdoDevice = Endpoint->FdoDevice;
805 DPRINT_CORE(
"USBPORT_FlushPendingTransfers: Endpoint Locked \n");
832 List = Endpoint->TransferList.Flink;
834 while (
List &&
List != &Endpoint->TransferList)
855 List = Endpoint->PendingTransferList.Flink;
873 DPRINT_CORE(
"USBPORT_FlushPendingTransfers: Transfer->Irp->CancelRoutine - %p\n",
874 Transfer->
Irp->CancelRoutine);
880 DPRINT_CORE(
"USBPORT_FlushPendingTransfers: Transfer->Irp - %p\n",
963 DPRINT_CORE(
"USBPORT_FlushPendingTransfers: Endpoint Unlocked. Exit\n");
976 DPRINT_CORE(
"USBPORT_QueuePendingUrbToEndpoint: Endpoint - %p, Urb - %p\n",
980 Transfer = Urb->UrbControlTransfer.hca.Reserved8[0];
997 DPRINT_CORE(
"USBPORT_QueueActiveUrbToEndpoint: Endpoint - %p, Urb - %p\n",
1001 Transfer = Urb->UrbControlTransfer.hca.Reserved8[0];
1002 FdoDevice = Endpoint->FdoDevice;
1006 &Endpoint->EndpointOldIrql);
1014 Endpoint->EndpointOldIrql);
1026 Endpoint->EndpointOldIrql);
1093 DPRINT_CORE(
"USBPORT_QueueTransferUrb: Urb - %p\n", Urb);
1098 Transfer = Urb->UrbControlTransfer.hca.Reserved8[0];
1102 Endpoint->
Flags &= ~ENDPOINT_FLAG_QUEUENE_EMPTY;
1104 Parameters->TransferBufferLength = Urb->UrbControlTransfer.TransferBufferLength;
1105 Parameters->TransferFlags = Urb->UrbControlTransfer.TransferFlags;
1121 Urb->UrbControlTransfer.SetupPacket,
1125 DPRINT_URB(
"... URB TransferBufferLength - %x\n",
1126 Urb->UrbControlTransfer.TransferBufferLength);
1128 Urb->UrbControlTransfer.TransferBufferLength = 0;
1146 DPRINT_URB(
"... URB TransferBufferLength - %x\n",
1147 Urb->UrbControlTransfer.TransferBufferLength);
1149 if (Urb->UrbControlTransfer.TransferBufferLength)
1156 Buffer = Urb->UrbControlTransfer.TransferBuffer;
1157 BufferLength = Urb->UrbControlTransfer.TransferBufferLength;
1232 ULONG KilledTransfers = 0;
1234 DPRINT_CORE(
"USBPORT_KillEndpointActiveTransfers \n");
1236 ActiveList = Endpoint->TransferList.
Flink;
1238 while (ActiveList && ActiveList != &Endpoint->TransferList)
1254 return KilledTransfers;
1264 ULONG KilledTransfers;
1304 KilledTransfers = 0;
1309 FlushControllerLink);
1319 if (!KilledTransfers)
1344 DPRINT1(
"USBPORT_BadRequestFlush: Irp - %p\n",
Irp);
1347 Irp->IoStatus.Information = 0;
1372 PendingList = Endpoint->PendingTransferList.
Flink;
1374 while (PendingList && PendingList != &Endpoint->PendingTransferList)
1380 DPRINT_CORE(
"USBPORT_AbortEndpoint: Abort PendingTransfer - %p\n",
1388 ActiveList = Endpoint->TransferList.
Flink;
1390 while (ActiveList && ActiveList != &Endpoint->TransferList)
1396 DPRINT_CORE(
"USBPORT_AbortEndpoint: Abort ActiveTransfer - %p\n",
PSINGLE_LIST_ENTRY FlushList(PSINGLE_LIST_ENTRY ListHead)
#define InterlockedIncrement
#define InterlockedDecrement
_In_opt_ PIRP _In_opt_ PVOID PeekContext
NTKERNELAPI PIRP NTAPI IoCsqRemoveNextIrp(_Inout_ PIO_CSQ Csq, _In_opt_ PVOID PeekContext)
IoCsqRemoveNextIrp - Removes the next IRP from the queue.
VOID NTAPI USBPORT_AbortEndpoint(IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_ENDPOINT Endpoint, IN PIRP Irp)
VOID NTAPI USBPORT_CancelActiveTransferIrp(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
VOID NTAPI USBPORT_ReleaseIdleLock(IN PIO_CSQ Csq, IN KIRQL Irql)
VOID NTAPI USBPORT_QueuePendingUrbToEndpoint(IN PUSBPORT_ENDPOINT Endpoint, IN PURB Urb)
VOID NTAPI USBPORT_InsertIrpInTable(IN PUSBPORT_IRP_TABLE IrpTable, IN PIRP Irp)
VOID NTAPI USBPORT_QueuePendingTransferIrp(IN PIRP Irp)
VOID NTAPI USBPORT_RemoveBadRequest(IN PIO_CSQ Csq, IN PIRP Irp)
VOID NTAPI USBPORT_FlushController(IN PDEVICE_OBJECT FdoDevice)
VOID NTAPI USBPORT_CancelPendingTransferIrp(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
PIRP NTAPI USBPORT_RemoveIrpFromTable(IN PUSBPORT_IRP_TABLE IrpTable, IN PIRP Irp)
VOID NTAPI USBPORT_InsertIdleIrp(IN PIO_CSQ Csq, IN PIRP Irp)
VOID NTAPI USBPORT_QueueTransferUrb(IN PURB Urb)
ULONG NTAPI USBPORT_KillEndpointActiveTransfers(IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_ENDPOINT Endpoint)
PIRP NTAPI USBPORT_RemovePendingTransferIrp(IN PDEVICE_OBJECT FdoDevice, IN PIRP Irp)
PIRP NTAPI USBPORT_PeekNextBadRequest(IN PIO_CSQ Csq, IN PIRP Irp, IN PVOID PeekContext)
PIRP NTAPI USBPORT_PeekNextIdleIrp(IN PIO_CSQ Csq, IN PIRP Irp, IN PVOID PeekContext)
VOID NTAPI USBPORT_FlushPendingTransfers(IN PUSBPORT_ENDPOINT Endpoint)
VOID NTAPI USBPORT_InsertBadRequest(IN PIO_CSQ Csq, IN PIRP Irp)
VOID NTAPI USBPORT_CompleteCanceledBadRequest(IN PIO_CSQ Csq, IN PIRP Irp)
PIRP NTAPI USBPORT_FindIrpInTable(IN PUSBPORT_IRP_TABLE IrpTable, IN PIRP Irp)
VOID NTAPI USBPORT_FlushAllEndpoints(IN PDEVICE_OBJECT FdoDevice)
VOID NTAPI USBPORT_FindUrbInIrpTable(IN PUSBPORT_IRP_TABLE IrpTable, IN PURB Urb, IN PIRP Irp)
VOID NTAPI USBPORT_ReleaseBadRequestLock(IN PIO_CSQ Csq, IN KIRQL Irql)
VOID NTAPI USBPORT_CompleteCanceledIdleIrp(IN PIO_CSQ Csq, IN PIRP Irp)
PIRP NTAPI USBPORT_RemoveActiveTransferIrp(IN PDEVICE_OBJECT FdoDevice, IN PIRP Irp)
VOID NTAPI USBPORT_AcquireBadRequestLock(IN PIO_CSQ Csq, IN PKIRQL Irql)
BOOLEAN NTAPI USBPORT_QueueActiveUrbToEndpoint(IN PUSBPORT_ENDPOINT Endpoint, IN PURB Urb)
VOID NTAPI USBPORT_AcquireIdleLock(IN PIO_CSQ Csq, IN PKIRQL Irql)
VOID NTAPI USBPORT_BadRequestFlush(IN PDEVICE_OBJECT FdoDevice)
VOID NTAPI USBPORT_RemoveIdleIrp(IN PIO_CSQ Csq, IN PIRP Irp)
PIRP NTAPI USBPORT_FindActiveTransferIrp(IN PDEVICE_OBJECT FdoDevice, IN PIRP Irp)
VOID NTAPI USBPORT_FlushCancelList(IN PUSBPORT_ENDPOINT Endpoint)
VOID NTAPI USBPORT_FlushAbortList(IN PUSBPORT_ENDPOINT Endpoint)
BOOLEAN NTAPI USBPORT_EndpointWorker(IN PUSBPORT_ENDPOINT Endpoint, IN BOOLEAN LockNotChecked)
VOID NTAPI USBPORT_InvalidateEndpointHandler(IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_ENDPOINT Endpoint, IN ULONG Type)
ULONG NTAPI USBPORT_GetEndpointState(IN PUSBPORT_ENDPOINT Endpoint)
#define RemoveEntryList(Entry)
#define InsertTailList(ListHead, Entry)
#define ExAllocatePoolWithTag(hernya, size, tag)
#define IsListEmpty(ListHead)
#define KeRaiseIrql(irql, oldIrql)
#define KeReleaseSpinLock(sl, irql)
#define KeLowerIrql(oldIrql)
#define KeAcquireSpinLock(sl, irql)
#define RemoveHeadList(ListHead)
#define InitializeListHead(ListHead)
_Inout_ PUSB_DEVICE_HANDLE DeviceHandle
#define InterlockedCompareExchange
IoSetCancelRoutine(Irp, CancelRoutine)
#define IoCompleteRequest
VOID NTAPI IoReleaseCancelSpinLock(IN KIRQL Irql)
VOID NTAPI IoAcquireCancelSpinLock(OUT PKIRQL Irql)
VOID NTAPI KeBugCheckEx(_In_ ULONG BugCheckCode, _In_ ULONG_PTR BugCheckParameter1, _In_ ULONG_PTR BugCheckParameter2, _In_ ULONG_PTR BugCheckParameter3, _In_ ULONG_PTR BugCheckParameter4)
#define KeAcquireSpinLockAtDpcLevel(SpinLock)
#define KeReleaseSpinLockFromDpcLevel(SpinLock)
base of all file and directory entries
struct _LIST_ENTRY * Blink
struct _LIST_ENTRY * Flink
struct _URB_CONTROL_TRANSFER UrbControlTransfer
struct _URB_HEADER UrbHeader
LIST_ENTRY FlushControllerLink
LIST_ENTRY PendingTransferList
KSPIN_LOCK EndpointSpinLock
USBPORT_ENDPOINT_PROPERTIES EndpointProperties
ULONG TransferBufferLength
KSPIN_LOCK TransferSpinLock
LIST_ENTRY SplitTransfersList
USBPORT_TRANSFER_PARAMETERS TransferParameters
PUSBPORT_ENDPOINT Endpoint
#define RtlCopyMemory(Destination, Source, Length)
#define RtlZeroMemory(Destination, Length)
#define CONTAINING_RECORD(address, type, field)
#define STATUS_DEVICE_NOT_CONNECTED
#define USBD_STATUS_DEVICE_GONE
#define USBD_STATUS_CANCELED
#define USBD_STATUS_SUCCESS
#define USBD_TRANSFER_DIRECTION_IN
#define URB_FUNCTION_CONTROL_TRANSFER
#define URB_FROM_IRP(Irp)
#define USBD_STATUS_PENDING
#define USBD_DEFAULT_PIPE_TRANSFER
#define DPRINT_QUEUE(...)
#define USBPORT_ENDPOINT_REMOVE
#define USBPORT_TRANSFER_TYPE_CONTROL
#define USBPORT_ENDPOINT_CLOSED
VOID NTAPI USBPORT_FlushMapTransfers(IN PDEVICE_OBJECT FdoDevice)
VOID NTAPI USBPORT_CompleteTransfer(IN PURB Urb, IN USBD_STATUS TransferStatus)
NTSTATUS NTAPI USBPORT_Wait(IN PVOID MiniPortExtension, IN ULONG Milliseconds)
NTSTATUS NTAPI USBPORT_USBDStatusToNtStatus(IN PURB Urb, IN USBD_STATUS USBDStatus)
#define USBPORT_DMA_DIRECTION_TO_DEVICE
#define ENDPOINT_FLAG_ABORTING
#define INVALIDATE_ENDPOINT_INT_NEXT_SOF
#define USBPORT_DMA_DIRECTION_FROM_DEVICE
#define TRANSFER_FLAG_CANCELED
#define ENDPOINT_FLAG_ROOTHUB_EP0
#define TRANSFER_FLAG_PARENT
#define INVALIDATE_ENDPOINT_WORKER_THREAD
#define USBPORT_FLAG_HC_SUSPEND
#define TRANSFER_FLAG_SUBMITED
#define ENDPOINT_FLAG_DMA_TYPE
#define ENDPOINT_FLAG_NUKE
#define TRANSFER_FLAG_DEVICE_GONE
#define TRANSFER_FLAG_ABORTED
_In_ PDEVICE_OBJECT DeviceObject
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
_Must_inspect_result_ _In_ WDFQUEUE _In_opt_ WDFREQUEST _In_opt_ WDFFILEOBJECT _Inout_opt_ PWDF_REQUEST_PARAMETERS Parameters
_Must_inspect_result_ _In_ WDFCMRESLIST List
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql