From patchwork Wed May 11 16:38:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 67614 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp322115qge; Wed, 11 May 2016 09:45:41 -0700 (PDT) X-Received: by 10.140.28.8 with SMTP id 8mr4471160qgy.91.1462984810785; Wed, 11 May 2016 09:40:10 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id n126si5726507qkf.201.2016.05.11.09.40.10 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 11 May 2016 09:40:10 -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]:53200 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b0XBA-00067b-1I for patch@linaro.org; Wed, 11 May 2016 12:40:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48948) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b0XAF-0004q9-OU for qemu-devel@nongnu.org; Wed, 11 May 2016 12:39:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b0XA8-0002Bf-Go for qemu-devel@nongnu.org; Wed, 11 May 2016 12:39:10 -0400 Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]:34044) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b0XA8-0002Ba-6U for qemu-devel@nongnu.org; Wed, 11 May 2016 12:39:04 -0400 Received: by mail-pf0-x241.google.com with SMTP id 145so4156066pfz.1 for ; Wed, 11 May 2016 09:39:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=fSlEhx6HvDRnM3gg9IpBlIwAL92mBpqRjwU0lGNxU9I=; b=1Fh5F7Yfckv7mYexM/6+DJEI7f6AwVvyICB/XbGJ2kR4I/adlwoiiJ3wKXcOY2UIZo R6Z+iyr69WF2cNjtBXq3pMsmOLsxBFidvFIXy99Ts9cZuTN/GNxuC7KpB2NENn6MWdR/ 1gbylJsVyYH56WvETuL8Q11gktJmQaTHCrjTGta6AcDPxZLE45KhBrGnUo90E6GNrYHb E5imoS6lIwo1FZ+KrO2nf74Dv0hNWxEgTGlzBl1cOldg9I7OE8zRDIJfYjHbSDjuzx3c ecpOv7qP4JxRkb0iVRs9SlzhXrwYH0dzHt5iR7X67icTpIxI5XZA5pZFShP7QdWPYVcd AsLQ== 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:cc:subject:date:message-id :in-reply-to:references; bh=fSlEhx6HvDRnM3gg9IpBlIwAL92mBpqRjwU0lGNxU9I=; b=KanxdX48wsWuSXJvixnK576sQAY0vtw8osEcDKi9+gDcVoBGBfeos5dfFSuRyvigSa WmL/hLPjB6N3yLKDi6o9jSryouAIJyCCAdFwlP7GtSU7GbSn0n5yliAiGPn/wIKBB8N2 bO1FLAODDxOiRGMJOmWhgl1Gu59QqUBDagbP9SHjrdmZdkFuHBjy3GX8G94soUNBOfHA ylkylsg4NcBF2h9MIj4brC9cdh9uXqhWpaoMFB7Crrwa4At8XXNCOd5pmhZIR3KkRFEQ 7jB8rr+pVahIKEfvIW7SuFyIm3kqV+cpq0nZoKCnevlq6AXiV6rKaqGRf7wNURFNWNPS csaw== X-Gm-Message-State: AOPr4FXW0BcWnmsZbZ9PxK3Mq5nLMqI/PL43/XR7/pPKFDEkDaBoBV+KYzf3IWnP1UydTw== X-Received: by 10.98.30.132 with SMTP id e126mr6432441pfe.109.1462984743546; Wed, 11 May 2016 09:39:03 -0700 (PDT) Received: from serve.minyard.net ([108.19.215.157]) by smtp.gmail.com with ESMTPSA id e184sm13418260pfe.14.2016.05.11.09.39.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 May 2016 09:39:02 -0700 (PDT) Received: from t430.minyard.net (unknown [IPv6:2001:470:b8f6:1b:a430:dab6:589a:a3a1]) by serve.minyard.net (Postfix) with ESMTPA id 651E91C9D; Wed, 11 May 2016 11:38:58 -0500 (CDT) Received: by t430.minyard.net (Postfix, from userid 1000) id 91D6930054A; Wed, 11 May 2016 11:38:56 -0500 (CDT) From: minyard@acm.org To: Igor Mammedov , "Michael S . Tsirkin" , Paolo Bonzini , qemu-devel@nongnu.org, minyard@acm.org Date: Wed, 11 May 2016 11:38:53 -0500 Message-Id: <1462984734-23803-5-git-send-email-minyard@acm.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1462984734-23803-1-git-send-email-minyard@acm.org> References: <1462984734-23803-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::241 Subject: [Qemu-devel] [PATCH v2 4/5] 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: , Cc: Corey Minyard 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 | 117 +++++++++++++++++++++++++++++++++++++++++++++++++ hw/acpi/noipmi.c | 14 ++++++ hw/i386/acpi-build.c | 4 ++ include/hw/acpi/ipmi.h | 17 +++++++ 5 files changed, 154 insertions(+) create mode 100644 hw/acpi/ipmi.c create mode 100644 hw/acpi/noipmi.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..b8d5c84 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 +common-obj-$(call land,$(CONFIG_ACPI),$(call lnot,$(CONFIG_IPMI))) += noipmi.o diff --git a/hw/acpi/ipmi.c b/hw/acpi/ipmi.c new file mode 100644 index 0000000..731f4ad --- /dev/null +++ b/hw/acpi/ipmi.c @@ -0,0 +1,117 @@ +/* + * 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 void +ipmi_encode_one_acpi(Aml *table, IPMIFwInfo *info) +{ + Aml *scope, *dev, *method; + uint16_t version = ((info->ipmi_spec_major_revision << 8) + | (info->ipmi_spec_minor_revision << 4)); + + /* + * The ACPI parent is a little bit of a pain. It could be in + * different places depending on the device. It could be an SMBus, + * it could be ISA, it could be PCI, etc. Only the device really + * knows, so it has to pass it in. + */ + if (!info->acpi_parent) { + ipmi_debug("device %s not compatible with ACPI, no parent given.", + info->interface_name); + return; + } + + scope = aml_scope("%s", info->acpi_parent); + + dev = aml_device("MI0"); + 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))); + + /* + * The spec seems to require these to be methods. All the examples + * show them this way and it doesn't seem to work if they are not. + */ + method = aml_method("_IFT", 0, AML_NOTSERIALIZED); + aml_append(method, aml_return(aml_int(info->interface_type))); + aml_append(dev, method); + method = aml_method("_SRV", 0, AML_NOTSERIALIZED); + aml_append(method, aml_return(aml_int(version))); + aml_append(dev, method); + + aml_append(scope, dev); + + aml_append(table, scope); +} + +void acpi_add_ipmi(Aml *table) +{ + IPMIFwInfo *info = ipmi_first_fwinfo(); + + while (info) { + ipmi_encode_one_acpi(table, info); + info = ipmi_next_fwinfo(info); + } +} diff --git a/hw/acpi/noipmi.c b/hw/acpi/noipmi.c new file mode 100644 index 0000000..4aae336 --- /dev/null +++ b/hw/acpi/noipmi.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 acpi_add_ipmi(Aml *ssdt) +{ +} diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 6477003..2294e7b 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 @@ -2364,6 +2366,8 @@ build_dsdt(GArray *table_data, GArray *linker, aml_append(dsdt, sb_scope); } + acpi_add_ipmi(dsdt); + /* copy AML table into ACPI tables blob and patch header there */ g_array_append_vals(table_data, dsdt->buf->data, dsdt->buf->len); build_header(linker, table_data, diff --git a/include/hw/acpi/ipmi.h b/include/hw/acpi/ipmi.h new file mode 100644 index 0000000..4f11a28 --- /dev/null +++ b/include/hw/acpi/ipmi.h @@ -0,0 +1,17 @@ +/* + * 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" + +void acpi_add_ipmi(Aml *ssdt); + +#endif /* HW_ACPI_IPMI_H */