Author: janderwald
Date: Mon Jan 30 10:41:52 2012
New Revision: 55325
URL:
http://svn.reactos.org/svn/reactos?rev=55325&view=rev
Log:
[USBCCGP]
- Fix bug while scanning configuration descriptor
- Store interface list in the PDO device extension
- Display interface numbers when dumping function descriptor
- Fix a few bugs while selecting the configuration for the PDO
Modified:
branches/usb-bringup-trunk/drivers/usb/usbccgp/descriptor.c
branches/usb-bringup-trunk/drivers/usb/usbccgp/fdo.c
branches/usb-bringup-trunk/drivers/usb/usbccgp/function.c
branches/usb-bringup-trunk/drivers/usb/usbccgp/misc.c
branches/usb-bringup-trunk/drivers/usb/usbccgp/pdo.c
branches/usb-bringup-trunk/drivers/usb/usbccgp/usbccgp.c
Modified: branches/usb-bringup-trunk/drivers/usb/usbccgp/descriptor.c
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup-trunk/drivers/usb/u…
==============================================================================
--- branches/usb-bringup-trunk/drivers/usb/usbccgp/descriptor.c [iso-8859-1] (original)
+++ branches/usb-bringup-trunk/drivers/usb/usbccgp/descriptor.c [iso-8859-1] Mon Jan 30
10:41:52 2012
@@ -301,7 +301,7 @@
//
// parse configuration descriptor
//
- InterfaceDescriptor =
USBD_ParseConfigurationDescriptorEx(ConfigurationDescriptor, CurrentPosition, -1, -1, -1,
-1, -1);
+ InterfaceDescriptor =
USBD_ParseConfigurationDescriptorEx(ConfigurationDescriptor, ConfigurationDescriptor,
InterfaceIndex, -1, -1, -1, -1);
if (InterfaceDescriptor)
{
//
Modified: branches/usb-bringup-trunk/drivers/usb/usbccgp/fdo.c
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup-trunk/drivers/usb/u…
==============================================================================
--- branches/usb-bringup-trunk/drivers/usb/usbccgp/fdo.c [iso-8859-1] (original)
+++ branches/usb-bringup-trunk/drivers/usb/usbccgp/fdo.c [iso-8859-1] Mon Jan 30 10:41:52
2012
@@ -277,8 +277,10 @@
//
PDODeviceExtension->Common.IsFDO = FALSE;
PDODeviceExtension->FunctionDescriptor =
&FDODeviceExtension->FunctionDescriptor[Index];
- PDODeviceExtension->NextDeviceObject = DeviceObject;
+ PDODeviceExtension->NextDeviceObject =
FDODeviceExtension->NextDeviceObject; //DeviceObject; HACK
PDODeviceExtension->FunctionIndex = Index;
+ PDODeviceExtension->InterfaceList = FDODeviceExtension->InterfaceList;
+ PDODeviceExtension->InterfaceListCount =
FDODeviceExtension->InterfaceListCount;
PDODeviceExtension->ConfigurationHandle =
FDODeviceExtension->ConfigurationHandle;
PDODeviceExtension->ConfigurationDescriptor =
FDODeviceExtension->ConfigurationDescriptor;
RtlCopyMemory(&PDODeviceExtension->Capabilities,
&FDODeviceExtension->Capabilities, sizeof(DEVICE_CAPABILITIES));
@@ -421,7 +423,7 @@
// get stack location
IoStack = IoGetCurrentIrpStackLocation(Irp);
-
+ DPRINT1("[USBCCGP] PnP Minor %x\n", IoStack->MinorFunction);
switch(IoStack->MinorFunction)
{
case IRP_MN_START_DEVICE:
Modified: branches/usb-bringup-trunk/drivers/usb/usbccgp/function.c
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup-trunk/drivers/usb/u…
==============================================================================
--- branches/usb-bringup-trunk/drivers/usb/usbccgp/function.c [iso-8859-1] (original)
+++ branches/usb-bringup-trunk/drivers/usb/usbccgp/function.c [iso-8859-1] Mon Jan 30
10:41:52 2012
@@ -650,13 +650,14 @@
for(Index = 0; Index <
FDODeviceExtension->ConfigurationDescriptor->bNumInterfaces; Index++)
{
// get interface descriptor
- InterfaceDescriptor =
USBD_ParseConfigurationDescriptor(FDODeviceExtension->ConfigurationDescriptor, Index,
0);
+ InterfaceDescriptor =
USBD_ParseConfigurationDescriptorEx(FDODeviceExtension->ConfigurationDescriptor,
FDODeviceExtension->ConfigurationDescriptor, Index, 0, -1, -1, -1);
if (InterfaceDescriptor == NULL)
{
//
// failed to find interface descriptor
//
DPRINT1("[USBCCGP] Failed to find interface descriptor index
%lu\n", Index);
+ ASSERT(FALSE);
return STATUS_UNSUCCESSFUL;
}
@@ -720,6 +721,7 @@
PUSB_INTERFACE_DESCRIPTOR InterfaceDescriptor, FirstDescriptor = NULL;
PFDO_DEVICE_EXTENSION FDODeviceExtension;
NTSTATUS Status = STATUS_SUCCESS;
+ PVOID StartPosition;
//
// get device extension
@@ -731,12 +733,21 @@
//
// first check if all interfaces belong to the same audio class
//
- for(Index = 0; Index <
FDODeviceExtension->ConfigurationDescriptor->bNumInterfaces; Index++)
+ StartPosition = FDODeviceExtension->ConfigurationDescriptor;
+ for(Index = 0; Index <
CountInterfaceDescriptors(FDODeviceExtension->ConfigurationDescriptor); Index++)
{
//
// get interface descriptor
//
- InterfaceDescriptor =
USBD_ParseConfigurationDescriptorEx(FDODeviceExtension->ConfigurationDescriptor,
FDODeviceExtension->ConfigurationDescriptor, Index, -1, -1, -1, -1);
+ InterfaceDescriptor =
USBD_ParseConfigurationDescriptorEx(FDODeviceExtension->ConfigurationDescriptor,
StartPosition, -1, -1, -1, -1, -1);
+ DPRINT1("Index %lu Descriptor %p\n", Index, InterfaceDescriptor);
+ ASSERT(InterfaceDescriptor);
+
+ //
+ // move to next descriptor
+ //
+ StartPosition = (PVOID)((ULONG_PTR)InterfaceDescriptor +
InterfaceDescriptor->bLength);
+
if (InterfaceDescriptor->bInterfaceClass != 0x1)
{
//
Modified: branches/usb-bringup-trunk/drivers/usb/usbccgp/misc.c
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup-trunk/drivers/usb/u…
==============================================================================
--- branches/usb-bringup-trunk/drivers/usb/usbccgp/misc.c [iso-8859-1] (original)
+++ branches/usb-bringup-trunk/drivers/usb/usbccgp/misc.c [iso-8859-1] Mon Jan 30 10:41:52
2012
@@ -200,7 +200,7 @@
IN PUSBC_FUNCTION_DESCRIPTOR FunctionDescriptor,
IN ULONG FunctionDescriptorCount)
{
- ULONG Index;
+ ULONG Index, SubIndex;
DPRINT1("FunctionCount %lu\n", FunctionDescriptorCount);
@@ -212,6 +212,13 @@
DPRINT1("CompatibleId %wZ\n",
&FunctionDescriptor[Index].CompatibleId);
DPRINT1("FunctionDescription %wZ\n",
&FunctionDescriptor[Index].FunctionDescription);
DPRINT1("NumInterfaces %lu\n",
FunctionDescriptor[Index].NumberOfInterfaces);
+
+ for(SubIndex = 0; SubIndex < FunctionDescriptor[Index].NumberOfInterfaces;
SubIndex++)
+ {
+ DPRINT1(" Interface %p\n",
FunctionDescriptor[Index].InterfaceDescriptorList[SubIndex]);
+ DPRINT1(" Interface InterfaceNumber %x\n",
FunctionDescriptor[Index].InterfaceDescriptorList[SubIndex]->bInterfaceNumber);
+ DPRINT1(" Interface Alternate %x\n",
FunctionDescriptor[Index].InterfaceDescriptorList[SubIndex]->bAlternateSetting );
+ }
}
}
Modified: branches/usb-bringup-trunk/drivers/usb/usbccgp/pdo.c
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup-trunk/drivers/usb/u…
==============================================================================
--- branches/usb-bringup-trunk/drivers/usb/usbccgp/pdo.c [iso-8859-1] (original)
+++ branches/usb-bringup-trunk/drivers/usb/usbccgp/pdo.c [iso-8859-1] Mon Jan 30 10:41:52
2012
@@ -523,7 +523,7 @@
PUSBD_INTERFACE_INFORMATION InterfaceInformation;
ULONG InterfaceInformationCount, Index, InterfaceIndex;
PUSBD_INTERFACE_LIST_ENTRY Entry;
- ULONG NeedSelect;
+ ULONG NeedSelect, FoundInterface;
//
// get current stack location
@@ -569,35 +569,66 @@
InterfaceInformation = &Urb->UrbSelectConfiguration.Interface;
Index = 0;
Entry = NULL;
-
+ DPRINT1("Count %x\n", InterfaceInformationCount);
do
{
- //
- // search for the interface
- //
+ DPRINT1("[USBCCGP] SelectConfiguration Function %x InterfaceNumber %x
Alternative %x\n", PDODeviceExtension->FunctionDescriptor->FunctionNumber,
InterfaceInformation->InterfaceNumber, InterfaceInformation->AlternateSetting);
+
+ //
+ // search for the interface in the local interface list
+ //
+ FoundInterface = FALSE;
for(InterfaceIndex = 0; InterfaceIndex <
PDODeviceExtension->FunctionDescriptor->NumberOfInterfaces; InterfaceIndex++)
+ {
+ if
(PDODeviceExtension->FunctionDescriptor->InterfaceDescriptorList[InterfaceIndex]->bInterfaceNumber
== InterfaceInformation->InterfaceNumber)
+ {
+ // found interface entry
+ FoundInterface = TRUE;
+ break;
+ }
+ }
+
+ if (!FoundInterface)
+ {
+ //
+ // invalid parameter
+ //
+ DPRINT1("InterfaceInformation InterfaceNumber %x Alternative %x
NumberOfPipes %x not found\n", InterfaceInformation->InterfaceNumber,
InterfaceInformation->AlternateSetting, InterfaceInformation->NumberOfPipes);
+ ASSERT(FALSE);
+ return STATUS_INVALID_PARAMETER;
+ }
+
+ //
+ // now query the total interface list
+ //
+ Entry = NULL;
+ for(InterfaceIndex = 0; InterfaceIndex <
PDODeviceExtension->InterfaceListCount; InterfaceIndex++)
{
if
(PDODeviceExtension->InterfaceList[InterfaceIndex].Interface->InterfaceNumber ==
InterfaceInformation->InterfaceNumber)
{
- // found interface entry
+ //
+ // found entry
+ //
Entry = &PDODeviceExtension->InterfaceList[InterfaceIndex];
- break;
}
}
- if (!Entry || Entry->InterfaceDescriptor)
- {
- //
- // invalid parameter
- //
- ASSERT(FALSE);
- return STATUS_INVALID_PARAMETER;
+ //
+ // sanity check
+ //
+ ASSERT(Entry);
+ if (!Entry)
+ {
+ //
+ // corruption detected
+ //
+ KeBugCheck(0);
}
NeedSelect = FALSE;
if (Entry->InterfaceDescriptor->bAlternateSetting ==
InterfaceInformation->AlternateSetting)
{
- for(InterfaceIndex = 0; Entry->InterfaceDescriptor->bNumEndpoints;
InterfaceIndex++)
+ for(InterfaceIndex = 0; InterfaceIndex <
Entry->InterfaceDescriptor->bNumEndpoints; InterfaceIndex++)
{
if (InterfaceInformation->Pipes[InterfaceIndex].MaximumTransferSize !=
Entry->Interface->Pipes[InterfaceIndex].MaximumTransferSize)
{
@@ -611,7 +642,7 @@
else
{
//
- // need select
+ // need select as the interface number differ
//
NeedSelect = TRUE;
}
@@ -640,6 +671,16 @@
Index++;
}while(Index < InterfaceInformationCount);
+ //
+ // store configuration handle
+ //
+ Urb->UrbSelectConfiguration.ConfigurationHandle =
PDODeviceExtension->ConfigurationHandle;
+
+ DPRINT1("[USBCCGP] SelectConfiguration Function %x Completed\n",
PDODeviceExtension->FunctionDescriptor->FunctionNumber);
+
+ //
+ // done
+ //
return STATUS_SUCCESS;
}
@@ -721,9 +762,14 @@
return Status;
}
}
-
-
-
+ else if (Urb->UrbHeader.Function ==
URB_FUNCTION_GET_DESCRIPTOR_FROM_INTERFACE)
+ {
+ DPRINT1("URB_FUNCTION_GET_DESCRIPTOR_FROM_INTERFACE\n");
+ IoSkipCurrentIrpStackLocation(Irp);
+ Status = IoCallDriver(PDODeviceExtension->NextDeviceObject, Irp);
+ DPRINT1("URB_FUNCTION_GET_DESCRIPTOR_FROM_INTERFACE Status %x\n",
Status);
+ return Status;
+ }
}
Modified: branches/usb-bringup-trunk/drivers/usb/usbccgp/usbccgp.c
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup-trunk/drivers/usb/u…
==============================================================================
--- branches/usb-bringup-trunk/drivers/usb/usbccgp/usbccgp.c [iso-8859-1] (original)
+++ branches/usb-bringup-trunk/drivers/usb/usbccgp/usbccgp.c [iso-8859-1] Mon Jan 30
10:41:52 2012
@@ -136,6 +136,7 @@
{
// initialize driver object
+ DPRINT1("[USBCCGP] DriverEntry\n");
DriverObject->DriverExtension->AddDevice = USBCCGP_AddDevice;
DriverObject->MajorFunction[IRP_MJ_CREATE] = USBCCGP_Dispatch;
DriverObject->MajorFunction[IRP_MJ_CLOSE] = USBCCGP_Dispatch;