From patchwork Tue Sep 22 00:21:25 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 53991 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f198.google.com (mail-lb0-f198.google.com [209.85.217.198]) by patches.linaro.org (Postfix) with ESMTPS id 8E02022B1E for ; Tue, 22 Sep 2015 00:24:04 +0000 (UTC) Received: by lbcao8 with SMTP id ao8sf43659240lbc.1 for ; Mon, 21 Sep 2015 17:24:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:subject:date:message-id :in-reply-to:references:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:cc:mime-version :content-type:content-transfer-encoding:sender:errors-to :x-original-sender:x-original-authentication-results:mailing-list; bh=DW0eZD1y2tV4QPCxCBgn2OsCZ6hD5dnsXiQWcvKucfo=; b=XdFFgVyoatIWN3gyeAzRX3ndt5FwoJvyfkRBMblrl+52/7NUyFTlfREYTzX5dUkyfl vtX2wQ35LJ4+l2+3+6EHq/I70sC+ryXTGfSXUwVK/kMFG8JER0wtHJTEarnuTz/876ad LLJrKO3w+YGRFMDC1tIV9S4TMBv9Y0I2dadIczUhRIBk59dZS/a4n7KzKg3+0LJ4n7xE IYYIZy4jvBTHxAir+o0yFdtW6CpqTpWuquKQoFWWC70WmMfazV8adAKcfZJLqdHNORZ4 0+JoZn5dhMpU0BR4HhdkmKGsdBc+5FHT+bE6koH+79pSJk0PyYAwzNKpsycUUMj6otMY FZvA== X-Gm-Message-State: ALoCoQkM4uX7gvGj1kmKr+QOg5mCnfW0g+4HAzcTN2LSIgqi7pSSB2lsen1jLUFWqsYbYzSoLCZP X-Received: by 10.112.63.165 with SMTP id h5mr3805552lbs.18.1442881443449; Mon, 21 Sep 2015 17:24:03 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.224.164 with SMTP id rd4ls531825lac.99.gmail; Mon, 21 Sep 2015 17:24:03 -0700 (PDT) X-Received: by 10.112.147.10 with SMTP id tg10mr8876374lbb.58.1442881443316; Mon, 21 Sep 2015 17:24:03 -0700 (PDT) Received: from mail-la0-f43.google.com (mail-la0-f43.google.com. [209.85.215.43]) by mx.google.com with ESMTPS id ut6si9208192lbc.67.2015.09.21.17.24.03 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Sep 2015 17:24:03 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.43 as permitted sender) client-ip=209.85.215.43; Received: by lanb10 with SMTP id b10so78076479lan.3 for ; Mon, 21 Sep 2015 17:24:03 -0700 (PDT) X-Received: by 10.112.151.106 with SMTP id up10mr8774338lbb.106.1442881443190; Mon, 21 Sep 2015 17:24:03 -0700 (PDT) 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.59.35 with SMTP id w3csp178902lbq; Mon, 21 Sep 2015 17:24:02 -0700 (PDT) X-Received: by 10.194.158.68 with SMTP id ws4mr28960490wjb.25.1442881442350; Mon, 21 Sep 2015 17:24:02 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id et11si34786177wjc.120.2015.09.21.17.24.02 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Sep 2015 17:24:02 -0700 (PDT) Received-SPF: pass (google.com: 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; 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 1ZeBLy-0001Q4-Gi; Tue, 22 Sep 2015 00:22:38 +0000 Received: from mail-pa0-f44.google.com ([209.85.220.44]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZeBLd-0001AW-Gw for linux-arm-kernel@lists.infradead.org; Tue, 22 Sep 2015 00:22:18 +0000 Received: by padhy16 with SMTP id hy16so130603517pad.1 for ; Mon, 21 Sep 2015 17:21:56 -0700 (PDT) X-Received: by 10.68.113.37 with SMTP id iv5mr27699182pbb.2.1442881316752; Mon, 21 Sep 2015 17:21:56 -0700 (PDT) Received: from localhost.localdomain ([70.35.39.2]) by smtp.gmail.com with ESMTPSA id xv12sm26924984pac.38.2015.09.21.17.21.53 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 21 Sep 2015 17:21:56 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, leif.lindholm@linaro.org, mark.rutland@arm.com, catalin.marinas@arm.com, will.deacon@arm.com, msalter@redhat.com Subject: [PATCH v3 3/6] efi: move FDT handling to separate object file Date: Mon, 21 Sep 2015 17:21:25 -0700 Message-Id: <1442881288-13962-4-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1442881288-13962-1-git-send-email-ard.biesheuvel@linaro.org> References: <1442881288-13962-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150921_172217_608136_56B61F62 X-CRM114-Status: GOOD ( 23.60 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.220.44 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.220.44 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 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: Ard Biesheuvel MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ard.biesheuvel@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.215.43 as permitted sender) smtp.mailfrom=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 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 --- 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(-) diff --git a/drivers/firmware/efi/Makefile b/drivers/firmware/efi/Makefile index 6fd3da938717..d9140208fc1c 100644 --- a/drivers/firmware/efi/Makefile +++ b/drivers/firmware/efi/Makefile @@ -9,3 +9,4 @@ obj-$(CONFIG_UEFI_CPER) += cper.o obj-$(CONFIG_EFI_RUNTIME_MAP) += runtime-map.o obj-$(CONFIG_EFI_RUNTIME_WRAPPERS) += runtime-wrappers.o obj-$(CONFIG_EFI_STUB) += libstub/ +obj-$(CONFIG_EFI_PARAMS_FROM_FDT) += efi-fdt.o diff --git a/drivers/firmware/efi/efi-fdt.c b/drivers/firmware/efi/efi-fdt.c new file mode 100644 index 000000000000..8f3ce66e2b02 --- /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 f38384b13254..3e1671ffd6ab 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c @@ -20,8 +20,6 @@ #include #include #include -#include -#include #include #include @@ -468,88 +466,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",