From patchwork Tue Nov 17 09:57:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 56775 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp1831362lbb; Tue, 17 Nov 2015 01:58:42 -0800 (PST) X-Received: by 10.68.219.98 with SMTP id pn2mr61367125pbc.141.1447754322362; Tue, 17 Nov 2015 01:58:42 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id qo8si56526165pac.117.2015.11.17.01.58.37; Tue, 17 Nov 2015 01:58:42 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of devicetree-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 devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dkim=neutral (body hash did not verify) header.i=@linaro_org.20150623.gappssmtp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753476AbbKQJ6g (ORCPT + 6 others); Tue, 17 Nov 2015 04:58:36 -0500 Received: from mail-wm0-f51.google.com ([74.125.82.51]:33395 "EHLO mail-wm0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753518AbbKQJ6a (ORCPT ); Tue, 17 Nov 2015 04:58:30 -0500 Received: by wmec201 with SMTP id c201so218545910wme.0 for ; Tue, 17 Nov 2015 01:58:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro_org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=9S83zXkjLPKmOygNPjV/lds6e/XRqJLLARplUajSWHY=; b=qlR0va5gITFBDnANbXg1SUAqc9onxv8g3oe3Z8gDvWqzm6lsH+5D7yKnD8Snz+PET3 +sfxqIVsJrTn14gz5s3jKHtIIu/Jff+Z3bCJE/tVAmLmPE8XkdDOggD7mQoTkWr1DXGG kCt5hIDl05TEsAlB9JWrEqs21HQXL2vQeRO2tVoUUZStzQ2cTkeyVXy6ORtMClPZ70wn niYtHim2Bkqo5K0yXkwSIv5CIbYzmB5VtQ1RA0oACNt9csPFGyS5dK5YS/D7ozMjG5Xc 4r96D5GQQ60dPJLIfOzD+xpaenZQ6A8wIwj1N+Gd5pVbmad07YDEZWx4Xdn2oUjhcs8h CaWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=9S83zXkjLPKmOygNPjV/lds6e/XRqJLLARplUajSWHY=; b=c4euxTrreytmwSTrvgtq18OcXrQQQV9gV94v5gn5S5wS25bVNJM9hv5bMV6kwRogY5 qbpQqa9TU3BeDEos/uPF/nPunQDv0EXVVI2fW1fpcWioTl7tChXgoIZexGMZQl0EmXFs 4wyKHGpujg6QIzXYMbkpN3bZNKNVLzQ4wBxGy6ZXzQNM/3ywakABoY3j2ET5DQ83Pb6r dFcX7DmHm2fDrLZwLIxZhqqQ/ZOj7IX5F83fvHTz6VfN59XZ7xAdV4VYt3yVy/QsGc9v q+8KIEg2os8nc+vRwEuLmEVk3ptWGb4S2E/nGJmEemNF9fJJNANU+sYw69YttCnMyecQ d/rQ== X-Gm-Message-State: ALoCoQk13CpfKxs/GvmGTCHmL4TvVe/V87yzFUUhDlFA/plY8dNDHjmtSD6ts1873nXKAwtjl5qE X-Received: by 10.194.200.5 with SMTP id jo5mr48307883wjc.79.1447754309348; Tue, 17 Nov 2015 01:58:29 -0800 (PST) Received: from localhost ([78.129.251.54]) by smtp.gmail.com with ESMTPSA id d2sm16676149wjy.16.2015.11.17.01.58.26 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 17 Nov 2015 01:58:28 -0800 (PST) From: shannon.zhao@linaro.org To: ian.campbell@citrix.com, stefano.stabellini@citrix.com, catalin.marinas@arm.com, will.deacon@arm.com, julien.grall@citrix.com, ard.biesheuvel@linaro.org, mark.rutland@arm.com, linux-arm-kernel@lists.infradead.org Cc: xen-devel@lists.xen.org, christoffer.dall@linaro.org, devicetree@vger.kernel.org, linux-efi@vger.kernel.org, peter.huangpeng@huawei.com, shannon.zhao@linaro.org, zhaoshenglong@huawei.com, hangaohuai@huawei.com Subject: [PATCH 08/13] Xen: EFI: Parse DT parameters for Xen specific UEFI Date: Tue, 17 Nov 2015 17:57:06 +0800 Message-Id: <1447754231-7772-9-git-send-email-shannon.zhao@linaro.org> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1447754231-7772-1-git-send-email-shannon.zhao@linaro.org> References: <1447754231-7772-1-git-send-email-shannon.zhao@linaro.org> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@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 | 67 ++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 62 insertions(+), 5 deletions(-) -- 2.1.0 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c index d6144e3..629bd06 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, @@ -488,12 +489,60 @@ static __initdata struct { UEFI_PARAM("MemMap Desc. Version", "linux,uefi-mmap-desc-ver", desc_ver) }; +static __initdata struct { + const char name[32]; + const char propname[32]; + int offset; + int size; +} xen_dt_params[] = { + 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 verbose; int found; void *params; }; +static int __init fdt_find_xen_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 (xen_initial_domain() && (depth != 2 || strcmp(uname, "uefi") != 0)) + return 0; + + for (i = 0; i < ARRAY_SIZE(xen_dt_params); i++) { + prop = of_get_flat_dt_prop(node, xen_dt_params[i].propname, + &len); + if (!prop) + return 0; + dest = info->params + xen_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", xen_dt_params[i].name, + xen_dt_params[i].size * 2, val); + } + + return 1; +} static int __init fdt_find_uefi_params(unsigned long node, const char *uname, int depth, void *data) { @@ -538,12 +587,20 @@ int __init efi_get_fdt_params(struct efi_fdt_params *params, int verbose) info.found = 0; info.params = params; - ret = of_scan_flat_dt(fdt_find_uefi_params, &info); - if (!info.found) + if (xen_initial_domain()) + ret = of_scan_flat_dt(fdt_find_xen_uefi_params, &info); + else + 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); + } else if (!ret) { + if (xen_initial_domain()) + pr_err("Can't find '%s' in device tree!\n", + xen_dt_params[info.found].name); + else + pr_err("Can't find '%s' in device tree!\n", + xen_dt_params[info.found].name); + } return ret; }