All of lore.kernel.org
 help / color / mirror / Atom feed
From: Corey Minyard <minyard@acm.org>
To: qemu-devel@nongnu.org
Cc: "Bret Ketchum" <bcketchum@gmail.com>,
	"Corey Minyard" <cminyard@mvista.com>,
	"Andreas Färber" <afaerber@suse.de>,
	"Michael S. Tsirkin" <mst@redhat.com>
Subject: [Qemu-devel] [PATCH 16/16] ipmi: Add SMBIOS table entry
Date: Tue, 12 Nov 2013 10:33:15 -0600	[thread overview]
Message-ID: <1384273995-16486-17-git-send-email-cminyard@mvista.com> (raw)
In-Reply-To: <1384273995-16486-1-git-send-email-cminyard@mvista.com>

Add an IPMI table entry to the SMBIOS.
---
 hw/ipmi/isa_ipmi.c       | 29 +++++++++++++++++++++++++++++
 include/hw/i386/smbios.h | 14 ++++++++++++++
 2 files changed, 43 insertions(+)

diff --git a/hw/ipmi/isa_ipmi.c b/hw/ipmi/isa_ipmi.c
index b38c846..e40ca90 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,36 @@
 typedef struct ISAIPMIDevice {
     ISADevice dev;
     char *interface;
+    int intftype;
     uint32_t iobase;
     uint32_t isairq;
     uint8_t slave_addr;
+    uint8_t version;
     CharDriverState *chr;
     IPMIInterface *intf;
 } ISAIPMIDevice;
 
+static void ipmi_encode_smbios(ISAIPMIDevice *info)
+{
+    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);
+}
+
 static void ipmi_isa_realizefn(DeviceState *dev, Error **errp)
 {
     ISADevice *isadev = ISA_DEVICE(dev);
@@ -50,6 +74,7 @@ static void ipmi_isa_realizefn(DeviceState *dev, Error **errp)
     char typename[20];
     Object *intfobj;
     IPMIInterface *intf;
+    IPMIInterfaceClass *intfk;
     Object *bmcobj;
     IPMIBmc *bmc;
     int rc;
@@ -69,10 +94,13 @@ static void ipmi_isa_realizefn(DeviceState *dev, Error **errp)
              TYPE_IPMI_INTERFACE_PREFIX "%s", isa->interface);
     intfobj = object_new(typename);
     intf = IPMI_INTERFACE(intfobj);
+    intfk = IPMI_INTERFACE_GET_CLASS(intf);
     bmc->intf = intf;
     intf->bmc = bmc;
     intf->io_base = isa->iobase;
     intf->slave_addr = isa->slave_addr;
+    isa->intftype = intfk->smbios_type;
+    isa->version = 0x20; /* Version 2.0 */
     rc = ipmi_interface_init(intf);
     if (rc) {
         error_setg(errp, "Error initializing IPMI interface: %d\n", rc);
@@ -106,6 +134,7 @@ 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);
+    ipmi_encode_smbios(isa);
 }
 
 static void ipmi_isa_reset(DeviceState *dev)
diff --git a/include/hw/i386/smbios.h b/include/hw/i386/smbios.h
index b08ec71..8133faa 100644
--- a/include/hw/i386/smbios.h
+++ b/include/hw/i386/smbios.h
@@ -29,6 +29,8 @@ struct smbios_structure_header {
     uint16_t handle;
 } QEMU_PACKED;
 
