Parcourir la source

acpi: build_mcfg: use acpi_table_begin()/acpi_table_end() instead of build_header()

it replaces error-prone pointer arithmetic for build_header() API,
with 2 calls to start and finish table creation,
which hides offsets magic from API user.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Message-Id: <20210924122802.1455362-9-imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Igor Mammedov il y a 3 ans
Parent
commit
578bc7a064
1 fichiers modifiés avec 9 ajouts et 9 suppressions
  1. 9 9
      hw/acpi/pci.c

+ 9 - 9
hw/acpi/pci.c

@@ -28,19 +28,20 @@
 #include "hw/acpi/pci.h"
 #include "hw/acpi/pci.h"
 #include "hw/pci/pcie_host.h"
 #include "hw/pci/pcie_host.h"
 
 
+/*
+ * PCI Firmware Specification, Revision 3.0
+ * 4.1.2 MCFG Table Description.
+ */
 void build_mcfg(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info,
 void build_mcfg(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info,
                 const char *oem_id, const char *oem_table_id)
                 const char *oem_id, const char *oem_table_id)
 {
 {
-    int mcfg_start = table_data->len;
+    AcpiTable table = { .sig = "MCFG", .rev = 1,
+                        .oem_id = oem_id, .oem_table_id = oem_table_id };
+
+    acpi_table_begin(&table, table_data);
 
 
-    /*
-     * PCI Firmware Specification, Revision 3.0
-     * 4.1.2 MCFG Table Description.
-     */
-    acpi_data_push(table_data, sizeof(AcpiTableHeader));
     /* Reserved */
     /* Reserved */
     build_append_int_noprefix(table_data, 0, 8);
     build_append_int_noprefix(table_data, 0, 8);
-
     /*
     /*
      * Memory Mapped Enhanced Configuration Space Base Address Allocation
      * Memory Mapped Enhanced Configuration Space Base Address Allocation
      * Structure
      * Structure
@@ -56,6 +57,5 @@ void build_mcfg(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info,
     /* Reserved */
     /* Reserved */
     build_append_int_noprefix(table_data, 0, 4);
     build_append_int_noprefix(table_data, 0, 4);
 
 
-    build_header(linker, table_data, (void *)(table_data->data + mcfg_start),
-                 "MCFG", table_data->len - mcfg_start, 1, oem_id, oem_table_id);
+    acpi_table_end(linker, &table);
 }
 }