From patchwork Mon May 23 17:40:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 68400 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp211611qge; Mon, 23 May 2016 10:42:57 -0700 (PDT) X-Received: by 10.140.42.78 with SMTP id b72mr77253qga.48.1464025377630; Mon, 23 May 2016 10:42:57 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id g185si4716799qkd.281.2016.05.23.10.42.57 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 23 May 2016 10:42:57 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org Received: from localhost ([::1]:49588 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b4tsX-0002JB-5B for patch@linaro.org; Mon, 23 May 2016 13:42:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47769) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b4tqJ-000170-Hm for qemu-devel@nongnu.org; Mon, 23 May 2016 13:40:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b4tqC-0001pp-Ew for qemu-devel@nongnu.org; Mon, 23 May 2016 13:40:38 -0400 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]:35313) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b4tqB-0001pD-QP for qemu-devel@nongnu.org; Mon, 23 May 2016 13:40:32 -0400 Received: by mail-pf0-x243.google.com with SMTP id f144so4374483pfa.2 for ; Mon, 23 May 2016 10:40:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=1LjhO73OSnwidVwScomkryEEXNukVG/Zm/9K3T72aeM=; b=NTLiSLNF9WbH40iVBqK8+fnBwdJZzuQF1FVMAXCPlkNubf1BOqU4xnXDdsfPPsOE4N lbAroE9gT8S6lm4CsTUeLD23JjBhX+FskpTwI8uZmKaWP5JCqRab569EngF15Tla9ugi RIZBr3k5guZf1TzdraY/pul0hYUATGiRFe1EgRHJhBip693fhzseheB4PO4CnwKOwco3 9pVvDNsjZDc5kGzGexjci+68tAIyLSLe4pTZwsveOvYD6M/174IQRAirP0dUljzphh/Z 3dLNR9Q6LHn86i5x38hkL1APHdpnE6Gl977tliVnDeSx/Bvni2hLDAgK483YATbwh1MN AWGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=1LjhO73OSnwidVwScomkryEEXNukVG/Zm/9K3T72aeM=; b=QVrjcFGWfKDQbmMj2GljPUb5nPxTtLb3sjbCnLsc1ZLuvYx1b0gd3iYmCg7kJMaMA+ FbHCjIKqrvTi9A3v6BMmrbDf8S0ktPTP/tMYv6hkxJcckzAnUDMjnms8APrR/z5vST7H nyTow912Ryf4C5yRLZ7vJjil3bceUQutKY+rrC5Fhjc5X0sG4t+tkYrxtBlNKuAkAe1X wXXlpMWJiiMQV5ONXFPG4t/9R3cX3CcIBp7Yn6HxeQSUMoEuUlxLsbIjWDL3UolnOvub NdFYaZWBq2GdIb8h4gLtEshIkwrBCbcrWd9JGDa13BBQSvIrbhsQ/IinBxwEH9uMsTie 8zlA== X-Gm-Message-State: ALyK8tL26cYrhTvStm5XBBckt5uHG1eX9CtC3gblxMLAQJZMhAaywK7HUAKpHi88Hr6SWA== X-Received: by 10.98.104.133 with SMTP id d127mr91223pfc.112.1464025230762; Mon, 23 May 2016 10:40:30 -0700 (PDT) Received: from serve.minyard.net ([108.19.215.157]) by smtp.gmail.com with ESMTPSA id qa9sm48254368pab.17.2016.05.23.10.40.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 May 2016 10:40:29 -0700 (PDT) Received: from t430.minyard.net (unknown [IPv6:2001:470:b8f6:1b:c5db:5808:170c:dd46]) by serve.minyard.net (Postfix) with ESMTPA id 147991D73; Mon, 23 May 2016 12:40:26 -0500 (CDT) Received: by t430.minyard.net (Postfix, from userid 1000) id C51A8300552; Mon, 23 May 2016 12:40:23 -0500 (CDT) From: minyard@acm.org To: Igor Mammedov , "Michael S . Tsirkin" , Paolo Bonzini , qemu-devel@nongnu.org, minyard@acm.org, cminyard@mvista.com Date: Mon, 23 May 2016 12:40:16 -0500 Message-Id: <1464025217-24054-6-git-send-email-minyard@acm.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1464025217-24054-1-git-send-email-minyard@acm.org> References: <1464025217-24054-1-git-send-email-minyard@acm.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400e:c00::243 Subject: [Qemu-devel] [PATCH v6 5/6] acpi: Add IPMI table entries 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Corey Minyard Use the new ACPI table construction tools to create an ACPI entry for IPMI. This adds a function called from build_dsdt to add an DSDT entry for IPMI if IPMI is compiled in and has registered firmware. It also adds a dummy function if IPMI is not compiled in. This conforms to section "C3-2 Locating IPMI System Interfaces in ACPI Name Space" in the IPMI 2.0 specification. Signed-off-by: Corey Minyard --- hw/acpi/Makefile.objs | 2 + hw/acpi/ipmi.c | 105 +++++++++++++++++++++++++++++++++++++++++++++++++ hw/i386/acpi-build.c | 24 +++++++++-- hw/stubs/Makefile.objs | 1 + hw/stubs/acpi_ipmi.c | 14 +++++++ include/hw/acpi/ipmi.h | 22 +++++++++++ 6 files changed, 165 insertions(+), 3 deletions(-) create mode 100644 hw/acpi/ipmi.c create mode 100644 hw/stubs/acpi_ipmi.c create mode 100644 include/hw/acpi/ipmi.h -- 2.7.4 diff --git a/hw/acpi/Makefile.objs b/hw/acpi/Makefile.objs index faee86c..95824e8 100644 --- a/hw/acpi/Makefile.objs +++ b/hw/acpi/Makefile.objs @@ -6,3 +6,5 @@ obj-$(CONFIG_ACPI_NVDIMM) += nvdimm.o common-obj-$(CONFIG_ACPI) += acpi_interface.o common-obj-$(CONFIG_ACPI) += bios-linker-loader.o common-obj-$(CONFIG_ACPI) += aml-build.o +common-obj-$(call land,$(CONFIG_ACPI),$(CONFIG_IPMI)) += ipmi.o + diff --git a/hw/acpi/ipmi.c b/hw/acpi/ipmi.c new file mode 100644 index 0000000..201f824 --- /dev/null +++ b/hw/acpi/ipmi.c @@ -0,0 +1,105 @@ +/* + * IPMI ACPI firmware handling + * + * Copyright (c) 2015 Corey Minyard, MontaVista Software, LLC + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "hw/ipmi/ipmi.h" +#include "hw/acpi/aml-build.h" +#include "hw/acpi/acpi.h" +#include "hw/acpi/ipmi.h" + +static Aml *aml_ipmi_crs(IPMIFwInfo *info) +{ + Aml *crs = aml_resource_template(); + uint8_t regspacing = info->register_spacing; + + /* + * The base address is fixed and cannot change. That may be different + * if someone does PCI, but we aren't there yet. + */ + switch (info->memspace) { + case IPMI_MEMSPACE_IO: + aml_append(crs, aml_io(AML_DECODE16, info->base_address, + info->base_address + info->register_length - 1, + regspacing, info->register_length)); + break; + case IPMI_MEMSPACE_MEM32: + aml_append(crs, + aml_dword_memory(AML_POS_DECODE, + AML_MIN_FIXED, AML_MAX_FIXED, + AML_NON_CACHEABLE, AML_READ_WRITE, + 0xffffffff, + info->base_address, + info->base_address + info->register_length - 1, + regspacing, info->register_length)); + break; + case IPMI_MEMSPACE_MEM64: + aml_append(crs, + aml_qword_memory(AML_POS_DECODE, + AML_MIN_FIXED, AML_MAX_FIXED, + AML_NON_CACHEABLE, AML_READ_WRITE, + 0xffffffffffffffffULL, + info->base_address, + info->base_address + info->register_length - 1, + regspacing, info->register_length)); + break; + case IPMI_MEMSPACE_SMBUS: + aml_append(crs, aml_return(aml_int(info->base_address))); + break; + default: + abort(); + } + + if (info->interrupt_number) { + aml_append(crs, aml_irq_no_flags(info->interrupt_number)); + } + + return crs; +} + +static Aml *aml_ipmi_device(IPMIFwInfo *info) +{ + Aml *dev; + uint16_t version = ((info->ipmi_spec_major_revision << 8) + | (info->ipmi_spec_minor_revision << 4)); + + dev = aml_device("MI%d", info->uuid); + aml_append(dev, aml_name_decl("_HID", aml_eisaid("IPI0001"))); + aml_append(dev, aml_name_decl("_STR", aml_string("ipmi_%s", + info->interface_name))); + aml_append(dev, aml_name_decl("_UID", aml_int(info->uuid))); + aml_append(dev, aml_name_decl("_CRS", aml_ipmi_crs(info))); + aml_append(dev, aml_name_decl("_IFT", aml_int(info->interface_type))); + aml_append(dev, aml_name_decl("_SRV", aml_int(version))); + + return dev; +} + +void build_acpi_ipmi_devices(Aml *scope, BusState *bus) +{ + + BusChild *kid; + + QTAILQ_FOREACH(kid, &bus->children, sibling) { + DeviceState *dev = kid->child; + Object *obj = object_dynamic_cast(OBJECT(dev), TYPE_IPMI_INTERFACE); + IPMIInterface *ii; + IPMIInterfaceClass *iic; + IPMIFwInfo info; + + if (!obj) { + continue; + } + + ii = IPMI_INTERFACE(obj); + iic = IPMI_INTERFACE_GET_CLASS(obj); + memset(&info, 0, sizeof(info)); + iic->get_fwinfo(ii, &info); + aml_append(scope, aml_ipmi_device(&info)); + } +} diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 279f0d7..bf9253d 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -59,6 +59,8 @@ #include "qapi/qmp/qint.h" #include "qom/qom-qobject.h" +#include "hw/acpi/ipmi.h" + /* These are used to size the ACPI tables for -M pc-i440fx-1.7 and * -M pc-i440fx-2.0. Even if the actual amount of AML generated grows * a little bit, there should be plenty of free space since the DSDT @@ -1445,7 +1447,21 @@ static Aml *build_com_device_aml(uint8_t uid) return dev; } -static void build_isa_devices_aml(Aml *table) +static void build_isa_ipmi_aml(Aml *scope) +{ + bool ambiguous; + Object *obj = object_resolve_path_type("", TYPE_ISA_BUS, &ambiguous); + + if (ambiguous) { + error_report("Multiple ISA busses, unable to define IPMI ACPI data"); + } else if (!obj) { + error_report("No ISA bus, unable to define IPMI ACPI data"); + } else { + build_acpi_ipmi_devices(scope, BUS(obj)); + } +} + +static void build_isa_devices_aml(Aml *table, PCMachineState *pcms) { ISADevice *fdc = pc_find_fdc0(); @@ -1461,6 +1477,8 @@ static void build_isa_devices_aml(Aml *table) aml_append(scope, build_com_device_aml(1)); aml_append(scope, build_com_device_aml(2)); + build_isa_ipmi_aml(scope); + aml_append(table, scope); } @@ -2011,7 +2029,7 @@ build_dsdt(GArray *table_data, GArray *linker, build_hpet_aml(dsdt); build_piix4_pm(dsdt); build_piix4_isa_bridge(dsdt); - build_isa_devices_aml(dsdt); + build_isa_devices_aml(dsdt, pcms); build_piix4_pci_hotplug(dsdt); build_piix4_pci0_int(dsdt); } else { @@ -2039,7 +2057,7 @@ build_dsdt(GArray *table_data, GArray *linker, build_hpet_aml(dsdt); build_q35_isa_bridge(dsdt); - build_isa_devices_aml(dsdt); + build_isa_devices_aml(dsdt, pcms); build_q35_pci0_int(dsdt); } diff --git a/hw/stubs/Makefile.objs b/hw/stubs/Makefile.objs index 60047e6..f09ea33 100644 --- a/hw/stubs/Makefile.objs +++ b/hw/stubs/Makefile.objs @@ -1 +1,2 @@ stub-obj-$(CONFIG_SMBIOS) += smbios_type_38.o +stub-obj-$(CONFIG_ACPI) += acpi_ipmi.o \ No newline at end of file diff --git a/hw/stubs/acpi_ipmi.c b/hw/stubs/acpi_ipmi.c new file mode 100644 index 0000000..e83fc19 --- /dev/null +++ b/hw/stubs/acpi_ipmi.c @@ -0,0 +1,14 @@ +/* + * IPMI ACPI firmware handling + * + * Copyright (c) 2015 Corey Minyard, MontaVista Software, LLC + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#include "hw/acpi/ipmi.h" + +void build_acpi_ipmi_devices(Aml *table, BusState *bus) +{ +} diff --git a/include/hw/acpi/ipmi.h b/include/hw/acpi/ipmi.h new file mode 100644 index 0000000..ca5043a --- /dev/null +++ b/include/hw/acpi/ipmi.h @@ -0,0 +1,22 @@ +/* + * QEMU IPMI ACPI handling + * + * Copyright (c) 2015 Corey Minyard + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ +#ifndef HW_ACPI_IPMI_H +#define HW_ACPI_IPMI_H + +#include "qemu/osdep.h" +#include "hw/acpi/aml-build.h" + +/* + * Add ACPI IPMI entries for all registered IPMI devices whose parent + * bus matches the given bus. The resource is the ACPI resource that + * contains the IPMI device, this is required for the I2C CRS. + */ +void build_acpi_ipmi_devices(Aml *table, BusState *bus); + +#endif /* HW_ACPI_IPMI_H */