qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: minyard@acm.org
Cc: Corey Minyard <cminyard@mvista.com>,
	andreas.faerber@web.de, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 02/17] ipmi: Add a PC ISA type structure
Date: Sun, 26 Apr 2015 10:58:56 +0200	[thread overview]
Message-ID: <20150426105502-mutt-send-email-mst@redhat.com> (raw)
In-Reply-To: <1429829878-26862-3-git-send-email-minyard@acm.org>

On Thu, Apr 23, 2015 at 05:57:43PM -0500, minyard@acm.org wrote:
> From: Corey Minyard <cminyard@mvista.com>
> 
> This provides the base infrastructure to tie IPMI low-level
> interfaces into a PC ISA bus.
> 
> Signed-off-by: Corey Minyard <cminyard@mvista.com>
> ---
>  default-configs/i386-softmmu.mak   |   1 +
>  default-configs/x86_64-softmmu.mak |   1 +
>  hw/ipmi/Makefile.objs              |   1 +
>  hw/ipmi/isa_ipmi.c                 | 144 +++++++++++++++++++++++++++++++++++++
>  include/hw/nvram/fw_cfg.h          |  11 ++-
>  5 files changed, 157 insertions(+), 1 deletion(-)
>  create mode 100644 hw/ipmi/isa_ipmi.c
> 
> diff --git a/default-configs/i386-softmmu.mak b/default-configs/i386-softmmu.mak
> index ab1a552..1c3153b 100644
> --- a/default-configs/i386-softmmu.mak
> +++ b/default-configs/i386-softmmu.mak
> @@ -9,6 +9,7 @@ CONFIG_VGA_CIRRUS=y
>  CONFIG_VMWARE_VGA=y
>  CONFIG_VMMOUSE=y
>  CONFIG_IPMI=y
> +CONFIG_ISA_IPMI=y
>  CONFIG_SERIAL=y
>  CONFIG_PARALLEL=y
>  CONFIG_I8254=y
> diff --git a/default-configs/x86_64-softmmu.mak b/default-configs/x86_64-softmmu.mak
> index 82bafcc..6b57430 100644
> --- a/default-configs/x86_64-softmmu.mak
> +++ b/default-configs/x86_64-softmmu.mak
> @@ -9,6 +9,7 @@ CONFIG_VGA_CIRRUS=y
>  CONFIG_VMWARE_VGA=y
>  CONFIG_VMMOUSE=y
>  CONFIG_IPMI=y
> +CONFIG_ISA_IPMI=y
>  CONFIG_SERIAL=y
>  CONFIG_PARALLEL=y
>  CONFIG_I8254=y
> diff --git a/hw/ipmi/Makefile.objs b/hw/ipmi/Makefile.objs
> index 65bde11..1518216 100644
> --- a/hw/ipmi/Makefile.objs
> +++ b/hw/ipmi/Makefile.objs
> @@ -1 +1,2 @@
> +common-obj-$(CONFIG_ISA_IPMI) += isa_ipmi.o
>  common-obj-$(CONFIG_IPMI) += ipmi.o
> diff --git a/hw/ipmi/isa_ipmi.c b/hw/ipmi/isa_ipmi.c
> new file mode 100644
> index 0000000..1c1ab8d
> --- /dev/null
> +++ b/hw/ipmi/isa_ipmi.c
> @@ -0,0 +1,144 @@
> +/*
> + * QEMU ISA IPMI emulation
> + *
> + * Copyright (c) 2012 Corey Minyard, MontaVista Software, LLC
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a copy
> + * of this software and associated documentation files (the "Software"), to deal
> + * in the Software without restriction, including without limitation the rights
> + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> + * copies of the Software, and to permit persons to whom the Software is
> + * furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice shall be included in
> + * all copies or substantial portions of the Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
> + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
> + * THE SOFTWARE.
> + */
> +#include "hw/hw.h"
> +#include "hw/isa/isa.h"
> +#include "hw/i386/pc.h"
> +#include "qemu/timer.h"
> +#include "sysemu/char.h"
> +#include "sysemu/sysemu.h"
> +#include "ipmi.h"
> +
> +/* This is the type the user specifies on the -device command line */
> +#define TYPE_ISA_IPMI           "isa-ipmi"
> +#define ISA_IPMI(obj) OBJECT_CHECK(ISAIPMIDevice, (obj), TYPE_ISA_IPMI)
> +
> +typedef struct ISAIPMIDevice {
> +    ISADevice dev;
> +    char *interface;
> +    uint32_t iobase;
> +    int32 isairq;
> +    uint8_t slave_addr;
> +    CharDriverState *chr;
> +    IPMIInterface *intf;
> +} ISAIPMIDevice;
> +
> +static void ipmi_isa_realizefn(DeviceState *dev, Error **errp)
> +{
> +    ISADevice *isadev = ISA_DEVICE(dev);
> +    ISAIPMIDevice *ipmi = ISA_IPMI(dev);
> +    char typename[20];
> +    Object *intfobj;
> +    IPMIInterface *intf;
> +    Object *bmcobj;
> +    IPMIBmc *bmc;
> +
> +    if (!ipmi->interface) {
> +        ipmi->interface = g_strdup("kcs");
> +    }
> +
> +    if (ipmi->chr) {
> +        bmcobj = object_new(TYPE_IPMI_BMC_EXTERN);
> +    } else {
> +        bmcobj = object_new(TYPE_IPMI_BMC_SIMULATOR);
> +    }
> +    bmc = IPMI_BMC(bmcobj);
> +    bmc->chr = ipmi->chr;
> +    snprintf(typename, sizeof(typename),
> +             TYPE_IPMI_INTERFACE_PREFIX "%s", ipmi->interface);
> +    intfobj = object_new(typename);


I wonder what Andreas thinks about this.
There are only 3 legal types, correct?
I think it would be cleaner to avoid the prefix trick,
and just do a plain
	if (!ipmi->interface)) {
		typename = TYPE_IPMI_INTERFACE_KCS
	} else if (!strcmp(ipmi->interface, "kcs")) {
		typename = TYPE_IPMI_INTERFACE_KCS
	} else if ....


