From patchwork Thu Nov 12 19:02:30 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 56473 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp600635lbb; Thu, 12 Nov 2015 11:15:01 -0800 (PST) X-Received: by 10.13.231.69 with SMTP id q66mr16091425ywe.299.1447355701237; Thu, 12 Nov 2015 11:15:01 -0800 (PST) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id l185si8873348ywd.229.2015.11.12.11.15.01 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 12 Nov 2015 11:15:01 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dkim=fail header.i=@gmail.com Received: from localhost ([::1]:49327 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZwxKm-0007F0-Qc for patch@linaro.org; Thu, 12 Nov 2015 14:15:00 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58813) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zwx92-0001ZD-CZ for qemu-devel@nongnu.org; Thu, 12 Nov 2015 14:02:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zwx91-000546-3S for qemu-devel@nongnu.org; Thu, 12 Nov 2015 14:02:52 -0500 Received: from mail-pa0-x22b.google.com ([2607:f8b0:400e:c03::22b]:35502) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zwx90-00053v-SB for qemu-devel@nongnu.org; Thu, 12 Nov 2015 14:02:51 -0500 Received: by pasz6 with SMTP id z6so75687354pas.2 for ; Thu, 12 Nov 2015 11:02:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=+/yDfpl5PX5IWrO5UftSx9A22wDK1sXqUU590E+BuFM=; b=ajv1G9K9o1FQ0aSnvHX/FeBOIVg83lx8FhTENJySxB2mTDAHGRkz3Gwi7LVrXOnUoA J+0Ucz28tsH1r3HyJWygrp7YmFrWc46b8ODzku82zoO6KitbqUCv0+exmwXD1hj74bLL SC/WnomkmXieDXaWPXAXk6kM75KjP78UycVTZhREL1Iv8QWJVjEGOpph4JX+ZQwkZRYo UJVJYXijWt8b057iMdjHbXqo14eBLjF6+4PaCSsSreAXiNHq5wQkO657lN30dwFcch5s YcOYUrxfUZY2lWvrjkkZDWChhWTRDC4kmj+QgJnDageY0nbt+d2rghAEvzbBS62eMD4P /KAw== X-Received: by 10.66.218.170 with SMTP id ph10mr25031783pac.58.1447354970189; Thu, 12 Nov 2015 11:02:50 -0800 (PST) Received: from t430.minyard.home (pool-173-57-176-17.dllstx.fios.verizon.net. [173.57.176.17]) by smtp.gmail.com with ESMTPSA id st5sm16137729pab.42.2015.11.12.11.02.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Nov 2015 11:02:46 -0800 (PST) Received: from t430.minyard.home (t430.minyard.home [127.0.0.1]) by t430.minyard.home (8.14.7/8.14.7) with ESMTP id tACJ2ixh019757; Thu, 12 Nov 2015 13:02:44 -0600 Received: (from cminyard@localhost) by t430.minyard.home (8.14.7/8.14.7/Submit) id tACJ2iRj019756; Thu, 12 Nov 2015 13:02:44 -0600 From: minyard@acm.org To: qemu-devel@nongnu.org, Paolo Bonzini , "Michael S. Tsirkin" , Igor Mammedov Date: Thu, 12 Nov 2015 13:02:30 -0600 Message-Id: <1447354953-18893-15-git-send-email-minyard@acm.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1447354953-18893-1-git-send-email-minyard@acm.org> References: <1447354953-18893-1-git-send-email-minyard@acm.org> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400e:c03::22b Cc: Corey Minyard Subject: [Qemu-devel] [PATCH v4 14/17] 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.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 | 75 ++++++++++++++++++++++++++++++++++++++ hw/smbios/noipmi.c | 14 +++++++ hw/smbios/smbios.c | 2 + include/hw/smbios/ipmi.h | 15 ++++++++ 7 files changed, 110 insertions(+) create mode 100644 hw/smbios/ipmi.c create mode 100644 hw/smbios/noipmi.c create mode 100644 include/hw/smbios/ipmi.h -- 1.8.3.1 diff --git a/default-configs/i386-softmmu.mak b/default-configs/i386-softmmu.mak index 1730fbb..b73bf3a 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 22a99a2..baf07cc 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..9c0ce3c --- /dev/null +++ b/hw/smbios/ipmi.c @@ -0,0 +1,75 @@ +/* + * 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/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 fe553f9..ebfb077 100644 --- a/hw/smbios/smbios.c +++ b/hw/smbios/smbios.c @@ -23,6 +23,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 { @@ -846,6 +847,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 */