From patchwork Tue Nov 12 16:33:15 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 290716 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 3234F2C0097 for ; Wed, 13 Nov 2013 03:41:51 +1100 (EST) Received: from localhost ([::1]:43895 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VgH2D-0007VR-CU for incoming@patchwork.ozlabs.org; Tue, 12 Nov 2013 11:41:49 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58683) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VgGuN-0004ip-Cf for qemu-devel@nongnu.org; Tue, 12 Nov 2013 11:33:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VgGu6-0007O1-JH for qemu-devel@nongnu.org; Tue, 12 Nov 2013 11:33:43 -0500 Received: from mail-oa0-x230.google.com ([2607:f8b0:4003:c02::230]:52505) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VgGu6-0007Nw-DV for qemu-devel@nongnu.org; Tue, 12 Nov 2013 11:33:26 -0500 Received: by mail-oa0-f48.google.com with SMTP id n16so3228040oag.7 for ; Tue, 12 Nov 2013 08:33:26 -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=LrddiZE6un4aL0mcqyBnluMA5J/BVkD2hx7pp2drIgs=; b=xIXQAi/e9G9IpNzruMhM5QDhdUmLKGpI7WzniENJjbhvn2htv2edOBW54UB6R81AjC JImKS5/xRZNyzXI6s9lvloWG3X5RerDfW6xBSP3wnKqG0yaxq7HUKKnomG/zdGJyha5P RUzGqgkZGspcIO0RF0UTG1lz6MlUI+ChwCQFfMb/ij713hW9Hd/ON0OorZTmcH/yBOcT a3wvzbCRqeoK35w0oIZ6gVt2v5p9TXsu5cdSQ18OE94ZFRRCuW6SsRd2GV3QSjwdOaQ3 2zwD/TPnkHntFfruA1t4AVd6e2E7awEkk5MmICXCX5C97aiSZIsqg/rlIA/F1wagDg2K Y3qg== X-Received: by 10.60.36.195 with SMTP id s3mr1509460oej.104.1384274005969; Tue, 12 Nov 2013 08:33:25 -0800 (PST) Received: from t430.minyard.home (pool-173-57-152-84.dllstx.fios.verizon.net. [173.57.152.84]) by mx.google.com with ESMTPSA id b5sm33785635obj.8.2013.11.12.08.33.24 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Nov 2013 08:33:25 -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 rACGXNFv016662; Tue, 12 Nov 2013 10:33:23 -0600 Received: (from cminyard@localhost) by t430.minyard.home (8.14.7/8.14.7/Submit) id rACGXNMT016661; Tue, 12 Nov 2013 10:33:23 -0600 From: Corey Minyard To: qemu-devel@nongnu.org Date: Tue, 12 Nov 2013 10:33:15 -0600 Message-Id: <1384273995-16486-17-git-send-email-cminyard@mvista.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1384273995-16486-1-git-send-email-cminyard@mvista.com> References: <1384273995-16486-1-git-send-email-cminyard@mvista.com> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:4003:c02::230 Cc: Bret Ketchum , Corey Minyard , =?UTF-8?q?Andreas=20F=C3=A4rber?= , "Michael S. Tsirkin" Subject: [Qemu-devel] [PATCH 16/16] 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Add an IPMI table entry to the SMBIOS. --- hw/ipmi/isa_ipmi.c | 29 +++++++++++++++++++++++++++++ include/hw/i386/smbios.h | 14 ++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/hw/ipmi/isa_ipmi.c b/hw/ipmi/isa_ipmi.c index b38c846..e40ca90 100644 --- a/hw/ipmi/isa_ipmi.c +++ b/hw/ipmi/isa_ipmi.c @@ -27,6 +27,7 @@ #include "qemu/timer.h" #include "sysemu/char.h" #include "sysemu/sysemu.h" +#include "hw/i386/smbios.h" #include "ipmi.h" /* This is the type the user specifies on the -device command line */ @@ -36,13 +37,36 @@ typedef struct ISAIPMIDevice { ISADevice dev; char *interface; + int intftype; uint32_t iobase; uint32_t isairq; uint8_t slave_addr; + uint8_t version; CharDriverState *chr; IPMIInterface *intf; } ISAIPMIDevice; +static void ipmi_encode_smbios(ISAIPMIDevice *info) +{ + struct smbios_type_38 smb38; + + smb38.header.type = 38; + smb38.header.length = sizeof(smb38); + smb38.header.handle = cpu_to_le16(0x3000); + smb38.interface_type = info->intftype; + smb38.ipmi_spec_revision = info->version; + smb38.i2c_slave_address = info->slave_addr; + smb38.nv_storage_device_address = 0; + + /* or 1 to set it to I/O space */ + smb38.base_address = cpu_to_le64(info->iobase | 1); + + /* 1-byte boundaries, addr bit0=0, level triggered irq */ + smb38.base_address_modifier = 1; + smb38.interrupt_number = info->isairq; + smbios_table_entry_add((struct smbios_structure_header *) &smb38); +} + static void ipmi_isa_realizefn(DeviceState *dev, Error **errp) { ISADevice *isadev = ISA_DEVICE(dev); @@ -50,6 +74,7 @@ static void ipmi_isa_realizefn(DeviceState *dev, Error **errp) char typename[20]; Object *intfobj; IPMIInterface *intf; + IPMIInterfaceClass *intfk; Object *bmcobj; IPMIBmc *bmc; int rc; @@ -69,10 +94,13 @@ static void ipmi_isa_realizefn(DeviceState *dev, Error **errp) TYPE_IPMI_INTERFACE_PREFIX "%s", isa->interface); intfobj = object_new(typename); intf = IPMI_INTERFACE(intfobj); + intfk = IPMI_INTERFACE_GET_CLASS(intf); bmc->intf = intf; intf->bmc = bmc; intf->io_base = isa->iobase; intf->slave_addr = isa->slave_addr; + isa->intftype = intfk->smbios_type; + isa->version = 0x20; /* Version 2.0 */ rc = ipmi_interface_init(intf); if (rc) { error_setg(errp, "Error initializing IPMI interface: %d\n", rc); @@ -106,6 +134,7 @@ static void ipmi_isa_realizefn(DeviceState *dev, Error **errp) qdev_set_legacy_instance_id(dev, intf->io_base, intf->io_length); isa_register_ioport(isadev, &intf->io, intf->io_base); + ipmi_encode_smbios(isa); } static void ipmi_isa_reset(DeviceState *dev) diff --git a/include/hw/i386/smbios.h b/include/hw/i386/smbios.h index b08ec71..8133faa 100644 --- a/include/hw/i386/smbios.h +++ b/include/hw/i386/smbios.h @@ -29,6 +29,8 @@ struct smbios_structure_header { uint16_t handle; } QEMU_PACKED; +int smbios_table_entry_add(struct smbios_structure_header *entry); + /* SMBIOS type 0 - BIOS Information */ struct smbios_type_0 { struct smbios_structure_header header; @@ -155,6 +157,18 @@ struct smbios_type_32 { uint8_t boot_status; } QEMU_PACKED; +/* 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; + /* SMBIOS type 127 -- End-of-table */ struct smbios_type_127 { struct smbios_structure_header header;