2 * PROJECT: ReactOS Universal Serial Bus Hub Driver
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: drivers/usb/usbhub/fdo.c
7 * Hervé Poussineau (hpoussin@reactos.org)
8 * Michael Martin (michael.martin@reactos.org)
9 * Johannes Anderwald (johannes.anderwald@reactos.org)
19 #define IO_METHOD_FROM_CTL_CODE(ctlCode) (ctlCode&0x00000003)
21 DEFINE_GUID(GUID_DEVINTERFACE_USB_DEVICE
,
22 0xA5DCBF10L
, 0x6530, 0x11D2, 0x90, 0x1F, 0x00, 0xC0, 0x4F, 0xB9, 0x51, 0xED);
27 PDEVICE_OBJECT DeviceObject
,
32 DPRINT("Entered Urb Completion\n");
35 // Get the original Irp
37 OriginalIrp
= (PIRP
)Context
;
40 // Update it to match what was returned for the IRP that was passed to RootHub
42 OriginalIrp
->IoStatus
.Status
= Irp
->IoStatus
.Status
;
43 OriginalIrp
->IoStatus
.Information
= Irp
->IoStatus
.Information
;
44 DPRINT("Status %x, Information %x\n", Irp
->IoStatus
.Status
, Irp
->IoStatus
.Information
);
47 // Complete the original Irp
49 IoCompleteRequest(OriginalIrp
, IO_NO_INCREMENT
);
52 // Return this status so the IO Manager doesnt mess with the Irp
54 return STATUS_MORE_PROCESSING_REQUIRED
;
59 PDEVICE_OBJECT RootHubDeviceObject
,
60 IN ULONG IoControlCode
,
62 OUT PVOID OutParameter1
,
63 OUT PVOID OutParameter2
)
66 IO_STATUS_BLOCK IoStatus
;
67 PIO_STACK_LOCATION ForwardStack
, CurrentStack
;
71 // Get the current stack location for the Irp
73 CurrentStack
= IoGetCurrentIrpStackLocation(Irp
);
77 // Pull the Urb from that stack, it will be reused in the Irp sent to RootHub
79 Urb
= (PURB
)CurrentStack
->Parameters
.Others
.Argument1
;
83 // Create the Irp to forward to RootHub
85 ForwardIrp
= IoBuildAsynchronousFsdRequest(IRP_MJ_SHUTDOWN
,
93 DPRINT1("Failed to allocate IRP\n");
94 return STATUS_INSUFFICIENT_RESOURCES
;
98 // Get the new Irps next stack
100 ForwardStack
= IoGetNextIrpStackLocation(ForwardIrp
);
103 // Copy the stack for the current irp into the next stack of new irp
105 RtlCopyMemory(ForwardStack
, CurrentStack
, sizeof(IO_STACK_LOCATION
));
107 IoStatus
.Status
= STATUS_NOT_SUPPORTED
;
108 IoStatus
.Information
= 0;
111 // Mark the Irp from upper driver as pending
113 IoMarkIrpPending(Irp
);
116 // Now set the completion routine for the new Irp.
118 IoSetCompletionRoutine(ForwardIrp
,
125 IoCallDriver(RootHubDeviceObject
, ForwardIrp
);
128 // Always return pending as the completion routine will take care of it
130 return STATUS_PENDING
;
135 IN PDEVICE_OBJECT DeviceObject
)
138 PHUB_DEVICE_EXTENSION HubDeviceExtension
;
139 PHUB_CHILDDEVICE_EXTENSION ChildDeviceExtension
;
142 ChildDeviceExtension
= (PHUB_CHILDDEVICE_EXTENSION
)DeviceObject
->DeviceExtension
;
143 ASSERT(ChildDeviceExtension
->Common
.IsFDO
== FALSE
);
144 HubDeviceExtension
= (PHUB_DEVICE_EXTENSION
)ChildDeviceExtension
->ParentDeviceObject
->DeviceExtension
;
146 for(Index
= 0; Index
< USB_MAXCHILDREN
; Index
++)
148 if (HubDeviceExtension
->ChildDeviceObject
[Index
] == DeviceObject
)
161 USBHUB_PdoHandleInternalDeviceControl(
162 IN PDEVICE_OBJECT DeviceObject
,
166 PIO_STACK_LOCATION Stack
;
167 ULONG_PTR Information
= 0;
168 PHUB_DEVICE_EXTENSION HubDeviceExtension
;
169 PHUB_CHILDDEVICE_EXTENSION ChildDeviceExtension
;
170 PDEVICE_OBJECT RootHubDeviceObject
;
173 //DPRINT1("UsbhubInternalDeviceControlPdo(%x) called\n", DeviceObject);
176 // get current stack location
178 Stack
= IoGetCurrentIrpStackLocation(Irp
);
182 // Set default status
184 Status
= Irp
->IoStatus
.Status
;
186 ChildDeviceExtension
= (PHUB_CHILDDEVICE_EXTENSION
)DeviceObject
->DeviceExtension
;
187 ASSERT(ChildDeviceExtension
->Common
.IsFDO
== FALSE
);
188 HubDeviceExtension
= (PHUB_DEVICE_EXTENSION
)ChildDeviceExtension
->ParentDeviceObject
->DeviceExtension
;
189 RootHubDeviceObject
= HubDeviceExtension
->RootHubPhysicalDeviceObject
;
191 if(!IsValidPDO(DeviceObject
))
193 DPRINT1("[USBHUB] Request for removed device object %p\n", DeviceObject
);
194 Irp
->IoStatus
.Status
= STATUS_DEVICE_NOT_CONNECTED
;
195 Irp
->IoStatus
.Information
= 0;
196 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
197 return STATUS_DEVICE_NOT_CONNECTED
;
200 switch (Stack
->Parameters
.DeviceIoControl
.IoControlCode
)
202 case IOCTL_INTERNAL_USB_GET_PARENT_HUB_INFO
:
204 DPRINT("IOCTL_INTERNAL_USB_GET_PARENT_HUB_INFO\n");
205 if (Irp
->AssociatedIrp
.SystemBuffer
== NULL
206 || Stack
->Parameters
.DeviceIoControl
.OutputBufferLength
!= sizeof(PVOID
))
208 Status
= STATUS_INVALID_PARAMETER
;
214 pHubPointer
= (PVOID
*)Irp
->AssociatedIrp
.SystemBuffer
;
217 Information
= sizeof(PVOID
);
218 Status
= STATUS_SUCCESS
;
222 case IOCTL_INTERNAL_USB_SUBMIT_URB
:
224 //DPRINT1("IOCTL_INTERNAL_USB_SUBMIT_URB\n");
229 Urb
= (PURB
)Stack
->Parameters
.Others
.Argument1
;
233 // Set the real device handle
235 //DPRINT("UsbdDeviceHandle %x, ChildDeviceHandle %x\n", Urb->UrbHeader.UsbdDeviceHandle, ChildDeviceExtension->UsbDeviceHandle);
237 Urb
->UrbHeader
.UsbdDeviceHandle
= ChildDeviceExtension
->UsbDeviceHandle
;
242 switch (Urb
->UrbHeader
.Function
)
247 case URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE
:
248 DPRINT("URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE\n");
250 case URB_FUNCTION_CLASS_DEVICE
:
251 DPRINT("URB_FUNCTION_CLASS_DEVICE\n");
253 case URB_FUNCTION_GET_STATUS_FROM_DEVICE
:
254 DPRINT("URB_FUNCTION_GET_STATUS_FROM_DEVICE\n");
256 case URB_FUNCTION_SELECT_CONFIGURATION
:
257 DPRINT("URB_FUNCTION_SELECT_CONFIGURATION\n");
259 case URB_FUNCTION_SELECT_INTERFACE
:
260 DPRINT("URB_FUNCTION_SELECT_INTERFACE\n");
262 case URB_FUNCTION_CLASS_OTHER
:
263 DPRINT("URB_FUNCTION_CLASS_OTHER\n");
265 case URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER
:
268 DPRINT1("URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER\n");
269 DPRINT1("PipeHandle %x\n", Urb->UrbBulkOrInterruptTransfer.PipeHandle);
270 DPRINT1("TransferFlags %x\n", Urb->UrbBulkOrInterruptTransfer.TransferFlags);
271 DPRINT1("Buffer %x\n", Urb->UrbBulkOrInterruptTransfer.TransferBuffer);
272 DPRINT1("BufferMDL %x\n", Urb->UrbBulkOrInterruptTransfer.TransferBufferMDL);
273 DPRINT1("Length %x\n", Urb->UrbBulkOrInterruptTransfer.TransferBufferLength);
274 DPRINT1("UrbLink %x\n", Urb->UrbBulkOrInterruptTransfer.UrbLink);
275 DPRINT1("hca %x\n", Urb->UrbBulkOrInterruptTransfer.hca);
276 if (Urb->UrbBulkOrInterruptTransfer.TransferFlags == USBD_SHORT_TRANSFER_OK)
283 case URB_FUNCTION_CLASS_INTERFACE
:
284 DPRINT("URB_FUNCTION_CLASS_INTERFACE\n");
286 case URB_FUNCTION_VENDOR_DEVICE
:
287 DPRINT("URB_FUNCTION_VENDOR_DEVICE\n");
290 DPRINT1("IOCTL_INTERNAL_USB_SUBMIT_URB Function %x NOT IMPLEMENTED\n", Urb
->UrbHeader
.Function
);
293 Urb
->UrbHeader
.UsbdDeviceHandle
= ChildDeviceExtension
->UsbDeviceHandle
;
294 //DPRINT1("Stack->CompletionRoutine %x\n", Stack->CompletionRoutine);
296 // Send the request to RootHub
298 Status
= FowardUrbToRootHub(RootHubDeviceObject
, IOCTL_INTERNAL_USB_SUBMIT_URB
, Irp
, Urb
, NULL
);
302 // FIXME: Can these be sent to RootHub?
304 case IOCTL_INTERNAL_USB_RESET_PORT
:
305 DPRINT1("IOCTL_INTERNAL_USB_RESET_PORT\n");
307 case IOCTL_INTERNAL_USB_GET_PORT_STATUS
:
309 PORT_STATUS_CHANGE PortStatus
;
311 PUCHAR PortStatusBits
;
313 PortStatusBits
= (PUCHAR
)Stack
->Parameters
.Others
.Argument1
;
315 // USBD_PORT_ENABLED (bit 0) or USBD_PORT_CONNECTED (bit 1)
317 DPRINT1("IOCTL_INTERNAL_USB_GET_PORT_STATUS\n");
318 DPRINT("Arg1 %x\n", *PortStatusBits
);
320 if (Stack
->Parameters
.Others
.Argument1
)
322 for (PortId
= 1; PortId
<= HubDeviceExtension
->UsbExtHubInfo
.NumberOfPorts
; PortId
++)
324 Status
= GetPortStatusAndChange(RootHubDeviceObject
, PortId
, &PortStatus
);
325 if (NT_SUCCESS(Status
))
327 DPRINT("Connect %x\n", ((PortStatus
.Status
& USB_PORT_STATUS_CONNECT
) << 1) << ((PortId
- 1) * 2));
328 DPRINT("Enable %x\n", ((PortStatus
.Status
& USB_PORT_STATUS_ENABLE
) >> 1) << ((PortId
- 1) * 2));
330 (((PortStatus
.Status
& USB_PORT_STATUS_CONNECT
) << 1) << ((PortId
- 1) * 2)) +
331 (((PortStatus
.Status
& USB_PORT_STATUS_ENABLE
) >> 1) << ((PortId
- 1) * 2));
337 DPRINT1("Arg1 %x\n", *PortStatusBits
);
338 Status
= STATUS_SUCCESS
;
341 case IOCTL_INTERNAL_USB_ENABLE_PORT
:
342 DPRINT1("IOCTL_INTERNAL_USB_ENABLE_PORT\n");
344 case IOCTL_INTERNAL_USB_CYCLE_PORT
:
345 DPRINT1("IOCTL_INTERNAL_USB_CYCLE_PORT\n");
347 case IOCTL_INTERNAL_USB_GET_DEVICE_HANDLE
:
349 DPRINT1("IOCTL_INTERNAL_USB_GET_DEVICE_HANDLE\n");
350 if (Stack
->Parameters
.Others
.Argument1
)
352 // store device handle
353 *(PVOID
*)Stack
->Parameters
.Others
.Argument1
= (PVOID
)ChildDeviceExtension
->UsbDeviceHandle
;
354 Status
= STATUS_SUCCESS
;
359 Status
= STATUS_INVALID_PARAMETER
;
363 case IOCTL_INTERNAL_USB_GET_ROOTHUB_PDO
:
365 if (Stack
->Parameters
.Others
.Argument1
)
367 // inform caller that it is a real usb hub
368 *(PVOID
*)Stack
->Parameters
.Others
.Argument1
= NULL
;
371 if (Stack
->Parameters
.Others
.Argument2
)
373 // output device object
374 *(PVOID
*)Stack
->Parameters
.Others
.Argument2
= DeviceObject
;
378 Status
= STATUS_SUCCESS
;
383 DPRINT1("Unknown IOCTL code 0x%lx\n", Stack
->Parameters
.DeviceIoControl
.IoControlCode
);
384 Information
= Irp
->IoStatus
.Information
;
385 Status
= Irp
->IoStatus
.Status
;
389 if (Status
!= STATUS_PENDING
)
391 Irp
->IoStatus
.Information
= Information
;
392 Irp
->IoStatus
.Status
= Status
;
393 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
399 USBHUB_PdoStartDevice(
400 IN PDEVICE_OBJECT DeviceObject
,
403 PHUB_CHILDDEVICE_EXTENSION ChildDeviceExtension
;
405 DPRINT("USBHUB_PdoStartDevice %x\n", DeviceObject
);
406 ChildDeviceExtension
= (PHUB_CHILDDEVICE_EXTENSION
)DeviceObject
->DeviceExtension
;
409 // This should be a PDO
411 ASSERT(ChildDeviceExtension
->Common
.IsFDO
== FALSE
);
414 // register device interface
416 IoRegisterDeviceInterface(DeviceObject
, &GUID_DEVINTERFACE_USB_DEVICE
, NULL
, &ChildDeviceExtension
->SymbolicLinkName
);
417 IoSetDeviceInterfaceState(&ChildDeviceExtension
->SymbolicLinkName
, TRUE
);
420 return STATUS_SUCCESS
;
425 IN PDEVICE_OBJECT DeviceObject
,
427 OUT ULONG_PTR
* Information
)
429 PHUB_CHILDDEVICE_EXTENSION ChildDeviceExtension
;
431 PUNICODE_STRING SourceString
= NULL
;
432 PWCHAR ReturnString
= NULL
;
433 NTSTATUS Status
= STATUS_SUCCESS
;
435 IdType
= IoGetCurrentIrpStackLocation(Irp
)->Parameters
.QueryId
.IdType
;
436 ChildDeviceExtension
= (PHUB_CHILDDEVICE_EXTENSION
)DeviceObject
->DeviceExtension
;
440 case BusQueryDeviceID
:
442 DPRINT("IRP_MJ_PNP / IRP_MN_QUERY_ID / BusQueryDeviceID\n");
443 SourceString
= &ChildDeviceExtension
->usDeviceId
;
446 case BusQueryHardwareIDs
:
448 DPRINT("IRP_MJ_PNP / IRP_MN_QUERY_ID / BusQueryHardwareIDs\n");
449 SourceString
= &ChildDeviceExtension
->usHardwareIds
;
452 case BusQueryCompatibleIDs
:
454 DPRINT("IRP_MJ_PNP / IRP_MN_QUERY_ID / BusQueryCompatibleIDs\n");
455 SourceString
= &ChildDeviceExtension
->usCompatibleIds
;
458 case BusQueryInstanceID
:
460 DPRINT("IRP_MJ_PNP / IRP_MN_QUERY_ID / BusQueryInstanceID\n");
461 SourceString
= &ChildDeviceExtension
->usInstanceId
;
465 DPRINT1("IRP_MJ_PNP / IRP_MN_QUERY_ID / unknown query id type 0x%lx\n", IdType
);
466 return STATUS_NOT_SUPPORTED
;
474 ReturnString
= ExAllocatePool(PagedPool
, SourceString
->MaximumLength
);
480 return STATUS_INSUFFICIENT_RESOURCES
;
486 RtlCopyMemory(ReturnString
, SourceString
->Buffer
, SourceString
->MaximumLength
);
489 *Information
= (ULONG_PTR
)ReturnString
;
495 USBHUB_PdoQueryDeviceText(
496 IN PDEVICE_OBJECT DeviceObject
,
498 OUT ULONG_PTR
* Information
)
500 PHUB_CHILDDEVICE_EXTENSION ChildDeviceExtension
;
501 DEVICE_TEXT_TYPE DeviceTextType
;
502 PUNICODE_STRING SourceString
= NULL
;
503 PWCHAR ReturnString
= NULL
;
504 NTSTATUS Status
= STATUS_SUCCESS
;
506 DeviceTextType
= IoGetCurrentIrpStackLocation(Irp
)->Parameters
.QueryDeviceText
.DeviceTextType
;
507 ChildDeviceExtension
= (PHUB_CHILDDEVICE_EXTENSION
)DeviceObject
->DeviceExtension
;
513 switch (DeviceTextType
)
515 case DeviceTextDescription
:
516 case DeviceTextLocationInformation
:
518 DPRINT("IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_TEXT / DeviceTextDescription\n");
521 // does the device provide a text description
523 if (ChildDeviceExtension
->usTextDescription
.Buffer
&& ChildDeviceExtension
->usTextDescription
.Length
)
528 SourceString
= &ChildDeviceExtension
->usTextDescription
;
534 DPRINT1("IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_TEXT / unknown device text type 0x%lx\n", DeviceTextType
);
535 Status
= STATUS_NOT_SUPPORTED
;
542 ReturnString
= ExAllocatePool(PagedPool
, SourceString
->MaximumLength
);
543 RtlCopyMemory(ReturnString
, SourceString
->Buffer
, SourceString
->MaximumLength
);
544 DPRINT1("%S\n", ReturnString
);
545 *Information
= (ULONG_PTR
)ReturnString
;
553 IN PDEVICE_OBJECT DeviceObject
,
558 PIO_STACK_LOCATION Stack
;
559 ULONG_PTR Information
= 0;
560 PHUB_CHILDDEVICE_EXTENSION UsbChildExtension
;
563 PDEVICE_RELATIONS DeviceRelation
;
564 PDEVICE_OBJECT ParentDevice
;
566 UsbChildExtension
= (PHUB_CHILDDEVICE_EXTENSION
)DeviceObject
->DeviceExtension
;
567 Stack
= IoGetCurrentIrpStackLocation(Irp
);
568 MinorFunction
= Stack
->MinorFunction
;
570 switch (MinorFunction
)
572 case IRP_MN_START_DEVICE
:
574 DPRINT("IRP_MJ_PNP / IRP_MN_START_DEVICE\n");
575 Status
= USBHUB_PdoStartDevice(DeviceObject
, Irp
);
578 case IRP_MN_QUERY_CAPABILITIES
:
580 PDEVICE_CAPABILITIES DeviceCapabilities
;
582 DPRINT("IRP_MJ_PNP / IRP_MN_QUERY_CAPABILITIES\n");
584 DeviceCapabilities
= (PDEVICE_CAPABILITIES
)Stack
->Parameters
.DeviceCapabilities
.Capabilities
;
585 // FIXME: capabilities can change with connected device
586 DeviceCapabilities
->LockSupported
= FALSE
;
587 DeviceCapabilities
->EjectSupported
= FALSE
;
588 DeviceCapabilities
->Removable
= TRUE
;
589 DeviceCapabilities
->DockDevice
= FALSE
;
590 DeviceCapabilities
->UniqueID
= FALSE
;
591 DeviceCapabilities
->SilentInstall
= FALSE
;
592 DeviceCapabilities
->RawDeviceOK
= FALSE
;
593 DeviceCapabilities
->SurpriseRemovalOK
= FALSE
;
594 DeviceCapabilities
->HardwareDisabled
= FALSE
;
595 //DeviceCapabilities->NoDisplayInUI = FALSE;
596 DeviceCapabilities
->Address
= UsbChildExtension
->PortNumber
;
597 DeviceCapabilities
->UINumber
= 0;
598 DeviceCapabilities
->DeviceState
[0] = PowerDeviceD0
;
599 for (i
= 1; i
< PowerSystemMaximum
; i
++)
600 DeviceCapabilities
->DeviceState
[i
] = PowerDeviceD3
;
601 //DeviceCapabilities->DeviceWake = PowerDeviceUndefined;
602 DeviceCapabilities
->D1Latency
= 0;
603 DeviceCapabilities
->D2Latency
= 0;
604 DeviceCapabilities
->D3Latency
= 0;
605 Status
= STATUS_SUCCESS
;
608 case IRP_MN_QUERY_RESOURCES
:
610 DPRINT("IRP_MJ_PNP / IRP_MN_QUERY_RESOURCES\n");
612 Information
= Irp
->IoStatus
.Information
;
613 Status
= Irp
->IoStatus
.Status
;
616 case IRP_MN_QUERY_RESOURCE_REQUIREMENTS
:
618 DPRINT("IRP_MJ_PNP / IRP_MN_QUERY_RESOURCE_REQUIREMENTS\n");
620 Information
= Irp
->IoStatus
.Information
;
621 Status
= Irp
->IoStatus
.Status
;
624 case IRP_MN_QUERY_DEVICE_TEXT
:
626 Status
= USBHUB_PdoQueryDeviceText(DeviceObject
, Irp
, &Information
);
629 case IRP_MN_QUERY_ID
:
631 Status
= USBHUB_PdoQueryId(DeviceObject
, Irp
, &Information
);
634 case IRP_MN_QUERY_BUS_INFORMATION
:
636 PPNP_BUS_INFORMATION BusInfo
;
637 BusInfo
= (PPNP_BUS_INFORMATION
)ExAllocatePool(PagedPool
, sizeof(PNP_BUS_INFORMATION
));
638 RtlCopyMemory(&BusInfo
->BusTypeGuid
,
640 sizeof(BusInfo
->BusTypeGuid
));
641 BusInfo
->LegacyBusType
= PNPBus
;
643 BusInfo
->BusNumber
= 0;
644 Information
= (ULONG_PTR
)BusInfo
;
645 Status
= STATUS_SUCCESS
;
648 case IRP_MN_REMOVE_DEVICE
:
650 PHUB_DEVICE_EXTENSION HubDeviceExtension
= (PHUB_DEVICE_EXTENSION
)UsbChildExtension
->ParentDeviceObject
->DeviceExtension
;
651 PUSB_BUS_INTERFACE_HUB_V5 HubInterface
= &HubDeviceExtension
->HubInterface
;
652 ParentDevice
= UsbChildExtension
->ParentDeviceObject
;
654 DPRINT("IRP_MJ_PNP / IRP_MN_REMOVE_DEVICE\n");
656 /* remove us from pdo list */
658 for(Index
= 0; Index
< USB_MAXCHILDREN
; Index
++)
660 if (HubDeviceExtension
->ChildDeviceObject
[Index
] == DeviceObject
)
662 /* Remove the device */
663 Status
= HubInterface
->RemoveUsbDevice(HubDeviceExtension
->UsbDInterface
.BusContext
, UsbChildExtension
->UsbDeviceHandle
, 0);
665 /* FIXME handle error */
666 ASSERT(Status
== STATUS_SUCCESS
);
669 HubDeviceExtension
->ChildDeviceObject
[Index
] = NULL
;
675 /* Complete the IRP */
676 Irp
->IoStatus
.Status
= STATUS_SUCCESS
;
677 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
680 IoDeleteDevice(DeviceObject
);
684 /* invalidate device relations */
685 IoInvalidateDeviceRelations(ParentDevice
, BusRelations
);
688 return STATUS_SUCCESS
;
690 case IRP_MN_QUERY_DEVICE_RELATIONS
:
692 /* only target relations are supported */
693 if (Stack
->Parameters
.QueryDeviceRelations
.Type
!= TargetDeviceRelation
)
696 Status
= Irp
->IoStatus
.Status
;
700 /* allocate device relations */
701 DeviceRelation
= (PDEVICE_RELATIONS
)ExAllocatePool(NonPagedPool
, sizeof(DEVICE_RELATIONS
));
705 Status
= STATUS_INSUFFICIENT_RESOURCES
;
709 /* init device relation */
710 DeviceRelation
->Count
= 1;
711 DeviceRelation
->Objects
[0] = DeviceObject
;
712 ObReferenceObject(DeviceRelation
->Objects
[0]);
715 Irp
->IoStatus
.Information
= (ULONG_PTR
)DeviceRelation
;
716 Status
= STATUS_SUCCESS
;
719 case IRP_MN_QUERY_STOP_DEVICE
:
720 case IRP_MN_QUERY_REMOVE_DEVICE
:
722 /* Sure, no problem */
723 Status
= STATUS_SUCCESS
;
727 case IRP_MN_QUERY_INTERFACE
:
729 DPRINT1("IRP_MN_QUERY_INTERFACE\n");
730 if (IsEqualGUIDAligned(Stack
->Parameters
.QueryInterface
.InterfaceType
, &USB_BUS_INTERFACE_USBDI_GUID
))
732 DPRINT1("USB_BUS_INTERFACE_USBDI_GUID\n");
733 RtlCopyMemory(Stack
->Parameters
.QueryInterface
.Interface
, &UsbChildExtension
->DeviceInterface
, Stack
->Parameters
.QueryInterface
.Size
);
734 Status
= STATUS_SUCCESS
;
739 IoSkipCurrentIrpStackLocation(Irp
);
740 return IoCallDriver(UsbChildExtension
->ParentDeviceObject
, Irp
);
742 case IRP_MN_SURPRISE_REMOVAL
:
744 DPRINT("[USBHUB] HandlePnp IRP_MN_SURPRISE_REMOVAL\n");
745 Status
= STATUS_SUCCESS
;
750 DPRINT1("PDO IRP_MJ_PNP / unknown minor function 0x%lx\n", MinorFunction
);
751 Information
= Irp
->IoStatus
.Information
;
752 Status
= Irp
->IoStatus
.Status
;
756 Irp
->IoStatus
.Information
= Information
;
757 Irp
->IoStatus
.Status
= Status
;
758 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);