diff mbox

[v2,14/23] FADT: add compliance tests for the ACPI_ENABLE and ACPI_DISABLE fields

Message ID 1455925199-8587-15-git-send-email-al.stone@linaro.org
State New
Headers show

Commit Message

Al Stone Feb. 19, 2016, 11:39 p.m. UTC
Do some checking of allowed values for ACPI_ENABLE and ACPI_DISABLE
fields, particularly if SMI_CMD is defined.

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

Acked-by: Colin Ian King <colin.king@canonical.com>

Acked-by: Alex Hung <alex.hung@canonical.com>

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

-- 
2.5.0
diff mbox

Patch

diff --git a/src/acpi/fadt/fadt.c b/src/acpi/fadt/fadt.c
index 32b3b77..2c56eba 100644
--- a/src/acpi/fadt/fadt.c
+++ b/src/acpi/fadt/fadt.c
@@ -740,6 +740,59 @@  static void acpi_table_check_fadt_smi_cmd(fwts_framework *fw)
 	}
 }
 
+static void acpi_table_check_fadt_acpi_enable(fwts_framework *fw)
+{
+	if (fadt->acpi_enable == 0)
+		if (fadt->smi_cmd == 0)
+			fwts_passed(fw, "FADT SMI ACPI enable command is zero, "
+				    "which is allowed since SMM is not "
+				    "supported, or machine is in legacy mode.");
+		else
+			fwts_failed(fw, LOG_LEVEL_MEDIUM,
+				    "SMMHasNoAcpiEnableCmd",
+				    "FADT SMI ACPI enable command is zero, "
+				    "but this is not allowed when SMM "
+				    "is supported.");
+	else
+		if (fadt->smi_cmd == 0)
+			fwts_failed(fw, LOG_LEVEL_MEDIUM,
+				    "SMMNeedsAcpiEnableCmd",
+				    "FADT SMI ACPI enable command is non-zero, "
+				    "but SMM is not supported.");
+		else
+			fwts_passed(fw, "FADT SMI ACPI enable command is "
+				    "non-zero, and SMM is supported.");
+
+	return;
+}
+
+static void acpi_table_check_fadt_acpi_disable(fwts_framework *fw)
+{
+	if (fadt->acpi_disable == 0)
+		if (fadt->smi_cmd == 0)
+			fwts_passed(fw,
+				    "FADT SMI ACPI disable command is zero, "
+				    "which is allowed since SMM is not "
+				    "supported, or machine is in legacy mode.");
+		else
+			fwts_failed(fw, LOG_LEVEL_MEDIUM,
+				    "SMMHasNoAcpiDisableCmd",
+				    "FADT SMI ACPI disable command is zero, "
+				    "but this is not allowed when SMM "
+				    "is supported.");
+	else
+		if (fadt->smi_cmd == 0)
+			fwts_failed(fw, LOG_LEVEL_MEDIUM,
+				    "SMMNeedsAcpiDisableCmd",
+				    "FADT SMI ACPI disable command is "
+				    "non-zero, but SMM is not supported.");
+		else
+			fwts_passed(fw, "FADT SMI ACPI disable command is "
+				    "non-zero, and SMM is supported.");
+
+	return;
+}
+
 static void acpi_table_check_fadt_pm_tmr(
 	fwts_framework *fw,
 	const fwts_acpi_table_fadt *fadt,
@@ -883,6 +936,8 @@  static int fadt_test1(fwts_framework *fw)
 	if (!fwts_acpi_is_reduced_hardware(fadt)) {
 		fwts_log_info(fw, "FADT SCI_INT is %" PRIu8, fadt->sci_int);
 		acpi_table_check_fadt_smi_cmd(fw);
+		acpi_table_check_fadt_acpi_enable(fw);
+		acpi_table_check_fadt_acpi_disable(fw);
 		acpi_table_check_fadt_pm_tmr(fw, fadt, &passed);
 		acpi_table_check_fadt_gpe(fw, fadt, &passed);
 		acpi_table_check_fadt_pm_addr(fw, fadt, &passed);