From patchwork Tue Oct 10 22:19:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 824103 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 3yBWkN2Hfvz9t69; Wed, 11 Oct 2017 09:19:40 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1e22sE-0000CX-VA; Tue, 10 Oct 2017 22:19:38 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1e22sD-0000CH-N2 for fwts-devel@lists.ubuntu.com; Tue, 10 Oct 2017 22:19:37 +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 1e22sD-0001t6-79; Tue, 10 Oct 2017 22:19:37 +0000 From: Alex Hung To: fwts-devel@lists.ubuntu.com Subject: [PATCH] acp: nfit: add platform capability according to manit 1831 (ACPI 6.2a) Date: Tue, 10 Oct 2017 15:19:35 -0700 Message-Id: <1507673975-24916-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.20 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" Signed-off-by: Alex Hung Acked-by: Colin Ian King Acked-by: Ivan Hu --- src/acpi/nfit/nfit.c | 31 +++++++++++++++++++++++++++++-- src/lib/include/fwts_acpi.h | 11 ++++++++++- 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/src/acpi/nfit/nfit.c b/src/acpi/nfit/nfit.c index e1a4815..b87f040 100644 --- a/src/acpi/nfit/nfit.c +++ b/src/acpi/nfit/nfit.c @@ -322,12 +322,39 @@ static int nfit_test1(fwts_framework *fw) if (reserved != 0) reserved_passed = reserved; + } else if (entry->type == FWTS_ACPI_NFIT_TYPE_PLATFORM_CAPABILITY) { + fwts_acpi_table_nfit_platform_cap *nfit_struct = (fwts_acpi_table_nfit_platform_cap *) entry; + uint32_t reserved1; + + reserved1 = (uint32_t) nfit_struct->reserved1[0] + ((uint32_t) nfit_struct->reserved1[1] << 8) + + ((uint32_t) nfit_struct->reserved1[2] << 16); + + fwts_log_info_verbatim(fw, " Highest Valid Capability: 0x%2.2" PRIx8, nfit_struct->highest_valid_cap); + fwts_log_info_verbatim(fw, " Reserved1: 0x%8.8" PRIx32, reserved1); + fwts_log_info_verbatim(fw, " Capabilities: 0x%8.8" PRIx32, nfit_struct->cap); + fwts_log_info_verbatim(fw, " Reserved2: 0x%8.8" PRIx32, nfit_struct->reserved2); + + fwts_acpi_reserved_zero_check(fw, "NFIT", "Reserved1", reserved1, sizeof(reserved1), &passed); + fwts_acpi_reserved_bits_check(fw, "NFIT", "Capabilities", nfit_struct->cap, sizeof(nfit_struct->cap), 3, 31, &passed); + + if ((nfit_struct->cap & 0x1) && !(nfit_struct->cap & 0x2)) { + passed = false; + fwts_failed(fw, LOG_LEVEL_CRITICAL, + "NFITBadCapabilities", + "NFIT Capabilities[1] must be set and if Capabilities[0] is set, got " + "0x%8.8" PRIx32 " instead", nfit_struct->cap); + } + + if (nfit_struct->reserved2 != 0) + reserved_passed = nfit_struct->reserved2; + } else { passed = false; fwts_failed(fw, LOG_LEVEL_HIGH, "NFITBadSubType", - "NFIT Structure supports type 0..6, got " - "0x%4.4" PRIx16 " instead", entry->type); + "NFIT Structure supports type 0..%" PRId8 ", got " + "0x%4.4" PRIx16 " instead", FWTS_ACPI_NFIT_TYPE_RESERVED - 1, + entry->type); } fwts_acpi_reserved_zero_check(fw, "NFIT", "Reserved", reserved_passed, sizeof(reserved_passed), &passed); diff --git a/src/lib/include/fwts_acpi.h b/src/lib/include/fwts_acpi.h index d919aa8..e22e1af 100644 --- a/src/lib/include/fwts_acpi.h +++ b/src/lib/include/fwts_acpi.h @@ -1166,7 +1166,8 @@ typedef enum { FWTS_ACPI_NFIT_TYPE_CONTROL_REGION = 4, FWTS_ACPI_NFIT_TYPE_DATA_REGION = 5, FWTS_ACPI_NFIT_TYPE_FLUSH_ADDRESS = 6, - FWTS_ACPI_NFIT_TYPE_RESERVED = 7 /* >= 7 are reserved */ + FWTS_ACPI_NFIT_TYPE_PLATFORM_CAPABILITY = 7, + FWTS_ACPI_NFIT_TYPE_RESERVED = 8 /* >= 8 are reserved */ } fwts_acpi_nfit_type; typedef struct { @@ -1255,6 +1256,14 @@ typedef struct { uint64_t hint_address[]; } __attribute__ ((packed)) fwts_acpi_table_nfit_flush_addr; +typedef struct { + fwts_acpi_table_nfit_struct_header header; + uint8_t highest_valid_cap; + uint8_t reserved1[3]; + uint32_t cap; + uint32_t reserved2; +} __attribute__ ((packed)) fwts_acpi_table_nfit_platform_cap; + /* * ACPI HMAT (Heterogeneous Memory Attribute Table), 5.2.27 */