Implement IRP_MN_QUERY_RESOURCE_REQUIREMENTS
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-05-18 20:19:22 UTC (rev 15398)
+++ trunk/reactos/drivers/bus/acpi/ospm/fdo.c	2005-05-18 21:23:54 UTC (rev 15399)
@@ -119,12 +119,16 @@
 static BOOLEAN
 AcpiCreateResourceList(PCM_RESOURCE_LIST* pResourceList,
                        PULONG ResourceListSize,
+                       PIO_RESOURCE_REQUIREMENTS_LIST* pRequirementsList,
+                       PULONG RequirementsListSize,
                        RESOURCE* resources)
 {
   BOOLEAN Done;
   ULONG NumberOfResources = 0;
   PCM_RESOURCE_LIST ResourceList;
+  PIO_RESOURCE_REQUIREMENTS_LIST RequirementsList;
   PCM_PARTIAL_RESOURCE_DESCRIPTOR ResourceDescriptor;
+  PIO_RESOURCE_DESCRIPTOR RequirementDescriptor;
   RESOURCE* resource;
   ULONG i;
   KIRQL Dirql;
@@ -176,6 +180,24 @@
   ResourceList->List[0].PartialResourceList.Count = NumberOfResources;
   ResourceDescriptor = ResourceList->List[0].PartialResourceList.PartialDescriptors;
 
+  *RequirementsListSize = sizeof(IO_RESOURCE_REQUIREMENTS_LIST) + sizeof(IO_RESOURCE_DESCRIPTOR) * (NumberOfResources - 1);
+  RequirementsList = (PIO_RESOURCE_REQUIREMENTS_LIST)ExAllocatePool(PagedPool, *RequirementsListSize);
+  *pRequirementsList = RequirementsList;
+  if (!RequirementsList)
+  {
+    ExFreePool(ResourceList);
+    return FALSE;
+  }
+  RequirementsList->ListSize = *RequirementsListSize;
+  RequirementsList->InterfaceType = ResourceList->List[0].InterfaceType;
+  RequirementsList->BusNumber = ResourceList->List[0].BusNumber;
+  RequirementsList->SlotNumber = 0; /* Not used by WDM drivers */
+  RequirementsList->AlternativeLists = 1;
+  RequirementsList->List[0].Version = 1;
+  RequirementsList->List[0].Revision = 1;
+  RequirementsList->List[0].Count = NumberOfResources;
+  RequirementDescriptor = RequirementsList->List[0].Descriptors;
+
   /* Fill resources list structure */
   Done = FALSE;
   resource = resources;
@@ -199,7 +221,16 @@
             &Dirql,
             &ResourceDescriptor->u.Interrupt.Affinity);
           ResourceDescriptor->u.Interrupt.Level = (ULONG)Dirql;
+
+          RequirementDescriptor->Option = 0; /* Required */
+          RequirementDescriptor->Type = ResourceDescriptor->Type;
+          RequirementDescriptor->ShareDisposition = ResourceDescriptor->ShareDisposition;
+          RequirementDescriptor->Flags = ResourceDescriptor->Flags;
+          RequirementDescriptor->u.Interrupt.MinimumVector = RequirementDescriptor->u.Interrupt.MaximumVector
+            = irq_data->interrupts[i];
+
           ResourceDescriptor++;
+          RequirementDescriptor++;
         }
         break;
       }
@@ -225,7 +256,16 @@
             case TRANSFER_8_16: ResourceDescriptor->Flags |= CM_RESOURCE_DMA_8_AND_16; break;
           }
           ResourceDescriptor->u.Dma.Channel = dma_data->channels[i];
+
+          RequirementDescriptor->Option = 0; /* Required */
+          RequirementDescriptor->Type = ResourceDescriptor->Type;
+          RequirementDescriptor->ShareDisposition = ResourceDescriptor->ShareDisposition;
+          RequirementDescriptor->Flags = ResourceDescriptor->Flags;
+          RequirementDescriptor->u.Dma.MinimumChannel = RequirementDescriptor->u.Dma.MaximumChannel
+            = ResourceDescriptor->u.Dma.Channel;
+
           ResourceDescriptor++;
+          RequirementDescriptor++;
         }
         break;
       }
