From 679512e16cb79c132069e43b684a08f000e45f62 Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Mon, 30 Jan 2012 12:42:05 +0000 Subject: [PATCH] [USBCCGP] - Add function to append interface number - Append function number to BusQueryDeviceId / BusQueryInstanceId - USBCCGP is now properly enumerated and its child device start to get installed svn path=/branches/usb-bringup-trunk/; revision=55326 --- drivers/usb/usbccgp/pdo.c | 107 +++++++++++++++++++++++++++++++++++--- 1 file changed, 100 insertions(+), 7 deletions(-) diff --git a/drivers/usb/usbccgp/pdo.c b/drivers/usb/usbccgp/pdo.c index ada8a935588..77c83a20bbb 100644 --- a/drivers/usb/usbccgp/pdo.c +++ b/drivers/usb/usbccgp/pdo.c @@ -123,6 +123,64 @@ USBCCGP_PdoHandleDeviceRelations( return STATUS_SUCCESS; } +NTSTATUS +USBCCGP_PdoAppendInterfaceNumber( + IN LPWSTR DeviceId, + IN ULONG InterfaceNumber, + OUT LPWSTR *OutString) +{ + ULONG Length = 0, StringLength; + LPWSTR String; + + // + // count length of string + // + String = DeviceId; + while(*String) + { + StringLength = wcslen(String) + 1; + Length += StringLength; + Length += 6; //&MI_XX + String += StringLength; + } + + // + // now allocate the buffer + // + String = AllocateItem(NonPagedPool, (Length + 2) * sizeof(WCHAR)); + if (!String) + { + // + // no memory + // + return STATUS_INSUFFICIENT_RESOURCES; + } + + // + // store result + // + *OutString = String; + + while(*DeviceId) + { + StringLength = swprintf(String, L"%s&MI_%02x", DeviceId) + 1; + Length = wcslen(DeviceId) + 1; + DPRINT1("String %p\n", String); + + // + // next string + // + String += StringLength; + DeviceId += Length; + } + + // + // success + // + return STATUS_SUCCESS; +} + + NTSTATUS USBCCGP_PdoHandleQueryId( PDEVICE_OBJECT DeviceObject, @@ -152,11 +210,32 @@ USBCCGP_PdoHandleQueryId( // handle query device id // Status = USBCCGP_SyncForwardIrp(PDODeviceExtension->NextDeviceObject, Irp); + if (NT_SUCCESS(Status)) + { + // + // allocate buffer + // + Buffer = AllocateItem(NonPagedPool, (wcslen((LPWSTR)Irp->IoStatus.Information) + 7) * sizeof(WCHAR)); + if (Buffer) + { + // + // append interface number + // + ASSERT(Irp->IoStatus.Information); + swprintf(Buffer, L"%s&MI_%02x", (LPWSTR)Irp->IoStatus.Information, PDODeviceExtension->FunctionDescriptor->FunctionNumber); + DPRINT1("BusQueryDeviceID %S\n", Buffer); - // - // FIXME append interface id - // - UNIMPLEMENTED + ExFreePool((PVOID)Irp->IoStatus.Information); + Irp->IoStatus .Information = (ULONG_PTR)Buffer; + } + else + { + // + // no memory + // + Status = STATUS_INSUFFICIENT_RESOURCES; + } + } return Status; } else if (IoStack->Parameters.QueryId.IdType == BusQueryHardwareIDs) @@ -171,8 +250,21 @@ USBCCGP_PdoHandleQueryId( // // handle instance id // - RtlInitUnicodeString(&TempString, L"0000"); - DeviceString = &TempString; + Buffer = AllocateItem(NonPagedPool, 5 * sizeof(WCHAR)); + if (!Buffer) + { + // + // no memory + // + return STATUS_INSUFFICIENT_RESOURCES; + } + + // + // use function number + // + swprintf(Buffer, L"%04x", PDODeviceExtension->FunctionDescriptor->FunctionNumber); + Irp->IoStatus.Information = (ULONG_PTR)Buffer; + return STATUS_SUCCESS; } else if (IoStack->Parameters.QueryId.IdType == BusQueryCompatibleIDs) { @@ -202,8 +294,9 @@ USBCCGP_PdoHandleQueryId( // // copy buffer // - Irp->IoStatus.Information = (ULONG_PTR)Buffer; RtlCopyMemory(Buffer, DeviceString->Buffer, DeviceString->Length); + Irp->IoStatus.Information = (ULONG_PTR)Buffer; + return STATUS_SUCCESS; }