+int smbios_table_entry_add(struct smbios_structure_header *entry);
+
 /* SMBIOS type 0 - BIOS Information */
 struct smbios_type_0 {
     struct smbios_structure_header header;
@@ -155,6 +157,18 @@ struct smbios_type_32 {
     uint8_t boot_status;
 } QEMU_PACKED;
 
+/* 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;
+
 /* SMBIOS type 127 -- End-of-table */
 struct smbios_type_127 {
     struct smbios_structure_header header;
-- 
1.8.3.1

  parent reply	other threads:[~2013-11-12 16:33 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-12 16:32 [Qemu-devel] [PATCH 00/16] Add an IPMI device to QEMU Corey Minyard
2013-11-12 16:33 ` [Qemu-devel] [PATCH 01/16] qemu-char: Allocate CharDriverState in qemu_chr_new_from_opts Corey Minyard
2014-01-23 13:32   ` Andreas Färber
2014-01-23 13:58     ` Andreas Färber
2013-11-12 16:33 ` [Qemu-devel] [PATCH 02/16] qemu-char: Allow a chardev to reconnect if disconnected Corey Minyard
2013-11-12 16:43   ` Eric Blake
2013-11-12 17:08     ` Corey Minyard
2013-11-14  7:32       ` Michael S. Tsirkin
2013-11-14 13:29         ` Corey Minyard
2013-11-13  8:55   ` Gerd Hoffmann
2013-11-13 20:51     ` Corey Minyard
2013-11-14 13:56       ` Michael S. Tsirkin
2013-11-12 16:33 ` [Qemu-devel] [PATCH 03/16] qemu-char: remove free of chr from win_stdio_close Corey Minyard
2013-11-12 16:33 ` [Qemu-devel] [PATCH 04/16] qemu-char: Close fd at end of file Corey Minyard
2013-11-12 16:33 ` [Qemu-devel] [PATCH 05/16] Add a base IPMI interface Corey Minyard
2013-11-12 16:33 ` [Qemu-devel] [PATCH 06/16] ipmi: Add a PC ISA type structure Corey Minyard
2014-01-29 14:58   ` Andreas Färber
2013-11-12 16:33 ` [Qemu-devel] [PATCH 07/16] ipmi: Add a KCS low-level interface Corey Minyard
2013-11-12 16:33 ` [Qemu-devel] [PATCH 08/16] ipmi: Add a BT " Corey Minyard
2013-11-12 16:33 ` [Qemu-devel] [PATCH 09/16] ipmi: Add a local BMC simulation Corey Minyard
2013-11-12 16:33 ` [Qemu-devel] [PATCH 10/16] ipmi: Add an external connection simulation interface Corey Minyard
2013-11-12 16:33 ` [Qemu-devel] [PATCH 11/16] ipmi: Add tests Corey Minyard
2013-11-13 14:12   ` Bret Ketchum
2013-11-13 20:51     ` Corey Minyard
2013-11-12 16:33 ` [Qemu-devel] [PATCH 12/16] ipmi: Add documentation Corey Minyard
2013-11-13 16:08   ` Bret Ketchum
2013-11-12 16:33 ` [Qemu-devel] [PATCH 13/16] ipmi: Add migration capability to the IPMI device Corey Minyard
2013-11-12 16:33 ` [Qemu-devel] [PATCH 14/16] pc: Postpone adding ACPI and SMBIOS to fw_cfg Corey Minyard
2013-11-13 14:31   ` Bret Ketchum
2013-11-14  7:30   ` Michael S. Tsirkin
2013-11-14 13:28     ` Corey Minyard
2013-11-14 13:38       ` Michael S. Tsirkin
2013-11-14 13:40         ` Corey Minyard
2013-11-14 13:50           ` Michael S. Tsirkin
2013-11-26 10:03           ` Michael S. Tsirkin
2013-11-12 16:33 ` [Qemu-devel] [PATCH 15/16] smbios: Add a function to directly add an entry Corey Minyard
2013-11-13 14:37   ` Bret Ketchum
2013-11-13 16:22     ` Andreas Färber
2013-11-13 20:52     ` Corey Minyard
2013-11-12 16:33 ` Corey Minyard [this message]
2013-11-14  7:46   ` [Qemu-devel] [PATCH 16/16] ipmi: Add SMBIOS table entry Michael S. Tsirkin
2013-11-14 13:43     ` Corey Minyard

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=1384273995-16486-17-git-send-email-cminyard@mvista.com \
    --to=minyard@acm.org \
    --cc=afaerber@suse.de \
    --cc=bcketchum@gmail.com \
    --cc=cminyard@mvista.com \
    --cc=mst@redhat.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.