[PATCH 08/30] acpi: move RSDT test from acpitables into new RSDT test
Colin King
colin.king at canonical.com
Thu Jun 18 08:49:20 UTC 2015
From: Colin Ian King <colin.king at canonical.com>
Re-organise RSDT test, move it out of acpitables and into
a new acpi RSDT test
Signed-off-by: Colin Ian King <colin.king at canonical.com>
---
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; i<n; i++) {
- if (rsdt->entries[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 <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <inttypes.h>
+#include <string.h>
+
+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)
--
2.1.4
More information about the fwts-devel
mailing list