From nobody Thu Nov 6 10:13:57 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 1540234215997810.5881388718932; Mon, 22 Oct 2018 11:50:15 -0700 (PDT) Received: from localhost ([::1]:36659 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gEfHK-0002oX-Ou for importer@patchew.org; Mon, 22 Oct 2018 14:50:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39467) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gEf6T-00012Z-TH for qemu-devel@nongnu.org; Mon, 22 Oct 2018 14:39:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gEf6P-0004ug-8J for qemu-devel@nongnu.org; Mon, 22 Oct 2018 14:39:00 -0400 Received: from mga01.intel.com ([192.55.52.88]:7887) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gEf6N-0004fU-4j for qemu-devel@nongnu.org; Mon, 22 Oct 2018 14:38:55 -0400 Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Oct 2018 11:38:42 -0700 Received: from omccarth-mobl.ger.corp.intel.com (HELO localhost.localdomain) ([10.252.18.99]) by FMSMGA003.fm.intel.com with ESMTP; 22 Oct 2018 11:38:38 -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,413,1534834800"; d="scan'208";a="90378025" From: Samuel Ortiz To: qemu-devel@nongnu.org Date: Mon, 22 Oct 2018 20:36:47 +0200 Message-Id: <20181022183656.4902-18-sameo@linux.intel.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181022183656.4902-1-sameo@linux.intel.com> References: <20181022183656.4902-1-sameo@linux.intel.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.88 Subject: [Qemu-devel] [PATCH 17/26] hw: i386: Convert PC machine type to firmware build methods 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: Samuel Ortiz , "Michael S. Tsirkin" , Eduardo Habkost , Paolo Bonzini , Igor Mammedov , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 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 | 22 ++++++++++++++-------- hw/i386/pc.c | 9 +++++++++ include/hw/i386/acpi.h | 27 +++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 8 deletions(-) create mode 100644 include/hw/i386/acpi.h diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 9cb739bf5c..4274349053 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -62,6 +62,7 @@ #include "qom/qom-qobject.h" #include "hw/i386/amd_iommu.h" #include "hw/i386/intel_iommu.h" +#include "hw/i386/acpi.h" =20 #include "hw/acpi/ipmi.h" =20 @@ -281,9 +282,8 @@ void pc_madt_cpu_entry(AcpiDeviceIf *adev, int uid, } } =20 -static void -build_madt(GArray *table_data, BIOSLinker *linker, - MachineState *ms, AcpiConfiguration *conf) +GArray *build_madt(GArray *table_data, BIOSLinker *linker, + MachineState *ms, AcpiConfiguration *conf) { MachineClass *mc =3D MACHINE_GET_CLASS(ms); const CPUArchIdList *apic_ids =3D mc->possible_cpu_arch_ids(ms); @@ -360,6 +360,8 @@ build_madt(GArray *table_data, BIOSLinker *linker, build_header(linker, table_data, (void *)(table_data->data + madt_start), "APIC", table_data->len - madt_start, 1, NULL, NULL); + + return table_data; } =20 static void build_hpet_aml(Aml *table) @@ -1544,6 +1546,7 @@ static void acpi_build(AcpiBuildTables *tables, MachineState *machine, AcpiConfiguration *conf) { + MachineClass *mc =3D MACHINE_GET_CLASS(machine); GArray *table_offsets; unsigned facs, dsdt, rsdt, fadt; AcpiPmInfo pm; @@ -1604,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); + mc->firmware_build_methods.acpi.madt(tables_blob, tables->linker, + machine, conf); =20 vmgenid_dev =3D find_vmgenid_dev(); if (vmgenid_dev) { @@ -1628,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); + mc->firmware_build_methods.acpi.srat(tables_blob, tables->linker, + machine, conf); if (have_numa_distance) { acpi_add_table(table_offsets, tables_blob); - build_slit(tables_blob, tables->linker); + mc->firmware_build_methods.acpi.slit(tables_blob, tables->link= er); } } if (acpi_get_mcfg(&mcfg)) { acpi_add_table(table_offsets, tables_blob); - build_mcfg(tables_blob, tables->linker, &mcfg); + mc->firmware_build_methods.acpi.mcfg(tables_blob, tables->linker, + &mcfg); } if (x86_iommu_get_default()) { IommuType IOMMUType =3D x86_iommu_get_type(); @@ -1667,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); + mc->firmware_build_methods.acpi.rsdp(tables->rsdp, tables->linker, rsd= t); =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 fa12583096..db69dbfef7 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -75,6 +75,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 @@ -2443,6 +2444,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 + /* Firmware building handler */ + mc->firmware_build_methods.acpi.madt =3D build_madt; + mc->firmware_build_methods.acpi.rsdp =3D build_rsdp_rsdt; + mc->firmware_build_methods.acpi.setup =3D acpi_setup; + mc->firmware_build_methods.acpi.mcfg =3D build_mcfg; + mc->firmware_build_methods.acpi.srat =3D build_srat; + mc->firmware_build_methods.acpi.slit =3D build_slit; + object_class_property_add(oc, MEMORY_DEVICE_REGION_SIZE, "int", pc_machine_get_device_memory_region_size, NULL, NULL, NULL, &error_abort); diff --git a/include/hw/i386/acpi.h b/include/hw/i386/acpi.h new file mode 100644 index 0000000000..d92c29350b --- /dev/null +++ b/include/hw/i386/acpi.h @@ -0,0 +1,27 @@ +/* + * + * Copyright (c) 2018 Intel Corportation + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2 or later, as published by the Free Software Foundation. + * + * This program is distributed in the hope 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 f= or + * more details. + * + * You should have received a copy of the GNU General Public License along= with + * this program. If not, see . + */ + +#ifndef QEMU_I386_ACPI_H +#define QEMU_I386_ACPI_H + +#include "hw/acpi/acpi.h" + +/* Build methods */ +GArray *build_madt(GArray *table_data, BIOSLinker *linker, + MachineState *ms, AcpiConfiguration *conf); + +#endif --=20 2.17.2