Implement IRP_MJ_PNP / IRP_MN_QUERY_TEXT / DeviceTextDescription for ACPI devices

svn path=/trunk/; revision=18244
This commit is contained in:
Hervé Poussineau 2005-10-03 12:53:31 +00:00
parent 32cf34124f
commit 4b42aa47f1
3 changed files with 98 additions and 0 deletions

View file

@ -116,6 +116,52 @@ AcpiCreateInstanceIDString(PUNICODE_STRING InstanceID,
}
BOOLEAN
AcpiCreateDeviceDescriptionString(PUNICODE_STRING DeviceDescription,
BM_NODE *Node)
{
PWSTR Buffer;
DPRINT1("'%s', '%s', %ld\n", Node->device.id.hid, "PNP040", RtlCompareMemory(Node->device.id.hid, "PNP040", 6));
if (RtlCompareMemory(Node->device.id.hid, "PNP000", 6) == 6)
Buffer = L"Programmable interrupt controller";
else if (RtlCompareMemory(Node->device.id.hid, "PNP010", 6) == 6)
Buffer = L"System timer";
else if (RtlCompareMemory(Node->device.id.hid, "PNP020", 6) == 6)
Buffer = L"DMA controller";
else if (RtlCompareMemory(Node->device.id.hid, "PNP03", 5) == 5)
Buffer = L"Keyboard";
else if (RtlCompareMemory(Node->device.id.hid, "PNP040", 6) == 6)
Buffer = L"Parallel port";
else if (RtlCompareMemory(Node->device.id.hid, "PNP05", 5) == 5)
Buffer = L"Serial port";
else if (RtlCompareMemory(Node->device.id.hid, "PNP06", 5) ==5)
Buffer = L"Disk controller";
else if (RtlCompareMemory(Node->device.id.hid, "PNP07", 5) == 5)
Buffer = L"Disk controller";
else if (RtlCompareMemory(Node->device.id.hid, "PNP09", 5) == 5)
Buffer = L"Display adapter";
else if (RtlCompareMemory(Node->device.id.hid, "PNP0A0", 6) == 6)
Buffer = L"Bus controller";
else if (RtlCompareMemory(Node->device.id.hid, "PNP0E0", 6) == 6)
Buffer = L"PCMCIA controller";
else if (RtlCompareMemory(Node->device.id.hid, "PNP0F", 5) == 5)
Buffer = L"Mouse device";
else if (RtlCompareMemory(Node->device.id.hid, "PNP8", 4) == 4)
Buffer = L"Network adapter";
else if (RtlCompareMemory(Node->device.id.hid, "PNPA0", 5) == 5)
Buffer = L"SCSI controller";
else if (RtlCompareMemory(Node->device.id.hid, "PNPB0", 5) == 5)
Buffer = L"Multimedia device";
else if (RtlCompareMemory(Node->device.id.hid, "PNPC00", 6) == 6)
Buffer = L"Modem";
else
Buffer = L"Other ACPI device";
return AcpiCreateUnicodeString(DeviceDescription, Buffer, PagedPool);
}
static BOOLEAN
AcpiCreateResourceList(PCM_RESOURCE_LIST* pResourceList,
PULONG ResourceListSize,
@ -458,6 +504,15 @@ FdoQueryBusRelations(
ASSERT(FALSE);
// ErrorStatus = STATUS_INSUFFICIENT_RESOURCES;
// ErrorOccurred = TRUE;
// break;
}
if (!AcpiCreateDeviceDescriptionString(&PdoDeviceExtension->DeviceDescription,
Node))
{
ASSERT(FALSE);
// ErrorStatus = STATUS_INSUFFICIENT_RESOURCES;
// ErrorOccurred = TRUE;
// break;
}
}

View file

@ -47,6 +47,8 @@ typedef struct _PDO_DEVICE_EXTENSION
UNICODE_STRING InstanceID;
// Hardware IDs
UNICODE_STRING HardwareIDs;
// Textual description of device
UNICODE_STRING DeviceDescription;
// Resource list
PCM_RESOURCE_LIST ResourceList;
ULONG ResourceListSize;

View file

@ -42,6 +42,46 @@ AcpiDuplicateUnicodeString(
}
static NTSTATUS
PdoQueryDeviceText(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp,
PIO_STACK_LOCATION IrpSp)
{
PPDO_DEVICE_EXTENSION DeviceExtension;
PWSTR Buffer;
NTSTATUS Status;
DPRINT("Called\n");
DeviceExtension = (PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
Status = STATUS_SUCCESS;
switch (IrpSp->Parameters.QueryDeviceText.DeviceTextType)
{
case DeviceTextDescription:
DPRINT("DeviceTextDescription\n");
Buffer = (PWSTR)ExAllocatePool(PagedPool, DeviceExtension->DeviceDescription.Length + sizeof(UNICODE_NULL));
if (Buffer == NULL)
Status = STATUS_INSUFFICIENT_RESOURCES;
else
{
RtlCopyMemory(Buffer, DeviceExtension->DeviceDescription.Buffer, DeviceExtension->DeviceDescription.Length);
Buffer[DeviceExtension->DeviceDescription.Length / sizeof(WCHAR)] = UNICODE_NULL;
Irp->IoStatus.Information = (ULONG_PTR)Buffer;
}
break;
default:
Irp->IoStatus.Information = 0;
Status = STATUS_INVALID_PARAMETER;
}
return Status;
}
static NTSTATUS
PdoQueryId(
IN PDEVICE_OBJECT DeviceObject,
@ -241,6 +281,7 @@ PdoPnpControl(
break;
case IRP_MN_QUERY_DEVICE_TEXT:
Status = PdoQueryDeviceText(DeviceObject, Irp, IrpSp);
break;
case IRP_MN_QUERY_ID: