diff mbox

[20/21] FADT: add in SLEEP_CONTROL_REG and SLEEP_STATUS_REG compliance tests

Message ID 1454981583-31872-21-git-send-email-al.stone@linaro.org
State Superseded
Headers show

Commit Message

Al Stone Feb. 9, 2016, 1:33 a.m. UTC
When in reduced hardware mode, these fields may or may not be used.  If
they are, there are rules to check to make the values are reasonable.
It is also possible that these fields are simple null and not used at all.

Signed-off-by: Al Stone <al.stone@linaro.org>

---
 src/acpi/fadt/fadt.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 63 insertions(+)

-- 
2.5.0
diff mbox

Patch

diff --git a/src/acpi/fadt/fadt.c b/src/acpi/fadt/fadt.c
index a2ed70c..05205cb 100644
--- a/src/acpi/fadt/fadt.c
+++ b/src/acpi/fadt/fadt.c
@@ -1452,6 +1452,66 @@  static void acpi_table_check_fadt_p_lvl3_lat(fwts_framework *fw, uint64_t pblk)
 	return;
 }
 
+static void acpi_table_check_fadt_sleep_control_reg(fwts_framework *fw)
+{
+	if (fwts_acpi_is_reduced_hardware(fadt)) {
+		if (fadt->sleep_control_reg.address == 0)
+			fwts_passed(fw, "FADT SLEEP_CONTROL_REG not in use.");
+		else {
+			if (fadt->sleep_control_reg.register_bit_width == 8 &&
+			    fadt->sleep_control_reg.register_bit_offset == 0)
+				fwts_passed(fw, "FADT SLEEP_CONTROL_REG is "
+					    "in use and well-defined.");
+			else
+				fwts_failed(fw, LOG_LEVEL_MEDIUM,
+					    "SleepControlRegHasBadGAS",
+					    "FADT SLEEP_CONTROL_REG is "
+					    "in use but register width or "
+					    "offset is incorrect.");
+		}
+	} else {
+		if (fadt->sleep_control_reg.address == 0)
+			fwts_passed(fw, "FADT SLEEP_CONTROL_REG is null and "
+				    "not available when not in reduced "
+				    "hardware mode.");
+		else
+			fwts_failed(fw, LOG_LEVEL_MEDIUM,
+				    "SleepControlRegNotAllowed",
+				    "FADT SLEEP_CONTROL_REG is defined but "
+				    "will be ignored reduced hardware mode.");
+	}
+}
+
+static void acpi_table_check_fadt_sleep_status_reg(fwts_framework *fw)
+{
+	if (fwts_acpi_is_reduced_hardware(fadt)) {
+		if (fadt->sleep_status_reg.address == 0)
+			fwts_passed(fw, "FADT SLEEP_STATUS_REG not in use.");
+		else {
+			if (fadt->sleep_status_reg.register_bit_width == 8 &&
+			    fadt->sleep_status_reg.register_bit_offset == 0)
+				fwts_passed(fw, "FADT SLEEP_STATUS_REG is "
+					    "in use and well-defined.");
+			else
+				fwts_failed(fw, LOG_LEVEL_MEDIUM,
+					    "SleepStatusRegHasBadGAS",
+					    "FADT SLEEP_STATUS_REG is "
+					    "in use but register width or "
+					    "offset is incorrect.");
+		}
+	} else {
+		if (fadt->sleep_status_reg.address == 0)
+			fwts_passed(fw, "FADT SLEEP_STATUS_REG is null and "
+				    "not available when not in reduced "
+				    "hardware mode.");
+		else
+			fwts_failed(fw, LOG_LEVEL_MEDIUM,
+				    "SleepStatusRegNotAllowed",
+				    "FADT SLEEP_STATUS_REG is defined but "
+				    "will be ignored reduced hardware mode.");
+	}
+}
+
 static int fadt_test1(fwts_framework *fw)
 {
 	bool passed = true;
@@ -1518,6 +1578,9 @@  static int fadt_test1(fwts_framework *fw)
 		fwts_log_info(fw, "FADT CENTURY is %" PRIu8, fadt->century);
 	}
 
+	acpi_table_check_fadt_sleep_control_reg(fw);
+	acpi_table_check_fadt_sleep_status_reg(fw);
+
 	/*
 	 * Cannot really test the Hypervisor Vendor Identity since
 	 * the value is provided by the hypervisor to the OS (as a