2 * PROJECT: ReactOS Universal Serial Bus Bulk Enhanced Host Controller Interface
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: drivers/usb/usbehci/pdo.c
5 * PURPOSE: USB EHCI device driver.
20 /* Lifted from Linux with slight changes */
21 const UCHAR ROOTHUB2_DEVICE_DESCRIPTOR
[] =
24 USB_DEVICE_DESCRIPTOR_TYPE
, /* bDescriptorType; Device */
25 0x00, 0x20, /* bcdUSB; v1.1 */
26 USB_DEVICE_CLASS_HUB
, /* bDeviceClass; HUB_CLASSCODE */
27 0x01, /* bDeviceSubClass; */
28 0x00, /* bDeviceProtocol; [ low/full speeds only ] */
29 0x08, /* bMaxPacketSize0; 8 Bytes */
30 /* Fill Vendor and Product in when init root hub */
31 0x00, 0x00, /* idVendor; */
32 0x00, 0x00, /* idProduct; */
33 0x00, 0x00, /* bcdDevice */
34 0x00, /* iManufacturer; */
36 0x00, /* iSerialNumber; */
37 0x01 /* bNumConfigurations; */
41 const UCHAR ROOTHUB2_CONFIGURATION_DESCRIPTOR
[] =
43 /* one configuration */
45 0x02, /* bDescriptorType; Configuration */
46 0x19, 0x00, /* wTotalLength; */
47 0x01, /* bNumInterfaces; (1) */
48 0x23, /* bConfigurationValue; */
49 0x00, /* iConfiguration; */
50 0x40, /* bmAttributes;
58 const UCHAR ROOTHUB2_INTERFACE_DESCRIPTOR
[] =
61 0x09, /* bLength: Interface; */
62 0x04, /* bDescriptorType; Interface */
63 0x00, /* bInterfaceNumber; */
64 0x00, /* bAlternateSetting; */
65 0x01, /* bNumEndpoints; */
66 0x09, /* bInterfaceClass; HUB_CLASSCODE */
67 0x01, /* bInterfaceSubClass; */
68 0x00, /* bInterfaceProtocol: */
69 0x00 /* iInterface; */
72 const UCHAR ROOTHUB2_ENDPOINT_DESCRIPTOR
[] =
74 /* one endpoint (status change endpoint) */
76 0x05, /* bDescriptorType; Endpoint */
77 0x81, /* bEndpointAddress; IN Endpoint 1 */
78 0x03, /* bmAttributes; Interrupt */
79 0x08, 0x00, /* wMaxPacketSize; 1 + (MAX_ROOT_PORTS / 8) */
80 0xFF /* bInterval; (255ms -- usb 2.0 spec) */
83 /* FIXME: Do something better */
85 UrbWorkerThread(PVOID Context
)
87 PPDO_DEVICE_EXTENSION PdoDeviceExtension
= (PPDO_DEVICE_EXTENSION
)Context
;
89 LARGE_INTEGER DueTime
;
90 PVOID PollEvents
[] = { (PVOID
) &PdoDeviceExtension
->QueueDrainedEvent
, (PVOID
) &PdoDeviceExtension
->Timer
};
93 KeInitializeTimerEx(&PdoDeviceExtension
->Timer
, SynchronizationTimer
);
94 KeSetTimerEx(&PdoDeviceExtension
->Timer
, DueTime
, 100, NULL
);
98 Status
= KeWaitForMultipleObjects(2, PollEvents
, WaitAll
, Executive
, KernelMode
, FALSE
, NULL
, NULL
);
100 if (!PdoDeviceExtension
->HaltQueue
)
101 KeResetEvent(&PdoDeviceExtension
->QueueDrainedEvent
);
102 CompletePendingURBRequest(PdoDeviceExtension
);
105 DPRINT1("Thread terminated\n");
109 PdoDispatchInternalDeviceControl(PDEVICE_OBJECT DeviceObject
, PIRP Irp
)
111 PPDO_DEVICE_EXTENSION PdoDeviceExtension
;
112 PFDO_DEVICE_EXTENSION FdoDeviceExtension
;
113 PIO_STACK_LOCATION Stack
= NULL
;
114 NTSTATUS Status
= STATUS_UNSUCCESSFUL
;
115 ULONG_PTR Information
= 0;
117 PdoDeviceExtension
= (PPDO_DEVICE_EXTENSION
) DeviceObject
->DeviceExtension
;
118 FdoDeviceExtension
= (PFDO_DEVICE_EXTENSION
) PdoDeviceExtension
->ControllerFdo
->DeviceExtension
;
120 ASSERT(PdoDeviceExtension
->Common
.IsFdo
== FALSE
);
122 Stack
= IoGetCurrentIrpStackLocation(Irp
);
124 switch(Stack
->Parameters
.DeviceIoControl
.IoControlCode
)
126 case IOCTL_INTERNAL_USB_SUBMIT_URB
:
130 Urb
= (PURB
) Stack
->Parameters
.Others
.Argument1
;
131 DPRINT("Header Length %d\n", Urb
->UrbHeader
.Length
);
132 DPRINT("Header Function %d\n", Urb
->UrbHeader
.Function
);
133 /* Queue all request for now, kernel thread will complete them */
134 QueueURBRequest(PdoDeviceExtension
, Irp
);
136 IoMarkIrpPending(Irp
);
137 Status
= STATUS_PENDING
;
140 case IOCTL_INTERNAL_USB_CYCLE_PORT
:
142 DPRINT1("IOCTL_INTERNAL_USB_CYCLE_PORT\n");
145 case IOCTL_INTERNAL_USB_ENABLE_PORT
:
147 DPRINT1("IOCTL_INTERNAL_USB_ENABLE_PORT\n");
149 Status
= STATUS_SUCCESS
;
152 case IOCTL_INTERNAL_USB_GET_BUS_INFO
:
154 DPRINT1("IOCTL_INTERNAL_USB_GET_BUS_INFO\n");
157 case IOCTL_INTERNAL_USB_GET_BUSGUID_INFO
:
159 DPRINT1("IOCTL_INTERNAL_USB_GET_BUSGUID_INFO\n");
162 case IOCTL_INTERNAL_USB_GET_CONTROLLER_NAME
:
164 DPRINT1("IOCTL_INTERNAL_USB_GET_CONTROLLER_NAME\n");
167 case IOCTL_INTERNAL_USB_GET_DEVICE_HANDLE
:
169 DPRINT1("IOCTL_INTERNAL_USB_GET_DEVICE_HANDLE %x\n", IOCTL_INTERNAL_USB_GET_DEVICE_HANDLE
);
170 if (Stack
->Parameters
.Others
.Argument1
)
172 /* Return the root hubs devicehandle */
173 DPRINT1("Returning RootHub Handle %x\n", PdoDeviceExtension
->UsbDevices
[0]);
174 *(PVOID
*)Stack
->Parameters
.Others
.Argument1
= (PVOID
)PdoDeviceExtension
->UsbDevices
[0];
175 Status
= STATUS_SUCCESS
;
178 Status
= STATUS_INVALID_DEVICE_REQUEST
;
183 case IOCTL_INTERNAL_USB_GET_HUB_COUNT
:
185 DPRINT1("IOCTL_INTERNAL_USB_GET_HUB_COUNT %x\n", IOCTL_INTERNAL_USB_GET_HUB_COUNT
);
186 ASSERT(Stack
->Parameters
.Others
.Argument1
!= NULL
);
187 if (Stack
->Parameters
.Others
.Argument1
)
189 /* FIXME: Determine the number of hubs between the usb device and root hub */
190 DPRINT1("RootHubCount %x\n", *(PULONG
)Stack
->Parameters
.Others
.Argument1
);
191 *(PULONG
)Stack
->Parameters
.Others
.Argument1
= 0;
193 Status
= STATUS_SUCCESS
;
196 case IOCTL_INTERNAL_USB_GET_HUB_NAME
:
198 DPRINT1("IOCTL_INTERNAL_USB_GET_HUB_NAME\n");
201 case IOCTL_INTERNAL_USB_GET_PARENT_HUB_INFO
:
203 DPRINT1("IOCTL_INTERNAL_USB_GET_PARENT_HUB_INFO\n");
206 case IOCTL_INTERNAL_USB_GET_PORT_STATUS
:
208 DPRINT1("IOCTL_INTERNAL_USB_GET_PORT_STATUS\n");
211 case IOCTL_INTERNAL_USB_RESET_PORT
:
213 DPRINT1("IOCTL_INTERNAL_USB_RESET_PORT\n");
216 case IOCTL_INTERNAL_USB_GET_ROOTHUB_PDO
:
218 DPRINT1("IOCTL_INTERNAL_USB_GET_ROOTHUB_PDO\n");
220 if (Stack
->Parameters
.Others
.Argument1
)
221 *(PVOID
*)Stack
->Parameters
.Others
.Argument1
= FdoDeviceExtension
->Pdo
;
222 if (Stack
->Parameters
.Others
.Argument2
)
223 *(PVOID
*)Stack
->Parameters
.Others
.Argument2
= IoGetAttachedDeviceReference(FdoDeviceExtension
->DeviceObject
);
226 Status
= STATUS_SUCCESS
;
229 case IOCTL_INTERNAL_USB_SUBMIT_IDLE_NOTIFICATION
:
231 PUSB_IDLE_CALLBACK_INFO CallBackInfo
;
232 DPRINT1("IOCTL_INTERNAL_USB_SUBMIT_IDLE_NOTIFICATION\n");
233 /* FIXME: Set Callback for safe power down */
234 CallBackInfo
= Stack
->Parameters
.DeviceIoControl
.Type3InputBuffer
;
235 DPRINT1("IdleCallback %x\n", CallBackInfo
->IdleCallback
);
236 DPRINT1("IdleContext %x\n", CallBackInfo
->IdleContext
);
238 PdoDeviceExtension
->IdleCallback
= CallBackInfo
->IdleCallback
;
239 PdoDeviceExtension
->IdleContext
= CallBackInfo
->IdleContext
;
242 Status
= STATUS_SUCCESS
;
247 DPRINT1("Unhandled IoControlCode %x\n", Stack
->Parameters
.DeviceIoControl
.IoControlCode
);
252 Irp
->IoStatus
.Information
= Information
;
254 if (Status
!= STATUS_PENDING
)
255 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
261 PdoQueryId(PDEVICE_OBJECT DeviceObject
, PIRP Irp
, ULONG_PTR
* Information
)
266 UNICODE_STRING SourceString
;
267 UNICODE_STRING String
;
270 IdType
= IoGetCurrentIrpStackLocation(Irp
)->Parameters
.QueryId
.IdType
;
274 case BusQueryDeviceID
:
276 RtlInitUnicodeString(&SourceString
, L
"USB\\ROOT_HUB20");
279 case BusQueryHardwareIDs
:
281 Index
+= swprintf(&Buffer
[Index
], L
"USB\\ROOT_HUB20&VID8086&PID265C&REV0000") + 1;
282 Index
+= swprintf(&Buffer
[Index
], L
"USB\\ROOT_HUB20&VID8086&PID265C") + 1;
283 Index
+= swprintf(&Buffer
[Index
], L
"USB\\ROOT_HUB20") + 1;
285 Buffer
[Index
] = UNICODE_NULL
;
286 SourceString
.Length
= SourceString
.MaximumLength
= Index
* sizeof(WCHAR
);
287 SourceString
.Buffer
= Buffer
;
291 case BusQueryCompatibleIDs
:
294 return STATUS_SUCCESS
;
296 case BusQueryInstanceID
:
298 return STATUS_SUCCESS
;
302 DPRINT1("IRP_MJ_PNP / IRP_MN_QUERY_ID / unknown query id type 0x%lx\n", IdType
);
303 return STATUS_NOT_SUPPORTED
;
307 Status
= DuplicateUnicodeString(RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE
,
311 *Information
= (ULONG_PTR
)String
.Buffer
;
316 PdoQueryDeviceRelations(PDEVICE_OBJECT DeviceObject
, PDEVICE_RELATIONS
* pDeviceRelations
)
318 PDEVICE_RELATIONS DeviceRelations
;
320 DeviceRelations
= (PDEVICE_RELATIONS
)ExAllocatePool(PagedPool
, sizeof(DEVICE_RELATIONS
));
321 if (!DeviceRelations
)
322 return STATUS_INSUFFICIENT_RESOURCES
;
324 DeviceRelations
->Count
= 1;
325 DeviceRelations
->Objects
[0] = DeviceObject
;
326 ObReferenceObject(DeviceObject
);
328 *pDeviceRelations
= DeviceRelations
;
329 return STATUS_SUCCESS
;
334 IN PDEVICE_OBJECT DeviceObject
,
338 PIO_STACK_LOCATION Stack
;
339 ULONG_PTR Information
= Irp
->IoStatus
.Information
;
340 NTSTATUS Status
= Irp
->IoStatus
.Status
;
342 Stack
= IoGetCurrentIrpStackLocation(Irp
);
343 MinorFunction
= Stack
->MinorFunction
;
345 switch (MinorFunction
)
347 case IRP_MN_QUERY_REMOVE_DEVICE
:
348 case IRP_MN_REMOVE_DEVICE
:
349 case IRP_MN_CANCEL_REMOVE_DEVICE
:
350 case IRP_MN_STOP_DEVICE
:
351 case IRP_MN_QUERY_STOP_DEVICE
:
352 case IRP_MN_CANCEL_STOP_DEVICE
:
353 case IRP_MN_QUERY_DEVICE_TEXT
:
354 case IRP_MN_SURPRISE_REMOVAL
:
355 case IRP_MN_QUERY_RESOURCES
:
356 case IRP_MN_QUERY_RESOURCE_REQUIREMENTS
:
357 case IRP_MN_FILTER_RESOURCE_REQUIREMENTS
:
359 Status
= STATUS_SUCCESS
;
363 case IRP_MN_START_DEVICE
:
365 PUSB_DEVICE RootHubDevice
;
366 PPDO_DEVICE_EXTENSION PdoDeviceExtension
;
367 PFDO_DEVICE_EXTENSION FdoDeviceExtension
;
368 UNICODE_STRING InterfaceSymLinkName
;
371 PdoDeviceExtension
= (PPDO_DEVICE_EXTENSION
)DeviceObject
->DeviceExtension
;
372 FdoDeviceExtension
= (PFDO_DEVICE_EXTENSION
)PdoDeviceExtension
->ControllerFdo
->DeviceExtension
;
374 /* Create the root hub */
375 RootHubDevice
= InternalCreateUsbDevice(1, 0, NULL
, TRUE
);
377 for (i
= 0; i
< 8; i
++)
379 PdoDeviceExtension
->Ports
[i
].PortStatus
= USB_PORT_STATUS_ENABLE
;
380 PdoDeviceExtension
->Ports
[i
].PortChange
= 0;
383 RtlCopyMemory(&RootHubDevice
->DeviceDescriptor
,
384 ROOTHUB2_DEVICE_DESCRIPTOR
,
385 sizeof(ROOTHUB2_DEVICE_DESCRIPTOR
));
387 RootHubDevice
->DeviceDescriptor
.idVendor
= FdoDeviceExtension
->VendorId
;
388 RootHubDevice
->DeviceDescriptor
.idProduct
= FdoDeviceExtension
->DeviceId
;
390 /* FIXME: Do something better below */
392 RootHubDevice
->Configs
= ExAllocatePoolWithTag(NonPagedPool
,
393 sizeof(PVOID
) * RootHubDevice
->DeviceDescriptor
.bNumConfigurations
,
396 RootHubDevice
->Configs
[0] = ExAllocatePoolWithTag(NonPagedPool
,
397 sizeof(USB_CONFIGURATION
) + sizeof(PVOID
) * ROOTHUB2_CONFIGURATION_DESCRIPTOR
[5],
400 RootHubDevice
->Configs
[0]->Interfaces
[0] = ExAllocatePoolWithTag(NonPagedPool
,
401 sizeof(USB_INTERFACE
) + sizeof(PVOID
) * ROOTHUB2_INTERFACE_DESCRIPTOR
[3],
404 RootHubDevice
->Configs
[0]->Interfaces
[0]->EndPoints
[0] = ExAllocatePoolWithTag(NonPagedPool
,
405 sizeof(USB_ENDPOINT
),
408 RootHubDevice
->ActiveConfig
= RootHubDevice
->Configs
[0];
409 RootHubDevice
->ActiveInterface
= RootHubDevice
->ActiveConfig
->Interfaces
[0];
411 RtlCopyMemory(&RootHubDevice
->ActiveConfig
->ConfigurationDescriptor
,
412 ROOTHUB2_CONFIGURATION_DESCRIPTOR
,
413 sizeof(ROOTHUB2_CONFIGURATION_DESCRIPTOR
));
415 RtlCopyMemory(&RootHubDevice
->ActiveConfig
->Interfaces
[0]->InterfaceDescriptor
,
416 ROOTHUB2_INTERFACE_DESCRIPTOR
,
417 sizeof(ROOTHUB2_INTERFACE_DESCRIPTOR
));
419 RtlCopyMemory(&RootHubDevice
->ActiveConfig
->Interfaces
[0]->EndPoints
[0]->EndPointDescriptor
,
420 ROOTHUB2_ENDPOINT_DESCRIPTOR
,
421 sizeof(ROOTHUB2_ENDPOINT_DESCRIPTOR
));
422 RootHubDevice
->DeviceSpeed
= UsbHighSpeed
;
423 RootHubDevice
->DeviceType
= Usb20Device
;
425 PdoDeviceExtension
->UsbDevices
[0] = RootHubDevice
;
427 /* Create a thread to handle the URB's */
429 Status
= PsCreateSystemThread(&PdoDeviceExtension
->ThreadHandle
,
435 (PVOID
)PdoDeviceExtension
);
437 if (!NT_SUCCESS(Status
))
438 DPRINT1("Failed Thread Creation with Status: %x\n", Status
);
440 Status
= IoRegisterDeviceInterface(DeviceObject
, &GUID_DEVINTERFACE_USB_HUB
, NULL
, &InterfaceSymLinkName
);
441 if (!NT_SUCCESS(Status
))
443 DPRINT1("Failed to register interface\n");
448 Status
= IoSetDeviceInterfaceState(&InterfaceSymLinkName
, TRUE
);
449 DPRINT1("Set interface state %x\n", Status
);
450 if (!NT_SUCCESS(Status
))
454 Status
= STATUS_SUCCESS
;
457 case IRP_MN_QUERY_DEVICE_RELATIONS
:
459 switch (Stack
->Parameters
.QueryDeviceRelations
.Type
)
461 case TargetDeviceRelation
:
463 PDEVICE_RELATIONS DeviceRelations
= NULL
;
464 Status
= PdoQueryDeviceRelations(DeviceObject
, &DeviceRelations
);
465 Information
= (ULONG_PTR
)DeviceRelations
;
470 PPDO_DEVICE_EXTENSION PdoDeviceExtension
;
471 PdoDeviceExtension
= (PPDO_DEVICE_EXTENSION
)DeviceObject
->DeviceExtension
;
473 DPRINT1("BusRelations!!!!!\n");
475 /* The hub driver has created the new device object and reported to pnp, as a result the pnp manager
476 has resent this IRP and type, so leave the next SCE request pending until a new device arrives.
477 Is there a better way to do this */
478 ExAcquireFastMutex(&PdoDeviceExtension
->ListLock
);
479 PdoDeviceExtension
->HaltQueue
= TRUE
;
480 ExReleaseFastMutex(&PdoDeviceExtension
->ListLock
);
482 case RemovalRelations
:
483 case EjectionRelations
:
485 /* Ignore the request */
486 Information
= Irp
->IoStatus
.Information
;
487 Status
= Irp
->IoStatus
.Status
;
493 DPRINT1("IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS / Unhandled type 0x%lx\n",
494 Stack
->Parameters
.QueryDeviceRelations
.Type
);
495 Status
= STATUS_NOT_SUPPORTED
;
501 case IRP_MN_QUERY_CAPABILITIES
:
503 PDEVICE_CAPABILITIES DeviceCapabilities
;
506 DeviceCapabilities
= (PDEVICE_CAPABILITIES
)Stack
->Parameters
.DeviceCapabilities
.Capabilities
;
508 DeviceCapabilities
->LockSupported
= FALSE
;
509 DeviceCapabilities
->EjectSupported
= FALSE
;
510 DeviceCapabilities
->Removable
= FALSE
;
511 DeviceCapabilities
->DockDevice
= FALSE
;
512 DeviceCapabilities
->UniqueID
= FALSE
;
513 DeviceCapabilities
->SilentInstall
= FALSE
;
514 DeviceCapabilities
->RawDeviceOK
= FALSE
;
515 DeviceCapabilities
->SurpriseRemovalOK
= FALSE
;
516 DeviceCapabilities
->Address
= 0;
517 DeviceCapabilities
->UINumber
= 0;
518 DeviceCapabilities
->DeviceD2
= 1;
521 DeviceCapabilities
->HardwareDisabled
= FALSE
;
522 //DeviceCapabilities->NoDisplayInUI = FALSE;
523 DeviceCapabilities
->DeviceState
[0] = PowerDeviceD0
;
524 for (i
= 0; i
< PowerSystemMaximum
; i
++)
525 DeviceCapabilities
->DeviceState
[i
] = PowerDeviceD3
;
526 DeviceCapabilities
->DeviceWake
= 0;
527 DeviceCapabilities
->D1Latency
= 0;
528 DeviceCapabilities
->D2Latency
= 0;
529 DeviceCapabilities
->D3Latency
= 0;
531 Status
= STATUS_SUCCESS
;
534 /*case IRP_MN_QUERY_DEVICE_TEXT:
536 Status = STATUS_NOT_SUPPORTED;
540 case IRP_MN_QUERY_ID
:
542 Status
= PdoQueryId(DeviceObject
, Irp
, &Information
);
545 case IRP_MN_QUERY_INTERFACE
:
547 UNICODE_STRING GuidString
;
548 PUSB_BUS_INTERFACE_HUB_V5 InterfaceHub
;
549 PUSB_BUS_INTERFACE_USBDI_V2 InterfaceDI
;
550 PPDO_DEVICE_EXTENSION PdoDeviceExtension
;
551 PFDO_DEVICE_EXTENSION FdoDeviceExtension
;
553 PdoDeviceExtension
= (PPDO_DEVICE_EXTENSION
)DeviceObject
->DeviceExtension
;
554 FdoDeviceExtension
= (PFDO_DEVICE_EXTENSION
)PdoDeviceExtension
->ControllerFdo
->DeviceExtension
;
556 Status
= RtlStringFromGUID(Stack
->Parameters
.QueryInterface
.InterfaceType
, &GuidString
);
557 if (!NT_SUCCESS(Status
))
559 DPRINT1("Failed to create string from GUID!\n");
562 DPRINT("Interface GUID requested %wZ\n", &GuidString
);
563 DPRINT("QueryInterface.Size %x\n", Stack
->Parameters
.QueryInterface
.Size
);
564 DPRINT("QueryInterface.Version %x\n", Stack
->Parameters
.QueryInterface
.Version
);
567 Status
= STATUS_SUCCESS
;
570 if (IsEqualGUIDAligned(Stack
->Parameters
.QueryInterface
.InterfaceType
, &USB_BUS_INTERFACE_HUB_GUID
))
572 InterfaceHub
= (PUSB_BUS_INTERFACE_HUB_V5
)Stack
->Parameters
.QueryInterface
.Interface
;
573 InterfaceHub
->Version
= Stack
->Parameters
.QueryInterface
.Version
;
574 if (Stack
->Parameters
.QueryInterface
.Version
>= 0)
576 InterfaceHub
->Size
= Stack
->Parameters
.QueryInterface
.Size
;
577 InterfaceHub
->BusContext
= PdoDeviceExtension
->DeviceObject
;
578 InterfaceHub
->InterfaceReference
= (PINTERFACE_REFERENCE
)InterfaceReference
;
579 InterfaceHub
->InterfaceDereference
= (PINTERFACE_DEREFERENCE
)InterfaceDereference
;
581 if (Stack
->Parameters
.QueryInterface
.Version
>= 1)
583 InterfaceHub
->CreateUsbDevice
= CreateUsbDevice
;
584 InterfaceHub
->InitializeUsbDevice
= InitializeUsbDevice
;
585 InterfaceHub
->GetUsbDescriptors
= GetUsbDescriptors
;
586 InterfaceHub
->RemoveUsbDevice
= RemoveUsbDevice
;
587 InterfaceHub
->RestoreUsbDevice
= RestoreUsbDevice
;
588 InterfaceHub
->GetPortHackFlags
= GetPortHackFlags
;
589 InterfaceHub
->QueryDeviceInformation
= QueryDeviceInformation
;
591 if (Stack
->Parameters
.QueryInterface
.Version
>= 2)
593 InterfaceHub
->GetControllerInformation
= GetControllerInformation
;
594 InterfaceHub
->ControllerSelectiveSuspend
= ControllerSelectiveSuspend
;
595 InterfaceHub
->GetExtendedHubInformation
= GetExtendedHubInformation
;
596 InterfaceHub
->GetRootHubSymbolicName
= GetRootHubSymbolicName
;
597 InterfaceHub
->GetDeviceBusContext
= GetDeviceBusContext
;
598 InterfaceHub
->Initialize20Hub
= Initialize20Hub
;
601 if (Stack
->Parameters
.QueryInterface
.Version
>= 3)
603 InterfaceHub
->RootHubInitNotification
= RootHubInitNotification
;
605 if (Stack
->Parameters
.QueryInterface
.Version
>= 4)
607 InterfaceHub
->FlushTransfers
= FlushTransfers
;
609 if (Stack
->Parameters
.QueryInterface
.Version
>= 5)
611 InterfaceHub
->SetDeviceHandleData
= SetDeviceHandleData
;
613 if (Stack
->Parameters
.QueryInterface
.Version
>= 6)
615 DPRINT1("USB_BUS_INTERFACE_HUB_GUID version not supported!\n");
620 if (IsEqualGUIDAligned(Stack
->Parameters
.QueryInterface
.InterfaceType
, &USB_BUS_INTERFACE_USBDI_GUID
))
622 InterfaceDI
= (PUSB_BUS_INTERFACE_USBDI_V2
) Stack
->Parameters
.QueryInterface
.Interface
;
623 InterfaceDI
->Version
= Stack
->Parameters
.QueryInterface
.Version
;
624 if (Stack
->Parameters
.QueryInterface
.Version
>= 0)
626 //InterfaceDI->Size = sizeof(USB_BUS_INTERFACE_USBDI_V2);
627 InterfaceDI
->Size
= Stack
->Parameters
.QueryInterface
.Size
;
628 InterfaceDI
->BusContext
= PdoDeviceExtension
->DeviceObject
;
629 InterfaceDI
->InterfaceReference
= (PINTERFACE_REFERENCE
)InterfaceReference
;
630 InterfaceDI
->InterfaceDereference
= (PINTERFACE_DEREFERENCE
)InterfaceDereference
;
631 InterfaceDI
->GetUSBDIVersion
= GetUSBDIVersion
;
632 InterfaceDI
->QueryBusTime
= QueryBusTime
;
633 InterfaceDI
->SubmitIsoOutUrb
= SubmitIsoOutUrb
;
634 InterfaceDI
->QueryBusInformation
= QueryBusInformation
;
636 if (Stack
->Parameters
.QueryInterface
.Version
>= 1)
638 InterfaceDI
->IsDeviceHighSpeed
= IsDeviceHighSpeed
;
640 if (Stack
->Parameters
.QueryInterface
.Version
>= 2)
642 InterfaceDI
->EnumLogEntry
= EnumLogEntry
;
645 if (Stack
->Parameters
.QueryInterface
.Version
>= 3)
647 DPRINT1("SB_BUS_INTERFACE_USBDI_GUID version not supported!\n");
652 DPRINT1("GUID Not Supported\n");
653 Status
= Irp
->IoStatus
.Status
;
654 Information
= Irp
->IoStatus
.Information
;
658 case IRP_MN_QUERY_BUS_INFORMATION
:
660 PPNP_BUS_INFORMATION BusInfo
;
662 BusInfo
= (PPNP_BUS_INFORMATION
)ExAllocatePool(PagedPool
, sizeof(PNP_BUS_INFORMATION
));
664 Status
= STATUS_INSUFFICIENT_RESOURCES
;
669 &BusInfo->BusTypeGuid,
670 &GUID_DEVINTERFACE_XXX,
673 BusInfo
->LegacyBusType
= PNPBus
;
674 BusInfo
->BusNumber
= 0;
675 Information
= (ULONG_PTR
)BusInfo
;
676 Status
= STATUS_SUCCESS
;
682 /* We are the PDO. So ignore */
683 DPRINT1("IRP_MJ_PNP / Unknown minor function 0x%lx\n", MinorFunction
);
688 Irp
->IoStatus
.Information
= Information
;
689 Irp
->IoStatus
.Status
= Status
;
690 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);