From patchwork Fri Apr 25 16:09:07 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Lindholm X-Patchwork-Id: 29101 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f199.google.com (mail-vc0-f199.google.com [209.85.220.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9CCF0203AC for ; Fri, 25 Apr 2014 16:20:04 +0000 (UTC) Received: by mail-vc0-f199.google.com with SMTP id lh14sf14370938vcb.10 for ; Fri, 25 Apr 2014 09:20:04 -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:cc:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version:sender :errors-to:x-original-sender:x-original-authentication-results :mailing-list:content-type:content-transfer-encoding; bh=2gqtoRKDOIZDVRVDRANhJfGodDrma49w+fX+anruBLc=; b=GzVQ2BStNfgM3V4MllGfXH8anXpch8DbHP6BT6Y7fW1L1LLkKJkrMvXkM0ZRb9+A67 39OXB4SlI2/G2YVipdE+GrfOnYQwWDDZkJh2Xo6tPYabUR9fVj14JSNoZ90g6TajnXYg 8uwH6eiviJ/XW8JNKi28381/+xuOIpE1ONDcNwGOc/BEy4CSWPJe40yUHgI5skR2ioOn Mf05x6nNNwm1stdEAyDlwSqFDrMbIOo0dNuS7KUjeNPT6fGlvuTSgJnZtlex0DsaLGIb /UC8/gZKv3d3zTvBdgfyW1mk6xs/saE921OekSbWoTQaI+279spFVocw8vr30wFzvOw5 /zpQ== X-Gm-Message-State: ALoCoQkcEDHyJ/O97VkI1kPr8r0pH+L5Y3PJCpr05IdntbCGWvewTzQ6T8ndzJ0RsPuSz3V/Qc8o X-Received: by 10.58.210.2 with SMTP id mq2mr4729607vec.3.1398442804190; Fri, 25 Apr 2014 09:20:04 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.82.145 with SMTP id h17ls1702754qgd.31.gmail; Fri, 25 Apr 2014 09:20:04 -0700 (PDT) X-Received: by 10.220.7.131 with SMTP id d3mr56836vcd.45.1398442804021; Fri, 25 Apr 2014 09:20:04 -0700 (PDT) Received: from mail-vc0-f176.google.com (mail-vc0-f176.google.com [209.85.220.176]) by mx.google.com with ESMTPS id uq6si1815088vcb.0.2014.04.25.09.20.04 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 25 Apr 2014 09:20:04 -0700 (PDT) Received-SPF: none (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) client-ip=209.85.220.176; Received: by mail-vc0-f176.google.com with SMTP id lc6so5035857vcb.35 for ; Fri, 25 Apr 2014 09:20:03 -0700 (PDT) X-Received: by 10.221.29.137 with SMTP id ry9mr7416375vcb.6.1398442803937; Fri, 25 Apr 2014 09:20: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.220.221.72 with SMTP id ib8csp110285vcb; Fri, 25 Apr 2014 09:20:03 -0700 (PDT) X-Received: by 10.140.108.4 with SMTP id i4mr12294695qgf.80.1398442803292; Fri, 25 Apr 2014 09:20:03 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id y67si4105753qgd.140.2014.04.25.09.20.03 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 25 Apr 2014 09:20:03 -0700 (PDT) Received-SPF: none (google.com: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org does not designate permitted sender hosts) 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 1Wdiov-0001Ng-MQ; Fri, 25 Apr 2014 16:17:49 +0000 Received: from mail-we0-f170.google.com ([74.125.82.170]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Wdiot-00018B-8w for linux-arm-kernel@lists.infradead.org; Fri, 25 Apr 2014 16:17:48 +0000 Received: by mail-we0-f170.google.com with SMTP id w61so3855469wes.15 for ; Fri, 25 Apr 2014 09:17:24 -0700 (PDT) X-Received: by 10.180.206.36 with SMTP id ll4mr4287513wic.57.1398442207758; Fri, 25 Apr 2014 09:10:07 -0700 (PDT) Received: from mohikan.mushroom.smurfnet.nu (cpc4-cmbg17-2-0-cust71.5-4.cable.virginm.net. [86.14.224.72]) by mx.google.com with ESMTPSA id uy4sm11813046wjc.8.2014.04.25.09.10.02 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 25 Apr 2014 09:10:06 -0700 (PDT) From: Leif Lindholm To: linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 03/10] efi: add helper function to get UEFI params from FDT Date: Fri, 25 Apr 2014 17:09:07 +0100 Message-Id: <1398442154-19974-4-git-send-email-leif.lindholm@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1398442154-19974-1-git-send-email-leif.lindholm@linaro.org> References: <1398442154-19974-1-git-send-email-leif.lindholm@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140425_091747_613030_0E543400 X-CRM114-Status: GOOD ( 20.81 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.3.2 on bombadil.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [74.125.82.170 listed in list.dnswl.org] Cc: mark.rutland@arm.com, matt.fleming@intel.com, ard.biesheuvel@linaro.org, catalin.marinas@arm.com, linux-doc@vger.kernel.org, roy.franz@linaro.org, msalter@redhat.com, grant.likely@linaro.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , 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: leif.lindholm@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) 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 From: Mark Salter ARM and ARM64 architectures use the device tree to pass UEFI parameters from stub to kernel. These parameters are things known to the stub but not discoverable by the kernel after the stub calls ExitBootSerives(). There is a helper function in: drivers/firmware/efi/fdt.c which the stub uses to add the UEFI parameters to the device tree. This patch adds a complimentary helper function which UEFI runtime support may use to retrieve the parameters from the device tree. If an architecture wants to use this helper, it should select CONFIG_UEFI_PARAMS_FROM_FDT. Signed-off-by: Mark Salter Signed-off-by: Leif Lindholm Acked-by: Matt Fleming --- drivers/firmware/efi/Kconfig | 7 ++++ drivers/firmware/efi/efi.c | 79 ++++++++++++++++++++++++++++++++++++++++++ include/linux/efi.h | 9 +++++ 3 files changed, 95 insertions(+) diff --git a/drivers/firmware/efi/Kconfig b/drivers/firmware/efi/Kconfig index 1e75f48..d3fe28d 100644 --- a/drivers/firmware/efi/Kconfig +++ b/drivers/firmware/efi/Kconfig @@ -47,6 +47,13 @@ config EFI_RUNTIME_MAP See also Documentation/ABI/testing/sysfs-firmware-efi-runtime-map. +config UEFI_PARAMS_FROM_FDT + bool + help + Select this config option from the architecture Kconfig if + the EFI runtime support gets system table address, memory + map address, and other parameters from the device tree. + endmenu config UEFI_CPER diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c index af20f17..ece6197 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c @@ -20,6 +20,8 @@ #include #include #include +#include +#include #include struct efi __read_mostly efi = { @@ -318,3 +320,80 @@ int __init efi_config_init(efi_config_table_type_t *arch_tables) return 0; } + +#ifdef CONFIG_UEFI_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; + void *params; +}; + +static int __init fdt_find_uefi_params(unsigned long node, const char *uname, + int depth, void *data) +{ + struct param_info *info = data; + void *prop, *dest; + unsigned long len; + u64 val; + int i; + + if (depth != 1 || + (strcmp(uname, "chosen") != 0 && strcmp(uname, "chosen@0") != 0)) + return 0; + + pr_info("Getting parameters from FDT:\n"); + + for (i = 0; i < ARRAY_SIZE(dt_params); i++) { + prop = of_get_flat_dt_prop(node, dt_params[i].propname, &len); + if (!prop) { + pr_err("Can't find %s in device tree!\n", + dt_params[i].name); + return 0; + } + dest = info->params + dt_params[i].offset; + + 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; + + info.verbose = verbose; + info.params = params; + + return of_scan_flat_dt(fdt_find_uefi_params, &info); +} +#endif /* CONFIG_UEFI_PARAMS_FROM_FDT */ diff --git a/include/linux/efi.h b/include/linux/efi.h index 82d0abb..4f52ac6 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h @@ -664,6 +664,14 @@ struct efi_memory_map { unsigned long desc_size; }; +struct efi_fdt_params { + u64 system_table; + u64 mmap; + u32 mmap_size; + u32 desc_size; + u32 desc_ver; +}; + typedef struct { u32 revision; u32 parent_handle; @@ -861,6 +869,7 @@ extern void efi_initialize_iomem_resources(struct resource *code_resource, extern void efi_get_time(struct timespec *now); extern int efi_set_rtc_mmss(const struct timespec *now); extern void efi_reserve_boot_services(void); +extern int efi_get_fdt_params(struct efi_fdt_params *params, int verbose); extern struct efi_memory_map memmap; /* Iterate through an efi_memory_map */