From patchwork Fri Jan 15 06:55:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 59839 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp357280lbb; Thu, 14 Jan 2016 22:58:31 -0800 (PST) X-Received: by 10.98.11.151 with SMTP id 23mr12620430pfl.93.1452841111763; Thu, 14 Jan 2016 22:58:31 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id yk10si3678714pac.24.2016.01.14.22.58.31; Thu, 14 Jan 2016 22:58:31 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754983AbcAOG63 (ORCPT + 29 others); Fri, 15 Jan 2016 01:58:29 -0500 Received: from szxga01-in.huawei.com ([58.251.152.64]:13301 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754474AbcAOG4n (ORCPT ); Fri, 15 Jan 2016 01:56:43 -0500 Received: from 172.24.1.50 (EHLO SZXEML429-HUB.china.huawei.com) ([172.24.1.50]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id DDB64125; Fri, 15 Jan 2016 14:56:37 +0800 (CST) Received: from HGHY1Z002260041.china.huawei.com (10.177.16.142) by SZXEML429-HUB.china.huawei.com (10.82.67.184) with Microsoft SMTP Server id 14.3.235.1; Fri, 15 Jan 2016 14:56:26 +0800 From: Shannon Zhao To: , , , CC: , , , , , , , , , Subject: [PATCH v2 14/16] Xen: EFI: Parse DT parameters for Xen specific UEFI Date: Fri, 15 Jan 2016 14:55:27 +0800 Message-ID: <1452840929-19612-15-git-send-email-zhaoshenglong@huawei.com> X-Mailer: git-send-email 1.9.0.msysgit.0 In-Reply-To: <1452840929-19612-1-git-send-email-zhaoshenglong@huawei.com> References: <1452840929-19612-1-git-send-email-zhaoshenglong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.177.16.142] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020205.56989828.0093, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-06-18 04:22:30, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: af5a913d69d0abe6123709d5ad6852ee Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Shannon Zhao Add a new function to parse DT parameters for Xen specific UEFI just like the way for normal UEFI. Then it could reuse the existing codes. Signed-off-by: Shannon Zhao --- drivers/firmware/efi/efi.c | 45 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 7 deletions(-) -- 2.0.4 diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c index 027ca21..2dbc2ac 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c @@ -24,6 +24,7 @@ #include #include #include +#include struct efi __read_mostly efi = { .mps = EFI_INVALID_TABLE_ADDR, @@ -498,12 +499,14 @@ device_initcall(efi_load_efivars); FIELD_SIZEOF(struct efi_fdt_params, field) \ } -static __initdata struct { +struct params { const char name[32]; const char propname[32]; int offset; int size; -} dt_params[] = { +}; + +static struct params fdt_params[] __initdata = { 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), @@ -511,6 +514,14 @@ static __initdata struct { UEFI_PARAM("MemMap Desc. Version", "linux,uefi-mmap-desc-ver", desc_ver) }; +static struct params xen_fdt_params[] __initdata = { + UEFI_PARAM("System Table", "xen,uefi-system-table", system_table), + UEFI_PARAM("MemMap Address", "xen,uefi-mmap-start", mmap), + UEFI_PARAM("MemMap Size", "xen,uefi-mmap-size", mmap_size), + UEFI_PARAM("MemMap Desc. Size", "xen,uefi-mmap-desc-size", desc_size), + UEFI_PARAM("MemMap Desc. Version", "xen,uefi-mmap-desc-ver", desc_ver) +}; + struct param_info { int found; void *params; @@ -520,15 +531,28 @@ static int __init fdt_find_uefi_params(unsigned long node, const char *uname, int depth, void *data) { struct param_info *info = data; + struct params *dt_params; + unsigned int size; const void *prop; void *dest; u64 val; int i, len; - if (depth != 1 || strcmp(uname, "chosen") != 0) - return 0; + if (efi_enabled(EFI_PARAVIRT)) { + if (depth != 2 || strcmp(uname, "uefi") != 0) + return 0; - for (i = 0; i < ARRAY_SIZE(dt_params); i++) { + dt_params = xen_fdt_params; + size = ARRAY_SIZE(xen_fdt_params); + } else { + if (depth != 1 || strcmp(uname, "chosen") != 0) + return 0; + + dt_params = fdt_params; + size = ARRAY_SIZE(fdt_params); + } + + for (i = 0; i < size; i++) { prop = of_get_flat_dt_prop(node, dt_params[i].propname, &len); if (!prop) return 0; @@ -552,6 +576,7 @@ static int __init fdt_find_uefi_params(unsigned long node, const char *uname, int __init efi_get_fdt_params(struct efi_fdt_params *params) { struct param_info info; + struct params *dt_params; int ret; pr_info("Getting EFI parameters from FDT:\n"); @@ -559,12 +584,18 @@ int __init efi_get_fdt_params(struct efi_fdt_params *params) info.found = 0; info.params = params; + if (efi_enabled(EFI_PARAVIRT)) + dt_params = xen_fdt_params; + else + dt_params = fdt_params; + ret = of_scan_flat_dt(fdt_find_uefi_params, &info); - if (!info.found) + if (!info.found) { pr_info("UEFI not found.\n"); - else if (!ret) + } else if (!ret) { pr_err("Can't find '%s' in device tree!\n", dt_params[info.found].name); + } return ret; }