[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 16/17] ipmi: Add ACPI table entries
From: |
Michael S. Tsirkin |
Subject: |
Re: [Qemu-devel] [PATCH 16/17] ipmi: Add ACPI table entries |
Date: |
Sun, 26 Apr 2015 10:36:14 +0200 |
On Thu, Apr 23, 2015 at 05:57:57PM -0500, address@hidden wrote:
> From: Corey Minyard <address@hidden>
>
> Use the new ACPI table construction tools to create an ACPI
> entry for IPMI.
>
> Signed-off-by: Corey Minyard <address@hidden>
Acked-by: Michael S. Tsirkin <address@hidden>
> ---
> hw/ipmi/Makefile.objs | 1 +
> hw/ipmi/ipmi_acpi.c | 122
> ++++++++++++++++++++++++++++++++++++++++++++++++++
> hw/ipmi/isa_ipmi.c | 4 ++
> 3 files changed, 127 insertions(+)
> create mode 100644 hw/ipmi/ipmi_acpi.c
>
> diff --git a/hw/ipmi/Makefile.objs b/hw/ipmi/Makefile.objs
> index d0129cf..17ca09f 100644
> --- a/hw/ipmi/Makefile.objs
> +++ b/hw/ipmi/Makefile.objs
> @@ -5,3 +5,4 @@ common-obj-$(CONFIG_IPMI_BT) += ipmi_bt.o
> common-obj-$(CONFIG_IPMI_LOCAL) += ipmi_sim.o
> common-obj-$(CONFIG_IPMI_EXTERN) += ipmi_extern.o
> common-obj-$(call land,$(CONFIG_IPMI),$(CONFIG_SMBIOS)) += ipmi_smbios.o
> +common-obj-$(call land,$(CONFIG_IPMI),$(CONFIG_ACPI)) += ipmi_acpi.o
> diff --git a/hw/ipmi/ipmi_acpi.c b/hw/ipmi/ipmi_acpi.c
> new file mode 100644
> index 0000000..e014da7
> --- /dev/null
> +++ b/hw/ipmi/ipmi_acpi.c
> @@ -0,0 +1,122 @@
> +/*
> + * IPMI ACPI firmware handling
> + *
> + * Copyright (c) 2015 Corey Minyard, MontaVista Software, LLC
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a
> copy
> + * of this software and associated documentation files (the "Software"), to
> deal
> + * in the Software without restriction, including without limitation the
> rights
> + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> + * copies of the Software, and to permit persons to whom the Software is
> + * furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice shall be included in
> + * all copies or substantial portions of the Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> FROM,
> + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
> + * THE SOFTWARE.
> + */
> +
> +#include "ipmi.h"
> +#include "hw/acpi/aml-build.h"
> +#include "hw/acpi/acpi.h"
> +#include "hw/acpi/acpi-dev-tables.h"
> +#include <qemu/error-report.h>
> +
> +static Aml *aml_ipmi_crs(IPMIFwInfo *info)
> +{
> + Aml *crs = aml_resource_template();
> + uint8_t regspacing = info->register_spacing;
> +
> + if (regspacing == 1) {
> + regspacing = 0;
> + }
> +
> + 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_ReadWrite,
> + 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_ReadWrite,
> + 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;
> + }
> +
> + if (info->interrupt_number) {
> + aml_append(crs, aml_irq_no_flags(info->interrupt_number));
> + }
> +
> + return crs;
> +}
> +
> +static void
> +ipmi_encode_one_acpi(IPMIFwInfo *info, void *opaque)
> +{
> + Aml *ssdt, *scope, *dev, *method;
> + char *name;
> + int version = ((info->ipmi_spec_major_revision << 8)
> + | (info->ipmi_spec_minor_revision << 4));
> +
> + if (!info->acpi_parent) {
> + ipmi_debug("device %s not compatible with ACPI, no parent given.",
> + info->interface_name);
> + return;
> + }
> +
> + ssdt = init_aml_allocator();
> +
> + scope = aml_scope("%s", info->acpi_parent);
> + name = g_strdup_printf("ipmi_%s", info->interface_name);
> +
> + dev = aml_device("MI0");
> + aml_append(dev, aml_name_decl("_HID", aml_eisaid("IPI0001")));
> + aml_append(dev, aml_name_decl("_STR", aml_string("%s", name)));
> + aml_append(dev, aml_name_decl("_UID", aml_int(0)));
> + aml_append(dev, aml_name_decl("_CRS", aml_ipmi_crs(info)));
> + method = aml_method("_IFT", 0);
> + aml_append(method, aml_return(aml_int(info->interface_type)));
> + aml_append(dev, method);
> + method = aml_method("_SRV", 0);
> + aml_append(method, aml_return(aml_int(version)));
> + aml_append(dev, method);
> +
> + aml_append(scope, dev);
> +
> + aml_append(ssdt, scope);
> +
> + add_acpi_dev_table(ssdt->buf->data, ssdt->buf->len, "SSDT", 1);
> + free_aml_allocator();
> +}
> +
> +static void ipmi_acpi_init(void)
> +{
> + ipmi_register_fwinfo_handler(ipmi_encode_one_acpi, NULL);
> +}
> +
> +type_init(ipmi_acpi_init);
> diff --git a/hw/ipmi/isa_ipmi.c b/hw/ipmi/isa_ipmi.c
> index da86247..ae6d3c8 100644
> --- a/hw/ipmi/isa_ipmi.c
> +++ b/hw/ipmi/isa_ipmi.c
> @@ -37,6 +37,8 @@ typedef struct ISAIPMIDevice {
> ISADevice dev;
> char *interface;
> uint32_t iobase;
> + uint32_t iolength;
> + uint8_t regspacing;
> int32 isairq;
> uint8_t slave_addr;
> CharDriverState *chr;
> @@ -73,12 +75,14 @@ static void ipmi_isa_realizefn(DeviceState *dev, Error
> **errp)
> intfk = IPMI_INTERFACE_GET_CLASS(intf);
> bmc->intf = intf;
> intf->bmc = bmc;
> + ipmi->regspacing = 1;
> intf->io_base = ipmi->iobase;
> intf->slave_addr = ipmi->slave_addr;
> ipmi_interface_init(intf, errp);
> if (*errp) {
> return;
> }
> + ipmi->iolength = intf->io_length;
> ipmi_bmc_init(bmc, errp);
> if (*errp) {
> return;
> --
> 1.8.3.1
>
- [Qemu-devel] [PATCH 07/17] ipmi: Add tests, (continued)
- [Qemu-devel] [PATCH 07/17] ipmi: Add tests, minyard, 2015/04/23
- [Qemu-devel] [PATCH 08/17] ipmi: Add documentation, minyard, 2015/04/23
- [Qemu-devel] [PATCH 09/17] ipmi: Add migration capability to the IPMI device., minyard, 2015/04/23
- [Qemu-devel] [PATCH 10/17] ipmi: Add a firmware configuration repository, minyard, 2015/04/23
- [Qemu-devel] [PATCH 12/17] smbios: Add a function to directly add an entry, minyard, 2015/04/23
- [Qemu-devel] [PATCH 13/17] pc: Postpone SMBIOS table installation to post machine init, minyard, 2015/04/23
- [Qemu-devel] [PATCH 14/17] ipmi: Add SMBIOS table entry, minyard, 2015/04/23
- [Qemu-devel] [PATCH 15/17] acpi: Add a way for devices to add ACPI tables, minyard, 2015/04/23
- [Qemu-devel] [PATCH 16/17] ipmi: Add ACPI table entries, minyard, 2015/04/23
- Re: [Qemu-devel] [PATCH 16/17] ipmi: Add ACPI table entries,
Michael S. Tsirkin <=
- [Qemu-devel] [PATCH 17/17] bios: Add tests for the IPMI ACPI and SMBIOS entries, minyard, 2015/04/23
- Re: [Qemu-devel] [PATCH 00/17] Update to adding an IPMI device to qemu, Eric Blake, 2015/04/23
- Re: [Qemu-devel] [PATCH 00/17] Update to adding an IPMI device to qemu, Paolo Bonzini, 2015/04/24