From patchwork Thu Mar 13 22:47:01 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Lindholm X-Patchwork-Id: 26237 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f71.google.com (mail-pa0-f71.google.com [209.85.220.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 255B0203AC for ; Thu, 13 Mar 2014 22:52:16 +0000 (UTC) Received: by mail-pa0-f71.google.com with SMTP id kq14sf4014780pab.6 for ; Thu, 13 Mar 2014 15:52:15 -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=tDj8pJoTm4Ea4Ew7b/E8IJhVkc4iCCXp0QIvhiBYsFc=; b=EH9WuCcpWf3gWvqVSv9vXg8Vi9Cv5W+Yr/2XHkj21iGKlSdwrmOI0Y8eaLBBETeWAO qAQhoy/HCt3u3EmXq1ehcszEQGANe//2aHgpsE1EBn8R6B/ZddR46KURyKc9MVOxrMkI TX7uv26ZLayAIwfacCbqwIHdD6eeBl7Q8RwFhEDSt6ElxlVut9shpWCNzHwqLfu4v5QP sDfRJCE0xGJbgxyvZ0oPl9Vnn76u7DaPfXvKwEHeRXaPJvqO8KOhXakVY5wI4FUiI4Es V2Z8tnHOEu+9fBtGDX+s7uS7HWRb0aO7oby5yWK4I3V60GXHhEpn6zMg1MNUNZcdiio7 YuHA== X-Gm-Message-State: ALoCoQnINfAzb/YjIkSBsAEWIgxpJXIKj8Y/HIlk51dpSc0UsLfLcokQDtA46nrbLS4eRd45wkX5 X-Received: by 10.66.137.8 with SMTP id qe8mr1827161pab.46.1394751135356; Thu, 13 Mar 2014 15:52:15 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.105.100 with SMTP id b91ls538915qgf.26.gmail; Thu, 13 Mar 2014 15:52:15 -0700 (PDT) X-Received: by 10.221.55.133 with SMTP id vy5mr3483608vcb.17.1394751135262; Thu, 13 Mar 2014 15:52:15 -0700 (PDT) Received: from mail-ve0-f176.google.com (mail-ve0-f176.google.com [209.85.128.176]) by mx.google.com with ESMTPS id uw4si1390925vdc.131.2014.03.13.15.52.15 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 13 Mar 2014 15:52:15 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.176 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.176; Received: by mail-ve0-f176.google.com with SMTP id cz12so1831511veb.7 for ; Thu, 13 Mar 2014 15:52:15 -0700 (PDT) X-Received: by 10.220.191.134 with SMTP id dm6mr3607018vcb.16.1394751135176; Thu, 13 Mar 2014 15:52:15 -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.78.9 with SMTP id i9csp10391vck; Thu, 13 Mar 2014 15:52:14 -0700 (PDT) X-Received: by 10.68.215.68 with SMTP id og4mr5396617pbc.112.1394751134316; Thu, 13 Mar 2014 15:52:14 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id uc9si2363336pac.376.2014.03.13.15.52.12; Thu, 13 Mar 2014 15:52:12 -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 S1755264AbaCMWwG (ORCPT + 26 others); Thu, 13 Mar 2014 18:52:06 -0400 Received: from mail-wg0-f46.google.com ([74.125.82.46]:60889 "EHLO mail-wg0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755365AbaCMWsM (ORCPT ); Thu, 13 Mar 2014 18:48:12 -0400 Received: by mail-wg0-f46.google.com with SMTP id b13so1446728wgh.17 for ; Thu, 13 Mar 2014 15:48:12 -0700 (PDT) X-Received: by 10.180.99.225 with SMTP id et1mr3556490wib.13.1394750891931; Thu, 13 Mar 2014 15:48:11 -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 dk9sm9072133wjb.4.2014.03.13.15.48.10 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Mar 2014 15:48:11 -0700 (PDT) From: Leif Lindholm To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-efi@vger.kernel.org, catalin.marinas@arm.com, matt.fleming@intel.com Cc: msalter@redhat.com, roy.franz@linaro.org, Leif Lindholm Subject: [PATCH v2 08/15] efi: Add get_dram_base() helper function Date: Thu, 13 Mar 2014 22:47:01 +0000 Message-Id: <1394750828-16351-9-git-send-email-leif.lindholm@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1394750828-16351-1-git-send-email-leif.lindholm@linaro.org> References: <1394750828-16351-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.176 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 4c8ab86..4a9986b 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; @@ -92,6 +96,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'. */