From patchwork Fri Jan 10 22:29:07 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Salter X-Patchwork-Id: 23118 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-gg0-f198.google.com (mail-gg0-f198.google.com [209.85.161.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 69958216DB for ; Fri, 10 Jan 2014 22:29:37 +0000 (UTC) Received: by mail-gg0-f198.google.com with SMTP id j1sf7106219ggn.5 for ; Fri, 10 Jan 2014 14:29:36 -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:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=B3xr77Do2dyLkN2RGVTzfEvEAcT6RVmCsiDJKhsZHS4=; b=EmjT0MNIzximk0a2BnsftmLv/cHgtxPb8pEEQ6VBfiMLD1yK7p3dNdV+QugABBsnQY Ugz5idKQTBrTazNY8T41EvW1coW//JbC8KCTXlYauNHcFgvjLic83bhYmUC2vB+y9PNX 7Fx8bFMEo9g5G2C/jXWqnjCKrzzrmUUOTcTEtww5ajf91f/cxD45HaASDiw5+Wc6+vgs uR5Xi+xXlOgFBOWr6PLkFHEgiTANT9VYTnXBfiv05REPYZGk46ceQ7umEGsKuI+D2OH7 ZRXicDs+0LI5QDQUBK/LFfIPVZSlapuX1nTklMx1jRLYf9cVcscT1eVk59nHs61hw/YQ ebAw== X-Gm-Message-State: ALoCoQkc9EkZuFZ3vKIht35OdcPgiF8glmu3WFoLszxuteEyzeYGu4463Aa36xI7xYSHS+ASR48v X-Received: by 10.236.78.69 with SMTP id f45mr4324582yhe.9.1389392976618; Fri, 10 Jan 2014 14:29:36 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.36.2 with SMTP id m2ls1684710qej.40.gmail; Fri, 10 Jan 2014 14:29:36 -0800 (PST) X-Received: by 10.58.235.129 with SMTP id um1mr9909091vec.17.1389392976510; Fri, 10 Jan 2014 14:29:36 -0800 (PST) Received: from mail-ve0-f181.google.com (mail-ve0-f181.google.com [209.85.128.181]) by mx.google.com with ESMTPS id gx6si5720334vdc.115.2014.01.10.14.29.36 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 10 Jan 2014 14:29:36 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.181 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.181; Received: by mail-ve0-f181.google.com with SMTP id oy12so3942211veb.12 for ; Fri, 10 Jan 2014 14:29:36 -0800 (PST) X-Received: by 10.58.208.130 with SMTP id me2mr9930626vec.13.1389392976398; Fri, 10 Jan 2014 14:29:36 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.59.13.131 with SMTP id ey3csp121819ved; Fri, 10 Jan 2014 14:29:36 -0800 (PST) X-Received: by 10.49.6.70 with SMTP id y6mr6911723qey.6.1389392975893; Fri, 10 Jan 2014 14:29:35 -0800 (PST) Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTP id w8si6050195qag.6.2014.01.10.14.29.35 for ; Fri, 10 Jan 2014 14:29:35 -0800 (PST) Received-SPF: pass (google.com: domain of msalter@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s0AMTVGe030412 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 10 Jan 2014 17:29:31 -0500 Received: from deneb.redhat.com (ovpn-113-39.phx2.redhat.com [10.3.113.39]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s0AMTQff004120; Fri, 10 Jan 2014 17:29:30 -0500 From: Mark Salter To: linux-kernel@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-efi@vger.kernel.org, Catalin Marinas , Will Deacon , matt.fleming@intel.com, Leif Lindholm , roy.franz@linaro.org, patches@linaro.org, Grant Likely , Mark Salter Subject: [PATCH 3/6] efi: add helper function to get UEFI params from FDT Date: Fri, 10 Jan 2014 17:29:07 -0500 Message-Id: <1389392950-22457-4-git-send-email-msalter@redhat.com> In-Reply-To: <1389392950-22457-1-git-send-email-msalter@redhat.com> References: <1389392950-22457-1-git-send-email-msalter@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: msalter@redhat.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.181 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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 --- 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 6aecbc8..d5101e6 100644 --- a/drivers/firmware/efi/Kconfig +++ b/drivers/firmware/efi/Kconfig @@ -36,6 +36,13 @@ config EFI_VARS_PSTORE_DEFAULT_DISABLE backend for pstore by default. This setting can be overridden using the efivars module's pstore_disable parameter. +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 2e2fbde..4f1372b 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 = { @@ -272,3 +274,80 @@ int __init efi_config_init(efi_config_table_type_t *arch_tables) early_iounmap(config_tables, efi.systab->nr_tables * sz); 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 9dc5b05..ff8524e 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h @@ -483,6 +483,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; void *parent_handle; @@ -616,6 +624,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 */