From patchwork Sat Feb 20 01:13:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Daney X-Patchwork-Id: 62444 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp106398lbl; Fri, 19 Feb 2016 17:15:49 -0800 (PST) X-Received: by 10.98.71.92 with SMTP id u89mr22244450pfa.122.1455930949616; Fri, 19 Feb 2016 17:15:49 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id w23si19888546pfa.234.2016.02.19.17.15.49 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 Feb 2016 17:15:49 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org; dkim=neutral (body hash did not verify) header.i=@gmail.com; dmarc=fail (p=NONE dis=NONE) header.from=gmail.com Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aWw7v-00027T-4H; Sat, 20 Feb 2016 01:14:27 +0000 Received: from mail-pa0-x235.google.com ([2607:f8b0:400e:c03::235]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aWw7Q-0001oL-Fs for linux-arm-kernel@lists.infradead.org; Sat, 20 Feb 2016 01:13:59 +0000 Received: by mail-pa0-x235.google.com with SMTP id fy10so58845913pac.1 for ; Fri, 19 Feb 2016 17:13:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=AnlI1KxszWMFqFGBU2IfTHppPX5dNMnQ2FyidpcIC1I=; b=hviQ2LlbdxYNBs5tgQoJVfYXuPgFBLqF9s0i7hd5EwsauhrryZCA+YETWi2Hm/sXLO LN/nmr3PA2wCYOSvTW+SPhC7fy/dafD4SkUmsVUXhOo1iKHnB3AEktaE72myRiKa/qeT izZOcLIXi/L0VwcyO1KAcioGuyxyJeyEenIRsxVoG7AXZeykskUyVkSBhvsFWwtdt8pO EtAGLr6/lKHhr+8Ew09WYUCOHog7ETWrJ1N9dju7ABvSD714k7zdS4eI/tbzeZH60I2j 79XW4DPaIjdM8ZLetzNTaGJ+NXHZ+dWKUzK+Oj2chkKV4uXc9rMQ/8Iylm5ahQQBTxSL bXEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=AnlI1KxszWMFqFGBU2IfTHppPX5dNMnQ2FyidpcIC1I=; b=duhh7McnEYH9nMhQKSy8tDFbQZ6bWqFMAnJyLeyXiBFOduKnAsZrhGOuEtJ0bzuAhL vv/B5vxbgWg3QS44Z/5+zTDURLRbwYREV4z9ZUTr9aPW339NDYzdUDO1DxrX49Yf+R9X FynaGNwntH9lSIK24FARddWl7nCIPOnyTUdTcC+Gajm1YsAT+llAz5HjF0qNaocOAz14 lKAeBPBCzoNWFFBgb6RROVoqbydidASbVrI1gxYnRcFd78ZfKbMPgAGoXWK2Kg5B/XNv /z3pstAKaVQOO+1qsVokDXOP3unEJpBmUbp9k3zispWXaE7OeapjvoLl/Zt+i3xKOzSh ymlA== X-Gm-Message-State: AG10YOQiSusC61l/Dcs3dYO4sX1IO/quNMlxAYH39Idi53JrrYFxw2reQqTSuxu5RHgTeA== X-Received: by 10.66.242.17 with SMTP id wm17mr22085515pac.155.1455930814693; Fri, 19 Feb 2016 17:13:34 -0800 (PST) Received: from dl.caveonetworks.com ([64.2.3.194]) by smtp.gmail.com with ESMTPSA id ta2sm20451568pab.42.2016.02.19.17.13.28 (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 19 Feb 2016 17:13:31 -0800 (PST) Received: from dl.caveonetworks.com (localhost.localdomain [127.0.0.1]) by dl.caveonetworks.com (8.14.5/8.14.5) with ESMTP id u1K1DRM9005426; Fri, 19 Feb 2016 17:13:27 -0800 Received: (from ddaney@localhost) by dl.caveonetworks.com (8.14.5/8.14.5/Submit) id u1K1DRgo005425; Fri, 19 Feb 2016 17:13:27 -0800 From: David Daney To: Will Deacon , linux-arm-kernel@lists.infradead.org, Rob Herring , Pawel Moll , Mark Rutland , Ian Campbell , Kumar Gala , devicetree@vger.kernel.org, Ard Biesheuvel , Frank Rowand , Grant Likely , Catalin Marinas , Matt Fleming , linux-efi@vger.kernel.org, Ganapatrao Kulkarni , Robert Richter Subject: [PATCH v11 03/10] efi: move FDT handling to separate object file Date: Fri, 19 Feb 2016 17:13:12 -0800 Message-Id: <1455930799-5371-4-git-send-email-ddaney.cavm@gmail.com> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1455930799-5371-1-git-send-email-ddaney.cavm@gmail.com> References: <1455930799-5371-1-git-send-email-ddaney.cavm@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160219_171356_822089_49659F28 X-CRM114-Status: GOOD ( 23.60 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2607:f8b0:400e:c03:0:0:0:235 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (ddaney.cavm[at]gmail.com) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, David Daney MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org From: Ard Biesheuvel The EFI specific FDT handling is compiled conditionally, and is logically independent of the rest of efi.o. So move it to a separate file before making changes to it in subsequent patches. Acked-by: Matt Fleming Acked-by: Leif Lindholm Signed-off-by: Ard Biesheuvel [ rric: Ported to v4.5-rc1 ] Signed-off-by: Robert Richter Signed-off-by: David Daney --- drivers/firmware/efi/Makefile | 1 + drivers/firmware/efi/efi-fdt.c | 91 ++++++++++++++++++++++++++++++++++++++++++ drivers/firmware/efi/efi.c | 84 -------------------------------------- 3 files changed, 92 insertions(+), 84 deletions(-) create mode 100644 drivers/firmware/efi/efi-fdt.c -- 1.8.3.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/drivers/firmware/efi/Makefile b/drivers/firmware/efi/Makefile index 62e654f..bb7ec2f 100644 --- a/drivers/firmware/efi/Makefile +++ b/drivers/firmware/efi/Makefile @@ -18,6 +18,7 @@ obj-$(CONFIG_EFI_RUNTIME_MAP) += runtime-map.o obj-$(CONFIG_EFI_RUNTIME_WRAPPERS) += runtime-wrappers.o obj-$(CONFIG_EFI_STUB) += libstub/ obj-$(CONFIG_EFI_FAKE_MEMMAP) += fake_mem.o +obj-$(CONFIG_EFI_PARAMS_FROM_FDT) += efi-fdt.o arm-obj-$(CONFIG_EFI) := arm-init.o arm-runtime.o obj-$(CONFIG_ARM) += $(arm-obj-y) diff --git a/drivers/firmware/efi/efi-fdt.c b/drivers/firmware/efi/efi-fdt.c new file mode 100644 index 0000000..8f3ce66 --- /dev/null +++ b/drivers/firmware/efi/efi-fdt.c @@ -0,0 +1,91 @@ +/* + * Copyright (C) 2013 - 2015 Linaro Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include +#include +#include +#include + +#define UEFI_PARAM(name, prop, field) \ + { \ + { name }, \ + { prop }, \ + offsetof(struct efi_fdt_params, field), \ + FIELD_SIZEOF(struct efi_fdt_params, field) \ + } + +static __initdata struct { + const char name[32]; + const char propname[32]; + int offset; + int size; +} dt_params[] = { + UEFI_PARAM("System Table", "linux,uefi-system-table", system_table), + UEFI_PARAM("MemMap Address", "linux,uefi-mmap-start", mmap), + UEFI_PARAM("MemMap Size", "linux,uefi-mmap-size", mmap_size), + UEFI_PARAM("MemMap Desc. Size", "linux,uefi-mmap-desc-size", desc_size), + UEFI_PARAM("MemMap Desc. Version", "linux,uefi-mmap-desc-ver", desc_ver) +}; + +struct param_info { + int found; + void *params; +}; + +static int __init fdt_find_uefi_params(unsigned long node, const char *uname, + int depth, void *data) +{ + struct param_info *info = data; + const void *prop; + void *dest; + u64 val; + int i, len; + + if (depth != 1 || strcmp(uname, "chosen") != 0) + return 0; + + for (i = 0; i < ARRAY_SIZE(dt_params); i++) { + prop = of_get_flat_dt_prop(node, dt_params[i].propname, &len); + if (!prop) + return 0; + dest = info->params + dt_params[i].offset; + info->found++; + + val = of_read_number(prop, len / sizeof(u32)); + + if (dt_params[i].size == sizeof(u32)) + *(u32 *)dest = val; + else + *(u64 *)dest = val; + + if (efi_enabled(EFI_DBG)) + pr_info(" %s: 0x%0*llx\n", dt_params[i].name, + dt_params[i].size * 2, val); + } + return 1; +} + +int __init efi_get_fdt_params(struct efi_fdt_params *params) +{ + struct param_info info; + int ret; + + pr_info("Getting EFI parameters from FDT:\n"); + + info.found = 0; + info.params = params; + + ret = of_scan_flat_dt(fdt_find_uefi_params, &info); + if (!info.found) + pr_info("UEFI not found.\n"); + else if (!ret) + pr_err("Can't find '%s' in device tree!\n", + dt_params[info.found].name); + + return ret; +} diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c index 2cd37da..7c41c428 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c @@ -20,8 +20,6 @@ #include #include #include -#include -#include #include #include @@ -490,88 +488,6 @@ static int __init efi_load_efivars(void) device_initcall(efi_load_efivars); #endif -#ifdef CONFIG_EFI_PARAMS_FROM_FDT - -#define UEFI_PARAM(name, prop, field) \ - { \ - { name }, \ - { prop }, \ - offsetof(struct efi_fdt_params, field), \ - FIELD_SIZEOF(struct efi_fdt_params, field) \ - } - -static __initdata struct { - const char name[32]; - const char propname[32]; - int offset; - int size; -} dt_params[] = { - UEFI_PARAM("System Table", "linux,uefi-system-table", system_table), - UEFI_PARAM("MemMap Address", "linux,uefi-mmap-start", mmap), - UEFI_PARAM("MemMap Size", "linux,uefi-mmap-size", mmap_size), - UEFI_PARAM("MemMap Desc. Size", "linux,uefi-mmap-desc-size", desc_size), - UEFI_PARAM("MemMap Desc. Version", "linux,uefi-mmap-desc-ver", desc_ver) -}; - -struct param_info { - int found; - void *params; -}; - -static int __init fdt_find_uefi_params(unsigned long node, const char *uname, - int depth, void *data) -{ - struct param_info *info = data; - const void *prop; - void *dest; - u64 val; - int i, len; - - if (depth != 1 || strcmp(uname, "chosen") != 0) - return 0; - - for (i = 0; i < ARRAY_SIZE(dt_params); i++) { - prop = of_get_flat_dt_prop(node, dt_params[i].propname, &len); - if (!prop) - return 0; - dest = info->params + dt_params[i].offset; - info->found++; - - val = of_read_number(prop, len / sizeof(u32)); - - if (dt_params[i].size == sizeof(u32)) - *(u32 *)dest = val; - else - *(u64 *)dest = val; - - if (efi_enabled(EFI_DBG)) - pr_info(" %s: 0x%0*llx\n", dt_params[i].name, - dt_params[i].size * 2, val); - } - return 1; -} - -int __init efi_get_fdt_params(struct efi_fdt_params *params) -{ - struct param_info info; - int ret; - - pr_info("Getting EFI parameters from FDT:\n"); - - info.found = 0; - info.params = params; - - ret = of_scan_flat_dt(fdt_find_uefi_params, &info); - if (!info.found) - pr_info("UEFI not found.\n"); - else if (!ret) - pr_err("Can't find '%s' in device tree!\n", - dt_params[info.found].name); - - return ret; -} -#endif /* CONFIG_EFI_PARAMS_FROM_FDT */ - static __initdata char memory_type_name[][20] = { "Reserved", "Loader Code",