From patchwork Thu Jul 19 05:49:07 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Ian King X-Patchwork-Id: 171889 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from chlorine.canonical.com (chlorine.canonical.com [91.189.94.204]) by ozlabs.org (Postfix) with ESMTP id C0A402C0102 for ; Thu, 19 Jul 2012 15:49:15 +1000 (EST) Received: from localhost ([127.0.0.1] helo=chlorine.canonical.com) by chlorine.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1Srjbu-0004J6-Fj for incoming@patchwork.ozlabs.org; Thu, 19 Jul 2012 05:49:14 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by chlorine.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1Srjbs-0004J0-9y for fwts-devel@lists.ubuntu.com; Thu, 19 Jul 2012 05:49:12 +0000 Received: from [12.232.236.2] (helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1Srjbr-0007We-RG for fwts-devel@lists.ubuntu.com; Thu, 19 Jul 2012 05:49:12 +0000 From: Colin King To: fwts-devel@lists.ubuntu.com Subject: [PATCH 1/2] lib: acpi_acpi_tables: Add tables based on ACPI name and not file name. Date: Wed, 18 Jul 2012 22:49:07 -0700 Message-Id: <1342676948-21368-1-git-send-email-colin.king@canonical.com> X-Mailer: git-send-email 1.7.10.4 X-BeenThere: fwts-devel@lists.ubuntu.com X-Mailman-Version: 2.1.13 Precedence: list List-Id: Firmware Test Suite Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: fwts-devel-bounces@lists.ubuntu.com Errors-To: fwts-devel-bounces@lists.ubuntu.com From: Colin Ian King When loading ACPI tables from raw files using the -t option load the table name from the table signature rather than using the filename. We need to ensure we cater for the RSD PTR and also normal ACPI table signatures correctly too. Signed-off-by: Colin Ian King Acked-by: Ivan Hu Acked-by: Keng-Yu Lin --- src/lib/src/fwts_acpi_tables.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/lib/src/fwts_acpi_tables.c b/src/lib/src/fwts_acpi_tables.c index bd47e99..4db5844 100644 --- a/src/lib/src/fwts_acpi_tables.c +++ b/src/lib/src/fwts_acpi_tables.c @@ -484,14 +484,29 @@ static int fwts_acpi_load_tables_from_file(fwts_framework *fw) if ((fd = open(path, O_RDONLY)) >= 0) { uint8_t *table; size_t length; - char name[PATH_MAX]; - strcpy(name, dir_entries[i]->d_name); - name[strlen(name)-4] = '\0'; - if ((table = fwts_acpi_load_table_from_file(fd, &length)) != NULL) + if ((table = fwts_acpi_load_table_from_file(fd, &length)) != NULL) { + char name[9]; /* "RSD PTR " or standard ACPI 4 letter name */ + + fwts_acpi_table_rsdp *rsdp = (fwts_acpi_table_rsdp *)table; + + /* Could be RSDP or a standard ACPI table, so check */ + + if (!strncmp(rsdp->signature, "RSD PTR ", 8)) { + /* In fwts, RSD PTR is tagged as the RSDP */ + strcpy(name, "RSDP"); + } else { + /* Assume it is a standard ACPI table */ + fwts_acpi_table_header *hdr = (fwts_acpi_table_header *)table; + + strncpy(name, hdr->signature, 4); + name[4] = '\0'; + } + fwts_acpi_add_table(name, table, (uint64_t)fwts_fake_physical_addr(length), length, FWTS_ACPI_TABLE_FROM_FILE); + } close(fd); } else fwts_log_error(fw, "Cannot load ACPI table from file '%s'\n", path);