mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-11 03:24:58 -06:00
tests: acpi: squash sanitize_fadt_ptrs() into test_acpi_fadt_table()
some parts of sanitize_fadt_ptrs() do redundant job - locating FADT - checking original checksum There is no need to do it as test_acpi_fadt_table() already does that, so drop duplicate code and move remaining fixup code into test_acpi_fadt_table(). Signed-off-by: Igor Mammedov <imammedo@redhat.com> Acked-by: Thomas Huth <thuth@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
3314778d88
commit
b997a04a50
1 changed files with 10 additions and 29 deletions
|
@ -128,6 +128,7 @@ static void test_acpi_fadt_table(test_data *data)
|
||||||
/* FADT table is 1st */
|
/* FADT table is 1st */
|
||||||
AcpiSdtTable table = g_array_index(data->tables, typeof(table), 0);
|
AcpiSdtTable table = g_array_index(data->tables, typeof(table), 0);
|
||||||
uint8_t *fadt_aml = table.aml;
|
uint8_t *fadt_aml = table.aml;
|
||||||
|
uint32_t fadt_len = table.aml_len;
|
||||||
|
|
||||||
ACPI_ASSERT_CMP(table.header->signature, "FACP");
|
ACPI_ASSERT_CMP(table.header->signature, "FACP");
|
||||||
|
|
||||||
|
@ -139,35 +140,17 @@ static void test_acpi_fadt_table(test_data *data)
|
||||||
acpi_fetch_table(data->qts, &table.aml, &table.aml_len,
|
acpi_fetch_table(data->qts, &table.aml, &table.aml_len,
|
||||||
fadt_aml + 40 /* DSDT */, "DSDT", true);
|
fadt_aml + 40 /* DSDT */, "DSDT", true);
|
||||||
g_array_append_val(data->tables, table);
|
g_array_append_val(data->tables, table);
|
||||||
}
|
|
||||||
|
|
||||||
static void sanitize_fadt_ptrs(test_data *data)
|
memset(fadt_aml + 36, 0, 4); /* sanitize FIRMWARE_CTRL ptr */
|
||||||
{
|
memset(fadt_aml + 40, 0, 4); /* sanitize DSDT ptr */
|
||||||
/* fixup pointers in FADT */
|
if (fadt_aml[8 /* FADT Major Version */] >= 3) {
|
||||||
int i;
|
memset(fadt_aml + 132, 0, 8); /* sanitize X_FIRMWARE_CTRL ptr */
|
||||||
|
memset(fadt_aml + 140, 0, 8); /* sanitize X_DSDT ptr */
|
||||||
for (i = 0; i < data->tables->len; i++) {
|
|
||||||
AcpiSdtTable *sdt = &g_array_index(data->tables, AcpiSdtTable, i);
|
|
||||||
|
|
||||||
if (memcmp(&sdt->header->signature, "FACP", 4)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* check original FADT checksum before sanitizing table */
|
|
||||||
g_assert(!acpi_calc_checksum(sdt->aml, sdt->aml_len));
|
|
||||||
|
|
||||||
memset(sdt->aml + 36, 0, 4); /* sanitize FIRMWARE_CTRL ptr */
|
|
||||||
memset(sdt->aml + 40, 0, 4); /* sanitize DSDT ptr */
|
|
||||||
if (sdt->header->revision >= 3) {
|
|
||||||
memset(sdt->aml + 132, 0, 8); /* sanitize X_FIRMWARE_CTRL ptr */
|
|
||||||
memset(sdt->aml + 140, 0, 8); /* sanitize X_DSDT ptr */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* update checksum */
|
/* update checksum */
|
||||||
sdt->header->checksum = 0;
|
fadt_aml[9 /* Checksum */] = 0;
|
||||||
sdt->header->checksum -= acpi_calc_checksum(sdt->aml, sdt->aml_len);
|
fadt_aml[9 /* Checksum */] -= acpi_calc_checksum(fadt_aml, fadt_len);
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dump_aml_files(test_data *data, bool rebuild)
|
static void dump_aml_files(test_data *data, bool rebuild)
|
||||||
|
@ -543,8 +526,6 @@ static void test_acpi_one(const char *params, test_data *data)
|
||||||
test_acpi_rsdt_table(data);
|
test_acpi_rsdt_table(data);
|
||||||
test_acpi_fadt_table(data);
|
test_acpi_fadt_table(data);
|
||||||
|
|
||||||
sanitize_fadt_ptrs(data);
|
|
||||||
|
|
||||||
if (iasl) {
|
if (iasl) {
|
||||||
if (getenv(ACPI_REBUILD_EXPECTED_AML)) {
|
if (getenv(ACPI_REBUILD_EXPECTED_AML)) {
|
||||||
dump_aml_files(data, true);
|
dump_aml_files(data, true);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue