From: "Michael S. Tsirkin" <mst@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
Corey Minyard <cminyard@mvista.com>,
Igor Mammedov <imammedo@redhat.com>
Subject: [Qemu-devel] [PULL 02/34] ipmi: Add SMBIOS table entry
Date: Fri, 24 Jun 2016 08:54:06 +0300 [thread overview]
Message-ID: <20160624085406-mutt-send-email-mst@redhat.com> (raw)
In-Reply-To: <1466747621-4342-1-git-send-email-mst@redhat.com>
From: Corey Minyard <cminyard@mvista.com>
Add an IPMI table entry to the SMBIOS.
Signed-off-by: Corey Minyard <cminyard@mvista.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
include/hw/smbios/ipmi.h | 15 ++++++
hw/smbios/smbios.c | 2 +
hw/smbios/smbios_type_38.c | 117 +++++++++++++++++++++++++++++++++++++++++++++
stubs/smbios_type_38.c | 14 ++++++
hw/smbios/Makefile.objs | 1 +
stubs/Makefile.objs | 1 +
6 files changed, 150 insertions(+)
create mode 100644 include/hw/smbios/ipmi.h
create mode 100644 hw/smbios/smbios_type_38.c
create mode 100644 stubs/smbios_type_38.c
diff --git a/include/hw/smbios/ipmi.h b/include/hw/smbios/ipmi.h
new file mode 100644
index 0000000..1c9aae3
--- /dev/null
+++ b/include/hw/smbios/ipmi.h
@@ -0,0 +1,15 @@
+/*
+ * IPMI SMBIOS firmware handling
+ *
+ * Copyright (c) 2015,2016 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.
+ */
+
+#ifndef QEMU_SMBIOS_IPMI_H
+#define QEMU_SMBIOS_IPMI_H
+
+void smbios_build_type_38_table(void);
+
+#endif /* QEMU_SMBIOS_IPMI_H */
diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c
index 5dc3e43..74c7102 100644
--- a/hw/smbios/smbios.c
+++ b/hw/smbios/smbios.c
@@ -25,6 +25,7 @@
#include "hw/loader.h"
#include "exec/cpu-common.h"
#include "smbios_build.h"
+#include "hw/smbios/ipmi.h"
/* legacy structures and constants for <= 2.0 machines */
struct smbios_header {
@@ -848,6 +849,7 @@ void smbios_get_tables(const struct smbios_phys_mem_area *mem_array,
}
smbios_build_type_32_table();
+ smbios_build_type_38_table();
smbios_build_type_127_table();
smbios_validate_table();
diff --git a/hw/smbios/smbios_type_38.c b/hw/smbios/smbios_type_38.c
new file mode 100644
index 0000000..56e8609
--- /dev/null
+++ b/hw/smbios/smbios_type_38.c
@@ -0,0 +1,117 @@
+/*
+ * IPMI SMBIOS firmware handling
+ *
+ * Copyright (c) 2015,2016 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/smbios/ipmi.h"
+#include "hw/smbios/smbios.h"
+#include "qemu/error-report.h"
+#include "smbios_build.h"
+
+/* SMBIOS type 38 - IPMI */
+struct smbios_type_38 {
+ struct smbios_structure_header header;
+ uint8_t interface_type;
+ uint8_t ipmi_spec_revision;
+ uint8_t i2c_slave_address;
+ uint8_t nv_storage_device_address;
+ uint64_t base_address;
+ uint8_t base_address_modifier;
+ uint8_t interrupt_number;
+} QEMU_PACKED;
+
+static void smbios_build_one_type_38(IPMIFwInfo *info)
+{
+ uint64_t baseaddr = info->base_address;
+ SMBIOS_BUILD_TABLE_PRE(38, 0x3000, true);
+
+ t->interface_type = info->interface_type;
+ t->ipmi_spec_revision = ((info->ipmi_spec_major_revision << 4)
+ | info->ipmi_spec_minor_revision);
+ t->i2c_slave_address = info->i2c_slave_address;
+ t->nv_storage_device_address = 0;
+
+ assert(info->ipmi_spec_minor_revision <= 15);
+ assert(info->ipmi_spec_major_revision <= 15);
+
+ /* or 1 to set it to I/O space */
+ switch (info->memspace) {
+ case IPMI_MEMSPACE_IO:
+ baseaddr |= 1;
+ break;
+ case IPMI_MEMSPACE_MEM32:
+ case IPMI_MEMSPACE_MEM64:
+ break;
+ case IPMI_MEMSPACE_SMBUS:
+ baseaddr <<= 1;
+ break;
+ }
+
+ t->base_address = cpu_to_le64(baseaddr);
+
+ t->base_address_modifier = 0;
+ if (info->irq_type == IPMI_LEVEL_IRQ) {
+ t->base_address_modifier |= 1;
+ }
+ switch (info->register_spacing) {
+ case 1:
+ break;
+ case 4:
+ t->base_address_modifier |= 1 << 6;
+ break;
+ case 16:
+ t->base_address_modifier |= 2 << 6;
+ break;
+ default:
+ error_report("IPMI register spacing %d is not compatible with"
+ " SMBIOS, ignoring this entry.", info->register_spacing);
+ return;
+ }
+ t->interrupt_number = info->interrupt_number;
+
+ SMBIOS_BUILD_TABLE_POST;
+}
+
+static void smbios_add_ipmi_devices(BusState *bus)
+{
+ BusChild *kid;
+
+ QTAILQ_FOREACH(kid, &bus->children, sibling) {
+ DeviceState *dev = kid->child;
+ Object *obj = object_dynamic_cast(OBJECT(dev), TYPE_IPMI_INTERFACE);
+ BusState *childbus;
+
+ if (obj) {
+ IPMIInterface *ii;
+ IPMIInterfaceClass *iic;
+ IPMIFwInfo info;
+
+ ii = IPMI_INTERFACE(obj);
+ iic = IPMI_INTERFACE_GET_CLASS(obj);
+ memset(&info, 0, sizeof(info));
+ iic->get_fwinfo(ii, &info);
+ smbios_build_one_type_38(&info);
+ continue;
+ }
+
+ QLIST_FOREACH(childbus, &dev->child_bus, sibling) {
+ smbios_add_ipmi_devices(childbus);
+ }
+ }
+}
+
+void smbios_build_type_38_table(void)
+{
+ BusState *bus;
+
+ bus = sysbus_get_default();
+ if (bus) {
+ smbios_add_ipmi_devices(bus);
+ }
+}
diff --git a/stubs/smbios_type_38.c b/stubs/smbios_type_38.c
new file mode 100644
index 0000000..9528c2c
--- /dev/null
+++ b/stubs/smbios_type_38.c
@@ -0,0 +1,14 @@
+/*
+ * IPMI SMBIOS firmware handling
+ *
+ * Copyright (c) 2015,2016 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/smbios/ipmi.h"
+
+void smbios_build_type_38_table(void)
+{
+}
diff --git a/hw/smbios/Makefile.objs b/hw/smbios/Makefile.objs
index f69a92f..c3d3753 100644
--- a/hw/smbios/Makefile.objs
+++ b/hw/smbios/Makefile.objs
@@ -1 +1,2 @@
common-obj-$(CONFIG_SMBIOS) += smbios.o
+common-obj-$(call land,$(CONFIG_SMBIOS),$(CONFIG_IPMI)) += smbios_type_38.o
diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs
index 4b258a6..b21cd5f 100644
--- a/stubs/Makefile.objs
+++ b/stubs/Makefile.objs
@@ -41,3 +41,4 @@ stub-obj-y += target-monitor-defs.o
stub-obj-y += target-get-monitor-def.o
stub-obj-y += vhost.o
stub-obj-y += iohandler.o
+stub-obj-y += smbios_type_38.o
--
MST
next prev parent reply other threads:[~2016-06-24 5:54 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1466747621-4342-1-git-send-email-mst@redhat.com>
2016-06-24 5:54 ` [Qemu-devel] [PULL 01/34] smbios: Move table build tools into an include file Michael S. Tsirkin
2016-06-24 5:54 ` Michael S. Tsirkin [this message]
2016-06-24 5:54 ` [Qemu-devel] [PULL 03/34] acpi: Add IPMI table entries Michael S. Tsirkin
2016-06-24 5:54 ` [Qemu-devel] [PULL 04/34] bios: Add tests for the IPMI ACPI and SMBIOS entries Michael S. Tsirkin
2016-06-24 5:54 ` [Qemu-devel] [PULL 05/34] pc-dimm: introduce get_vmstate_memory_region callback Michael S. Tsirkin
2016-06-24 5:54 ` [Qemu-devel] [PULL 06/34] nvdimm: support nvdimm label Michael S. Tsirkin
2016-06-24 5:54 ` [Qemu-devel] [PULL 07/34] acpi: add aml_object_type Michael S. Tsirkin
2016-06-24 5:54 ` [Qemu-devel] [PULL 08/34] acpi: add aml_call5 Michael S. Tsirkin
2016-06-24 5:54 ` [Qemu-devel] [PULL 09/34] nvdimm acpi: set HDLE properly Michael S. Tsirkin
2016-06-24 5:54 ` [Qemu-devel] [PULL 10/34] nvdimm acpi: save arg3 of _DSM method Michael S. Tsirkin
2016-06-24 5:54 ` [Qemu-devel] [PULL 11/34] nvdimm acpi: check UUID Michael S. Tsirkin
2016-06-24 5:54 ` [Qemu-devel] [PULL 12/34] nvdimm acpi: abstract the operations for root & nvdimm devices Michael S. Tsirkin
2016-06-24 5:54 ` [Qemu-devel] [PULL 13/34] nvdimm acpi: check revision Michael S. Tsirkin
2016-06-24 5:54 ` [Qemu-devel] [PULL 14/34] nvdimm acpi: support Get Namespace Label Size function Michael S. Tsirkin
2016-06-24 5:54 ` [Qemu-devel] [PULL 15/34] nvdimm acpi: support Get Namespace Label Data function Michael S. Tsirkin
2016-06-24 5:54 ` [Qemu-devel] [PULL 16/34] nvdimm acpi: support Set " Michael S. Tsirkin
2016-06-24 5:55 ` [Qemu-devel] [PULL 17/34] docs: add NVDIMM ACPI documentation Michael S. Tsirkin
2016-06-24 5:55 ` [Qemu-devel] [PULL 18/34] i386: pci-assign: Fix MSI-X table size Michael S. Tsirkin
2016-06-24 5:55 ` [Qemu-devel] [PULL 19/34] docs: update ACPI CPU hotplug spec with new protocol Michael S. Tsirkin
2016-06-24 5:55 ` [Qemu-devel] [PULL 20/34] pc: piix4/ich9: add 'cpu-hotplug-legacy' property Michael S. Tsirkin
2016-06-24 5:55 ` [Qemu-devel] [PULL 21/34] acpi: cpuhp: add CPU devices AML with _STA method Michael S. Tsirkin
2016-06-24 5:55 ` [Qemu-devel] [PULL 22/34] pc: acpi: introduce AcpiDeviceIfClass.madt_cpu hook Michael S. Tsirkin
2016-06-24 5:55 ` [Qemu-devel] [PULL 23/34] acpi: cpuhp: implement hot-add parts of CPU hotplug interface Michael S. Tsirkin
2016-06-24 5:55 ` [Qemu-devel] [PULL 24/34] acpi: cpuhp: implement hot-remove " Michael S. Tsirkin
2016-06-24 5:55 ` [Qemu-devel] [PULL 25/34] acpi: cpuhp: add cpu._OST handling Michael S. Tsirkin
2016-06-24 5:55 ` [Qemu-devel] [PULL 26/34] pc: use new CPU hotplug interface since 2.7 machine type Michael S. Tsirkin
2016-06-24 5:55 ` [Qemu-devel] [PULL 27/34] acpi-test-data: update expected Michael S. Tsirkin
2016-06-24 5:55 ` [Qemu-devel] [PULL 28/34] pc: acpi: drop intermediate PCMachineState.node_cpu Michael S. Tsirkin
2016-06-24 5:55 ` [Qemu-devel] [PULL 29/34] virtio-bus: common ioeventfd infrastructure Michael S. Tsirkin
2016-06-24 5:55 ` [Qemu-devel] [PULL 30/34] virtio-bus: have callers tolerate new host notifier api Michael S. Tsirkin
2016-06-29 11:37 ` Marc-André Lureau
2016-06-29 11:48 ` Cornelia Huck
2016-06-24 5:55 ` [Qemu-devel] [PULL 31/34] virtio-ccw: convert to ioeventfd callbacks Michael S. Tsirkin
2016-06-24 5:55 ` [Qemu-devel] [PULL 32/34] virtio-pci: " Michael S. Tsirkin
2016-06-24 5:56 ` [Qemu-devel] [PULL 33/34] virtio-mmio: " Michael S. Tsirkin
2016-06-24 5:56 ` [Qemu-devel] [PULL 34/34] virtio-bus: remove old set_host_notifier callback Michael S. Tsirkin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160624085406-mutt-send-email-mst@redhat.com \
--to=mst@redhat.com \
--cc=cminyard@mvista.com \
--cc=imammedo@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).