ReactOS 0.4.16-dev-974-g5022a45
endpoint.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS USB Port Driver
3 * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4 * PURPOSE: USBPort endpoint functions
5 * COPYRIGHT: Copyright 2017 Vadim Galyant <vgal@rambler.ru>
6 */
7
8#include "usbport.h"
9
10#define NDEBUG
11#include <debug.h>
12
13#define NDEBUG_USBPORT_CORE
14#include "usbdebug.h"
15
19 IN PUSBPORT_ENDPOINT Endpoint)
20{
21 PUSBPORT_ENDPOINT_PROPERTIES EndpointProperties;
22 ULONG Bandwidth;
23 ULONG Overhead;
24
25 DPRINT("USBPORT_CalculateUsbBandwidth ... \n");
26
27 EndpointProperties = &Endpoint->EndpointProperties;
28
29 switch (EndpointProperties->TransferType)
30 {
33 break;
34
37 break;
38
39 default: //USBPORT_TRANSFER_TYPE_CONTROL or USBPORT_TRANSFER_TYPE_BULK
40 Overhead = 0;
41 break;
42 }
43
44 if (Overhead == 0)
45 {
46 Bandwidth = 0;
47 }
48 else
49 {
50 Bandwidth = (EndpointProperties->TotalMaxPacketSize + Overhead) * USB2_BIT_STUFFING_OVERHEAD;
51 }
52
53 if (EndpointProperties->DeviceSpeed == UsbLowSpeed)
54 {
55 Bandwidth *= 8;
56 }
57
58 return Bandwidth;
59}
60
64 IN PUSBPORT_ENDPOINT Endpoint)
65{
67 PUSBPORT_ENDPOINT_PROPERTIES EndpointProperties;
68 ULONG TransferType;
69 ULONG TotalBusBandwidth;
70 ULONG EndpointBandwidth;
71 ULONG MinBandwidth;
72 PULONG Bandwidth;
73 ULONG MaxBandwidth = 0;
74 ULONG ix;
76 LONG ScheduleOffset = -1;
78 ULONG Factor;
79 UCHAR Bit;
80
81 DPRINT("USBPORT_AllocateBandwidth: FdoDevice - %p, Endpoint - %p\n",
82 FdoDevice,
83 Endpoint);
84
85 FdoExtension = FdoDevice->DeviceExtension;
86 EndpointProperties = &Endpoint->EndpointProperties;
87 TransferType = EndpointProperties->TransferType;
88
89 if (TransferType == USBPORT_TRANSFER_TYPE_BULK ||
90 TransferType == USBPORT_TRANSFER_TYPE_CONTROL ||
91 Endpoint->Flags & ENDPOINT_FLAG_ROOTHUB_EP0)
92 {
93 EndpointProperties->ScheduleOffset = 0;
94 return TRUE;
95 }
96
97 TotalBusBandwidth = FdoExtension->TotalBusBandwidth;
98 EndpointBandwidth = EndpointProperties->UsbBandwidth;
99
100 Period = EndpointProperties->Period;
101 ASSERT(Period != 0);
102 Factor = USB2_FRAMES / Period;
103
104 for (Offset = 0; Offset < Period; Offset++)
105 {
106 MinBandwidth = TotalBusBandwidth;
107 Bandwidth = &FdoExtension->Bandwidth[Offset * Factor];
108
109 for (ix = 1; *Bandwidth >= EndpointBandwidth; ix++)
110 {
111 MinBandwidth = min(MinBandwidth, *Bandwidth);
112
113 Bandwidth++;
114
115 if (Factor <= ix)
116 {
117 if (MinBandwidth > MaxBandwidth)
118 {
119 MaxBandwidth = MinBandwidth;
120 ScheduleOffset = Offset;
121
122 DPRINT("USBPORT_AllocateBandwidth: ScheduleOffset - %X\n",
123 ScheduleOffset);
124 }
125
126 break;
127 }
128 }
129 }
130
131 DPRINT("USBPORT_AllocateBandwidth: ScheduleOffset - %X\n", ScheduleOffset);
132
133 if (ScheduleOffset != -1)
134 {
135 EndpointProperties->ScheduleOffset = ScheduleOffset;
136
137 Bandwidth = &FdoExtension->Bandwidth[ScheduleOffset * Factor];
138
139 for (Factor = USB2_FRAMES / Period; Factor; Factor--)
140 {
141 FdoExtension->Bandwidth[ScheduleOffset * Factor] -= EndpointBandwidth;
142 }
143
144 if (TransferType == USBPORT_TRANSFER_TYPE_INTERRUPT)
145 {
146 for (Bit = 0x80; Bit != 0; Bit >>= 1)
147 {
148 if ((Period & Bit) != 0)
149 {
150 Period = Bit;
151 break;
152 }
153 }
154
155 DPRINT("USBPORT_AllocateBandwidth: FIXME AllocatedInterrupt_XXms\n");
156 }
157 else
158 {
159 DPRINT("USBPORT_AllocateBandwidth: FIXME AllocatedIso\n");
160 }
161 }
162
163 DPRINT("USBPORT_AllocateBandwidth: FIXME USBPORT_UpdateAllocatedBw\n");
164
165 DPRINT("USBPORT_AllocateBandwidth: ScheduleOffset - %X\n", ScheduleOffset);
166 return ScheduleOffset != -1;
167}
168
169VOID
170NTAPI
172 IN PUSBPORT_ENDPOINT Endpoint)
173{
175 PUSBPORT_ENDPOINT_PROPERTIES EndpointProperties;
176 ULONG TransferType;
178 ULONG EndpointBandwidth;
180 ULONG Factor;
181 UCHAR Bit;
182
183 DPRINT("USBPORT_FreeBandwidth: FdoDevice - %p, Endpoint - %p\n",
184 FdoDevice,
185 Endpoint);
186
187 FdoExtension = FdoDevice->DeviceExtension;
188
189 EndpointProperties = &Endpoint->EndpointProperties;
190 TransferType = EndpointProperties->TransferType;
191
192 if (TransferType == USBPORT_TRANSFER_TYPE_BULK ||
193 TransferType == USBPORT_TRANSFER_TYPE_CONTROL ||
194 (Endpoint->Flags & ENDPOINT_FLAG_ROOTHUB_EP0))
195 {
196 return;
197 }
198
199 Offset = Endpoint->EndpointProperties.ScheduleOffset;
200 EndpointBandwidth = Endpoint->EndpointProperties.UsbBandwidth;
201
202 Period = Endpoint->EndpointProperties.Period;
203 ASSERT(Period != 0);
204
205 for (Factor = USB2_FRAMES / Period; Factor; Factor--)
206 {
207 FdoExtension->Bandwidth[Offset * Factor] += EndpointBandwidth;
208 }
209
210 if (TransferType == USBPORT_TRANSFER_TYPE_INTERRUPT)
211 {
212 for (Bit = 0x80; Bit != 0; Bit >>= 1)
213 {
214 if ((Period & Bit) != 0)
215 {
216 Period = Bit;
217 break;
218 }
219 }
220
221 ASSERT(Period != 0);
222
223 DPRINT("USBPORT_AllocateBandwidth: FIXME AllocatedInterrupt_XXms\n");
224 }
225 else
226 {
227 DPRINT("USBPORT_AllocateBandwidth: FIXME AllocatedIso\n");
228 }
229
230 DPRINT1("USBPORT_FreeBandwidth: FIXME USBPORT_UpdateAllocatedBw\n");
231}
232
233UCHAR
234NTAPI
236{
238
239 DPRINT("USBPORT_NormalizeHsInterval: Interval - %x\n", Interval);
240
242
243 if (Interval)
244 interval = Interval - 1;
245
246 if (interval > 5)
247 interval = 5;
248
249 return 1 << interval;
250}
251
253NTAPI
255 IN PUSBPORT_ENDPOINT Endpoint,
256 IN PULONG TransferCount)
257{
259 PUSBPORT_TRANSFER Transfer;
261
262 DPRINT_CORE("USBPORT_EndpointHasQueuedTransfers: ... \n");
263
264 KeAcquireSpinLock(&Endpoint->EndpointSpinLock, &Endpoint->EndpointOldIrql);
265
266 if (!IsListEmpty(&Endpoint->PendingTransferList))
267 Result = TRUE;
268
269 if (!IsListEmpty(&Endpoint->TransferList))
270 {
271 Result = TRUE;
272
273 if (TransferCount)
274 {
275 *TransferCount = 0;
276
277 for (Entry = Endpoint->TransferList.Flink;
278 Entry && Entry != &Endpoint->TransferList;
279 Entry = Transfer->TransferLink.Flink)
280 {
281 Transfer = CONTAINING_RECORD(Entry,
283 TransferLink);
284
285 if (Transfer->Flags & TRANSFER_FLAG_SUBMITED)
286 {
287 ++*TransferCount;
288 }
289 }
290 }
291 }
292
293 KeReleaseSpinLock(&Endpoint->EndpointSpinLock, Endpoint->EndpointOldIrql);
294
295 return Result;
296}
297
298VOID
299NTAPI
301{
303 PLIST_ENTRY EndpointList;
304 PUSBPORT_ENDPOINT Endpoint;
306
307 DPRINT("USBPORT_NukeAllEndpoints \n");
308
309 FdoExtension = FdoDevice->DeviceExtension;
310
311 KeAcquireSpinLock(&FdoExtension->EndpointListSpinLock, &OldIrql);
312
313 EndpointList = FdoExtension->EndpointList.Flink;
314
315 while (EndpointList && (EndpointList != &FdoExtension->EndpointList))
316 {
317 Endpoint = CONTAINING_RECORD(EndpointList,
319 EndpointLink);
320
321 if (!(Endpoint->Flags & ENDPOINT_FLAG_ROOTHUB_EP0))
322 Endpoint->Flags |= ENDPOINT_FLAG_NUKE;
323
324 EndpointList = Endpoint->EndpointLink.Flink;
325 }
326
327 KeReleaseSpinLock(&FdoExtension->EndpointListSpinLock, OldIrql);
328}
329
330ULONG
331NTAPI
333{
334 ULONG State;
335
336 //DPRINT("USBPORT_GetEndpointState \n");
337
338 KeAcquireSpinLockAtDpcLevel(&Endpoint->StateChangeSpinLock);
339
340 if (Endpoint->StateLast != Endpoint->StateNext)
341 {
343 }
344 else
345 {
346 State = Endpoint->StateLast;
347 }
348
349 KeReleaseSpinLockFromDpcLevel(&Endpoint->StateChangeSpinLock);
350
352 {
353 DPRINT("USBPORT_GetEndpointState: Endpoint - %p, State - %x\n",
354 Endpoint,
355 State);
356 }
357
358 return State;
359}
360
361VOID
362NTAPI
364 IN ULONG State)
365{
366 PDEVICE_OBJECT FdoDevice;
370
371 DPRINT("USBPORT_SetEndpointState: Endpoint - %p, State - %x\n",
372 Endpoint,
373 State);
374
375 FdoDevice = Endpoint->FdoDevice;
376 FdoExtension = FdoDevice->DeviceExtension;
377 Packet = &FdoExtension->MiniPortInterface->Packet;
378
379 KeAcquireSpinLock(&Endpoint->StateChangeSpinLock,
380 &Endpoint->EndpointStateOldIrql);
381
382 if (!(Endpoint->Flags & ENDPOINT_FLAG_ROOTHUB_EP0))
383 {
384 if (Endpoint->Flags & ENDPOINT_FLAG_NUKE)
385 {
386 Endpoint->StateLast = State;
387 Endpoint->StateNext = State;
388
389 KeReleaseSpinLock(&Endpoint->StateChangeSpinLock,
390 Endpoint->EndpointStateOldIrql);
391
393 Endpoint,
395 return;
396 }
397
398 KeReleaseSpinLock(&Endpoint->StateChangeSpinLock,
399 Endpoint->EndpointStateOldIrql);
400
401 KeAcquireSpinLock(&FdoExtension->MiniportSpinLock, &OldIrql);
402 Packet->SetEndpointState(FdoExtension->MiniPortExt,
403 Endpoint + 1,
404 State);
405 KeReleaseSpinLock(&FdoExtension->MiniportSpinLock, OldIrql);
406
407 Endpoint->StateNext = State;
408
409 KeAcquireSpinLock(&FdoExtension->MiniportSpinLock, &OldIrql);
410 Endpoint->FrameNumber = Packet->Get32BitFrameNumber(FdoExtension->MiniPortExt);
411 KeReleaseSpinLock(&FdoExtension->MiniportSpinLock, OldIrql);
412
413 ExInterlockedInsertTailList(&FdoExtension->EpStateChangeList,
414 &Endpoint->StateChangeLink,
415 &FdoExtension->EpStateChangeSpinLock);
416
417 KeAcquireSpinLock(&FdoExtension->MiniportSpinLock, &OldIrql);
418 Packet->InterruptNextSOF(FdoExtension->MiniPortExt);
419 KeReleaseSpinLock(&FdoExtension->MiniportSpinLock, OldIrql);
420 }
421 else
422 {
423 Endpoint->StateLast = State;
424 Endpoint->StateNext = State;
425
427 {
428 KeReleaseSpinLock(&Endpoint->StateChangeSpinLock,
429 Endpoint->EndpointStateOldIrql);
430
432 Endpoint,
434 return;
435 }
436
437 KeReleaseSpinLock(&Endpoint->StateChangeSpinLock,
438 Endpoint->EndpointStateOldIrql);
439 }
440}
441
442VOID
443NTAPI
446{
447 DPRINT("USBPORT_AddPipeHandle: DeviceHandle - %p, PipeHandle - %p\n",
449 PipeHandle);
450
451 InsertTailList(&DeviceHandle->PipeHandleList, &PipeHandle->PipeLink);
452}
453
454VOID
455NTAPI
458{
459 DPRINT("USBPORT_RemovePipeHandle: PipeHandle - %p\n", PipeHandle);
460
461 RemoveEntryList(&PipeHandle->PipeLink);
462
463 PipeHandle->PipeLink.Flink = NULL;
464 PipeHandle->PipeLink.Blink = NULL;
465}
466
468NTAPI
471{
472 PLIST_ENTRY HandleList;
473 PUSBPORT_PIPE_HANDLE CurrentHandle;
474
475 //DPRINT("USBPORT_ValidatePipeHandle: DeviceHandle - %p, PipeHandle - %p\n",
476 // DeviceHandle,
477 // PipeHandle);
478
479 HandleList = DeviceHandle->PipeHandleList.Flink;
480
481 while (HandleList != &DeviceHandle->PipeHandleList)
482 {
483 CurrentHandle = CONTAINING_RECORD(HandleList,
485 PipeLink);
486
487 HandleList = HandleList->Flink;
488
489 if (CurrentHandle == PipeHandle)
490 return TRUE;
491 }
492
493 return FALSE;
494}
495
497NTAPI
499 IN PUSBPORT_ENDPOINT Endpoint)
500{
504
505 DPRINT1("USBPORT_DeleteEndpoint: Endpoint - %p\n", Endpoint);
506
507 FdoExtension = FdoDevice->DeviceExtension;
508
509 if ((Endpoint->WorkerLink.Flink && Endpoint->WorkerLink.Blink) ||
510 Endpoint->LockCounter != -1)
511 {
512 KeAcquireSpinLock(&FdoExtension->EndpointListSpinLock, &OldIrql);
513
514 ExInterlockedInsertTailList(&FdoExtension->EndpointClosedList,
515 &Endpoint->CloseLink,
516 &FdoExtension->EndpointClosedSpinLock);
517
518 KeReleaseSpinLock(&FdoExtension->EndpointListSpinLock, OldIrql);
519
520 Result = FALSE;
521 }
522 else
523 {
524 KeAcquireSpinLock(&FdoExtension->EndpointListSpinLock, &OldIrql);
525
526 RemoveEntryList(&Endpoint->EndpointLink);
527 Endpoint->EndpointLink.Flink = NULL;
528 Endpoint->EndpointLink.Blink = NULL;
529
530 KeReleaseSpinLock(&FdoExtension->EndpointListSpinLock, OldIrql);
531
532 MiniportCloseEndpoint(FdoDevice, Endpoint);
533
534 if (Endpoint->HeaderBuffer)
535 {
536 USBPORT_FreeCommonBuffer(FdoDevice, Endpoint->HeaderBuffer);
537 }
538
540
541 Result = TRUE;
542 }
543
544 return Result;
545}
546
547VOID
548NTAPI
550 IN PUSBPORT_ENDPOINT Endpoint)
551{
554 BOOLEAN IsDoDisablePeriodic;
555 ULONG TransferType;
557
558 DPRINT("MiniportCloseEndpoint: Endpoint - %p\n", Endpoint);
559
560 FdoExtension = FdoDevice->DeviceExtension;
561 Packet = &FdoExtension->MiniPortInterface->Packet;
562
563 KeAcquireSpinLock(&FdoExtension->MiniportSpinLock, &OldIrql);
564
565 if (Endpoint->Flags & ENDPOINT_FLAG_OPENED)
566 {
567 TransferType = Endpoint->EndpointProperties.TransferType;
568
569 if (TransferType == USBPORT_TRANSFER_TYPE_INTERRUPT ||
570 TransferType == USBPORT_TRANSFER_TYPE_ISOCHRONOUS)
571 {
572 --FdoExtension->PeriodicEndpoints;
573 }
574
575 IsDoDisablePeriodic = FdoExtension->PeriodicEndpoints == 0;
576
577 Packet->CloseEndpoint(FdoExtension->MiniPortExt,
578 Endpoint + 1,
579 IsDoDisablePeriodic);
580
581 Endpoint->Flags &= ~ENDPOINT_FLAG_OPENED;
582 Endpoint->Flags |= ENDPOINT_FLAG_CLOSED;
583 }
584
585 KeReleaseSpinLock(&FdoExtension->MiniportSpinLock, OldIrql);
586}
587
588VOID
589NTAPI
591 IN PDEVICE_OBJECT FdoDevice,
593{
596 PUSBPORT_ENDPOINT Endpoint;
598 PUSB2_TT_EXTENSION TtExtension;
599 ULONG ix;
600 BOOLEAN IsReady;
602
603 DPRINT1("USBPORT_ClosePipe \n");
604
605 FdoExtension = FdoDevice->DeviceExtension;
606
608 return;
609
611
613
615 {
616 PipeHandle->Flags &= ~PIPE_HANDLE_FLAG_NULL_PACKET_SIZE;
617 return;
618 }
619
620 Endpoint = PipeHandle->Endpoint;
621
622 KeAcquireSpinLock(&FdoExtension->EndpointListSpinLock, &OldIrql);
623
624 if ((Endpoint->Flags & ENDPOINT_FLAG_ROOTHUB_EP0) &&
626 {
627 PdoExtension = FdoExtension->RootHubPdo->DeviceExtension;
628 PdoExtension->Endpoint = NULL;
629 }
630
631 KeReleaseSpinLock(&FdoExtension->EndpointListSpinLock, OldIrql);
632
633 while (TRUE)
634 {
635 IsReady = TRUE;
636
638 &Endpoint->EndpointOldIrql);
639
640 if (!IsListEmpty(&Endpoint->PendingTransferList))
641 IsReady = FALSE;
642
643 if (!IsListEmpty(&Endpoint->TransferList))
644 IsReady = FALSE;
645
646 if (!IsListEmpty(&Endpoint->CancelList))
647 IsReady = FALSE;
648
649 if (!IsListEmpty(&Endpoint->AbortList))
650 IsReady = FALSE;
651
653 if (Endpoint->StateLast != Endpoint->StateNext)
654 IsReady = FALSE;
656
658 Endpoint->EndpointOldIrql);
659
660 if (InterlockedIncrement(&Endpoint->LockCounter))
661 IsReady = FALSE;
663
664 if (IsReady == TRUE)
665 break;
666
667 USBPORT_Wait(FdoDevice, 1);
668 }
669
670 Endpoint->DeviceHandle = NULL;
671 Packet = &FdoExtension->MiniPortInterface->Packet;
672
673 if (Packet->MiniPortFlags & USB_MINIPORT_FLAGS_USB2)
674 {
675 USBPORT_FreeBandwidthUSB2(FdoDevice, Endpoint);
676
677 KeAcquireSpinLock(&FdoExtension->TtSpinLock, &OldIrql);
678
679 TtExtension = Endpoint->TtExtension;
680 DPRINT1("USBPORT_ClosePipe: TtExtension - %p\n", TtExtension);
681
682 if (TtExtension)
683 {
684 RemoveEntryList(&Endpoint->TtLink);
685
686 Endpoint->TtLink.Flink = NULL;
687 Endpoint->TtLink.Blink = NULL;
688
689 if (TtExtension->Flags & USB2_TT_EXTENSION_FLAG_DELETED)
690 {
691 if (IsListEmpty(&TtExtension->EndpointList))
692 {
693 USBPORT_UpdateAllocatedBwTt(TtExtension);
694
695 for (ix = 0; ix < USB2_FRAMES; ix++)
696 {
697 FdoExtension->Bandwidth[ix] += TtExtension->MaxBandwidth;
698 }
699
700 DPRINT1("USBPORT_ClosePipe: ExFreePoolWithTag TtExtension - %p\n", TtExtension);
701 ExFreePoolWithTag(TtExtension, USB_PORT_TAG);
702 }
703 }
704 }
705
707 }
708 else
709 {
710 USBPORT_FreeBandwidth(FdoDevice, Endpoint);
711 }
712
713 KeAcquireSpinLock(&Endpoint->EndpointSpinLock, &Endpoint->EndpointOldIrql);
716
718}
719
721NTAPI
723 IN PUSBPORT_ENDPOINT Endpoint)
724{
728 ULONG TransferType;
729 MPSTATUS MpStatus;
730
731 DPRINT("MiniportOpenEndpoint: Endpoint - %p\n", Endpoint);
732
733 FdoExtension = FdoDevice->DeviceExtension;
734 Packet = &FdoExtension->MiniPortInterface->Packet;
735
736 KeAcquireSpinLock(&FdoExtension->MiniportSpinLock, &OldIrql);
737
738 Endpoint->Flags &= ~ENDPOINT_FLAG_CLOSED;
739
740 MpStatus = Packet->OpenEndpoint(FdoExtension->MiniPortExt,
741 &Endpoint->EndpointProperties,
742 Endpoint + 1);
743
744 if (!MpStatus)
745 {
746 TransferType = Endpoint->EndpointProperties.TransferType;
747
748 if (TransferType == USBPORT_TRANSFER_TYPE_INTERRUPT ||
749 TransferType == USBPORT_TRANSFER_TYPE_ISOCHRONOUS)
750 {
751 ++FdoExtension->PeriodicEndpoints;
752 }
753
754 Endpoint->Flags |= ENDPOINT_FLAG_OPENED;
755 }
756
757 KeReleaseSpinLock(&FdoExtension->MiniportSpinLock, OldIrql);
758 return MpStatus;
759}
760
762NTAPI
767{
771 SIZE_T EndpointSize;
772 PUSBPORT_ENDPOINT Endpoint;
773 PUSBPORT_ENDPOINT_PROPERTIES EndpointProperties;
774 PUSB_ENDPOINT_DESCRIPTOR EndpointDescriptor;
778 USBPORT_ENDPOINT_REQUIREMENTS EndpointRequirements = {0};
780 MPSTATUS MpStatus;
781 USBD_STATUS USBDStatus = USBD_STATUS_SUCCESS;
784 USHORT MaxPacketSize;
785 USHORT AdditionalTransaction;
786 BOOLEAN IsAllocatedBandwidth;
787 ULONG RetryCount;
788
789 DPRINT1("USBPORT_OpenPipe: DeviceHandle - %p, FdoDevice - %p, PipeHandle - %p\n",
791 FdoDevice,
792 PipeHandle);
793
794 FdoExtension = FdoDevice->DeviceExtension;
795 Packet = &FdoExtension->MiniPortInterface->Packet;
796
797 EndpointSize = sizeof(USBPORT_ENDPOINT) + Packet->MiniPortEndpointSize;
798
799 if (Packet->MiniPortFlags & USB_MINIPORT_FLAGS_USB2)
800 {
801 EndpointSize += sizeof(USB2_TT_ENDPOINT);
802 }
803
804 if (PipeHandle->EndpointDescriptor.wMaxPacketSize == 0)
805 {
807
808 PipeHandle->Flags = (PipeHandle->Flags & ~PIPE_HANDLE_FLAG_CLOSED) |
810
811 PipeHandle->Endpoint = (PUSBPORT_ENDPOINT)-1;
812
813 return STATUS_SUCCESS;
814 }
815
816 Endpoint = ExAllocatePoolWithTag(NonPagedPool, EndpointSize, USB_PORT_TAG);
817
818 if (!Endpoint)
819 {
820 DPRINT1("USBPORT_OpenPipe: Not allocated Endpoint!\n");
822 return Status;
823 }
824
825 RtlZeroMemory(Endpoint, EndpointSize);
826
827 Endpoint->FdoDevice = FdoDevice;
828 Endpoint->DeviceHandle = DeviceHandle;
829 Endpoint->LockCounter = -1;
830
831 Endpoint->TtExtension = DeviceHandle->TtExtension;
832
833 if (DeviceHandle->TtExtension)
834 {
835 ExInterlockedInsertTailList(&DeviceHandle->TtExtension->EndpointList,
836 &Endpoint->TtLink,
837 &FdoExtension->TtSpinLock);
838 }
839
840 if (Packet->MiniPortFlags & USB_MINIPORT_FLAGS_USB2)
841 {
842 Endpoint->TtEndpoint = (PUSB2_TT_ENDPOINT)((ULONG_PTR)Endpoint +
843 sizeof(USBPORT_ENDPOINT) +
844 Packet->MiniPortEndpointSize);
845 }
846 else
847 {
848 Endpoint->TtEndpoint = NULL;
849 }
850
853
856 InitializeListHead(&Endpoint->CancelList);
857 InitializeListHead(&Endpoint->AbortList);
858
859 EndpointProperties = &Endpoint->EndpointProperties;
860 EndpointDescriptor = &PipeHandle->EndpointDescriptor;
861
862 MaxPacketSize = EndpointDescriptor->wMaxPacketSize & 0x7FF;
863 AdditionalTransaction = (EndpointDescriptor->wMaxPacketSize >> 11) & 3;
864
865 EndpointProperties->DeviceAddress = DeviceHandle->DeviceAddress;
866 EndpointProperties->DeviceSpeed = DeviceHandle->DeviceSpeed;
867 EndpointProperties->Period = 0;
868 EndpointProperties->EndpointAddress = EndpointDescriptor->bEndpointAddress;
869 EndpointProperties->TransactionPerMicroframe = AdditionalTransaction + 1;
870 EndpointProperties->MaxPacketSize = MaxPacketSize;
871 EndpointProperties->TotalMaxPacketSize = MaxPacketSize *
872 (AdditionalTransaction + 1);
873
874 if (Endpoint->TtExtension)
875 {
876 EndpointProperties->HubAddr = Endpoint->TtExtension->DeviceAddress;
877 }
878 else
879 {
880 EndpointProperties->HubAddr = -1;
881 }
882
883 EndpointProperties->PortNumber = DeviceHandle->PortNumber;
884
885 switch (EndpointDescriptor->bmAttributes & USB_ENDPOINT_TYPE_MASK)
886 {
888 EndpointProperties->TransferType = USBPORT_TRANSFER_TYPE_CONTROL;
889
890 if (EndpointProperties->EndpointAddress == 0)
891 {
892 EndpointProperties->MaxTransferSize = 0x1000; // OUT Ep0
893 }
894 else
895 {
896 EndpointProperties->MaxTransferSize = 0x10000;
897 }
898
899 break;
900
902 DPRINT1("USBPORT_OpenPipe: USB_ENDPOINT_TYPE_ISOCHRONOUS UNIMPLEMENTED. FIXME. \n");
904 EndpointProperties->MaxTransferSize = 0x1000000;
905 break;
906
908 EndpointProperties->TransferType = USBPORT_TRANSFER_TYPE_BULK;
909 EndpointProperties->MaxTransferSize = 0x10000;
910 break;
911
913 EndpointProperties->TransferType = USBPORT_TRANSFER_TYPE_INTERRUPT;
914 EndpointProperties->MaxTransferSize = 0x400;
915 break;
916 }
917
918 if (EndpointProperties->TransferType == USBPORT_TRANSFER_TYPE_INTERRUPT)
919 {
920 if (EndpointProperties->DeviceSpeed == UsbHighSpeed)
921 {
922 Interval = USBPORT_NormalizeHsInterval(EndpointDescriptor->bInterval);
923 }
924 else
925 {
926 Interval = EndpointDescriptor->bInterval;
927 }
928
929 EndpointProperties->Period = ENDPOINT_INTERRUPT_32ms;
930
931 if (Interval && (Interval < USB2_FRAMES))
932 {
933 if ((EndpointProperties->DeviceSpeed != UsbLowSpeed) ||
935 {
937 {
938 Period = EndpointProperties->Period;
939
940 do
941 {
942 Period >>= 1;
943 }
944 while (!(Period & Interval));
945
946 EndpointProperties->Period = Period;
947 }
948 }
949 else
950 {
951 EndpointProperties->Period = ENDPOINT_INTERRUPT_8ms;
952 }
953 }
954 }
955
956 if (EndpointProperties->TransferType == USB_ENDPOINT_TYPE_ISOCHRONOUS)
957 {
958 if (EndpointProperties->DeviceSpeed == UsbHighSpeed)
959 {
960 EndpointProperties->Period =
961 USBPORT_NormalizeHsInterval(EndpointDescriptor->bInterval);
962 }
963 else
964 {
965 EndpointProperties->Period = ENDPOINT_INTERRUPT_1ms;
966 }
967 }
968
969 if ((DeviceHandle->Flags & DEVICE_HANDLE_FLAG_ROOTHUB) != 0)
970 {
971 Endpoint->Flags |= ENDPOINT_FLAG_ROOTHUB_EP0;
972 }
973
974 if (Packet->MiniPortFlags & USB_MINIPORT_FLAGS_USB2)
975 {
976 IsAllocatedBandwidth = USBPORT_AllocateBandwidthUSB2(FdoDevice, Endpoint);
977 }
978 else
979 {
980 EndpointProperties->UsbBandwidth = USBPORT_CalculateUsbBandwidth(FdoDevice,
981 Endpoint);
982
983 IsAllocatedBandwidth = USBPORT_AllocateBandwidth(FdoDevice, Endpoint);
984 }
985
986 if (!IsAllocatedBandwidth)
987 {
989
990 if (UsbdStatus)
991 {
993 }
994
995 goto ExitWithError;
996 }
997
999 EndpointProperties->Direction = Direction;
1000
1001 if (DeviceHandle->IsRootHub)
1002 {
1003 Endpoint->EndpointWorker = 0; // USBPORT_RootHubEndpointWorker;
1004
1005 Endpoint->Flags |= ENDPOINT_FLAG_ROOTHUB_EP0;
1006
1009
1010 PdoExtension = FdoExtension->RootHubPdo->DeviceExtension;
1011
1012 if (EndpointProperties->TransferType == USBPORT_TRANSFER_TYPE_INTERRUPT)
1013 {
1014 PdoExtension->Endpoint = Endpoint;
1015 }
1016
1017 USBDStatus = USBD_STATUS_SUCCESS;
1018 }
1019 else
1020 {
1021 Endpoint->EndpointWorker = 1; // USBPORT_DmaEndpointWorker;
1022
1023 KeAcquireSpinLock(&FdoExtension->MiniportSpinLock, &OldIrql);
1024
1025 Packet->QueryEndpointRequirements(FdoExtension->MiniPortExt,
1026 &Endpoint->EndpointProperties,
1027 &EndpointRequirements);
1028
1029 KeReleaseSpinLock(&FdoExtension->MiniportSpinLock, OldIrql);
1030
1031 if ((EndpointProperties->TransferType == USBPORT_TRANSFER_TYPE_BULK) ||
1032 (EndpointProperties->TransferType == USBPORT_TRANSFER_TYPE_INTERRUPT))
1033 {
1034 EndpointProperties->MaxTransferSize = EndpointRequirements.MaxTransferSize;
1035 }
1036
1037 if (EndpointRequirements.HeaderBufferSize)
1038 {
1039 HeaderBuffer = USBPORT_AllocateCommonBuffer(FdoDevice,
1040 EndpointRequirements.HeaderBufferSize);
1041 }
1042 else
1043 {
1044 HeaderBuffer = NULL;
1045 }
1046
1047 if (HeaderBuffer || (EndpointRequirements.HeaderBufferSize == 0))
1048 {
1049 Endpoint->HeaderBuffer = HeaderBuffer;
1050
1051 if (HeaderBuffer)
1052 {
1053 EndpointProperties->BufferVA = HeaderBuffer->VirtualAddress;
1054 EndpointProperties->BufferPA = HeaderBuffer->PhysicalAddress;
1055 EndpointProperties->BufferLength = HeaderBuffer->BufferLength; // BufferLength + LengthPadded;
1056 }
1057
1058 MpStatus = MiniportOpenEndpoint(FdoDevice, Endpoint);
1059
1060 Endpoint->Flags |= ENDPOINT_FLAG_DMA_TYPE;
1062
1063 if (MpStatus == 0)
1064 {
1065 ULONG State;
1066
1068 &Endpoint->EndpointOldIrql);
1069
1072
1074
1076 Endpoint->EndpointOldIrql);
1077
1078 /* Wait maximum 1 second for the endpoint to be active */
1079 for (RetryCount = 0; RetryCount < 1000; RetryCount++)
1080 {
1082 &Endpoint->EndpointOldIrql);
1083
1084 State = USBPORT_GetEndpointState(Endpoint);
1085
1087 Endpoint->EndpointOldIrql);
1088
1090 {
1091 break;
1092 }
1093
1094 USBPORT_Wait(FdoDevice, 1); // 1 msec.
1095 }
1097 {
1098 DPRINT1("Timeout State %x\n", State);
1099 USBDStatus = USBD_STATUS_TIMEOUT;
1100 }
1101 }
1102 }
1103 else
1104 {
1105 MpStatus = MP_STATUS_NO_RESOURCES;
1106 Endpoint->HeaderBuffer = NULL;
1107 }
1108
1109 if (MpStatus)
1110 {
1112 }
1113 }
1114
1115 if (UsbdStatus)
1116 {
1117 *UsbdStatus = USBDStatus;
1118 }
1119
1121
1122 if (NT_SUCCESS(Status))
1123 {
1125
1127 &Endpoint->EndpointLink,
1128 &FdoExtension->EndpointListSpinLock);
1129
1130 PipeHandle->Endpoint = Endpoint;
1131 PipeHandle->Flags &= ~PIPE_HANDLE_FLAG_CLOSED;
1132
1133 return Status;
1134 }
1135
1136ExitWithError:
1137
1138 if (Endpoint)
1139 {
1140 if (IsAllocatedBandwidth)
1141 {
1142 if (Packet->MiniPortFlags & USB_MINIPORT_FLAGS_USB2)
1143 {
1144 USBPORT_FreeBandwidthUSB2(FdoDevice, Endpoint);
1145 }
1146 else
1147 {
1148 USBPORT_FreeBandwidth(FdoDevice, Endpoint);
1149 }
1150 }
1151
1152 if (Endpoint->TtExtension)
1153 {
1154 KeAcquireSpinLock(&FdoExtension->TtSpinLock, &OldIrql);
1155 RemoveEntryList(&Endpoint->TtLink);
1156 KeReleaseSpinLock(&FdoExtension->TtSpinLock, OldIrql);
1157 }
1158
1160 }
1161
1162 DPRINT1("USBPORT_OpenPipe: Status - %lx\n", Status);
1163 return Status;
1164}
1165
1167NTAPI
1169 IN PUSBPORT_ENDPOINT Endpoint)
1170{
1172 PUSBPORT_COMMON_BUFFER_HEADER HeaderBuffer;
1173 USBPORT_ENDPOINT_REQUIREMENTS EndpointRequirements = {0};
1175 KIRQL MiniportOldIrql;
1177
1178 DPRINT1("USBPORT_ReopenPipe ... \n");
1179
1180 FdoExtension = FdoDevice->DeviceExtension;
1181 Packet = &FdoExtension->MiniPortInterface->Packet;
1182
1183 while (TRUE)
1184 {
1185 if (!InterlockedIncrement(&Endpoint->LockCounter))
1186 break;
1187
1188 InterlockedDecrement(&Endpoint->LockCounter);
1189 USBPORT_Wait(FdoDevice, 1);
1190 }
1191
1192 KeAcquireSpinLock(&Endpoint->EndpointSpinLock, &Endpoint->EndpointOldIrql);
1193 KeAcquireSpinLockAtDpcLevel(&FdoExtension->MiniportSpinLock);
1194
1195 Packet->SetEndpointState(FdoExtension->MiniPortExt,
1196 Endpoint + 1,
1198
1199 KeReleaseSpinLockFromDpcLevel(&FdoExtension->MiniportSpinLock);
1200 KeReleaseSpinLock(&Endpoint->EndpointSpinLock, Endpoint->EndpointOldIrql);
1201
1202 USBPORT_Wait(FdoDevice, 2);
1203
1204 MiniportCloseEndpoint(FdoDevice, Endpoint);
1205
1206 RtlZeroMemory(Endpoint + 1,
1207 Packet->MiniPortEndpointSize);
1208
1209 if (Endpoint->HeaderBuffer)
1210 {
1211 USBPORT_FreeCommonBuffer(FdoDevice, Endpoint->HeaderBuffer);
1212 Endpoint->HeaderBuffer = NULL;
1213 }
1214
1215 KeAcquireSpinLock(&FdoExtension->MiniportSpinLock, &MiniportOldIrql);
1216
1217 Packet->QueryEndpointRequirements(FdoExtension->MiniPortExt,
1218 &Endpoint->EndpointProperties,
1219 &EndpointRequirements);
1220
1221 KeReleaseSpinLock(&FdoExtension->MiniportSpinLock, MiniportOldIrql);
1222
1223 if (EndpointRequirements.HeaderBufferSize)
1224 {
1225 HeaderBuffer = USBPORT_AllocateCommonBuffer(FdoDevice,
1226 EndpointRequirements.HeaderBufferSize);
1227 }
1228 else
1229 {
1230 HeaderBuffer = NULL;
1231 }
1232
1233 if (HeaderBuffer || EndpointRequirements.HeaderBufferSize == 0)
1234 {
1235 Endpoint->HeaderBuffer = HeaderBuffer;
1237 }
1238 else
1239 {
1240 Endpoint->HeaderBuffer = 0;
1242 }
1243
1244 if (Endpoint->HeaderBuffer && HeaderBuffer)
1245 {
1246 Endpoint->EndpointProperties.BufferVA = HeaderBuffer->VirtualAddress;
1247 Endpoint->EndpointProperties.BufferPA = HeaderBuffer->PhysicalAddress;
1248 Endpoint->EndpointProperties.BufferLength = HeaderBuffer->BufferLength;
1249 }
1250
1251 if (NT_SUCCESS(Status))
1252 {
1253 MiniportOpenEndpoint(FdoDevice, Endpoint);
1254
1255 KeAcquireSpinLock(&Endpoint->EndpointSpinLock, &Endpoint->EndpointOldIrql);
1256 KeAcquireSpinLockAtDpcLevel(&Endpoint->StateChangeSpinLock);
1257
1258 if (Endpoint->StateLast == USBPORT_ENDPOINT_ACTIVE)
1259 {
1260 KeReleaseSpinLockFromDpcLevel(&Endpoint->StateChangeSpinLock);
1261 KeAcquireSpinLockAtDpcLevel(&FdoExtension->MiniportSpinLock);
1262
1263 Packet->SetEndpointState(FdoExtension->MiniPortExt,
1264 Endpoint + 1,
1266
1267 KeReleaseSpinLockFromDpcLevel(&FdoExtension->MiniportSpinLock);
1268 }
1269 else
1270 {
1271 KeReleaseSpinLockFromDpcLevel(&Endpoint->StateChangeSpinLock);
1272 }
1273
1274 KeReleaseSpinLock(&Endpoint->EndpointSpinLock, Endpoint->EndpointOldIrql);
1275 }
1276
1277 InterlockedDecrement(&Endpoint->LockCounter);
1278
1279 return Status;
1280}
1281
1282VOID
1283NTAPI
1285{
1287 KIRQL OldIrql;
1288 PLIST_ENTRY ClosedList;
1289 PUSBPORT_ENDPOINT Endpoint;
1290
1291 DPRINT_CORE("USBPORT_FlushClosedEndpointList: ... \n");
1292
1293 FdoExtension = FdoDevice->DeviceExtension;
1294
1295 KeAcquireSpinLock(&FdoExtension->EndpointClosedSpinLock, &OldIrql);
1296 ClosedList = &FdoExtension->EndpointClosedList;
1297
1298 while (!IsListEmpty(ClosedList))
1299 {
1300 Endpoint = CONTAINING_RECORD(ClosedList->Flink,
1302 CloseLink);
1303
1304 RemoveHeadList(ClosedList);
1305 Endpoint->CloseLink.Flink = NULL;
1306 Endpoint->CloseLink.Blink = NULL;
1307
1308 KeReleaseSpinLock(&FdoExtension->EndpointClosedSpinLock, OldIrql);
1309
1310 USBPORT_DeleteEndpoint(FdoDevice, Endpoint);
1311
1312 KeAcquireSpinLock(&FdoExtension->EndpointClosedSpinLock, &OldIrql);
1313 }
1314
1315 KeReleaseSpinLock(&FdoExtension->EndpointClosedSpinLock, OldIrql);
1316}
1317
1318VOID
1319NTAPI
1321 IN PUSBPORT_ENDPOINT Endpoint,
1322 IN ULONG Type)
1323{
1327 PLIST_ENTRY WorkerLink;
1329 KIRQL OldIrql;
1330 BOOLEAN IsAddEntry = FALSE;
1331
1332 DPRINT_CORE("USBPORT_InvalidateEndpointHandler: Endpoint - %p, Type - %x\n",
1333 Endpoint,
1334 Type);
1335
1336 FdoExtension = FdoDevice->DeviceExtension;
1337 Packet = &FdoExtension->MiniPortInterface->Packet;
1338
1339 if (Endpoint)
1340 {
1341 WorkerLink = &Endpoint->WorkerLink;
1342 KeAcquireSpinLock(&FdoExtension->EndpointListSpinLock, &OldIrql);
1343 DPRINT_CORE("USBPORT_InvalidateEndpointHandler: KeAcquireSpinLock \n");
1344
1345 if ((!WorkerLink->Flink || !WorkerLink->Blink) &&
1346 !(Endpoint->Flags & ENDPOINT_FLAG_IDLE) &&
1348 {
1349 DPRINT_CORE("USBPORT_InvalidateEndpointHandler: InsertTailList \n");
1350 InsertTailList(&FdoExtension->WorkerList, WorkerLink);
1351 IsAddEntry = TRUE;
1352 }
1353
1354 KeReleaseSpinLock(&FdoExtension->EndpointListSpinLock, OldIrql);
1355
1356 if (Endpoint->Flags & ENDPOINT_FLAG_ROOTHUB_EP0)
1358 }
1359 else
1360 {
1361 KeAcquireSpinLock(&FdoExtension->EndpointListSpinLock, &OldIrql);
1362
1363 for (Entry = FdoExtension->EndpointList.Flink;
1364 Entry && Entry != &FdoExtension->EndpointList;
1365 Entry = Entry->Flink)
1366 {
1369 EndpointLink);
1370
1371 if (!endpoint->WorkerLink.Flink || !endpoint->WorkerLink.Blink)
1372 {
1373 if (!(endpoint->Flags & ENDPOINT_FLAG_IDLE) &&
1374 !(endpoint->Flags & ENDPOINT_FLAG_ROOTHUB_EP0) &&
1376 {
1377 DPRINT_CORE("USBPORT_InvalidateEndpointHandler: InsertTailList \n");
1378 InsertTailList(&FdoExtension->WorkerList, &endpoint->WorkerLink);
1379 IsAddEntry = TRUE;
1380 }
1381 }
1382 }
1383
1384 KeReleaseSpinLock(&FdoExtension->EndpointListSpinLock, OldIrql);
1385 }
1386
1388 {
1390 }
1391 else if (IsAddEntry == FALSE && Type == INVALIDATE_ENDPOINT_INT_NEXT_SOF)
1392 {
1394 }
1395
1396 switch (Type)
1397 {
1399 USBPORT_SignalWorkerThread(FdoDevice);
1400 break;
1401
1403 KeInsertQueueDpc(&FdoExtension->WorkerRequestDpc, NULL, NULL);
1404 break;
1405
1407 KeAcquireSpinLock(&FdoExtension->MiniportSpinLock, &OldIrql);
1408 Packet->InterruptNextSOF(FdoExtension->MiniPortExt);
1409 KeReleaseSpinLock(&FdoExtension->MiniportSpinLock, OldIrql);
1410 break;
1411 }
1412}
1413
1414ULONG
1415NTAPI
1417 IN PUSBPORT_ENDPOINT Endpoint)
1418{
1422 PUSBPORT_TRANSFER Transfer;
1423 PURB Urb;
1424 ULONG Frame;
1425 ULONG CurrentFrame;
1426 ULONG CompletedLen = 0;
1427 KIRQL OldIrql;
1428
1429 DPRINT_CORE("USBPORT_DmaEndpointPaused \n");
1430
1431 FdoExtension = FdoDevice->DeviceExtension;
1432 Packet = &FdoExtension->MiniPortInterface->Packet;
1433
1434 Entry = Endpoint->TransferList.Flink;
1435
1436 if (Entry == &Endpoint->TransferList)
1438
1439 while (Entry && Entry != &Endpoint->TransferList)
1440 {
1441 Transfer = CONTAINING_RECORD(Entry,
1443 TransferLink);
1444
1446 {
1447 if (Transfer->Flags & TRANSFER_FLAG_ISO &&
1448 Transfer->Flags & TRANSFER_FLAG_SUBMITED &&
1449 !(Endpoint->Flags & ENDPOINT_FLAG_NUKE))
1450 {
1451 Urb = Transfer->Urb;
1452
1453 Frame = Urb->UrbIsochronousTransfer.StartFrame +
1454 Urb->UrbIsochronousTransfer.NumberOfPackets;
1455
1456 KeAcquireSpinLock(&FdoExtension->MiniportSpinLock, &OldIrql);
1457 CurrentFrame = Packet->Get32BitFrameNumber(FdoExtension->MiniPortExt);
1458 KeReleaseSpinLock(&FdoExtension->MiniportSpinLock, OldIrql);
1459
1460 if (Frame + 1 > CurrentFrame)
1461 {
1462 return USBPORT_GetEndpointState(Endpoint);
1463 }
1464 }
1465
1466 if ((Transfer->Flags & TRANSFER_FLAG_SUBMITED) &&
1467 !(Endpoint->Flags & ENDPOINT_FLAG_NUKE))
1468 {
1469 KeAcquireSpinLock(&FdoExtension->MiniportSpinLock, &OldIrql);
1470
1471 Packet->AbortTransfer(FdoExtension->MiniPortExt,
1472 Endpoint + 1,
1473 Transfer->MiniportTransfer,
1474 &CompletedLen);
1475
1476 KeReleaseSpinLock(&FdoExtension->MiniportSpinLock, OldIrql);
1477
1478 if (Transfer->Flags & TRANSFER_FLAG_ISO)
1479 {
1480 DPRINT1("USBPORT_DmaEndpointActive: FIXME call USBPORT_FlushIsoTransfer\n");
1481 ASSERT(FALSE); //USBPORT_FlushIsoTransfer();
1482 }
1483 else
1484 {
1485 Transfer->CompletedTransferLen = CompletedLen;
1486 }
1487 }
1488
1489 RemoveEntryList(&Transfer->TransferLink);
1490 Entry = Transfer->TransferLink.Flink;
1491
1492 if (Transfer->Flags & TRANSFER_FLAG_SPLITED)
1493 {
1495 }
1496 else
1497 {
1498 InsertTailList(&Endpoint->CancelList, &Transfer->TransferLink);
1499 }
1500 }
1501 else
1502 {
1503 Entry = Transfer->TransferLink.Flink;
1504 }
1505 }
1506
1508}
1509
1510ULONG
1511NTAPI
1513 IN PUSBPORT_ENDPOINT Endpoint)
1514{
1518 PUSBPORT_TRANSFER Transfer;
1519 LARGE_INTEGER TimeOut;
1520 MPSTATUS MpStatus;
1521 KIRQL OldIrql;
1522
1523 DPRINT_CORE("USBPORT_DmaEndpointActive \n");
1524
1525 FdoExtension = FdoDevice->DeviceExtension;
1526
1527 Entry = Endpoint->TransferList.Flink;
1528
1529 while (Entry && Entry != &Endpoint->TransferList)
1530 {
1531 Transfer = CONTAINING_RECORD(Entry,
1533 TransferLink);
1534
1535 if (!(Transfer->Flags & TRANSFER_FLAG_SUBMITED) &&
1536 !(Endpoint->Flags & ENDPOINT_FLAG_NUKE))
1537 {
1538 KeAcquireSpinLock(&FdoExtension->MiniportSpinLock, &OldIrql);
1539
1540 Packet = &FdoExtension->MiniPortInterface->Packet;
1541
1542 if (Transfer->Flags & TRANSFER_FLAG_ISO)
1543 {
1544 DPRINT1("USBPORT_DmaEndpointActive: FIXME call SubmitIsoTransfer\n");
1545
1546 MpStatus = Packet->SubmitIsoTransfer(FdoExtension->MiniPortExt,
1547 Endpoint + 1,
1548 &Transfer->TransferParameters,
1549 Transfer->MiniportTransfer,
1550 NULL);//&Transfer->IsoTransferParameters);
1551 }
1552 else
1553 {
1554 MpStatus = Packet->SubmitTransfer(FdoExtension->MiniPortExt,
1555 Endpoint + 1,
1556 &Transfer->TransferParameters,
1557 Transfer->MiniportTransfer,
1558 &Transfer->SgList);
1559 }
1560
1561 KeReleaseSpinLock(&FdoExtension->MiniportSpinLock, OldIrql);
1562
1563 if (MpStatus)
1564 {
1565 if ((MpStatus != MP_STATUS_FAILURE) && Transfer->Flags & TRANSFER_FLAG_ISO)
1566 {
1567 DPRINT1("USBPORT_DmaEndpointActive: FIXME call USBPORT_ErrorCompleteIsoTransfer\n");
1568 ASSERT(FALSE); //USBPORT_ErrorCompleteIsoTransfer();
1569 }
1570
1572 }
1573
1574 Transfer->Flags |= TRANSFER_FLAG_SUBMITED;
1575 KeQuerySystemTime(&Transfer->Time);
1576
1577 TimeOut.QuadPart = 10000 * Transfer->TimeOut;
1578 Transfer->Time.QuadPart += TimeOut.QuadPart;
1579 }
1580
1582 {
1584 }
1585
1586 Entry = Transfer->TransferLink.Flink;
1587 }
1588
1590}
1591
1592VOID
1593NTAPI
1595{
1596 PDEVICE_OBJECT FdoDevice;
1597 ULONG PrevState;
1598 ULONG EndpointState;
1599 BOOLEAN IsPaused = FALSE;
1600
1601 DPRINT_CORE("USBPORT_DmaEndpointWorker ... \n");
1602
1603 FdoDevice = Endpoint->FdoDevice;
1604
1605 KeAcquireSpinLock(&Endpoint->EndpointSpinLock, &Endpoint->EndpointOldIrql);
1606
1607 PrevState = USBPORT_GetEndpointState(Endpoint);
1608
1609 if (PrevState == USBPORT_ENDPOINT_PAUSED)
1610 {
1611 EndpointState = USBPORT_DmaEndpointPaused(FdoDevice, Endpoint);
1612 }
1613 else if (PrevState == USBPORT_ENDPOINT_ACTIVE)
1614 {
1615 EndpointState = USBPORT_DmaEndpointActive(FdoDevice, Endpoint);
1616 }
1617 else
1618 {
1619#ifndef NDEBUG_USBPORT_CORE
1620 DPRINT1("USBPORT_DmaEndpointWorker: DbgBreakPoint. EndpointState - %x\n",
1621 EndpointState);
1622 DbgBreakPoint();
1623#endif
1624 EndpointState = USBPORT_ENDPOINT_UNKNOWN;
1625 }
1626
1627 KeReleaseSpinLock(&Endpoint->EndpointSpinLock, Endpoint->EndpointOldIrql);
1628
1629 USBPORT_FlushCancelList(Endpoint);
1630
1631 KeAcquireSpinLock(&Endpoint->EndpointSpinLock, &Endpoint->EndpointOldIrql);
1632
1633 if (EndpointState == PrevState)
1634 {
1635 if (EndpointState == USBPORT_ENDPOINT_PAUSED)
1636 {
1637 IsPaused = TRUE;
1638 }
1639 }
1640 else
1641 {
1642 USBPORT_SetEndpointState(Endpoint, EndpointState);
1643 }
1644
1645 KeReleaseSpinLock(&Endpoint->EndpointSpinLock, Endpoint->EndpointOldIrql);
1646
1647 if (IsPaused)
1648 {
1650 Endpoint,
1652 }
1653
1654 DPRINT_CORE("USBPORT_DmaEndpointWorker exit \n");
1655}
1656
1657BOOLEAN
1658NTAPI
1660 IN BOOLEAN LockNotChecked)
1661{
1662 PDEVICE_OBJECT FdoDevice;
1665 ULONG EndpointState;
1666
1667 DPRINT_CORE("USBPORT_EndpointWorker: Endpoint - %p, LockNotChecked - %x\n",
1668 Endpoint,
1669 LockNotChecked);
1670
1671 FdoDevice = Endpoint->FdoDevice;
1672 FdoExtension = FdoDevice->DeviceExtension;
1673 Packet = &FdoExtension->MiniPortInterface->Packet;
1674
1675 if (LockNotChecked == FALSE)
1676 {
1677 if (InterlockedIncrement(&Endpoint->LockCounter))
1678 {
1679 InterlockedDecrement(&Endpoint->LockCounter);
1680 DPRINT_CORE("USBPORT_EndpointWorker: LockCounter > 0\n");
1681 return TRUE;
1682 }
1683 }
1684
1686
1687 KeAcquireSpinLockAtDpcLevel(&Endpoint->EndpointSpinLock);
1688
1690 {
1691 KeReleaseSpinLockFromDpcLevel(&Endpoint->EndpointSpinLock);
1692 InterlockedDecrement(&Endpoint->LockCounter);
1693 DPRINT_CORE("USBPORT_EndpointWorker: State == USBPORT_ENDPOINT_CLOSED. return FALSE\n");
1694 return FALSE;
1695 }
1696
1697 if ((Endpoint->Flags & (ENDPOINT_FLAG_ROOTHUB_EP0 | ENDPOINT_FLAG_NUKE)) == 0)
1698 {
1699 KeAcquireSpinLockAtDpcLevel(&FdoExtension->MiniportSpinLock);
1700 Packet->PollEndpoint(FdoExtension->MiniPortExt, Endpoint + 1);
1701 KeReleaseSpinLockFromDpcLevel(&FdoExtension->MiniportSpinLock);
1702 }
1703
1704 EndpointState = USBPORT_GetEndpointState(Endpoint);
1705
1706 if (EndpointState == USBPORT_ENDPOINT_REMOVE)
1707 {
1708 KeAcquireSpinLockAtDpcLevel(&Endpoint->StateChangeSpinLock);
1709 Endpoint->StateLast = USBPORT_ENDPOINT_CLOSED;
1710 Endpoint->StateNext = USBPORT_ENDPOINT_CLOSED;
1711 KeReleaseSpinLockFromDpcLevel(&Endpoint->StateChangeSpinLock);
1712
1713 KeReleaseSpinLockFromDpcLevel(&Endpoint->EndpointSpinLock);
1714
1715 KeAcquireSpinLockAtDpcLevel(&FdoExtension->EndpointListSpinLock);
1716
1717 ExInterlockedInsertTailList(&FdoExtension->EndpointClosedList,
1718 &Endpoint->CloseLink,
1719 &FdoExtension->EndpointClosedSpinLock);
1720
1721 KeReleaseSpinLockFromDpcLevel(&FdoExtension->EndpointListSpinLock);
1722
1723 InterlockedDecrement(&Endpoint->LockCounter);
1724 DPRINT_CORE("USBPORT_EndpointWorker: State == USBPORT_ENDPOINT_REMOVE. return FALSE\n");
1725 return FALSE;
1726 }
1727
1728 if (!IsListEmpty(&Endpoint->PendingTransferList) ||
1729 !IsListEmpty(&Endpoint->TransferList) ||
1730 !IsListEmpty(&Endpoint->CancelList))
1731 {
1732 KeReleaseSpinLockFromDpcLevel(&Endpoint->EndpointSpinLock);
1733
1734 EndpointState = USBPORT_GetEndpointState(Endpoint);
1735
1736 KeAcquireSpinLockAtDpcLevel(&Endpoint->StateChangeSpinLock);
1737 if (EndpointState == Endpoint->StateNext)
1738 {
1739 KeReleaseSpinLockFromDpcLevel(&Endpoint->StateChangeSpinLock);
1740
1741 if (Endpoint->EndpointWorker)
1742 {
1743 USBPORT_DmaEndpointWorker(Endpoint);
1744 }
1745 else
1746 {
1748 }
1749
1750 USBPORT_FlushAbortList(Endpoint);
1751
1752 InterlockedDecrement(&Endpoint->LockCounter);
1753 DPRINT_CORE("USBPORT_EndpointWorker: return FALSE\n");
1754 return FALSE;
1755 }
1756
1757 KeReleaseSpinLockFromDpcLevel(&Endpoint->StateChangeSpinLock);
1758 InterlockedDecrement(&Endpoint->LockCounter);
1759
1760 DPRINT_CORE("USBPORT_EndpointWorker: return TRUE\n");
1761 return TRUE;
1762 }
1763
1764 KeReleaseSpinLockFromDpcLevel(&Endpoint->EndpointSpinLock);
1765
1766 USBPORT_FlushAbortList(Endpoint);
1767
1768 InterlockedDecrement(&Endpoint->LockCounter);
1769 DPRINT_CORE("USBPORT_EndpointWorker: return FALSE\n");
1770 return FALSE;
1771}
unsigned char BOOLEAN
Type
Definition: Type.h:7
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
static HANDLE PipeHandle
Definition: dhcpcsvc.c:22
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
BOOLEAN NTAPI KeInsertQueueDpc(IN PKDPC Dpc, IN PVOID SystemArgument1, IN PVOID SystemArgument2)
Definition: dpc.c:725
@ PdoExtension
Definition: precomp.h:49
@ FdoExtension
Definition: precomp.h:48
VOID NTAPI USBPORT_FlushCancelList(IN PUSBPORT_ENDPOINT Endpoint)
Definition: queue.c:714
VOID NTAPI USBPORT_FlushAbortList(IN PUSBPORT_ENDPOINT Endpoint)
Definition: queue.c:605
ULONG NTAPI USBPORT_CalculateUsbBandwidth(IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_ENDPOINT Endpoint)
Definition: endpoint.c:18
ULONG NTAPI USBPORT_DmaEndpointPaused(IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_ENDPOINT Endpoint)
Definition: endpoint.c:1416
BOOLEAN NTAPI USBPORT_EndpointWorker(IN PUSBPORT_ENDPOINT Endpoint, IN BOOLEAN LockNotChecked)
Definition: endpoint.c:1659
VOID NTAPI USBPORT_NukeAllEndpoints(IN PDEVICE_OBJECT FdoDevice)
Definition: endpoint.c:300
BOOLEAN NTAPI USBPORT_DeleteEndpoint(IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_ENDPOINT Endpoint)
Definition: endpoint.c:498
VOID NTAPI USBPORT_RemovePipeHandle(IN PUSBPORT_DEVICE_HANDLE DeviceHandle, IN PUSBPORT_PIPE_HANDLE PipeHandle)
Definition: endpoint.c:456
VOID NTAPI USBPORT_AddPipeHandle(IN PUSBPORT_DEVICE_HANDLE DeviceHandle, IN PUSBPORT_PIPE_HANDLE PipeHandle)
Definition: endpoint.c:444
VOID NTAPI USBPORT_InvalidateEndpointHandler(IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_ENDPOINT Endpoint, IN ULONG Type)
Definition: endpoint.c:1320
VOID NTAPI USBPORT_ClosePipe(IN PUSBPORT_DEVICE_HANDLE DeviceHandle, IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_PIPE_HANDLE PipeHandle)
Definition: endpoint.c:590
BOOLEAN NTAPI USBPORT_EndpointHasQueuedTransfers(IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_ENDPOINT Endpoint, IN PULONG TransferCount)
Definition: endpoint.c:254
VOID NTAPI USBPORT_FreeBandwidth(IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_ENDPOINT Endpoint)
Definition: endpoint.c:171
BOOLEAN NTAPI USBPORT_ValidatePipeHandle(IN PUSBPORT_DEVICE_HANDLE DeviceHandle, IN PUSBPORT_PIPE_HANDLE PipeHandle)
Definition: endpoint.c:469
NTSTATUS NTAPI USBPORT_ReopenPipe(IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_ENDPOINT Endpoint)
Definition: endpoint.c:1168
VOID NTAPI USBPORT_FlushClosedEndpointList(IN PDEVICE_OBJECT FdoDevice)
Definition: endpoint.c:1284
BOOLEAN NTAPI USBPORT_AllocateBandwidth(IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_ENDPOINT Endpoint)
Definition: endpoint.c:63
MPSTATUS NTAPI MiniportOpenEndpoint(IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_ENDPOINT Endpoint)
Definition: endpoint.c:722
ULONG NTAPI USBPORT_DmaEndpointActive(IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_ENDPOINT Endpoint)
Definition: endpoint.c:1512
VOID NTAPI USBPORT_SetEndpointState(IN PUSBPORT_ENDPOINT Endpoint, IN ULONG State)
Definition: endpoint.c:363
VOID NTAPI MiniportCloseEndpoint(IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_ENDPOINT Endpoint)
Definition: endpoint.c:549
UCHAR NTAPI USBPORT_NormalizeHsInterval(UCHAR Interval)
Definition: endpoint.c:235
ULONG NTAPI USBPORT_GetEndpointState(IN PUSBPORT_ENDPOINT Endpoint)
Definition: endpoint.c:332
NTSTATUS NTAPI USBPORT_OpenPipe(IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_DEVICE_HANDLE DeviceHandle, IN PUSBPORT_PIPE_HANDLE PipeHandle, IN OUT PUSBD_STATUS UsbdStatus)
Definition: endpoint.c:763
VOID NTAPI USBPORT_DmaEndpointWorker(IN PUSBPORT_ENDPOINT Endpoint)
Definition: endpoint.c:1594
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
#define InsertTailList(ListHead, Entry)
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
#define KeQuerySystemTime(t)
Definition: env_spec_w32.h:570
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
#define RemoveHeadList(ListHead)
Definition: env_spec_w32.h:964
#define NonPagedPool
Definition: env_spec_w32.h:307
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
#define KeInitializeSpinLock(sl)
Definition: env_spec_w32.h:604
Status
Definition: gdiplustypes.h:25
_Inout_ PUSB_DEVICE_HANDLE DeviceHandle
Definition: hubbusif.h:121
NTSYSAPI void WINAPI DbgBreakPoint(void)
PLIST_ENTRY NTAPI ExInterlockedInsertTailList(IN OUT PLIST_ENTRY ListHead, IN OUT PLIST_ENTRY ListEntry, IN OUT PKSPIN_LOCK Lock)
Definition: interlocked.c:140
if(dx< 0)
Definition: linetemp.h:194
#define ASSERT(a)
Definition: mode.c:44
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
#define min(a, b)
Definition: monoChain.cc:55
_In_ NDIS_HANDLE _In_ PNDIS_PACKET Packet
Definition: ndis.h:1549
DWORD Interval
Definition: netstat.c:30
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
long LONG
Definition: pedump.c:60
unsigned short USHORT
Definition: pedump.c:61
#define KeAcquireSpinLockAtDpcLevel(SpinLock)
Definition: ke.h:125
#define KeReleaseSpinLockFromDpcLevel(SpinLock)
Definition: ke.h:135
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:73
base of all file and directory entries
Definition: entries.h:83
PVOID DeviceExtension
Definition: env_spec_w32.h:418
Definition: typedefs.h:120
struct _LIST_ENTRY * Blink
Definition: typedefs.h:122
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
Definition: usb.h:529
struct _URB_ISOCH_TRANSFER UrbIsochronousTransfer
Definition: usb.h:544
ULONG MaxBandwidth
Definition: usbport.h:553
USHORT DeviceAddress
Definition: usbport.h:555
LIST_ENTRY EndpointList
Definition: usbport.h:557
USB_DEVICE_SPEED DeviceSpeed
Definition: usbmport.h:73
KIRQL EndpointOldIrql
Definition: usbport.h:216
LIST_ENTRY EndpointLink
Definition: usbport.h:232
PUSBPORT_DEVICE_HANDLE DeviceHandle
Definition: usbport.h:208
KSPIN_LOCK StateChangeSpinLock
Definition: usbport.h:225
LIST_ENTRY CancelList
Definition: usbport.h:229
LIST_ENTRY CloseLink
Definition: usbport.h:234
PDEVICE_OBJECT FdoDevice
Definition: usbport.h:206
LIST_ENTRY PendingTransferList
Definition: usbport.h:227
LIST_ENTRY TransferList
Definition: usbport.h:228
KSPIN_LOCK EndpointSpinLock
Definition: usbport.h:215
ULONG EndpointWorker
Definition: usbport.h:212
PUSB2_TT_ENDPOINT TtEndpoint
Definition: usbport.h:210
LIST_ENTRY TtLink
Definition: usbport.h:239
PUSB2_TT_EXTENSION TtExtension
Definition: usbport.h:209
LIST_ENTRY AbortList
Definition: usbport.h:230
USBPORT_ENDPOINT_PROPERTIES EndpointProperties
Definition: usbport.h:211
PUSBPORT_COMMON_BUFFER_HEADER HeaderBuffer
Definition: usbport.h:207
ULONG CompletedTransferLen
Definition: usbport.h:259
PVOID MiniportTransfer
Definition: usbport.h:250
LARGE_INTEGER Time
Definition: usbport.h:263
USBPORT_TRANSFER_PARAMETERS TransferParameters
Definition: usbport.h:254
LIST_ENTRY TransferLink
Definition: usbport.h:257
USBPORT_SCATTER_GATHER_LIST SgList
Definition: usbport.h:271
Definition: nis.h:10
VOID NTAPI USBPORT_CancelSplitTransfer(IN PUSBPORT_TRANSFER SplitTransfer)
Definition: trfsplit.c:314
uint32_t * PULONG
Definition: typedefs.h:59
#define NTAPI
Definition: typedefs.h:36
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define IN
Definition: typedefs.h:39
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
LONGLONG QuadPart
Definition: typedefs.h:114
#define USB_ENDPOINT_TYPE_INTERRUPT
Definition: usb100.h:65
#define USB_ENDPOINT_DIRECTION_OUT(x)
Definition: usb100.h:75
#define USB_ENDPOINT_TYPE_CONTROL
Definition: usb100.h:62
#define USB_ENDPOINT_TYPE_ISOCHRONOUS
Definition: usb100.h:63
#define USB_ENDPOINT_TYPE_MASK
Definition: usb100.h:61
#define USB_ENDPOINT_TYPE_BULK
Definition: usb100.h:64
@ UsbHighSpeed
Definition: usb200.h:44
@ UsbLowSpeed
Definition: usb200.h:42
BOOLEAN NTAPI USBPORT_AllocateBandwidthUSB2(IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_ENDPOINT Endpoint)
Definition: usb2.c:1799
VOID NTAPI USBPORT_UpdateAllocatedBwTt(IN PUSB2_TT_EXTENSION TtExtension)
Definition: usb2.c:1768
VOID NTAPI USBPORT_FreeBandwidthUSB2(IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_ENDPOINT Endpoint)
Definition: usb2.c:2040
#define USBD_STATUS_NO_BANDWIDTH
Definition: usb.h:195
#define USBD_STATUS_SUCCESS
Definition: usb.h:170
#define USBD_STATUS_INSUFFICIENT_RESOURCES
Definition: usb.h:204
#define USBD_STATUS_TIMEOUT
Definition: usb.h:209
LONG USBD_STATUS
Definition: usb.h:165
#define DPRINT_CORE(...)
Definition: usbdebug.h:144
#define USBPORT_ENDPOINT_REMOVE
Definition: usbmport.h:16
#define USBPORT_ENDPOINT_ACTIVE
Definition: usbmport.h:15
#define USB_MINIPORT_FLAGS_USB2
Definition: usbmport.h:534
#define ENDPOINT_INTERRUPT_32ms
Definition: usbmport.h:30
ULONG MPSTATUS
Definition: usbmport.h:131
#define ENDPOINT_INTERRUPT_8ms
Definition: usbmport.h:28
#define USBPORT_TRANSFER_TYPE_INTERRUPT
Definition: usbmport.h:10
#define USBPORT_ENDPOINT_PAUSED
Definition: usbmport.h:14
#define USBPORT_TRANSFER_TYPE_ISOCHRONOUS
Definition: usbmport.h:7
#define ENDPOINT_INTERRUPT_1ms
Definition: usbmport.h:25
#define MP_STATUS_NO_RESOURCES
Definition: usbmport.h:136
#define USBPORT_ENDPOINT_UNKNOWN
Definition: usbmport.h:13
#define USBPORT_TRANSFER_TYPE_CONTROL
Definition: usbmport.h:8
#define MP_STATUS_FAILURE
Definition: usbmport.h:135
#define USBPORT_ENDPOINT_CLOSED
Definition: usbmport.h:17
#define USBPORT_TRANSFER_TYPE_BULK
Definition: usbmport.h:9
VOID NTAPI USBPORT_RootHubEndpointWorker(IN PUSBPORT_ENDPOINT Endpoint)
Definition: roothub.c:664
PUSBPORT_COMMON_BUFFER_HEADER NTAPI USBPORT_AllocateCommonBuffer(IN PDEVICE_OBJECT FdoDevice, IN SIZE_T BufferLength)
Definition: usbport.c:1708
VOID NTAPI USBPORT_FreeCommonBuffer(IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_COMMON_BUFFER_HEADER HeaderBuffer)
Definition: usbport.c:1770
VOID NTAPI USBPORT_SignalWorkerThread(IN PDEVICE_OBJECT FdoDevice)
Definition: usbport.c:1111
NTSTATUS NTAPI USBPORT_Wait(IN PVOID MiniPortExtension, IN ULONG Milliseconds)
Definition: usbport.c:543
NTSTATUS NTAPI USBPORT_USBDStatusToNtStatus(IN PURB Urb, IN USBD_STATUS USBDStatus)
Definition: usbport.c:485
struct _USB2_TT_ENDPOINT * PUSB2_TT_ENDPOINT
Definition: usbport.h:160
#define PIPE_HANDLE_FLAG_CLOSED
Definition: usbport.h:126
#define ENDPOINT_FLAG_IDLE
Definition: usbport.h:116
struct _USBPORT_ENDPOINT * PUSBPORT_ENDPOINT
Definition: usbport.h:155
#define INVALIDATE_ENDPOINT_INT_NEXT_SOF
Definition: usbport.h:39
#define USB2_BIT_STUFFING_OVERHEAD
Definition: usbport.h:483
#define PIPE_HANDLE_FLAG_NULL_PACKET_SIZE
Definition: usbport.h:127
#define TRANSFER_FLAG_CANCELED
Definition: usbport.h:130
#define USB2_TT_EXTENSION_FLAG_DELETED
Definition: usbport.h:546
#define ENDPOINT_FLAG_ROOTHUB_EP0
Definition: usbport.h:112
#define DEVICE_HANDLE_FLAG_ROOTHUB
Definition: usbport.h:106
#define USB_PORT_TAG
Definition: usbport.h:44
#define USB2_FS_INTERRUPT_OVERHEAD
Definition: usbport.h:467
#define INVALIDATE_ENDPOINT_WORKER_THREAD
Definition: usbport.h:37
struct _USB2_TT_ENDPOINT USB2_TT_ENDPOINT
#define USBPORT_FLAG_HC_SUSPEND
Definition: usbport.h:71
USBD_STATUS * PUSBD_STATUS
Definition: usbport.h:144
#define TRANSFER_FLAG_SUBMITED
Definition: usbport.h:133
#define TRANSFER_FLAG_ISO
Definition: usbport.h:135
#define ENDPOINT_FLAG_DMA_TYPE
Definition: usbport.h:111
#define USB2_FS_ISOCHRONOUS_OVERHEAD
Definition: usbport.h:470
#define ENDPOINT_FLAG_CLOSED
Definition: usbport.h:118
struct _USBPORT_ENDPOINT USBPORT_ENDPOINT
#define USB2_FRAMES
Definition: usbport.h:452
#define ENDPOINT_FLAG_NUKE
Definition: usbport.h:113
#define INVALIDATE_ENDPOINT_ONLY
Definition: usbport.h:36
#define TRANSFER_FLAG_SPLITED
Definition: usbport.h:137
#define TRANSFER_FLAG_ABORTED
Definition: usbport.h:134
#define ENDPOINT_FLAG_QUEUENE_EMPTY
Definition: usbport.h:114
#define INVALIDATE_ENDPOINT_WORKER_DPC
Definition: usbport.h:38
#define ENDPOINT_FLAG_OPENED
Definition: usbport.h:117
WDF_EXTERN_C_START typedef _In_ WDFDEVICE _In_ WDFCONTEXT _In_ WDF_DMA_DIRECTION Direction
_In_ NTSTATUS _In_ USBD_STATUS UsbdStatus
Definition: wdfusb.h:403
_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
Definition: wsk.h:409
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:778
_In_ LARGE_INTEGER _In_ ULONG Period
Definition: kefuncs.h:1313
unsigned char UCHAR
Definition: xmlstorage.h:181