From patchwork Tue Feb 9 01:32:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Stone X-Patchwork-Id: 61461 Delivered-To: patches@linaro.org Received: by 10.112.43.199 with SMTP id y7csp1766707lbl; Mon, 8 Feb 2016 17:33:50 -0800 (PST) X-Received: by 10.202.172.9 with SMTP id v9mr1541341oie.14.1454981621816; Mon, 08 Feb 2016 17:33:41 -0800 (PST) Return-Path: Received: from mail-ob0-x232.google.com (mail-ob0-x232.google.com. [2607:f8b0:4003:c01::232]) by mx.google.com with ESMTPS id q84si645971oih.117.2016.02.08.17.33.41 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Feb 2016 17:33:41 -0800 (PST) Received-SPF: pass (google.com: domain of al.stone@linaro.org designates 2607:f8b0:4003:c01::232 as permitted sender) client-ip=2607:f8b0:4003:c01::232; Authentication-Results: mx.google.com; spf=pass (google.com: domain of al.stone@linaro.org designates 2607:f8b0:4003:c01::232 as permitted sender) smtp.mailfrom=al.stone@linaro.org; dkim=pass header.i=@linaro.org Received: by mail-ob0-x232.google.com with SMTP id wb13so175736949obb.1 for ; Mon, 08 Feb 2016 17:33:41 -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=NGGiZAyQEn0qwDZ01QOE6moIZ+TSBbNievnA0ajOSS4=; b=XSnWyJgr33i97LXfIrZXPY8hy4OY5FWhiXfO2skU2mC3Be8W3I7OCEPSRVbCDmgtnj vO53mWWHaiRsru2UtYIWtuQdrShH04v288EbjSSuCa54La/TUz6VL3YvyilaUsHgmRtG W78E+Bj6fJnc5HYR9W8l3v3bvr/eLAFUBpwvk= 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=NGGiZAyQEn0qwDZ01QOE6moIZ+TSBbNievnA0ajOSS4=; b=gsZLKdrynhT6ezZHdNx2mbK20ckt9xDj/wwJAZOk1/BtLhJnCLGCJKayyB62qK1RVD Izfe1ltLGkBgflLTrHBrzgJScWhVQiyfA5z7wA8XNZTYmxolQ+YnumKkozM39Cstb9Rv XkRLDq+Rn4JWhbsTWqPJ6JCn0rBxtGoe4RVlX/myb5GyMiG0bZiYRP8bV8Wd9We82Z/t F6hhGlDmfAXWwpZpHaM1bsGX0PnekSSTJfMbtDKFGqKv8t/+sZhToHn8BA24lFzbVz2Q azY7jfLROrPDkl0Y0x6Jrf/NZN7CYUQFtZU0Aabmb5yDkH2Pbeiy2Id4hpbP16BTynPp o3kw== X-Gm-Message-State: AG10YOSVv3HwIUKEX6REt3OMS9Xfp4j2XTefprDHd9ycIH+JE0/gJ4VFV5ji6k0iPKTccSkWI04= X-Received: by 10.60.35.201 with SMTP id k9mr28803207oej.3.1454981621544; Mon, 08 Feb 2016 17:33:41 -0800 (PST) Return-Path: Received: from fidelio.ahs3 (c-50-134-239-249.hsd1.co.comcast.net. [50.134.239.249]) by smtp.googlemail.com with ESMTPSA id qp4sm19097135obc.9.2016.02.08.17.33.39 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 08 Feb 2016 17:33:40 -0800 (PST) From: Al Stone To: fwts-devel@lists.ubuntu.com Cc: linaro-acpi@lists.linaro.org, patches@linaro.org, Al Stone Subject: [PATCH 08/21] FADT: minor cleanup and initial compliance tests Date: Mon, 8 Feb 2016 18:32:50 -0700 Message-Id: <1454981583-31872-9-git-send-email-al.stone@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1454981583-31872-1-git-send-email-al.stone@linaro.org> References: <1454981583-31872-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 | 51 +++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 47 insertions(+), 4 deletions(-) -- 2.5.0 diff --git a/src/acpi/fadt/fadt.c b/src/acpi/fadt/fadt.c index 5106e4e..6e5ee26 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 */ @@ -152,6 +152,47 @@ 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) +{ + 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 == 6) + fwts_passed(fw, "FADT revision is up to date."); + else + fwts_failed(fw, LOG_LEVEL_MEDIUM, "SPECFADTRevision", + "FADT revision is outdated: %d.%d", major, minor); + + return FWTS_OK; +} + + static void acpi_table_check_fadt_firmware_control( fwts_framework *fw, const fwts_acpi_table_fadt *fadt, @@ -635,8 +676,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 }