From nobody Thu Nov 6 12:12:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.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 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1540831288070612.1477307156815; Mon, 29 Oct 2018 09:41:28 -0700 (PDT) Received: from localhost ([::1]:46826 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHAbW-00004z-OI for importer@patchew.org; Mon, 29 Oct 2018 12:41:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59680) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHAN3-0000qH-Te for qemu-devel@nongnu.org; Mon, 29 Oct 2018 12:26:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHAMz-0008Bb-8Y for qemu-devel@nongnu.org; Mon, 29 Oct 2018 12:26:29 -0400 Received: from mga07.intel.com ([134.134.136.100]:22748) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gHAMw-0008AB-SR for qemu-devel@nongnu.org; Mon, 29 Oct 2018 12:26:24 -0400 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Oct 2018 09:26:19 -0700 Received: from mjadwisz-mobl.ger.corp.intel.com (HELO localhost.localdomain) ([10.252.7.64]) by fmsmga001.fm.intel.com with ESMTP; 29 Oct 2018 09:26:10 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,440,1534834800"; d="scan'208";a="103492204" From: Samuel Ortiz To: qemu-devel@nongnu.org Date: Mon, 29 Oct 2018 17:24:41 +0100 Message-Id: <20181029162441.31631-20-sameo@linux.intel.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181029162441.31631-1-sameo@linux.intel.com> References: <20181029162441.31631-1-sameo@linux.intel.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 134.134.136.100 Subject: [Qemu-devel] [PATCH v2 19/19] hw: i386: Implement the ACPI builder interface for PC 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: Eduardo Habkost , "Michael S. Tsirkin" , Paolo Bonzini , Igor Mammedov , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" All PC machine type derivatives will use the same ACPI table build methods. But with that change in place, any new x86 machine type will be able to re-use the acpi-build API and customize part of it by defining its own ACPI table build methods. Cc: "Michael S. Tsirkin" Cc: Igor Mammedov Cc: Marcel Apfelbaum Cc: Paolo Bonzini Cc: Richard Henderson Cc: Eduardo Habkost Signed-off-by: Samuel Ortiz --- hw/i386/acpi-build.c | 15 ++++++++++----- hw/i386/pc.c | 19 +++++++++++++++++++ 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 5035dac556..d40599e6d1 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -35,6 +35,7 @@ #include "hw/acpi/acpi-defs.h" #include "hw/acpi/acpi.h" #include "hw/acpi/cpu.h" +#include "hw/acpi/builder.h" #include "hw/nvram/fw_cfg.h" #include "hw/acpi/bios-linker-loader.h" #include "hw/loader.h" @@ -1556,6 +1557,7 @@ void acpi_build(AcpiBuildTables *tables, GArray *tables_blob =3D tables->table_data; AcpiSlicOem slic_oem =3D { .id =3D NULL, .table_id =3D NULL }; Object *vmgenid_dev; + AcpiBuilder *ab =3D ACPI_BUILDER(machine); =20 acpi_get_pm_info(&pm); acpi_get_misc_info(&misc); @@ -1605,7 +1607,8 @@ void acpi_build(AcpiBuildTables *tables, aml_len +=3D tables_blob->len - fadt; =20 acpi_add_table(table_offsets, tables_blob); - build_madt(tables_blob, tables->linker, machine, conf); + acpi_builder_madt(ab, tables_blob, tables->linker, + machine, conf); =20 vmgenid_dev =3D find_vmgenid_dev(); if (vmgenid_dev) { @@ -1629,15 +1632,17 @@ void acpi_build(AcpiBuildTables *tables, } if (conf->numa_nodes) { acpi_add_table(table_offsets, tables_blob); - build_srat(tables_blob, tables->linker, machine, conf); + + acpi_builder_srat(ab, tables_blob, tables->linker, + machine, conf); if (have_numa_distance) { acpi_add_table(table_offsets, tables_blob); - build_slit(tables_blob, tables->linker); + acpi_builder_slit(ab, tables_blob, tables->linker); } } if (acpi_get_mcfg(&mcfg)) { acpi_add_table(table_offsets, tables_blob); - build_mcfg(tables_blob, tables->linker, &mcfg); + acpi_builder_mcfg(ab, tables_blob, tables->linker, &mcfg); } if (x86_iommu_get_default()) { IommuType IOMMUType =3D x86_iommu_get_type(); @@ -1668,7 +1673,7 @@ void acpi_build(AcpiBuildTables *tables, slic_oem.id, slic_oem.table_id); =20 /* RSDP is in FSEG memory, so allocate it separately */ - build_rsdp_rsdt(tables->rsdp, tables->linker, rsdt); + acpi_builder_rsdp(ab, tables->rsdp, tables->linker, rsdt); =20 /* We'll expose it all to Guest so we want to reduce * chance of size changes. diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 1dcbbd5139..986ed0eabd 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -64,6 +64,7 @@ #include "qemu/option.h" #include "hw/acpi/acpi.h" #include "hw/acpi/cpu_hotplug.h" +#include "hw/acpi/builder.h" #include "hw/boards.h" #include "acpi-build.h" #include "hw/mem/pc-dimm.h" @@ -75,6 +76,7 @@ #include "hw/nmi.h" #include "hw/i386/intel_iommu.h" #include "hw/net/ne2000-isa.h" +#include "hw/i386/acpi.h" =20 /* debug PC/ISA interrupts */ //#define DEBUG_IRQ @@ -2403,12 +2405,20 @@ static void x86_nmi(NMIState *n, int cpu_index, Err= or **errp) } } =20 +static AcpiConfiguration *pc_acpi_configuration(AcpiBuilder *builder) +{ + PCMachineState *pcms =3D PC_MACHINE(builder); + + return &pcms->acpi_configuration; +} + static void pc_machine_class_init(ObjectClass *oc, void *data) { MachineClass *mc =3D MACHINE_CLASS(oc); PCMachineClass *pcmc =3D PC_MACHINE_CLASS(oc); HotplugHandlerClass *hc =3D HOTPLUG_HANDLER_CLASS(oc); NMIClass *nc =3D NMI_CLASS(oc); + AcpiBuilderMethods *abm =3D ACPI_BUILDER_METHODS(oc); =20 pcmc->pci_enabled =3D true; pcmc->has_acpi_build =3D true; @@ -2443,6 +2453,14 @@ static void pc_machine_class_init(ObjectClass *oc, v= oid *data) nc->nmi_monitor_handler =3D x86_nmi; mc->default_cpu_type =3D TARGET_DEFAULT_CPU_TYPE; =20 + /* ACPI building methods */ + abm->madt =3D build_madt; + abm->rsdp =3D build_rsdp_rsdt; + abm->mcfg =3D build_mcfg; + abm->srat =3D build_srat; + abm->slit =3D build_slit; + abm->configuration =3D pc_acpi_configuration; + object_class_property_add(oc, MEMORY_DEVICE_REGION_SIZE, "int", pc_machine_get_device_memory_region_size, NULL, NULL, NULL, &error_abort); @@ -2494,6 +2512,7 @@ static const TypeInfo pc_machine_info =3D { .interfaces =3D (InterfaceInfo[]) { { TYPE_HOTPLUG_HANDLER }, { TYPE_NMI }, + { TYPE_ACPI_BUILDER }, { } }, }; --=20 2.17.2