ReactOS 0.4.16-dev-109-gf4cb10f
iface.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 interface 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
13VOID
16{
17 DPRINT("USBI_InterfaceReference\n");
18}
19
20VOID
23{
24 DPRINT("USBI_InterfaceDereference\n");
25}
26
27/* USB port driver Interface functions */
28
32 IN OUT PUSB_DEVICE_HANDLE *UsbdDeviceHandle,
33 IN PUSB_DEVICE_HANDLE UsbdHubDeviceHandle,
36{
37 PDEVICE_OBJECT PdoDevice;
39 PUSB_DEVICE_HANDLE deviceHandle = NULL;
41
42 DPRINT("USBHI_CreateUsbDevice: ...\n");
43
44 PdoDevice = BusContext;
45 PdoExtension = PdoDevice->DeviceExtension;
46
47 Status = USBPORT_CreateDevice(&deviceHandle,
48 PdoExtension->FdoDevice,
49 (PUSBPORT_DEVICE_HANDLE)UsbdHubDeviceHandle,
52
53 *UsbdDeviceHandle = deviceHandle;
54
55 return Status;
56}
57
61 OUT PUSB_DEVICE_HANDLE UsbdDeviceHandle)
62{
63 PDEVICE_OBJECT PdoDevice;
65
66 DPRINT("USBHI_InitializeUsbDevice\n");
67
68 PdoDevice = BusContext;
69 PdoExtension = PdoDevice->DeviceExtension;
70
71 return USBPORT_InitializeDevice((PUSBPORT_DEVICE_HANDLE)UsbdDeviceHandle,
72 PdoExtension->FdoDevice);
73}
74
78 IN PUSB_DEVICE_HANDLE UsbdDeviceHandle,
79 IN PUCHAR DeviceDescBuffer,
80 IN PULONG DeviceDescBufferLen,
81 IN PUCHAR ConfigDescBuffer,
82 IN PULONG ConfigDescBufferLen)
83{
84 PDEVICE_OBJECT PdoDevice;
87
89
90 DPRINT("USBHI_GetUsbDescriptors ...\n");
91
92 PdoDevice = BusContext;
93 PdoExtension = PdoDevice->DeviceExtension;
94 DeviceHandle = (PUSBPORT_DEVICE_HANDLE)UsbdDeviceHandle;
95
96 if (DeviceDescBuffer && *DeviceDescBufferLen)
97 {
98 if (*DeviceDescBufferLen > sizeof(USB_DEVICE_DESCRIPTOR))
99 *DeviceDescBufferLen = sizeof(USB_DEVICE_DESCRIPTOR);
100
101 RtlCopyMemory(DeviceDescBuffer,
102 &DeviceHandle->DeviceDescriptor,
103 *DeviceDescBufferLen);
104 }
105
107 PdoExtension->FdoDevice,
109 ConfigDescBuffer,
110 ConfigDescBufferLen);
111
113
114 return Status;
115}
116
120 IN OUT PUSB_DEVICE_HANDLE UsbdDeviceHandle,
121 IN ULONG Flags)
122{
123 PDEVICE_OBJECT PdoDevice;
125
126 DPRINT("USBHI_RemoveUsbDevice: UsbdDeviceHandle - %p, Flags - %x\n",
127 UsbdDeviceHandle,
128 Flags);
129
130 PdoDevice = BusContext;
131 PdoExtension = PdoDevice->DeviceExtension;
132
133 return USBPORT_RemoveDevice(PdoExtension->FdoDevice,
134 (PUSBPORT_DEVICE_HANDLE)UsbdDeviceHandle,
135 Flags);
136}
137
141 OUT PUSB_DEVICE_HANDLE OldUsbdDeviceHandle,
142 OUT PUSB_DEVICE_HANDLE NewUsbdDeviceHandle)
143{
144 PDEVICE_OBJECT PdoDevice;
146
147 DPRINT("USBHI_RestoreUsbDevice: OldUsbdDeviceHandle - %p, NewUsbdDeviceHandle - %x\n",
148 OldUsbdDeviceHandle,
149 NewUsbdDeviceHandle);
150
151 PdoDevice = BusContext;
152 PdoExtension = PdoDevice->DeviceExtension;
153
154 return USBPORT_RestoreDevice(PdoExtension->FdoDevice,
155 (PUSBPORT_DEVICE_HANDLE)OldUsbdDeviceHandle,
156 (PUSBPORT_DEVICE_HANDLE)NewUsbdDeviceHandle);
157}
158
162 IN PUSB_DEVICE_HANDLE UsbdDeviceHandle,
163 OUT PVOID DeviceInfoBuffer,
164 IN ULONG DeviceInfoBufferLen,
165 OUT PULONG LenDataReturned)
166{
169 PLIST_ENTRY InterfaceEntry;
171 ULONG NumberOfOpenPipes = 0;
174 PUSBPORT_INTERFACE_HANDLE InterfaceHandle;
175 ULONG ActualLength;
176 ULONG ix;
177
178 DPRINT("USBHI_QueryDeviceInformation: ...\n");
179
180 *LenDataReturned = 0;
181
182 if (DeviceInfoBufferLen < sizeof(USB_LEVEL_INFORMATION))
183 {
185 }
186
187 DeviceInfo = DeviceInfoBuffer;
188
189 if (DeviceInfo->InformationLevel > 0)
190 {
192 }
193
194 DeviceHandle = UsbdDeviceHandle;
195 ConfigHandle = DeviceHandle->ConfigHandle;
196
197 if (ConfigHandle)
198 {
199 InterfaceEntry = ConfigHandle->InterfaceHandleList.Flink;
200
201 while (InterfaceEntry &&
202 InterfaceEntry != &ConfigHandle->InterfaceHandleList)
203 {
204 InterfaceHandle = CONTAINING_RECORD(InterfaceEntry,
206 InterfaceLink);
207
208 NumberOfOpenPipes += InterfaceHandle->InterfaceDescriptor.bNumEndpoints;
209
210 InterfaceEntry = InterfaceEntry->Flink;
211 }
212 }
213
214 ActualLength = FIELD_OFFSET(USB_DEVICE_INFORMATION_0, PipeList) +
215 NumberOfOpenPipes * sizeof(USB_PIPE_INFORMATION_0);
216
217 if (DeviceInfoBufferLen < ActualLength)
218 {
219 DeviceInfo->ActualLength = ActualLength;
220 *LenDataReturned = sizeof(USB_LEVEL_INFORMATION);
221
223 }
224
225 RtlZeroMemory(DeviceInfo, ActualLength);
226
227 DeviceInfo->InformationLevel = 0;
228 DeviceInfo->ActualLength = ActualLength;
229 DeviceInfo->DeviceAddress = DeviceHandle->DeviceAddress;
230 DeviceInfo->NumberOfOpenPipes = NumberOfOpenPipes;
231 DeviceInfo->DeviceSpeed = DeviceHandle->DeviceSpeed;
232
233 RtlCopyMemory(&DeviceInfo->DeviceDescriptor,
234 &DeviceHandle->DeviceDescriptor,
235 sizeof(USB_DEVICE_DESCRIPTOR));
236
238
239 if (DeviceHandle->DeviceSpeed == UsbFullSpeed ||
240 DeviceHandle->DeviceSpeed == UsbLowSpeed)
241 {
242 DeviceInfo->DeviceType = Usb11Device;
243 }
244 else if (DeviceHandle->DeviceSpeed == UsbHighSpeed)
245 {
246 DeviceInfo->DeviceType = Usb20Device;
247 }
248
249 DeviceInfo->CurrentConfigurationValue = 0;
250
251 if (!ConfigHandle)
252 {
253 *LenDataReturned = ActualLength;
254 return STATUS_SUCCESS;
255 }
256
257 DeviceInfo->CurrentConfigurationValue =
259
260 InterfaceEntry = ConfigHandle->InterfaceHandleList.Flink;
261
262 while (InterfaceEntry &&
263 InterfaceEntry != &ConfigHandle->InterfaceHandleList)
264 {
265 InterfaceHandle = CONTAINING_RECORD(InterfaceEntry,
267 InterfaceLink);
268
269 if (InterfaceHandle->InterfaceDescriptor.bNumEndpoints > 0)
270 {
271 PipeInfo = &DeviceInfo->PipeList[0];
272 PipeHandle = &InterfaceHandle->PipeHandle[0];
273
274 for (ix = 0;
275 ix < InterfaceHandle->InterfaceDescriptor.bNumEndpoints;
276 ix++)
277 {
279 {
280 PipeInfo->ScheduleOffset = 1;
281 }
282 else
283 {
284 PipeInfo->ScheduleOffset =
285 PipeHandle->Endpoint->EndpointProperties.ScheduleOffset;
286 }
287
288 RtlCopyMemory(&PipeInfo->EndpointDescriptor,
289 &PipeHandle->EndpointDescriptor,
291
292 PipeInfo += 1;
293 PipeHandle += 1;
294 }
295 }
296
297 InterfaceEntry = InterfaceEntry->Flink;
298 }
299
300 *LenDataReturned = ActualLength;
301
302 return STATUS_SUCCESS;
303}
304
308 OUT PVOID ControllerInfoBuffer,
309 IN ULONG ControllerInfoBufferLen,
310 OUT PULONG LenDataReturned)
311{
312 PDEVICE_OBJECT PdoDevice;
314 PDEVICE_OBJECT FdoDevice;
318
319 DPRINT("USBHI_GetControllerInformation: ControllerInfoBufferLen - %x\n",
320 ControllerInfoBufferLen);
321
322 PdoDevice = BusContext;
323 PdoExtension = PdoDevice->DeviceExtension;
324 FdoDevice = PdoExtension->FdoDevice;
325 FdoExtension = FdoDevice->DeviceExtension;
326
327 InfoBuffer = ControllerInfoBuffer;
328
329 *LenDataReturned = 0;
330
331 if (ControllerInfoBufferLen < sizeof(USB_LEVEL_INFORMATION))
332 {
334 return Status;
335 }
336
337 *LenDataReturned = sizeof(USB_LEVEL_INFORMATION);
338
339 if (InfoBuffer->InformationLevel > 0)
340 {
342 return Status;
343 }
344
345 InfoBuffer->ActualLength = sizeof(USB_CONTROLLER_INFORMATION_0);
346
347 if (ControllerInfoBufferLen >= sizeof(USB_CONTROLLER_INFORMATION_0))
348 {
349 InfoBuffer->SelectiveSuspendEnabled =
352 }
353
354 *LenDataReturned = sizeof(USB_CONTROLLER_INFORMATION_0);
355
356 return STATUS_SUCCESS;
357}
358
363{
364 PDEVICE_OBJECT PdoDevice;
366 PDEVICE_OBJECT FdoDevice;
368 ULONG Flags;
369 ULONG HcDisable;
371
372 DPRINT("USBHI_ControllerSelectiveSuspend: Enable - %x\n", Enable);
373
374 PdoDevice = BusContext;
375 PdoExtension = PdoDevice->DeviceExtension;
376 FdoDevice = PdoExtension->FdoDevice;
377 FdoExtension = FdoDevice->DeviceExtension;
378
379 Flags = FdoExtension->Flags;
380
382 {
383 return STATUS_SUCCESS;
384 }
385
386 if (Enable)
387 {
389 HcDisable = 0;
390 }
391 else
392 {
393 FdoExtension->Flags &= ~USBPORT_FLAG_SELECTIVE_SUSPEND;
394 HcDisable = 1;
395 }
396
397 Status = USBPORT_SetRegistryKeyValue(FdoExtension->CommonExtension.LowerPdoDevice,
398 TRUE,
399 REG_DWORD,
400 L"HcDisableSelectiveSuspend",
401 &HcDisable,
402 sizeof(HcDisable));
403
404 if (NT_SUCCESS(Status))
405 {
406 if (Enable)
408 else
409 FdoExtension->Flags &= ~USBPORT_FLAG_SELECTIVE_SUSPEND;
410 }
411
412 return Status;
413}
414
419 IN OUT PVOID HubInformationBuffer,
420 IN ULONG HubInfoLen,
421 IN OUT PULONG LenDataReturned)
422{
423 PDEVICE_OBJECT PdoDevice;
425 PDEVICE_OBJECT FdoDevice;
428 ULONG NumPorts;
429 ULONG ix;
430 PUSB_EXTHUB_INFORMATION_0 HubInfoBuffer;
432 ULONG PortAttrX;
433
434 DPRINT("USBHI_GetExtendedHubInformation: ...\n");
435
436 PdoDevice = BusContext;
437 PdoExtension = PdoDevice->DeviceExtension;
438 FdoDevice = PdoExtension->FdoDevice;
439 FdoExtension = FdoDevice->DeviceExtension;
440 Packet = &FdoExtension->MiniPortInterface->Packet;
441
442 HubInfoBuffer = HubInformationBuffer;
443 PortStatus.AsUlong32 = 0;
444
445 if (HubPhysicalDeviceObject != PdoDevice)
446 {
447 *LenDataReturned = 0;
449 }
450
451 if (HubInfoLen < sizeof(USB_EXTHUB_INFORMATION_0))
452 {
453 *LenDataReturned = 0;
455 }
456
457 NumPorts = PdoExtension->RootHubDescriptors->Descriptor.bNumberOfPorts;
458 HubInfoBuffer->NumberOfPorts = NumPorts;
459
460 if (NumPorts == 0)
461 {
462 *LenDataReturned = sizeof(USB_EXTHUB_INFORMATION_0);
463 return STATUS_SUCCESS;
464 }
465
466 for (ix = 0; ix < HubInfoBuffer->NumberOfPorts; ++ix)
467 {
468 HubInfoBuffer->Port[ix].PhysicalPortNumber = ix + 1;
469 HubInfoBuffer->Port[ix].PortLabelNumber = ix;
470 HubInfoBuffer->Port[ix].VidOverride = 0;
471 HubInfoBuffer->Port[ix].PidOverride = 0;
472 HubInfoBuffer->Port[ix].PortAttributes = 0;
473
474 if (Packet->MiniPortFlags & USB_MINIPORT_FLAGS_USB2)
475 {
476 HubInfoBuffer->Port[ix].PortAttributes = USB_PORTATTR_SHARED_USB2;
477
478 Packet->RH_GetPortStatus(FdoExtension->MiniPortExt,
479 ix + 1,
480 &PortStatus);
481
482 if (PortStatus.PortStatus.Usb20PortStatus.AsUshort16 & 0x8000)
483 {
484 HubInfoBuffer->Port[ix].PortAttributes |= USB_PORTATTR_OWNED_BY_CC;
485 }
486 }
487 else
488 {
490 {
491 continue;
492 }
493
494 if (USBPORT_FindUSB2Controller(FdoDevice))
495 {
497 }
498 }
499 }
500
501 for (ix = 0; ix < HubInfoBuffer->NumberOfPorts; ++ix)
502 {
503 PortAttrX = 0;
504
506 FdoExtension->CommonExtension.LowerPdoDevice,
507 FALSE,
508 L"PortAttrX",
509 sizeof(L"PortAttrX"),
510 &PortAttrX,
511 sizeof(PortAttrX));
512
513 HubInfoBuffer->Port[ix].PortAttributes |= PortAttrX;
514 }
515
516 *LenDataReturned = sizeof(USB_EXTHUB_INFORMATION_0);
517
518 return STATUS_SUCCESS;
519}
520
524 IN OUT PVOID HubInfoBuffer,
525 IN ULONG HubInfoBufferLen,
526 OUT PULONG HubNameActualLen)
527{
528 PDEVICE_OBJECT PdoDevice;
529 UNICODE_STRING HubName;
530 PUNICODE_STRING InfoBuffer;
532
533 DPRINT("USBHI_GetRootHubSymbolicName: ...\n");
534
535 PdoDevice = BusContext;
536
537 Status = USBPORT_GetSymbolicName(PdoDevice, &HubName);
538
539 if (HubInfoBufferLen < HubName.Length)
540 {
541 InfoBuffer = HubInfoBuffer;
542 InfoBuffer->Length = 0;
543 }
544 else
545 {
546 RtlCopyMemory(HubInfoBuffer, HubName.Buffer, HubName.Length);
547 }
548
549 *HubNameActualLen = HubName.Length;
550
551 if (NT_SUCCESS(Status))
552 RtlFreeUnicodeString(&HubName);
553
554 return Status;
555}
556
557PVOID
561{
562 DPRINT1("USBHI_GetDeviceBusContext: UNIMPLEMENTED. FIXME.\n");
563 return NULL;
564}
565
569 IN PUSB_DEVICE_HANDLE UsbdHubDeviceHandle,
571{
572 PDEVICE_OBJECT PdoDevice;
574
575 DPRINT("USBHI_Initialize20Hub: UsbdHubDeviceHandle - %p, TtCount - %x\n",
576 UsbdHubDeviceHandle,
577 TtCount);
578
579 PdoDevice = BusContext;
580 PdoExtension = PdoDevice->DeviceExtension;
581
582 return USBPORT_Initialize20Hub(PdoExtension->FdoDevice,
583 (PUSBPORT_DEVICE_HANDLE)UsbdHubDeviceHandle,
584 TtCount);
585}
586
592{
593 PDEVICE_OBJECT PdoDevice;
595 PDEVICE_OBJECT FdoDevice;
598
599 DPRINT("USBHI_RootHubInitNotification\n");
600
601 PdoDevice = BusContext;
602 PdoExtension = PdoDevice->DeviceExtension;
603 FdoDevice = PdoExtension->FdoDevice;
604 FdoExtension = FdoDevice->DeviceExtension;
605
606 KeAcquireSpinLock(&FdoExtension->RootHubCallbackSpinLock, &OldIrql);
607 PdoExtension->RootHubInitContext = CallbackContext;
608 PdoExtension->RootHubInitCallback = CallbackFunction;
609 KeReleaseSpinLock(&FdoExtension->RootHubCallbackSpinLock, OldIrql);
610
611 return STATUS_SUCCESS;
612}
613
614VOID
617 OUT PUSB_DEVICE_HANDLE UsbdDeviceHandle)
618{
619 PDEVICE_OBJECT PdoDevice;
621
622 DPRINT("USBHI_FlushTransfers: ...\n");
623
624 PdoDevice = BusContext;
625 PdoExtension = PdoDevice->DeviceExtension;
626
628}
629
630VOID
635{
636 DPRINT1("USBHI_SetDeviceHandleData: UNIMPLEMENTED. FIXME.\n");
637}
638
639/* USB bus driver Interface functions */
640
641VOID
645 OUT PULONG HcdCapabilities)
646{
647 DPRINT1("USBDI_GetUSBDIVersion: UNIMPLEMENTED. FIXME.\n");
648}
649
653 OUT PULONG CurrentFrame)
654{
655 DPRINT1("USBDI_QueryBusTime: UNIMPLEMENTED. FIXME.\n");
656 return STATUS_SUCCESS;
657}
658
662 IN PURB Urb)
663{
664 DPRINT1("USBDI_SubmitIsoOutUrb: UNIMPLEMENTED. FIXME.\n");
665 return STATUS_SUCCESS;
666}
667
671 IN ULONG Level,
672 OUT PVOID BusInfoBuffer,
673 OUT PULONG BusInfoBufferLen,
674 OUT PULONG BusInfoActualLen)
675{
676 PDEVICE_OBJECT PdoDevice;
678 PDEVICE_OBJECT FdoDevice;
682
683 DPRINT("USBDI_QueryBusInformation: Level - %p\n", Level);
684
685 if ((Level != 0) && (Level != 1))
686 {
687 DPRINT1("USBDI_QueryBusInformation: Level should be 0 or 1\n");
689 }
690
691 PdoDevice = BusContext;
692 PdoExtension = PdoDevice->DeviceExtension;
693 FdoDevice = PdoExtension->FdoDevice;
694 FdoExtension = FdoDevice->DeviceExtension;
695
696 if (Level == 0)
697 {
698 if (BusInfoActualLen)
699 *BusInfoActualLen = sizeof(USB_BUS_INFORMATION_LEVEL_0);
700
701 if (*BusInfoBufferLen < sizeof(USB_BUS_INFORMATION_LEVEL_0))
702 {
704 }
705
706 *BusInfoBufferLen = sizeof(USB_BUS_INFORMATION_LEVEL_0);
707
708 //Buffer0 = BusInfoBuffer;
709 DPRINT1("USBDI_QueryBusInformation: LEVEL_0 UNIMPLEMENTED. FIXME\n");
710 //Buffer0->TotalBandwidth = USBPORT_GetTotalBandwidth();
711 //Buffer0->ConsumedBandwidth = USBPORT_GetAllocatedBandwidth();
712
713 return STATUS_SUCCESS;
714 }
715
716 if (Level == 1)
717 {
719 FdoExtension->CommonExtension.SymbolicLinkName.Length;
720
721 if (BusInfoActualLen)
722 *BusInfoActualLen = Length;
723
724 if (*BusInfoBufferLen < Length)
725 {
727 }
728
729 *BusInfoBufferLen = Length;
730
731 Buffer1 = BusInfoBuffer;
732 DPRINT1("USBDI_QueryBusInformation: LEVEL_1 UNIMPLEMENTED. FIXME\n");
733 //Buffer1->TotalBandwidth = USBPORT_GetTotalBandwidth();
734 //Buffer1->ConsumedBandwidth = USBPORT_GetAllocatedBandwidth();
735 Buffer1->ControllerNameLength = FdoExtension->CommonExtension.SymbolicLinkName.Length;
736
738 FdoExtension->CommonExtension.SymbolicLinkName.Buffer,
739 FdoExtension->CommonExtension.SymbolicLinkName.Length);
740
741 return STATUS_SUCCESS;
742 }
743
744 return STATUS_SUCCESS;
745}
746
750{
751 PDEVICE_OBJECT PdoDevice;
753 PDEVICE_OBJECT FdoDevice;
756
757 DPRINT("USBDI_IsDeviceHighSpeed: ...\n");
758
759 PdoDevice = BusContext;
760 PdoExtension = PdoDevice->DeviceExtension;
761 FdoDevice = PdoExtension->FdoDevice;
762 FdoExtension = FdoDevice->DeviceExtension;
763 Packet = &FdoExtension->MiniPortInterface->Packet;
764
765 return (Packet->MiniPortFlags & USB_MINIPORT_FLAGS_USB2) != 0;
766}
767
771 IN ULONG DriverTag,
772 IN ULONG EnumTag,
773 IN ULONG P1,
774 IN ULONG P2)
775{
776 DPRINT1("USBDI_EnumLogEntry: UNIMPLEMENTED. FIXME.\n");
777 return STATUS_SUCCESS;
778}
779
781NTAPI
783 IN PDEVICE_OBJECT PdoDevice,
784 IN PIRP Irp)
785{
787 PUSB_BUS_INTERFACE_HUB_V5 InterfaceHub;
788 PUSB_BUS_INTERFACE_USBDI_V2 InterfaceDI;
789 UNICODE_STRING GuidBuffer;
791
792 DPRINT("USBPORT_PdoQueryInterface: ...\n");
793
794 if (IsEqualGUIDAligned(IoStack->Parameters.QueryInterface.InterfaceType,
795 &USB_BUS_INTERFACE_HUB_GUID))
796 {
797 /* Get request parameters */
798 InterfaceHub = (PUSB_BUS_INTERFACE_HUB_V5)IoStack->Parameters.QueryInterface.Interface;
799 InterfaceHub->Version = IoStack->Parameters.QueryInterface.Version;
800
801 /* Check version */
802 if (IoStack->Parameters.QueryInterface.Version >= 6)
803 {
804 DPRINT1("USB_BUS_INTERFACE_HUB_GUID version %x not supported!\n",
805 IoStack->Parameters.QueryInterface.Version);
806
807 return Irp->IoStatus.Status; // Version not supported
808 }
809
810 /* Interface version 0 */
811 InterfaceHub->Size = IoStack->Parameters.QueryInterface.Size;
812 InterfaceHub->BusContext = PdoDevice;
813
816
817 /* Interface version 1 */
818 if (IoStack->Parameters.QueryInterface.Version >= 1)
819 {
826 }
827
828 /* Interface version 2 */
829 if (IoStack->Parameters.QueryInterface.Version >= 2)
830 {
837 }
838
839 /* Interface version 3 */
840 if (IoStack->Parameters.QueryInterface.Version >= 3)
842
843 /* Interface version 4 */
844 if (IoStack->Parameters.QueryInterface.Version >= 4)
845 InterfaceHub->FlushTransfers = USBHI_FlushTransfers;
846
847 /* Interface version 5 */
848 if (IoStack->Parameters.QueryInterface.Version >= 5)
850
851 /* Request completed */
852 return STATUS_SUCCESS;
853 }
854 else if (IsEqualGUIDAligned(IoStack->Parameters.QueryInterface.InterfaceType,
855 &USB_BUS_INTERFACE_USBDI_GUID))
856 {
857 /* Get request parameters */
858 InterfaceDI = (PUSB_BUS_INTERFACE_USBDI_V2)IoStack->Parameters.QueryInterface.Interface;
859 InterfaceDI->Version = IoStack->Parameters.QueryInterface.Version;
860
861 /* Check version */
862 if (IoStack->Parameters.QueryInterface.Version >= 3)
863 {
864 DPRINT1("USB_BUS_INTERFACE_USBDI_GUID version %x not supported!\n",
865 IoStack->Parameters.QueryInterface.Version);
866
867 return Irp->IoStatus.Status; // Version not supported
868 }
869
870 /* Interface version 0 */
871 InterfaceDI->Size = IoStack->Parameters.QueryInterface.Size;
872 InterfaceDI->BusContext = PdoDevice;
876 InterfaceDI->QueryBusTime = USBDI_QueryBusTime;
879
880 /* Interface version 1 */
881 if (IoStack->Parameters.QueryInterface.Version >= 1)
883
884 /* Interface version 2 */
885 if (IoStack->Parameters.QueryInterface.Version >= 2)
886 InterfaceDI->EnumLogEntry = USBDI_EnumLogEntry;
887
888 return STATUS_SUCCESS;
889 }
890 else
891 {
892 /* Convert GUID to string */
893 Status = RtlStringFromGUID(IoStack->Parameters.QueryInterface.InterfaceType,
894 &GuidBuffer);
895
896 if (NT_SUCCESS(Status))
897 {
898 /* Print interface */
899 DPRINT1("HandleQueryInterface UNKNOWN INTERFACE GUID: %wZ Version %x\n",
900 &GuidBuffer,
901 IoStack->Parameters.QueryInterface.Version);
902
903 RtlFreeUnicodeString(&GuidBuffer); // Free GUID buffer
904 }
905 }
906
907 return Irp->IoStatus.Status;
908}
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
OSVERSIONINFOW VersionInfo
Definition: wkssvc.c:40
_In_ PIRP Irp
Definition: csq.h:116
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
@ PdoExtension
Definition: precomp.h:49
@ FdoExtension
Definition: precomp.h:48
VOID NTAPI USBPORT_DumpingDeviceDescriptor(IN PUSB_DEVICE_DESCRIPTOR DeviceDescriptor)
Definition: debug.c:79
NTSTATUS NTAPI USBPORT_RemoveDevice(IN PDEVICE_OBJECT FdoDevice, IN OUT PUSBPORT_DEVICE_HANDLE DeviceHandle, IN ULONG Flags)
Definition: device.c:1584
NTSTATUS NTAPI USBPORT_GetUsbDescriptor(IN PUSBPORT_DEVICE_HANDLE DeviceHandle, IN PDEVICE_OBJECT FdoDevice, IN UCHAR Type, IN PUCHAR ConfigDesc, IN PULONG ConfigDescSize)
Definition: device.c:1425
NTSTATUS NTAPI USBPORT_CreateDevice(IN OUT PUSB_DEVICE_HANDLE *pUsbdDeviceHandle, IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_DEVICE_HANDLE HubDeviceHandle, IN USHORT PortStatus, IN USHORT Port)
Definition: device.c:982
NTSTATUS NTAPI USBPORT_Initialize20Hub(IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_DEVICE_HANDLE HubDeviceHandle, IN ULONG TtCount)
Definition: device.c:2012
NTSTATUS NTAPI USBPORT_InitializeDevice(IN PUSBPORT_DEVICE_HANDLE DeviceHandle, IN PDEVICE_OBJECT FdoDevice)
Definition: device.c:1316
NTSTATUS NTAPI USBPORT_RestoreDevice(IN PDEVICE_OBJECT FdoDevice, IN OUT PUSBPORT_DEVICE_HANDLE OldDeviceHandle, IN OUT PUSBPORT_DEVICE_HANDLE NewDeviceHandle)
Definition: device.c:1701
NTSTATUS NTAPI USBPORT_GetSymbolicName(IN PDEVICE_OBJECT RootHubPdo, IN PUNICODE_STRING DestinationString)
Definition: ioctl.c:62
VOID NTAPI USBPORT_BadRequestFlush(IN PDEVICE_OBJECT FdoDevice)
Definition: queue.c:1328
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
Status
Definition: gdiplustypes.h:25
struct _USB_BUS_INTERFACE_HUB_V5 * PUSB_BUS_INTERFACE_HUB_V5
_Inout_ PUSB_DEVICE_HANDLE DeviceHandle
Definition: hubbusif.h:121
RH_INIT_CALLBACK * PRH_INIT_CALLBACK
Definition: hubbusif.h:270
struct _USB_LEVEL_INFORMATION USB_LEVEL_INFORMATION
_Outptr_ PUSB_DEVICE_HANDLE _In_ PUSB_DEVICE_HANDLE _In_ USHORT PortStatus
Definition: hubbusif.h:42
#define USB_BUSIFFN
Definition: hubbusif.h:22
_In_ PVOID _In_ PDEVICE_OBJECT UsbDevicePdo
Definition: hubbusif.h:322
struct _USB_PIPE_INFORMATION_0 USB_PIPE_INFORMATION_0
_In_ PUSB_DEVICE_HANDLE _In_ ULONG TtCount
Definition: hubbusif.h:240
struct _USB_CONTROLLER_INFORMATION_0 USB_CONTROLLER_INFORMATION_0
_In_ PDEVICE_OBJECT HubPhysicalDeviceObject
Definition: hubbusif.h:209
struct _USB_EXTHUB_INFORMATION_0 USB_EXTHUB_INFORMATION_0
NTSYSAPI NTSTATUS WINAPI RtlStringFromGUID(REFGUID, PUNICODE_STRING)
if(dx< 0)
Definition: linetemp.h:194
_In_ NDIS_HANDLE _In_ PNDIS_PACKET Packet
Definition: ndis.h:1549
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
_In_ ULONGLONG _In_ ULONGLONG _In_ BOOLEAN Enable
Definition: ntddpcm.h:142
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:423
#define L(x)
Definition: ntvdm.h:50
unsigned short USHORT
Definition: pedump.c:61
#define REG_DWORD
Definition: sdbapi.c:596
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
#define DPRINT
Definition: sndvol32.h:73
ULONG PortNumber
Definition: storport.c:18
PVOID DeviceExtension
Definition: env_spec_w32.h:418
struct _IO_STACK_LOCATION::@3974::@4000 QueryInterface
union _IO_STACK_LOCATION::@1575 Parameters
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
Definition: usb.h:529
PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor
Definition: usbport.h:172
LIST_ENTRY InterfaceHandleList
Definition: usbport.h:173
USBPORT_PIPE_HANDLE PipeHandle[1]
Definition: usbport.h:183
USB_INTERFACE_DESCRIPTOR InterfaceDescriptor
Definition: usbport.h:181
WCHAR ControllerNameUnicodeString[1]
Definition: usbbusif.h:54
PUSB_BUSIFFN_GET_DEVICE_BUSCONTEXT GetDeviceBusContext
Definition: hubbusif.h:552
PUSB_BUSIFFN_GET_EXTENDED_HUB_INFO GetExtendedHubInformation
Definition: hubbusif.h:550
PUSB_BUSIFFN_INITIALIZE_USB_DEVICE InitializeUsbDevice
Definition: hubbusif.h:542
PUSB_BUSIFFN_GET_USB_DESCRIPTORS GetUsbDescriptors
Definition: hubbusif.h:543
PUSB_BUSIFFN_FLUSH_TRANSFERS FlushTransfers
Definition: hubbusif.h:555
PUSB_BUSIFFN_GET_DEVICE_INFORMATION QueryDeviceInformation
Definition: hubbusif.h:547
PUSB_BUSIFFN_SET_DEVHANDLE_DATA SetDeviceHandleData
Definition: hubbusif.h:556
PUSB_BUSIFFN_INITIALIZE_20HUB Initialize20Hub
Definition: hubbusif.h:553
PUSB_BUSIFFN_GET_CONTROLLER_INFORMATION GetControllerInformation
Definition: hubbusif.h:548
PUSB_BUSIFFN_CONTROLLER_SELECTIVE_SUSPEND ControllerSelectiveSuspend
Definition: hubbusif.h:549
PUSB_BUSIFFN_REMOVE_USB_DEVICE RemoveUsbDevice
Definition: hubbusif.h:544
PINTERFACE_DEREFERENCE InterfaceDereference
Definition: hubbusif.h:540
PUSB_BUSIFFN_CREATE_USB_DEVICE CreateUsbDevice
Definition: hubbusif.h:541
PUSB_BUSIFFN_RESTORE_DEVICE RestoreUsbDevice
Definition: hubbusif.h:545
PINTERFACE_REFERENCE InterfaceReference
Definition: hubbusif.h:539
PUSB_BUSIFFN_ROOTHUB_INIT_NOTIFY RootHubInitNotification
Definition: hubbusif.h:554
PUSB_BUSIFFN_GET_ROOTHUB_SYM_NAME GetRootHubSymbolicName
Definition: hubbusif.h:551
PUSB_BUSIFFN_IS_DEVICE_HIGH_SPEED IsDeviceHighSpeed
Definition: usbbusif.h:116
PINTERFACE_REFERENCE InterfaceReference
Definition: usbbusif.h:110
PUSB_BUSIFFN_QUERY_BUS_TIME QueryBusTime
Definition: usbbusif.h:113
PUSB_BUSIFFN_ENUM_LOG_ENTRY EnumLogEntry
Definition: usbbusif.h:117
PUSB_BUSIFFN_SUBMIT_ISO_OUT_URB SubmitIsoOutUrb
Definition: usbbusif.h:114
PUSB_BUSIFFN_GETUSBDI_VERSION GetUSBDIVersion
Definition: usbbusif.h:112
PINTERFACE_DEREFERENCE InterfaceDereference
Definition: usbbusif.h:111
PUSB_BUSIFFN_QUERY_BUS_INFORMATION QueryBusInformation
Definition: usbbusif.h:115
USB_EXTPORT_INFORMATION_0 Port[255]
Definition: hubbusif.h:732
uint32_t * PULONG
Definition: typedefs.h:59
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define NTAPI
Definition: typedefs.h:36
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define IN
Definition: typedefs.h:39
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
unsigned char * PUCHAR
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
#define USB_CONFIGURATION_DESCRIPTOR_TYPE
Definition: usb100.h:50
@ UsbHighSpeed
Definition: usb200.h:44
@ UsbLowSpeed
Definition: usb200.h:42
@ UsbFullSpeed
Definition: usb200.h:43
@ Usb20Device
Definition: usb200.h:38
@ Usb11Device
Definition: usb200.h:37
NTSTATUS USB_BUSIFFN USBHI_RootHubInitNotification(IN PVOID BusContext, IN PVOID CallbackContext, IN PRH_INIT_CALLBACK CallbackFunction)
Definition: iface.c:589
NTSTATUS USB_BUSIFFN USBHI_InitializeUsbDevice(IN PVOID BusContext, OUT PUSB_DEVICE_HANDLE UsbdDeviceHandle)
Definition: iface.c:60
NTSTATUS USB_BUSIFFN USBHI_GetControllerInformation(IN PVOID BusContext, OUT PVOID ControllerInfoBuffer, IN ULONG ControllerInfoBufferLen, OUT PULONG LenDataReturned)
Definition: iface.c:307
NTSTATUS USB_BUSIFFN USBDI_SubmitIsoOutUrb(IN PVOID BusContext, IN PURB Urb)
Definition: iface.c:661
NTSTATUS USB_BUSIFFN USBHI_GetExtendedHubInformation(IN PVOID BusContext, IN PDEVICE_OBJECT HubPhysicalDeviceObject, IN OUT PVOID HubInformationBuffer, IN ULONG HubInfoLen, IN OUT PULONG LenDataReturned)
Definition: iface.c:417
NTSTATUS USB_BUSIFFN USBHI_QueryDeviceInformation(IN PVOID BusContext, IN PUSB_DEVICE_HANDLE UsbdDeviceHandle, OUT PVOID DeviceInfoBuffer, IN ULONG DeviceInfoBufferLen, OUT PULONG LenDataReturned)
Definition: iface.c:161
VOID USB_BUSIFFN USBHI_FlushTransfers(IN PVOID BusContext, OUT PUSB_DEVICE_HANDLE UsbdDeviceHandle)
Definition: iface.c:616
VOID USB_BUSIFFN USBI_InterfaceDereference(IN PVOID BusContext)
Definition: iface.c:22
NTSTATUS USB_BUSIFFN USBHI_GetRootHubSymbolicName(IN PVOID BusContext, IN OUT PVOID HubInfoBuffer, IN ULONG HubInfoBufferLen, OUT PULONG HubNameActualLen)
Definition: iface.c:523
NTSTATUS USB_BUSIFFN USBHI_ControllerSelectiveSuspend(IN PVOID BusContext, IN BOOLEAN Enable)
Definition: iface.c:361
NTSTATUS USB_BUSIFFN USBHI_GetUsbDescriptors(IN PVOID BusContext, IN PUSB_DEVICE_HANDLE UsbdDeviceHandle, IN PUCHAR DeviceDescBuffer, IN PULONG DeviceDescBufferLen, IN PUCHAR ConfigDescBuffer, IN PULONG ConfigDescBufferLen)
Definition: iface.c:77
VOID USB_BUSIFFN USBDI_GetUSBDIVersion(IN PVOID BusContext, OUT PUSBD_VERSION_INFORMATION VersionInfo, OUT PULONG HcdCapabilities)
Definition: iface.c:643
NTSTATUS USB_BUSIFFN USBHI_RemoveUsbDevice(IN PVOID BusContext, IN OUT PUSB_DEVICE_HANDLE UsbdDeviceHandle, IN ULONG Flags)
Definition: iface.c:119
VOID USB_BUSIFFN USBHI_SetDeviceHandleData(IN PVOID BusContext, IN PVOID DeviceHandle, IN PDEVICE_OBJECT UsbDevicePdo)
Definition: iface.c:632
NTSTATUS USB_BUSIFFN USBHI_Initialize20Hub(IN PVOID BusContext, IN PUSB_DEVICE_HANDLE UsbdHubDeviceHandle, IN ULONG TtCount)
Definition: iface.c:568
NTSTATUS USB_BUSIFFN USBDI_EnumLogEntry(IN PVOID BusContext, IN ULONG DriverTag, IN ULONG EnumTag, IN ULONG P1, IN ULONG P2)
Definition: iface.c:770
VOID USB_BUSIFFN USBI_InterfaceReference(IN PVOID BusContext)
Definition: iface.c:15
NTSTATUS USB_BUSIFFN USBHI_CreateUsbDevice(IN PVOID BusContext, IN OUT PUSB_DEVICE_HANDLE *UsbdDeviceHandle, IN PUSB_DEVICE_HANDLE UsbdHubDeviceHandle, IN USHORT PortStatus, IN USHORT PortNumber)
Definition: iface.c:31
NTSTATUS USB_BUSIFFN USBDI_QueryBusTime(IN PVOID BusContext, OUT PULONG CurrentFrame)
Definition: iface.c:652
PVOID USB_BUSIFFN USBHI_GetDeviceBusContext(IN PVOID BusContext, IN PVOID DeviceHandle)
Definition: iface.c:559
NTSTATUS USB_BUSIFFN USBDI_QueryBusInformation(IN PVOID BusContext, IN ULONG Level, OUT PVOID BusInfoBuffer, OUT PULONG BusInfoBufferLen, OUT PULONG BusInfoActualLen)
Definition: iface.c:670
BOOLEAN USB_BUSIFFN USBDI_IsDeviceHighSpeed(IN PVOID BusContext)
Definition: iface.c:749
NTSTATUS NTAPI USBPORT_PdoQueryInterface(IN PDEVICE_OBJECT FdoDevice, IN PDEVICE_OBJECT PdoDevice, IN PIRP Irp)
Definition: iface.c:782
NTSTATUS USB_BUSIFFN USBHI_RestoreUsbDevice(IN PVOID BusContext, OUT PUSB_DEVICE_HANDLE OldUsbdDeviceHandle, OUT PUSB_DEVICE_HANDLE NewUsbdDeviceHandle)
Definition: iface.c:140
#define USB_PORTATTR_NO_OVERCURRENT_UI
Definition: usb.h:52
#define USB_PORTATTR_SHARED_USB2
Definition: usb.h:48
#define USB_PORTATTR_OWNED_BY_CC
Definition: usb.h:51
struct _USB_BUS_INTERFACE_USBDI_V2 * PUSB_BUS_INTERFACE_USBDI_V2
struct _USB_BUS_INFORMATION_LEVEL_0 USB_BUS_INFORMATION_LEVEL_0
struct _USB_BUS_INFORMATION_LEVEL_1 USB_BUS_INFORMATION_LEVEL_1
#define USB_MINIPORT_FLAGS_USB2
Definition: usbmport.h:534
PDEVICE_OBJECT NTAPI USBPORT_FindUSB2Controller(IN PDEVICE_OBJECT FdoDevice)
Definition: usbport.c:27
NTSTATUS NTAPI USBPORT_GetRegistryKeyValueFullInfo(IN PDEVICE_OBJECT FdoDevice, IN PDEVICE_OBJECT PdoDevice, IN BOOL UseDriverKey, IN PCWSTR SourceString, IN ULONG LengthStr, IN PVOID Buffer, IN ULONG BufferLength)
Definition: usbport.c:296
NTSTATUS NTAPI USBPORT_SetRegistryKeyValue(IN PDEVICE_OBJECT DeviceObject, IN BOOL UseDriverKey, IN ULONG Type, IN PCWSTR ValueNameString, IN PVOID Data, IN ULONG DataSize)
Definition: usbport.c:248
struct _USBPORT_DEVICE_HANDLE * PUSBPORT_DEVICE_HANDLE
#define PIPE_HANDLE_FLAG_NULL_PACKET_SIZE
Definition: usbport.h:127
#define USBPORT_FLAG_BIOS_DISABLE_SS
Definition: usbport.h:81
#define USBPORT_FLAG_COMPANION_HC
Definition: usbport.h:78
#define USBPORT_FLAG_SELECTIVE_SUSPEND
Definition: usbport.h:73
_In_ WDFUSBINTERFACE _In_ UCHAR _Out_opt_ PWDF_USB_PIPE_INFORMATION PipeInfo
Definition: wdfusb.h:2543
#define IsEqualGUIDAligned(guid1, guid2)
Definition: wdm.template.h:235
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR _In_ ULONGLONG _In_ ULONGLONG _In_opt_ PEVENT_FILTER_DESCRIPTOR _Inout_opt_ PVOID CallbackContext
Definition: wmitypes.h:60
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR Level
Definition: wmitypes.h:56
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
_In_ PCALLBACK_FUNCTION CallbackFunction
Definition: exfuncs.h:1034
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:778