mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 19:12:57 +00:00
Implement IRP_MN_QUERY_RESOURCE_REQUIREMENTS
svn path=/trunk/; revision=15399
This commit is contained in:
parent
7646e46a35
commit
4507d7ac14
3 changed files with 88 additions and 0 deletions
|
@ -119,12 +119,16 @@ AcpiCreateInstanceIDString(PUNICODE_STRING InstanceID,
|
||||||
static BOOLEAN
|
static BOOLEAN
|
||||||
AcpiCreateResourceList(PCM_RESOURCE_LIST* pResourceList,
|
AcpiCreateResourceList(PCM_RESOURCE_LIST* pResourceList,
|
||||||
PULONG ResourceListSize,
|
PULONG ResourceListSize,
|
||||||
|
PIO_RESOURCE_REQUIREMENTS_LIST* pRequirementsList,
|
||||||
|
PULONG RequirementsListSize,
|
||||||
RESOURCE* resources)
|
RESOURCE* resources)
|
||||||
{
|
{
|
||||||
BOOLEAN Done;
|
BOOLEAN Done;
|
||||||
ULONG NumberOfResources = 0;
|
ULONG NumberOfResources = 0;
|
||||||
PCM_RESOURCE_LIST ResourceList;
|
PCM_RESOURCE_LIST ResourceList;
|
||||||
|
PIO_RESOURCE_REQUIREMENTS_LIST RequirementsList;
|
||||||
PCM_PARTIAL_RESOURCE_DESCRIPTOR ResourceDescriptor;
|
PCM_PARTIAL_RESOURCE_DESCRIPTOR ResourceDescriptor;
|
||||||
|
PIO_RESOURCE_DESCRIPTOR RequirementDescriptor;
|
||||||
RESOURCE* resource;
|
RESOURCE* resource;
|
||||||
ULONG i;
|
ULONG i;
|
||||||
KIRQL Dirql;
|
KIRQL Dirql;
|
||||||
|
@ -176,6 +180,24 @@ AcpiCreateResourceList(PCM_RESOURCE_LIST* pResourceList,
|
||||||
ResourceList->List[0].PartialResourceList.Count = NumberOfResources;
|
ResourceList->List[0].PartialResourceList.Count = NumberOfResources;
|
||||||
ResourceDescriptor = ResourceList->List[0].PartialResourceList.PartialDescriptors;
|
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 */
|
/* Fill resources list structure */
|
||||||
Done = FALSE;
|
Done = FALSE;
|
||||||
resource = resources;
|
resource = resources;
|
||||||
|
@ -199,7 +221,16 @@ AcpiCreateResourceList(PCM_RESOURCE_LIST* pResourceList,
|
||||||
&Dirql,
|
&Dirql,
|
||||||
&ResourceDescriptor->u.Interrupt.Affinity);
|
&ResourceDescriptor->u.Interrupt.Affinity);
|
||||||
ResourceDescriptor->u.Interrupt.Level = (ULONG)Dirql;
|
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++;
|
ResourceDescriptor++;
|
||||||
|
RequirementDescriptor++;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -225,7 +256,16 @@ AcpiCreateResourceList(PCM_RESOURCE_LIST* pResourceList,
|
||||||
case TRANSFER_8_16: ResourceDescriptor->Flags |= CM_RESOURCE_DMA_8_AND_16; break;
|
case TRANSFER_8_16: ResourceDescriptor->Flags |= CM_RESOURCE_DMA_8_AND_16; break;
|
||||||
}
|
}
|
||||||
ResourceDescriptor->u.Dma.Channel = dma_data->channels[i];
|
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++;
|
ResourceDescriptor++;
|
||||||
|
RequirementDescriptor++;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -242,7 +282,18 @@ AcpiCreateResourceList(PCM_RESOURCE_LIST* pResourceList,
|
||||||
ResourceDescriptor->u.Port.Start.u.HighPart = 0;
|
ResourceDescriptor->u.Port.Start.u.HighPart = 0;
|
||||||
ResourceDescriptor->u.Port.Start.u.LowPart = io_data->min_base_address;
|
ResourceDescriptor->u.Port.Start.u.LowPart = io_data->min_base_address;
|
||||||
ResourceDescriptor->u.Port.Length = io_data->range_length;
|
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++;
|
ResourceDescriptor++;
|
||||||
|
RequirementDescriptor++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case end_tag:
|
case end_tag:
|
||||||
|
@ -366,6 +417,8 @@ FdoQueryBusRelations(
|
||||||
}
|
}
|
||||||
if (!AcpiCreateResourceList(&PdoDeviceExtension->ResourceList,
|
if (!AcpiCreateResourceList(&PdoDeviceExtension->ResourceList,
|
||||||
&PdoDeviceExtension->ResourceListSize,
|
&PdoDeviceExtension->ResourceListSize,
|
||||||
|
&PdoDeviceExtension->ResourceRequirementsList,
|
||||||
|
&PdoDeviceExtension->ResourceRequirementsListSize,
|
||||||
(RESOURCE*)Buffer.pointer))
|
(RESOURCE*)Buffer.pointer))
|
||||||
{
|
{
|
||||||
ASSERT(FALSE);
|
ASSERT(FALSE);
|
||||||
|
|
|
@ -50,6 +50,9 @@ typedef struct _PDO_DEVICE_EXTENSION
|
||||||
// Resource list
|
// Resource list
|
||||||
PCM_RESOURCE_LIST ResourceList;
|
PCM_RESOURCE_LIST ResourceList;
|
||||||
ULONG ResourceListSize;
|
ULONG ResourceListSize;
|
||||||
|
// Requirement list
|
||||||
|
PIO_RESOURCE_REQUIREMENTS_LIST ResourceRequirementsList;
|
||||||
|
ULONG ResourceRequirementsListSize;
|
||||||
} PDO_DEVICE_EXTENSION, *PPDO_DEVICE_EXTENSION;
|
} PDO_DEVICE_EXTENSION, *PPDO_DEVICE_EXTENSION;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -107,6 +107,35 @@ PdoQueryId(
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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
|
static NTSTATUS
|
||||||
PdoQueryResources(
|
PdoQueryResources(
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
IN PDEVICE_OBJECT DeviceObject,
|
||||||
|
@ -227,6 +256,9 @@ PdoPnpControl(
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IRP_MN_QUERY_RESOURCE_REQUIREMENTS:
|
case IRP_MN_QUERY_RESOURCE_REQUIREMENTS:
|
||||||
|
Status = PdoQueryResourceRequirements(DeviceObject,
|
||||||
|
Irp,
|
||||||
|
IrpSp);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IRP_MN_QUERY_RESOURCES:
|
case IRP_MN_QUERY_RESOURCES:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue