From patchwork Tue Nov 12 16:33:14 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 290714 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 C23952C00AB for ; Wed, 13 Nov 2013 03:40:36 +1100 (EST) Received: from localhost ([::1]:43885 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VgH10-0005mG-SU for incoming@patchwork.ozlabs.org; Tue, 12 Nov 2013 11:40:34 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58647) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VgGuK-0004iB-Cv for qemu-devel@nongnu.org; Tue, 12 Nov 2013 11:33:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VgGu6-0007NV-46 for qemu-devel@nongnu.org; Tue, 12 Nov 2013 11:33:40 -0500 Received: from mail-oa0-x234.google.com ([2607:f8b0:4003:c02::234]:48922) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VgGu5-0007ND-Vy for qemu-devel@nongnu.org; Tue, 12 Nov 2013 11:33:26 -0500 Received: by mail-oa0-f52.google.com with SMTP id o6so2932810oag.39 for ; Tue, 12 Nov 2013 08:33:25 -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=PG7UbRH0R+EUdcnLI7hlA8oTzLz0m/eoaWB7Dnvp1B4=; b=1IGNv6gHC2lTe/fSzpVs9N+pBZ6cR2J0Mk3GOlIcwflPXoDkbhJWTWO34HuSztJF4s KlOIL39EmbIXrVj4l7Rqy1E5+KTwLNof8eStT8Eh4uqRPamhIqme2WPzeMJjA8m6hM8H i3IsaZW6vYWGkST0TFv4XYyud9nCph18La4L+TyaFh74fzl3CDauXVFzEKFZogGz37lI B87l+FwORUY5kHUrRiOqWSI3vCUsN66AlUwTk2CFLVyD0fJnRDORNxpon2/RvwpT94FE HdeTZsEyU7tYUA9hiOGXlp9JetIGBKzpmIWuXJxFBCNn/SVOWT115vFGSpEX2VBzGrk9 0RFg== X-Received: by 10.182.60.41 with SMTP id e9mr31598007obr.8.1384274005515; 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 tz10sm33773511obc.10.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:24 -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 rACGXNLh016657; Tue, 12 Nov 2013 10:33:23 -0600 Received: (from cminyard@localhost) by t430.minyard.home (8.14.7/8.14.7/Submit) id rACGXMCE016656; Tue, 12 Nov 2013 10:33:22 -0600 From: Corey Minyard To: qemu-devel@nongnu.org Date: Tue, 12 Nov 2013 10:33:14 -0600 Message-Id: <1384273995-16486-16-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::234 Cc: Bret Ketchum , Corey Minyard , =?UTF-8?q?Andreas=20F=C3=A4rber?= , "Michael S. Tsirkin" Subject: [Qemu-devel] [PATCH 15/16] smbios: Add a function to directly add an 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 There was no way to directly add a table entry to the SMBIOS table, even though the BIOS supports this. So add a function to do this. This is in preparation for the IPMI handler adding it's SMBIOS table entry. Signed-off-by: Corey Minyard --- hw/i386/smbios.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/hw/i386/smbios.c b/hw/i386/smbios.c index d3f1ee6..9c53131 100644 --- a/hw/i386/smbios.c +++ b/hw/i386/smbios.c @@ -277,6 +277,33 @@ static void save_opt(const char **dest, QemuOpts *opts, const char *name) } } +int smbios_table_entry_add(struct smbios_structure_header *entry) +{ + struct smbios_table *table; + struct smbios_structure_header *header; + unsigned int size = entry->length; + + if (!smbios_entries) { + smbios_entries_len = sizeof(uint16_t); + smbios_entries = g_malloc0(smbios_entries_len); + } + smbios_entries = g_realloc(smbios_entries, smbios_entries_len + + sizeof(*table) + size); + table = (struct smbios_table *)(smbios_entries + smbios_entries_len); + table->header.type = SMBIOS_TABLE_ENTRY; + table->header.length = cpu_to_le16(sizeof(*table) + size); + + header = (struct smbios_structure_header *)(table->data); + memcpy(header, entry, size); + + smbios_check_collision(header->type, SMBIOS_TABLE_ENTRY); + + smbios_entries_len += sizeof(*table) + size; + (*(uint16_t *)smbios_entries) = + cpu_to_le16(le16_to_cpu(*(uint16_t *)smbios_entries) + 1); + return 0; +} + void smbios_entry_add(QemuOpts *opts) { Error *local_err = NULL;