From patchwork Thu Sep 7 00:34:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 810828 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 3xnhKc746xz9s8J; Thu, 7 Sep 2017 10:34:28 +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 1dpkm2-0007QN-Mz; Thu, 07 Sep 2017 00:34:26 +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 1dpkm1-0007QB-Q8 for fwts-devel@lists.ubuntu.com; Thu, 07 Sep 2017 00:34:25 +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 1dpkm1-0001lt-8n; Thu, 07 Sep 2017 00:34:25 +0000 From: Alex Hung To: fwts-devel@lists.ubuntu.com Subject: [PATCH 1/3] lib: fwts_acpi_tables: add a new function to check Reserved field Date: Wed, 6 Sep 2017 17:34:16 -0700 Message-Id: <1504744458-559-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 --- src/lib/include/fwts_acpi_tables.h | 2 ++ src/lib/src/fwts_acpi_tables.c | 44 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 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..5a2450b 100644 --- a/src/lib/src/fwts_acpi_tables.c +++ b/src/lib/src/fwts_acpi_tables.c @@ -1383,4 +1383,48 @@ 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 = malloc(20); + strncpy(label, table, 4); /* ACPI table name is 4 char long */ + strncat(label, "ReservedNonZero", strlen("ReservedNonZero")); + + 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; + free(label); + } +} + #endif