From patchwork Mon Dec 10 18:10:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 10722137 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2090A159A for ; Mon, 10 Dec 2018 18:29:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1372E2AA81 for ; Mon, 10 Dec 2018 18:29:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 082BF2AA93; Mon, 10 Dec 2018 18:29:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id EC5942AA6F for ; Mon, 10 Dec 2018 18:29:37 +0000 (UTC) Received: from localhost ([::1]:34218 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gWQJF-0008CA-3F for patchwork-qemu-devel@patchwork.kernel.org; Mon, 10 Dec 2018 13:29:37 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59236) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gWQAm-0001Wt-NW for qemu-devel@nongnu.org; Mon, 10 Dec 2018 13:20:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gWQAj-0006NJ-HZ for qemu-devel@nongnu.org; Mon, 10 Dec 2018 13:20:52 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45384) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gWQAj-0006Lw-8R for qemu-devel@nongnu.org; Mon, 10 Dec 2018 13:20:49 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 11E9C3001FE7; Mon, 10 Dec 2018 18:20:47 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id D83D95C1B4; Mon, 10 Dec 2018 18:20:45 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Mon, 10 Dec 2018 19:10:09 +0100 Message-Id: <1544465415-207855-4-git-send-email-imammedo@redhat.com> In-Reply-To: <1544465415-207855-1-git-send-email-imammedo@redhat.com> References: <1544465415-207855-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Mon, 10 Dec 2018 18:20:47 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 3/9] tests: acpi: make sure FADT is fetched only once X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Thomas Huth , Samuel Ortiz , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Whole FADT is fetched as part of RSDT referenced tables in fetch_rsdt_referenced_tables() albeit a bit later than when FADT is partially parsed in fadt_fetch_facs_and_dsdt_ptrs(). However there is no reason for calling fetch_rsdt_referenced_tables() so late, just move it right after we fetched RSDT and before fadt_fetch_facs_and_dsdt_ptrs(). That way we can reuse whole FADT fetched by fetch_rsdt_referenced_tables() and avoid duplicate custom fields fetching in fadt_fetch_facs_and_dsdt_ptrs(). While at it rename fadt_fetch_facs_and_dsdt_ptrs() to test_acpi_fadt_table(). The follow up patch will merge fadt_fetch_facs_and_dsdt_ptrs() into test_acpi_rsdt_table(), so that we would end up calling only test_acpi_FOO_table() for consistency for tables that require special processing. Signed-off-by: Igor Mammedov --- tests/bios-tables-test.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c index 1666cf7..5faf75f 100644 --- a/tests/bios-tables-test.c +++ b/tests/bios-tables-test.c @@ -139,18 +139,15 @@ static void test_acpi_rsdt_table(test_data *data) data->rsdt_tables_nr = tables_nr; } -static void fadt_fetch_facs_and_dsdt_ptrs(test_data *data) +static void test_acpi_fadt_table(test_data *data) { - uint32_t addr; - AcpiTableHeader hdr; + /* FADT table is 1st */ + AcpiSdtTable *fadt = &g_array_index(data->tables, typeof(*fadt), 0); - /* FADT table comes first */ - addr = le32_to_cpu(data->rsdt_tables_addr[0]); - ACPI_READ_TABLE_HEADER(&hdr, addr); - ACPI_ASSERT_CMP(hdr.signature, "FACP"); + ACPI_ASSERT_CMP(fadt->header->signature, "FACP"); - ACPI_READ_FIELD(data->facs_addr, addr); - ACPI_READ_FIELD(data->dsdt_addr, addr); + memcpy(&data->facs_addr, fadt->aml + 36 /* FIRMWARE_CTRL */, 4); + memcpy(&data->dsdt_addr, fadt->aml + 40 /* DSDT */, 4); } static void sanitize_fadt_ptrs(test_data *data) @@ -622,10 +619,10 @@ static void test_acpi_one(const char *params, test_data *data) test_acpi_rsdp_address(data); test_acpi_rsdp_table(data); test_acpi_rsdt_table(data); - fadt_fetch_facs_and_dsdt_ptrs(data); + fetch_rsdt_referenced_tables(data); + test_acpi_fadt_table(data); test_acpi_facs_table(data); test_acpi_dsdt_table(data); - fetch_rsdt_referenced_tables(data); sanitize_fadt_ptrs(data);