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/usbccgp/pdo.c
5 * PURPOSE: USB device driver.
7 * Michael Martin (michael.martin@reactos.org)
8 * Johannes Anderwald (johannes.anderwald@reactos.org)
15 USBCCGP_PdoHandleQueryDeviceText(
16 IN PDEVICE_OBJECT DeviceObject
,
20 PPDO_DEVICE_EXTENSION PDODeviceExtension
;
21 LPWSTR GenericString
= L
"Composite USB Device";
23 // get device extension
25 PDODeviceExtension
= (PPDO_DEVICE_EXTENSION
)DeviceObject
->DeviceExtension
;
28 // is there a device description
30 if (PDODeviceExtension
->FunctionDescriptor
->FunctionDescription
.Length
)
35 Buffer
= AllocateItem(NonPagedPool
, PDODeviceExtension
->FunctionDescriptor
->FunctionDescription
.Length
+ sizeof(WCHAR
));
41 return STATUS_INSUFFICIENT_RESOURCES
;
47 Irp
->IoStatus
.Information
= (ULONG_PTR
)Buffer
;
48 RtlCopyMemory(Buffer
, PDODeviceExtension
->FunctionDescriptor
->FunctionDescription
.Buffer
, PDODeviceExtension
->FunctionDescriptor
->FunctionDescription
.Length
);
49 return STATUS_SUCCESS
;
53 // FIXME use GenericCompositeUSBDeviceString
56 Buffer
= AllocateItem(PagedPool
, (wcslen(GenericString
) + 1) * sizeof(WCHAR
));
62 return STATUS_INSUFFICIENT_RESOURCES
;
64 RtlCopyMemory(Buffer
, GenericString
, (wcslen(GenericString
) + 1) * sizeof(WCHAR
));
65 Irp
->IoStatus
.Information
= (ULONG_PTR
)Buffer
;
67 return STATUS_SUCCESS
;
71 USBCCGP_PdoHandleDeviceRelations(
72 IN PDEVICE_OBJECT DeviceObject
,
75 PDEVICE_RELATIONS DeviceRelations
;
76 PIO_STACK_LOCATION IoStack
;
78 DPRINT1("USBCCGP_PdoHandleDeviceRelations\n");
81 // get current irp stack location
83 IoStack
= IoGetCurrentIrpStackLocation(Irp
);
86 // check if relation type is BusRelations
88 if (IoStack
->Parameters
.QueryDeviceRelations
.Type
!= TargetDeviceRelation
)
91 // PDO handles only target device relation
93 return Irp
->IoStatus
.Status
;
97 // allocate device relations
99 DeviceRelations
= (PDEVICE_RELATIONS
)AllocateItem(PagedPool
, sizeof(DEVICE_RELATIONS
));
100 if (!DeviceRelations
)
105 return STATUS_INSUFFICIENT_RESOURCES
;
109 // initialize device relations
111 DeviceRelations
->Count
= 1;
112 DeviceRelations
->Objects
[0] = DeviceObject
;
113 ObReferenceObject(DeviceObject
);
118 Irp
->IoStatus
.Information
= (ULONG_PTR
)DeviceRelations
;
121 // completed successfully
123 return STATUS_SUCCESS
;
127 USBCCGP_PdoAppendInterfaceNumber(
129 IN ULONG InterfaceNumber
,
130 OUT LPWSTR
*OutString
)
132 ULONG Length
= 0, StringLength
;
136 // count length of string
141 StringLength
= wcslen(String
) + 1;
142 Length
+= StringLength
;
143 Length
+= 6; //&MI_XX
144 String
+= StringLength
;
148 // now allocate the buffer
150 String
= AllocateItem(NonPagedPool
, (Length
+ 2) * sizeof(WCHAR
));
156 return STATUS_INSUFFICIENT_RESOURCES
;
166 StringLength
= swprintf(String
, L
"%s&MI_%02x", DeviceId
) + 1;
167 Length
= wcslen(DeviceId
) + 1;
168 DPRINT1("String %p\n", String
);
173 String
+= StringLength
;
180 return STATUS_SUCCESS
;
185 USBCCGP_PdoHandleQueryId(
186 PDEVICE_OBJECT DeviceObject
,
189 PIO_STACK_LOCATION IoStack
;
190 PUNICODE_STRING DeviceString
= NULL
;
191 PPDO_DEVICE_EXTENSION PDODeviceExtension
;
196 // get current irp stack location
198 IoStack
= IoGetCurrentIrpStackLocation(Irp
);
201 // get device extension
203 PDODeviceExtension
= (PPDO_DEVICE_EXTENSION
)DeviceObject
->DeviceExtension
;
206 if (IoStack
->Parameters
.QueryId
.IdType
== BusQueryDeviceID
)
209 // handle query device id
211 Status
= USBCCGP_SyncForwardIrp(PDODeviceExtension
->NextDeviceObject
, Irp
);
212 if (NT_SUCCESS(Status
))
217 Buffer
= AllocateItem(NonPagedPool
, (wcslen((LPWSTR
)Irp
->IoStatus
.Information
) + 7) * sizeof(WCHAR
));
221 // append interface number
223 ASSERT(Irp
->IoStatus
.Information
);
224 swprintf(Buffer
, L
"%s&MI_%02x", (LPWSTR
)Irp
->IoStatus
.Information
, PDODeviceExtension
->FunctionDescriptor
->FunctionNumber
);
225 DPRINT1("BusQueryDeviceID %S\n", Buffer
);
227 ExFreePool((PVOID
)Irp
->IoStatus
.Information
);
228 Irp
->IoStatus
.Information
= (ULONG_PTR
)Buffer
;
235 Status
= STATUS_INSUFFICIENT_RESOURCES
;
240 else if (IoStack
->Parameters
.QueryId
.IdType
== BusQueryHardwareIDs
)
243 // handle instance id
245 DeviceString
= &PDODeviceExtension
->FunctionDescriptor
->HardwareId
;
247 else if (IoStack
->Parameters
.QueryId
.IdType
== BusQueryInstanceID
)
250 // handle instance id
252 Buffer
= AllocateItem(NonPagedPool
, 5 * sizeof(WCHAR
));
258 return STATUS_INSUFFICIENT_RESOURCES
;
262 // use function number
264 swprintf(Buffer
, L
"%04x", PDODeviceExtension
->FunctionDescriptor
->FunctionNumber
);
265 Irp
->IoStatus
.Information
= (ULONG_PTR
)Buffer
;
266 return STATUS_SUCCESS
;
268 else if (IoStack
->Parameters
.QueryId
.IdType
== BusQueryCompatibleIDs
)
271 // handle instance id
273 DeviceString
= &PDODeviceExtension
->FunctionDescriptor
->CompatibleId
;
279 ASSERT(DeviceString
!= NULL
);
284 Buffer
= AllocateItem(NonPagedPool
, DeviceString
->Length
+ sizeof(WCHAR
));
290 return STATUS_INSUFFICIENT_RESOURCES
;
296 RtlCopyMemory(Buffer
, DeviceString
->Buffer
, DeviceString
->Length
);
297 Irp
->IoStatus
.Information
= (ULONG_PTR
)Buffer
;
299 return STATUS_SUCCESS
;
304 PDEVICE_OBJECT DeviceObject
,
307 PIO_STACK_LOCATION IoStack
;
308 PPDO_DEVICE_EXTENSION PDODeviceExtension
;
313 // get current stack location
315 IoStack
= IoGetCurrentIrpStackLocation(Irp
);
318 // get device extension
320 PDODeviceExtension
= (PPDO_DEVICE_EXTENSION
)DeviceObject
->DeviceExtension
;
325 ASSERT(PDODeviceExtension
->Common
.IsFDO
== FALSE
);
327 switch(IoStack
->MinorFunction
)
329 case IRP_MN_QUERY_DEVICE_RELATIONS
:
332 // handle device relations
334 Status
= USBCCGP_PdoHandleDeviceRelations(DeviceObject
, Irp
);
337 case IRP_MN_QUERY_DEVICE_TEXT
:
340 // handle query device text
342 Status
= USBCCGP_PdoHandleQueryDeviceText(DeviceObject
, Irp
);
345 case IRP_MN_QUERY_ID
:
350 Status
= USBCCGP_PdoHandleQueryId(DeviceObject
, Irp
);
353 case IRP_MN_REMOVE_DEVICE
:
356 // remove us from the fdo's pdo list
358 for(Index
= 0; Index
< PDODeviceExtension
->FDODeviceExtension
->FunctionDescriptorCount
; Index
++)
360 if (PDODeviceExtension
->FDODeviceExtension
->ChildPDO
[Index
] == DeviceObject
)
365 PDODeviceExtension
->FDODeviceExtension
->ChildPDO
[Index
] = NULL
;
373 Irp
->IoStatus
.Status
= STATUS_SUCCESS
;
374 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
377 // Delete the device object
379 IoDeleteDevice(DeviceObject
);
380 return STATUS_SUCCESS
;
382 case IRP_MN_QUERY_CAPABILITIES
:
385 // copy device capabilities
387 RtlCopyMemory(IoStack
->Parameters
.DeviceCapabilities
.Capabilities
, &PDODeviceExtension
->Capabilities
, sizeof(DEVICE_CAPABILITIES
));
389 /* Complete the IRP */
390 Irp
->IoStatus
.Status
= STATUS_SUCCESS
;
391 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
392 return STATUS_SUCCESS
;
394 case IRP_MN_QUERY_REMOVE_DEVICE
:
395 case IRP_MN_QUERY_STOP_DEVICE
:
400 Status
= STATUS_SUCCESS
;
403 case IRP_MN_START_DEVICE
:
408 DPRINT1("[USBCCGP] PDO IRP_MN_START\n");
409 Status
= STATUS_SUCCESS
;
417 Status
= Irp
->IoStatus
.Status
;
425 if (Status
!= STATUS_PENDING
)
430 Irp
->IoStatus
.Status
= Status
;
435 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
446 USBCCGP_BuildConfigurationDescriptor(
447 PDEVICE_OBJECT DeviceObject
,
450 PIO_STACK_LOCATION IoStack
;
451 PPDO_DEVICE_EXTENSION PDODeviceExtension
;
452 PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor
;
453 PUSB_INTERFACE_DESCRIPTOR InterfaceDescriptor
;
454 ULONG TotalSize
, Index
;
460 // get current stack location
462 IoStack
= IoGetCurrentIrpStackLocation(Irp
);
464 DPRINT1("USBCCGP_BuildConfigurationDescriptor\n");
467 // get device extension
469 PDODeviceExtension
= (PPDO_DEVICE_EXTENSION
)DeviceObject
->DeviceExtension
;
472 // get configuration descriptor
474 ConfigurationDescriptor
= PDODeviceExtension
->ConfigurationDescriptor
;
477 // calculate size of configuration descriptor
479 TotalSize
= sizeof(USB_CONFIGURATION_DESCRIPTOR
);
481 for(Index
= 0; Index
< PDODeviceExtension
->FunctionDescriptor
->NumberOfInterfaces
; Index
++)
484 // get current interface descriptor
486 InterfaceDescriptor
= PDODeviceExtension
->FunctionDescriptor
->InterfaceDescriptorList
[Index
];
489 // add to size and move to next descriptor
491 TotalSize
+= InterfaceDescriptor
->bLength
;
492 InterfaceDescriptor
= (PUSB_INTERFACE_DESCRIPTOR
)((ULONG_PTR
)InterfaceDescriptor
+ InterfaceDescriptor
->bLength
);
496 if ((ULONG_PTR
)InterfaceDescriptor
>= ((ULONG_PTR
)ConfigurationDescriptor
+ ConfigurationDescriptor
->wTotalLength
))
499 // reached end of configuration descriptor
505 // association descriptors are removed
507 if (InterfaceDescriptor
->bDescriptorType
!= USB_INTERFACE_ASSOCIATION_DESCRIPTOR_TYPE
)
509 if (InterfaceDescriptor
->bDescriptorType
== USB_INTERFACE_DESCRIPTOR_TYPE
)
512 // reached next descriptor
520 TotalSize
+= InterfaceDescriptor
->bLength
;
524 // move to next descriptor
526 InterfaceDescriptor
= (PUSB_INTERFACE_DESCRIPTOR
)((ULONG_PTR
)InterfaceDescriptor
+ InterfaceDescriptor
->bLength
);
531 // now allocate temporary buffer for the configuration descriptor
533 Buffer
= AllocateItem(NonPagedPool
, TotalSize
);
537 // failed to allocate buffer
539 DPRINT1("[USBCCGP] Failed to allocate %lu Bytes\n", TotalSize
);
540 return STATUS_INSUFFICIENT_RESOURCES
;
544 // first copy the configuration descriptor
546 RtlCopyMemory(Buffer
, ConfigurationDescriptor
, sizeof(USB_CONFIGURATION_DESCRIPTOR
));
547 BufferPtr
= (PUCHAR
)((ULONG_PTR
)Buffer
+ ConfigurationDescriptor
->bLength
);
549 for(Index
= 0; Index
< PDODeviceExtension
->FunctionDescriptor
->NumberOfInterfaces
; Index
++)
552 // get current interface descriptor
554 InterfaceDescriptor
= PDODeviceExtension
->FunctionDescriptor
->InterfaceDescriptorList
[Index
];
557 // copy descriptor and move to next descriptor
559 RtlCopyMemory(BufferPtr
, InterfaceDescriptor
, InterfaceDescriptor
->bLength
);
560 BufferPtr
+= InterfaceDescriptor
->bLength
;
561 InterfaceDescriptor
= (PUSB_INTERFACE_DESCRIPTOR
)((ULONG_PTR
)InterfaceDescriptor
+ InterfaceDescriptor
->bLength
);
565 if ((ULONG_PTR
)InterfaceDescriptor
>= ((ULONG_PTR
)ConfigurationDescriptor
+ ConfigurationDescriptor
->wTotalLength
))
568 // reached end of configuration descriptor
574 // association descriptors are removed
576 if (InterfaceDescriptor
->bDescriptorType
!= USB_INTERFACE_ASSOCIATION_DESCRIPTOR_TYPE
)
578 if (InterfaceDescriptor
->bDescriptorType
== USB_INTERFACE_DESCRIPTOR_TYPE
)
581 // reached next descriptor
589 RtlCopyMemory(BufferPtr
, InterfaceDescriptor
, InterfaceDescriptor
->bLength
);
590 BufferPtr
+= InterfaceDescriptor
->bLength
;
594 // move to next descriptor
596 InterfaceDescriptor
= (PUSB_INTERFACE_DESCRIPTOR
)((ULONG_PTR
)InterfaceDescriptor
+ InterfaceDescriptor
->bLength
);
601 // modify configuration descriptor
603 ConfigurationDescriptor
= Buffer
;
604 ConfigurationDescriptor
->wTotalLength
= TotalSize
;
605 ConfigurationDescriptor
->bNumInterfaces
= PDODeviceExtension
->FunctionDescriptor
->NumberOfInterfaces
;
610 Urb
= (PURB
)IoStack
->Parameters
.Others
.Argument1
;
616 RtlCopyMemory(Urb
->UrbControlDescriptorRequest
.TransferBuffer
, Buffer
, min(TotalSize
, Urb
->UrbControlDescriptorRequest
.TransferBufferLength
));
621 Urb
->UrbControlDescriptorRequest
.TransferBufferLength
= TotalSize
;
631 return STATUS_SUCCESS
;
635 USBCCGP_PDOSelectConfiguration(
636 PDEVICE_OBJECT DeviceObject
,
639 PIO_STACK_LOCATION IoStack
;
640 PPDO_DEVICE_EXTENSION PDODeviceExtension
;
642 PUSBD_INTERFACE_INFORMATION InterfaceInformation
;
643 ULONG InterfaceInformationCount
, Index
, InterfaceIndex
;
644 PUSBD_INTERFACE_LIST_ENTRY Entry
;
645 ULONG NeedSelect
, FoundInterface
;
649 // get current stack location
651 IoStack
= IoGetCurrentIrpStackLocation(Irp
);
654 // get device extension
656 PDODeviceExtension
= (PPDO_DEVICE_EXTENSION
)DeviceObject
->DeviceExtension
;
661 Urb
= (PURB
)IoStack
->Parameters
.Others
.Argument1
;
665 // is there already an configuration handle
667 if (Urb
->UrbSelectConfiguration
.ConfigurationHandle
)
672 return STATUS_SUCCESS
;
676 // count interface information
678 InterfaceInformationCount
= 0;
679 InterfaceInformation
= &Urb
->UrbSelectConfiguration
.Interface
;
682 InterfaceInformationCount
++;
683 InterfaceInformation
= (PUSBD_INTERFACE_INFORMATION
)((ULONG_PTR
)InterfaceInformation
+ InterfaceInformation
->Length
);
684 }while((ULONG_PTR
)InterfaceInformation
< (ULONG_PTR
)Urb
+ Urb
->UrbSelectConfiguration
.Hdr
.Length
);
687 // check all interfaces
689 InterfaceInformation
= &Urb
->UrbSelectConfiguration
.Interface
;
692 DPRINT1("Count %x\n", InterfaceInformationCount
);
695 DPRINT1("[USBCCGP] SelectConfiguration Function %x InterfaceNumber %x Alternative %x\n", PDODeviceExtension
->FunctionDescriptor
->FunctionNumber
, InterfaceInformation
->InterfaceNumber
, InterfaceInformation
->AlternateSetting
);
698 // search for the interface in the local interface list
700 FoundInterface
= FALSE
;
701 for(InterfaceIndex
= 0; InterfaceIndex
< PDODeviceExtension
->FunctionDescriptor
->NumberOfInterfaces
; InterfaceIndex
++)
703 if (PDODeviceExtension
->FunctionDescriptor
->InterfaceDescriptorList
[InterfaceIndex
]->bInterfaceNumber
== InterfaceInformation
->InterfaceNumber
)
705 // found interface entry
706 FoundInterface
= TRUE
;
716 DPRINT1("InterfaceInformation InterfaceNumber %x Alternative %x NumberOfPipes %x not found\n", InterfaceInformation
->InterfaceNumber
, InterfaceInformation
->AlternateSetting
, InterfaceInformation
->NumberOfPipes
);
718 return STATUS_INVALID_PARAMETER
;
722 // now query the total interface list
725 for(InterfaceIndex
= 0; InterfaceIndex
< PDODeviceExtension
->InterfaceListCount
; InterfaceIndex
++)
727 if (PDODeviceExtension
->InterfaceList
[InterfaceIndex
].Interface
->InterfaceNumber
== InterfaceInformation
->InterfaceNumber
)
732 Entry
= &PDODeviceExtension
->InterfaceList
[InterfaceIndex
];
743 // corruption detected
749 if (Entry
->InterfaceDescriptor
->bAlternateSetting
== InterfaceInformation
->AlternateSetting
)
752 for(InterfaceIndex
= 0; InterfaceIndex
< InterfaceInformation
->NumberOfPipes
; InterfaceIndex
++)
754 if (InterfaceInformation
->Pipes
[InterfaceIndex
].MaximumTransferSize
!= Entry
->Interface
->Pipes
[InterfaceIndex
].MaximumTransferSize
)
766 // need select as the interface number differ
774 // interface is already selected
776 RtlCopyMemory(InterfaceInformation
, Entry
->Interface
, min(InterfaceInformation
->Length
, Entry
->Interface
->Length
));
783 DPRINT1("Selecting InterfaceIndex %lu AlternateSetting %lu NumberOfPipes %lu\n", InterfaceInformation
->InterfaceNumber
, InterfaceInformation
->AlternateSetting
, InterfaceInformation
->NumberOfPipes
);
784 ASSERT(InterfaceInformation
->Length
== Entry
->Interface
->Length
);
789 NewUrb
= AllocateItem(NonPagedPool
, GET_SELECT_INTERFACE_REQUEST_SIZE(InterfaceInformation
->NumberOfPipes
));
795 return STATUS_INSUFFICIENT_RESOURCES
;
799 // now prepare interface urb
801 UsbBuildSelectInterfaceRequest(NewUrb
, GET_SELECT_INTERFACE_REQUEST_SIZE(InterfaceInformation
->NumberOfPipes
), PDODeviceExtension
->ConfigurationHandle
, InterfaceInformation
->InterfaceNumber
, InterfaceInformation
->AlternateSetting
);
804 // now select the interface
806 Status
= USBCCGP_SyncUrbRequest(PDODeviceExtension
->NextDeviceObject
, NewUrb
);
807 DPRINT1("SelectInterface Status %x\n", Status
);
812 if (NT_SUCCESS(Status
))
815 // update configuration info
817 ASSERT(Entry
->Interface
->Length
== NewUrb
->UrbSelectInterface
.Interface
.Length
);
818 ASSERT(InterfaceInformation
->Length
== NewUrb
->UrbSelectInterface
.Interface
.Length
);
819 RtlCopyMemory(Entry
->Interface
, &NewUrb
->UrbSelectInterface
.Interface
, NewUrb
->UrbSelectInterface
.Interface
.Length
);
822 // update provided interface information
824 RtlCopyMemory(InterfaceInformation
, Entry
->Interface
, Entry
->Interface
->Length
);
834 // move to next information
836 InterfaceInformation
= (PUSBD_INTERFACE_INFORMATION
)((ULONG_PTR
)InterfaceInformation
+ InterfaceInformation
->Length
);
838 }while(Index
< InterfaceInformationCount
);
841 // store configuration handle
843 Urb
->UrbSelectConfiguration
.ConfigurationHandle
= PDODeviceExtension
->ConfigurationHandle
;
845 DPRINT1("[USBCCGP] SelectConfiguration Function %x Completed\n", PDODeviceExtension
->FunctionDescriptor
->FunctionNumber
);
850 return STATUS_SUCCESS
;
854 PDO_HandleInternalDeviceControl(
855 PDEVICE_OBJECT DeviceObject
,
858 PIO_STACK_LOCATION IoStack
;
859 PPDO_DEVICE_EXTENSION PDODeviceExtension
;
864 // get current stack location
866 IoStack
= IoGetCurrentIrpStackLocation(Irp
);
869 // get device extension
871 PDODeviceExtension
= (PPDO_DEVICE_EXTENSION
)DeviceObject
->DeviceExtension
;
873 if (IoStack
->Parameters
.DeviceIoControl
.IoControlCode
== IOCTL_INTERNAL_USB_SUBMIT_URB
)
878 Urb
= (PURB
)IoStack
->Parameters
.Others
.Argument1
;
880 DPRINT("IOCTL_INTERNAL_USB_SUBMIT_URB Function %x\n", Urb
->UrbHeader
.Function
);
882 if (Urb
->UrbHeader
.Function
== URB_FUNCTION_SELECT_CONFIGURATION
)
885 // select configuration
887 Status
= USBCCGP_PDOSelectConfiguration(DeviceObject
, Irp
);
888 Irp
->IoStatus
.Status
= Status
;
889 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
892 else if (Urb
->UrbHeader
.Function
== URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE
)
894 if(Urb
->UrbControlDescriptorRequest
.DescriptorType
== USB_DEVICE_DESCRIPTOR_TYPE
)
897 // is the buffer big enough
899 if (Urb
->UrbControlDescriptorRequest
.TransferBufferLength
< sizeof(USB_DEVICE_DESCRIPTOR
))
902 // invalid buffer size
904 DPRINT1("[USBCCGP] invalid device descriptor size %lu\n", Urb
->UrbControlDescriptorRequest
.TransferBufferLength
);
905 Urb
->UrbControlDescriptorRequest
.TransferBufferLength
= sizeof(USB_DEVICE_DESCRIPTOR
);
906 Irp
->IoStatus
.Status
= STATUS_INVALID_BUFFER_SIZE
;
907 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
908 return STATUS_INVALID_BUFFER_SIZE
;
912 // copy device descriptor
914 ASSERT(Urb
->UrbControlDescriptorRequest
.TransferBuffer
);
915 RtlCopyMemory(Urb
->UrbControlDescriptorRequest
.TransferBuffer
, &PDODeviceExtension
->DeviceDescriptor
, sizeof(USB_DEVICE_DESCRIPTOR
));
916 Irp
->IoStatus
.Status
= STATUS_SUCCESS
;
917 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
918 return STATUS_SUCCESS
;
920 else if (Urb
->UrbControlDescriptorRequest
.DescriptorType
== USB_CONFIGURATION_DESCRIPTOR_TYPE
)
923 // build configuration descriptor
925 Status
= USBCCGP_BuildConfigurationDescriptor(DeviceObject
, Irp
);
926 Irp
->IoStatus
.Status
= Status
;
927 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
933 IoSkipCurrentIrpStackLocation(Irp
);
934 Status
= IoCallDriver(PDODeviceExtension
->NextDeviceObject
, Irp
);
938 else if (IoStack
->Parameters
.DeviceIoControl
.IoControlCode
== IOCTL_INTERNAL_USB_GET_PORT_STATUS
)
940 IoSkipCurrentIrpStackLocation(Irp
);
941 Status
= IoCallDriver(PDODeviceExtension
->NextDeviceObject
, Irp
);
944 else if (IoStack
->Parameters
.DeviceIoControl
.IoControlCode
== IOCTL_INTERNAL_USB_RESET_PORT
)
946 IoSkipCurrentIrpStackLocation(Irp
);
947 Status
= IoCallDriver(PDODeviceExtension
->NextDeviceObject
, Irp
);
950 else if (IoStack
->Parameters
.DeviceIoControl
.IoControlCode
== IOCTL_INTERNAL_USB_CYCLE_PORT
)
952 IoSkipCurrentIrpStackLocation(Irp
);
953 Status
= IoCallDriver(PDODeviceExtension
->NextDeviceObject
, Irp
);
959 DPRINT1("IOCTL %x\n", IoStack
->Parameters
.DeviceIoControl
.IoControlCode
);
960 DPRINT1("InputBufferLength %lu\n", IoStack
->Parameters
.DeviceIoControl
.InputBufferLength
);
961 DPRINT1("OutputBufferLength %lu\n", IoStack
->Parameters
.DeviceIoControl
.OutputBufferLength
);
962 DPRINT1("Type3InputBuffer %p\n", IoStack
->Parameters
.DeviceIoControl
.Type3InputBuffer
);
966 Irp
->IoStatus
.Status
= STATUS_NOT_IMPLEMENTED
;
967 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
968 return STATUS_NOT_IMPLEMENTED
;
974 PDEVICE_OBJECT DeviceObject
,
977 PIO_STACK_LOCATION IoStack
;
980 /* get stack location */
981 IoStack
= IoGetCurrentIrpStackLocation(Irp
);
983 switch(IoStack
->MajorFunction
)
986 return PDO_HandlePnp(DeviceObject
, Irp
);
987 case IRP_MJ_INTERNAL_DEVICE_CONTROL
:
988 return PDO_HandleInternalDeviceControl(DeviceObject
, Irp
);
990 DPRINT1("PDO_Dispatch Function %x not implemented\n", IoStack
->MajorFunction
);
992 Status
= Irp
->IoStatus
.Status
;
993 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);