Implement IRP_MJ_PNP / IRP_MN_QUERY_TEXT / DeviceTextDescription for ACPI devices
Modified: trunk/reactos/drivers/bus/acpi/ospm/fdo.c
Modified: trunk/reactos/drivers/bus/acpi/ospm/include/acpisys.h
Modified: trunk/reactos/drivers/bus/acpi/ospm/pdo.c

Modified: trunk/reactos/drivers/bus/acpi/ospm/fdo.c
--- trunk/reactos/drivers/bus/acpi/ospm/fdo.c	2005-10-03 12:39:50 UTC (rev 18243)
+++ trunk/reactos/drivers/bus/acpi/ospm/fdo.c	2005-10-03 12:53:31 UTC (rev 18244)
@@ -116,6 +116,52 @@
 }
 
 
+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,
@@ -460,6 +506,15 @@
 //          ErrorOccurred = TRUE;
 //          break;
         }
+
+        if (!AcpiCreateDeviceDescriptionString(&PdoDeviceExtension->DeviceDescription,
+                                            Node))
+        {
+          ASSERT(FALSE);
+//          ErrorStatus = STATUS_INSUFFICIENT_RESOURCES;
+//          ErrorOccurred = TRUE;
+//          break;
+        }
       }
     }
 

Modified: trunk/reactos/drivers/bus/acpi/ospm/include/acpisys.h
--- trunk/reactos/drivers/bus/acpi/ospm/include/acpisys.h	2005-10-03 12:39:50 UTC (rev 18243)
+++ trunk/reactos/drivers/bus/acpi/ospm/include/acpisys.h	2005-10-03 12:53:31 UTC (rev 18244)
@@ -47,6 +47,8 @@
   UNICODE_STRING InstanceID;
   // Hardware IDs
   UNICODE_STRING HardwareIDs;
+  // Textual description of device
+  UNICODE_STRING DeviceDescription;
   // Resource list
   PCM_RESOURCE_LIST ResourceList;
   ULONG ResourceListSize;

Modified: trunk/reactos/drivers/bus/acpi/ospm/pdo.c
--- trunk/reactos/drivers/bus/acpi/ospm/pdo.c	2005-10-03 12:39:50 UTC (rev 18243)
+++ trunk/reactos/drivers/bus/acpi/ospm/pdo.c	2005-10-03 12:53:31 UTC (rev 18244)
@@ -43,6 +43,46 @@
 
 
 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,
   IN PIRP Irp,
@@ -241,6 +281,7 @@
     break;
 
   case IRP_MN_QUERY_DEVICE_TEXT:
+    Status = PdoQueryDeviceText(DeviceObject, Irp, IrpSp);
     break;
 
   case IRP_MN_QUERY_ID: