[PATCH 07/30] acpi: move RSDP test from acpitables into new RSDP test
Colin King
colin.king at canonical.com
Thu Jun 18 08:49:19 UTC 2015
From: Colin Ian King <colin.king at canonical.com>
Re-organise RSDP test, move it out of acpitables and into
a new acpi RSDP test
Signed-off-by: Colin Ian King <colin.king at canonical.com>
---
src/Makefile.am | 1 +
src/acpi/acpitables/acpitables.c | 24 ----------
src/acpi/rsdp/rsdp.c | 96 ++++++++++++++++++++++++++++++++++++++++
3 files changed, 97 insertions(+), 24 deletions(-)
create mode 100644 src/acpi/rsdp/rsdp.c
diff --git a/src/Makefile.am b/src/Makefile.am
index 6a20bf2..0209006 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -57,6 +57,7 @@ fwts_SOURCES = main.c \
acpi/pcc/pcc.c \
acpi/powerbutton/powerbutton.c \
acpi/plddump/plddump.c \
+ acpi/rsdp/rsdp.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 8822eb4..2deb24a 100644
--- a/src/acpi/acpitables/acpitables.c
+++ b/src/acpi/acpitables/acpitables.c
@@ -230,29 +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_rsdp(fwts_framework *fw, fwts_acpi_table_info *table)
-{
- fwts_acpi_table_rsdp *rsdp = (fwts_acpi_table_rsdp*)table->data;
- int i;
- int passed;
-
- for (passed=0,i=0;i<6;i++) {
- if (isalnum(rsdp->oem_id[i]))
- passed++;
- }
- if (!passed) {
- fwts_failed(fw, LOG_LEVEL_MEDIUM, "RSDPBadOEMId", "RSDP: oem_id does not contain any alpha numeric characters.");
- fwts_advice(fw, "The RSDP OEM Id is non-conforming, but this will not affect the system behaviour. However "
- "this should be fixed if possible to make the firmware ACPI complaint.");
- }
-
- if (rsdp->revision > 2) {
- fwts_failed(fw, LOG_LEVEL_MEDIUM, "RSDPBadRevisionId", "RSDP: revision is %" PRIu8
- ", expected value less than 2.", rsdp->revision);
- fwts_advice(fw, "A RSDP revision number greater than 2 probably won't cause any system problems.");
- }
-}
-
static void acpi_table_check_rsdt(fwts_framework *fw, fwts_acpi_table_info *table)
{
int i;
@@ -313,7 +290,6 @@ static acpi_table_check_table check_table[] = {
{ "FACP", acpi_table_check_fadt },
{ "MCFG", acpi_table_check_mcfg },
{ "RSDT", acpi_table_check_rsdt },
- { "RSDP", acpi_table_check_rsdp },
{ "SBST", acpi_table_check_sbst },
{ NULL , NULL },
} ;
diff --git a/src/acpi/rsdp/rsdp.c b/src/acpi/rsdp/rsdp.c
new file mode 100644
index 0000000..cab263c
--- /dev/null
+++ b/src/acpi/rsdp/rsdp.c
@@ -0,0 +1,96 @@
+/*
+ * 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>
+#include <ctype.h>
+
+static fwts_acpi_table_info *table;
+
+static int rsdp_init(fwts_framework *fw)
+{
+ if (fwts_acpi_find_table(fw, "RSDP", 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 RSDP table does not exist, skipping test");
+ return FWTS_SKIP;
+ }
+ return FWTS_OK;
+}
+
+/*
+ * RSDP Root System Description Pointer
+ */
+static int rsdp_test1(fwts_framework *fw)
+{
+ fwts_acpi_table_rsdp *rsdp = (fwts_acpi_table_rsdp*)table->data;
+ bool passed = true;
+ size_t i;
+
+ for (i = 0; i < 6; i++) {
+ if (!isalnum(rsdp->oem_id[i])) {
+ passed = false;
+ break;
+ }
+ }
+ if (!passed) {
+ fwts_failed(fw, LOG_LEVEL_MEDIUM,
+ "RSDPBadOEMId",
+ "RSDP: oem_id does not contain any alpha "
+ "numeric characters.");
+ fwts_advice(fw,
+ "The RSDP OEM Id is non-conforming, but this "
+ "will not affect the system behaviour. However "
+ "this should be fixed if possible to make the "
+ "firmware ACPI complaint.");
+ }
+ if (rsdp->revision > 2) {
+ passed = false;
+ fwts_failed(fw, LOG_LEVEL_MEDIUM,
+ "RSDPBadRevisionId",
+ "RSDP: revision is %" PRIu8 ", expected "
+ "value less than 2.", rsdp->revision);
+ }
+
+ if (passed)
+ fwts_passed(fw, "No issues found in RSDP table.");
+
+ return FWTS_OK;
+}
+
+static fwts_framework_minor_test rsdp_tests[] = {
+ { rsdp_test1, "RSDP Root System Description Pointer test." },
+ { NULL, NULL }
+};
+
+static fwts_framework_ops rsdp_ops = {
+ .description = "RSDP Root System Description Pointer test.",
+ .init = rsdp_init,
+ .minor_tests = rsdp_tests
+};
+
+FWTS_REGISTER("rsdp", &rsdp_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