acpi: vmgenid_build_acpi: 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-13-imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
de67dd1be0
commit
b25681c358
|
@ -29,6 +29,8 @@ void vmgenid_build_acpi(VmGenIdState *vms, GArray *table_data, GArray *guid,
|
||||||
Aml *ssdt, *dev, *scope, *method, *addr, *if_ctx;
|
Aml *ssdt, *dev, *scope, *method, *addr, *if_ctx;
|
||||||
uint32_t vgia_offset;
|
uint32_t vgia_offset;
|
||||||
QemuUUID guid_le;
|
QemuUUID guid_le;
|
||||||
|
AcpiTable table = { .sig = "SSDT", .rev = 1,
|
||||||
|
.oem_id = oem_id, .oem_table_id = "VMGENID" };
|
||||||
|
|
||||||
/* Fill in the GUID values. These need to be converted to little-endian
|
/* Fill in the GUID values. These need to be converted to little-endian
|
||||||
* first, since that's what the guest expects
|
* first, since that's what the guest expects
|
||||||
|
@ -42,12 +44,10 @@ void vmgenid_build_acpi(VmGenIdState *vms, GArray *table_data, GArray *guid,
|
||||||
g_array_insert_vals(guid, VMGENID_GUID_OFFSET, guid_le.data,
|
g_array_insert_vals(guid, VMGENID_GUID_OFFSET, guid_le.data,
|
||||||
ARRAY_SIZE(guid_le.data));
|
ARRAY_SIZE(guid_le.data));
|
||||||
|
|
||||||
/* Put this in a separate SSDT table */
|
/* Put VMGNEID into a separate SSDT table */
|
||||||
|
acpi_table_begin(&table, table_data);
|
||||||
ssdt = init_aml_allocator();
|
ssdt = init_aml_allocator();
|
||||||
|
|
||||||
/* Reserve space for header */
|
|
||||||
acpi_data_push(ssdt->buf, sizeof(AcpiTableHeader));
|
|
||||||
|
|
||||||
/* Storage for the GUID address */
|
/* Storage for the GUID address */
|
||||||
vgia_offset = table_data->len +
|
vgia_offset = table_data->len +
|
||||||
build_append_named_dword(ssdt->buf, "VGIA");
|
build_append_named_dword(ssdt->buf, "VGIA");
|
||||||
|
@ -116,9 +116,8 @@ void vmgenid_build_acpi(VmGenIdState *vms, GArray *table_data, GArray *guid,
|
||||||
ACPI_BUILD_TABLE_FILE, vgia_offset, sizeof(uint32_t),
|
ACPI_BUILD_TABLE_FILE, vgia_offset, sizeof(uint32_t),
|
||||||
VMGENID_GUID_FW_CFG_FILE, 0);
|
VMGENID_GUID_FW_CFG_FILE, 0);
|
||||||
|
|
||||||
build_header(linker, table_data,
|
/* must be called after above command to ensure correct table checksum */
|
||||||
(void *)(table_data->data + table_data->len - ssdt->buf->len),
|
acpi_table_end(linker, &table);
|
||||||
"SSDT", ssdt->buf->len, 1, oem_id, "VMGENID");
|
|
||||||
free_aml_allocator();
|
free_aml_allocator();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue