[ISAPNP] Create resource list ahead of IRP_MN_QUERY_RESOURCES
[reactos.git] / drivers / bus / isapnp / isapnp.c
index c902587..6f22efc 100644 (file)
@@ -379,6 +379,45 @@ IsaPnpCreateReadPortDORequirements(
     return STATUS_SUCCESS;
 }
 
+static
+NTSTATUS
+NTAPI
+IsaPnpCreateReadPortDOResources(
+    IN PISAPNP_PDO_EXTENSION PdoExt)
+{
+    USHORT Ports[] = { ISAPNP_WRITE_DATA, ISAPNP_ADDRESS };
+    ULONG ListSize, i;
+    PCM_RESOURCE_LIST ResourceList;
+    PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor;
+
+    ListSize = sizeof(CM_RESOURCE_LIST)
+             + (ARRAYSIZE(Ports) - 1) * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR);
+    ResourceList = ExAllocatePool(PagedPool, ListSize);
+    if (!ResourceList)
+        return STATUS_NO_MEMORY;
+
+    RtlZeroMemory(ResourceList, ListSize);
+    ResourceList->Count = 1;
+    ResourceList->List[0].InterfaceType = Internal;
+    ResourceList->List[0].PartialResourceList.Version = 1;
+    ResourceList->List[0].PartialResourceList.Revision = 1;
+    ResourceList->List[0].PartialResourceList.Count = 2;
+
+    for (i = 0; i < ARRAYSIZE(Ports); i++)
+    {
+        Descriptor = &ResourceList->List[0].PartialResourceList.PartialDescriptors[i];
+        Descriptor->Type = CmResourceTypePort;
+        Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
+        Descriptor->Flags = CM_RESOURCE_PORT_16_BIT_DECODE;
+        Descriptor->u.Port.Length = 0x01;
+        Descriptor->u.Port.Start.LowPart = Ports[i];
+    }
+
+    PdoExt->ResourceList = ResourceList;
+    PdoExt->ResourceListSize = ListSize;
+    return STATUS_SUCCESS;
+}
+
 static
 NTSTATUS
 NTAPI
@@ -435,6 +474,10 @@ IsaPnpCreateReadPortDO(PISAPNP_FDO_EXTENSION FdoExt)
     if (!NT_SUCCESS(Status))
         return Status;
 
+    Status = IsaPnpCreateReadPortDOResources(PdoExt);
+    if (!NT_SUCCESS(Status))
+        return Status;
+
     return Status;
 }