All of lore.kernel.org
 help / color / mirror / Atom feed
From: minyard@acm.org
To: qemu-devel@nongnu.org
Cc: Corey Minyard <cminyard@mvista.com>
Subject: [Qemu-devel] [PATCH 12/15] ipmi: Add SMBIOS table entry
Date: Tue,  7 Apr 2015 14:51:41 -0500	[thread overview]
Message-ID: <1428436304-24044-13-git-send-email-minyard@acm.org> (raw)
In-Reply-To: <1428436304-24044-1-git-send-email-minyard@acm.org>

From: Corey Minyard <cminyard@mvista.com>

Add an IPMI table entry to the SMBIOS.

Signed-off-by: Corey Minyard <cminyard@mvista.com>
---
 hw/ipmi/isa_ipmi.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)

diff --git a/hw/ipmi/isa_ipmi.c b/hw/ipmi/isa_ipmi.c
index e62f744..ff379ce 100644
--- a/hw/ipmi/isa_ipmi.c
+++ b/hw/ipmi/isa_ipmi.c
@@ -27,6 +27,7 @@
 #include "qemu/timer.h"
 #include "sysemu/char.h"
 #include "sysemu/sysemu.h"
+#include "hw/i386/smbios.h"
 #include "ipmi.h"
 
 /* This is the type the user specifies on the -device command line */
@@ -36,13 +37,52 @@
 typedef struct ISAIPMIDevice {
     ISADevice dev;
     char *interface;
+    int intftype;
     uint32_t iobase;
     int32 isairq;
     uint8_t slave_addr;
+    uint8_t version;
     CharDriverState *chr;
     IPMIInterface *intf;
 } ISAIPMIDevice;
 
+#ifdef TARGET_I386
+/* 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 ipmi_encode_smbios(void *opaque)
+{
+    ISAIPMIDevice *info = opaque;
+    struct smbios_type_38 smb38;
+
+    smb38.header.type = 38;
+    smb38.header.length = sizeof(smb38);
+    smb38.header.handle = cpu_to_le16(0x3000);
+    smb38.interface_type = info->intftype;
+    smb38.ipmi_spec_revision = info->version;
+    smb38.i2c_slave_address = info->slave_addr;
+    smb38.nv_storage_device_address = 0;
+
+    /* or 1 to set it to I/O space */
+    smb38.base_address = cpu_to_le64(info->iobase | 1);
+
+     /* 1-byte boundaries, addr bit0=0, level triggered irq */
+    smb38.base_address_modifier = 1;
+    smb38.interrupt_number = info->isairq;
+    smbios_table_entry_add((struct smbios_structure_header *) &smb38,
+                           sizeof(smb38), true);
+}
+#endif
+
 static void ipmi_isa_realizefn(DeviceState *dev, Error **errp)
 {
     ISADevice *isadev = ISA_DEVICE(dev);
@@ -50,6 +90,7 @@ static void ipmi_isa_realizefn(DeviceState *dev, Error **errp)
     char typename[20];
     Object *intfobj;
     IPMIInterface *intf;
+    IPMIInterfaceClass *intfk;
     Object *bmcobj;
     IPMIBmc *bmc;
 
@@ -68,10 +109,13 @@ static void ipmi_isa_realizefn(DeviceState *dev, Error **errp)
              TYPE_IPMI_INTERFACE_PREFIX "%s", ipmi->interface);
     intfobj = object_new(typename);
     intf = IPMI_INTERFACE(intfobj);
+    intfk = IPMI_INTERFACE_GET_CLASS(intf);
     bmc->intf = intf;
     intf->bmc = bmc;
     intf->io_base = ipmi->iobase;
     intf->slave_addr = ipmi->slave_addr;
