From patchwork Wed Feb 5 17:03:57 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Lindholm X-Patchwork-Id: 3587561 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 9C088C02DC for ; Wed, 5 Feb 2014 17:08:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CA21B20123 for ; Wed, 5 Feb 2014 17:08:34 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A02222011E for ; Wed, 5 Feb 2014 17:08:33 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WB5w9-00040e-1g; Wed, 05 Feb 2014 17:06:57 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WB5vn-0001jl-0c; Wed, 05 Feb 2014 17:06:35 +0000 Received: from mail-wi0-f181.google.com ([209.85.212.181]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WB5ur-0001YQ-2N for linux-arm-kernel@lists.infradead.org; Wed, 05 Feb 2014 17:05:42 +0000 Received: by mail-wi0-f181.google.com with SMTP id hi5so768658wib.8 for ; Wed, 05 Feb 2014 09:05:18 -0800 (PST) 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=zTmgA5Jqq651KSTh/lS43j/dACjpn8cQBMQmLxIkXfI=; b=BXqvg3ooMUFDctpKK/FJVehbv0t/lwIYeMHjoyZsZ3o3CD3Tl3snDGgs5FG1F9Ng9h 21eJVvez922j9otzzTR0ZLKjKMbsjFAEmL5v+SQ5WCQvwAxcJDs/AGFLjRP5dmmVovsA VydVV2i3c8Fwb1F9t9+Q4J0iczAHfCy0gy21QkgTA6nXzkHPlWTigt8OlSn7PdLgwN9I mp/Kb+imp0HyXaC/+Z+HFfh+UEDn5BioydfIwKCBfGQ3a4HAPH4csjZLITSnzpNxtRi2 FNCVrr32CqgS74BuU8tUJ6fZduN4lY2LHT3I1rCGvudqifxU5Yv+pqLM1F1TBjjeJCR1 DK4Q== X-Gm-Message-State: ALoCoQkwG3qhvgIrNh491MJNf1cmHeT20EpisGPciycS2RQmGuxGh9T2xZfKDhCLj2/u/XDsI0Gx X-Received: by 10.194.188.80 with SMTP id fy16mr2246062wjc.30.1391619917876; Wed, 05 Feb 2014 09:05:17 -0800 (PST) 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 p1sm47427211wie.1.2014.02.05.09.05.16 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Feb 2014 09:05:17 -0800 (PST) From: Leif Lindholm To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-efi@vger.kernel.org Subject: [PATCH 06/22] Add helper functions used by arm/arm64 Date: Wed, 5 Feb 2014 17:03:57 +0000 Message-Id: <1391619853-10601-7-git-send-email-leif.lindholm@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1391619853-10601-1-git-send-email-leif.lindholm@linaro.org> References: <1391619853-10601-1-git-send-email-leif.lindholm@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140205_120537_453057_DCF6EB91 X-CRM114-Status: GOOD ( 15.39 ) X-Spam-Score: -2.6 (--) Cc: Roy Franz , Leif Lindholm , patches@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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Roy Franz Add the get_dram_base() function and efi_call_physN() macros that are shared by arm/arm64. Signed-off-by: Roy Franz Signed-off-by: Leif Lindholm --- drivers/firmware/efi/efi-stub-helper.c | 63 +++++++++++++++++++++++++------- 1 file changed, 50 insertions(+), 13 deletions(-) diff --git a/drivers/firmware/efi/efi-stub-helper.c b/drivers/firmware/efi/efi-stub-helper.c index eb5d2eb..8477a72 100644 --- a/drivers/firmware/efi/efi-stub-helper.c +++ b/drivers/firmware/efi/efi-stub-helper.c @@ -11,6 +11,27 @@ */ #define EFI_READ_CHUNK_SIZE (1024 * 1024) +/* error code which can't be mistaken for valid address */ +#define EFI_ERROR (~0UL) + +# if !defined(CONFIG_X86) +/* + * EFI function call wrappers. These are not required for arm/arm64, but + * wrappers are required for X86 to convert between ABIs. These wrappers are + * provided to allow code sharing between X86 and other architectures. Since + * these wrappers directly invoke the EFI function pointer, the function + * pointer type must be properly defined, which is not the case for X86. One + * advantage of this is it allows for type checking of arguments, which is not + * possible with the X86 wrappers. + */ +#define efi_call_phys0(f) f() +#define efi_call_phys1(f, a1) f(a1) +#define efi_call_phys2(f, a1, a2) f(a1, a2) +#define efi_call_phys3(f, a1, a2, a3) f(a1, a2, a3) +#define efi_call_phys4(f, a1, a2, a3, a4) f(a1, a2, a3, a4) +#define efi_call_phys5(f, a1, a2, a3, a4, a5) f(a1, a2, a3, a4, a5) +#endif + struct file_info { efi_file_handle_t *handle; u64 size; @@ -92,6 +113,32 @@ fail: return status; } + +static unsigned long __init get_dram_base(efi_system_table_t *sys_table) +{ + efi_status_t status; + unsigned long map_size; + unsigned long membase = EFI_ERROR; + struct efi_memory_map map; + efi_memory_desc_t *md; + + status = efi_get_memory_map(sys_table, (efi_memory_desc_t **)&map.map, + &map_size, &map.desc_size, NULL, NULL); + if (status != EFI_SUCCESS) + return membase; + + map.map_end = map.map + map_size; + + for_each_efi_memory_desc(&map, md) + if (md->attribute & EFI_MEMORY_WB) + if (membase > md->phys_addr) + membase = md->phys_addr; + + efi_call_phys1(sys_table->boottime->free_pool, map.map); + + return membase; +} + /* * Allocate at the highest possible address that is not above 'max'. */ @@ -610,19 +657,9 @@ static char *efi_convert_cmdline_to_ascii(efi_system_table_t *sys_table_arg, options = &zero; } - options_size++; /* NUL termination */ -#ifdef CONFIG_ARM - /* - * For ARM, allocate at a high address to avoid reserved - * regions at low addresses that we don't know the specfics of - * at the time we are processing the command line. - */ - status = efi_high_alloc(sys_table_arg, options_size, 0, - &cmdline_addr, 0xfffff000); -#else - status = efi_low_alloc(sys_table_arg, options_size, 0, - &cmdline_addr); -#endif + options_size++; /* NULL termination */ + + status = efi_low_alloc(sys_table_arg, options_bytes, 0, &cmdline_addr); if (status != EFI_SUCCESS) return NULL;