From patchwork Wed Jul 1 13:11:42 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Ian King X-Patchwork-Id: 490137 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id A6A051402B3; Wed, 1 Jul 2015 23:12:01 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1ZAHo0-0008Tm-Ix; Wed, 01 Jul 2015 13:12:00 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1ZAHnv-0008T6-TL for fwts-devel@lists.ubuntu.com; Wed, 01 Jul 2015 13:11:55 +0000 Received: from [10.172.65.212] (helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1ZAHnv-0000gi-30 for fwts-devel@lists.ubuntu.com; Wed, 01 Jul 2015 13:11:55 +0000 From: Colin King To: fwts-devel@lists.ubuntu.com Subject: [PATCH 1/2] acpi: Add WAET ACPI table test (LP: #1470495) Date: Wed, 1 Jul 2015 14:11:42 +0100 Message-Id: <1435756303-20478-2-git-send-email-colin.king@canonical.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1435756303-20478-1-git-send-email-colin.king@canonical.com> References: <1435756303-20478-1-git-send-email-colin.king@canonical.com> X-BeenThere: fwts-devel@lists.ubuntu.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: Firmware Test Suite Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: fwts-devel-bounces@lists.ubuntu.com Sender: fwts-devel-bounces@lists.ubuntu.com From: Colin Ian King Trivial table to check, just see if size is value and flags reserved fields are zero. Signed-off-by: Colin Ian King Acked-by: Ivan Hu Acked-by: Alex Hung --- src/Makefile.am | 1 + src/acpi/waet/waet.c | 100 ++++++++++++++++++++++++++++++++++++++++++++ src/lib/include/fwts_acpi.h | 9 ++++ 3 files changed, 110 insertions(+) create mode 100644 src/acpi/waet/waet.c diff --git a/src/Makefile.am b/src/Makefile.am index e79d5f6..bba6301 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -75,6 +75,7 @@ fwts_SOURCES = main.c \ acpi/tcpa/tcpa.c \ acpi/srat/srat.c \ acpi/syntaxcheck/syntaxcheck.c \ + acpi/waet/waet.c \ acpi/wakealarm/wakealarm.c \ acpi/wmi/wmi.c \ acpi/xsdt/xsdt.c \ diff --git a/src/acpi/waet/waet.c b/src/acpi/waet/waet.c new file mode 100644 index 0000000..d709de8 --- /dev/null +++ b/src/acpi/waet/waet.c @@ -0,0 +1,100 @@ +/* + * Copyright (C) 2015 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" + +#include +#include +#include +#include +#include +#include + +#include "fwts_acpi_object_eval.h" + +static fwts_acpi_table_info *table; + +static int waet_init(fwts_framework *fw) +{ + if (fwts_acpi_find_table(fw, "WAET", 0, &table) != FWTS_OK) { + fwts_log_error(fw, "Cannot read ACPI tables."); + return FWTS_ERROR; + } + if (table == NULL || (table && table->length == 0)) { + fwts_log_error(fw, "ACPI WAET table does not exist, skipping test"); + return FWTS_SKIP; + } + + return FWTS_OK; +} + +/* + * WAET Windows ACPI Emulated Devices Table + * see http://msdn.microsoft.com/en-us/windows/hardware/gg487524.aspx + */ +static int waet_test1(fwts_framework *fw) +{ + bool passed = true; + fwts_acpi_table_waet *waet = (fwts_acpi_table_waet *)table->data; + + /* Enough length for the initial waet header? */ + if (table->length < sizeof(fwts_acpi_table_waet)) { + passed = false; + fwts_failed(fw, LOG_LEVEL_HIGH, + "WAETTooShort", + "WAET table too short, expecting %zu bytes, " + "instead got %zu bytes", + sizeof(fwts_acpi_table_waet), table->length); + goto done; + } + + fwts_log_info_verbatum(fw, "WAET Table:"); + fwts_log_info_verbatum(fw, " Emulated Device Flags: 0x%8.8" PRIx32, waet->flags); + fwts_log_info_verbatum(fw, " Bit [0] RTC Good: %1" PRIu32, waet->flags & 1); + fwts_log_info_verbatum(fw, " Bit [1] PM Timer Good: %1" PRIu32, (waet->flags >> 1) & 1); + fwts_log_nl(fw); + + if (waet->flags & ~3) { + passed = false; + fwts_failed(fw, LOG_LEVEL_HIGH, + "WAETFlagReservedNotZero", + "WAET Emulated Device Flags was 0x%" PRIx32 + " and so some of reserved bits [31:2] are not zero " + " as expected.", waet->flags); + } +done: + if (passed) + fwts_passed(fw, "No issues found in WAET table."); + + return FWTS_OK; +} + +static fwts_framework_minor_test waet_tests[] = { + { waet_test1, "Windows ACPI Emulated Devices Table test." }, + { NULL, NULL } +}; + +static fwts_framework_ops waet_ops = { + .description = "Windows ACPI Emulated Devices Table test.", + .init = waet_init, + .minor_tests = waet_tests +}; + +FWTS_REGISTER("waet", &waet_ops, FWTS_TEST_ANYTIME, FWTS_FLAG_BATCH | FWTS_FLAG_TEST_ACPI) diff --git a/src/lib/include/fwts_acpi.h b/src/lib/include/fwts_acpi.h index 1acbaef..5706e2f 100644 --- a/src/lib/include/fwts_acpi.h +++ b/src/lib/include/fwts_acpi.h @@ -1123,4 +1123,13 @@ typedef struct { /* followed by 1 or more LPI structure types */ } __attribute__ ((packed)) fwts_acpi_table_lpit; +/* + * Windows ACPI Emulated Devices Table + * http://msdn.microsoft.com/en-us/windows/hardware/gg487524.aspx + */ +typedef struct { + fwts_acpi_table_header header; + uint32_t flags; +} __attribute__ ((packed)) fwts_acpi_table_waet; + #endif