From patchwork Fri Feb 19 23:39:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Stone X-Patchwork-Id: 62424 Delivered-To: patches@linaro.org Received: by 10.112.43.199 with SMTP id y7csp78565lbl; Fri, 19 Feb 2016 15:40:45 -0800 (PST) X-Received: by 10.182.86.33 with SMTP id m1mr13932778obz.48.1455925245691; Fri, 19 Feb 2016 15:40:45 -0800 (PST) Return-Path: Received: from mail-ob0-x231.google.com (mail-ob0-x231.google.com. [2607:f8b0:4003:c01::231]) by mx.google.com with ESMTPS id w128si18890400oie.5.2016.02.19.15.40.45 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 Feb 2016 15:40:45 -0800 (PST) Received-SPF: pass (google.com: domain of al.stone@linaro.org designates 2607:f8b0:4003:c01::231 as permitted sender) client-ip=2607:f8b0:4003:c01::231; Authentication-Results: mx.google.com; spf=pass (google.com: domain of al.stone@linaro.org designates 2607:f8b0:4003:c01::231 as permitted sender) smtp.mailfrom=al.stone@linaro.org; dkim=pass header.i=@linaro.org Received: by mail-ob0-x231.google.com with SMTP id gc3so121026487obb.3 for ; Fri, 19 Feb 2016 15:40:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=FtKcCtTsLk6GtXJ76/utJP+FKIcPwSuC0nkEcFt36Mo=; b=FIk8hN+94JBGnMECCANAB3zzQhP++eaE3fjeGbl9KD8sOPmkxapMK3jEkUKUhyOGL9 ph+YaAqshMYoIF5h/Iv0L+u5AyyPnY6lzDT8JYRVLnD3UXojCmOPFj+qK/J+n8O6k4Hd OakecIqm4vq9IK/betK18Y9quQi6tsskJSsuw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=FtKcCtTsLk6GtXJ76/utJP+FKIcPwSuC0nkEcFt36Mo=; b=QTGRfJ+XohSl1uOE2+Q9MmWIh+3HLRdCb8AdxcdpTTa12gPjog9CypZqV9Ssgt5poj R77uUTaZ9YaGX07QmLVdT3GFurHQC6On6Hx+fjLary1uCQZlDOVTo5Gty+v8C/3CNJLW Kq1bKrEopNT8kAesDya1y4JX9V3CYEc3f1VgwOkmJeVMzubKne3l5JZWfNzljCvHuNdR QP/mVEivEh/LaKH0HELyKlGWt1sHQyvXSqOSNyB1OscDbSTLEgLcesS1SlsBrt0s4Wd4 hV/CfQ4WkGOv0+0KE+V7wzewa5EkVHNIFB8X7970cgF4UvLplpJEGUfrJYYLfsQTdn7L GFkg== X-Gm-Message-State: AG10YOQbkObOEKwTX0MSn2/Faz9P9e99QECRrccjyDohwN7GtuM9aZwjctl/Gp1TWIyTjvaTd/A= X-Received: by 10.60.82.229 with SMTP id l5mr13708097oey.6.1455925245339; Fri, 19 Feb 2016 15:40:45 -0800 (PST) Return-Path: Received: from fidelio.ahs3.com (c-50-134-239-249.hsd1.co.comcast.net. [50.134.239.249]) by smtp.googlemail.com with ESMTPSA id kg7sm8655217obb.27.2016.02.19.15.40.43 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 19 Feb 2016 15:40:43 -0800 (PST) From: Al Stone To: fwts-devel@lists.ubuntu.com Cc: linaro-acpi@lists.linaro.org, patches@linaro.org, Al Stone Subject: [PATCH v2 08/23] FADT: minor cleanup and initial compliance tests Date: Fri, 19 Feb 2016 16:39:44 -0700 Message-Id: <1455925199-8587-9-git-send-email-al.stone@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1455925199-8587-1-git-send-email-al.stone@linaro.org> References: <1455925199-8587-1-git-send-email-al.stone@linaro.org> The primary purpose of this patch is to catch some very minor white space edits while adding in two very simple compliance tests -- is the table checksum correct, and is the revision number current? Signed-off-by: Al Stone --- src/acpi/fadt/fadt.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 56 insertions(+), 4 deletions(-) -- 2.5.0 diff --git a/src/acpi/fadt/fadt.c b/src/acpi/fadt/fadt.c index 7ca351d..afe52f3 100644 --- a/src/acpi/fadt/fadt.c +++ b/src/acpi/fadt/fadt.c @@ -20,8 +20,8 @@ */ #include "fwts.h" -#include #include +#include #include #include #ifdef FWTS_ARCH_INTEL @@ -53,7 +53,7 @@ static int fadt_init(fwts_framework *fw) fwts_log_error(fw, "ACPI table FACP does not exist!"); return FWTS_ERROR; } - fadt = (const fwts_acpi_table_fadt*)table->data; + fadt = (const fwts_acpi_table_fadt *)table->data; fadt_size = table->length; /* Not having a FADT is not a failure on x86 */ @@ -154,6 +154,56 @@ static int fadt_info(fwts_framework *fw) return FWTS_OK; } +static int fadt_checksum(fwts_framework *fw) +{ + const uint8_t *data = (const uint8_t *)fadt; + ssize_t length = fadt->header.length; + uint8_t checksum = 0; + + /* verify the table checksum */ + checksum = fwts_checksum(data, length); + if (checksum == 0) + fwts_passed(fw, "FADT checksum is correct"); + else + fwts_failed(fw, LOG_LEVEL_MEDIUM, + "SPECMADTChecksum", + "FADT checksum is incorrect: 0x%x", checksum); + + return FWTS_OK; +} + +static int fadt_revision(fwts_framework *fw) +{ + const uint8_t LATEST_MAJOR = 6; + const uint8_t LATEST_MINOR = 1; + uint8_t major; + uint8_t minor; + + major = fadt->header.revision; + minor = 0; + if (major >= 5 && fadt->header.length >= 268) + minor = fadt->minor_version; /* field added ACPI 5.1 */ + + fwts_log_info(fw, "FADT revision: %d.%d", major, minor); + fwts_log_info(fw, "FADT table length: %d", fadt->header.length); + + if (major == LATEST_MAJOR && minor == LATEST_MINOR) + fwts_passed(fw, "FADT revision is up to date."); + else { + fwts_warning(fw, "FADT revision is outdated: %d.%d", + major, minor); + fwts_advice(fw, "The most recent revision of the FADT " + "defined in the ACPI specification is %d.%d. " + "While older revisions of the FADT can be used, " + "newer ones may enable additional functionality " + "that cannot be used until the FADT is updated.", + LATEST_MAJOR, LATEST_MINOR); + } + + return FWTS_OK; +} + + static void acpi_table_check_fadt_firmware_control( fwts_framework *fw, const fwts_acpi_table_fadt *fadt, @@ -637,8 +687,10 @@ static int fadt_test3(fwts_framework *fw) } static fwts_framework_minor_test fadt_tests[] = { - { fadt_info, "FADT ACPI Description Table flag info." }, - { fadt_test1, "Test FADT ACPI Description Table tests." }, + { fadt_info, "ACPI FADT Description Table flag info." }, + { fadt_checksum, "FADT checksum test." }, + { fadt_revision, "FADT revision test." }, + { fadt_test1, "ACPI FADT Description Table tests." }, { fadt_test2, "Test FADT SCI_EN bit is enabled." }, { fadt_test3, "Test FADT reset register." }, { NULL, NULL }