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: 24195 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yk0-f200.google.com (mail-yk0-f200.google.com [209.85.160.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E2E2520675 for ; Wed, 5 Feb 2014 17:05:24 +0000 (UTC) Received: by mail-yk0-f200.google.com with SMTP id q9sf3015448ykb.3 for ; Wed, 05 Feb 2014 09:05:23 -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=zTmgA5Jqq651KSTh/lS43j/dACjpn8cQBMQmLxIkXfI=; b=fO9j5aLJYVdz0ciWh1SVzFRIFp8gynttztfuoc1ml1s7srIVG61tMsoIixYdatvZoR PLLEYBtV4vNAVltdzJg2eEX6MRVh5TKhluwtcXp/C0n0AwpfNkgdch1c+O5y4h5aT0rM EYBH/mUsWro/Xtkdu0HzPTDrcHsFPNmBsDnsM16gGuOORiEmB/Ry4APf5FeEoGHk4/GJ owu1hkzDPe/nLH7sfFcspnZM7d9SDtvlIEC5GHNJoaFKPTMF+hXL1A5XlC0anpc936Vb isiMcqDSvTJop2451xH0yGvEnrzfLE8+PmhzeVKWWJmFRL1nTfAzOGu32qRjwRbZfTBI IHQA== X-Gm-Message-State: ALoCoQkf9kMu5baSjGG/T2dlX03Th0ax2CldhvD+EgM6jQ6En+AgRjEmfxljial2yRJZ6qZEK/UV X-Received: by 10.52.187.41 with SMTP id fp9mr889010vdc.5.1391619923662; Wed, 05 Feb 2014 09:05:23 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.84.165 with SMTP id l34ls232716qgd.5.gmail; Wed, 05 Feb 2014 09:05:23 -0800 (PST) X-Received: by 10.52.108.232 with SMTP id hn8mr1440809vdb.29.1391619923591; Wed, 05 Feb 2014 09:05:23 -0800 (PST) Received: from mail-vb0-f44.google.com (mail-vb0-f44.google.com [209.85.212.44]) by mx.google.com with ESMTPS id uo16si9822378veb.124.2014.02.05.09.05.23 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 05 Feb 2014 09:05:23 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.44 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.44; Received: by mail-vb0-f44.google.com with SMTP id f12so506196vbg.31 for ; Wed, 05 Feb 2014 09:05:23 -0800 (PST) X-Received: by 10.52.23.68 with SMTP id k4mr1466013vdf.24.1391619923510; Wed, 05 Feb 2014 09:05:23 -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.220.174.196 with SMTP id u4csp64579vcz; Wed, 5 Feb 2014 09:05:22 -0800 (PST) X-Received: by 10.180.97.37 with SMTP id dx5mr3300478wib.53.1391619918453; Wed, 05 Feb 2014 09:05:18 -0800 (PST) Received: from mail-wi0-f171.google.com (mail-wi0-f171.google.com [209.85.212.171]) by mx.google.com with ESMTPS id o17si9766797wie.52.2014.02.05.09.05.18 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 05 Feb 2014 09:05:18 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.171 is neither permitted nor denied by best guess record for domain of leif.lindholm@linaro.org) client-ip=209.85.212.171; Received: by mail-wi0-f171.google.com with SMTP id cc10so791547wib.16 for ; Wed, 05 Feb 2014 09:05:18 -0800 (PST) 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 Cc: patches@linaro.org, Roy Franz , Leif Lindholm 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-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: 209.85.212.44 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: , 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;