diff --git a/drivers/bus/isapnp/isapnp.c b/drivers/bus/isapnp/isapnp.c index c9025875ddc..6f22efcd014 100644 --- a/drivers/bus/isapnp/isapnp.c +++ b/drivers/bus/isapnp/isapnp.c @@ -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; } diff --git a/drivers/bus/isapnp/isapnp.h b/drivers/bus/isapnp/isapnp.h index 2d45ce6cac7..416ed2df55f 100644 --- a/drivers/bus/isapnp/isapnp.h +++ b/drivers/bus/isapnp/isapnp.h @@ -54,6 +54,8 @@ typedef struct _ISAPNP_PDO_EXTENSION { UNICODE_STRING CompatibleIDs; UNICODE_STRING InstanceID; PIO_RESOURCE_REQUIREMENTS_LIST RequirementsList; + PCM_RESOURCE_LIST ResourceList; + ULONG ResourceListSize; } ISAPNP_PDO_EXTENSION, *PISAPNP_PDO_EXTENSION; /* isapnp.c */ diff --git a/drivers/bus/isapnp/pdo.c b/drivers/bus/isapnp/pdo.c index cecb3d2000f..d4a34cf78ec 100644 --- a/drivers/bus/isapnp/pdo.c +++ b/drivers/bus/isapnp/pdo.c @@ -6,7 +6,6 @@ */ #include -#include #define NDEBUG #include @@ -144,34 +143,18 @@ IsaPdoQueryResources( IN PIRP Irp, IN PIO_STACK_LOCATION IrpSp) { - USHORT Ports[] = { ISAPNP_WRITE_DATA, ISAPNP_ADDRESS }; - ULONG ListSize, i; + ULONG ListSize; PCM_RESOURCE_LIST ResourceList; - PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor; - ListSize = sizeof(CM_RESOURCE_LIST) - + (ARRAYSIZE(Ports) - 1) * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR); - ResourceList = ExAllocatePool(NonPagedPool, ListSize); + if (!PdoExt->ResourceList) + return Irp->IoStatus.Status; + + ListSize = PdoExt->ResourceListSize; + 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]; - } - + RtlCopyMemory(ResourceList, PdoExt->ResourceList, ListSize); Irp->IoStatus.Information = (ULONG_PTR)ResourceList; return STATUS_SUCCESS; } @@ -348,10 +331,7 @@ IsaPdoPnp( break; case IRP_MN_QUERY_RESOURCES: - if (PdoExt->Common.Self == PdoExt->FdoExt->DataPortPdo) - Status = IsaPdoQueryResources(PdoExt, Irp, IrpSp); - else - DPRINT1("IRP_MN_QUERY_RESOURCES is UNIMPLEMENTED!\n"); + Status = IsaPdoQueryResources(PdoExt, Irp, IrpSp); break; case IRP_MN_QUERY_RESOURCE_REQUIREMENTS: