From patchwork Fri May 15 18:00:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 1291553 X-Patchwork-Delegate: alex.hung@canonical.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=fwts-devel-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49Nx5w5KjPz9sRW; Sat, 16 May 2020 04:00:34 +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 1jZedK-0004ae-5M; Fri, 15 May 2020 18:00:30 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jZedF-0004aD-3r for fwts-devel@lists.ubuntu.com; Fri, 15 May 2020 18:00:25 +0000 Received: from 2.general.alexhung.us.vpn ([10.172.65.255] helo=canonical.com) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jZedE-0001W3-DL; Fri, 15 May 2020 18:00:24 +0000 From: Alex Hung To: fwts-devel@lists.ubuntu.com Subject: [PATCH 1/2] fwts_acpi_object_eval: add a function to check package elements Date: Fri, 15 May 2020 12:00:20 -0600 Message-Id: <20200515180021.876721-1-alex.hung@canonical.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 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: , Errors-To: fwts-devel-bounces@lists.ubuntu.com Sender: "fwts-devel" This function checks if all elements are integers in a returned package. This is one of common forms returned by ACPI methods. Signed-off-by: Alex Hung --- src/lib/include/fwts_acpi_object_eval.h | 1 + src/lib/src/fwts_acpi_object_eval.c | 28 +++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/src/lib/include/fwts_acpi_object_eval.h b/src/lib/include/fwts_acpi_object_eval.h index 09f3f754..92177857 100644 --- a/src/lib/include/fwts_acpi_object_eval.h +++ b/src/lib/include/fwts_acpi_object_eval.h @@ -128,6 +128,7 @@ void fwts_method_test_buffer_return(fwts_framework *fw, char *name, ACPI_BUFFER void fwts_method_test_all_reference_package_return(fwts_framework *fw, char *name, ACPI_BUFFER *buf, ACPI_OBJECT *obj, void *private); void fwts_method_test_integer_reserved_bits_return(fwts_framework *fw, char *name, ACPI_BUFFER *buf, ACPI_OBJECT *obj, void *private); void fwts_method_test_integer_max_return(fwts_framework *fw, char *name, ACPI_BUFFER *buf, ACPI_OBJECT *obj, void *private); +void fwts_method_test_package_integer_return(fwts_framework *fw, char *name, ACPI_BUFFER *buf, ACPI_OBJECT *obj, void *private); void fwts_method_test_passed_failed_return(fwts_framework *fw, char *name, ACPI_BUFFER *buf, ACPI_OBJECT *obj, void *private); void fwts_method_test_polling_return( fwts_framework *fw, char *name, ACPI_BUFFER *buf, ACPI_OBJECT *obj, void *private); diff --git a/src/lib/src/fwts_acpi_object_eval.c b/src/lib/src/fwts_acpi_object_eval.c index 1e3575c9..613a6fd3 100644 --- a/src/lib/src/fwts_acpi_object_eval.c +++ b/src/lib/src/fwts_acpi_object_eval.c @@ -881,6 +881,34 @@ void fwts_method_test_integer_max_return( fwts_passed(fw, "%s correctly returned an integer.", name); } +/* + * fwts_method_test_package_integer_return + * check if all integers in a returned package + */ +void fwts_method_test_package_integer_return( + fwts_framework *fw, + char *name, + ACPI_BUFFER *buf, + ACPI_OBJECT *obj, + void *private) +{ + char method[4]; + uint32_t *element_size = (uint32_t *) private; + + memcpy(method, &name[strlen(name) - 4], 4); + + if (fwts_method_check_type(fw, name, buf, ACPI_TYPE_PACKAGE) != FWTS_OK) + return; + + if (fwts_method_package_count_equal(fw, name, method, obj, *element_size) != FWTS_OK) + return; + + if (fwts_method_package_elements_all_type(fw, name, method, obj, ACPI_TYPE_INTEGER) != FWTS_OK) + return; + + fwts_method_passed_sane(fw, name, "package"); +} + /* * fwts_method_test_passed_failed_return * check if 0 or 1 (false/true) integer is returned From patchwork Fri May 15 18:00:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 1291554 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=fwts-devel-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49Nx5x4Lmhz9sSF; Sat, 16 May 2020 04:00:37 +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 1jZedP-0004bO-7z; Fri, 15 May 2020 18:00:35 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jZedH-0004aT-Og for fwts-devel@lists.ubuntu.com; Fri, 15 May 2020 18:00:27 +0000 Received: from 2.general.alexhung.us.vpn ([10.172.65.255] helo=canonical.com) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jZedH-0001WF-3U; Fri, 15 May 2020 18:00:27 +0000 From: Alex Hung To: fwts-devel@lists.ubuntu.com Subject: [PATCH 2/2] acpi/method: remove duplicated code by a common function Date: Fri, 15 May 2020 12:00:21 -0600 Message-Id: <20200515180021.876721-2-alex.hung@canonical.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200515180021.876721-1-alex.hung@canonical.com> References: <20200515180021.876721-1-alex.hung@canonical.com> MIME-Version: 1.0 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: , Errors-To: fwts-devel-bounces@lists.ubuntu.com Sender: "fwts-devel" _CLS, _HPP, _LSI, _MBM, _FIF and _FST all returns a package containing all integer elements. Each individual function is placed by the new fwts_method_test_package_integer_return function. Signed-off-by: Alex Hung Acked-by: Ivan Hu Acked-by: Colin Ian King --- src/acpi/method/method.c | 158 ++---------------------- src/lib/include/fwts_acpi_object_eval.h | 1 - src/lib/src/fwts_acpi_object_eval.c | 24 +--- 3 files changed, 14 insertions(+), 169 deletions(-) diff --git a/src/acpi/method/method.c b/src/acpi/method/method.c index 254e1519..76ce8a81 100644 --- a/src/acpi/method/method.c +++ b/src/acpi/method/method.c @@ -750,14 +750,14 @@ static int method_test_PIC(fwts_framework *fw) return ret; } - /* * Section 6.1 Device Identification Objects */ static int method_test_CLS(fwts_framework *fw) { + uint32_t element_size = 3; return method_evaluate_method(fw, METHOD_OPTIONAL, - "_CLS", NULL, 0, fwts_method_test_CLS_return, NULL); + "_CLS", NULL, 0, fwts_method_test_package_integer_return, &element_size); } static int method_test_DDN(fwts_framework *fw) @@ -1087,33 +1087,11 @@ static int method_test_GSB(fwts_framework *fw) "_GSB", NULL, 0, fwts_method_test_integer_return, NULL); } -static void method_test_HPP_return( - fwts_framework *fw, - char *name, - ACPI_BUFFER *buf, - ACPI_OBJECT *obj, - void *private) -{ - FWTS_UNUSED(private); - - if (fwts_method_check_type(fw, name, buf, ACPI_TYPE_PACKAGE) != FWTS_OK) - return; - - /* Must be 4 elements in the package */ - if (fwts_method_package_count_equal(fw, name, "_HPP", obj, 4) != FWTS_OK) - return; - - /* All 4 elements in the package must be integers */ - if (fwts_method_package_elements_all_type(fw, name, "_HPP", obj, ACPI_TYPE_INTEGER) != FWTS_OK) - return; - - fwts_method_passed_sane(fw, name, "package"); -} - static int method_test_HPP(fwts_framework *fw) { + uint32_t element_size = 4; return method_evaluate_method(fw, METHOD_OPTIONAL, - "_HPP", NULL, 0, method_test_HPP_return, NULL); + "_HPP", NULL, 0, fwts_method_test_package_integer_return, &element_size); } static int method_test_PXM(fwts_framework *fw) @@ -1255,28 +1233,11 @@ static int method_test_FIT(fwts_framework *fw) "_FIT", NULL, 0, fwts_method_test_buffer_return, NULL); } -static void method_test_LSI_return( - fwts_framework *fw, - char *name, - ACPI_BUFFER *buf, - ACPI_OBJECT *obj, - void *private) -{ - FWTS_UNUSED(private); - - if (fwts_method_check_type(fw, name, buf, ACPI_TYPE_PACKAGE) != FWTS_OK) - return; - - if (fwts_method_package_elements_all_type(fw, name, "_LSI", obj, ACPI_TYPE_INTEGER) != FWTS_OK) - return; - - fwts_method_passed_sane(fw, name, "package"); -} - static int method_test_LSI(fwts_framework *fw) { + uint32_t element_size = 3; return method_evaluate_method(fw, METHOD_OPTIONAL, - "_LSI", NULL, 0, method_test_LSI_return, NULL); + "_LSI", NULL, 0, fwts_method_test_package_integer_return, &element_size); } static int method_test_DCK(fwts_framework *fw) @@ -3193,44 +3154,11 @@ static int method_test_GTM(fwts_framework *fw) /* * Section 9.12 Memory Devices */ - -static void method_test_MBM_return( - fwts_framework *fw, - char *name, - ACPI_BUFFER *buf, - ACPI_OBJECT *obj, - void *private) -{ - static const fwts_package_element elements[] = { - { ACPI_TYPE_INTEGER, "Revision" }, - { ACPI_TYPE_INTEGER, "Window Size" }, - { ACPI_TYPE_INTEGER, "Sampling Interval" }, - { ACPI_TYPE_INTEGER, "Maximum Bandwidth" }, - { ACPI_TYPE_INTEGER, "Average Bandwidth" }, - { ACPI_TYPE_INTEGER, "Low Bandwidth" }, - { ACPI_TYPE_INTEGER, "Low Notification Threshold" }, - { ACPI_TYPE_INTEGER, "High Notification Threshold" }, - }; - - FWTS_UNUSED(private); - - if (fwts_method_check_type(fw, name, buf, ACPI_TYPE_PACKAGE) != FWTS_OK) - return; - - if (fwts_method_package_count_equal(fw, name, "_MBM", obj, 8) != FWTS_OK) - return; - - /* For now, just check types */ - if (fwts_method_package_elements_type(fw, name, "_MBM", obj, elements, 8) != FWTS_OK) - return; - - fwts_method_passed_sane(fw, name, "package"); -} - static int method_test_MBM(fwts_framework *fw) { + uint32_t element_size = 8; return method_evaluate_method(fw, METHOD_OPTIONAL, - "_MBM", NULL, 0, method_test_MBM_return, NULL); + "_MBM", NULL, 0, fwts_method_test_package_integer_return, &element_size); } /* @@ -4579,42 +4507,11 @@ static int method_test_WPP(fwts_framework *fw) /* * Section 11.3 Fan Devices */ -static void method_test_FIF_return( - fwts_framework *fw, - char *name, - ACPI_BUFFER *buf, - ACPI_OBJECT *obj, - void *private) -{ - FWTS_UNUSED(private); - - if (fwts_method_check_type(fw, name, buf, ACPI_TYPE_PACKAGE) != FWTS_OK) - return; - - if (fwts_method_package_count_equal(fw, name, "_FIF", obj, 4) != FWTS_OK) - return; - - if (fwts_method_package_elements_all_type(fw, name, "_FIF", - obj, ACPI_TYPE_INTEGER) != FWTS_OK) { - fwts_advice(fw, - "%s is not returning the correct " - "fan information. It may be worth " - "running the firmware test suite " - "interactive 'fan' test to see if " - "this affects the control and " - "operation of the fan.", name); - return; - } - - fwts_acpi_object_dump(fw, obj); - - fwts_method_passed_sane(fw, name, "package"); -} - static int method_test_FIF(fwts_framework *fw) { + uint32_t element_size = 4; return method_evaluate_method(fw, METHOD_OPTIONAL, - "_FIF", NULL, 0, method_test_FIF_return, NULL); + "_FIF", NULL, 0, fwts_method_test_package_integer_return, &element_size); } static void method_test_FPS_return( @@ -4713,42 +4610,11 @@ static int method_test_FSL(fwts_framework *fw) "_FSL", arg, 1, fwts_method_test_NULL_return, NULL); } -static void method_test_FST_return( - fwts_framework *fw, - char *name, - ACPI_BUFFER *buf, - ACPI_OBJECT *obj, - void *private) -{ - FWTS_UNUSED(private); - - if (fwts_method_check_type(fw, name, buf, ACPI_TYPE_PACKAGE) != FWTS_OK) - return; - - if (fwts_method_package_count_equal(fw, name, "_FST", obj, 3) != FWTS_OK) - return; - - if (fwts_method_package_elements_all_type(fw, name, "_FST", - obj, ACPI_TYPE_INTEGER) != FWTS_OK) { - fwts_advice(fw, - "%s is not returning the correct " - "fan status information. It may be " - "worth running the firmware test " - "suite interactive 'fan' test to see " - "if this affects the control and " - "operation of the fan.", name); - return; - } - - fwts_acpi_object_dump(fw, obj); - - fwts_method_passed_sane(fw, name, "package"); -} - static int method_test_FST(fwts_framework *fw) { + uint32_t element_size = 3; return method_evaluate_method(fw, METHOD_OPTIONAL, - "_FST", NULL, 0, method_test_FST_return, NULL); + "_FST", NULL, 0, fwts_method_test_package_integer_return, &element_size); } diff --git a/src/lib/include/fwts_acpi_object_eval.h b/src/lib/include/fwts_acpi_object_eval.h index 92177857..080a0d65 100644 --- a/src/lib/include/fwts_acpi_object_eval.h +++ b/src/lib/include/fwts_acpi_object_eval.h @@ -158,7 +158,6 @@ int fwts_method_test_UID(fwts_framework *fw, ACPI_HANDLE *device); void fwts_method_valid_CID_Type(fwts_framework *fw, char *name, ACPI_OBJECT *obj); void fwts_method_test_CID_return(fwts_framework *fw, char *name,ACPI_BUFFER *buf, ACPI_OBJECT *obj, void *private); -void fwts_method_test_CLS_return(fwts_framework *fw, char *name, ACPI_BUFFER *buf, ACPI_OBJECT *obj, void *private); void fwts_method_test_HID_return(fwts_framework *fw, char *name, ACPI_BUFFER *buf, ACPI_OBJECT *obj, void *private); void fwts_method_test_MLS_return( fwts_framework *fw, char *name, ACPI_BUFFER *buf, ACPI_OBJECT *obj, void *private); void fwts_method_test_PLD_return(fwts_framework *fw, char *name, ACPI_BUFFER *buf, ACPI_OBJECT *obj, void *private); diff --git a/src/lib/src/fwts_acpi_object_eval.c b/src/lib/src/fwts_acpi_object_eval.c index 613a6fd3..42b97d26 100644 --- a/src/lib/src/fwts_acpi_object_eval.c +++ b/src/lib/src/fwts_acpi_object_eval.c @@ -1985,31 +1985,11 @@ int fwts_method_test_CID(fwts_framework *fw, ACPI_HANDLE *device) "_CID", NULL, 0, fwts_method_test_CID_return, NULL); } -void fwts_method_test_CLS_return( - fwts_framework *fw, - char *name, - ACPI_BUFFER *buf, - ACPI_OBJECT *obj, - void *private) -{ - FWTS_UNUSED(private); - - if (fwts_method_check_type(fw, name, buf, ACPI_TYPE_PACKAGE) != FWTS_OK) - return; - - if (fwts_method_package_count_equal(fw, name, "_CLS", obj, 3) != FWTS_OK) - return; - - if (fwts_method_package_elements_all_type(fw, name, "_CLS", obj, ACPI_TYPE_INTEGER) != FWTS_OK) - return; - - fwts_method_passed_sane(fw, name, "package"); -} - int fwts_method_test_CLS(fwts_framework *fw, ACPI_HANDLE *device) { + uint32_t element_size = 3; return fwts_evaluate_method(fw, METHOD_OPTIONAL, device, - "_CLS", NULL, 0, fwts_method_test_CLS_return, NULL); + "_CLS", NULL, 0, fwts_method_test_package_integer_return, &element_size); } int fwts_method_test_DDN(fwts_framework *fw, ACPI_HANDLE *device)