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: 3829481 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 BA49FBF540 for ; Thu, 13 Mar 2014 23:21:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DBB7E202B4 for ; Thu, 13 Mar 2014 23:21:06 +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 EBF4B2020A for ; Thu, 13 Mar 2014 23:21:05 +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 1WOESZ-0002CB-4x; Thu, 13 Mar 2014 22:50:44 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WOERs-0002H1-CA; Thu, 13 Mar 2014 22:50:00 +0000 Received: from mail-we0-f169.google.com ([74.125.82.169]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WOEQT-00024D-Ql for linux-arm-kernel@lists.infradead.org; Thu, 13 Mar 2014 22:48:40 +0000 Received: by mail-we0-f169.google.com with SMTP id w62so1464774wes.28 for ; Thu, 13 Mar 2014 15:48:12 -0700 (PDT) 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=dF59KEm+udiR/3K+v65gPIMGlDxmN5swp2Q+hMmfMAw=; b=b199RPEicTfUoEH+0OymXqquxUCsxkxqeo1tSDEF8SOMR4u8FdtWAWSsVIvmnV/wMr txYeEmJqoor7wR0TJfkZe1kaDCXbQfShLcsI4pCh8dUxzfKnNJm7SB3c6W8TZjQ83SYv 6q3+Pk12VireD5SfK6dn5OD2TujLVoc//RksAmwLXNhwTkbPXQctzVPpB/fOsDDc4BdB B8CoLvPRxbBsD/9vb5IQCj9fNCNIhWKQe9RVPlk5jP9KhSz89cdajRkZ5upt6j1fhsVp f3h48EARvaq4CPgE4CubSkEN3dxmwamc4IsB0GQIWCAFhjqGeHPeFSoKMUn9PZDKZ3ML SMXw== X-Gm-Message-State: ALoCoQknwacinpIcONzY1x0x+lvxrq51nqAO8/I91BPByCF8q6ennmx377FtluiHcYfCtgC4i4Wn 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140313_184834_045604_105D1FD0 X-CRM114-Status: GOOD ( 10.26 ) X-Spam-Score: -2.6 (--) Cc: roy.franz@linaro.org, Leif Lindholm , msalter@redhat.com 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.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_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, 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'. */