From patchwork Thu Jun 18 08:49:20 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Ian King X-Patchwork-Id: 486166 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id B110E140129; Thu, 18 Jun 2015 18:52:38 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1Z5VYr-0004X2-Ii; Thu, 18 Jun 2015 08:52:37 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1Z5VYa-0004SX-9J for fwts-devel@lists.ubuntu.com; Thu, 18 Jun 2015 08:52:20 +0000 Received: from [10.172.65.212] (helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1Z5VYZ-0004dq-SO for fwts-devel@lists.ubuntu.com; Thu, 18 Jun 2015 08:52:20 +0000 From: Colin King To: fwts-devel@lists.ubuntu.com Subject: [PATCH 08/30] acpi: move RSDT test from acpitables into new RSDT test Date: Thu, 18 Jun 2015 09:49:20 +0100 Message-Id: <1434617382-9980-9-git-send-email-colin.king@canonical.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1434617382-9980-1-git-send-email-colin.king@canonical.com> References: <1434617382-9980-1-git-send-email-colin.king@canonical.com> X-BeenThere: fwts-devel@lists.ubuntu.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: Firmware Test Suite Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: fwts-devel-bounces@lists.ubuntu.com Sender: fwts-devel-bounces@lists.ubuntu.com From: Colin Ian King Re-organise RSDT test, move it out of acpitables and into a new acpi RSDT test Signed-off-by: Colin Ian King Acked-by: Alex Hung Acked-by: Ivan Hu --- src/Makefile.am | 1 + src/acpi/acpitables/acpitables.c | 18 --------- src/acpi/rsdt/rsdt.c | 85 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 86 insertions(+), 18 deletions(-) create mode 100644 src/acpi/rsdt/rsdt.c diff --git a/src/Makefile.am b/src/Makefile.am index 0209006..487e083 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -58,6 +58,7 @@ fwts_SOURCES = main.c \ acpi/powerbutton/powerbutton.c \ acpi/plddump/plddump.c \ acpi/rsdp/rsdp.c \ + acpi/rsdt/rsdt.c \ acpi/s3/s3.c \ acpi/s3power/s3power.c \ acpi/s4/s4.c \ diff --git a/src/acpi/acpitables/acpitables.c b/src/acpi/acpitables/acpitables.c index 2deb24a..a66697b 100644 --- a/src/acpi/acpitables/acpitables.c +++ b/src/acpi/acpitables/acpitables.c @@ -230,23 +230,6 @@ static void acpi_table_check_fadt(fwts_framework *fw, fwts_acpi_table_info *tabl acpi_table_check_fadt_reset(fw, fadt); } -static void acpi_table_check_rsdt(fwts_framework *fw, fwts_acpi_table_info *table) -{ - int i; - int n; - fwts_acpi_table_rsdt *rsdt = (fwts_acpi_table_rsdt*)table->data; - - n = (table->length - sizeof(fwts_acpi_table_header)) / sizeof(uint32_t); - for (i=0; ientries[i] == 0) { - fwts_failed(fw, LOG_LEVEL_HIGH, "RSDTEntryNull", "RSDT Entry %d is null, should not be non-zero.", i); - fwts_advice(fw, "A RSDT pointer is null and therefore erroneously points to an invalid 32 bit " - "ACPI table header. At worse this will cause the kernel to oops, at best the kernel " - "may ignore this. However, it should be fixed where possible."); - } - } -} - static void acpi_table_check_sbst(fwts_framework *fw, fwts_acpi_table_info *table) { fwts_acpi_table_sbst *sbst = (fwts_acpi_table_sbst*)table->data; @@ -289,7 +272,6 @@ typedef struct { static acpi_table_check_table check_table[] = { { "FACP", acpi_table_check_fadt }, { "MCFG", acpi_table_check_mcfg }, - { "RSDT", acpi_table_check_rsdt }, { "SBST", acpi_table_check_sbst }, { NULL , NULL }, } ; diff --git a/src/acpi/rsdt/rsdt.c b/src/acpi/rsdt/rsdt.c new file mode 100644 index 0000000..0151b02 --- /dev/null +++ b/src/acpi/rsdt/rsdt.c @@ -0,0 +1,85 @@ +/* + * Copyright (C) 2015 Canonical + * + * Portions of this code original from the Linux-ready Firmware Developer Kit + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ +#include "fwts.h" + +#include +#include +#include +#include +#include + +static fwts_acpi_table_info *table; + +static int rsdt_init(fwts_framework *fw) +{ + if (fwts_acpi_find_table(fw, "RSDT", 0, &table) != FWTS_OK) { + fwts_log_error(fw, "Cannot read ACPI tables."); + return FWTS_ERROR; + } + if (table == NULL || (table && table->length == 0)) { + fwts_log_error(fw, "ACPI RSDT table does not exist, skipping test"); + return FWTS_SKIP; + } + return FWTS_OK; +} + +/* + * RSDT Extended System Description Table + */ +static int rsdt_test1(fwts_framework *fw) +{ + fwts_acpi_table_rsdt *rsdt = (fwts_acpi_table_rsdt*)table->data; + size_t i, n; + bool passed = true; + + n = (table->length - sizeof(fwts_acpi_table_header)) / sizeof(uint32_t); + for (i = 0; i < n; i++) { + if (rsdt->entries[i] == 0) { + passed = false; + fwts_failed(fw, LOG_LEVEL_HIGH, + "RSDTEntryNull", + "RSDT Entry %zd is null, should not be non-zero.", i); + fwts_advice(fw, + "A XSDT pointer is null and therefore erroneously " + "points to an invalid 32 bit ACPI table header. " + "At worse this will cause the kernel to oops, at " + "best the kernel may ignore this. However, it " + "should be fixed where possible."); + } + } + if (passed) + fwts_passed(fw, "No issues found in RSDT table."); + + return FWTS_OK; +} + +static fwts_framework_minor_test rsdt_tests[] = { + { rsdt_test1, "RSDT Root System Description Table test." }, + { NULL, NULL } +}; + +static fwts_framework_ops rsdt_ops = { + .description = "RSDT Root System Description Table test.", + .init = rsdt_init, + .minor_tests = rsdt_tests +}; + +FWTS_REGISTER("rsdt", &rsdt_ops, FWTS_TEST_ANYTIME, FWTS_FLAG_BATCH | FWTS_FLAG_ROOT_PRIV | FWTS_FLAG_TEST_ACPI)