From patchwork Wed Feb 24 18:59:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 587692 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 1D9A2140317 for ; Thu, 25 Feb 2016 07:02:35 +1100 (AEDT) Received: from localhost ([::1]:38044 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aYfdp-0004SB-6i for incoming@patchwork.ozlabs.org; Wed, 24 Feb 2016 15:02:33 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58462) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aYfc3-0001KX-2A for qemu-devel@nongnu.org; Wed, 24 Feb 2016 15:00:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aYfbx-00042N-Qu for qemu-devel@nongnu.org; Wed, 24 Feb 2016 15:00:42 -0500 Received: from vms173007pub.verizon.net ([206.46.173.7]:56280) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aYfbx-00042F-JD for qemu-devel@nongnu.org; Wed, 24 Feb 2016 15:00:37 -0500 Received: from vz-proxy-l004.mx.aol.com ([64.236.82.152]) by vms173007.mailsrvcs.net (Oracle Communications Messaging Server 7.0.5.32.0 64bit (built Jul 16 2014)) with ESMTPA id <0O3200FOGFEXAF80@vms173007.mailsrvcs.net> for qemu-devel@nongnu.org; Wed, 24 Feb 2016 12:59:26 -0600 (CST) X-CMAE-Score: 0 X-CMAE-Analysis: v=2.1 cv=Nc0brD34 c=1 sm=1 tr=0 a=a3t/a0oOYlYu/nGe1mf8ZA==:117 a=xqWC_Br6kY4A:10 a=jFJIQSaiL_oA:10 a=fk1lIlRQAAAA:8 a=20KFwNOVAAAA:8 a=vsjbJye-uSVFZ0YFDb4A:9 a=VB8l0G--ALKJqt1B:21 a=-1lfc4-I_l__asQe:21 Received: by 173.57.176.17 with SMTP id 10d3cb38; Wed, 24 Feb 2016 18:59:26 GMT Received: from t430.minyard.net (unknown [IPv6:2001:470:b8f6:1b:88cc:7bcf:2247:8571]) by serve.minyard.net (Postfix) with ESMTPA id C1FC32C75; Wed, 24 Feb 2016 12:59:20 -0600 (CST) Received: by t430.minyard.net (Postfix, from userid 1000) id 07E38300736; Wed, 24 Feb 2016 12:59:18 -0600 (CST) From: minyard@acm.org To: Igor Mammedov , "Michael S. Tsirkin" , Paolo Bonzini , qemu-devel@nongnu.org Date: Wed, 24 Feb 2016 12:59:14 -0600 Message-id: <1456340356-17147-4-git-send-email-minyard@acm.org> X-Mailer: git-send-email 2.5.0 In-reply-to: <1456340356-17147-1-git-send-email-minyard@acm.org> References: <1456340356-17147-1-git-send-email-minyard@acm.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 206.46.173.7 Cc: Corey Minyard , minyard@acm.org Subject: [Qemu-devel] [PATCH 3/5] ipmi: Add SMBIOS table entry X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Corey Minyard Add an IPMI table entry to the SMBIOS. Signed-off-by: Corey Minyard Acked-by: Michael S. Tsirkin --- 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); + + 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 */