From patchwork Fri Jan 23 20:21:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 43695 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-we0-f197.google.com (mail-we0-f197.google.com [74.125.82.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 141AC218DB for ; Fri, 23 Jan 2015 20:22:27 +0000 (UTC) Received: by mail-we0-f197.google.com with SMTP id l61sf5317132wev.0 for ; Fri, 23 Jan 2015 12:22:26 -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=4j5pixGrb2jNSpqN8rUtSHOzb4m9Gr7FlfTHL3qmIWY=; b=cTi+3ArnDqz0W0C5Gk0cLMi9p5WiVHobSZgHYRsKgY/aiY48Do1w4y6wmN+QZSpgnR V0z0CKfCWh+NCD+15BpdFwDVnxIQLGmgJTXzjYWTxP9j8OnYfmBWsR6MXCDTkwKt4GuW e90rb6BVjEdHq5LT7MlQGqPxU9YwppZJKghaikx5isQ4zQByAQ7NidIjXLHLfRasgtOa vWzyg+njf3sx6i3xNrh32si61evKyif3NJU0LJh5Gh5PIi4aH6zcTDwCjBh9xlNpDnOt 2jIohpBeIKAuGNR2O5jOLrx98yhRWAgDulpnz3DqccykfYhrFOib0t/z+/A7jQ6Yzj8h QIuQ== X-Gm-Message-State: ALoCoQlSpMYdJAn3MHtlFig2+UkL2WwDMUSSNpcrCsXtQUeXOtVdhu27hULXoZuz8wNPCv/Ybmqo X-Received: by 10.180.108.197 with SMTP id hm5mr541554wib.4.1422044546290; Fri, 23 Jan 2015 12:22:26 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.203.134 with SMTP id kq6ls303626lac.36.gmail; Fri, 23 Jan 2015 12:22:26 -0800 (PST) X-Received: by 10.152.29.6 with SMTP id f6mr9428580lah.32.1422044546028; Fri, 23 Jan 2015 12:22:26 -0800 (PST) Received: from mail-lb0-f169.google.com (mail-lb0-f169.google.com. [209.85.217.169]) by mx.google.com with ESMTPS id ll1si2298397lac.41.2015.01.23.12.22.25 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Jan 2015 12:22:25 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.169 as permitted sender) client-ip=209.85.217.169; Received: by mail-lb0-f169.google.com with SMTP id f15so8975676lbj.0 for ; Fri, 23 Jan 2015 12:22:25 -0800 (PST) X-Received: by 10.112.30.71 with SMTP id q7mr9315189lbh.41.1422044545887; Fri, 23 Jan 2015 12:22:25 -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 h5csp15544lbj; Fri, 23 Jan 2015 12:22:24 -0800 (PST) X-Received: by 10.70.51.199 with SMTP id m7mr13936342pdo.111.1422044543909; Fri, 23 Jan 2015 12:22:23 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id wm4si3136752pbc.131.2015.01.23.12.22.22; Fri, 23 Jan 2015 12:22:23 -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 S1756589AbbAWUWM (ORCPT + 28 others); Fri, 23 Jan 2015 15:22:12 -0500 Received: from mail-wi0-f172.google.com ([209.85.212.172]:48413 "EHLO mail-wi0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756516AbbAWUWI (ORCPT ); Fri, 23 Jan 2015 15:22:08 -0500 Received: by mail-wi0-f172.google.com with SMTP id bs8so5341255wib.5 for ; Fri, 23 Jan 2015 12:22:07 -0800 (PST) X-Received: by 10.180.98.162 with SMTP id ej2mr7220842wib.39.1422044527148; Fri, 23 Jan 2015 12:22:07 -0800 (PST) Received: from khorivan.itg.ti.com (101-172-94-178.pool.ukrtel.net. [178.94.172.101]) by mx.google.com with ESMTPSA id dp8sm3151873wib.20.2015.01.23.12.22.04 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 23 Jan 2015 12:22:06 -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 1/2] firmware: dmi_scan: add symbol to get SMBIOS entry area Date: Fri, 23 Jan 2015 22:21:46 +0200 Message-Id: <1422044507-22982-2-git-send-email-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1422044507-22982-1-git-send-email-ivan.khoronzhuk@linaro.org> References: <1422044507-22982-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.169 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 --- drivers/firmware/dmi_scan.c | 34 ++++++++++++++++++++++++++++++++++ include/linux/dmi.h | 2 ++ 2 files changed, 36 insertions(+) diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c index 420c8d8..ae9204a 100644 --- a/drivers/firmware/dmi_scan.c +++ b/drivers/firmware/dmi_scan.c @@ -113,6 +113,7 @@ static void dmi_table(u8 *buf, int len, int num, } } +static unsigned char smbios_header[32]; static phys_addr_t dmi_base; static u16 dmi_len; static u16 dmi_num; @@ -474,6 +475,7 @@ 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); + memcpy(smbios_header, buf, buf[5]); /* Some BIOS report weird SMBIOS version, fix that up */ switch (smbios_ver) { @@ -505,6 +507,7 @@ static int __init dmi_present(const u8 *buf) pr_info("SMBIOS %d.%d present.\n", dmi_ver >> 8, dmi_ver & 0xFF); } else { + memcpy(smbios_header, buf, 15); dmi_ver = (buf[14] & 0xF0) << 4 | (buf[14] & 0x0F); pr_info("Legacy DMI %d.%d present.\n", @@ -531,6 +534,7 @@ 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); + memcpy(smbios_header, buf, buf[6]); /* * The 64-bit SMBIOS 3.0 entry point no longer has a field @@ -944,3 +948,33 @@ 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. + * @entry - pointer on array to read area in, current max size is 32 bytes. + * + * returns -ENODATA if table is not available, otherwise returns actual + * size of SMBIOS entry point area. + */ +int dmi_get_smbios_entry_area(char *table) +{ + int size = 0; + + if (!dmi_available) + return -ENODATA; + + if (memcmp(smbios_header, "_SM3_", 5) == 0) + size = smbios_header[6]; + else if (memcmp(smbios_header, "_SM_", 4) == 0) + size = smbios_header[5]; + else if (memcmp(smbios_header, "_DMI_", 5) == 0) + size = 15; + + memcpy(table, smbios_header, size); + + if (!size) + return -ENODATA; + + return size; +} +EXPORT_SYMBOL_GPL(dmi_get_smbios_entry_area); diff --git a/include/linux/dmi.h b/include/linux/dmi.h index f820f0a..7cae713 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); +int dmi_get_smbios_entry_area(char *table); #else @@ -140,6 +141,7 @@ 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 int dmi_get_smbios_entry_area(char *table) { return -ENODATA; } #endif