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 // Free our allocated IRP
57 // Return this status so the IO Manager doesnt mess with the Irp
59 return STATUS_MORE_PROCESSING_REQUIRED
;
64 PDEVICE_OBJECT RootHubDeviceObject
,
65 IN ULONG IoControlCode
,
67 OUT PVOID OutParameter1
,
68 OUT PVOID OutParameter2
)
71 IO_STATUS_BLOCK IoStatus
;
72 PIO_STACK_LOCATION ForwardStack
, CurrentStack
;
76 // Get the current stack location for the Irp
78 CurrentStack
= IoGetCurrentIrpStackLocation(Irp
);
82 // Pull the Urb from that stack, it will be reused in the Irp sent to RootHub
84 Urb
= (PURB
)CurrentStack
->Parameters
.Others
.Argument1
;
88 // Create the Irp to forward to RootHub
90 ForwardIrp
= IoBuildAsynchronousFsdRequest(IRP_MJ_SHUTDOWN
,
98 DPRINT1("Failed to allocate IRP\n");
99 return STATUS_INSUFFICIENT_RESOURCES
;
103 // Get the new Irps next stack
105 ForwardStack
= IoGetNextIrpStackLocation(ForwardIrp
);
108 // Copy the stack for the current irp into the next stack of new irp
110 RtlCopyMemory(ForwardStack
, CurrentStack
, sizeof(IO_STACK_LOCATION
));
112 IoStatus
.Status
= STATUS_NOT_SUPPORTED
;
113 IoStatus
.Information
= 0;
116 // Mark the Irp from upper driver as pending
118 IoMarkIrpPending(Irp
);
121 // Now set the completion routine for the new Irp.
123 IoSetCompletionRoutine(ForwardIrp
,
130 IoCallDriver(RootHubDeviceObject
, ForwardIrp
);
133 // Always return pending as the completion routine will take care of it
135 return STATUS_PENDING
;
140 IN PDEVICE_OBJECT DeviceObject
)
143 PHUB_DEVICE_EXTENSION HubDeviceExtension
;
144 PHUB_CHILDDEVICE_EXTENSION ChildDeviceExtension
;
147 ChildDeviceExtension
= (PHUB_CHILDDEVICE_EXTENSION
)DeviceObject
->DeviceExtension
;
148 ASSERT(ChildDeviceExtension
->Common
.IsFDO
== FALSE
);
149 HubDeviceExtension
= (PHUB_DEVICE_EXTENSION
)ChildDeviceExtension
->ParentDeviceObject
->DeviceExtension
;
151 for(Index
= 0; Index
< USB_MAXCHILDREN
; Index
++)
153 if (HubDeviceExtension
->ChildDeviceObject
[Index
] == DeviceObject
)
166 USBHUB_PdoHandleInternalDeviceControl(
167 IN PDEVICE_OBJECT DeviceObject
,
171 PIO_STACK_LOCATION Stack
;
172 ULONG_PTR Information
= 0;
173 PHUB_DEVICE_EXTENSION HubDeviceExtension
;
174 PHUB_CHILDDEVICE_EXTENSION ChildDeviceExtension
;
175 PDEVICE_OBJECT RootHubDeviceObject
;
178 //DPRINT1("UsbhubInternalDeviceControlPdo(%x) called\n", DeviceObject);
181 // get current stack location
183 Stack
= IoGetCurrentIrpStackLocation(Irp
);
187 // Set default status
189 Status
= Irp
->IoStatus
.Status
;
191 ChildDeviceExtension
= (PHUB_CHILDDEVICE_EXTENSION
)DeviceObject
->DeviceExtension
;
192 ASSERT(ChildDeviceExtension
->Common
.IsFDO
== FALSE
);
193 HubDeviceExtension
= (PHUB_DEVICE_EXTENSION
)ChildDeviceExtension
->ParentDeviceObject
->DeviceExtension
;
194 RootHubDeviceObject
= HubDeviceExtension
->RootHubPhysicalDeviceObject
;
196 if(!IsValidPDO(DeviceObject
))
198 DPRINT1("[USBHUB] Request for removed device object %p\n", DeviceObject
);
199 Irp
->IoStatus
.Status
= STATUS_DEVICE_NOT_CONNECTED
;
200 Irp
->IoStatus
.Information
= 0;
201 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
202 return STATUS_DEVICE_NOT_CONNECTED
;
205 switch (Stack
->Parameters
.DeviceIoControl
.IoControlCode
)
207 case IOCTL_INTERNAL_USB_GET_PARENT_HUB_INFO
:
209 DPRINT("IOCTL_INTERNAL_USB_GET_PARENT_HUB_INFO\n");
210 if (Irp
->AssociatedIrp
.SystemBuffer
== NULL
211 || Stack
->Parameters
.DeviceIoControl
.OutputBufferLength
!= sizeof(PVOID
))
213 Status
= STATUS_INVALID_PARAMETER
;
219 pHubPointer
= (PVOID
*)Irp
->AssociatedIrp
.SystemBuffer
;
222 Information
= sizeof(PVOID
);
223 Status
= STATUS_SUCCESS
;
227 case IOCTL_INTERNAL_USB_SUBMIT_URB
:
229 //DPRINT1("IOCTL_INTERNAL_USB_SUBMIT_URB\n");
234 Urb
= (PURB
)Stack
->Parameters
.Others
.Argument1
;
238 // Set the real device handle
240 //DPRINT("UsbdDeviceHandle %x, ChildDeviceHandle %x\n", Urb->UrbHeader.UsbdDeviceHandle, ChildDeviceExtension->UsbDeviceHandle);
242 Urb
->UrbHeader
.UsbdDeviceHandle
= ChildDeviceExtension
->UsbDeviceHandle
;
247 switch (Urb
->UrbHeader
.Function
)
252 case URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE
:
253 DPRINT("URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE\n");
255 case URB_FUNCTION_CLASS_DEVICE
:
256 DPRINT("URB_FUNCTION_CLASS_DEVICE\n");
258 case URB_FUNCTION_GET_STATUS_FROM_DEVICE
:
259 DPRINT("URB_FUNCTION_GET_STATUS_FROM_DEVICE\n");
261 case URB_FUNCTION_SELECT_CONFIGURATION
:
262 DPRINT("URB_FUNCTION_SELECT_CONFIGURATION\n");
264 case URB_FUNCTION_SELECT_INTERFACE
:
265 DPRINT("URB_FUNCTION_SELECT_INTERFACE\n");
267 case URB_FUNCTION_CLASS_OTHER
:
268 DPRINT("URB_FUNCTION_CLASS_OTHER\n");
270 case URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER
:
273 DPRINT1("URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER\n");
274 DPRINT1("PipeHandle %x\n", Urb->UrbBulkOrInterruptTransfer.PipeHandle);
275 DPRINT1("TransferFlags %x\n", Urb->UrbBulkOrInterruptTransfer.TransferFlags);
276 DPRINT1("Buffer %x\n", Urb->UrbBulkOrInterruptTransfer.TransferBuffer);
277 DPRINT1("BufferMDL %x\n", Urb->UrbBulkOrInterruptTransfer.TransferBufferMDL);
278 DPRINT1("Length %x\n", Urb->UrbBulkOrInterruptTransfer.TransferBufferLength);
279 DPRINT1("UrbLink %x\n", Urb->UrbBulkOrInterruptTransfer.UrbLink);
280 DPRINT1("hca %x\n", Urb->UrbBulkOrInterruptTransfer.hca);
281 if (Urb->UrbBulkOrInterruptTransfer.TransferFlags == USBD_SHORT_TRANSFER_OK)
288 case URB_FUNCTION_CLASS_INTERFACE
:
289 DPRINT("URB_FUNCTION_CLASS_INTERFACE\n");
291 case URB_FUNCTION_VENDOR_DEVICE
:
292 DPRINT("URB_FUNCTION_VENDOR_DEVICE\n");
295 DPRINT1("IOCTL_INTERNAL_USB_SUBMIT_URB Function %x NOT IMPLEMENTED\n", Urb
->UrbHeader
.Function
);
298 Urb
->UrbHeader
.UsbdDeviceHandle
= ChildDeviceExtension
->UsbDeviceHandle
;
299 //DPRINT1("Stack->CompletionRoutine %x\n", Stack->CompletionRoutine);
301 // Send the request to RootHub
303 Status
= FowardUrbToRootHub(RootHubDeviceObject
, IOCTL_INTERNAL_USB_SUBMIT_URB
, Irp
, Urb
, NULL
);
307 // FIXME: Can these be sent to RootHub?
309 case IOCTL_INTERNAL_USB_RESET_PORT
:
310 DPRINT1("IOCTL_INTERNAL_USB_RESET_PORT\n");
312 case IOCTL_INTERNAL_USB_GET_PORT_STATUS
:
314 PORT_STATUS_CHANGE PortStatus
;
316 PUCHAR PortStatusBits
;
318 PortStatusBits
= (PUCHAR
)Stack
->Parameters
.Others
.Argument1
;
320 // USBD_PORT_ENABLED (bit 0) or USBD_PORT_CONNECTED (bit 1)
322 DPRINT1("IOCTL_INTERNAL_USB_GET_PORT_STATUS\n");
323 DPRINT("Arg1 %x\n", *PortStatusBits
);
325 if (Stack
->Parameters
.Others
.Argument1
)
327 for (PortId
= 1; PortId
<= HubDeviceExtension
->UsbExtHubInfo
.NumberOfPorts
; PortId
++)
329 Status
= GetPortStatusAndChange(RootHubDeviceObject
, PortId
, &PortStatus
);
330 if (NT_SUCCESS(Status
))
332 DPRINT("Connect %x\n", ((PortStatus
.Status
& USB_PORT_STATUS_CONNECT
) << 1) << ((PortId
- 1) * 2));
333 DPRINT("Enable %x\n", ((PortStatus
.Status
& USB_PORT_STATUS_ENABLE
) >> 1) << ((PortId
- 1) * 2));
335 (((PortStatus
.Status
& USB_PORT_STATUS_CONNECT
) << 1) << ((PortId
- 1) * 2)) +
336 (((PortStatus
.Status
& USB_PORT_STATUS_ENABLE
) >> 1) << ((PortId
- 1) * 2));
342 DPRINT1("Arg1 %x\n", *PortStatusBits
);
343 Status
= STATUS_SUCCESS
;
346 case IOCTL_INTERNAL_USB_ENABLE_PORT
:
347 DPRINT1("IOCTL_INTERNAL_USB_ENABLE_PORT\n");
349 case IOCTL_INTERNAL_USB_CYCLE_PORT
:
350 DPRINT1("IOCTL_INTERNAL_USB_CYCLE_PORT\n");
352 case IOCTL_INTERNAL_USB_GET_DEVICE_HANDLE
:
354 DPRINT1("IOCTL_INTERNAL_USB_GET_DEVICE_HANDLE\n");
355 if (Stack
->Parameters
.Others
.Argument1
)
357 // store device handle
358 *(PVOID
*)Stack
->Parameters
.Others
.Argument1
= (PVOID
)ChildDeviceExtension
->UsbDeviceHandle
;
359 Status
= STATUS_SUCCESS
;
364 Status
= STATUS_INVALID_PARAMETER
;
368 case IOCTL_INTERNAL_USB_GET_ROOTHUB_PDO
:
370 if (Stack
->Parameters
.Others
.Argument1
)
372 // inform caller that it is a real usb hub
373 *(PVOID
*)Stack
->Parameters
.Others
.Argument1
= NULL
;
376 if (Stack
->Parameters
.Others
.Argument2
)
378 // output device object
379 *(PVOID
*)Stack
->Parameters
.Others
.Argument2
= DeviceObject
;
383 Status
= STATUS_SUCCESS
;
388 DPRINT1("Unknown IOCTL code 0x%lx\n", Stack
->Parameters
.DeviceIoControl
.IoControlCode
);
389 Information
= Irp
->IoStatus
.Information
;
390 Status
= Irp
->IoStatus
.Status
;
394 if (Status
!= STATUS_PENDING
)
396 Irp
->IoStatus
.Information
= Information
;
397 Irp
->IoStatus
.Status
= Status
;
398 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
404 USBHUB_PdoStartDevice(
405 IN PDEVICE_OBJECT DeviceObject
,
408 PHUB_CHILDDEVICE_EXTENSION ChildDeviceExtension
;
410 DPRINT("USBHUB_PdoStartDevice %x\n", DeviceObject
);
411 ChildDeviceExtension
= (PHUB_CHILDDEVICE_EXTENSION
)DeviceObject
->DeviceExtension
;
414 // This should be a PDO
416 ASSERT(ChildDeviceExtension
->Common
.IsFDO
== FALSE
);
419 // register device interface
421 IoRegisterDeviceInterface(DeviceObject
, &GUID_DEVINTERFACE_USB_DEVICE
, NULL
, &ChildDeviceExtension
->SymbolicLinkName
);
422 IoSetDeviceInterfaceState(&ChildDeviceExtension
->SymbolicLinkName
, TRUE
);
425 return STATUS_SUCCESS
;
430 IN PDEVICE_OBJECT DeviceObject
,
432 OUT ULONG_PTR
* Information
)
434 PHUB_CHILDDEVICE_EXTENSION ChildDeviceExtension
;
436 PUNICODE_STRING SourceString
= NULL
;
437 PWCHAR ReturnString
= NULL
;
438 NTSTATUS Status
= STATUS_SUCCESS
;
440 IdType
= IoGetCurrentIrpStackLocation(Irp
)->Parameters
.QueryId
.IdType
;
441 ChildDeviceExtension
= (PHUB_CHILDDEVICE_EXTENSION
)DeviceObject
->DeviceExtension
;
445 case BusQueryDeviceID
:
447 DPRINT("IRP_MJ_PNP / IRP_MN_QUERY_ID / BusQueryDeviceID\n");
448 SourceString
= &ChildDeviceExtension
->usDeviceId
;
451 case BusQueryHardwareIDs
:
453 DPRINT("IRP_MJ_PNP / IRP_MN_QUERY_ID / BusQueryHardwareIDs\n");
454 SourceString
= &ChildDeviceExtension
->usHardwareIds
;
457 case BusQueryCompatibleIDs
:
459 DPRINT("IRP_MJ_PNP / IRP_MN_QUERY_ID / BusQueryCompatibleIDs\n");
460 SourceString
= &ChildDeviceExtension
->usCompatibleIds
;
463 case BusQueryInstanceID
:
465 DPRINT("IRP_MJ_PNP / IRP_MN_QUERY_ID / BusQueryInstanceID\n");
466 SourceString
= &ChildDeviceExtension
->usInstanceId
;
470 DPRINT1("IRP_MJ_PNP / IRP_MN_QUERY_ID / unknown query id type 0x%lx\n", IdType
);
471 return STATUS_NOT_SUPPORTED
;
479 ReturnString
= ExAllocatePool(PagedPool
, SourceString
->MaximumLength
);
485 return STATUS_INSUFFICIENT_RESOURCES
;
491 RtlCopyMemory(ReturnString
, SourceString
->Buffer
, SourceString
->MaximumLength
);
494 *Information
= (ULONG_PTR
)ReturnString
;
500 USBHUB_PdoQueryDeviceText(
501 IN PDEVICE_OBJECT DeviceObject
,
503 OUT ULONG_PTR
* Information
)
505 PHUB_CHILDDEVICE_EXTENSION ChildDeviceExtension
;
506 DEVICE_TEXT_TYPE DeviceTextType
;
507 PUNICODE_STRING SourceString
= NULL
;
508 PWCHAR ReturnString
= NULL
;
509 NTSTATUS Status
= STATUS_SUCCESS
;
511 DeviceTextType
= IoGetCurrentIrpStackLocation(Irp
)->Parameters
.QueryDeviceText
.DeviceTextType
;
512 ChildDeviceExtension
= (PHUB_CHILDDEVICE_EXTENSION
)DeviceObject
->DeviceExtension
;
518 switch (DeviceTextType
)
520 case DeviceTextDescription
:
521 case DeviceTextLocationInformation
:
523 DPRINT("IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_TEXT / DeviceTextDescription\n");
526 // does the device provide a text description
528 if (ChildDeviceExtension
->usTextDescription
.Buffer
&& ChildDeviceExtension
->usTextDescription
.Length
)
533 SourceString
= &ChildDeviceExtension
->usTextDescription
;
539 DPRINT1("IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_TEXT / unknown device text type 0x%lx\n", DeviceTextType
);
540 Status
= STATUS_NOT_SUPPORTED
;
547 ReturnString
= ExAllocatePool(PagedPool
, SourceString
->MaximumLength
);
548 RtlCopyMemory(ReturnString
, SourceString
->Buffer
, SourceString
->MaximumLength
);
549 DPRINT1("%S\n", ReturnString
);
550 *Information
= (ULONG_PTR
)ReturnString
;
558 IN PDEVICE_OBJECT DeviceObject
,
563 PIO_STACK_LOCATION Stack
;
564 ULONG_PTR Information
= 0;
565 PHUB_CHILDDEVICE_EXTENSION UsbChildExtension
;
568 PDEVICE_RELATIONS DeviceRelation
;
569 PDEVICE_OBJECT ParentDevice
;
571 UsbChildExtension
= (PHUB_CHILDDEVICE_EXTENSION
)DeviceObject
->DeviceExtension
;
572 Stack
= IoGetCurrentIrpStackLocation(Irp
);
573 MinorFunction
= Stack
->MinorFunction
;
575 switch (MinorFunction
)
577 case IRP_MN_START_DEVICE
:
579 DPRINT("IRP_MJ_PNP / IRP_MN_START_DEVICE\n");
580 Status
= USBHUB_PdoStartDevice(DeviceObject
, Irp
);
583 case IRP_MN_QUERY_CAPABILITIES
:
585 PDEVICE_CAPABILITIES DeviceCapabilities
;
587 DPRINT("IRP_MJ_PNP / IRP_MN_QUERY_CAPABILITIES\n");
589 DeviceCapabilities
= (PDEVICE_CAPABILITIES
)Stack
->Parameters
.DeviceCapabilities
.Capabilities
;
590 // FIXME: capabilities can change with connected device
591 DeviceCapabilities
->LockSupported
= FALSE
;
592 DeviceCapabilities
->EjectSupported
= FALSE
;
593 DeviceCapabilities
->Removable
= TRUE
;
594 DeviceCapabilities
->DockDevice
= FALSE
;
595 DeviceCapabilities
->UniqueID
= FALSE
;
596 DeviceCapabilities
->SilentInstall
= FALSE
;
597 DeviceCapabilities
->RawDeviceOK
= FALSE
;
598 DeviceCapabilities
->SurpriseRemovalOK
= FALSE
;
599 DeviceCapabilities
->HardwareDisabled
= FALSE
;
600 //DeviceCapabilities->NoDisplayInUI = FALSE;
601 DeviceCapabilities
->Address
= UsbChildExtension
->PortNumber
;
602 DeviceCapabilities
->UINumber
= 0;
603 DeviceCapabilities
->DeviceState
[0] = PowerDeviceD0
;
604 for (i
= 1; i
< PowerSystemMaximum
; i
++)
605 DeviceCapabilities
->DeviceState
[i
] = PowerDeviceD3
;
606 //DeviceCapabilities->DeviceWake = PowerDeviceUndefined;
607 DeviceCapabilities
->D1Latency
= 0;
608 DeviceCapabilities
->D2Latency
= 0;
609 DeviceCapabilities
->D3Latency
= 0;
610 Status
= STATUS_SUCCESS
;
613 case IRP_MN_QUERY_RESOURCES
:
615 DPRINT("IRP_MJ_PNP / IRP_MN_QUERY_RESOURCES\n");
617 Information
= Irp
->IoStatus
.Information
;
618 Status
= Irp
->IoStatus
.Status
;
621 case IRP_MN_QUERY_RESOURCE_REQUIREMENTS
:
623 DPRINT("IRP_MJ_PNP / IRP_MN_QUERY_RESOURCE_REQUIREMENTS\n");
625 Information
= Irp
->IoStatus
.Information
;
626 Status
= Irp
->IoStatus
.Status
;
629 case IRP_MN_QUERY_DEVICE_TEXT
:
631 Status
= USBHUB_PdoQueryDeviceText(DeviceObject
, Irp
, &Information
);
634 case IRP_MN_QUERY_ID
:
636 Status
= USBHUB_PdoQueryId(DeviceObject
, Irp
, &Information
);
639 case IRP_MN_QUERY_BUS_INFORMATION
:
641 PPNP_BUS_INFORMATION BusInfo
;
642 BusInfo
= (PPNP_BUS_INFORMATION
)ExAllocatePool(PagedPool
, sizeof(PNP_BUS_INFORMATION
));
643 RtlCopyMemory(&BusInfo
->BusTypeGuid
,
645 sizeof(BusInfo
->BusTypeGuid
));
646 BusInfo
->LegacyBusType
= PNPBus
;
648 BusInfo
->BusNumber
= 0;
649 Information
= (ULONG_PTR
)BusInfo
;
650 Status
= STATUS_SUCCESS
;
653 case IRP_MN_REMOVE_DEVICE
:
655 PHUB_DEVICE_EXTENSION HubDeviceExtension
= (PHUB_DEVICE_EXTENSION
)UsbChildExtension
->ParentDeviceObject
->DeviceExtension
;
656 PUSB_BUS_INTERFACE_HUB_V5 HubInterface
= &HubDeviceExtension
->HubInterface
;
657 ParentDevice
= UsbChildExtension
->ParentDeviceObject
;
659 DPRINT("IRP_MJ_PNP / IRP_MN_REMOVE_DEVICE\n");
661 /* remove us from pdo list */
663 for(Index
= 0; Index
< USB_MAXCHILDREN
; Index
++)
665 if (HubDeviceExtension
->ChildDeviceObject
[Index
] == DeviceObject
)
667 /* Remove the device */
668 Status
= HubInterface
->RemoveUsbDevice(HubDeviceExtension
->UsbDInterface
.BusContext
, UsbChildExtension
->UsbDeviceHandle
, 0);
670 /* FIXME handle error */
671 ASSERT(Status
== STATUS_SUCCESS
);
674 HubDeviceExtension
->ChildDeviceObject
[Index
] = NULL
;
680 /* Complete the IRP */
681 Irp
->IoStatus
.Status
= STATUS_SUCCESS
;
682 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
685 IoDeleteDevice(DeviceObject
);
689 /* invalidate device relations */
690 IoInvalidateDeviceRelations(ParentDevice
, BusRelations
);
693 return STATUS_SUCCESS
;
695 case IRP_MN_QUERY_DEVICE_RELATIONS
:
697 /* only target relations are supported */
698 if (Stack
->Parameters
.QueryDeviceRelations
.Type
!= TargetDeviceRelation
)
701 Status
= Irp
->IoStatus
.Status
;
705 /* allocate device relations */
706 DeviceRelation
= (PDEVICE_RELATIONS
)ExAllocatePool(NonPagedPool
, sizeof(DEVICE_RELATIONS
));
710 Status
= STATUS_INSUFFICIENT_RESOURCES
;
714 /* init device relation */
715 DeviceRelation
->Count
= 1;
716 DeviceRelation
->Objects
[0] = DeviceObject
;
717 ObReferenceObject(DeviceRelation
->Objects
[0]);
720 Irp
->IoStatus
.Information
= (ULONG_PTR
)DeviceRelation
;
721 Status
= STATUS_SUCCESS
;
724 case IRP_MN_QUERY_STOP_DEVICE
:
725 case IRP_MN_QUERY_REMOVE_DEVICE
:
727 /* Sure, no problem */
728 Status
= STATUS_SUCCESS
;
732 case IRP_MN_QUERY_INTERFACE
:
734 DPRINT1("IRP_MN_QUERY_INTERFACE\n");
735 if (IsEqualGUIDAligned(Stack
->Parameters
.QueryInterface
.InterfaceType
, &USB_BUS_INTERFACE_USBDI_GUID
))
737 DPRINT1("USB_BUS_INTERFACE_USBDI_GUID\n");
738 RtlCopyMemory(Stack
->Parameters
.QueryInterface
.Interface
, &UsbChildExtension
->DeviceInterface
, Stack
->Parameters
.QueryInterface
.Size
);
739 Status
= STATUS_SUCCESS
;
744 IoSkipCurrentIrpStackLocation(Irp
);
745 return IoCallDriver(UsbChildExtension
->ParentDeviceObject
, Irp
);
747 case IRP_MN_SURPRISE_REMOVAL
:
749 DPRINT("[USBHUB] HandlePnp IRP_MN_SURPRISE_REMOVAL\n");
750 Status
= STATUS_SUCCESS
;
755 DPRINT1("PDO IRP_MJ_PNP / unknown minor function 0x%lx\n", MinorFunction
);
756 Information
= Irp
->IoStatus
.Information
;
757 Status
= Irp
->IoStatus
.Status
;
761 Irp
->IoStatus
.Information
= Information
;
762 Irp
->IoStatus
.Status
= Status
;
763 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);