[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
This commit is contained in:
Johannes Anderwald 2012-01-30 12:42:05 +00:00
parent d7bc987891
commit 679512e16c

View file

@ -123,6 +123,64 @@ USBCCGP_PdoHandleDeviceRelations(
return STATUS_SUCCESS; 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 NTSTATUS
USBCCGP_PdoHandleQueryId( USBCCGP_PdoHandleQueryId(
PDEVICE_OBJECT DeviceObject, PDEVICE_OBJECT DeviceObject,
@ -152,11 +210,32 @@ USBCCGP_PdoHandleQueryId(
// handle query device id // handle query device id
// //
Status = USBCCGP_SyncForwardIrp(PDODeviceExtension->NextDeviceObject, Irp); 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);
ExFreePool((PVOID)Irp->IoStatus.Information);
Irp->IoStatus .Information = (ULONG_PTR)Buffer;
}
else
{
// //
// FIXME append interface id // no memory
// //
UNIMPLEMENTED Status = STATUS_INSUFFICIENT_RESOURCES;
}
}
return Status; return Status;
} }
else if (IoStack->Parameters.QueryId.IdType == BusQueryHardwareIDs) else if (IoStack->Parameters.QueryId.IdType == BusQueryHardwareIDs)
@ -171,8 +250,21 @@ USBCCGP_PdoHandleQueryId(
// //
// handle instance id // handle instance id
// //
RtlInitUnicodeString(&TempString, L"0000"); Buffer = AllocateItem(NonPagedPool, 5 * sizeof(WCHAR));
DeviceString = &TempString; 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) else if (IoStack->Parameters.QueryId.IdType == BusQueryCompatibleIDs)
{ {
@ -202,8 +294,9 @@ USBCCGP_PdoHandleQueryId(
// //
// copy buffer // copy buffer
// //
Irp->IoStatus.Information = (ULONG_PTR)Buffer;
RtlCopyMemory(Buffer, DeviceString->Buffer, DeviceString->Length); RtlCopyMemory(Buffer, DeviceString->Buffer, DeviceString->Length);
Irp->IoStatus.Information = (ULONG_PTR)Buffer;
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }