Perform the generation of the VIOT ACPI table in 2 separate passes: the first
pass
enumerates all of the PCI host bridges and adds the min_bus and max_bus
information
to an array.
Once this is done the VIOT table header is generated using the size of the array
to calculate the node count, which means it is no longer necessary to use a
sub-array to hold the PCI host bridge range information along with viommu_off.
Finally the PCI host bridge array is iterated again to add the required entries
to the final VIOT ACPI table.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
hw/acpi/viot.c | 42 ++++++++++++++++++++++++------------------
1 file changed, 24 insertions(+), 18 deletions(-)
@@ -44,8 +43,7 @@ static void build_pci_host_range(GArray *table_data, int
min_bus, int max_bus,
/* Build PCI range for a given PCI host bridge */
static int pci_host_bridges(Object *obj, void *opaque)
{
- struct viot_pci_ranges *pci_ranges = opaque;
- GArray *blob = pci_ranges->blob;
+ GArray *pci_host_ranges = opaque;
if (object_dynamic_cast(obj, TYPE_PCI_HOST_BRIDGE)) {
PCIBus *bus = PCI_HOST_BRIDGE(obj)->bus;
@@ -55,9 +53,11 @@ static int pci_host_bridges(Object *obj, void *opaque)
pci_bus_range(bus, &min_bus, &max_bus);
- build_pci_host_range(blob, min_bus, max_bus,
- pci_ranges->output_node);
- pci_ranges->count++;
+ struct viot_pci_host_range pci_host_range = {