From patchwork Fri May 13 13:07:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 67784 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp259060qge; Fri, 13 May 2016 06:08:40 -0700 (PDT) X-Received: by 10.55.117.10 with SMTP id q10mr16578358qkc.103.1463144920771; Fri, 13 May 2016 06:08:40 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id n84si11988368qhn.110.2016.05.13.06.08.40 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 13 May 2016 06:08:40 -0700 (PDT) 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; dkim=fail header.i=@gmail.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 Received: from localhost ([::1]:34468 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b1Cpc-0004Re-6u for patch@linaro.org; Fri, 13 May 2016 09:08:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46362) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b1CoX-0002zT-5o for qemu-devel@nongnu.org; Fri, 13 May 2016 09:07:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b1CoQ-0006ar-2q for qemu-devel@nongnu.org; Fri, 13 May 2016 09:07:32 -0400 Received: from mail-oi0-x242.google.com ([2607:f8b0:4003:c06::242]:33277) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b1CoP-0006ai-SF for qemu-devel@nongnu.org; Fri, 13 May 2016 09:07:26 -0400 Received: by mail-oi0-x242.google.com with SMTP id t140so4138937oie.0 for ; Fri, 13 May 2016 06:07:25 -0700 (PDT) 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=Z0WNVcmORsBfhPOsWgxK0gL+0486PaBKXnzwSb5Y6wM=; b=fhNvSzXbwVrCYhhvZ6C/w3PPirrZIYOcIuvXfUlWSjJaAGeerhLjZBQnIhnrvu/L1w skwN1Azt2joeg6rfKm/nT4xyjnoGvi8y2CZrbfjthysEcakoiLoT9+rMntyOGMdm2jmd 01biPkDcrahT9J/CxtlcP+wF2hQOr0F+7TLaw4+QgOZn1N9AHDIqnkeUL2t7IwifuWRp a9H3kc8zMBHJ22GVFzgEyKpg9vUQEiB7dUshvmzgzp5oapzSSAMwSlWB2D22t9yniGim kPIqGZH9nh643QWUT9FTTgKTUAivNoGIY/XW634kAOC3hIMhTvrNX6cZ5DFk/fcxMvjl l+Tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=Z0WNVcmORsBfhPOsWgxK0gL+0486PaBKXnzwSb5Y6wM=; b=DtXv26sS7CiCwS0EGK21n2Uzer9HoCFARJTJH1zvPAhUM1xmZ46v1Vp0cNIUWGZ8PI hOHEvYmdET2jeJDl6GSoi1DJb89Z7+dxoW8oiWZGVCMa0mpKHHDDfn54BYzSQ8PNDZY7 Snx8HCImuS1NXQ2rzZB62rQjj9UWDAr8BaD2F/Ik+ASCAxUMzC0Ah3ObYG2XkWypIMSK Ui+c+ZRJ0dol+CENK4rdW9cZrbA1F0xW1b8uosaoGB3TR40iRFLkFfg26jRcc9nNaj2e BO2AcNcrUyFlajAjfT/fX5zEZhVeB3vhfofzJyfjWkX/rNeQhL4K8BuFHtkLDdMlFbli LY/Q== X-Gm-Message-State: AOPr4FUmiQ/5YwDPUrf/58BHSHRUfDCoD2mvnugQ4OcRj+wjeScB4RABOMFOTEKmzsJ5UQ== X-Received: by 10.157.40.242 with SMTP id s105mr7967639ota.68.1463144845552; Fri, 13 May 2016 06:07:25 -0700 (PDT) Received: from serve.minyard.net ([108.19.215.157]) by smtp.gmail.com with ESMTPSA id q8sm5366779oec.15.2016.05.13.06.07.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 May 2016 06:07:23 -0700 (PDT) Received: from t430.minyard.net (unknown [IPv6:2001:470:b8f6:1b:b1c3:fd99:bd02:8a4c]) by serve.minyard.net (Postfix) with ESMTPA id 056A31C9D; Fri, 13 May 2016 08:07:21 -0500 (CDT) Received: by t430.minyard.net (Postfix, from userid 1000) id 9B101300529; Fri, 13 May 2016 08:07:18 -0500 (CDT) From: minyard@acm.org To: Igor Mammedov , "Michael S . Tsirkin" , Paolo Bonzini , qemu-devel@nongnu.org Date: Fri, 13 May 2016 08:07:09 -0500 Message-Id: <1463144831-4502-5-git-send-email-minyard@acm.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1463144831-4502-1-git-send-email-minyard@acm.org> References: <1463144831-4502-1-git-send-email-minyard@acm.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:4003:c06::242 Subject: [Qemu-devel] [PATCH v3 4/6] ipmi: Add SMBIOS table entry X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Corey Minyard Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Corey Minyard Add an IPMI table entry to the SMBIOS. Signed-off-by: Corey Minyard Acked-by: Michael S. Tsirkin --- 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 ++++++++++ 5 files changed, 109 insertions(+) create mode 100644 hw/smbios/ipmi.c create mode 100644 hw/smbios/noipmi.c create mode 100644 include/hw/smbios/ipmi.h -- 2.7.4 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..b4b6151 --- /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 5dc3e43..74c7102 100644 --- a/hw/smbios/smbios.c +++ b/hw/smbios/smbios.c @@ -25,6 +25,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 { @@ -848,6 +849,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 */