From patchwork Thu Jul 19 05:49:08 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [2/2] lib: fwts_acpi_tables: Force fixup on XSDT and RSDT when loading from .dat files Date: Wed, 18 Jul 2012 19:49:08 -0000 From: Colin King X-Patchwork-Id: 171890 Message-Id: <1342676948-21368-2-git-send-email-colin.king@canonical.com> To: fwts-devel@lists.ubuntu.com From: Colin Ian King When loading raw ACPI tables from .dat files we have no idea where the original .dat tables were in memory, so this means that loading in the XSDT and RSDT is problematic because these contain references to the original tables in memory but we have no clue how these match up with the raw data. Since fwts has to fake the addresses of the loaded ACPI tables these don't match those in the loaded XSDT and RSDT which leads to the ACPICA core getting confused. The best strategy is to therefore not load the XSDT and RSDT and rely on the fwts table fix up stage to notice we haven't loaded the XSDT and RSDT and let this create these tables based on the tables we have loaded from the raw .dat data, leading us to having sane XSDT and RSDT that correctly reference the loaded ACPI tables even if they are at faked addresses. Signed-off-by: Colin Ian King Acked-by: Ivan Hu Acked-by: Keng-Yu Lin --- src/lib/src/fwts_acpi_tables.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/lib/src/fwts_acpi_tables.c b/src/lib/src/fwts_acpi_tables.c index 4db5844..f388cdd 100644 --- a/src/lib/src/fwts_acpi_tables.c +++ b/src/lib/src/fwts_acpi_tables.c @@ -503,9 +503,24 @@ static int fwts_acpi_load_tables_from_file(fwts_framework *fw) name[4] = '\0'; } - fwts_acpi_add_table(name, table, - (uint64_t)fwts_fake_physical_addr(length), length, - FWTS_ACPI_TABLE_FROM_FILE); + if (!strncmp(name, "XSDT", 4) || !strncmp(name, "RSDT", 4)) { + /* + * For XSDT and RSDT we don't bother loading at this point. + * These tables point to the other tables, however, we can't + * figure out which table each pointer references because + * we are loading in raw table data and we don't know where + * these were located in the original machine. So the best + * way forward is to ignore these tables and instead leave + * the fix up stage fwts_acpi_load_tables_fixup() to magically + * create faked XSDT and RSDT entries based on the tables + * we've loaded from file. + */ + fwts_low_free(table); + } else { + fwts_acpi_add_table(name, table, + (uint64_t)fwts_fake_physical_addr(length), length, + FWTS_ACPI_TABLE_FROM_FILE); + } } close(fd); } else