From patchwork Wed Aug 26 08:06:28 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 52707 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 5F24622E8B for ; Wed, 26 Aug 2015 08:08:40 +0000 (UTC) Received: by lbcli1 with SMTP id li1sf59419657lbc.2 for ; Wed, 26 Aug 2015 01:08:39 -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=seymTJ/0BmCakvoMjEOQUF4oPbhlkTpA7sN9D0QCBS8=; b=VrG0TVAsVKR+B2nABntfP0vUMTIwSIVCSUCsDdyr+AfTR1Sp75/7Xjlj0dU7fDDunV YuDPwlpW3FOGGoiGG23aXrX7+9w+JsxK0/yhDJmw9I5DPs/8q9UTE9XapX7fJ+ofbaFH dhZxKzajT8swb9xvETbDS8iC/lYVLQoQIAbk3uQOScn+b3oNNTJQxfo/7Tb/X+fL6v+Q U2wssevVm/YmkEtPqRepqq9R80TTZP8tvsXNqAGAA6rgoESSd/O5NV2gck+JEC1V2NQK ofh3VENmYGv1XMy7rsOJNqiUSu9jnEICfAaxH22tdfQ7nJAaHYJWFjFu0uK2PJoj63of Vd4Q== X-Gm-Message-State: ALoCoQkO0DJFPev9FHk5Y7PZnYpE6krkAhoZk7DA8nSWqCS8LOgTZNz2JIBP+2km4XovIczd9bUA X-Received: by 10.113.3.8 with SMTP id bs8mr9611814lbd.23.1440576519364; Wed, 26 Aug 2015 01:08:39 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.185.67 with SMTP id fa3ls730623lac.76.gmail; Wed, 26 Aug 2015 01:08:39 -0700 (PDT) X-Received: by 10.112.168.41 with SMTP id zt9mr3861669lbb.25.1440576519207; Wed, 26 Aug 2015 01:08:39 -0700 (PDT) Received: from mail-la0-f50.google.com (mail-la0-f50.google.com. [209.85.215.50]) by mx.google.com with ESMTPS id x8si18179330lby.143.2015.08.26.01.08.39 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Aug 2015 01:08:39 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.50 as permitted sender) client-ip=209.85.215.50; Received: by lalv9 with SMTP id v9so113965364lal.0 for ; Wed, 26 Aug 2015 01:08:39 -0700 (PDT) X-Received: by 10.152.203.134 with SMTP id kq6mr29825737lac.106.1440576519054; Wed, 26 Aug 2015 01:08:39 -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.162.200 with SMTP id yc8csp3739709lbb; Wed, 26 Aug 2015 01:08:37 -0700 (PDT) X-Received: by 10.140.131.134 with SMTP id 128mr79053104qhd.44.1440576514720; Wed, 26 Aug 2015 01:08:34 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id d107si1589728qge.67.2015.08.26.01.08.34 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Aug 2015 01:08:34 -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 1ZUVjs-0007sr-Hv; Wed, 26 Aug 2015 08:07:20 +0000 Received: from mail-wi0-f178.google.com ([209.85.212.178]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZUVje-0007hM-Q9 for linux-arm-kernel@lists.infradead.org; Wed, 26 Aug 2015 08:07:07 +0000 Received: by wicja10 with SMTP id ja10so7201844wic.1 for ; Wed, 26 Aug 2015 01:06:44 -0700 (PDT) X-Received: by 10.194.78.164 with SMTP id c4mr54230627wjx.65.1440576404128; Wed, 26 Aug 2015 01:06:44 -0700 (PDT) Received: from localhost.localdomain (cag06-7-83-153-85-71.fbx.proxad.net. [83.153.85.71]) by smtp.gmail.com with ESMTPSA id gm20sm2569597wjc.17.2015.08.26.01.06.42 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 26 Aug 2015 01:06:43 -0700 (PDT) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, linux-efi@vger.kernel.org, leif.lindholm@linaro.org, catalin.marinas@arm.com, will.deacon@arm.com, mark.rutland@arm.com, msalter@redhat.com Subject: [PATCH v2 2/5] efi: move FDT handling to separate object file Date: Wed, 26 Aug 2015 10:06:28 +0200 Message-Id: <1440576391-25725-3-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1440576391-25725-1-git-send-email-ard.biesheuvel@linaro.org> References: <1440576391-25725-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150826_010707_043151_F6440DA8 X-CRM114-Status: GOOD ( 23.23 ) 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.212.178 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [209.85.212.178 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] -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders 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 , haojian.zhuang@linaro.org, Ganapatrao.Kulkarni@caviumnetworks.com, leo.yan@linaro.org 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.50 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 Signed-off-by: Ard Biesheuvel Acked-by: Leif Lindholm --- drivers/firmware/efi/Makefile | 1 + drivers/firmware/efi/efi-fdt.c | 93 ++++++++++++++++++++ drivers/firmware/efi/efi.c | 86 ------------------ 3 files changed, 94 insertions(+), 86 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..f0e7ef2ae0e9 --- /dev/null +++ b/drivers/firmware/efi/efi-fdt.c @@ -0,0 +1,93 @@ +/* + * 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 verbose; + 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 (info->verbose) + 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, int verbose) +{ + struct param_info info; + int ret; + + pr_info("Getting EFI parameters from FDT:\n"); + + info.verbose = verbose; + 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 9fa8084a7c8d..f975a1a45b80 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c @@ -20,8 +20,6 @@ #include #include #include -#include -#include #include #include @@ -460,90 +458,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 verbose; - 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 (info->verbose) - 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, int verbose) -{ - struct param_info info; - int ret; - - pr_info("Getting EFI parameters from FDT:\n"); - - info.verbose = verbose; - 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",