From patchwork Wed May 11 16:38:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 67611 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp320269qge; Wed, 11 May 2016 09:41:23 -0700 (PDT) X-Received: by 10.55.214.4 with SMTP id t4mr4693238qki.202.1462984883753; Wed, 11 May 2016 09:41:23 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id m63si5718076qkf.226.2016.05.11.09.41.23 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 11 May 2016 09:41:23 -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]:53212 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b0XCM-0000Bc-TN for patch@linaro.org; Wed, 11 May 2016 12:41:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48929) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b0XAD-0004nX-KL for qemu-devel@nongnu.org; Wed, 11 May 2016 12:39:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b0XA6-0002B8-IA for qemu-devel@nongnu.org; Wed, 11 May 2016 12:39:08 -0400 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]:36447) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b0XA6-0002B0-8f for qemu-devel@nongnu.org; Wed, 11 May 2016 12:39:02 -0400 Received: by mail-pf0-x243.google.com with SMTP id g132so4138089pfb.3 for ; Wed, 11 May 2016 09:39:02 -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=hX7tpsLxgWhSCWzIQEtV5Spsf2/2sWyA0PHjWezJbzc=; b=D4YT+r2SQObNk+6uAUApmoMqu4BbtXOJ8G1MT1XOdCAnF3j2Lf6UoFD77lvClfECv1 9yzfQUwYy64UtgSBmA3j3jJtNmTr4AL2Bd5f5phlVwVm6ZSCc309bh0Dych/yU1Q64/J OkVArxmJCE0k+GMqaxDn6GWiBvPkpmDaojvRfF2BvopvaB4BPBtqwbEqIwKFfsMPJQ3w y1FIegdu83Vj7TFOd/Kb85AiaMJthZNsM6Ig42m5JZ6Sd47Ol8qNN9xfWnT6TJGq6Lpn ovURAUVDf/FdkKmvF75IeecpWa/EshIsJc0Q/5OHR9sV0VkzmepzV1x3+dpKDHOj3kh4 EDlg== 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=hX7tpsLxgWhSCWzIQEtV5Spsf2/2sWyA0PHjWezJbzc=; b=aUoqHON3WDn0nO6/1v94eBZCLJDHIvCD3+WqdHGy/cJqHzpJ/eneu7htZQTJkiEUDT EvYtaITx+Umkcxvo2hdnQD0ish3sBJt4H8zFcHV97Vqg8T7tOFCsMMx496fUYAqWTW3/ uvtu/LFHYZkfAd10z1c/791bW4HHJjkaMed1P0nZt3lXKOGyQqYhr/N3cPyqZ8I2i8iA yAj8Q7vIt61uR17YExwcm5PrDKT8yU2oFhG/AkAbOqYeGszEqCdy8a5CqA4xNY3c1gdf N3Z3dV3AV3/8t+XWKiKNnWjiXo7jVwADkAiL5vs/SPRbTz3WffGtDfmvmm1n4snKvEII T2cw== X-Gm-Message-State: AOPr4FUSOh37zhEqYkWDAj2qi+v6Sd0QktY1Jkser62/rDa9rSyqACgjjNoOY6ljIFR+CA== X-Received: by 10.98.47.194 with SMTP id v185mr6297622pfv.120.1462984741635; Wed, 11 May 2016 09:39:01 -0700 (PDT) Received: from serve.minyard.net ([108.19.215.157]) by smtp.gmail.com with ESMTPSA id dr4sm13425179pac.11.2016.05.11.09.38.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 May 2016 09:38:59 -0700 (PDT) Received: from t430.minyard.net (t430m.minyard.net [192.168.27.3]) by serve.minyard.net (Postfix) with ESMTPA id 962C4DD4; Wed, 11 May 2016 11:38:57 -0500 (CDT) Received: by t430.minyard.net (Postfix, from userid 1000) id 814EC300549; Wed, 11 May 2016 11:38:56 -0500 (CDT) From: minyard@acm.org To: Igor Mammedov , "Michael S . Tsirkin" , Paolo Bonzini , qemu-devel@nongnu.org, minyard@acm.org Date: Wed, 11 May 2016 11:38:52 -0500 Message-Id: <1462984734-23803-4-git-send-email-minyard@acm.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1462984734-23803-1-git-send-email-minyard@acm.org> References: <1462984734-23803-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:400e:c00::243 Subject: [Qemu-devel] [PATCH v2 3/5] 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 --- 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 -- 2.7.4 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..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 */