From patchwork Fri Apr 4 12:25:50 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Lindholm X-Patchwork-Id: 27809 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ve0-f199.google.com (mail-ve0-f199.google.com [209.85.128.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B177B20369 for ; Fri, 4 Apr 2014 12:27:18 +0000 (UTC) Received: by mail-ve0-f199.google.com with SMTP id jy13sf6007793veb.2 for ; Fri, 04 Apr 2014 05:27:18 -0700 (PDT) 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:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=tabT2RxQsBHyYNZpoKw/m8a225xeLeHMBRA1JOSe+JE=; b=jfTaQBBtp8LYAS5YdRb21cqNOZkK1GeXf9R+e0Le73NsRwBRMSq31xEmNGVF38An6t DGEBhTTCEG/Etb+YMdbi9M1rIMQGQ6W6RAlReA/AkSzTWwwcTPzLaNgkNwRcodjKfQB3 HleAnuplDB36AjqLbceA+Mu9M8068QZdxcKa+o/am/RQzcJncSB2Rfw2XwN+CHSfIVVL cCowK+PXo7oHjVfg0wmRy338V2Oc6y9qX1KkZSRednv55WObnnOvJwZt6/YyW7n++7bL wdaNCJLKxG5i/RChB91QZ8eDQL3KiD/UHCKS9k3X7M1BRG5yJSiAUirROXxXPl3mkqCT Hdjg== X-Gm-Message-State: ALoCoQkYfNOUDxv0+gJNlCL3BMZxCRYrdbFo4IJwzoaFw7YBoukfqRG+9OvueWRvbsaOhfilj/XE X-Received: by 10.236.39.99 with SMTP id c63mr7144405yhb.31.1396614438168; Fri, 04 Apr 2014 05:27:18 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.47.197 with SMTP id m63ls1031200qga.58.gmail; Fri, 04 Apr 2014 05:27:18 -0700 (PDT) X-Received: by 10.220.162.6 with SMTP id t6mr8230361vcx.12.1396614438072; Fri, 04 Apr 2014 05:27:18 -0700 (PDT) Received: from mail-ve0-f170.google.com (mail-ve0-f170.google.com [209.85.128.170]) by mx.google.com with ESMTPS id e9si1749116vct.142.2014.04.04.05.27.18 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 04 Apr 2014 05:27:18 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.170 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.170; Received: by mail-ve0-f170.google.com with SMTP id pa12so1408090veb.1 for ; Fri, 04 Apr 2014 05:27:18 -0700 (PDT) X-Received: by 10.58.38.166 with SMTP id h6mr1430407vek.22.1396614437973; Fri, 04 Apr 2014 05:27:17 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.12.8 with SMTP id v8csp109693vcv; Fri, 4 Apr 2014 05:27:17 -0700 (PDT) X-Received: by 10.66.189.226 with SMTP id gl2mr14609318pac.65.1396614436766; Fri, 04 Apr 2014 05:27:16 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id sr9si4540721pab.243.2014.04.04.05.27.15; Fri, 04 Apr 2014 05:27:15 -0700 (PDT) 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; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753079AbaDDM1F (ORCPT + 27 others); Fri, 4 Apr 2014 08:27:05 -0400 Received: from mail-wg0-f50.google.com ([74.125.82.50]:35950 "EHLO mail-wg0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752960AbaDDM0m (ORCPT ); Fri, 4 Apr 2014 08:26:42 -0400 Received: by mail-wg0-f50.google.com with SMTP id x13so3334554wgg.33 for ; Fri, 04 Apr 2014 05:26:41 -0700 (PDT) X-Received: by 10.180.97.37 with SMTP id dx5mr4061106wib.53.1396614401440; Fri, 04 Apr 2014 05:26:41 -0700 (PDT) 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 u8sm855089wjq.1.2014.04.04.05.26.40 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 04 Apr 2014 05:26:40 -0700 (PDT) From: Leif Lindholm To: linux-efi@vger.kernel.org, matt.fleming@intel.com Cc: linux-kernel@vger.kernel.org, Roy Franz , Leif Lindholm Subject: [PATCH 5/5] efi: Add get_dram_base() helper function Date: Fri, 4 Apr 2014 13:25:50 +0100 Message-Id: <1396614350-20889-6-git-send-email-leif.lindholm@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1396614350-20889-1-git-send-email-leif.lindholm@linaro.org> References: <1396614350-20889-1-git-send-email-leif.lindholm@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.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.128.170 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 Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Roy Franz Add the get_dram_base() function, shared by arm/arm64. Signed-off-by: Roy Franz Signed-off-by: Leif Lindholm --- drivers/firmware/efi/efi-stub-helper.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/drivers/firmware/efi/efi-stub-helper.c b/drivers/firmware/efi/efi-stub-helper.c index 183289c..998b884 100644 --- a/drivers/firmware/efi/efi-stub-helper.c +++ b/drivers/firmware/efi/efi-stub-helper.c @@ -11,6 +11,10 @@ */ #define EFI_READ_CHUNK_SIZE (1024 * 1024) +/* error code which can't be mistaken for valid address */ +#define EFI_ERROR (~0UL) + + struct file_info { efi_file_handle_t *handle; u64 size; @@ -83,6 +87,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'. */