+    ipmi->intftype = intfk->smbios_type;
+    ipmi->version = 0x20; /* Version 2.0 */
     ipmi_interface_init(intf, errp);
     if (*errp) {
         return;
@@ -103,6 +147,9 @@ static void ipmi_isa_realizefn(DeviceState *dev, Error **errp)
     qdev_set_legacy_instance_id(dev, intf->io_base, intf->io_length);
 
     isa_register_ioport(isadev, &intf->io, intf->io_base);
+#ifdef TARGET_I386
+    smbios_register_device_table_handler(ipmi_encode_smbios, ipmi);
+#endif
 }
 
 static void ipmi_isa_reset(DeviceState *qdev)
-- 
1.8.3.1

  parent reply	other threads:[~2015-04-07 19:52 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-07 19:51 [Qemu-devel] [PATCH 00/15] IPMI device for qemu minyard
2015-04-07 19:51 ` [Qemu-devel] [PATCH 01/15] Add a base IPMI interface minyard
2015-04-07 19:51 ` [Qemu-devel] [PATCH 02/15] ipmi: Add a PC ISA type structure minyard
2015-04-07 19:51 ` [Qemu-devel] [PATCH 03/15] ipmi: Add a KCS low-level interface minyard
2015-04-07 19:51 ` [Qemu-devel] [PATCH 04/15] ipmi: Add a BT " minyard
2015-04-07 19:51 ` [Qemu-devel] [PATCH 05/15] ipmi: Add a local BMC simulation minyard
2015-04-07 19:51 ` [Qemu-devel] [PATCH 06/15] ipmi: Add an external connection simulation interface minyard
2015-04-07 19:51 ` [Qemu-devel] [PATCH 07/15] ipmi: Add tests minyard
2015-04-07 19:51 ` [Qemu-devel] [PATCH 08/15] ipmi: Add documentation minyard
2015-04-07 19:51 ` [Qemu-devel] [PATCH 09/15] ipmi: Add migration capability to the IPMI device minyard
2015-04-07 19:51 ` [Qemu-devel] [PATCH 10/15] smbios: Add a function to directly add an entry minyard
2015-04-12 16:05   ` Michael S. Tsirkin
2015-04-13  1:26     ` Corey Minyard
2015-04-13  7:00       ` Michael S. Tsirkin
2015-04-13 16:34         ` Corey Minyard
2015-04-13 16:40           ` Paolo Bonzini
2015-04-14  6:31             ` Michael S. Tsirkin
2015-04-14 15:30               ` Corey Minyard
2015-04-14 16:31               ` Paolo Bonzini
2015-04-14  6:41           ` Michael S. Tsirkin
2015-04-07 19:51 ` [Qemu-devel] [PATCH 11/15] pc: Postpone SMBIOS table installation to post machine init minyard
2015-04-07 19:51 ` minyard [this message]
2015-04-07 19:51 ` [Qemu-devel] [PATCH 13/15] configure: Copy some items from default configs to target configs minyard
2015-04-10 11:47   ` Paolo Bonzini
2015-04-07 19:51 ` [Qemu-devel] [PATCH 14/15] acpi: Add hooks for adding things to the SSDT table minyard
2015-04-10 11:29   ` Paolo Bonzini
2015-04-12 16:17   ` Michael S. Tsirkin
2015-04-13  1:30     ` Corey Minyard
2015-04-13  6:36       ` Michael S. Tsirkin
2015-04-13  8:39         ` Paolo Bonzini
2015-04-13 11:32           ` Michael S. Tsirkin
2015-04-13 13:47             ` Paolo Bonzini
2015-04-13 13:44       ` Paolo Bonzini
2015-04-13 16:00         ` Corey Minyard
2015-04-13 16:41           ` Paolo Bonzini
2015-04-10 11:48 ` [Qemu-devel] [PATCH 00/15] IPMI device for qemu Paolo Bonzini

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=1428436304-24044-13-git-send-email-minyard@acm.org \
    --to=minyard@acm.org \
    --cc=cminyard@mvista.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.