[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 12/18] IPMI: Add a PC ISA type structure
From: |
Andreas Färber |
Subject: |
Re: [Qemu-devel] [PATCH 12/18] IPMI: Add a PC ISA type structure |
Date: |
Mon, 30 Jul 2012 15:45:51 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120713 Thunderbird/14.0 |
Am 19.07.2012 20:53, schrieb address@hidden:
> From: Corey Minyard <address@hidden>
>
> This provides the base infrastructure to tie IPMI low-level
> interfaces into a PC ISA bus.
>
> Signed-off-by: Corey Minyard <address@hidden>
> ---
> default-configs/i386-softmmu.mak | 1 +
> default-configs/x86_64-softmmu.mak | 1 +
> hw/Makefile.objs | 1 +
> hw/isa_ipmi.c | 181
> ++++++++++++++++++++++++++++++++++++
> hw/smbios.h | 12 +++
> 5 files changed, 196 insertions(+), 0 deletions(-)
> create mode 100644 hw/isa_ipmi.c
>
> diff --git a/default-configs/i386-softmmu.mak
> b/default-configs/i386-softmmu.mak
> index eb17afc..c0aff0d 100644
> --- a/default-configs/i386-softmmu.mak
> +++ b/default-configs/i386-softmmu.mak
> @@ -8,6 +8,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 e4e3e4f..615e4f2 100644
> --- a/default-configs/x86_64-softmmu.mak
> +++ b/default-configs/x86_64-softmmu.mak
> @@ -8,6 +8,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/Makefile.objs b/hw/Makefile.objs
> index 256cfae..928870b 100644
> --- a/hw/Makefile.objs
> +++ b/hw/Makefile.objs
> @@ -21,6 +21,7 @@ hw-obj-$(CONFIG_ESCC) += escc.o
> hw-obj-$(CONFIG_EMPTY_SLOT) += empty_slot.o
>
> hw-obj-$(CONFIG_IPMI) += ipmi.o
> +hw-obj-$(CONFIG_ISA_IPMI) += isa_ipmi.o
>
> hw-obj-$(CONFIG_SERIAL) += serial.o
> hw-obj-$(CONFIG_PARALLEL) += parallel.o
> diff --git a/hw/isa_ipmi.c b/hw/isa_ipmi.c
> new file mode 100644
> index 0000000..c15ca22
> --- /dev/null
> +++ b/hw/isa_ipmi.c
> @@ -0,0 +1,181 @@
> +/*
> + * QEMU ISA IPMI KCS 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.h"
> +#include "isa.h"
> +#include "pc.h"
> +#include "qemu-timer.h"
> +#include "qemu-char.h"
> +#include "sysemu.h"
> +#include "smbios.h"
> +#include "ipmi.h"
> +
> +
> +typedef struct ISAIPMIDevice {
> + ISADevice dev;
> + char *interface;
> + uint32_t iobase;
> + uint32_t isairq;
> + uint8_t slave_addr;
> + CharDriverState *chr;
> + IPMIInterface *intf;
> +} ISAIPMIDevice;
> +
> +static int ipmi_isa_initfn(ISADevice *dev)
> +{
> + ISAIPMIDevice *isa = DO_UPCAST(ISAIPMIDevice, dev, dev);
> + struct smbios_type_38 smb38;
> + char typename[20];
> + Object *intfobj;
> + IPMIInterface *intf;
> + IPMIInterfaceClass *intfk;
> + Object *bmcobj;
> + IPMIBmc *bmc;
> + int rc;
> + Error *errp = NULL;
> +
> + if (!isa->interface) {
> + isa->interface = g_strdup("kcs");
> + }
> +
> + if (isa->chr) {
> + bmcobj = object_new("ipmi-bmc-extern");
> + } else {
> + bmcobj = object_new("ipmi-bmc-sim");
> + }
Please use TYPE_ constants instead of hardcoding strings.
> + bmc = DO_UPCAST(IPMIBmc, parent_obj, bmcobj);
Please use QOM cast macros rather than qdev's DO_UPCAST().
> + bmc->chr = isa->chr;
> + snprintf(typename, sizeof(typename), "ipmi-interface-%s",
> isa->interface);
> + intfobj = object_new(typename);
> + intf = DO_UPCAST(IPMIInterface, parent_obj, intfobj);
> + bmc->intf = intf;
> + intf->bmc = bmc;
> + intf->io_base = isa->iobase;
> + intf->slave_addr = isa->slave_addr;
> + rc = ipmi_interface_init(intf);
> + if (rc) {
> + return rc;
> + }
> + rc = ipmi_bmc_init(bmc);
> + if (rc) {
> + return rc;
> + }
> +
> + /* These may be set by the interface. */
> + isa->iobase = intf->io_base;
> + isa->slave_addr = intf->slave_addr;
> +
> + if (isa->isairq != 0) {
> + isa_init_irq(dev, &intf->irq, isa->isairq);
> + intf->use_irq = 1;
> + }
> +
> + isa->intf = intf;
> + object_property_add_child(OBJECT(isa), "intf", OBJECT(intf), &errp);
> + if (error_is_set(&errp)) {
> + fprintf(stderr, "%s\n", error_get_pretty(errp));
> + return 1;
> + }
> + object_property_add_child(OBJECT(isa), "bmc", OBJECT(bmc), &errp);
> + if (error_is_set(&errp)) {
> + fprintf(stderr, "%s\n", error_get_pretty(errp));
> + return 1;
> + }
> +
> + qdev_set_legacy_instance_id(&dev->qdev, intf->io_base, intf->io_length);
> +
> + isa_register_ioport(dev, &intf->io, intf->io_base);
> +
> + intfk = IPMI_INTERFACE_GET_CLASS(intf);
> +
> + smb38.header.type = 38;
> + smb38.header.length = sizeof(smb38);
> + smb38.header.handle = 0x3000;
> + smb38.interface_type = intfk->smbios_type;
> + smb38.ipmi_version = 0x20;
> + smb38.i2c_slave_addr = intf->slave_addr;
> + smb38.nv_storage_dev_addr = 0;
> +
> + /* or 1 to set it to I/O space */
> + smb38.base_addr = intf->io_base | 1;
> +
> + /* 1-byte boundaries, addr bit0=0, level triggered irq */
> + smb38.base_addr_mod_and_irq_info = 1;
> + smb38.interrupt_number = isa->isairq;
> + smbios_table_entry_add((struct smbios_structure_header *) &smb38);
> +
> + return 0;
> +}
> +
> +static void ipmi_isa_reset(DeviceState *qdev)
> +{
> + ISAIPMIDevice *isa = DO_UPCAST(ISAIPMIDevice, dev.qdev, qdev);
> +
> + ipmi_interface_reset(isa->intf);
> +}
> +
> +static Property ipmi_isa_properties[] = {
> + DEFINE_PROP_STRING("interface", ISAIPMIDevice, interface),
> + DEFINE_PROP_HEX32("iobase", ISAIPMIDevice, iobase, 0),
> + DEFINE_PROP_UINT32("irq", ISAIPMIDevice, isairq, 5),
> + DEFINE_PROP_UINT8("slave_addr", ISAIPMIDevice, slave_addr, 0),
> + DEFINE_PROP_CHR("chardev", ISAIPMIDevice, chr),
> + DEFINE_PROP_END_OF_LIST(),
> +};
> +
> +#if 0 /* FIXME */
Fix this? x86 machines should definitely remain migratable.
> +static const VMStateDescription vmstate_isa_ipmi = {
> + .name = "isa-ipmi",
> + .version_id = 3,
> + .minimum_version_id = 3,
> + .fields = (VMStateField[]) {
> + /* FIXME - fill this in */
> + VMSTATE_END_OF_LIST()
> + }
> +};
> +#endif
> +
> +static void ipmi_isa_class_initfn(ObjectClass *klass, void *data)
> +{
> + DeviceClass *dc = DEVICE_CLASS(klass);
> + ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
> + ic->init = ipmi_isa_initfn;
> + dc->reset = ipmi_isa_reset;
> + /* dc->vmsd = &vmstate_isa_ipmi; FIXME */
> + dc->props = ipmi_isa_properties;
> +}
> +
> +static TypeInfo ipmi_isa_info = {
static const please.
> + .name = "isa-ipmi",
Where is this used? Should probably be TYPE_..., too.
Andreas
> + .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);
> + qdev_add_prefw_init("isa-ipmi");
> +}
> +
> +type_init(ipmi_register_types)
> diff --git a/hw/smbios.h b/hw/smbios.h
> index 6431a15..b9e4a61 100644
> --- a/hw/smbios.h
> +++ b/hw/smbios.h
> @@ -155,6 +155,18 @@ struct smbios_type_32 {
> uint8_t boot_status;
> } QEMU_PACKED;
>
> +/* SMBIOS type 38 - IPMI Device Information */
> +struct smbios_type_38 {
> + struct smbios_structure_header header;
> + uint8_t interface_type;
> + uint8_t ipmi_version;
> + uint8_t i2c_slave_addr;
> + uint8_t nv_storage_dev_addr;
> + uint64_t base_addr;
> + uint8_t base_addr_mod_and_irq_info;
> + uint8_t interrupt_number;
> +} QEMU_PACKED;
> +
> /* SMBIOS type 127 -- End-of-table */
> struct smbios_type_127 {
> struct smbios_structure_header header;
>
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
- Re: [Qemu-devel] [PATCH 01/18] smbios: Add a function to directly add an entry, (continued)
[Qemu-devel] [PATCH 05/18] qemu-char: Allow a chardev to reconnect if disconnected, minyard, 2012/07/19
[Qemu-devel] [PATCH 11/18] Add a base IPMI interface, minyard, 2012/07/19
[Qemu-devel] [PATCH 03/18] vl: Move init_timer_alarm() earlier, minyard, 2012/07/19
[Qemu-devel] [PATCH 02/18] pc: move SMBIOS setup to after device init, minyard, 2012/07/19
[Qemu-devel] [PATCH 14/18] IPMI: Add a BT low-level interface, minyard, 2012/07/19
[Qemu-devel] [PATCH 18/18] IPMI: Add documentation., minyard, 2012/07/19
[Qemu-devel] [PATCH 12/18] IPMI: Add a PC ISA type structure, minyard, 2012/07/19
- Re: [Qemu-devel] [PATCH 12/18] IPMI: Add a PC ISA type structure,
Andreas Färber <=
[Qemu-devel] [PATCH 17/18] IPMI: Add tests, minyard, 2012/07/19
[Qemu-devel] [PATCH 08/18] qemu-char: Close fd at end of file, minyard, 2012/07/19
[Qemu-devel] [PATCH 16/18] IPMI: Add an external connection simulation interface, minyard, 2012/07/19
[Qemu-devel] [PATCH 13/18] IPMI: Add a KCS low-level interface, minyard, 2012/07/19
[Qemu-devel] [PATCH 15/18] IPMI: Add a local BMC simulation, minyard, 2012/07/19
Re: [Qemu-devel] Third shot at adding IPMI to qemu, Paolo Bonzini, 2012/07/20
Re: [Qemu-devel] Third shot at adding IPMI to qemu, Corey Minyard, 2012/07/30