qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: minyard@acm.org
Cc: Igor Mammedov <imammedo@redhat.com>,
	Corey Minyard <cminyard@mvista.com>,
	qemu-devel@nongnu.org, Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 3/5] ipmi: Add SMBIOS table entry
Date: Sun, 13 Mar 2016 16:04:17 +0200	[thread overview]
Message-ID: <20160313160405-mutt-send-email-mst@redhat.com> (raw)
In-Reply-To: <1456340356-17147-4-git-send-email-minyard@acm.org>

On Wed, Feb 24, 2016 at 12:59:14PM -0600, minyard@acm.org wrote:
> From: Corey Minyard <cminyard@mvista.com>
> 
> Add an IPMI table entry to the SMBIOS.
> 
> Signed-off-by: Corey Minyard <cminyard@mvista.com>
> Acked-by: Michael S. Tsirkin <mst@redhat.com>
> ---
>  default-configs/i386-softmmu.mak   |  1 +
>  default-configs/x86_64-softmmu.mak |  1 +
>  hw/smbios/Makefile.objs            |  2 +
>  hw/smbios/ipmi.c                   | 76 ++++++++++++++++++++++++++++++++++++++
>  hw/smbios/noipmi.c                 | 14 +++++++
>  hw/smbios/smbios.c                 |  2 +
>  include/hw/smbios/ipmi.h           | 15 ++++++++
>  7 files changed, 111 insertions(+)
>  create mode 100644 hw/smbios/ipmi.c
>  create mode 100644 hw/smbios/noipmi.c
>  create mode 100644 include/hw/smbios/ipmi.h
> 
> diff --git a/default-configs/i386-softmmu.mak b/default-configs/i386-softmmu.mak
> index b177e52..c94431d 100644
> --- a/default-configs/i386-softmmu.mak
> +++ b/default-configs/i386-softmmu.mak
> @@ -20,6 +20,7 @@ CONFIG_I8254=y
>  CONFIG_PCSPK=y
>  CONFIG_PCKBD=y
>  CONFIG_FDC=y
> +CONFIG_SMBIOS=y
>  CONFIG_ACPI=y
>  CONFIG_ACPI_X86=y
>  CONFIG_ACPI_X86_ICH=y
> diff --git a/default-configs/x86_64-softmmu.mak b/default-configs/x86_64-softmmu.mak
> index 6e3b312..256294d 100644
> --- a/default-configs/x86_64-softmmu.mak
> +++ b/default-configs/x86_64-softmmu.mak
> @@ -20,6 +20,7 @@ CONFIG_I8254=y
>  CONFIG_PCSPK=y
>  CONFIG_PCKBD=y
>  CONFIG_FDC=y
> +CONFIG_SMBIOS=y
>  CONFIG_ACPI=y
>  CONFIG_ACPI_X86=y
>  CONFIG_ACPI_X86_ICH=y
> diff --git a/hw/smbios/Makefile.objs b/hw/smbios/Makefile.objs
> index f69a92f..5578f51 100644
> --- a/hw/smbios/Makefile.objs
> +++ b/hw/smbios/Makefile.objs
> @@ -1 +1,3 @@
>  common-obj-$(CONFIG_SMBIOS) += smbios.o
> +common-obj-$(call land,$(CONFIG_SMBIOS),$(CONFIG_IPMI)) += ipmi.o
> +common-obj-$(call land,$(CONFIG_SMBIOS),$(call lnot,$(CONFIG_IPMI))) += noipmi.o
> diff --git a/hw/smbios/ipmi.c b/hw/smbios/ipmi.c
> new file mode 100644
> index 0000000..3874431
> --- /dev/null
> +++ b/hw/smbios/ipmi.c
> @@ -0,0 +1,76 @@
> +/*
> + * IPMI SMBIOS 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 "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 ipmi_encode_one_smbios(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;
> +
> +    /* or 1 to set it to I/O space */
> +    switch (info->memspace) {
> +    case IPMI_MEMSPACE_IO: baseaddr |= 1; break;
> +    case IPMI_MEMSPACE_MEM32: break;
> +    case IPMI_MEMSPACE_MEM64: break;
> +    case IPMI_MEMSPACE_SMBUS: baseaddr <<= 1; break;
> +    }
> +
> +    t->base_address = cpu_to_le64(baseaddr);
> +    

trailing whitespace

> +    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;
> +}
> +
> +void smbios_build_type_38_table(void)
> +{
> +    IPMIFwInfo *info = ipmi_first_fwinfo();
> +
> +    while (info) {
> +        ipmi_encode_one_smbios(info);
> +        info = ipmi_next_fwinfo(info);
> +    }
> +}
> diff --git a/hw/smbios/noipmi.c b/hw/smbios/noipmi.c
> new file mode 100644
> index 0000000..ad669a4
> --- /dev/null
> +++ b/hw/smbios/noipmi.c
> @@ -0,0 +1,14 @@
> +/*
> + * IPMI SMBIOS 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/smbios/ipmi.h"
> +
> +void smbios_build_type_38_table(void)
> +{
> +}
> diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c
> index e1bc1ea..ef8acdd 100644
> --- a/hw/smbios/smbios.c
> +++ b/hw/smbios/smbios.c
> @@ -24,6 +24,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 {
> @@ -847,6 +848,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/include/hw/smbios/ipmi.h b/include/hw/smbios/ipmi.h
> new file mode 100644
> index 0000000..fd53c96
> --- /dev/null
> +++ b/include/hw/smbios/ipmi.h
> @@ -0,0 +1,15 @@
> +/*
> + * IPMI SMBIOS 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.
> + */
> +
> +#ifndef QEMU_SMBIOS_IPMI_H
> +#define QEMU_SMBIOS_IPMI_H
> +
> +void smbios_build_type_38_table(void);
> +
> +#endif /* QEMU_SMBIOS_IPMI_H */
> -- 
> 2.5.0

  reply	other threads:[~2016-03-13 14:04 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-24 18:59 [Qemu-devel] [PATCH 0/5] Add ACPI and SMBIOS table entries for IPMI minyard
2016-02-24 18:59 ` [Qemu-devel] [PATCH 1/5] smbios: Move table build tools into an include file minyard
2016-02-24 18:59 ` [Qemu-devel] [PATCH 2/5] pc: Postpone SMBIOS table installation to post machine init minyard
2016-03-13 14:03   ` Michael S. Tsirkin
2016-03-14 13:30     ` Corey Minyard
2016-03-14 14:16       ` Paolo Bonzini
2016-03-14 15:01         ` Corey Minyard
2016-03-14 15:25           ` Gerd Hoffmann
2016-03-15  5:05         ` Michael S. Tsirkin
2016-02-24 18:59 ` [Qemu-devel] [PATCH 3/5] ipmi: Add SMBIOS table entry minyard
2016-03-13 14:04   ` Michael S. Tsirkin [this message]
2016-02-24 18:59 ` [Qemu-devel] [PATCH 4/5] acpi: Add IPMI table entries minyard
2016-02-24 18:59 ` [Qemu-devel] [PATCH 5/5] bios: Add tests for the IPMI ACPI and SMBIOS entries minyard
2016-03-12  1:30 ` [Qemu-devel] [PATCH 0/5] Add ACPI and SMBIOS table entries for IPMI 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=20160313160405-mutt-send-email-mst@redhat.com \
    --to=mst@redhat.com \
    --cc=cminyard@mvista.com \
    --cc=imammedo@redhat.com \
    --cc=minyard@acm.org \
    --cc=pbonzini@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 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).