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 1540832058493735.7731725563151; Mon, 29 Oct 2018 09:54:18 -0700 (PDT) Received: from localhost ([::1]:46927 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHAnx-00037l-7r for importer@patchew.org; Mon, 29 Oct 2018 12:54:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59674) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHAN3-0000q2-Gy 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-0008Bt-AW for qemu-devel@nongnu.org; Mon, 29 Oct 2018 12:26:27 -0400 Received: from mga06.intel.com ([134.134.136.31]:12989) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gHAMy-00083a-8C for qemu-devel@nongnu.org; Mon, 29 Oct 2018 12:26:24 -0400 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Oct 2018 09:26:08 -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:05 -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="103492189" From: Samuel Ortiz To: qemu-devel@nongnu.org Date: Mon, 29 Oct 2018 17:24:39 +0100 Message-Id: <20181029162441.31631-18-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.31 Subject: [Qemu-devel] [PATCH v2 17/19] hw: acpi: Define ACPI tables builder interface 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 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" In order to decouple ACPI APIs from specific machine types, we are creating an ACPI builder interface that each ACPI platform can choose to implement. This way, a new machine type can re-use the high level ACPI APIs and define some custom table build methods, without having to duplicate most of the existing implementation only to add small variations to it. Cc: Eduardo Habkost Cc: Marcel Apfelbaum Signed-off-by: Samuel Ortiz --- hw/acpi/Makefile.objs | 1 + hw/acpi/builder.c | 97 +++++++++++++++++++++++++++++++++++++++ include/hw/acpi/builder.h | 97 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 195 insertions(+) create mode 100644 hw/acpi/builder.c create mode 100644 include/hw/acpi/builder.h diff --git a/hw/acpi/Makefile.objs b/hw/acpi/Makefile.objs index 11c35bcb44..2f383adc6f 100644 --- a/hw/acpi/Makefile.objs +++ b/hw/acpi/Makefile.objs @@ -11,6 +11,7 @@ common-obj-$(call lnot,$(CONFIG_ACPI_X86)) +=3D acpi-stub= .o 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 builder.o =20 common-obj-$(CONFIG_IPMI) +=3D ipmi.o common-obj-$(call lnot,$(CONFIG_IPMI)) +=3D ipmi-stub.o diff --git a/hw/acpi/builder.c b/hw/acpi/builder.c new file mode 100644 index 0000000000..c29a614793 --- /dev/null +++ b/hw/acpi/builder.c @@ -0,0 +1,97 @@ +/* + * + * Copyright (c) 2018 Intel Corporation + * + * 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 . + */ + +#include "qemu/osdep.h" +#include "qemu/module.h" +#include "qom/object.h" +#include "hw/acpi/builder.h" + +void acpi_builder_rsdp(AcpiBuilder *builder, + GArray *table_data, BIOSLinker *linker, + unsigned rsdt_tbl_offset) +{ + AcpiBuilderMethods *abm =3D ACPI_BUILDER_GET_METHODS(builder); + + if (abm && abm->rsdp) { + abm->rsdp(table_data, linker, rsdt_tbl_offset); + } +} + +void acpi_builder_madt(AcpiBuilder *builder, + GArray *table_data, BIOSLinker *linker, + MachineState *ms, AcpiConfiguration *conf) +{ + AcpiBuilderMethods *abm =3D ACPI_BUILDER_GET_METHODS(builder); + + if (abm && abm->madt) { + abm->madt(table_data, linker, ms, conf); + } +} + +void acpi_builder_mcfg(AcpiBuilder *builder, + GArray *table_data, BIOSLinker *linker, + AcpiMcfgInfo *info) +{ + AcpiBuilderMethods *abm =3D ACPI_BUILDER_GET_METHODS(builder); + + if (abm && abm->mcfg) { + abm->mcfg(table_data, linker, info); + } +} + +void acpi_builder_srat(AcpiBuilder *builder, + GArray *table_data, BIOSLinker *linker, + MachineState *machine, AcpiConfiguration *conf) +{ + AcpiBuilderMethods *abm =3D ACPI_BUILDER_GET_METHODS(builder); + + if (abm && abm->srat) { + abm->srat(table_data, linker, machine, conf); + } +} + +void acpi_builder_slit(AcpiBuilder *builder, + GArray *table_data, BIOSLinker *linker) +{ + AcpiBuilderMethods *abm =3D ACPI_BUILDER_GET_METHODS(builder); + + if (abm && abm->slit) { + abm->slit(table_data, linker); + } +} + +AcpiConfiguration *acpi_builder_configuration(AcpiBuilder *builder) +{ + AcpiBuilderMethods *abm =3D ACPI_BUILDER_GET_METHODS(builder); + if (abm && abm->configuration) { + return abm->configuration(builder); + } + return NULL; +} + +static const TypeInfo acpi_builder_info =3D { + .name =3D TYPE_ACPI_BUILDER, + .parent =3D TYPE_INTERFACE, + .class_size =3D sizeof(AcpiBuilderMethods), +}; + +static void acpi_builder_register_type(void) +{ + type_register_static(&acpi_builder_info); +} + +type_init(acpi_builder_register_type) diff --git a/include/hw/acpi/builder.h b/include/hw/acpi/builder.h new file mode 100644 index 0000000000..639b554de3 --- /dev/null +++ b/include/hw/acpi/builder.h @@ -0,0 +1,97 @@ +/* + * + * Copyright (c) 2018 Intel Corporation + * + * 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 ACPI_BUILDER_H +#define ACPI_BUILDER_H + +#include "qemu/osdep.h" +#include "hw/acpi/bios-linker-loader.h" +#include "qom/object.h" + +#define TYPE_ACPI_BUILDER "acpi-builder" + +#define ACPI_BUILDER_METHODS(klass) \ + OBJECT_CLASS_CHECK(AcpiBuilderMethods, (klass), TYPE_ACPI_BUILDER) +#define ACPI_BUILDER_GET_METHODS(obj) \ + OBJECT_GET_CLASS(AcpiBuilderMethods, (obj), TYPE_ACPI_BUILDER) +#define ACPI_BUILDER(obj) \ + INTERFACE_CHECK(AcpiBuilder, (obj), TYPE_ACPI_BUILDER) + +typedef struct AcpiConfiguration AcpiConfiguration; +typedef struct AcpiBuildState AcpiBuildState; +typedef struct AcpiMcfgInfo AcpiMcfgInfo; + +typedef struct AcpiBuilder { + /* */ + Object Parent; +} AcpiBuilder; + +/** + * AcpiBuildMethods: + * + * Interface to be implemented by a machine type that needs to provide + * custom ACPI tables build method. + * + * @parent: Opaque parent interface. + * + * @rsdp: + * @madt: + * @mcfg: + * @srat: + * @slit: + * @setup: + */ +typedef struct AcpiBuilderMethods { + /* */ + InterfaceClass parent; + + /* */ + void (*rsdp)(GArray *table_data, BIOSLinker *linker, + unsigned rsdt_tbl_offset); + void (*madt)(GArray *table_data, BIOSLinker *linker, + MachineState *ms, AcpiConfiguration *conf); + void (*mcfg)(GArray *table_data, BIOSLinker *linker, + AcpiMcfgInfo *info); + void (*srat)(GArray *table_data, BIOSLinker *linker, + MachineState *machine, AcpiConfiguration *conf); + void (*slit)(GArray *table_data, BIOSLinker *linker); + + AcpiConfiguration *(*configuration)(AcpiBuilder *builder); +} AcpiBuilderMethods; + +void acpi_builder_rsdp(AcpiBuilder *builder, + GArray *table_data, BIOSLinker *linker, + unsigned rsdt_tbl_offset); + +void acpi_builder_madt(AcpiBuilder *builder, + GArray *table_data, BIOSLinker *linker, + MachineState *ms, AcpiConfiguration *conf); + +void acpi_builder_mcfg(AcpiBuilder *builder, + GArray *table_data, BIOSLinker *linker, + AcpiMcfgInfo *info); + +void acpi_builder_srat(AcpiBuilder *builder, + GArray *table_data, BIOSLinker *linker, + MachineState *machine, AcpiConfiguration *conf); + +void acpi_builder_slit(AcpiBuilder *builder, + GArray *table_data, BIOSLinker *linker); + +AcpiConfiguration *acpi_builder_configuration(AcpiBuilder *builder); + +#endif --=20 2.17.2