From patchwork Fri May 13 13:07:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 67782 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp259025qge; Fri, 13 May 2016 06:08:37 -0700 (PDT) X-Received: by 10.55.71.76 with SMTP id u73mr15451619qka.6.1463144917071; Fri, 13 May 2016 06:08:37 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id a76si7377224qhb.55.2016.05.13.06.08.36 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 13 May 2016 06:08:37 -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]:34466 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b1CpY-0004I6-Fr for patch@linaro.org; Fri, 13 May 2016 09:08:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46355) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b1CoV-0002xp-Id for qemu-devel@nongnu.org; Fri, 13 May 2016 09:07:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b1CoO-0006Zh-8V for qemu-devel@nongnu.org; Fri, 13 May 2016 09:07:30 -0400 Received: from mail-oi0-x233.google.com ([2607:f8b0:4003:c06::233]:34232) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b1CoO-0006ZP-23 for qemu-devel@nongnu.org; Fri, 13 May 2016 09:07:24 -0400 Received: by mail-oi0-x233.google.com with SMTP id k142so169418585oib.1 for ; Fri, 13 May 2016 06:07:24 -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=GFBM1rRiDkWxaUFZ07ej6O+DuFUXgYxRSIAkBA+Ax44=; b=c/e0+LGCquORl2yZO2EFFUFHl46hDaVWmo2s1cMLy8LhxF2jXGhohmQbtd/VwY5Rwn pQ0kxUn2tjqbdJ/wlPOw5RY5H7E9x4VUYWVsVcaoeVRrLYYB9p/+GxYsYfU6A4/YBRmk xX2+HQRHXEraIIr/Xc/FFK684WMt3GQzcmuz7WAQpfLXmuOBJ+L7K1wyHfAqpbojYR/M WeUONdumxyXDdCO/DRl6w8lNx+NW6RivXsjn05fqLYsaVA/iQ6is9BoWTc47e8XmgSen uGyiYa9fmlIrFFYIRu50BvRe41Nk8v5JdJI5BiE0CnZcEGSobFXSjjKbfzXYO7w88Pzq cJqQ== 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=GFBM1rRiDkWxaUFZ07ej6O+DuFUXgYxRSIAkBA+Ax44=; b=TNYemRXG1YkN0DvKdkIL8JDHo4g9at31d07KpxxJmb07aAgPnK+5MqhF3DlHr4MHA0 Y6jrdY0ZT6f0ayY3ppYlksVcLlWBUumEBpucXmIubiy3BHBjAbUWrAJgQSzNa+zY/6/b n79KAZkkgVE5oLCB9aZVxuZmp5rmXUYMd4g5ge0bJk94G1J/3FBdRU2imAVcxyCOaxjb 3c1Dk0SCCSZ4zk7CgX/tVASKdJjoY4fU/rAoVjmcBuvlrpbeyzu6wYNUqZxn0cVrrcrA w66rmvo7zVXVxODMJfs23654PqRGtXOaB2dlBxFDgFGqwcsjkNGOHxiOwnmVWyqil0D6 i4Mg== X-Gm-Message-State: AOPr4FU7rJUrbrXYttstyExdsG7qevgG17O6ciQ1aOS+Z2uAaasejnI6O6Vh0tfWzt/VVA== X-Received: by 10.202.189.10 with SMTP id n10mr7868434oif.101.1463144843729; Fri, 13 May 2016 06:07:23 -0700 (PDT) Received: from serve.minyard.net ([108.19.215.157]) by smtp.gmail.com with ESMTPSA id aq9sm5349745obc.12.2016.05.13.06.07.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 May 2016 06:07:22 -0700 (PDT) Received: from t430.minyard.net (t430m.minyard.net [192.168.27.3]) by serve.minyard.net (Postfix) with ESMTPA id C44FFDC1; Fri, 13 May 2016 08:07:20 -0500 (CDT) Received: by t430.minyard.net (Postfix, from userid 1000) id BE98330054D; Fri, 13 May 2016 08:07:18 -0500 (CDT) From: minyard@acm.org To: Igor Mammedov , "Michael S . Tsirkin" , Paolo Bonzini , qemu-devel@nongnu.org Date: Fri, 13 May 2016 08:07:10 -0500 Message-Id: <1463144831-4502-6-git-send-email-minyard@acm.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1463144831-4502-1-git-send-email-minyard@acm.org> References: <1463144831-4502-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:4003:c06::233 Subject: [Qemu-devel] [PATCH v3 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: , 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 | 102 +++++++++++++++++++++++++++++++++++++++++++++++++ hw/acpi/noipmi.c | 14 +++++++ hw/i386/acpi-build.c | 10 +++-- hw/i386/pc_piix.c | 1 + hw/i386/pc_q35.c | 1 + include/hw/acpi/ipmi.h | 22 +++++++++++ include/hw/i386/pc.h | 1 + 8 files changed, 150 insertions(+), 3 deletions(-) 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..87be6c7 --- /dev/null +++ b/hw/acpi/ipmi.c @@ -0,0 +1,102 @@ +/* + * 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, const char *scope) +{ + 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, + const char *resource) +{ + Aml *dev, *method; + uint16_t version = ((info->ipmi_spec_major_revision << 8) + | (info->ipmi_spec_minor_revision << 4)); + + 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, resource))); + + /* + * 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(table, dev); +} + +void acpi_add_ipmi(Aml *table, BusState *bus, const char *resource) +{ + IPMIFwInfo *info = ipmi_first_fwinfo(); + + while (info) { + if (qdev_get_parent_bus(info->dev) == bus) + ipmi_encode_one_acpi(table, info, resource); + info = ipmi_next_fwinfo(info); + } +} diff --git a/hw/acpi/noipmi.c b/hw/acpi/noipmi.c new file mode 100644 index 0000000..dd7590d --- /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 *table, BusState *bus, const char *resource) +{ +} diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 6477003..375a94b 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,7 @@ static Aml *build_com_device_aml(uint8_t uid) return dev; } -static void build_isa_devices_aml(Aml *table) +static void build_isa_devices_aml(Aml *table, ISABus *isa_bus) { ISADevice *fdc = pc_find_fdc0(); @@ -1461,6 +1463,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)); + acpi_add_ipmi(scope, BUS(isa_bus), "\\_SB.PCI0.ISA"); + aml_append(table, scope); } @@ -2011,7 +2015,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->isa_bus); build_piix4_pci_hotplug(dsdt); build_piix4_pci0_int(dsdt); } else { @@ -2039,7 +2043,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->isa_bus); build_q35_pci0_int(dsdt); } diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 7f50116..2e5ff45 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -185,6 +185,7 @@ static void pc_init1(MachineState *machine, &error_abort); no_hpet = 1; } + pcms->isa_bus = isa_bus; isa_bus_irqs(isa_bus, gsi); if (kvm_pic_in_kernel()) { diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index 04aae89..027655b 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -190,6 +190,7 @@ static void pc_q35_init(MachineState *machine) ICH9_LPC_NB_PIRQS); pci_bus_set_route_irq_fn(host_bus, ich9_route_intx_pin_to_irq); isa_bus = ich9_lpc->isa_bus; + pcms->isa_bus = isa_bus; /*end early*/ isa_bus_irqs(isa_bus, gsi); diff --git a/include/hw/acpi/ipmi.h b/include/hw/acpi/ipmi.h new file mode 100644 index 0000000..67d6e2f --- /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 acpi_add_ipmi(Aml *table, BusState *bus, const char *resource); + +#endif /* HW_ACPI_IPMI_H */ diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 96f0b66..aa8bc97 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -51,6 +51,7 @@ struct PCMachineState { HotplugHandler *acpi_dev; ISADevice *rtc; PCIBus *bus; + ISABus *isa_bus; FWCfgState *fw_cfg; /* Configuration options: */