ReactOS 0.4.15-dev-7705-g2320c37
ioctl.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS USB Hub Driver
3 * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4 * PURPOSE: USBHub I/O control functions
5 * COPYRIGHT: Copyright 2017 Vadim Galyant <vgal@rambler.ru>
6 */
7
8#include "usbhub.h"
9
10#define NDEBUG
11#include <debug.h>
12
13#define NDEBUG_USBHUB_IOCTL
14#include "dbg_uhub.h"
15
19 IN PIRP Irp,
21{
22 PUSBHUB_PORT_PDO_EXTENSION PortExtension;
23 PUSBHUB_FDO_EXTENSION HubExtension;
24 PVOID TimeoutContext; // PUSBHUB_BANDWIDTH_TIMEOUT_CONTEXT
25 PUSBHUB_PORT_DATA PortData = NULL;
28 PURB Urb;
29
30 DPRINT("USBH_SelectConfigOrInterfaceComplete ... \n");
31
32 if (Irp->PendingReturned)
33 {
35 }
36
37 PortExtension = Context;
38 HubExtension = PortExtension->HubExtension;
39
40 ASSERT(PortExtension->PortNumber > 0);
41
42 if (HubExtension)
43 {
44 PortData = &HubExtension->PortData[PortExtension->PortNumber - 1];
45 }
46
47 Status = Irp->IoStatus.Status;
48
49 if (NT_SUCCESS(Irp->IoStatus.Status))
50 {
52
53 TimeoutContext = PortExtension->BndwTimeoutContext;
54
55 if (TimeoutContext)
56 {
57 DPRINT1("USBH_SelectConfigOrInterfaceComplete: TimeoutContext != NULL. FIXME\n");
59 }
60
62
65
66 if (PortData && PortData->ConnectionStatus != DeviceHubNestedTooDeeply)
67 {
69 }
70 }
71 else
72 {
73 Urb = URB_FROM_IRP(Irp);
74 DPRINT1("USBH_SelectConfigOrInterfaceComplete: Status = 0x%lx, UsbdStatus = 0x%lx\n", Status, Urb->UrbHeader.Status);
75 if (Urb->UrbHeader.Status == USBD_STATUS_NO_BANDWIDTH)
76 {
77 DPRINT1("USBH_SelectConfigOrInterfaceComplete: USBD_STATUS_NO_BANDWIDTH. FIXME\n");
78 /*DbgBreakPoint();*/ /* disabled due to CORE-16384, seems to be continuable */
79 }
80 }
81
82 return Status;
83}
84
88 IN PIRP Irp)
89{
91 PUSBHUB_FDO_EXTENSION HubExtension;
93 PURB Urb;
95 ULONG MaxPower;
96 USBD_STATUS UrbStatus;
97 BOOLEAN IsValidConfig;
98
99 HubExtension = PortExtension->HubExtension;
100 DeviceObject = PortExtension->Common.SelfDevice;
101
102 Urb = URB_FROM_IRP(Irp);
103
104 DPRINT_IOCTL("USBH_PdoUrbFilter: Device - %p, Irp - %p, Urb - %p\n",
106 Irp,
107 Urb);
108
109 if (PortExtension->PortPdoFlags & (USBHUB_PDO_FLAG_PORT_RESTORE_FAIL |
111 {
115 }
116
117 Function = Urb->UrbHeader.Function;
118
119 switch (Function)
120 {
122 {
123 ConfigDescriptor = Urb->UrbSelectConfiguration.ConfigurationDescriptor;
124
126 {
127 IsValidConfig = TRUE;
128
130 {
131 DPRINT1("USBH_PdoUrbFilter: Not valid Cfg. bDescriptorType\n");
132 IsValidConfig = FALSE;
134 }
135
136 if (ConfigDescriptor->bLength < sizeof(USB_CONFIGURATION_DESCRIPTOR))
137 {
138 DPRINT1("USBH_PdoUrbFilter: Size Cfg. descriptor is too small\n");
139 IsValidConfig = FALSE;
141 }
142
143 if (!IsValidConfig)
144 {
145 Urb->UrbHeader.Status = UrbStatus;
148 }
149
150 MaxPower = 2 * ConfigDescriptor->MaxPower;
151 PortExtension->MaxPower = MaxPower;
152
153 if (HubExtension->MaxPowerPerPort < MaxPower)
154 {
155 PortExtension->PortPdoFlags |= USBHUB_PDO_FLAG_INSUFFICIENT_PWR;
156
157 DPRINT1("USBH_PdoUrbFilter: USBH_InvalidatePortDeviceState() UNIMPLEMENTED. FIXME\n");
159
162 }
163 }
164 }
165
166 /* fall through */
167
169 {
171
174 PortExtension,
175 TRUE,
176 TRUE,
177 TRUE);
178
179 return IoCallDriver(HubExtension->RootHubPdo2, Irp);
180 }
181
185 {
186 if (PortExtension->PortPdoFlags & USBHUB_PDO_FLAG_DELETE_PENDING)
187 {
191 }
192
193 break;
194 }
195
196 case URB_FUNCTION_GET_MS_FEATURE_DESCRIPTOR:
197 DPRINT1("USBH_PdoUrbFilter: URB_FUNCTION_GET_MS_FEATURE_DESCRIPTOR UNIMPLEMENTED. FIXME\n");
200
201 default:
202 break;
203 }
204
205 return USBH_PassIrp(HubExtension->RootHubPdo2, Irp);
206}
207
209NTAPI
211 IN PIRP Irp)
212{
213 PUSBHUB_FDO_EXTENSION HubExtension;
214 PURB Urb;
216
217 DPRINT_IOCTL("USBH_PdoIoctlSubmitUrb ... \n");
218
219 HubExtension = PortExtension->HubExtension;
220
221 Urb = URB_FROM_IRP(Irp);
222
223 if (PortExtension->DeviceHandle == NULL)
224 {
225 Urb->UrbHeader.UsbdDeviceHandle = NULL;
226 Status = USBH_PassIrp(HubExtension->RootHubPdo2, Irp);
227 }
228 else
229 {
230 Urb->UrbHeader.UsbdDeviceHandle = PortExtension->DeviceHandle;
231 Status = USBH_PdoUrbFilter(PortExtension, Irp);
232 }
233
234 return Status;
235}
236
238NTAPI
240 IN PIRP Irp)
241{
242 PUSBHUB_FDO_EXTENSION HubExtension;
243 PUSBHUB_PORT_DATA PortData;
244 PIO_STACK_LOCATION IoStack;
247
248 DPRINT("USBH_PdoIoctlGetPortStatus ... \n");
249
250 HubExtension = PortExtension->HubExtension;
251
253
254 KeWaitForSingleObject(&HubExtension->HubSemaphore,
255 Executive,
257 FALSE,
258 NULL);
259
260 ASSERT(PortExtension->PortNumber > 0);
261 PortData = &HubExtension->PortData[PortExtension->PortNumber - 1];
262
263 Status = USBH_SyncGetPortStatus(HubExtension,
264 PortExtension->PortNumber,
265 &PortData->PortStatus,
267
269 PortStatus = IoStack->Parameters.Others.Argument1;
270
271 *PortStatus = 0;
272
273 if (PortExtension->Common.SelfDevice == PortData->DeviceObject)
274 {
276 {
278 }
279
281 {
283 }
284 }
285
286 KeReleaseSemaphore(&HubExtension->HubSemaphore,
288 1,
289 FALSE);
290
291 if (!InterlockedDecrement(&HubExtension->PendingRequestCount))
292 {
293 KeSetEvent(&HubExtension->PendingRequestEvent,
295 FALSE);
296 }
297
299
300 return Status;
301}
302
303VOID
304NTAPI
307{
308 PUSBHUB_RESET_PORT_CONTEXT WorkItemReset;
309 PUSBHUB_PORT_PDO_EXTENSION PortExtension;
312 USHORT Port;
313
314 DPRINT("USBH_ResetPortWorker ... \n");
315
316 WorkItemReset = Context;
317
318 PortExtension = WorkItemReset->PortExtension;
319
320 if (!HubExtension)
321 {
323 goto Exit;
324 }
325
326 InterlockedIncrement(&HubExtension->PendingRequestCount);
327
328 KeWaitForSingleObject(&HubExtension->HubSemaphore,
329 Executive,
331 FALSE,
332 NULL);
333
334 Port = PortExtension->PortNumber;
335 DeviceHandle = PortExtension->DeviceHandle;
336
337 ASSERT(Port > 0);
338
339 if (PortExtension->Common.SelfDevice == HubExtension->PortData[Port-1].DeviceObject &&
341 {
342 USBD_RemoveDeviceEx(HubExtension,
345
346 Status = USBH_ResetDevice(HubExtension,
347 Port,
348 TRUE,
349 FALSE);
350 }
351 else
352 {
354 }
355
356 KeReleaseSemaphore(&HubExtension->HubSemaphore,
358 1,
359 FALSE);
360
361 if (!InterlockedDecrement(&HubExtension->PendingRequestCount))
362 {
363 KeSetEvent(&HubExtension->PendingRequestEvent,
365 FALSE);
366 }
367
368Exit:
369
370 PortExtension->PortPdoFlags &= ~USBHUB_PDO_FLAG_PORT_RESSETING;
371
372 USBH_CompleteIrp(WorkItemReset->Irp, Status);
373
374 WorkItemReset->PortExtension->PortPdoFlags &= ~USBHUB_PDO_FLAG_PORT_RESTORE_FAIL;
375}
376
378NTAPI
380 IN PIRP Irp)
381{
382 PUSBHUB_FDO_EXTENSION HubExtension;
383 PUSBHUB_RESET_PORT_CONTEXT HubWorkItemBuffer;
384 PUSBHUB_IO_WORK_ITEM HubIoWorkItem;
386
387 HubExtension = PortExtension->HubExtension;
388
389 DPRINT("USBH_PdoIoctlResetPort ... \n");
390
391 if (PortExtension->PortPdoFlags & USBHUB_PDO_FLAG_PORT_RESSETING)
392 {
395 return Status;
396 }
397
398 Status = USBH_AllocateWorkItem(HubExtension,
399 &HubIoWorkItem,
402 (PVOID *)&HubWorkItemBuffer,
404
405 if (!NT_SUCCESS(Status))
406 {
409 return Status;
410 }
411
412 PortExtension->PortPdoFlags |= USBHUB_PDO_FLAG_PORT_RESSETING;
414
415 HubWorkItemBuffer->PortExtension = PortExtension;
416 HubWorkItemBuffer->Irp = Irp;
417
419
420 USBH_QueueWorkItem(PortExtension->HubExtension, HubIoWorkItem);
421
422 return Status;
423}
424
425VOID
426NTAPI
428 IN PIRP Irp)
429{
430 PUSBHUB_PORT_PDO_EXTENSION PortExtension;
431 PUSBHUB_FDO_EXTENSION HubExtension;
432 PIRP PendingIdleIrp = NULL;
433 PUSBHUB_IO_WORK_ITEM HubIoWorkItem;
434 PUSBHUB_IDLE_PORT_CANCEL_CONTEXT HubWorkItemBuffer;
436
437 DPRINT("USBH_PortIdleNotificationCancelRoutine ... \n");
438
439 PortExtension = Device->DeviceExtension;
440 PortExtension->PortPdoFlags &= ~USBHUB_PDO_FLAG_IDLE_NOTIFICATION;
441
442 HubExtension = PortExtension->HubExtension;
443 ASSERT(HubExtension);
444
445 PortExtension->IdleNotificationIrp = NULL;
446
448 {
449 PendingIdleIrp = HubExtension->PendingIdleIrp;
450 HubExtension->PendingIdleIrp = NULL;
451 }
452
453 IoReleaseCancelSpinLock(Irp->CancelIrql);
454
455 if (PendingIdleIrp)
456 {
457 USBH_HubCancelIdleIrp(HubExtension, PendingIdleIrp);
458 }
459
460 if (HubExtension->CurrentPowerState.DeviceState == PowerDeviceD0)
461 {
462 goto ErrorExit;
463 }
464
465 Status = USBH_AllocateWorkItem(HubExtension,
466 &HubIoWorkItem,
469 (PVOID *)&HubWorkItemBuffer,
471
472 if (NT_SUCCESS(Status))
473 {
474 HubWorkItemBuffer->Irp = Irp;
475 USBH_QueueWorkItem(HubExtension, HubIoWorkItem);
476 return;
477 }
478
480
481 Irp->IoStatus.Status = STATUS_CANCELLED;
483}
484
486NTAPI
488 IN PIRP Irp)
489{
490 PUSBHUB_FDO_EXTENSION HubExtension;
491 PIO_STACK_LOCATION IoStack;
492 PUSB_IDLE_CALLBACK_INFO IdleCallbackInfo;
494 KIRQL Irql;
495
496 DPRINT("USBH_PortIdleNotificationRequest ... \n");
497
498 HubExtension = PortExtension->HubExtension;
499
501
502 if (PortExtension->IdleNotificationIrp)
503 {
505 Irp->IoStatus.Status = STATUS_DEVICE_BUSY;
507 return STATUS_DEVICE_BUSY;
508 }
509
511 IdleCallbackInfo = IoStack->Parameters.DeviceIoControl.Type3InputBuffer;
512
513 if (!IdleCallbackInfo || !IdleCallbackInfo->IdleCallback)
514 {
516
518 Irp->IoStatus.Status = Status;
520
521 return Status;
522 }
523
525
526 if (Irp->Cancel)
527 {
529 {
532 Irp->IoStatus.Status = STATUS_CANCELLED;
534 }
535 else
536 {
540 }
541 }
542 else
543 {
544 PortExtension->PortPdoFlags |= USBHUB_PDO_FLAG_IDLE_NOTIFICATION;
545
546 PortExtension->IdleNotificationIrp = Irp;
548
551
552 DPRINT("USBH_PortIdleNotificationRequest: IdleNotificationIrp - %p\n",
553 PortExtension->IdleNotificationIrp);
554
555 USBH_CheckIdleDeferred(HubExtension);
556 }
557
558 return Status;
559}
560
562NTAPI
564 IN PIRP Irp)
565{
566 PUSB_NODE_CONNECTION_NAME ConnectionName;
567 PDEVICE_OBJECT PortDevice;
568 PUSBHUB_PORT_PDO_EXTENSION PortExtension;
569 size_t LengthSkip;
574 size_t LengthName;
577 PIO_STACK_LOCATION IoStack;
579
580 DPRINT("USBH_IoctlGetNodeName ... \n");
581
583
584 ConnectionName = Irp->AssociatedIrp.SystemBuffer;
585
587 Length = IoStack->Parameters.DeviceIoControl.OutputBufferLength;
588
589 if (Length < sizeof(USB_NODE_CONNECTION_NAME))
590 {
592 Information = Irp->IoStatus.Information;
593 goto Exit;
594 }
595
596 if (ConnectionName->ConnectionIndex == 0 ||
597 ConnectionName->ConnectionIndex > HubExtension->HubDescriptor->bNumberOfPorts)
598 {
600 Information = Irp->IoStatus.Information;
601 goto Exit;
602 }
603
604 PortDevice = HubExtension->PortData[ConnectionName->ConnectionIndex - 1].DeviceObject;
605
606 if (!PortDevice)
607 {
608 ConnectionName->NodeName[0] = 0;
609 ConnectionName->ActualLength = sizeof(USB_NODE_CONNECTION_NAME);
610
612 goto Exit;
613 }
614
615 PortExtension = PortDevice->DeviceExtension;
616
617 if (!(PortExtension->PortPdoFlags & USBHUB_PDO_FLAG_HUB_DEVICE) ||
618 !(PortExtension->PortPdoFlags & USBHUB_PDO_FLAG_DEVICE_STARTED) ||
620 {
621 ConnectionName->NodeName[0] = 0;
622 ConnectionName->ActualLength = sizeof(USB_NODE_CONNECTION_NAME);
623
625 goto Exit;
626 }
627
628 Buffer = PortExtension->SymbolicLinkName.Buffer;
629 BufferLength = PortExtension->SymbolicLinkName.Length;
630
632
633 LengthSkip = 0;
634
635 if (*Buffer == L'\\')
636 {
637 BufferEnd = wcschr(Buffer + 1, L'\\');
638
639 if (BufferEnd != NULL)
640 {
641 LengthSkip = (BufferEnd + 1 - Buffer) * sizeof(WCHAR);
642 }
643 else
644 {
645 LengthSkip = PortExtension->SymbolicLinkName.Length;
646 }
647 }
648
649 LengthName = BufferLength - LengthSkip;
650
651 ConnectionName->ActualLength = 0;
652
653 RtlZeroMemory(ConnectionName->NodeName,
655
656 LengthReturned = sizeof(USB_NODE_CONNECTION_NAME) + LengthName;
657
659 {
660 ConnectionName->NodeName[0] = 0;
661 ConnectionName->ActualLength = LengthReturned;
662
664 goto Exit;
665 }
666
667 RtlCopyMemory(&ConnectionName->NodeName[0],
668 &Buffer[LengthSkip / sizeof(WCHAR)],
669 LengthName);
670
671 ConnectionName->ActualLength = LengthReturned;
672
675
676Exit:
677 Irp->IoStatus.Information = Information;
679 return Status;
680}
681
683NTAPI
685 IN PIRP Irp)
686{
687 PUSB_NODE_INFORMATION NodeInfo;
688 PIO_STACK_LOCATION IoStack;
691 BOOLEAN HubIsBusPowered;
692
693 DPRINT("USBH_IoctlGetNodeInformation ... \n");
694
696
697 NodeInfo = Irp->AssociatedIrp.SystemBuffer;
698
700 BufferLength = IoStack->Parameters.DeviceIoControl.OutputBufferLength;
701
702 RtlZeroMemory(Irp->AssociatedIrp.SystemBuffer, BufferLength);
703
705 {
708 return Status;
709 }
710
711 NodeInfo->NodeType = UsbHub;
712
714 HubExtension->HubDescriptor,
715 sizeof(USB_HUB_DESCRIPTOR));
716
717 HubIsBusPowered = USBH_HubIsBusPowered(HubExtension->Common.SelfDevice,
718 HubExtension->HubConfigDescriptor);
719
720 NodeInfo->u.HubInformation.HubIsBusPowered = HubIsBusPowered;
721
722 Irp->IoStatus.Information = sizeof(USB_NODE_INFORMATION);
723
725
726 return Status;
727}
728
730NTAPI
732 IN PIRP Irp)
733{
734 PUSB_HUB_CAPABILITIES Capabilities;
735 PIO_STACK_LOCATION IoStack;
738 USB_HUB_CAPABILITIES HubCaps;
739
740 DPRINT("USBH_IoctlGetHubCapabilities ... \n");
741
742 Capabilities = Irp->AssociatedIrp.SystemBuffer;
743
744 HubCaps.HubIs2xCapable = (HubExtension->HubFlags & USBHUB_FDO_FLAG_USB20_HUB) ==
746
748
749 BufferLength = IoStack->Parameters.DeviceIoControl.OutputBufferLength;
750
751 if (BufferLength == 0)
752 {
753 Irp->IoStatus.Information = BufferLength;
756 }
757
758 if (BufferLength <= sizeof(HubCaps))
759 {
760 Length = IoStack->Parameters.DeviceIoControl.OutputBufferLength;
761 }
762 else
763 {
764 Length = sizeof(HubCaps);
765 }
766
769
770 Irp->IoStatus.Information = Length;
771
773
774 return STATUS_SUCCESS;
775}
776
778NTAPI
780 IN PIRP Irp)
781{
782 PUSB_NODE_CONNECTION_ATTRIBUTES Attributes;
783 ULONG ConnectionIndex;
784 ULONG NumPorts;
786 PUSBHUB_PORT_DATA PortData;
787 PIO_STACK_LOCATION IoStack;
789
790 DPRINT("USBH_IoctlGetNodeConnectionAttributes ... \n");
791
793 BufferLength = IoStack->Parameters.DeviceIoControl.OutputBufferLength;
794
795 if (BufferLength < sizeof(USB_NODE_CONNECTION_ATTRIBUTES))
796 {
798 goto Exit;
799 }
800
801 Attributes = Irp->AssociatedIrp.SystemBuffer;
802
803 ConnectionIndex = Attributes->ConnectionIndex;
805 Attributes->ConnectionIndex = ConnectionIndex;
806
808
809 NumPorts = HubExtension->HubDescriptor->bNumberOfPorts;
810
811 if (NumPorts == 0 ||
812 ConnectionIndex == 0 ||
813 ConnectionIndex > NumPorts)
814 {
815 goto Exit;
816 }
817
818 PortData = HubExtension->PortData + (ConnectionIndex - 1);
819
821 Attributes->PortAttributes = PortData->PortAttributes;
822
823 Irp->IoStatus.Information = sizeof(USB_NODE_CONNECTION_ATTRIBUTES);
825
826Exit:
827
829 return Status;
830}
831
833NTAPI
835 IN PIRP Irp,
836 IN BOOLEAN IsExt)
837{
838 PUSBHUB_PORT_DATA PortData;
840 PUSB_NODE_CONNECTION_INFORMATION_EX Info;
841 ULONG ConnectionIndex;
842 ULONG NumPorts;
845 PUSBHUB_PORT_PDO_EXTENSION PortExtension;
846 PIO_STACK_LOCATION IoStack;
847
848 DPRINT("USBH_IoctlGetNodeConnectionInformation ... \n");
849
851 BufferLength = IoStack->Parameters.DeviceIoControl.OutputBufferLength;
852
853 if (BufferLength < (ULONG)FIELD_OFFSET(USB_NODE_CONNECTION_INFORMATION_EX,
854 PipeList))
855 {
857 goto Exit;
858 }
859
860 Info = Irp->AssociatedIrp.SystemBuffer;
861
862 ConnectionIndex = Info->ConnectionIndex;
864 Info->ConnectionIndex = ConnectionIndex;
865
867
868 NumPorts = HubExtension->HubDescriptor->bNumberOfPorts;
869
870 if (NumPorts == 0 ||
871 ConnectionIndex == 0 ||
872 ConnectionIndex > NumPorts)
873 {
874 goto Exit;
875 }
876
877 PortData = HubExtension->PortData + (ConnectionIndex - 1);
878 DeviceObject = PortData->DeviceObject;
879
880 if (!DeviceObject)
881 {
882 Info->ConnectionStatus = PortData->ConnectionStatus;
883
884 Irp->IoStatus.Information = FIELD_OFFSET(USB_NODE_CONNECTION_INFORMATION_EX,
885 PipeList);
887 goto Exit;
888 }
889
890 PortExtension = DeviceObject->DeviceExtension;
891
892 Info->ConnectionStatus = PortData->ConnectionStatus;
893
894 Info->DeviceIsHub = (PortExtension->PortPdoFlags &
897
898 RtlCopyMemory(&Info->DeviceDescriptor,
899 &PortExtension->DeviceDescriptor,
900 sizeof(USB_DEVICE_DESCRIPTOR));
901
902 if (PortExtension->DeviceHandle)
903 {
904 Status = USBD_GetDeviceInformationEx(PortExtension,
905 HubExtension,
906 Info,
908 PortExtension->DeviceHandle);
909 }
910 else
911 {
913 }
914
915 if (NT_SUCCESS(Status))
916 {
917 if (!IsExt)
918 {
919 /* IOCTL_USB_GET_NODE_CONNECTION_INFORMATION request reports
920 only low and full speed connections. Info->Speed member
921 is Info->LowSpeed in the non-EX version of the structure */
922
923 Info->Speed = (Info->Speed == UsbLowSpeed);
924 }
925
926 Irp->IoStatus.Information = sizeof(USB_NODE_CONNECTION_INFORMATION_EX) +
927 (Info->NumberOfOpenPipes - 1) * sizeof(USB_PIPE_INFO);
928 goto Exit;
929 }
930
932 {
933 goto Exit;
934 }
935
936 Irp->IoStatus.Information = FIELD_OFFSET(USB_NODE_CONNECTION_INFORMATION_EX,
937 PipeList);
939
940Exit:
942 return Status;
943}
944
946NTAPI
948 IN PIRP Irp)
949{
950 PUSBHUB_PORT_DATA PortData;
951 PDEVICE_OBJECT PortDevice;
955 PIO_STACK_LOCATION IoStack;
958 PUSBHUB_PORT_PDO_EXTENSION PortExtension;
959
960 DPRINT("USBH_IoctlGetNodeConnectionDriverKeyName ... \n");
961
963 BufferLength = IoStack->Parameters.DeviceIoControl.OutputBufferLength;
964
966 HubExtension->HubDescriptor->bNumberOfPorts == 0)
967 {
969 goto Exit;
970 }
971
972 KeyName = Irp->AssociatedIrp.SystemBuffer;
974
975 PortData = &HubExtension->PortData[KeyName->ConnectionIndex - 1];
976 PortDevice = PortData->DeviceObject;
977
978 if (!PortDevice)
979 {
980 goto Exit;
981 }
982
983 PortExtension = PortDevice->DeviceExtension;
984
985 if (!(PortExtension->PortPdoFlags & USBHUB_PDO_FLAG_ENUMERATED))
986 {
988 goto Exit;
989 }
990
992
993 Status = IoGetDeviceProperty(PortDevice,
996 &KeyName->DriverKeyName,
997 &ResultLength);
998
1000 {
1002 }
1003
1005 KeyName->ActualLength = Length;
1006
1007 if (BufferLength < Length)
1008 {
1009 KeyName->DriverKeyName[0] = 0;
1010 Irp->IoStatus.Information = sizeof(USB_NODE_CONNECTION_DRIVERKEY_NAME);
1011 }
1012 else
1013 {
1014 Irp->IoStatus.Information = Length;
1015 }
1016
1017Exit:
1019 return Status;
1020}
1021
1023NTAPI
1025 IN PIRP Irp)
1026{
1028 PUSBHUB_PORT_DATA PortData;
1029 PUSB_DESCRIPTOR_REQUEST UsbRequest;
1030 PDEVICE_OBJECT PortDevice;
1031 PUSBHUB_PORT_PDO_EXTENSION PortExtension;
1032 struct _URB_CONTROL_TRANSFER * Urb;
1034 ULONG RequestBufferLength;
1035 PIO_STACK_LOCATION IoStack;
1036 ULONG NumPorts;
1037
1039 BufferLength = IoStack->Parameters.DeviceIoControl.OutputBufferLength;
1040
1041 DPRINT("USBH_IoctlGetDescriptor: BufferLength - %x\n", BufferLength);
1042
1044 {
1046 goto Exit;
1047 }
1048
1049 UsbRequest = Irp->AssociatedIrp.SystemBuffer;
1050 RequestBufferLength = UsbRequest->SetupPacket.wLength;
1051
1052 if (RequestBufferLength > BufferLength -
1054 {
1055 DPRINT("USBH_IoctlGetDescriptor: RequestBufferLength - %x\n",
1056 RequestBufferLength);
1057
1059 goto Exit;
1060 }
1061
1063
1064 NumPorts = HubExtension->HubDescriptor->bNumberOfPorts;
1065
1066 if (NumPorts == 0 ||
1067 UsbRequest->ConnectionIndex == 0 ||
1068 UsbRequest->ConnectionIndex > NumPorts)
1069 {
1070 goto Exit;
1071 }
1072
1073 PortData = HubExtension->PortData + (UsbRequest->ConnectionIndex - 1);
1074 PortDevice = PortData->DeviceObject;
1075
1076 if (!PortDevice)
1077 {
1078 goto Exit;
1079 }
1080
1081 PortExtension = PortDevice->DeviceExtension;
1082
1083 if (UsbRequest->SetupPacket.bmRequest == USB_CONFIGURATION_DESCRIPTOR_TYPE &&
1084 RequestBufferLength == sizeof(USB_CONFIGURATION_DESCRIPTOR))
1085 {
1087
1088 RtlCopyMemory(&UsbRequest->Data[0],
1089 &PortExtension->ConfigDescriptor,
1091
1092 Irp->IoStatus.Information = sizeof(USB_DESCRIPTOR_REQUEST) - sizeof(UCHAR) +
1094 goto Exit;
1095 }
1096
1098 sizeof(struct _URB_CONTROL_DESCRIPTOR_REQUEST),
1099 USB_HUB_TAG);
1100
1101 if (!Urb)
1102 {
1104 goto Exit;
1105 }
1106
1108
1110 Urb->Hdr.Length = sizeof(struct _URB_CONTROL_DESCRIPTOR_REQUEST);
1111
1112 Urb->TransferBuffer = &UsbRequest->Data[0];
1113 Urb->TransferBufferLength = RequestBufferLength;
1114 Urb->TransferBufferMDL = NULL;
1115 Urb->UrbLink = NULL;
1116
1118 &UsbRequest->SetupPacket,
1120
1121 Status = USBH_SyncSubmitUrb(PortExtension->Common.SelfDevice,
1122 (PURB)Urb);
1123
1124 Irp->IoStatus.Information = (sizeof(USB_DESCRIPTOR_REQUEST) - sizeof(UCHAR)) +
1126
1128
1129Exit:
1131 return Status;
1132}
1133
1135NTAPI
1137 IN PIRP Irp)
1138{
1140 PIO_STACK_LOCATION IoStack;
1142 BOOLEAN IsCheckHubIdle = FALSE;
1143
1144 DPRINT("USBH_DeviceControl: HubExtension - %p, Irp - %p\n",
1145 HubExtension,
1146 Irp);
1147
1149 ControlCode = IoStack->Parameters.DeviceIoControl.IoControlCode;
1150 DPRINT("USBH_DeviceControl: ControlCode - %lX\n", ControlCode);
1151
1152 if ((HubExtension->CurrentPowerState.DeviceState != PowerDeviceD0) &&
1153 (HubExtension->HubFlags & USBHUB_FDO_FLAG_DEVICE_STARTED))
1154 {
1155 IsCheckHubIdle = TRUE;
1156 USBH_HubSetD0(HubExtension);
1157 }
1158
1159 switch (ControlCode)
1160 {
1161 case IOCTL_USB_GET_HUB_CAPABILITIES:
1162 DPRINT("USBH_DeviceControl: IOCTL_USB_GET_HUB_CAPABILITIES\n");
1163 if (!(HubExtension->HubFlags & USBHUB_FDO_FLAG_DEVICE_STOPPED))
1164 {
1165 Status = USBH_IoctlGetHubCapabilities(HubExtension, Irp);
1166 break;
1167 }
1168
1170 break;
1171
1172 case IOCTL_USB_HUB_CYCLE_PORT:
1173 DPRINT1("USBH_DeviceControl: IOCTL_USB_HUB_CYCLE_PORT UNIMPLEMENTED. FIXME\n");
1174 DbgBreakPoint();
1175 break;
1176
1178 DPRINT("USBH_DeviceControl: IOCTL_USB_GET_NODE_INFORMATION\n");
1179 if (!(HubExtension->HubFlags & USBHUB_FDO_FLAG_DEVICE_STOPPED))
1180 {
1181 Status = USBH_IoctlGetNodeInformation(HubExtension, Irp);
1182 break;
1183 }
1184
1186 break;
1187
1189 DPRINT("USBH_DeviceControl: IOCTL_USB_GET_NODE_CONNECTION_INFORMATION\n");
1190 if (!(HubExtension->HubFlags & USBHUB_FDO_FLAG_DEVICE_STOPPED))
1191 {
1193 Irp,
1194 FALSE);
1195 break;
1196 }
1197
1199 break;
1200
1201 case IOCTL_USB_GET_NODE_CONNECTION_INFORMATION_EX:
1202 DPRINT("USBH_DeviceControl: IOCTL_USB_GET_NODE_CONNECTION_INFORMATION_EX\n");
1203 if (!(HubExtension->HubFlags & USBHUB_FDO_FLAG_DEVICE_STOPPED))
1204 {
1206 Irp,
1207 TRUE);
1208 break;
1209 }
1210
1212 break;
1213
1214 case IOCTL_USB_GET_NODE_CONNECTION_ATTRIBUTES:
1215 DPRINT("USBH_DeviceControl: IOCTL_USB_GET_NODE_CONNECTION_ATTRIBUTES\n");
1216 if (!(HubExtension->HubFlags & USBHUB_FDO_FLAG_DEVICE_STOPPED))
1217 {
1219 break;
1220 }
1221
1223 break;
1224
1226 DPRINT("USBH_DeviceControl: IOCTL_USB_GET_NODE_CONNECTION_NAME\n");
1227 if (!(HubExtension->HubFlags & USBHUB_FDO_FLAG_DEVICE_STOPPED))
1228 {
1229 Status = USBH_IoctlGetNodeName(HubExtension, Irp);
1230 break;
1231 }
1232
1234 break;
1235
1237 DPRINT("USBH_DeviceControl: IOCTL_USB_GET_NODE_CONNECTION_DRIVERKEY_NAME\n");
1238 if (!(HubExtension->HubFlags & USBHUB_FDO_FLAG_DEVICE_STOPPED))
1239 {
1241 break;
1242 }
1243
1245 break;
1246
1248 DPRINT("USBH_DeviceControl: IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION\n");
1249 if (!(HubExtension->HubFlags & USBHUB_FDO_FLAG_DEVICE_STOPPED))
1250 {
1251 Status = USBH_IoctlGetDescriptor(HubExtension, Irp);
1252 break;
1253 }
1254
1256 break;
1257
1258 case IOCTL_KS_PROPERTY:
1259 DPRINT("USBH_DeviceControl: IOCTL_KS_PROPERTY\n");
1262 break;
1263
1264 default:
1265 DPRINT1("USBH_DeviceControl: Unhandled IOCTL_ - %lX\n", ControlCode);
1266 Status = USBH_PassIrp(HubExtension->RootHubPdo, Irp);
1267 break;
1268 }
1269
1270 if (IsCheckHubIdle)
1271 {
1272 USBH_CheckHubIdle(HubExtension);
1273 }
1274
1275 return Status;
1276}
1277
1279NTAPI
1281 IN PIRP Irp)
1282{
1283 PUSBHUB_FDO_EXTENSION HubExtension;
1286 PIO_STACK_LOCATION IoStack;
1287 PULONG HubCount;
1288
1289 DPRINT_IOCTL("USBH_PdoInternalControl: PortExtension - %p, Irp - %p\n",
1290 PortExtension,
1291 Irp);
1292
1293 HubExtension = PortExtension->HubExtension;
1294
1295 if (PortExtension->PortPdoFlags & USBHUB_PDO_FLAG_NOT_CONNECTED)
1296 {
1298 goto Exit;
1299 }
1300
1301 if (PortExtension->CurrentPowerState.DeviceState != PowerDeviceD0)
1302 {
1304 goto Exit;
1305 }
1306
1308 ControlCode = IoStack->Parameters.DeviceIoControl.IoControlCode;
1309
1311 {
1312 HubExtension = PortExtension->RootHubExtension;
1313 DPRINT("USBH_PdoInternalControl: HubExtension - %p\n", HubExtension);
1314 }
1315
1316 if (!HubExtension)
1317 {
1319 goto Exit;
1320 }
1321
1322 switch (ControlCode)
1323 {
1325 return USBH_PdoIoctlSubmitUrb(PortExtension, Irp);
1326
1327 case IOCTL_INTERNAL_USB_SUBMIT_IDLE_NOTIFICATION:
1328 DPRINT1("USBH_PdoInternalControl: IOCTL_INTERNAL_USB_SUBMIT_IDLE_NOTIFICATION\n");
1329 return USBH_PortIdleNotificationRequest(PortExtension, Irp);
1330
1332 DPRINT("USBH_PdoInternalControl: IOCTL_INTERNAL_USB_GET_PORT_STATUS\n");
1333 return USBH_PdoIoctlGetPortStatus(PortExtension, Irp);
1334
1336 DPRINT1("USBH_PdoInternalControl: IOCTL_INTERNAL_USB_RESET_PORT\n");
1337 return USBH_PdoIoctlResetPort(PortExtension, Irp);
1338
1340 DPRINT1("USBH_PdoInternalControl: IOCTL_INTERNAL_USB_ENABLE_PORT\n");
1341 DbgBreakPoint();
1342 break;
1343
1345 DPRINT1("USBH_PdoInternalControl: IOCTL_INTERNAL_USB_CYCLE_PORT\n");
1346 DbgBreakPoint();
1347 break;
1348
1349 case IOCTL_INTERNAL_USB_GET_DEVICE_HANDLE:
1350 DPRINT("USBH_PdoInternalControl: IOCTL_INTERNAL_USB_GET_DEVICE_HANDLE\n");
1351 *(PVOID *)IoStack->Parameters.Others.Argument1 = PortExtension->DeviceHandle;
1353 break;
1354
1356 DPRINT("USBH_PdoInternalControl: IOCTL_INTERNAL_USB_GET_HUB_COUNT. PortPdoFlags - %lX\n",
1357 PortExtension->PortPdoFlags);
1358
1359 if (!(PortExtension->PortPdoFlags & USBHUB_PDO_FLAG_HUB_DEVICE))
1360 {
1362 break;
1363 }
1364
1365 HubCount = IoStack->Parameters.Others.Argument1;
1366
1367 ++*HubCount;
1368
1369 Status = USBH_SyncGetHubCount(HubExtension->LowerDevice,
1370 HubCount);
1371
1372 DPRINT("USBH_PdoInternalControl: *HubCount - %x\n", *HubCount);
1373 break;
1374
1376 DPRINT("USBH_PdoInternalControl: IOCTL_INTERNAL_USB_GET_ROOTHUB_PDO. PortPdoFlags - %lX\n",
1377 PortExtension->PortPdoFlags);
1378
1379 if (!(PortExtension->PortPdoFlags & USBHUB_PDO_FLAG_HUB_DEVICE))
1380 {
1381 DbgBreakPoint();
1383
1384 *(PVOID *)IoStack->Parameters.Others.Argument1 = NULL;
1385
1387 break;
1388 }
1389
1390 ASSERT(HubExtension->RootHubPdo);
1391 return USBH_PassIrp(HubExtension->RootHubPdo, Irp);
1392
1394 DPRINT1("USBH_PdoInternalControl: IOCTL_INTERNAL_USB_GET_HUB_NAME\n");
1395 DbgBreakPoint();
1396 break;
1397
1399 DPRINT1("USBH_PdoInternalControl: IOCTL_GET_HCD_DRIVERKEY_NAME\n");
1400 DbgBreakPoint();
1401 break;
1402
1404 DPRINT1("USBH_PdoInternalControl: IOCTL_INTERNAL_USB_GET_BUS_INFO\n");
1405 DbgBreakPoint();
1406 break;
1407
1409 DPRINT1("USBH_PdoInternalControl: IOCTL_INTERNAL_USB_GET_PARENT_HUB_INFO\n");
1410 DbgBreakPoint();
1411 break;
1412
1413 default:
1414 DPRINT1("USBH_PdoInternalControl: unhandled IOCTL_ - %lX\n", ControlCode);
1415 break;
1416 }
1417
1418Exit:
1420 return Status;
1421}
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
_In_ CDROM_SCAN_FOR_SPECIAL_INFO _In_ PCDROM_SCAN_FOR_SPECIAL_HANDLER Function
Definition: cdrom.h:1156
Definition: bufpool.h:45
_In_ PIRP Irp
Definition: csq.h:116
_Out_ PKIRQL Irql
Definition: csq.h:179
#define DPRINT_IOCTL(...)
Definition: dbg_uhub.h:107
#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:32
#define wcschr
Definition: compat.h:17
NTSTATUS NTAPI USBH_IoctlGetNodeName(IN PUSBHUB_FDO_EXTENSION HubExtension, IN PIRP Irp)
Definition: ioctl.c:563
NTSTATUS NTAPI USBH_PdoIoctlGetPortStatus(IN PUSBHUB_PORT_PDO_EXTENSION PortExtension, IN PIRP Irp)
Definition: ioctl.c:239
NTSTATUS NTAPI USBH_IoctlGetNodeConnectionInformation(IN PUSBHUB_FDO_EXTENSION HubExtension, IN PIRP Irp, IN BOOLEAN IsExt)
Definition: ioctl.c:834
NTSTATUS NTAPI USBH_IoctlGetNodeConnectionAttributes(IN PUSBHUB_FDO_EXTENSION HubExtension, IN PIRP Irp)
Definition: ioctl.c:779
NTSTATUS NTAPI USBH_DeviceControl(IN PUSBHUB_FDO_EXTENSION HubExtension, IN PIRP Irp)
Definition: ioctl.c:1136
NTSTATUS NTAPI USBH_IoctlGetHubCapabilities(IN PUSBHUB_FDO_EXTENSION HubExtension, IN PIRP Irp)
Definition: ioctl.c:731
NTSTATUS NTAPI USBH_PdoUrbFilter(IN PUSBHUB_PORT_PDO_EXTENSION PortExtension, IN PIRP Irp)
Definition: ioctl.c:87
NTSTATUS NTAPI USBH_PortIdleNotificationRequest(IN PUSBHUB_PORT_PDO_EXTENSION PortExtension, IN PIRP Irp)
Definition: ioctl.c:487
VOID NTAPI USBH_PortIdleNotificationCancelRoutine(IN PDEVICE_OBJECT Device, IN PIRP Irp)
Definition: ioctl.c:427
NTSTATUS NTAPI USBH_PdoIoctlSubmitUrb(IN PUSBHUB_PORT_PDO_EXTENSION PortExtension, IN PIRP Irp)
Definition: ioctl.c:210
NTSTATUS NTAPI USBH_IoctlGetDescriptor(IN PUSBHUB_FDO_EXTENSION HubExtension, IN PIRP Irp)
Definition: ioctl.c:1024
NTSTATUS NTAPI USBH_IoctlGetNodeConnectionDriverKeyName(IN PUSBHUB_FDO_EXTENSION HubExtension, IN PIRP Irp)
Definition: ioctl.c:947
NTSTATUS NTAPI USBH_PdoIoctlResetPort(IN PUSBHUB_PORT_PDO_EXTENSION PortExtension, IN PIRP Irp)
Definition: ioctl.c:379
NTSTATUS NTAPI USBH_SelectConfigOrInterfaceComplete(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Context)
Definition: ioctl.c:18
NTSTATUS NTAPI USBH_PdoInternalControl(IN PUSBHUB_PORT_PDO_EXTENSION PortExtension, IN PIRP Irp)
Definition: ioctl.c:1280
VOID NTAPI USBH_ResetPortWorker(IN PUSBHUB_FDO_EXTENSION HubExtension, IN PVOID Context)
Definition: ioctl.c:305
NTSTATUS NTAPI USBH_IoctlGetNodeInformation(IN PUSBHUB_FDO_EXTENSION HubExtension, IN PIRP Irp)
Definition: ioctl.c:684
NTSTATUS NTAPI USBH_HubSetD0(IN PUSBHUB_FDO_EXTENSION HubExtension)
Definition: power.c:77
VOID NTAPI USBH_IdleCancelPowerHubWorker(IN PUSBHUB_FDO_EXTENSION HubExtension, IN PVOID Context)
Definition: power.c:135
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
Definition: env_spec_w32.h:478
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
#define KeSetEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:476
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
#define NonPagedPool
Definition: env_spec_w32.h:307
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ ULONG _In_ FILE_INFORMATION_CLASS _Out_opt_ PULONG LengthReturned
Definition: fltkernel.h:1308
Status
Definition: gdiplustypes.h:25
CPPORT Port[4]
Definition: headless.c:35
_Must_inspect_result_ typedef _Out_ PHIDP_CAPS Capabilities
Definition: hidclass.h:103
#define USBD_MARK_DEVICE_BUSY
Definition: hubbusif.h:30
_Inout_ PUSB_DEVICE_HANDLE DeviceHandle
Definition: hubbusif.h:121
_Outptr_ PUSB_DEVICE_HANDLE _In_ PUSB_DEVICE_HANDLE _In_ USHORT PortStatus
Definition: hubbusif.h:42
NTSYSAPI void WINAPI DbgBreakPoint(void)
#define LOW_REALTIME_PRIORITY
IoMarkIrpPending(Irp)
IoSetCancelRoutine(Irp, CancelRoutine)
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
Definition: irp.cpp:490
#define IOCTL_KS_PROPERTY
Definition: ks.h:127
#define ASSERT(a)
Definition: mode.c:44
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
#define KernelMode
Definition: asm.h:34
#define UNICODE_NULL
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
#define IoCopyCurrentIrpStackLocationToNext(Irp)
Definition: ntifs_ex.h:413
#define IoCompleteRequest
Definition: irp.c:1240
#define IoCallDriver
Definition: irp.c:1225
VOID NTAPI IoReleaseCancelSpinLock(IN KIRQL Irql)
Definition: util.c:150
VOID NTAPI IoAcquireCancelSpinLock(OUT PKIRQL Irql)
Definition: util.c:56
@ PowerDeviceD0
Definition: ntpoapi.h:49
#define STATUS_DEVICE_POWERED_OFF
Definition: ntstatus.h:195
#define STATUS_DELETE_PENDING
Definition: ntstatus.h:322
#define STATUS_NO_CALLBACK_ACTIVE
Definition: ntstatus.h:726
#define STATUS_PENDING
Definition: ntstatus.h:82
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:423
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:239
#define L(x)
Definition: ntvdm.h:50
unsigned short USHORT
Definition: pedump.c:61
NTSTATUS NTAPI IoGetDeviceProperty(IN PDEVICE_OBJECT DeviceObject, IN DEVICE_REGISTRY_PROPERTY DeviceProperty, IN ULONG BufferLength, OUT PVOID PropertyBuffer, OUT PULONG ResultLength)
Definition: pnpmgr.c:1382
LONG NTAPI KeReleaseSemaphore(IN PKSEMAPHORE Semaphore, IN KPRIORITY Increment, IN LONG Adjustment, IN BOOLEAN Wait)
Definition: semphobj.c:54
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
#define DPRINT
Definition: sndvol32.h:71
static void Exit(void)
Definition: sock.c:1330
PDEVICE_OBJECT SelfDevice
Definition: usbhub.h:144
PVOID DeviceExtension
Definition: env_spec_w32.h:418
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3128
PMDL TransferBufferMDL
Definition: usb.h:472
struct _URB * UrbLink
Definition: usb.h:473
ULONG TransferBufferLength
Definition: usb.h:470
PVOID TransferBuffer
Definition: usb.h:471
struct _URB_HEADER Hdr
Definition: usb.h:467
UCHAR SetupPacket[8]
Definition: usb.h:475
Definition: usb.h:529
struct _URB_SELECT_CONFIGURATION UrbSelectConfiguration
Definition: usb.h:533
struct _URB_HEADER UrbHeader
Definition: usb.h:531
PUSBHUB_PORT_DATA PortData
Definition: usbhub.h:167
LONG PendingRequestCount
Definition: usbhub.h:180
POWER_STATE CurrentPowerState
Definition: usbhub.h:160
KSEMAPHORE HubSemaphore
Definition: usbhub.h:196
KEVENT PendingRequestEvent
Definition: usbhub.h:181
COMMON_DEVICE_EXTENSION Common
Definition: usbhub.h:148
PDEVICE_OBJECT LowerDevice
Definition: usbhub.h:150
PDEVICE_OBJECT RootHubPdo2
Definition: usbhub.h:152
PDEVICE_OBJECT RootHubPdo
Definition: usbhub.h:151
USB_CONNECTION_STATUS ConnectionStatus
Definition: usbhub.h:120
USB_PORT_STATUS_AND_CHANGE PortStatus
Definition: usbhub.h:118
ULONG PortAttributes
Definition: usbhub.h:121
PDEVICE_OBJECT DeviceObject
Definition: usbhub.h:119
USB_DEVICE_DESCRIPTOR DeviceDescriptor
Definition: usbhub.h:216
PUSB_DEVICE_HANDLE DeviceHandle
Definition: usbhub.h:211
PUSBHUB_FDO_EXTENSION HubExtension
Definition: usbhub.h:209
COMMON_DEVICE_EXTENSION Common
Definition: usbhub.h:204
UNICODE_STRING SymbolicLinkName
Definition: usbhub.h:207
USB_CONFIGURATION_DESCRIPTOR ConfigDescriptor
Definition: usbhub.h:218
KSPIN_LOCK PortTimeoutSpinLock
Definition: usbhub.h:226
PUSBHUB_PORT_PDO_EXTENSION PortExtension
Definition: usbhub.h:270
UCHAR Data[ANYSIZE_ARRAY]
Definition: usbioctl.h:337
struct _USB_DESCRIPTOR_REQUEST::@3270 SetupPacket
BOOLEAN HubIsBusPowered
Definition: usbioctl.h:225
USB_HUB_DESCRIPTOR HubDescriptor
Definition: usbioctl.h:224
WCHAR NodeName[ANYSIZE_ARRAY]
Definition: usbioctl.h:310
USB_HUB_NODE NodeType
Definition: usbioctl.h:233
USB_HUB_INFORMATION HubInformation
Definition: usbioctl.h:235
union _USB_NODE_INFORMATION::@3269 u
static VOID ErrorExit(LPTSTR lpszMessage)
Definition: telnetd.c:647
uint32_t * PULONG
Definition: typedefs.h:59
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#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
uint16_t * PWCHAR
Definition: typedefs.h:56
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
#define STATUS_DEVICE_NOT_CONNECTED
Definition: udferr_usr.h:160
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define STATUS_INVALID_DEVICE_STATE
Definition: udferr_usr.h:178
#define STATUS_DEVICE_BUSY
Definition: udferr_usr.h:129
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define STATUS_CANCELLED
Definition: udferr_usr.h:170
DEVICE_POWER_STATE DeviceState
Definition: ntpoapi.h:58
USHORT CurrentConnectStatus
Definition: usb200.h:133
USHORT PortEnabledDisabled
Definition: usb200.h:134
USB_PORT_STATUS PortStatus
Definition: usb200.h:240
USB_20_PORT_STATUS Usb20PortStatus
Definition: usb200.h:223
struct _USB_CONFIGURATION_DESCRIPTOR USB_CONFIGURATION_DESCRIPTOR
#define USB_CONFIGURATION_DESCRIPTOR_TYPE
Definition: usb100.h:50
@ UsbLowSpeed
Definition: usb200.h:42
#define URB_FUNCTION_SELECT_INTERFACE
Definition: usb.h:87
#define USBD_STATUS_NO_BANDWIDTH
Definition: usb.h:195
#define URB_FUNCTION_CONTROL_TRANSFER
Definition: usb.h:94
#define URB_FUNCTION_SELECT_CONFIGURATION
Definition: usb.h:86
#define USBD_STATUS_INVALID_PARAMETER
Definition: usb.h:192
#define URB_FROM_IRP(Irp)
Definition: usb.h:85
#define URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER
Definition: usb.h:95
LONG USBD_STATUS
Definition: usb.h:165
#define USBD_STATUS_INVALID_CONFIGURATION_DESCRIPTOR
Definition: usb.h:203
#define URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE
Definition: usb.h:97
#define URB_FUNCTION_ISOCH_TRANSFER
Definition: usb.h:96
_In_ PUCHAR BufferEnd
Definition: usbdlib.h:189
VOID NTAPI USBH_CheckHubIdle(IN PUSBHUB_FDO_EXTENSION HubExtension)
Definition: usbhub.c:3808
NTSTATUS NTAPI USBD_RemoveDeviceEx(IN PUSBHUB_FDO_EXTENSION HubExtension, IN PUSB_DEVICE_HANDLE DeviceHandle, IN ULONG Flags)
Definition: usbhub.c:2538
VOID NTAPI USBH_CompleteIrp(IN PIRP Irp, IN NTSTATUS CompleteStatus)
Definition: usbhub.c:63
VOID NTAPI USBH_CheckIdleDeferred(IN PUSBHUB_FDO_EXTENSION HubExtension)
Definition: usbhub.c:3957
NTSTATUS NTAPI USBH_AllocateWorkItem(PUSBHUB_FDO_EXTENSION HubExtension, PUSBHUB_IO_WORK_ITEM *OutHubIoWorkItem, PUSBHUB_WORKER_ROUTINE WorkerRoutine, SIZE_T BufferLength, PVOID *OutHubWorkItemBuffer, WORK_QUEUE_TYPE Type)
Definition: usbhub.c:2791
NTSTATUS NTAPI USBH_SyncSubmitUrb(IN PDEVICE_OBJECT DeviceObject, IN PURB Urb)
Definition: usbhub.c:250
VOID NTAPI USBH_QueueWorkItem(IN PUSBHUB_FDO_EXTENSION HubExtension, IN PUSBHUB_IO_WORK_ITEM HubIoWorkItem)
Definition: usbhub.c:2917
VOID NTAPI USBH_HubCancelIdleIrp(IN PUSBHUB_FDO_EXTENSION HubExtension, IN PIRP IdleIrp)
Definition: usbhub.c:3206
NTSTATUS NTAPI USBH_SyncGetPortStatus(IN PUSBHUB_FDO_EXTENSION HubExtension, IN USHORT Port, IN PUSB_PORT_STATUS_AND_CHANGE PortStatus, IN ULONG Length)
Definition: usbhub.c:1414
NTSTATUS NTAPI USBH_ResetDevice(IN PUSBHUB_FDO_EXTENSION HubExtension, IN USHORT Port, IN BOOLEAN IsKeepDeviceData, IN BOOLEAN IsWait)
Definition: usbhub.c:4615
NTSTATUS NTAPI USBH_SyncGetHubCount(IN PDEVICE_OBJECT DeviceObject, IN OUT PULONG OutHubCount)
Definition: usbhub.c:781
NTSTATUS NTAPI USBD_GetDeviceInformationEx(IN PUSBHUB_PORT_PDO_EXTENSION PortExtension, IN PUSBHUB_FDO_EXTENSION HubExtension, IN PUSB_NODE_CONNECTION_INFORMATION_EX Info, IN ULONG Length, IN PUSB_DEVICE_HANDLE DeviceHandle)
Definition: usbhub.c:2639
NTSTATUS NTAPI USBH_PassIrp(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: usbhub.c:79
BOOLEAN NTAPI USBH_HubIsBusPowered(IN PDEVICE_OBJECT DeviceObject, IN PUSB_CONFIGURATION_DESCRIPTOR HubConfigDescriptor)
Definition: usbhub.c:1589
#define USBHUB_FDO_FLAG_DEVICE_STARTED
Definition: usbhub.h:33
#define USBHUB_PDO_FLAG_DEVICE_STARTED
Definition: usbhub.h:70
#define USBHUB_FDO_FLAG_USB20_HUB
Definition: usbhub.h:47
#define USBHUB_PDO_FLAG_INSUFFICIENT_PWR
Definition: usbhub.h:77
#define USBHUB_PDO_FLAG_PORT_RESSETING
Definition: usbhub.h:79
#define USB_HUB_TAG
Definition: usbhub.h:26
#define USBHUB_PDO_FLAG_IDLE_NOTIFICATION
Definition: usbhub.h:80
#define USBHUB_PDO_FLAG_HUB_DEVICE
Definition: usbhub.h:61
#define USBHUB_PDO_FLAG_ALLOC_BNDW_FAILED
Definition: usbhub.h:78
#define USBHUB_PDO_FLAG_PORT_RESTORE_FAIL
Definition: usbhub.h:73
#define USBHUB_FDO_FLAG_WAIT_IDLE_REQUEST
Definition: usbhub.h:44
#define USBHUB_PDO_FLAG_ENUMERATED
Definition: usbhub.h:82
#define USBHUB_PDO_FLAG_NOT_CONNECTED
Definition: usbhub.h:67
#define USBHUB_PDO_FLAG_REG_DEV_INTERFACE
Definition: usbhub.h:72
#define USBHUB_FDO_FLAG_DEVICE_STOPPED
Definition: usbhub.h:37
#define USBHUB_PDO_FLAG_DELETE_PENDING
Definition: usbhub.h:68
#define IOCTL_INTERNAL_USB_SUBMIT_URB
Definition: usbioctl.h:32
#define IOCTL_INTERNAL_USB_GET_PARENT_HUB_INFO
Definition: usbioctl.h:68
struct _USB_NODE_CONNECTION_DRIVERKEY_NAME USB_NODE_CONNECTION_DRIVERKEY_NAME
#define IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION
Definition: usbioctl.h:175
struct _USB_DESCRIPTOR_REQUEST USB_DESCRIPTOR_REQUEST
#define IOCTL_USB_GET_NODE_CONNECTION_DRIVERKEY_NAME
Definition: usbioctl.h:187
struct _USB_NODE_INFORMATION USB_NODE_INFORMATION
#define IOCTL_INTERNAL_USB_RESET_PORT
Definition: usbioctl.h:35
#define IOCTL_USB_GET_NODE_CONNECTION_INFORMATION
Definition: usbioctl.h:172
#define IOCTL_GET_HCD_DRIVERKEY_NAME
Definition: usbioctl.h:165
#define IOCTL_INTERNAL_USB_CYCLE_PORT
Definition: usbioctl.h:53
#define IOCTL_USB_GET_NODE_INFORMATION
Definition: usbioctl.h:169
#define IOCTL_USB_GET_NODE_CONNECTION_NAME
Definition: usbioctl.h:178
struct _USB_PIPE_INFO USB_PIPE_INFO
struct _USB_NODE_CONNECTION_NAME USB_NODE_CONNECTION_NAME
#define IOCTL_INTERNAL_USB_GET_HUB_COUNT
Definition: usbioctl.h:50
#define IOCTL_INTERNAL_USB_ENABLE_PORT
Definition: usbioctl.h:47
#define IOCTL_INTERNAL_USB_GET_BUS_INFO
Definition: usbioctl.h:59
@ DeviceConnected
Definition: usbioctl.h:279
#define IOCTL_INTERNAL_USB_GET_ROOTHUB_PDO
Definition: usbioctl.h:38
#define IOCTL_INTERNAL_USB_GET_HUB_NAME
Definition: usbioctl.h:56
#define USBD_PORT_ENABLED
Definition: usbioctl.h:41
@ UsbHub
Definition: usbioctl.h:219
#define USBD_PORT_CONNECTED
Definition: usbioctl.h:42
#define IOCTL_INTERNAL_USB_GET_PORT_STATUS
Definition: usbioctl.h:44
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:690
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
_Must_inspect_result_ _In_ WDFDMAENABLER _In_ _In_opt_ PWDF_OBJECT_ATTRIBUTES Attributes
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG _Out_ PULONG ResultLength
Definition: wdfdevice.h:3776
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2699
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
Definition: wdfdevice.h:3771
_In_ WDFREQUEST _In_ NTSTATUS _In_ ULONG_PTR Information
Definition: wdfrequest.h:1049
_Must_inspect_result_ _In_ WDFUSBDEVICE _Out_writes_bytes_to_opt_ ConfigDescriptorLength PVOID ConfigDescriptor
Definition: wdfusb.h:1036
_IRQL_requires_same_ typedef _In_ ULONG ControlCode
Definition: wmitypes.h:55
@ DelayedWorkQueue
Definition: extypes.h:190
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2793
#define EVENT_INCREMENT
Definition: iotypes.h:597
#define IO_NO_INCREMENT
Definition: iotypes.h:598
@ DevicePropertyDriverKeyName
Definition: iotypes.h:1202
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:778
@ Executive
Definition: ketypes.h:415
unsigned char UCHAR
Definition: xmlstorage.h:181
__wchar_t WCHAR
Definition: xmlstorage.h:180