From nobody Thu Mar 28 08:33:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.intel.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1552611302174796.9435816161421; Thu, 14 Mar 2019 17:55:02 -0700 (PDT) Received: from localhost ([127.0.0.1]:47194 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h4b7c-0005M3-Q0 for importer@patchew.org; Thu, 14 Mar 2019 20:54:52 -0400 Received: from eggs.gnu.org ([209.51.188.92]:52600) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h4b6G-0004MO-Bf for qemu-devel@nongnu.org; Thu, 14 Mar 2019 20:53:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h4ay7-0005yh-QN for qemu-devel@nongnu.org; Thu, 14 Mar 2019 20:45:04 -0400 Received: from mga06.intel.com ([134.134.136.31]:24121) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h4ay6-0005tS-0U; Thu, 14 Mar 2019 20:45:02 -0400 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Mar 2019 17:44:58 -0700 Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by orsmga001.jf.intel.com with ESMTP; 14 Mar 2019 17:44:57 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,480,1544515200"; d="scan'208";a="214314577" From: Wei Yang To: qemu-devel@nongnu.org, qemu-arm@nongnu.org Date: Fri, 15 Mar 2019 08:44:32 +0800 Message-Id: <20190315004432.3445-1-richardw.yang@linux.intel.com> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 134.134.136.31 Subject: [Qemu-devel] [PATCH v3] hw/acpi: extract acpi_add_rom_blob() 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: yang.zhong@intel.com, peter.maydell@linaro.org, mst@redhat.com, shannon.zhaosl@gmail.com, Wei Yang , imammedo@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" arm and i386 has almost the same function acpi_add_rom_blob(), except giving different FWCfgCallback function. This patch extract acpi_add_rom_blob() to utils.c by passing FWCfgCallback to it. Signed-off-by: Wei Yang --- v3: * put acpi_add_rom_blob() to hw/acpi/utils.c v2: * remove unused header in original source file --- hw/acpi/Makefile.objs | 2 +- hw/acpi/utils.c | 35 +++++++++++++++++++++++++++++++++++ hw/arm/virt-acpi-build.c | 26 ++++++++++---------------- hw/i386/acpi-build.c | 26 ++++++++++---------------- include/hw/acpi/utils.h | 9 +++++++++ 5 files changed, 65 insertions(+), 33 deletions(-) create mode 100644 hw/acpi/utils.c create mode 100644 include/hw/acpi/utils.h diff --git a/hw/acpi/Makefile.objs b/hw/acpi/Makefile.objs index 2d46e3789a..ba93c5b64a 100644 --- a/hw/acpi/Makefile.objs +++ b/hw/acpi/Makefile.objs @@ -10,7 +10,7 @@ common-obj-$(call lnot,$(CONFIG_ACPI_X86)) +=3D acpi-stub= .o =20 common-obj-y +=3D acpi_interface.o common-obj-y +=3D bios-linker-loader.o -common-obj-y +=3D aml-build.o +common-obj-y +=3D aml-build.o utils.o common-obj-$(CONFIG_TPM) +=3D tpm.o =20 common-obj-$(CONFIG_IPMI) +=3D ipmi.o diff --git a/hw/acpi/utils.c b/hw/acpi/utils.c new file mode 100644 index 0000000000..ab0e064a0e --- /dev/null +++ b/hw/acpi/utils.c @@ -0,0 +1,35 @@ +/* Utilities for generating ACPI tables and passing them to Guests + * + * Copyright (C) 2019 Intel Corporation + * Copyright (C) 2019 Red Hat Inc + * + * Author: Wei Yang + * Author: Igor Mammedov + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License along + * with this program; if not, see . + */ + +#include "qemu/osdep.h" +#include +#include "hw/acpi/aml-build.h" +#include "hw/acpi/utils.h" + +MemoryRegion *acpi_add_rom_blob(FWCfgCallback update, void *opaque, + GArray *blob, const char *name, + uint64_t max_size) +{ + return rom_add_blob(name, blob->data, acpi_data_len(blob), max_size, -= 1, + name, update, opaque, NULL, true); +} + diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index 57679a89bf..a846f74a14 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -37,9 +37,9 @@ #include "hw/acpi/acpi.h" #include "hw/nvram/fw_cfg.h" #include "hw/acpi/bios-linker-loader.h" -#include "hw/loader.h" #include "hw/hw.h" #include "hw/acpi/aml-build.h" +#include "hw/acpi/utils.h" #include "hw/pci/pcie_host.h" #include "hw/pci/pci.h" #include "hw/arm/virt.h" @@ -881,14 +881,6 @@ static void virt_acpi_build_reset(void *build_opaque) build_state->patched =3D false; } =20 -static MemoryRegion *acpi_add_rom_blob(AcpiBuildState *build_state, - GArray *blob, const char *name, - uint64_t max_size) -{ - return rom_add_blob(name, blob->data, acpi_data_len(blob), max_size, -= 1, - name, virt_acpi_build_update, build_state, NULL, t= rue); -} - static const VMStateDescription vmstate_virt_acpi_build =3D { .name =3D "virt_acpi_build", .version_id =3D 1, @@ -920,20 +912,22 @@ void virt_acpi_setup(VirtMachineState *vms) virt_acpi_build(vms, &tables); =20 /* Now expose it all to Guest */ - build_state->table_mr =3D acpi_add_rom_blob(build_state, tables.table_= data, - ACPI_BUILD_TABLE_FILE, - ACPI_BUILD_TABLE_MAX_SIZE); + build_state->table_mr =3D acpi_add_rom_blob(virt_acpi_build_update, + build_state, tables.table_da= ta, + ACPI_BUILD_TABLE_FILE, + ACPI_BUILD_TABLE_MAX_SIZE); assert(build_state->table_mr !=3D NULL); =20 build_state->linker_mr =3D - acpi_add_rom_blob(build_state, tables.linker->cmd_blob, - "etc/table-loader", 0); + acpi_add_rom_blob(virt_acpi_build_update, build_state, + tables.linker->cmd_blob, "etc/table-loader", 0); =20 fw_cfg_add_file(vms->fw_cfg, ACPI_BUILD_TPMLOG_FILE, tables.tcpalog->d= ata, acpi_data_len(tables.tcpalog)); =20 - build_state->rsdp_mr =3D acpi_add_rom_blob(build_state, tables.rsdp, - ACPI_BUILD_RSDP_FILE, 0); + build_state->rsdp_mr =3D acpi_add_rom_blob(virt_acpi_build_update, + build_state, tables.rsdp, + ACPI_BUILD_RSDP_FILE, 0); =20 qemu_register_reset(virt_acpi_build_reset, build_state); virt_acpi_build_reset(build_state); diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 416da318ae..b17d4a711d 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -37,7 +37,6 @@ #include "hw/acpi/cpu.h" #include "hw/nvram/fw_cfg.h" #include "hw/acpi/bios-linker-loader.h" -#include "hw/loader.h" #include "hw/isa/isa.h" #include "hw/block/fdc.h" #include "hw/acpi/memory_hotplug.h" @@ -58,6 +57,7 @@ #include "hw/i386/x86-iommu.h" =20 #include "hw/acpi/aml-build.h" +#include "hw/acpi/utils.h" =20 #include "qom/qom-qobject.h" #include "hw/i386/amd_iommu.h" @@ -2842,14 +2842,6 @@ static void acpi_build_reset(void *build_opaque) build_state->patched =3D 0; } =20 -static MemoryRegion *acpi_add_rom_blob(AcpiBuildState *build_state, - GArray *blob, const char *name, - uint64_t max_size) -{ - return rom_add_blob(name, blob->data, acpi_data_len(blob), max_size, -= 1, - name, acpi_build_update, build_state, NULL, true); -} - static const VMStateDescription vmstate_acpi_build =3D { .name =3D "acpi_build", .version_id =3D 1, @@ -2891,14 +2883,15 @@ void acpi_setup(void) acpi_build(&tables, MACHINE(pcms)); =20 /* Now expose it all to Guest */ - build_state->table_mr =3D acpi_add_rom_blob(build_state, tables.table_= data, - ACPI_BUILD_TABLE_FILE, - ACPI_BUILD_TABLE_MAX_SIZE); + build_state->table_mr =3D acpi_add_rom_blob(acpi_build_update, + build_state, tables.table_da= ta, + ACPI_BUILD_TABLE_FILE, + ACPI_BUILD_TABLE_MAX_SIZE); assert(build_state->table_mr !=3D NULL); =20 build_state->linker_mr =3D - acpi_add_rom_blob(build_state, tables.linker->cmd_blob, - "etc/table-loader", 0); + acpi_add_rom_blob(acpi_build_update, build_state, + tables.linker->cmd_blob, "etc/table-loader", 0); =20 fw_cfg_add_file(pcms->fw_cfg, ACPI_BUILD_TPMLOG_FILE, tables.tcpalog->data, acpi_data_len(tables.tcpalog)); @@ -2935,8 +2928,9 @@ void acpi_setup(void) build_state->rsdp_mr =3D NULL; } else { build_state->rsdp =3D NULL; - build_state->rsdp_mr =3D acpi_add_rom_blob(build_state, tables.rsd= p, - ACPI_BUILD_RSDP_FILE, 0); + build_state->rsdp_mr =3D acpi_add_rom_blob(acpi_build_update, + build_state, tables.rsdp, + ACPI_BUILD_RSDP_FILE, 0); } =20 qemu_register_reset(acpi_build_reset, build_state); diff --git a/include/hw/acpi/utils.h b/include/hw/acpi/utils.h new file mode 100644 index 0000000000..5212113b7d --- /dev/null +++ b/include/hw/acpi/utils.h @@ -0,0 +1,9 @@ +#ifndef HW_ACPI_UTILS_H +#define HW_ACPI_UTILS_H + +#include "hw/loader.h" + +MemoryRegion *acpi_add_rom_blob(FWCfgCallback update, void *opaque, + GArray *blob, const char *name, + uint64_t max_size); +#endif --=20 2.19.1