From patchwork Tue Dec 22 16:53:41 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 58948 Delivered-To: patch@linaro.org Received: by 10.112.89.199 with SMTP id bq7csp3364734lbb; Tue, 22 Dec 2015 09:13:31 -0800 (PST) X-Received: by 10.31.151.200 with SMTP id z191mr15396547vkd.57.1450804411846; Tue, 22 Dec 2015 09:13:31 -0800 (PST) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id g85si11098293vki.98.2015.12.22.09.13.31 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 22 Dec 2015 09:13:31 -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 Received: from localhost ([::1]:51855 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aBQV7-0005ut-6p for patch@linaro.org; Tue, 22 Dec 2015 12:13:29 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33655) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aBQC5-0006se-Hy for qemu-devel@nongnu.org; Tue, 22 Dec 2015 11:53:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aBQC0-0000o2-Hi for qemu-devel@nongnu.org; Tue, 22 Dec 2015 11:53:49 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45448) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aBQC0-0000nt-6P for qemu-devel@nongnu.org; Tue, 22 Dec 2015 11:53:44 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id C02F1693C8; Tue, 22 Dec 2015 16:53:43 +0000 (UTC) Received: from redhat.com (vpn1-5-205.ams2.redhat.com [10.36.5.205]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id tBMGrgng001382; Tue, 22 Dec 2015 11:53:42 -0500 Date: Tue, 22 Dec 2015 18:53:41 +0200 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1450803119-4223-22-git-send-email-mst@redhat.com> References: <1450803119-4223-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1450803119-4223-1-git-send-email-mst@redhat.com> X-Mutt-Fcc: =sent X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Peter Maydell , Corey Minyard Subject: [Qemu-devel] [PULL 21/55] ipmi: Add a firmware configuration repository 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 a way for IPMI devices to register their firmware information with the IPMI subsystem so that various firmware entities can pull that information later for adding to firmware tables. Signed-off-by: Corey Minyard Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/ipmi/ipmi.h | 35 +++++++++++++++++++++++++++++++++++ hw/ipmi/ipmi.c | 27 +++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) -- MST diff --git a/include/hw/ipmi/ipmi.h b/include/hw/ipmi/ipmi.h index e4f7738..32bac0f 100644 --- a/include/hw/ipmi/ipmi.h +++ b/include/hw/ipmi/ipmi.h @@ -168,6 +168,41 @@ typedef struct IPMIBmcClass { */ void ipmi_bmc_find_and_link(Object *obj, Object **bmc); +/* + * Used for transferring information to interfaces that add + * entries to firmware tables. + */ +typedef struct IPMIFwInfo { + const char *interface_name; + int interface_type; + uint8_t ipmi_spec_major_revision; + uint8_t ipmi_spec_minor_revision; + uint8_t i2c_slave_address; + uint32_t uuid; + + uint64_t base_address; + uint64_t register_length; + uint8_t register_spacing; + enum { + IPMI_MEMSPACE_IO, + IPMI_MEMSPACE_MEM32, + IPMI_MEMSPACE_MEM64, + IPMI_MEMSPACE_SMBUS + } memspace; + + int interrupt_number; + enum { + IPMI_LEVEL_IRQ, + IPMI_EDGE_IRQ + } irq_type; + + const char *acpi_parent; +} IPMIFwInfo; + +void ipmi_add_fwinfo(IPMIFwInfo *info, Error **errp); +IPMIFwInfo *ipmi_first_fwinfo(void); +IPMIFwInfo *ipmi_next_fwinfo(IPMIFwInfo *current); + #ifdef IPMI_DEBUG #define ipmi_debug(fs, ...) \ fprintf(stderr, "IPMI (%s): " fs, __func__, ##__VA_ARGS__) diff --git a/hw/ipmi/ipmi.c b/hw/ipmi/ipmi.c index 7d17469..52aba1e 100644 --- a/hw/ipmi/ipmi.c +++ b/hw/ipmi/ipmi.c @@ -123,3 +123,30 @@ static void ipmi_register_types(void) } type_init(ipmi_register_types) + +static IPMIFwInfo *ipmi_fw_info; +static unsigned int ipmi_fw_info_len; + +static uint32_t current_uuid = 1; + +void ipmi_add_fwinfo(IPMIFwInfo *info, Error **errp) +{ + info->uuid = current_uuid++; + ipmi_fw_info = g_realloc(ipmi_fw_info, + sizeof(*ipmi_fw_info) * (ipmi_fw_info_len + 1)); + ipmi_fw_info[ipmi_fw_info_len] = *info; +} + +IPMIFwInfo *ipmi_first_fwinfo(void) +{ + return ipmi_fw_info; +} + +IPMIFwInfo *ipmi_next_fwinfo(IPMIFwInfo *current) +{ + current++; + if (current >= &ipmi_fw_info[ipmi_fw_info_len]) { + return NULL; + } + return current; +}