[PATCH 1/2] s0idle: add a test to verify lower power s0 idle is enabled

Alex Hung alex.hung at canonical.com
Wed Sep 9 23:17:00 UTC 2020


Signed-off-by: Alex Hung <alex.hung at canonical.com>
---
 src/Makefile.am          |  1 +
 src/bios/s0idle/s0idle.c | 76 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 77 insertions(+)
 create mode 100644 src/bios/s0idle/s0idle.c

diff --git a/src/Makefile.am b/src/Makefile.am
index 19ae7a05..5d78411b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -161,6 +161,7 @@ fwts_SOURCES = main.c 				\
 	bios/pciirq/pciirq.c 			\
 	bios/pnp/pnp.c 				\
 	bios/romdump/romdump.c 			\
+	bios/s0idle/s0idle.c 			\
 	cmos/cmosdump/cmosdump.c 		\
 	coreboot/clog/clog.c			\
 	cpu/virt/virt.c 			\
diff --git a/src/bios/s0idle/s0idle.c b/src/bios/s0idle/s0idle.c
new file mode 100644
index 00000000..b6ccca48
--- /dev/null
+++ b/src/bios/s0idle/s0idle.c
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2020 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"
+
+#if defined(FWTS_HAS_ACPI)
+
+#include "fwts_acpi_object_eval.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <inttypes.h>
+#include <string.h>
+
+
+static fwts_acpi_table_info *table;
+
+static int s0idle_init(fwts_framework *fw)
+{
+	if (fwts_acpi_find_table(fw, "FACP", 0, &table) != FWTS_OK) {
+		fwts_log_error(fw, "Cannot read ACPI table FACP.");
+		return FWTS_ERROR;
+	}
+	if (table == NULL) {
+		fwts_log_error(fw, "ACPI table FACP does not exist!");
+		return FWTS_ERROR;
+	}
+
+	return FWTS_OK;
+}
+
+static int s0idle_test1(fwts_framework *fw)
+{
+	fwts_acpi_table_fadt *fadt = (fwts_acpi_table_fadt*) table->data;
+
+	if (fadt->flags & FWTS_FACP_FLAG_LOW_POWER_S0_IDLE_CAPABLE)
+		fwts_passed(fw, "LOW_POWER_S0_IDLE_CAPABLE is set in ACPI FADT.");
+	else
+		fwts_failed(fw, LOG_LEVEL_HIGH, "S0idleNoFADT", "LOW_POWER_S0_IDLE_CAPABLE is not set in ACPI FADT.");
+
+	return FWTS_OK;
+}
+
+static fwts_framework_minor_test s0idle_tests[] = {
+	{ s0idle_test1, "Test ACPI FADT S0 idle capable." },
+	{ NULL, NULL }
+};
+
+static fwts_framework_ops s0idle = {
+	.description = "S0IDLE FADT Low Power S0 Idle tests.",
+	.init        = s0idle_init,
+	.minor_tests = s0idle_tests
+};
+
+FWTS_REGISTER("s0idle", &s0idle, FWTS_TEST_ANYTIME, FWTS_FLAG_UTILS)
+#endif
-- 
2.25.1




More information about the fwts-devel mailing list