@@ -242,7 +282,18 @@
         ResourceDescriptor->u.Port.Start.u.HighPart = 0;
         ResourceDescriptor->u.Port.Start.u.LowPart = io_data->min_base_address;
         ResourceDescriptor->u.Port.Length = io_data->range_length;
+
+        RequirementDescriptor->Option = 0; /* Required */
+        RequirementDescriptor->Type = ResourceDescriptor->Type;
+        RequirementDescriptor->ShareDisposition = ResourceDescriptor->ShareDisposition;
+        RequirementDescriptor->Flags = ResourceDescriptor->Flags;
+        RequirementDescriptor->u.Port.Length = ResourceDescriptor->u.Port.Length;
+        RequirementDescriptor->u.Port.Alignment = 1; /* Start address is specified, so it doesn't matter */
+        RequirementDescriptor->u.Port.MinimumAddress = RequirementDescriptor->u.Port.MaximumAddress
+          = ResourceDescriptor->u.Port.Start;
+
         ResourceDescriptor++;
+        RequirementDescriptor++;
         break;
       }
       case end_tag:
@@ -366,6 +417,8 @@
           }
           if (!AcpiCreateResourceList(&PdoDeviceExtension->ResourceList,
                                       &PdoDeviceExtension->ResourceListSize,
+                                      &PdoDeviceExtension->ResourceRequirementsList,
+                                      &PdoDeviceExtension->ResourceRequirementsListSize,
                                       (RESOURCE*)Buffer.pointer))
           {
             ASSERT(FALSE);

Modified: trunk/reactos/drivers/bus/acpi/ospm/include/acpisys.h
--- trunk/reactos/drivers/bus/acpi/ospm/include/acpisys.h	2005-05-18 20:19:22 UTC (rev 15398)
+++ trunk/reactos/drivers/bus/acpi/ospm/include/acpisys.h	2005-05-18 21:23:54 UTC (rev 15399)
@@ -50,6 +50,9 @@
   // Resource list
   PCM_RESOURCE_LIST ResourceList;
   ULONG ResourceListSize;
+  // Requirement list
+  PIO_RESOURCE_REQUIREMENTS_LIST ResourceRequirementsList;
+  ULONG ResourceRequirementsListSize;
 } PDO_DEVICE_EXTENSION, *PPDO_DEVICE_EXTENSION;
 
 

Modified: trunk/reactos/drivers/bus/acpi/ospm/pdo.c
--- trunk/reactos/drivers/bus/acpi/ospm/pdo.c	2005-05-18 20:19:22 UTC (rev 15398)
+++ trunk/reactos/drivers/bus/acpi/ospm/pdo.c	2005-05-18 21:23:54 UTC (rev 15399)
@@ -108,6 +108,35 @@
 
 
 static NTSTATUS
+PdoQueryResourceRequirements(
+  IN PDEVICE_OBJECT DeviceObject,
+  IN PIRP Irp,
+  PIO_STACK_LOCATION IrpSp)
+{
+  PPDO_DEVICE_EXTENSION DeviceExtension;
+  PIO_RESOURCE_REQUIREMENTS_LIST ResourceRequirementsList;
+
+  DeviceExtension = (PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
+
+  if (DeviceExtension->ResourceRequirementsListSize == 0)
+  {
+    return Irp->IoStatus.Status;
+  }
+
+  ResourceRequirementsList = ExAllocatePool(PagedPool, DeviceExtension->ResourceRequirementsListSize);
+  if (!ResourceRequirementsList)
+  {
+    Irp->IoStatus.Information = 0;
+    return STATUS_INSUFFICIENT_RESOURCES;
+  }
+
+  RtlCopyMemory(ResourceRequirementsList, DeviceExtension->ResourceRequirementsList, DeviceExtension->ResourceRequirementsListSize);
+  Irp->IoStatus.Information = (ULONG_PTR)ResourceRequirementsList;
+  return STATUS_SUCCESS;
+}
+
+
+static NTSTATUS
 PdoQueryResources(
   IN PDEVICE_OBJECT DeviceObject,
   IN PIRP Irp,
@@ -227,6 +256,9 @@
     break;
 
   case IRP_MN_QUERY_RESOURCE_REQUIREMENTS:
+    Status = PdoQueryResourceRequirements(DeviceObject,
+                                          Irp,
+                                          IrpSp);
     break;
 
   case IRP_MN_QUERY_RESOURCES: