[PATCH 10/30] acpi: move SBST test from acpitables into new SBST test
Colin King
colin.king at canonical.com
Thu Jun 18 08:49:22 UTC 2015
From: Colin Ian King <colin.king at canonical.com>
Re-organise SBST test, move it out of acpitables and into
a new acpi SBST test
Signed-off-by: Colin Ian King <colin.king at canonical.com>
---
src/acpi/acpitables/acpitables.c | 27 ------------
src/acpi/sbst/sbst.c | 95 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 95 insertions(+), 27 deletions(-)
create mode 100644 src/acpi/sbst/sbst.c
diff --git a/src/acpi/acpitables/acpitables.c b/src/acpi/acpitables/acpitables.c
index bc68603..60d2af4 100644
--- a/src/acpi/acpitables/acpitables.c
+++ b/src/acpi/acpitables/acpitables.c
@@ -230,32 +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_sbst(fwts_framework *fw, fwts_acpi_table_info *table)
-{
- fwts_acpi_table_sbst *sbst = (fwts_acpi_table_sbst*)table->data;
-
- if (sbst->critical_energy_level > sbst->low_energy_level) {
- fwts_failed(fw, LOG_LEVEL_MEDIUM, "SBSTEnergyLevel1",
- "SBST Critical Energy Level (%" PRIu32 ") "
- "is greater than the Low Energy Level (%" PRIu32 ").",
- sbst->critical_energy_level, sbst->low_energy_level);
- fwts_advice(fw, "This could affect system behaviour based on incorrect smart battery information. This should be fixed.");
- }
-
- if (sbst->low_energy_level > sbst->warning_energy_level) {
- fwts_failed(fw, LOG_LEVEL_MEDIUM, "SBSTEnergeyLevel2",
- "SBST Low Energy Energy Level (%" PRIu32 ") "
- "is greater than the Warning Energy Level (%" PRIu32 ").",
- sbst->low_energy_level, sbst->warning_energy_level);
- fwts_advice(fw, "This could affect system behaviour based on incorrect smart battery information. This should be fixed.");
- }
-
- if (sbst->warning_energy_level == 0) {
- fwts_failed(fw, LOG_LEVEL_MEDIUM, "SBSTEnergyLevelZero", "SBST Warning Energy Level is zero, which is probably too low.");
- fwts_advice(fw, "This could affect system behaviour based on incorrect smart battery information. This should be fixed.");
- }
-}
-
typedef void (*check_func)(fwts_framework *fw, fwts_acpi_table_info *table);
typedef struct {
@@ -265,7 +239,6 @@ typedef struct {
static acpi_table_check_table check_table[] = {
{ "FACP", acpi_table_check_fadt },
- { "SBST", acpi_table_check_sbst },
{ NULL , NULL },
} ;
diff --git a/src/acpi/sbst/sbst.c b/src/acpi/sbst/sbst.c
new file mode 100644
index 0000000..f16817d
--- /dev/null
+++ b/src/acpi/sbst/sbst.c
@@ -0,0 +1,95 @@
+/*
+ * 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 sbst_init(fwts_framework *fw)
+{
+ if (fwts_acpi_find_table(fw, "SBST", 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 SBST table does not exist, skipping test");
+ return FWTS_SKIP;
+ }
+ return FWTS_OK;
+}
+
+/*
+ * SBST Extended System Description Table
+ */
+static int sbst_test1(fwts_framework *fw)
+{
+ fwts_acpi_table_sbst *sbst = (fwts_acpi_table_sbst*)table->data;
+ bool passed = true;
+
+ if (sbst->critical_energy_level > sbst->low_energy_level) {
+ passed = false;
+ fwts_failed(fw, LOG_LEVEL_MEDIUM,
+ "SBSTEnergyLevel1",
+ "SBST Critical Energy Level (%" PRIu32 ") "
+ "is greater than the Low Energy Level (%" PRIu32 ").",
+ sbst->critical_energy_level,
+ sbst->low_energy_level);
+ }
+ if (sbst->low_energy_level > sbst->warning_energy_level) {
+ passed = false;
+ fwts_failed(fw, LOG_LEVEL_MEDIUM,
+ "SBSTEnergeyLevel2",
+ "SBST Low Energy Energy Level (%" PRIu32 ") "
+ "is greater than the Warning Energy Level (%" PRIu32 ").",
+ sbst->low_energy_level,
+ sbst->warning_energy_level);
+ }
+ if (sbst->warning_energy_level == 0) {
+ passed = false;
+ fwts_failed(fw, LOG_LEVEL_MEDIUM,
+ "SBSTEnergyLevelZero",
+ "SBST Warning Energy Level is zero, "
+ "which is probably too low.");
+ }
+
+ if (passed)
+ fwts_passed(fw, "No issues found in SBST table.");
+
+ return FWTS_OK;
+}
+
+static fwts_framework_minor_test sbst_tests[] = {
+ { sbst_test1, "SBST Smart Battery Specificiation Table test." },
+ { NULL, NULL }
+};
+
+static fwts_framework_ops sbst_ops = {
+ .description = "SBST Smart Battery Specification Table test.",
+ .init = sbst_init,
+ .minor_tests = sbst_tests
+};
+
+FWTS_REGISTER("sbst", &sbst_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