From patchwork Wed May 18 07:29:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 9116441 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 76217BF29F for ; Wed, 18 May 2016 07:33:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 93864202F0 for ; Wed, 18 May 2016 07:33:38 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A4F8F202AE for ; Wed, 18 May 2016 07:33:37 +0000 (UTC) Received: from localhost ([::1]:43401 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b2vz6-0003bD-Rv for patchwork-qemu-devel@patchwork.kernel.org; Wed, 18 May 2016 03:33:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49495) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b2vvJ-0000jW-9l for qemu-devel@nongnu.org; Wed, 18 May 2016 03:29:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b2vvC-0007Dc-9z for qemu-devel@nongnu.org; Wed, 18 May 2016 03:29:40 -0400 Received: from mail-oi0-x244.google.com ([2607:f8b0:4003:c06::244]:35505) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b2vvC-0007DU-3A for qemu-devel@nongnu.org; Wed, 18 May 2016 03:29:34 -0400 Received: by mail-oi0-x244.google.com with SMTP id w198so8037469oiw.2 for ; Wed, 18 May 2016 00:29:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=bwpkDt3ZD/IzG3CFJF1dR8XFdkkvl4iTKT7TBYPiaGQ=; b=rERjrzEQtBY6GFZpUoHDd0L4aGmZ0vEoloScFZhGkVlUNUwrGvp6SUbRceyGVKrXYm PciE7V9UU/4YcPDiMXIOYX+O4vb6tMeei1d6fbj99vBvee19/rr6ZE+3tP50ojZGxtmz KJZMP7EeWkZ93yC+XwQ7YD28BCTuiv5mGDzbsWMQEwKOPVwZkifDhBuqHqUPF5i9eQ/p gCAj76e0Uq2hKkNcI93TyYsjqRDOLapB1fE4UGY9M1hctNTZrIF7xRwimp4VHU7inTwj NNTJODs7QBOHIF1arLH0Afi5+U8UVOgL6csRSIbEexv23icMjFrUgd91Ew6jnCbDKKww eBxw== 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:subject:date:message-id :in-reply-to:references; bh=bwpkDt3ZD/IzG3CFJF1dR8XFdkkvl4iTKT7TBYPiaGQ=; b=h3Wv5GL1TUGwHtjlXcNFA22IQnt0st6yOra7kCII3T+YCebdzoM9RVOspknFH026j6 O0IraC/0dK6y77DKYJmvlqlfmrbYD5DkVlzfmThDpvIvoDYr8KOKUC+89akIK6WVVPf/ pOvThzY0dg36rbq3rxf8fG567bZCZuL0bsXolaFo8trb8oK85csnsmsV1MZG9xPX2zSP 77LCLSl25EfOhq+iM62sM46Ayv7+a8ohHphE41fVIex1W9mdWG2vc6slEDZXsx53jpcV ohP6BT8vDzs6V0bE64FQbcdFynkLo0uLGHAyVJ46HJcOU4Ccg3Mib6DtyzutAqHtQObx TEDg== X-Gm-Message-State: AOPr4FWv1BrNaLnAuPPMY011WXsOQesOpZwismWtukGd4iXYQxfFLNZScm8N02dPYgTh1g== X-Received: by 10.202.236.16 with SMTP id k16mr3207147oih.132.1463556573600; Wed, 18 May 2016 00:29:33 -0700 (PDT) Received: from serve.minyard.net ([108.19.215.157]) by smtp.gmail.com with ESMTPSA id 90sm1953629otx.14.2016.05.18.00.29.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 May 2016 00:29:32 -0700 (PDT) Received: from t430.minyard.net (unknown [IPv6:2001:470:b8f6:1b:118:a7b5:8fb4:e42a]) by serve.minyard.net (Postfix) with ESMTPA id 06A43199F; Wed, 18 May 2016 02:29:30 -0500 (CDT) Received: by t430.minyard.net (Postfix, from userid 1000) id 07C57300554; Wed, 18 May 2016 02:29:27 -0500 (CDT) From: minyard@acm.org To: Igor Mammedov , "Michael S . Tsirkin" , Paolo Bonzini , qemu-devel@nongnu.org, minyard@acm.org, cminyard@mvista.com Date: Wed, 18 May 2016 02:29:23 -0500 Message-Id: <1463556565-3947-5-git-send-email-minyard@acm.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1463556565-3947-1-git-send-email-minyard@acm.org> References: <1463556565-3947-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::244 Subject: [Qemu-devel] [PATCH v4 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: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 | 104 +++++++++++++++++++++++++++++++++++++++++++++++ hw/smbios/noipmi.c | 14 +++++++ hw/smbios/smbios.c | 2 + include/hw/smbios/ipmi.h | 15 +++++++ 5 files changed, 137 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/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..257217d --- /dev/null +++ b/hw/smbios/ipmi.c @@ -0,0 +1,104 @@ +/* + * 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; +} + +static void search_for_ipmi_dev(BusState *bus) +{ + BusChild *kid; + + QTAILQ_FOREACH(kid, &bus->children, sibling) { + DeviceState *dev = kid->child; + Object *obj = object_dynamic_cast(OBJECT(dev), TYPE_IPMI_INTERFACE); + BusState *childbus; + + if (obj) { + IPMIInterface *ii; + IPMIInterfaceClass *iic; + IPMIFwInfo info; + + ii = IPMI_INTERFACE(obj); + iic = IPMI_INTERFACE_GET_CLASS(obj); + memset(&info, 0, sizeof(info)); + iic->get_fwinfo(ii, &info); + ipmi_encode_one_smbios(&info); + continue; + } + + QLIST_FOREACH(childbus, &dev->child_bus, sibling) { + search_for_ipmi_dev(childbus); + } + } +} + +void smbios_build_type_38_table(void) +{ + BusState *bus; + + bus = sysbus_get_default(); + if (bus) { + search_for_ipmi_dev(bus); + } +} 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 */