aboutsummaryrefslogtreecommitdiff
path: root/hw/acpi
diff options
context:
space:
mode:
authorIgor Mammedov <imammedo@redhat.com>2021-09-24 08:27:31 -0400
committerMichael S. Tsirkin <mst@redhat.com>2021-10-05 17:30:57 -0400
commit7469f1991dc5e061ff724070c65e3fef96602bca (patch)
treecbe922f6cc7eaca490b4735e27eef86026afdd84 /hw/acpi
parentf497b7cae1cd052fdbc023f02d37921c4069f7e6 (diff)
acpi: build_slit: 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-5-imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'hw/acpi')
-rw-r--r--hw/acpi/aml-build.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
index 86b8322ee1..ec870f53ba 100644
--- a/hw/acpi/aml-build.c
+++ b/hw/acpi/aml-build.c
@@ -1958,11 +1958,12 @@ void build_srat_memory(AcpiSratMemoryAffinity *numamem, uint64_t base,
void build_slit(GArray *table_data, BIOSLinker *linker, MachineState *ms,
const char *oem_id, const char *oem_table_id)
{
- int slit_start, i, j;
- slit_start = table_data->len;
+ int i, j;
int nb_numa_nodes = ms->numa_state->num_nodes;
+ AcpiTable table = { .sig = "SLIT", .rev = 1,
+ .oem_id = oem_id, .oem_table_id = oem_table_id };
- acpi_data_push(table_data, sizeof(AcpiTableHeader));
+ acpi_table_begin(&table, table_data);
build_append_int_noprefix(table_data, nb_numa_nodes, 8);
for (i = 0; i < nb_numa_nodes; i++) {
@@ -1973,11 +1974,7 @@ void build_slit(GArray *table_data, BIOSLinker *linker, MachineState *ms,
1);
}
}
-
- build_header(linker, table_data,
- (void *)(table_data->data + slit_start),
- "SLIT",
- table_data->len - slit_start, 1, oem_id, oem_table_id);
+ acpi_table_end(linker, &table);
}
/* build rev1/rev3/rev5.1 FADT */