From patchwork Fri Sep 8 00:44:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 811276 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 3xpJWM6MY1z9sBZ; Fri, 8 Sep 2017 10:45:03 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1dq7Pp-0004OF-Ed; Fri, 08 Sep 2017 00:45:01 +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 1dq7Po-0004O6-0d for fwts-devel@lists.ubuntu.com; Fri, 08 Sep 2017 00:45:00 +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 1dq7Pn-0003Ag-H2; Fri, 08 Sep 2017 00:44:59 +0000 From: Alex Hung To: fwts-devel@lists.ubuntu.com Subject: [PATCH][V2] lib: fwts_acpi_tables: add a new function to check Reserved field Date: Thu, 7 Sep 2017 17:44:52 -0700 Message-Id: <1504831492-16508-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/lib/include/fwts_acpi_tables.h | 2 ++ src/lib/src/fwts_acpi_tables.c | 43 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/src/lib/include/fwts_acpi_tables.h b/src/lib/include/fwts_acpi_tables.h index 2527984..d478d99 100644 --- a/src/lib/include/fwts_acpi_tables.h +++ b/src/lib/include/fwts_acpi_tables.h @@ -53,6 +53,8 @@ bool fwts_acpi_obj_find(fwts_framework *fw, const char *obj_name); fwts_bool fwts_acpi_is_reduced_hardware(const fwts_acpi_table_fadt *fadt); +void fwts_acpi_reserved_zero_check(fwts_framework *fw, const char *table, const char *field, uint64_t value, uint8_t size, bool *passed); + #endif #endif diff --git a/src/lib/src/fwts_acpi_tables.c b/src/lib/src/fwts_acpi_tables.c index 3c3a63a..4ac70f8 100644 --- a/src/lib/src/fwts_acpi_tables.c +++ b/src/lib/src/fwts_acpi_tables.c @@ -1383,4 +1383,47 @@ bool fwts_acpi_obj_find(fwts_framework *fw, const char *obj_name) return found; } +/* + * fwts_acpi_reserved_zero_check() + * verify whether the reserved field is zero + */ +void fwts_acpi_reserved_zero_check( + fwts_framework *fw, + const char *table, + const char *field, + uint64_t value, + uint8_t size, + bool *passed) +{ + if (value != 0) { + char label[20]; + strncpy(label, table, 4); /* ACPI table name is 4 char long */ + strncpy(label + 4, "ReservedNonZero", sizeof(label) - 4); + + switch (size) { + case sizeof(uint8_t): + fwts_failed(fw, LOG_LEVEL_MEDIUM, label, + "%4.4s %s field must be zero, got " + "0x%2.2" PRIx8 " instead", table, field, (uint8_t)value); + break; + case sizeof(uint16_t): + fwts_failed(fw, LOG_LEVEL_MEDIUM, label, + "%4.4s %s field must be zero, got " + "0x%4.4" PRIx16 " instead", table, field, (uint16_t)value); + break; + case sizeof(uint32_t): + fwts_failed(fw, LOG_LEVEL_MEDIUM, label, + "%4.4s %s field must be zero, got " + "0x%8.8" PRIx32 " instead", table, field, (uint32_t)value); + break; + case sizeof(uint64_t): + fwts_failed(fw, LOG_LEVEL_MEDIUM, label, + "%4.4s %s field must be zero, got " + "0x%16.16" PRIx64 " instead", table, field, value); + break; + } + *passed = false; + } +} + #endif