From patchwork Mon Jan 26 13:28:37 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 43758 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f72.google.com (mail-la0-f72.google.com [209.85.215.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3A28A20D5D for ; Mon, 26 Jan 2015 13:29:35 +0000 (UTC) Received: by mail-la0-f72.google.com with SMTP id gq15sf4264249lab.3 for ; Mon, 26 Jan 2015 05:29:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=2DZxCMaxCgP0OlHNUBZdYYWEsf/JEJfjINemsefIwiQ=; b=kImNdipS0crKReu1DR2BpPGwoLWC/g/XsIKysiOR1TKHcpY2E6GkpQ72YzlD1BIr04 R1hmBCS77Ov9mVQNDaxb5Kh8J8XrY9aPcITEvrgMtFpM6fHpsx3+Xp9xe/1X28t/1b6+ 8UFrSgDkzvrF5DxGgUMjcRQZGA+2WBBPdC2UEA8ZpkcKieIHD7CmWUryjCR38n5/Br/k zM+SPPA9764cvMhd259v2K4K+WPOxQm33O8WhgqynBJvVKMQ5mJxeMZKn7p69uNye6D4 QiUnKoJR3RsVF1IUYeoYxmcUEwoXI6nir7qGj1SZLrST8uQfugwvyPB0Kc224yM0f343 Qg/w== X-Gm-Message-State: ALoCoQkcU8cBbValrmwTOSv9UBJUPP0d6smXw72LWdBrBgpYfQT8OfuOYuFIzuT2s9/CNYV9USSZ X-Received: by 10.112.175.10 with SMTP id bw10mr1320075lbc.7.1422278974152; Mon, 26 Jan 2015 05:29:34 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.25.201 with SMTP id e9ls87754lag.67.gmail; Mon, 26 Jan 2015 05:29:33 -0800 (PST) X-Received: by 10.152.5.226 with SMTP id v2mr21174025lav.34.1422278973913; Mon, 26 Jan 2015 05:29:33 -0800 (PST) Received: from mail-lb0-f181.google.com (mail-lb0-f181.google.com. [209.85.217.181]) by mx.google.com with ESMTPS id df3si209399lac.106.2015.01.26.05.29.33 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 26 Jan 2015 05:29:33 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.181 as permitted sender) client-ip=209.85.217.181; Received: by mail-lb0-f181.google.com with SMTP id u10so7498633lbd.12 for ; Mon, 26 Jan 2015 05:29:33 -0800 (PST) X-Received: by 10.152.5.226 with SMTP id v2mr21174016lav.34.1422278973799; Mon, 26 Jan 2015 05:29:33 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.35.133 with SMTP id h5csp780309lbj; Mon, 26 Jan 2015 05:29:32 -0800 (PST) X-Received: by 10.68.190.5 with SMTP id gm5mr15220472pbc.164.1422278971941; Mon, 26 Jan 2015 05:29:31 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id he8si12124479pac.236.2015.01.26.05.29.31; Mon, 26 Jan 2015 05:29:31 -0800 (PST) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755003AbbAZN31 (ORCPT + 28 others); Mon, 26 Jan 2015 08:29:27 -0500 Received: from mail-wi0-f182.google.com ([209.85.212.182]:48236 "EHLO mail-wi0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753771AbbAZN2z (ORCPT ); Mon, 26 Jan 2015 08:28:55 -0500 Received: by mail-wi0-f182.google.com with SMTP id n3so9705833wiv.3 for ; Mon, 26 Jan 2015 05:28:54 -0800 (PST) X-Received: by 10.180.20.50 with SMTP id k18mr32948565wie.31.1422278934057; Mon, 26 Jan 2015 05:28:54 -0800 (PST) Received: from khorivan.itg.ti.com ([195.238.92.128]) by mx.google.com with ESMTPSA id tc2sm13921553wic.21.2015.01.26.05.28.52 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 26 Jan 2015 05:28:53 -0800 (PST) From: Ivan Khoronzhuk To: linux-kernel@vger.kernel.org, ard.biesheuvel@linaro.org Cc: dmidecode-devel@nongnu.org, grant.likely@linaro.org, leif.lindholm@linaro.org, matt.fleming@intel.com, Ivan Khoronzhuk Subject: [Patch v2 1/2] firmware: dmi_scan: add symbol to get SMBIOS entry area Date: Mon, 26 Jan 2015 15:28:37 +0200 Message-Id: <1422278918-31477-2-git-send-email-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1422278918-31477-1-git-send-email-ivan.khoronzhuk@linaro.org> References: <1422278918-31477-1-git-send-email-ivan.khoronzhuk@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ivan.khoronzhuk@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.181 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , There are situations when code needs to access SMBIOS entry table area. For example, to pass it via sysfs to userspace when it's not allowed to get SMBIOS info via /dev/mem. Signed-off-by: Ivan Khoronzhuk Reviewed-by: Ard Biesheuvel --- drivers/firmware/dmi_scan.c | 26 ++++++++++++++++++++++++++ include/linux/dmi.h | 3 +++ 2 files changed, 29 insertions(+) diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c index 420c8d8..d94c6b7 100644 --- a/drivers/firmware/dmi_scan.c +++ b/drivers/firmware/dmi_scan.c @@ -113,6 +113,8 @@ static void dmi_table(u8 *buf, int len, int num, } } +static unsigned char smbios_header[32]; +static int smbios_header_size; static phys_addr_t dmi_base; static u16 dmi_len; static u16 dmi_num; @@ -474,6 +476,8 @@ static int __init dmi_present(const u8 *buf) if (memcmp(buf, "_SM_", 4) == 0 && buf[5] < 32 && dmi_checksum(buf, buf[5])) { smbios_ver = get_unaligned_be16(buf + 6); + smbios_header_size = buf[5]; + memcpy(smbios_header, buf, smbios_header_size); /* Some BIOS report weird SMBIOS version, fix that up */ switch (smbios_ver) { @@ -505,6 +509,8 @@ static int __init dmi_present(const u8 *buf) pr_info("SMBIOS %d.%d present.\n", dmi_ver >> 8, dmi_ver & 0xFF); } else { + smbios_header_size = 15; + memcpy(smbios_header, buf, smbios_header_size); dmi_ver = (buf[14] & 0xF0) << 4 | (buf[14] & 0x0F); pr_info("Legacy DMI %d.%d present.\n", @@ -531,6 +537,8 @@ static int __init dmi_smbios3_present(const u8 *buf) dmi_ver &= 0xFFFFFF; dmi_len = get_unaligned_le32(buf + 12); dmi_base = get_unaligned_le64(buf + 16); + smbios_header_size = buf[6]; + memcpy(smbios_header, buf, smbios_header_size); /* * The 64-bit SMBIOS 3.0 entry point no longer has a field @@ -944,3 +952,21 @@ void dmi_memdev_name(u16 handle, const char **bank, const char **device) } } EXPORT_SYMBOL_GPL(dmi_memdev_name); + +/** + * dmi_get_smbios_entry_area - copy SMBIOS entry point area to array. + * @size - pointer to assign actual size of SMBIOS entry point area. + * + * returns NULL if table is not available, otherwise returns pointer on + * SMBIOS entry point area array. + */ +const u8 *dmi_get_smbios_entry_area(int *size) +{ + if (!smbios_header_size || !dmi_available) + return NULL; + + *size = smbios_header_size; + + return smbios_header; +} +EXPORT_SYMBOL_GPL(dmi_get_smbios_entry_area); diff --git a/include/linux/dmi.h b/include/linux/dmi.h index f820f0a..8e1a28d 100644 --- a/include/linux/dmi.h +++ b/include/linux/dmi.h @@ -109,6 +109,7 @@ extern int dmi_walk(void (*decode)(const struct dmi_header *, void *), void *private_data); extern bool dmi_match(enum dmi_field f, const char *str); extern void dmi_memdev_name(u16 handle, const char **bank, const char **device); +const u8 *dmi_get_smbios_entry_area(int *size); #else @@ -140,6 +141,8 @@ static inline void dmi_memdev_name(u16 handle, const char **bank, const char **device) { } static inline const struct dmi_system_id * dmi_first_match(const struct dmi_system_id *list) { return NULL; } +static inline const u8 *dmi_get_smbios_entry_area(int *size) + { return NULL; } #endif