ReactOS 0.4.16-dev-257-g6aa11ac
queue.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 queue implementation
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#define NDEBUG_USBPORT_QUEUE
15#define NDEBUG_USBPORT_URB
16#include "usbdebug.h"
17
18VOID
21 IN PIRP Irp)
22{
24
25 DPRINT_QUEUE("USBPORT_InsertIdleIrp: Irp - %p\n", Irp);
26
29 IdleIoCsq);
30
31 InsertTailList(&FdoExtension->IdleIrpList,
32 &Irp->Tail.Overlay.ListEntry);
33}
34
35VOID
38 IN PIRP Irp)
39{
40 DPRINT_QUEUE("USBPORT_RemoveIdleIrp: Irp - %p\n", Irp);
41 RemoveEntryList(&Irp->Tail.Overlay.ListEntry);
42}
43
44PIRP
47 IN PIRP Irp,
49{
51 PLIST_ENTRY NextEntry;
52 PLIST_ENTRY ListHead;
53 PIRP NextIrp = NULL;
54
55 DPRINT_QUEUE("USBPORT_PeekNextIdleIrp: Irp - %p, PeekContext - %p\n",
56 Irp,
58
61 IdleIoCsq);
62
63 ListHead = &FdoExtension->IdleIrpList;
64
65 if (Irp)
66 {
67 NextEntry = Irp->Tail.Overlay.ListEntry.Flink;
68 }
69 else
70 {
71 NextEntry = ListHead->Flink;
72 }
73
74 while (NextEntry != ListHead)
75 {
76 NextIrp = CONTAINING_RECORD(NextEntry,
77 IRP,
78 Tail.Overlay.ListEntry);
79
80 if (!PeekContext)
81 break;
82
83 NextEntry = NextEntry->Flink;
84 }
85
86 return NextIrp;
87}
88
89VOID
93{
95
96 DPRINT_QUEUE("USBPORT_AcquireIdleLock: ... \n");
97
100 IdleIoCsq);
101
102 KeAcquireSpinLock(&FdoExtension->IdleIoCsqSpinLock, Irql);
103}
104
105VOID
106NTAPI
108 IN KIRQL Irql)
109{
111
112 DPRINT_QUEUE("USBPORT_ReleaseIdleLock: ... \n");
113
116 IdleIoCsq);
117
118 KeReleaseSpinLock(&FdoExtension->IdleIoCsqSpinLock, Irql);
119}
120
121VOID
122NTAPI
124 IN PIRP Irp)
125{
127
128 DPRINT_QUEUE("USBPORT_CompleteCanceledIdleIrp: ... \n");
129
132 IdleIoCsq);
133
134 InterlockedDecrement(&FdoExtension->IdleLockCounter);
135
136 Irp->IoStatus.Status = STATUS_CANCELLED;
137 Irp->IoStatus.Information = 0;
139}
140
141VOID
142NTAPI
144 IN PIRP Irp)
145{
147
148 DPRINT_QUEUE("USBPORT_InsertBadRequest: Irp - %p\n", Irp);
149
152 BadRequestIoCsq);
153
154 InsertTailList(&FdoExtension->BadRequestList,
155 &Irp->Tail.Overlay.ListEntry);
156}
157
158VOID
159NTAPI
161 IN PIRP Irp)
162{
163 DPRINT_QUEUE("USBPORT_RemoveBadRequest: Irp - %p\n", Irp);
164 RemoveEntryList(&Irp->Tail.Overlay.ListEntry);
165}
166
167PIRP
168NTAPI
170 IN PIRP Irp,
172{
174 PLIST_ENTRY NextEntry;
175 PLIST_ENTRY ListHead;
176 PIRP NextIrp = NULL;
177
178 DPRINT_QUEUE("USBPORT_PeekNextBadRequest: Irp - %p, PeekContext - %p\n",
179 Irp,
181
184 BadRequestIoCsq);
185
186 ListHead = &FdoExtension->BadRequestList;
187
188 if (Irp)
189 {
190 NextEntry = Irp->Tail.Overlay.ListEntry.Flink;
191 }
192 else
193 {
194 NextEntry = ListHead->Flink;
195 }
196
197 while (NextEntry != ListHead)
198 {
199 NextIrp = CONTAINING_RECORD(NextEntry,
200 IRP,
201 Tail.Overlay.ListEntry);
202
203 if (!PeekContext)
204 break;
205
206 NextEntry = NextEntry->Flink;
207 }
208
209 return NextIrp;
210}
211
212VOID
213NTAPI
215 IN PKIRQL Irql)
216{
218
219 DPRINT_QUEUE("USBPORT_AcquireBadRequestLock: ... \n");
220
223 BadRequestIoCsq);
224
225 KeAcquireSpinLock(&FdoExtension->BadRequestIoCsqSpinLock, Irql);
226}
227
228VOID
229NTAPI
231 IN KIRQL Irql)
232{
234
235 DPRINT_QUEUE("USBPORT_ReleaseBadRequestLock: ... \n");
236
239 BadRequestIoCsq);
240
241 KeReleaseSpinLock(&FdoExtension->BadRequestIoCsqSpinLock, Irql);
242}
243
244VOID
245NTAPI
247 IN PIRP Irp)
248{
250
251 DPRINT_QUEUE("USBPORT_CompleteCanceledBadRequest: Irp - %p\n", Irp);
252
255 BadRequestIoCsq);
256
257 InterlockedDecrement(&FdoExtension->BadRequestLockCounter);
258
259 Irp->IoStatus.Status = STATUS_CANCELLED;
260 Irp->IoStatus.Information = 0;
262}
263
264VOID
265NTAPI
267 IN PIRP Irp)
268{
269 ULONG ix;
270
271 DPRINT_CORE("USBPORT_InsertIrpInTable: IrpTable - %p, Irp - %p\n",
272 IrpTable,
273 Irp);
274
275 ASSERT(IrpTable != NULL);
276
277 while (TRUE)
278 {
279 for (ix = 0; ix < 0x200; ix++)
280 {
281 if (IrpTable->irp[ix] == NULL)
282 {
283 IrpTable->irp[ix] = Irp;
284
285 if (ix > 0)
286 {
287 DPRINT_CORE("USBPORT_InsertIrpInTable: ix - %x\n", ix);
288 }
289
290 return;
291 }
292 }
293
294 if (ix != 0x200)
295 {
296 KeBugCheckEx(BUGCODE_USB_DRIVER, 1, 0, 0, 0);
297 }
298
299 IrpTable->LinkNextTable = ExAllocatePoolWithTag(NonPagedPool,
300 sizeof(USBPORT_IRP_TABLE),
302
303 if (IrpTable->LinkNextTable == NULL)
304 {
305 KeBugCheckEx(BUGCODE_USB_DRIVER, 1, 0, 0, 0);
306 }
307
308 RtlZeroMemory(IrpTable->LinkNextTable, sizeof(USBPORT_IRP_TABLE));
309
310 IrpTable = IrpTable->LinkNextTable;
311 }
312}
313
314PIRP
315NTAPI
317 IN PIRP Irp)
318{
319 ULONG ix;
320
321 DPRINT_CORE("USBPORT_RemoveIrpFromTable: IrpTable - %p, Irp - %p\n",
322 IrpTable,
323 Irp);
324
325 ASSERT(IrpTable != NULL);
326
327 while (TRUE)
328 {
329 for (ix = 0; ix < 0x200; ix++)
330 {
331 if (IrpTable->irp[ix] == Irp)
332 {
333 IrpTable->irp[ix] = NULL;
334
335 if (ix > 0)
336 {
337 DPRINT_CORE("USBPORT_RemoveIrpFromTable: ix - %x\n", ix);
338 }
339
340 return Irp;
341 }
342 }
343
344 if (IrpTable->LinkNextTable == NULL)
345 break;
346
347 IrpTable = IrpTable->LinkNextTable;
348 continue;
349 }
350
351 DPRINT1("USBPORT_RemoveIrpFromTable: return NULL. ix - %x\n", ix);
352 return NULL;
353}
354
355PIRP
356NTAPI
358 IN PIRP Irp)
359{
361
362 DPRINT_CORE("USBPORT_RemoveActiveTransferIrp: Irp - %p\n", Irp);
363 FdoExtension = FdoDevice->DeviceExtension;
364 return USBPORT_RemoveIrpFromTable(FdoExtension->ActiveIrpTable, Irp);
365}
366
367PIRP
368NTAPI
370 IN PIRP Irp)
371{
373
374 DPRINT_CORE("USBPORT_RemovePendingTransferIrp: Irp - %p\n", Irp);
375 FdoExtension = FdoDevice->DeviceExtension;
376 return USBPORT_RemoveIrpFromTable(FdoExtension->PendingIrpTable, Irp);
377}
378
379VOID
380NTAPI
382 IN PURB Urb,
383 IN PIRP Irp)
384{
385 ULONG ix;
386 PIRP irp;
387 PURB urbIn;
388
389 DPRINT_CORE("USBPORT_FindUrbInIrpTable: IrpTable - %p, Urb - %p, Irp - %p\n",
390 IrpTable,
391 Urb,
392 Irp);
393
394 ASSERT(IrpTable != NULL);
395
396 do
397 {
398 for (ix = 0; ix < 0x200; ix++)
399 {
400 irp = IrpTable->irp[ix];
401
402 if (irp)
403 {
404 urbIn = URB_FROM_IRP(irp);
405
406 if (urbIn == Urb)
407 {
408 if (irp == Irp)
409 {
410 KeBugCheckEx(BUGCODE_USB_DRIVER,
411 4,
412 (ULONG_PTR)irp,
413 (ULONG_PTR)urbIn,
414 0);
415 }
416
417 KeBugCheckEx(BUGCODE_USB_DRIVER,
418 2,
419 (ULONG_PTR)irp,
420 (ULONG_PTR)Irp,
421 (ULONG_PTR)urbIn);
422 }
423 }
424 }
425
426 IrpTable = IrpTable->LinkNextTable;
427 }
428 while (IrpTable);
429}
430
431PIRP
432NTAPI
434 IN PIRP Irp)
435{
436 ULONG ix;
437 PIRP irp;
438
439 DPRINT_CORE("USBPORT_FindIrpInTable: IrpTable - %p, Irp - %p\n",
440 IrpTable,
441 Irp);
442
443 ASSERT(IrpTable != NULL);
444
445 do
446 {
447 for (ix = 0; ix < 0x200; ix++)
448 {
449 irp = IrpTable->irp[ix];
450
451 if (irp && irp == Irp)
452 {
453 return irp;
454 }
455 }
456
457 IrpTable = IrpTable->LinkNextTable;
458 }
459 while (IrpTable->LinkNextTable);
460
461 DPRINT_CORE("USBPORT_FindIrpInTable: Not found!!!\n");
462 return NULL;
463}
464
465PIRP
466NTAPI
468 IN PIRP Irp)
469{
471
472 DPRINT_CORE("USBPORT_FindActiveTransferIrp: Irp - %p\n", Irp);
473 FdoExtension = FdoDevice->DeviceExtension;
474 return USBPORT_FindIrpInTable(FdoExtension->ActiveIrpTable, Irp);
475}
476
477VOID
478NTAPI
480 IN PIRP Irp)
481{
482 PURB Urb;
483 PUSBPORT_TRANSFER Transfer;
484 PUSBPORT_ENDPOINT Endpoint;
485 PDEVICE_OBJECT FdoDevice;
488 PIRP irp;
489
490 DPRINT_CORE("USBPORT_CancelPendingTransferIrp: DeviceObject - %p, Irp - %p\n",
492 Irp);
493
494 Urb = URB_FROM_IRP(Irp);
495 Transfer = Urb->UrbControlTransfer.hca.Reserved8[0];
496 Endpoint = Transfer->Endpoint;
497
498 FdoDevice = Endpoint->FdoDevice;
499 FdoExtension = DeviceObject->DeviceExtension;
500
501 IoReleaseCancelSpinLock(Irp->CancelIrql);
502
503 KeAcquireSpinLock(&FdoExtension->FlushPendingTransferSpinLock, &OldIrql);
504
506
507 if (!irp)
508 {
509 KeReleaseSpinLock(&FdoExtension->FlushPendingTransferSpinLock,
510 OldIrql);
511 return;
512 }
513
515
516 RemoveEntryList(&Transfer->TransferLink);
517
518 Transfer->TransferLink.Flink = NULL;
519 Transfer->TransferLink.Blink = NULL;
520
522 KeReleaseSpinLock(&FdoExtension->FlushPendingTransferSpinLock, OldIrql);
523
525}
526
527VOID
528NTAPI
530 IN PIRP Irp)
531{
533 PDEVICE_OBJECT FdoDevice;
535 PURB Urb;
536 PUSBPORT_TRANSFER Transfer;
537 PUSBPORT_ENDPOINT Endpoint;
538 PIRP irp;
539 PUSBPORT_TRANSFER SplitTransfer;
542
543 DPRINT_CORE("USBPORT_CancelActiveTransferIrp: Irp - %p\n", Irp);
544
545 PdoExtension = DeviceObject->DeviceExtension;
546 FdoDevice = PdoExtension->FdoDevice;
547 FdoExtension = FdoDevice->DeviceExtension;
548
549 IoReleaseCancelSpinLock(Irp->CancelIrql);
550
551 KeAcquireSpinLock(&FdoExtension->FlushTransferSpinLock, &OldIrql);
552
554
555 if (!irp)
556 {
557 KeReleaseSpinLock(&FdoExtension->FlushTransferSpinLock, OldIrql);
558 return;
559 }
560
561 Urb = URB_FROM_IRP(irp);
562 Transfer = Urb->UrbControlTransfer.hca.Reserved8[0];
563 Endpoint = Transfer->Endpoint;
564
565 DPRINT_CORE("USBPORT_CancelActiveTransferIrp: irp - %p, Urb - %p, Transfer - %p\n",
566 irp,
567 Urb,
568 Transfer);
569
571
572 Transfer->Flags |= TRANSFER_FLAG_CANCELED;
573
574 if (Transfer->Flags & TRANSFER_FLAG_PARENT)
575 {
577
578 Entry = Transfer->SplitTransfersList.Flink;
579
580 while (Entry && Entry != &Transfer->SplitTransfersList)
581 {
582 SplitTransfer = CONTAINING_RECORD(Entry,
584 SplitLink);
585
586 SplitTransfer->Flags |= TRANSFER_FLAG_CANCELED;
587
588 Entry = Entry->Flink;
589 }
590
592 }
593
595 KeReleaseSpinLock(&FdoExtension->FlushTransferSpinLock, OldIrql);
596
598 Endpoint,
600 return;
601}
602
603VOID
604NTAPI
606{
608 PUSBPORT_TRANSFER Transfer;
609 PLIST_ENTRY AbortList;
612 PIRP Irp;
613 PURB Urb;
615
616 DPRINT_CORE("USBPORT_FlushAbortList: Endpoint - %p\n", Endpoint);
617
619
620 KeAcquireSpinLock(&Endpoint->EndpointSpinLock, &Endpoint->EndpointOldIrql);
621
622 if (IsListEmpty(&Endpoint->AbortList))
623 {
624 KeReleaseSpinLock(&Endpoint->EndpointSpinLock,
625 Endpoint->EndpointOldIrql);
626 return;
627 }
628
629 Entry = Endpoint->PendingTransferList.Flink;
630
631 while (Entry && Entry != &Endpoint->PendingTransferList)
632 {
633 Transfer = CONTAINING_RECORD(Entry,
635 TransferLink);
636
637 if (Transfer->Flags & TRANSFER_FLAG_ABORTED)
638 {
639 DPRINT_CORE("USBPORT_FlushAbortList: Aborted PendingTransfer - %p\n",
640 Transfer);
641
642 KeReleaseSpinLock(&Endpoint->EndpointSpinLock,
643 Endpoint->EndpointOldIrql);
644 return;
645 }
646
647 Entry = Transfer->TransferLink.Flink;
648 }
649
650 Entry = Endpoint->TransferList.Flink;
651
652 while (Entry && Entry != &Endpoint->TransferList)
653 {
654 Transfer = CONTAINING_RECORD(Entry,
656 TransferLink);
657
658 if (Transfer->Flags & TRANSFER_FLAG_ABORTED)
659 {
660 DPRINT_CORE("USBPORT_FlushAbortList: Aborted ActiveTransfer - %p\n",
661 Transfer);
662
663 KeReleaseSpinLock(&Endpoint->EndpointSpinLock,
664 Endpoint->EndpointOldIrql);
665 return;
666 }
667
668 Entry = Transfer->TransferLink.Flink;
669 }
670
671 AbortList = &Endpoint->AbortList;
672
673 while (!IsListEmpty(AbortList))
674 {
675 //DbgBreakPoint();
676
677 Irp = CONTAINING_RECORD(AbortList->Flink,
678 IRP,
679 Tail.Overlay.ListEntry);
680
681 RemoveHeadList(AbortList);
682 InsertTailList(&List, &Irp->Tail.Overlay.ListEntry);
683 }
684
685 KeReleaseSpinLock(&Endpoint->EndpointSpinLock, Endpoint->EndpointOldIrql);
686
687 while (!IsListEmpty(&List))
688 {
689 //DbgBreakPoint();
690
691 Irp = CONTAINING_RECORD(List.Flink,
692 IRP,
693 Tail.Overlay.ListEntry);
694
696
697 Urb = URB_FROM_IRP(Irp);
698
699 DeviceHandle = Urb->UrbHeader.UsbdDeviceHandle;
700 InterlockedDecrement(&DeviceHandle->DeviceHandleLock);
701
703
704 DPRINT_CORE("USBPORT_FlushAbortList: complete Irp - %p\n", Irp);
705
706 Irp->IoStatus.Status = Status;
707 Irp->IoStatus.Information = 0;
709 }
710}
711
712VOID
713NTAPI
715{
716 PDEVICE_OBJECT FdoDevice;
718 PUSBPORT_TRANSFER Transfer;
719 PIRP Irp;
721 KIRQL PrevIrql;
722
723 DPRINT_CORE("USBPORT_FlushCancelList: ... \n");
724
725 FdoDevice = Endpoint->FdoDevice;
726 FdoExtension = FdoDevice->DeviceExtension;
727
728 KeAcquireSpinLock(&FdoExtension->FlushTransferSpinLock, &OldIrql);
729 KeAcquireSpinLockAtDpcLevel(&Endpoint->EndpointSpinLock);
730
731 while (!IsListEmpty(&Endpoint->CancelList))
732 {
733 Transfer = CONTAINING_RECORD(Endpoint->CancelList.Flink,
735 TransferLink);
736
737 RemoveHeadList(&Endpoint->CancelList);
738
739 Irp = Transfer->Irp;
740
741 if (Irp)
742 {
743 DPRINT("USBPORT_FlushCancelList: Irp - %p\n", Irp);
744
745 IoAcquireCancelSpinLock(&PrevIrql);
747 IoReleaseCancelSpinLock(PrevIrql);
748
750 }
751
752 KeReleaseSpinLockFromDpcLevel(&Endpoint->EndpointSpinLock);
753 KeReleaseSpinLock(&FdoExtension->FlushTransferSpinLock, OldIrql);
754
755 if (Endpoint->Flags & ENDPOINT_FLAG_NUKE)
756 {
758 }
759 else
760 {
761 if (Transfer->Flags & TRANSFER_FLAG_DEVICE_GONE)
762 {
765 }
766 else
767 {
770 }
771 }
772
773 KeAcquireSpinLock(&FdoExtension->FlushTransferSpinLock, &OldIrql);
774 KeAcquireSpinLockAtDpcLevel(&Endpoint->EndpointSpinLock);
775 }
776
777 KeReleaseSpinLockFromDpcLevel(&Endpoint->EndpointSpinLock);
778 KeReleaseSpinLock(&FdoExtension->FlushTransferSpinLock, OldIrql);
779
780 USBPORT_FlushAbortList(Endpoint);
781}
782
783VOID
784NTAPI
786{
787 PDEVICE_OBJECT FdoDevice;
789 BOOLEAN IsMapTransfer;
790 BOOLEAN IsEnd = FALSE;
792 PUSBPORT_TRANSFER Transfer;
793 PURB Urb;
794 PIRP Irp;
797
798 DPRINT_CORE("USBPORT_FlushPendingTransfers: Endpoint - %p\n", Endpoint);
799
800 FdoDevice = Endpoint->FdoDevice;
801 FdoExtension = FdoDevice->DeviceExtension;
802
803 if (InterlockedCompareExchange(&Endpoint->FlushPendingLock, 1, 0))
804 {
805 DPRINT_CORE("USBPORT_FlushPendingTransfers: Endpoint Locked \n");
806 return;
807 }
808
809 while (TRUE)
810 {
811 IsMapTransfer = 0;
812
813 KeAcquireSpinLock(&FdoExtension->FlushPendingTransferSpinLock,
814 &OldIrql);
815
816 KeAcquireSpinLockAtDpcLevel(&Endpoint->EndpointSpinLock);
817
819 {
820 IsEnd = TRUE;
821
822 KeReleaseSpinLockFromDpcLevel(&Endpoint->EndpointSpinLock);
823 KeReleaseSpinLock(&FdoExtension->FlushPendingTransferSpinLock,
824 OldIrql);
825 goto Next;
826 }
827
828 if (!(Endpoint->Flags & ENDPOINT_FLAG_ROOTHUB_EP0))
829 {
830 if (!IsListEmpty(&Endpoint->TransferList))
831 {
832 List = Endpoint->TransferList.Flink;
833
834 while (List && List != &Endpoint->TransferList)
835 {
836 Transfer = CONTAINING_RECORD(List,
838 TransferLink);
839
840 if (!(Transfer->Flags & TRANSFER_FLAG_SUBMITED))
841 {
842 KeReleaseSpinLockFromDpcLevel(&Endpoint->EndpointSpinLock);
843 KeReleaseSpinLock(&FdoExtension->FlushPendingTransferSpinLock,
844 OldIrql);
845
846 IsEnd = TRUE;
847 goto Worker;
848 }
849
850 List = Transfer->TransferLink.Flink;
851 }
852 }
853 }
854
855 List = Endpoint->PendingTransferList.Flink;
856
857 if (List == NULL || IsListEmpty(&Endpoint->PendingTransferList))
858 {
859 KeReleaseSpinLockFromDpcLevel(&Endpoint->EndpointSpinLock);
860 KeReleaseSpinLock(&FdoExtension->FlushPendingTransferSpinLock,
861 OldIrql);
862
863 IsEnd = TRUE;
864 goto Worker;
865 }
866
867 Transfer = CONTAINING_RECORD(List,
869 TransferLink);
870
871 if (Transfer->Irp)
872 {
873 DPRINT_CORE("USBPORT_FlushPendingTransfers: Transfer->Irp->CancelRoutine - %p\n",
874 Transfer->Irp->CancelRoutine);
875 }
876
877 if (Transfer->Irp &&
878 (IoSetCancelRoutine(Transfer->Irp, NULL) == NULL))
879 {
880 DPRINT_CORE("USBPORT_FlushPendingTransfers: Transfer->Irp - %p\n",
881 Transfer->Irp);
882
883 Transfer = NULL;
884 IsEnd = TRUE;
885 }
886
887 if (!Transfer)
888 {
889 KeReleaseSpinLockFromDpcLevel(&Endpoint->EndpointSpinLock);
890 KeReleaseSpinLock(&FdoExtension->FlushPendingTransferSpinLock,
891 OldIrql);
892
893 if (IsMapTransfer)
894 {
895 USBPORT_FlushMapTransfers(FdoDevice);
896 goto Next;
897 }
898
899 goto Worker;
900 }
901
902 Irp = Transfer->Irp;
903 Urb = Transfer->Urb;
904
905 RemoveEntryList(&Transfer->TransferLink);
906 Transfer->TransferLink.Flink = NULL;
907 Transfer->TransferLink.Blink = NULL;
908
909 if (Irp)
910 {
912 }
913
914 KeReleaseSpinLockFromDpcLevel(&Endpoint->EndpointSpinLock);
915 KeReleaseSpinLock(&FdoExtension->FlushPendingTransferSpinLock,
916 OldIrql);
917
918 KeAcquireSpinLock(&FdoExtension->FlushTransferSpinLock, &OldIrql);
919
920 if (Irp)
921 {
923
924 if (Irp->Cancel && IoSetCancelRoutine(Irp, NULL))
925 {
926 DPRINT_CORE("USBPORT_FlushPendingTransfers: irp - %p\n", Irp);
927
928 KeReleaseSpinLock(&FdoExtension->FlushTransferSpinLock,
929 OldIrql);
930
932 goto Worker;
933 }
934
935 USBPORT_FindUrbInIrpTable(FdoExtension->ActiveIrpTable, Urb, Irp);
936 USBPORT_InsertIrpInTable(FdoExtension->ActiveIrpTable, Irp);
937 }
938
939 IsMapTransfer = USBPORT_QueueActiveUrbToEndpoint(Endpoint, Urb);
940
941 KeReleaseSpinLock(&FdoExtension->FlushTransferSpinLock, OldIrql);
942
943 if (IsMapTransfer)
944 {
945 USBPORT_FlushMapTransfers(FdoDevice);
946 goto Next;
947 }
948
949Worker:
953
954 if (Result)
956 Endpoint,
958
959Next:
960 if (IsEnd)
961 {
962 InterlockedDecrement(&Endpoint->FlushPendingLock);
963 DPRINT_CORE("USBPORT_FlushPendingTransfers: Endpoint Unlocked. Exit\n");
964 return;
965 }
966 }
967}
968
969VOID
970NTAPI
972 IN PURB Urb)
973{
974 PUSBPORT_TRANSFER Transfer;
975
976 DPRINT_CORE("USBPORT_QueuePendingUrbToEndpoint: Endpoint - %p, Urb - %p\n",
977 Endpoint,
978 Urb);
979
980 Transfer = Urb->UrbControlTransfer.hca.Reserved8[0];
981 //FIXME USBPORT_ResetEndpointIdle();
982 InsertTailList(&Endpoint->PendingTransferList, &Transfer->TransferLink);
983 Urb->UrbHeader.Status = USBD_STATUS_PENDING;
984}
985
987NTAPI
989 IN PURB Urb)
990{
991 PUSBPORT_TRANSFER Transfer;
992 PDEVICE_OBJECT FdoDevice;
996
997 DPRINT_CORE("USBPORT_QueueActiveUrbToEndpoint: Endpoint - %p, Urb - %p\n",
998 Endpoint,
999 Urb);
1000
1001 Transfer = Urb->UrbControlTransfer.hca.Reserved8[0];
1002 FdoDevice = Endpoint->FdoDevice;
1003 FdoExtension = FdoDevice->DeviceExtension;
1004
1005 KeAcquireSpinLock(&Endpoint->EndpointSpinLock,
1006 &Endpoint->EndpointOldIrql);
1007
1008 if ((Endpoint->Flags & ENDPOINT_FLAG_NUKE) ||
1009 (Transfer->Flags & TRANSFER_FLAG_ABORTED))
1010 {
1011 InsertTailList(&Endpoint->CancelList, &Transfer->TransferLink);
1012
1013 KeReleaseSpinLock(&Endpoint->EndpointSpinLock,
1014 Endpoint->EndpointOldIrql);
1015
1016 //DPRINT_CORE("USBPORT_QueueActiveUrbToEndpoint: return FALSE\n");
1017 return FALSE;
1018 }
1019
1020 if (Transfer->TransferParameters.TransferBufferLength == 0 ||
1021 !(Endpoint->Flags & ENDPOINT_FLAG_DMA_TYPE))
1022 {
1023 InsertTailList(&Endpoint->TransferList, &Transfer->TransferLink);
1024
1025 KeReleaseSpinLock(&Endpoint->EndpointSpinLock,
1026 Endpoint->EndpointOldIrql);
1027
1028 //DPRINT_CORE("USBPORT_QueueActiveUrbToEndpoint: return FALSE\n");
1029 return FALSE;
1030 }
1031
1032 KeReleaseSpinLock(&Endpoint->EndpointSpinLock, Endpoint->EndpointOldIrql);
1033
1034 KeAcquireSpinLock(&FdoExtension->MapTransferSpinLock, &OldIrql);
1035
1036 InsertTailList(&FdoExtension->MapTransferList, &Transfer->TransferLink);
1037
1038 DeviceHandle = Transfer->Urb->UrbHeader.UsbdDeviceHandle;
1039 InterlockedIncrement(&DeviceHandle->DeviceHandleLock);
1040
1041 KeReleaseSpinLock(&FdoExtension->MapTransferSpinLock, OldIrql);
1042
1043 //DPRINT_CORE("USBPORT_QueueActiveUrbToEndpoint: return TRUE\n");
1044 return TRUE;
1045}
1046
1047VOID
1048NTAPI
1050{
1051 PURB Urb;
1052 PUSBPORT_TRANSFER Transfer;
1053 PUSBPORT_ENDPOINT Endpoint;
1054 PDEVICE_OBJECT FdoDevice;
1056
1057 DPRINT_CORE("USBPORT_QueuePendingTransferIrp: Irp - %p\n", Irp);
1058
1059 Urb = URB_FROM_IRP(Irp);
1060
1061 Transfer = Urb->UrbControlTransfer.hca.Reserved8[0];
1062 Endpoint = Transfer->Endpoint;
1063
1064 FdoDevice = Endpoint->FdoDevice;
1065 FdoExtension = FdoDevice->DeviceExtension;
1066
1067 Irp->IoStatus.Status = STATUS_PENDING;
1069
1071
1072 if (Irp->Cancel && IoSetCancelRoutine(Irp, NULL))
1073 {
1075 }
1076 else
1077 {
1078 USBPORT_InsertIrpInTable(FdoExtension->PendingIrpTable, Irp);
1079 USBPORT_QueuePendingUrbToEndpoint(Endpoint, Urb);
1080 }
1081}
1082
1083VOID
1084NTAPI
1086{
1087 PUSBPORT_TRANSFER Transfer;
1088 PUSBPORT_ENDPOINT Endpoint;
1089 PIRP Irp;
1092
1093 DPRINT_CORE("USBPORT_QueueTransferUrb: Urb - %p\n", Urb);
1094
1095 if (Urb->UrbControlTransfer.TransferFlags & USBD_DEFAULT_PIPE_TRANSFER)
1096 Urb->UrbHeader.Function = URB_FUNCTION_CONTROL_TRANSFER;
1097
1098 Transfer = Urb->UrbControlTransfer.hca.Reserved8[0];
1099 Parameters = &Transfer->TransferParameters;
1100
1101 Endpoint = Transfer->Endpoint;
1102 Endpoint->Flags &= ~ENDPOINT_FLAG_QUEUENE_EMPTY;
1103
1104 Parameters->TransferBufferLength = Urb->UrbControlTransfer.TransferBufferLength;
1105 Parameters->TransferFlags = Urb->UrbControlTransfer.TransferFlags;
1106
1107 Transfer->TransferBufferMDL = Urb->UrbControlTransfer.TransferBufferMDL;
1108
1109 if (Urb->UrbControlTransfer.TransferFlags & USBD_TRANSFER_DIRECTION_IN)
1110 {
1112 }
1113 else
1114 {
1116 }
1117
1119 {
1120 RtlCopyMemory(&Parameters->SetupPacket,
1121 Urb->UrbControlTransfer.SetupPacket,
1123 }
1124
1125 DPRINT_URB("... URB TransferBufferLength - %x\n",
1126 Urb->UrbControlTransfer.TransferBufferLength);
1127
1128 Urb->UrbControlTransfer.TransferBufferLength = 0;
1129
1130 Irp = Transfer->Irp;
1131
1132 if (Irp)
1133 {
1135 }
1136 else
1137 {
1138 USBPORT_QueuePendingUrbToEndpoint(Endpoint, Urb);
1139 }
1140
1141 DeviceHandle = Urb->UrbHeader.UsbdDeviceHandle;
1142 InterlockedDecrement(&DeviceHandle->DeviceHandleLock);
1143
1145
1146 DPRINT_URB("... URB TransferBufferLength - %x\n",
1147 Urb->UrbControlTransfer.TransferBufferLength);
1148
1149 if (Urb->UrbControlTransfer.TransferBufferLength)
1150 {
1151 PULONG Buffer;
1154 ULONG ix;
1155
1156 Buffer = Urb->UrbControlTransfer.TransferBuffer;
1157 BufferLength = Urb->UrbControlTransfer.TransferBufferLength;
1159
1160 DPRINT_URB("URB TransferBuffer - %p\n", Buffer);
1161
1162 for (ix = 0; (ULONG_PTR)(Buffer + ix) < BufferEnd; ix++)
1163 {
1164 DPRINT_URB("Buffer[%02X] - %p\n", ix, Buffer[ix]);
1165 }
1166 }
1167}
1168
1169VOID
1170NTAPI
1172{
1175 PUSBPORT_ENDPOINT Endpoint;
1177 KIRQL OldIrql;
1178
1179 DPRINT_CORE("USBPORT_FlushAllEndpoints: ... \n");
1180
1181 FdoExtension = FdoDevice->DeviceExtension;
1182
1183 KeAcquireSpinLock(&FdoExtension->EndpointListSpinLock, &OldIrql);
1184
1186
1187 Entry = FdoExtension->EndpointList.Flink;
1188
1189 while (Entry && Entry != &FdoExtension->EndpointList)
1190 {
1191 Endpoint = CONTAINING_RECORD(Entry,
1193 EndpointLink);
1194
1196 {
1197 InsertTailList(&List, &Endpoint->FlushLink);
1198 }
1199
1200 Entry = Endpoint->EndpointLink.Flink;
1201 }
1202
1203 KeReleaseSpinLock(&FdoExtension->EndpointListSpinLock, OldIrql);
1204
1205 while (!IsListEmpty(&List))
1206 {
1207 Endpoint = CONTAINING_RECORD(List.Flink,
1209 FlushLink);
1210
1212
1213 Endpoint->FlushLink.Flink = NULL;
1214 Endpoint->FlushLink.Blink = NULL;
1215
1216 if (!IsListEmpty(&Endpoint->PendingTransferList))
1217 {
1219 }
1220 }
1221
1222 DPRINT_CORE("USBPORT_FlushAllEndpoints: exit\n");
1223}
1224
1225ULONG
1226NTAPI
1228 IN PUSBPORT_ENDPOINT Endpoint)
1229{
1230 PLIST_ENTRY ActiveList;
1231 PUSBPORT_TRANSFER Transfer;
1232 ULONG KilledTransfers = 0;
1233
1234 DPRINT_CORE("USBPORT_KillEndpointActiveTransfers \n");
1235
1236 ActiveList = Endpoint->TransferList.Flink;
1237
1238 while (ActiveList && ActiveList != &Endpoint->TransferList)
1239 {
1240 ++KilledTransfers;
1241
1242 Transfer = CONTAINING_RECORD(ActiveList,
1244 TransferLink);
1245
1246 Transfer->Flags |= TRANSFER_FLAG_ABORTED;
1247
1248 ActiveList = Transfer->TransferLink.Flink;
1249 }
1250
1252 USBPORT_FlushCancelList(Endpoint);
1253
1254 return KilledTransfers;
1255}
1256
1257VOID
1258NTAPI
1260{
1263 PUSBPORT_ENDPOINT Endpoint;
1264 ULONG KilledTransfers;
1265 PLIST_ENTRY EndpointList;
1266 KIRQL OldIrql;
1268
1269 DPRINT_CORE("USBPORT_FlushController \n");
1270
1271 FdoExtension = FdoDevice->DeviceExtension;
1272
1273 EndpointList = &FdoExtension->EndpointList;
1274
1275 while (TRUE)
1276 {
1277 KeAcquireSpinLock(&FdoExtension->EndpointListSpinLock, &OldIrql);
1278
1280
1281 Entry = EndpointList->Flink;
1282
1283 if (!IsListEmpty(EndpointList))
1284 {
1285 while (Entry && Entry != EndpointList)
1286 {
1287 Endpoint = CONTAINING_RECORD(Entry,
1289 EndpointLink);
1290
1291 if (Endpoint->StateLast != USBPORT_ENDPOINT_REMOVE &&
1293 {
1296 }
1297
1298 Entry = Endpoint->EndpointLink.Flink;
1299 }
1300 }
1301
1302 KeReleaseSpinLock(&FdoExtension->EndpointListSpinLock, OldIrql);
1303
1304 KilledTransfers = 0;
1305 while (!IsListEmpty(&FlushList))
1306 {
1307 Endpoint = CONTAINING_RECORD(FlushList.Flink,
1309 FlushControllerLink);
1310
1312
1313 KilledTransfers += USBPORT_KillEndpointActiveTransfers(FdoDevice,
1314 Endpoint);
1315
1317 }
1318
1319 if (!KilledTransfers)
1320 break;
1321
1322 USBPORT_Wait(FdoDevice, 100);
1323 }
1324}
1325
1326VOID
1327NTAPI
1329{
1331 PIRP Irp;
1332
1333 DPRINT_QUEUE("USBPORT_BadRequestFlush: ... \n");
1334
1335 FdoExtension = FdoDevice->DeviceExtension;
1336
1337 while (TRUE)
1338 {
1339 Irp = IoCsqRemoveNextIrp(&FdoExtension->BadRequestIoCsq, 0);
1340
1341 if (!Irp)
1342 break;
1343
1344 DPRINT1("USBPORT_BadRequestFlush: Irp - %p\n", Irp);
1345
1346 Irp->IoStatus.Status = STATUS_DEVICE_NOT_CONNECTED;
1347 Irp->IoStatus.Information = 0;
1349 }
1350}
1351
1352VOID
1353NTAPI
1355 IN PUSBPORT_ENDPOINT Endpoint,
1356 IN PIRP Irp)
1357{
1358 PLIST_ENTRY PendingList;
1359 PUSBPORT_TRANSFER PendingTransfer;
1360 PLIST_ENTRY ActiveList;
1361 PUSBPORT_TRANSFER ActiveTransfer;
1362
1363 DPRINT_CORE("USBPORT_AbortEndpoint: Irp - %p\n", Irp);
1364
1365 KeAcquireSpinLock(&Endpoint->EndpointSpinLock, &Endpoint->EndpointOldIrql);
1366
1367 if (Irp)
1368 {
1369 InsertTailList(&Endpoint->AbortList, &Irp->Tail.Overlay.ListEntry);
1370 }
1371
1372 PendingList = Endpoint->PendingTransferList.Flink;
1373
1374 while (PendingList && PendingList != &Endpoint->PendingTransferList)
1375 {
1376 PendingTransfer = CONTAINING_RECORD(PendingList,
1378 TransferLink);
1379
1380 DPRINT_CORE("USBPORT_AbortEndpoint: Abort PendingTransfer - %p\n",
1381 PendingTransfer);
1382
1383 PendingTransfer->Flags |= TRANSFER_FLAG_ABORTED;
1384
1385 PendingList = PendingTransfer->TransferLink.Flink;
1386 }
1387
1388 ActiveList = Endpoint->TransferList.Flink;
1389
1390 while (ActiveList && ActiveList != &Endpoint->TransferList)
1391 {
1392 ActiveTransfer = CONTAINING_RECORD(ActiveList,
1394 TransferLink);
1395
1396 DPRINT_CORE("USBPORT_AbortEndpoint: Abort ActiveTransfer - %p\n",
1397 ActiveTransfer);
1398
1399 ActiveTransfer->Flags |= TRANSFER_FLAG_ABORTED;
1400
1401 if (Endpoint->Flags & ENDPOINT_FLAG_ABORTING)
1402 {
1403 ActiveTransfer->Flags |= TRANSFER_FLAG_DEVICE_GONE;
1404 }
1405
1406 ActiveList = ActiveTransfer->TransferLink.Flink;
1407 }
1408
1409 KeReleaseSpinLock(&Endpoint->EndpointSpinLock, Endpoint->EndpointOldIrql);
1410
1412 Endpoint,
1414
1416 USBPORT_FlushCancelList(Endpoint);
1417}
PSINGLE_LIST_ENTRY FlushList(PSINGLE_LIST_ENTRY ListHead)
Definition: ExSingleList.c:24
unsigned char BOOLEAN
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
Definition: bufpool.h:45
_In_ PIRP Irp
Definition: csq.h:116
_In_opt_ PIRP _In_opt_ PVOID PeekContext
Definition: csq.h:160
_Out_ PKIRQL Irql
Definition: csq.h:179
NTKERNELAPI PIRP NTAPI IoCsqRemoveNextIrp(_Inout_ PIO_CSQ Csq, _In_opt_ PVOID PeekContext)
IoCsqRemoveNextIrp - Removes the next IRP from the queue.
Definition: csq.c:398
IO_CSQ Csq
Definition: csqrtns.c:46
#define STATUS_PENDING
Definition: d3dkmdt.h:43
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define ULONG_PTR
Definition: config.h:101
@ PdoExtension
Definition: precomp.h:49
@ FdoExtension
Definition: precomp.h:48
VOID NTAPI USBPORT_AbortEndpoint(IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_ENDPOINT Endpoint, IN PIRP Irp)
Definition: queue.c:1354
VOID NTAPI USBPORT_CancelActiveTransferIrp(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: queue.c:529
VOID NTAPI USBPORT_ReleaseIdleLock(IN PIO_CSQ Csq, IN KIRQL Irql)
Definition: queue.c:107
VOID NTAPI USBPORT_QueuePendingUrbToEndpoint(IN PUSBPORT_ENDPOINT Endpoint, IN PURB Urb)
Definition: queue.c:971
VOID NTAPI USBPORT_InsertIrpInTable(IN PUSBPORT_IRP_TABLE IrpTable, IN PIRP Irp)
Definition: queue.c:266
VOID NTAPI USBPORT_QueuePendingTransferIrp(IN PIRP Irp)
Definition: queue.c:1049
VOID NTAPI USBPORT_RemoveBadRequest(IN PIO_CSQ Csq, IN PIRP Irp)
Definition: queue.c:160
VOID NTAPI USBPORT_FlushController(IN PDEVICE_OBJECT FdoDevice)
Definition: queue.c:1259
VOID NTAPI USBPORT_CancelPendingTransferIrp(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: queue.c:479
PIRP NTAPI USBPORT_RemoveIrpFromTable(IN PUSBPORT_IRP_TABLE IrpTable, IN PIRP Irp)
Definition: queue.c:316
VOID NTAPI USBPORT_InsertIdleIrp(IN PIO_CSQ Csq, IN PIRP Irp)
Definition: queue.c:20
VOID NTAPI USBPORT_QueueTransferUrb(IN PURB Urb)
Definition: queue.c:1085
ULONG NTAPI USBPORT_KillEndpointActiveTransfers(IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_ENDPOINT Endpoint)
Definition: queue.c:1227
PIRP NTAPI USBPORT_RemovePendingTransferIrp(IN PDEVICE_OBJECT FdoDevice, IN PIRP Irp)
Definition: queue.c:369
PIRP NTAPI USBPORT_PeekNextBadRequest(IN PIO_CSQ Csq, IN PIRP Irp, IN PVOID PeekContext)
Definition: queue.c:169
PIRP NTAPI USBPORT_PeekNextIdleIrp(IN PIO_CSQ Csq, IN PIRP Irp, IN PVOID PeekContext)
Definition: queue.c:46
VOID NTAPI USBPORT_FlushPendingTransfers(IN PUSBPORT_ENDPOINT Endpoint)
Definition: queue.c:785
VOID NTAPI USBPORT_InsertBadRequest(IN PIO_CSQ Csq, IN PIRP Irp)
Definition: queue.c:143
VOID NTAPI USBPORT_CompleteCanceledBadRequest(IN PIO_CSQ Csq, IN PIRP Irp)
Definition: queue.c:246
PIRP NTAPI USBPORT_FindIrpInTable(IN PUSBPORT_IRP_TABLE IrpTable, IN PIRP Irp)
Definition: queue.c:433
VOID NTAPI USBPORT_FlushAllEndpoints(IN PDEVICE_OBJECT FdoDevice)
Definition: queue.c:1171
VOID NTAPI USBPORT_FindUrbInIrpTable(IN PUSBPORT_IRP_TABLE IrpTable, IN PURB Urb, IN PIRP Irp)
Definition: queue.c:381
VOID NTAPI USBPORT_ReleaseBadRequestLock(IN PIO_CSQ Csq, IN KIRQL Irql)
Definition: queue.c:230
VOID NTAPI USBPORT_CompleteCanceledIdleIrp(IN PIO_CSQ Csq, IN PIRP Irp)
Definition: queue.c:123
PIRP NTAPI USBPORT_RemoveActiveTransferIrp(IN PDEVICE_OBJECT FdoDevice, IN PIRP Irp)
Definition: queue.c:357
VOID NTAPI USBPORT_AcquireBadRequestLock(IN PIO_CSQ Csq, IN PKIRQL Irql)
Definition: queue.c:214
BOOLEAN NTAPI USBPORT_QueueActiveUrbToEndpoint(IN PUSBPORT_ENDPOINT Endpoint, IN PURB Urb)
Definition: queue.c:988
VOID NTAPI USBPORT_AcquireIdleLock(IN PIO_CSQ Csq, IN PKIRQL Irql)
Definition: queue.c:91
VOID NTAPI USBPORT_BadRequestFlush(IN PDEVICE_OBJECT FdoDevice)
Definition: queue.c:1328
VOID NTAPI USBPORT_RemoveIdleIrp(IN PIO_CSQ Csq, IN PIRP Irp)
Definition: queue.c:37
PIRP NTAPI USBPORT_FindActiveTransferIrp(IN PDEVICE_OBJECT FdoDevice, IN PIRP Irp)
Definition: queue.c:467
VOID NTAPI USBPORT_FlushCancelList(IN PUSBPORT_ENDPOINT Endpoint)
Definition: queue.c:714
VOID NTAPI USBPORT_FlushAbortList(IN PUSBPORT_ENDPOINT Endpoint)
Definition: queue.c:605
BOOLEAN NTAPI USBPORT_EndpointWorker(IN PUSBPORT_ENDPOINT Endpoint, IN BOOLEAN LockNotChecked)
Definition: endpoint.c:1656
VOID NTAPI USBPORT_InvalidateEndpointHandler(IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_ENDPOINT Endpoint, IN ULONG Type)
Definition: endpoint.c:1317
ULONG NTAPI USBPORT_GetEndpointState(IN PUSBPORT_ENDPOINT Endpoint)
Definition: endpoint.c:332
#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 KeRaiseIrql(irql, oldIrql)
Definition: env_spec_w32.h:597
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
KIRQL * PKIRQL
Definition: env_spec_w32.h:592
#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
FxIrp * irp
Status
Definition: gdiplustypes.h:25
_Inout_ PUSB_DEVICE_HANDLE DeviceHandle
Definition: hubbusif.h:121
#define InterlockedCompareExchange
Definition: interlocked.h:104
IoMarkIrpPending(Irp)
IoSetCancelRoutine(Irp, CancelRoutine)
#define ASSERT(a)
Definition: mode.c:44
#define IoCompleteRequest
Definition: irp.c:1240
VOID NTAPI IoReleaseCancelSpinLock(IN KIRQL Irql)
Definition: util.c:150
VOID NTAPI IoAcquireCancelSpinLock(OUT PKIRQL Irql)
Definition: util.c:56
VOID NTAPI KeBugCheckEx(_In_ ULONG BugCheckCode, _In_ ULONG_PTR BugCheckParameter1, _In_ ULONG_PTR BugCheckParameter2, _In_ ULONG_PTR BugCheckParameter3, _In_ ULONG_PTR BugCheckParameter4)
Definition: rtlcompat.c:108
#define KeAcquireSpinLockAtDpcLevel(SpinLock)
Definition: ke.h:125
#define KeReleaseSpinLockFromDpcLevel(SpinLock)
Definition: ke.h:135
#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: csq.h:222
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_CONTROL_TRANSFER UrbControlTransfer
Definition: usb.h:539
struct _URB_HEADER UrbHeader
Definition: usb.h:531
LIST_ENTRY FlushControllerLink
Definition: usbport.h:237
LIST_ENTRY EndpointLink
Definition: usbport.h:232
PDEVICE_OBJECT FdoDevice
Definition: usbport.h:206
LIST_ENTRY PendingTransferList
Definition: usbport.h:227
KSPIN_LOCK EndpointSpinLock
Definition: usbport.h:215
USBPORT_ENDPOINT_PROPERTIES EndpointProperties
Definition: usbport.h:211
LIST_ENTRY FlushLink
Definition: usbport.h:236
PMDL TransferBufferMDL
Definition: usbport.h:255
KSPIN_LOCK TransferSpinLock
Definition: usbport.h:265
LIST_ENTRY SplitTransfersList
Definition: usbport.h:266
USBPORT_TRANSFER_PARAMETERS TransferParameters
Definition: usbport.h:254
PUSBPORT_ENDPOINT Endpoint
Definition: usbport.h:253
LIST_ENTRY TransferLink
Definition: usbport.h:257
uint32_t * PULONG
Definition: typedefs.h:59
#define NTAPI
Definition: typedefs.h:36
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#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 STATUS_DEVICE_NOT_CONNECTED
Definition: udferr_usr.h:160
#define STATUS_CANCELLED
Definition: udferr_usr.h:170
#define USBD_STATUS_DEVICE_GONE
Definition: usb.h:210
#define USBD_STATUS_CANCELED
Definition: usb.h:213
#define USBD_STATUS_SUCCESS
Definition: usb.h:170
#define USBD_TRANSFER_DIRECTION_IN
Definition: usb.h:160
#define URB_FUNCTION_CONTROL_TRANSFER
Definition: usb.h:94
#define URB_FROM_IRP(Irp)
Definition: usb.h:85
#define USBD_STATUS_PENDING
Definition: usb.h:171
#define USBD_DEFAULT_PIPE_TRANSFER
Definition: usb.h:156
#define DPRINT_CORE(...)
Definition: usbdebug.h:144
#define DPRINT_URB(...)
Definition: usbdebug.h:145
#define DPRINT_QUEUE(...)
Definition: usbdebug.h:148
_In_ PUCHAR BufferEnd
Definition: usbdlib.h:189
#define USBPORT_ENDPOINT_REMOVE
Definition: usbmport.h:16
#define USBPORT_TRANSFER_TYPE_CONTROL
Definition: usbmport.h:8
#define USBPORT_ENDPOINT_CLOSED
Definition: usbmport.h:17
VOID NTAPI USBPORT_FlushMapTransfers(IN PDEVICE_OBJECT FdoDevice)
Definition: usbport.c:2483
VOID NTAPI USBPORT_CompleteTransfer(IN PURB Urb, IN USBD_STATUS TransferStatus)
Definition: usbport.c:2198
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
#define USBPORT_DMA_DIRECTION_TO_DEVICE
Definition: usbport.h:42
#define ENDPOINT_FLAG_ABORTING
Definition: usbport.h:115
#define INVALIDATE_ENDPOINT_INT_NEXT_SOF
Definition: usbport.h:39
#define USBPORT_DMA_DIRECTION_FROM_DEVICE
Definition: usbport.h:41
#define TRANSFER_FLAG_CANCELED
Definition: usbport.h:130
#define ENDPOINT_FLAG_ROOTHUB_EP0
Definition: usbport.h:112
#define USB_PORT_TAG
Definition: usbport.h:44
#define TRANSFER_FLAG_PARENT
Definition: usbport.h:139
#define INVALIDATE_ENDPOINT_WORKER_THREAD
Definition: usbport.h:37
#define USBPORT_FLAG_HC_SUSPEND
Definition: usbport.h:71
#define TRANSFER_FLAG_SUBMITED
Definition: usbport.h:133
#define ENDPOINT_FLAG_DMA_TYPE
Definition: usbport.h:111
#define ENDPOINT_FLAG_NUKE
Definition: usbport.h:113
#define TRANSFER_FLAG_DEVICE_GONE
Definition: usbport.h:136
#define TRANSFER_FLAG_ABORTED
Definition: usbport.h:134
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
Definition: wdfdevice.h:3771
_Must_inspect_result_ _In_ WDFQUEUE _In_opt_ WDFREQUEST _In_opt_ WDFFILEOBJECT _Inout_opt_ PWDF_REQUEST_PARAMETERS Parameters
Definition: wdfio.h:869
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
_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
#define IO_NO_INCREMENT
Definition: iotypes.h:598
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:778