etc



> +    intf = IPMI_INTERFACE(intfobj);
> +    bmc->intf = intf;
> +    intf->bmc = bmc;
> +    intf->io_base = ipmi->iobase;
> +    intf->slave_addr = ipmi->slave_addr;
> +    ipmi_interface_init(intf, errp);
> +    if (*errp) {
> +        return;
> +    }
> +    ipmi_bmc_init(bmc, errp);
> +    if (*errp) {
> +        return;
> +    }
> +
> +    /* These may be set by the interface. */
> +    ipmi->iobase = intf->io_base;
> +    ipmi->slave_addr = intf->slave_addr;
> +
> +    if (ipmi->isairq > 0) {
> +        isa_init_irq(isadev, &intf->irq, ipmi->isairq);
> +        intf->use_irq = 1;
> +    }
> +
> +    ipmi->intf = intf;
> +    object_property_add_child(OBJECT(isadev), "intf", OBJECT(intf), errp);
> +    if (*errp) {
> +        return;
> +    }
> +    object_property_add_child(OBJECT(isadev), "bmc", OBJECT(bmc), errp);
> +    if (*errp) {
> +        return;
> +    }
> +

Should the created object be destroyed before return?

> +    qdev_set_legacy_instance_id(dev, intf->io_base, intf->io_length);
> +
> +    isa_register_ioport(isadev, &intf->io, intf->io_base);
> +}
> +
> +static void ipmi_isa_reset(DeviceState *qdev)
> +{
> +    ISAIPMIDevice *isa = ISA_IPMI(qdev);
> +
> +    ipmi_interface_reset(isa->intf);
> +}
> +
> +static Property ipmi_isa_properties[] = {
> +    DEFINE_PROP_STRING("interface", ISAIPMIDevice, interface),
> +    DEFINE_PROP_UINT32("iobase", ISAIPMIDevice, iobase,  0),
> +    DEFINE_PROP_INT32("irq",   ISAIPMIDevice, isairq,  5),
> +    DEFINE_PROP_UINT8("slave_addr", ISAIPMIDevice, slave_addr,  0),
> +    DEFINE_PROP_CHR("chardev",  ISAIPMIDevice, chr),
> +    DEFINE_PROP_END_OF_LIST(),
> +};
> +
> +static void ipmi_isa_class_initfn(ObjectClass *klass, void *data)
> +{
> +    DeviceClass *dc = DEVICE_CLASS(klass);
> +    dc->realize = ipmi_isa_realizefn;
> +    dc->reset = ipmi_isa_reset;
> +    dc->props = ipmi_isa_properties;
> +}
> +
> +static const TypeInfo ipmi_isa_info = {
> +    .name          = TYPE_ISA_IPMI,
> +    .parent        = TYPE_ISA_DEVICE,
> +    .instance_size = sizeof(ISAIPMIDevice),
> +    .class_init    = ipmi_isa_class_initfn,
> +};
> +
> +static void ipmi_register_types(void)
> +{
> +    type_register_static(&ipmi_isa_info);
> +}
> +
> +type_init(ipmi_register_types)
> diff --git a/include/hw/nvram/fw_cfg.h b/include/hw/nvram/fw_cfg.h
> index 6d8a8ac..cac3a34 100644
> --- a/include/hw/nvram/fw_cfg.h
> +++ b/include/hw/nvram/fw_cfg.h
> @@ -38,7 +38,16 @@
>  
>  #define FW_CFG_FILE_FIRST       0x20
>  #define FW_CFG_FILE_SLOTS       0x10
> -#define FW_CFG_MAX_ENTRY        (FW_CFG_FILE_FIRST+FW_CFG_FILE_SLOTS)
> +
> +#define FW_CFG_IPMI_INTERFACE   0x30
> +#define FW_CFG_IPMI_BASE_ADDR   0x31
> +#define FW_CFG_IPMI_REG_SPACE   0x32
> +#define FW_CFG_IPMI_REG_SPACING 0x33
> +#define FW_CFG_IPMI_SLAVE_ADDR  0x34
> +#define FW_CFG_IPMI_IRQ         0x35
> +#define FW_CFG_IPMI_VERSION     0x36
> +
> +#define FW_CFG_MAX_ENTRY        (FW_CFG_IPMI_VERSION + 1)
>  
>  #define FW_CFG_WRITE_CHANNEL    0x4000
>  #define FW_CFG_ARCH_LOCAL       0x8000
> -- 
> 1.8.3.1
> 

  reply	other threads:[~2015-04-26  8:59 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-23 22:57 [Qemu-devel] [PATCH 00/17] Update to adding an IPMI device to qemu minyard
2015-04-23 22:57 ` [Qemu-devel] [PATCH 01/17] Add a base IPMI interface minyard
2015-04-23 22:57 ` [Qemu-devel] [PATCH 02/17] ipmi: Add a PC ISA type structure minyard
2015-04-26  8:58   ` Michael S. Tsirkin [this message]
2015-04-26  9:07     ` Michael S. Tsirkin
2015-05-08 21:16     ` Corey Minyard
2015-05-11 14:21       ` Paolo Bonzini
2015-05-11 17:26       ` Andreas Färber
2015-05-11 19:42         ` Paolo Bonzini
2015-05-11 19:58           ` Corey Minyard
2015-05-13 14:52             ` Paolo Bonzini
2015-05-16  1:48               ` Corey Minyard
2015-05-16 13:47                 ` Paolo Bonzini
2015-04-26  9:05   ` Michael S. Tsirkin
2015-04-26 17:03     ` Paolo Bonzini
2015-05-08 20:59       ` Corey Minyard
2015-04-23 22:57 ` [Qemu-devel] [PATCH 03/17] ipmi: Add a KCS low-level interface minyard
2015-04-23 22:57 ` [Qemu-devel] [PATCH 04/17] ipmi: Add a BT " minyard
2015-04-23 22:57 ` [Qemu-devel] [PATCH 05/17] ipmi: Add a local BMC simulation minyard
2015-04-23 22:57 ` [Qemu-devel] [PATCH 06/17] ipmi: Add an external connection simulation interface minyard
2015-04-23 22:57 ` [Qemu-devel] [PATCH 07/17] ipmi: Add tests minyard
2015-04-23 22:57 ` [Qemu-devel] [PATCH 08/17] ipmi: Add documentation minyard
2015-04-23 22:57 ` [Qemu-devel] [PATCH 09/17] ipmi: Add migration capability to the IPMI device minyard
2015-04-23 22:57 ` [Qemu-devel] [PATCH 10/17] ipmi: Add a firmware configuration repository minyard
2015-04-23 22:57 ` [Qemu-devel] [PATCH 12/17] smbios: Add a function to directly add an entry minyard
2015-04-23 22:57 ` [Qemu-devel] [PATCH 13/17] pc: Postpone SMBIOS table installation to post machine init minyard
2015-04-23 22:57 ` [Qemu-devel] [PATCH 14/17] ipmi: Add SMBIOS table entry minyard
2015-04-26  8:36   ` Michael S. Tsirkin
2015-04-23 22:57 ` [Qemu-devel] [PATCH 15/17] acpi: Add a way for devices to add ACPI tables minyard
2015-04-23 22:57 ` [Qemu-devel] [PATCH 16/17] ipmi: Add ACPI table entries minyard
2015-04-26  8:36   ` Michael S. Tsirkin
2015-04-23 22:57 ` [Qemu-devel] [PATCH 17/17] bios: Add tests for the IPMI ACPI and SMBIOS entries minyard
2015-04-23 23:11 ` [Qemu-devel] [PATCH 00/17] Update to adding an IPMI device to qemu Eric Blake
2015-04-26 11:39   ` Andreas Färber
2015-04-26 16:52     ` Paolo Bonzini
2015-04-27 13:19     ` Corey Minyard
2015-04-24  9:38 ` Paolo Bonzini
2015-04-24 13:07   ` 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=20150426105502-mutt-send-email-mst@redhat.com \
    --to=mst@redhat.com \
    --cc=andreas.faerber@web.de \
    --cc=cminyard@mvista.com \
    --cc=minyard@acm.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).