[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v5 14/16] acpi: Add IPMI table entries
From: |
minyard |
Subject: |
[Qemu-devel] [PATCH v5 14/16] acpi: Add IPMI table entries |
Date: |
Thu, 17 Dec 2015 12:50:17 -0600 |
From: Corey Minyard <address@hidden>
Use the new ACPI table construction tools to create an ACPI
entry for IPMI. This adds a function called from build_ssdt
to add an SSDT 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 <address@hidden>
---
hw/acpi/Makefile.objs | 2 +
hw/acpi/ipmi.c | 116 +++++++++++++++++++++++++++++++++++++++++++++++++
hw/acpi/noipmi.c | 14 ++++++
hw/i386/acpi-build.c | 4 ++
include/hw/acpi/ipmi.h | 16 +++++++
5 files changed, 152 insertions(+)
create mode 100644 hw/acpi/ipmi.c
create mode 100644 hw/acpi/noipmi.c
create mode 100644 include/hw/acpi/ipmi.h
diff --git a/hw/acpi/Makefile.objs b/hw/acpi/Makefile.objs
index 7d3230c..f35ecfc 100644
--- a/hw/acpi/Makefile.objs
+++ b/hw/acpi/Makefile.objs
@@ -5,3 +5,5 @@ common-obj-$(CONFIG_ACPI_MEMORY_HOTPLUG) += memory_hotplug.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..eacaa93
--- /dev/null
+++ b/hw/acpi/ipmi.c
@@ -0,0 +1,116 @@
+/*
+ * 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/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 *ssdt, 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(ssdt, scope);
+}
+
+void acpi_add_ipmi(Aml *ssdt)
+{
+ IPMIFwInfo *info = ipmi_first_fwinfo();
+
+ while (info) {
+ ipmi_encode_one_acpi(ssdt, 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 fa866f6..81081a4 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
@@ -1346,6 +1348,8 @@ build_ssdt(GArray *table_data, GArray *linker,
aml_append(ssdt, sb_scope);
}
+ acpi_add_ipmi(ssdt);
+
/* copy AML table into ACPI tables blob and patch header there */
g_array_append_vals(table_data, ssdt->buf->data, ssdt->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..313ce37
--- /dev/null
+++ b/include/hw/acpi/ipmi.h
@@ -0,0 +1,16 @@
+/*
+ * QEMU IPMI ACPI handling
+ *
+ * Copyright (c) 2015 Corey Minyard <address@hidden>
+ *
+ * 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 "hw/acpi/aml-build.h"
+
+void acpi_add_ipmi(Aml *ssdt);
+
+#endif /* HW_ACPI_IPMI_H */
--
2.5.0
- [Qemu-devel] [PATCH v5 10/16] ipmi: Add firmware registration to the ISA interface, (continued)
- [Qemu-devel] [PATCH v5 10/16] ipmi: Add firmware registration to the ISA interface, minyard, 2015/12/17
- [Qemu-devel] [PATCH v5 08/16] ipmi: Add migration capability to the IPMI devices., minyard, 2015/12/17
- [Qemu-devel] [PATCH v5 05/16] ipmi: Add a BT low-level interface, minyard, 2015/12/17
- [Qemu-devel] [PATCH v5 06/16] ipmi: Add tests, minyard, 2015/12/17
- [Qemu-devel] [PATCH v5 04/16] ipmi: Add an ISA KCS low-level interface, minyard, 2015/12/17
- [Qemu-devel] [PATCH v5 13/16] ipmi: Add SMBIOS table entry, minyard, 2015/12/17
- [Qemu-devel] [PATCH v5 03/16] ipmi: Add an external connection simulation interface, minyard, 2015/12/17
- [Qemu-devel] [PATCH v5 12/16] pc: Postpone SMBIOS table installation to post machine init, minyard, 2015/12/17
- [Qemu-devel] [PATCH v5 11/16] smbios: Move table build tools into an include file., minyard, 2015/12/17
- [Qemu-devel] [PATCH v5 15/16] bios: Add tests for the IPMI ACPI and SMBIOS entries, minyard, 2015/12/17
- [Qemu-devel] [PATCH v5 14/16] acpi: Add IPMI table entries,
minyard <=
- [Qemu-devel] [PATCH v5 01/16] Add a base IPMI interface, minyard, 2015/12/17
- [Qemu-devel] [PATCH v5 16/16] ipmi: Add a force off function, minyard, 2015/12/17
- [Qemu-devel] [PATCH v5 02/16] ipmi: Add a local BMC simulation, minyard, 2015/12/17