From patchwork Fri Aug 4 22:49:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 798088 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=fwts-devel-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id 3xPMZQ54gHz9s7m; Sat, 5 Aug 2017 08:50:06 +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 1ddlPx-0003Aw-0F; Fri, 04 Aug 2017 22:50:05 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1ddlPr-0003AF-IG for fwts-devel@lists.ubuntu.com; Fri, 04 Aug 2017 22:49:59 +0000 Received: from 1.general.alexhung.us.vpn ([10.172.65.254] helo=canonical.com) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1ddlPq-000305-UK; Fri, 04 Aug 2017 22:49:59 +0000 From: Alex Hung To: fwts-devel@lists.ubuntu.com Subject: [PATCH 1/2] acpi: sdei: add ACPI SDEI test (mantis 1714) Date: Fri, 4 Aug 2017 15:49:55 -0700 Message-Id: <1501886996-29373-1-git-send-email-alex.hung@canonical.com> X-Mailer: git-send-email 2.7.4 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 Signed-off-by: Alex Hung Acked-by: Colin Ian King Acked-by: Ivan Hu --- src/Makefile.am | 1 + src/acpi/sdei/sdei.c | 88 +++++++++++++++++++++++++++++++++++++++++++++ src/lib/include/fwts_acpi.h | 8 +++++ 3 files changed, 97 insertions(+) create mode 100644 src/acpi/sdei/sdei.c diff --git a/src/Makefile.am b/src/Makefile.am index 916834c..43c398e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -104,6 +104,7 @@ fwts_SOURCES = main.c \ acpi/s3power/s3power.c \ acpi/s4/s4.c \ acpi/sbst/sbst.c \ + acpi/sdei/sdei.c \ acpi/slic/slic.c \ acpi/slit/slit.c \ acpi/spcr/spcr.c \ diff --git a/src/acpi/sdei/sdei.c b/src/acpi/sdei/sdei.c new file mode 100644 index 0000000..c75300e --- /dev/null +++ b/src/acpi/sdei/sdei.c @@ -0,0 +1,88 @@ +/* + * Copyright (C) 2017 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" + +#if defined(FWTS_HAS_ACPI) + +#include +#include +#include +#include +#include + +static fwts_acpi_table_info *table; + +static int sdei_init(fwts_framework *fw) +{ + if (fwts_acpi_find_table(fw, "SDEI", 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 SDEI table does not exist, skipping test"); + return FWTS_SKIP; + } + + return FWTS_OK; +} + +static int sdei_test1(fwts_framework *fw) +{ + fwts_acpi_table_sdei *sdei = (fwts_acpi_table_sdei *) table->data; + bool passed = true; + + fwts_log_info_verbatim(fw, "SDEI (Software Delegated Exception Interface) Table:"); + + /* Current spec says: + * "The table consists only of a basic header with revision 1." + * "Later revisions of the SDEI table may define additional fields." + * + * More validation will be implemented for revision 2 and later. + */ + switch (sdei->header.revision) { + case 1: + /* nothing to validate */ + break; + default: + fwts_log_info(fw, "Unsupported SDEI Revision %" PRIu8, sdei->header.revision); + break; + } + + if (passed) + fwts_passed(fw, "No issues found in SDEI table."); + + return FWTS_OK; +} + +static fwts_framework_minor_test sdei_tests[] = { + { sdei_test1, "Validate SDEI table." }, + { NULL, NULL } +}; + +static fwts_framework_ops sdei_ops = { + .description = "SDEI Software Delegated Exception Interface Table test", + .init = sdei_init, + .minor_tests = sdei_tests +}; + +FWTS_REGISTER("sdei", &sdei_ops, FWTS_TEST_ANYTIME, FWTS_FLAG_BATCH | FWTS_FLAG_TEST_ACPI) + +#endif diff --git a/src/lib/include/fwts_acpi.h b/src/lib/include/fwts_acpi.h index 0742ef3..12d63aa 100644 --- a/src/lib/include/fwts_acpi.h +++ b/src/lib/include/fwts_acpi.h @@ -1770,6 +1770,14 @@ typedef struct { } __attribute__ ((packed)) fwts_acpi_table_msdm; /* + * ACPI SDEI (Software Delegated Exception Interface) + * http://infocenter.arm.com/help/topic/com.arm.doc.den0054a/ARM_DEN0054A_Software_Delegated_Exception_Interface.pdf + */ +typedef struct { + fwts_acpi_table_header header; +} __attribute__ ((packed)) fwts_acpi_table_sdei; + +/* * ACPI IORT (IO Remapping Table) * http://infocenter.arm.com/help/topic/com.arm.doc.den0049a/DEN0049A_IO_Remapping_Table.pdf */