From patchwork Mon Mar 14 12:52:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laszlo Ersek X-Patchwork-Id: 63807 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp17666lbc; Mon, 14 Mar 2016 05:53:10 -0700 (PDT) X-Received: by 10.98.12.154 with SMTP id 26mr29825816pfm.20.1457959990151; Mon, 14 Mar 2016 05:53:10 -0700 (PDT) Return-Path: Received: from ml01.01.org (ml01.01.org. [198.145.21.10]) by mx.google.com with ESMTPS id df2si2865595pad.176.2016.03.14.05.53.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Mar 2016 05:53:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) client-ip=198.145.21.10; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 5B2F41A1F30; Mon, 14 Mar 2016 05:53:27 -0700 (PDT) X-Original-To: edk2-devel@ml01.01.org Delivered-To: edk2-devel@ml01.01.org Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 595D21A1F30 for ; Mon, 14 Mar 2016 05:53:26 -0700 (PDT) Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 2BAAAC00B8E2; Mon, 14 Mar 2016 12:53:08 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-113-101.phx2.redhat.com [10.3.113.101]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u2ECr3Zm003103; Mon, 14 Mar 2016 08:53:06 -0400 From: Laszlo Ersek To: edk2-devel@ml01.01.org Date: Mon, 14 Mar 2016 13:52:58 +0100 Message-Id: <1457959980-29438-2-git-send-email-lersek@redhat.com> In-Reply-To: <1457959980-29438-1-git-send-email-lersek@redhat.com> References: <56E6B2D9.5010507@redhat.com> <1457959980-29438-1-git-send-email-lersek@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 Cc: Marcel Apfelbaum , Jordan Justen Subject: [edk2] [wave 2 PATCH 1/3] OvmfPkg: PlatformPei: factor out GetFirstNonAddress() X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Factor out the expression that is currently the basis of the address width calculation into a standalone function. In the next patches we'll raise the return value under certain circumstances. Cc: Gerd Hoffmann Cc: Jordan Justen Cc: Marcel Apfelbaum Cc: Thomas Lamprecht Ref: https://github.com/tianocore/edk2/issues/59 Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek --- OvmfPkg/PlatformPei/MemDetect.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) -- 1.8.3.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/OvmfPkg/PlatformPei/MemDetect.c b/OvmfPkg/PlatformPei/MemDetect.c index 455fcbb49d13..286f6914a702 100644 --- a/OvmfPkg/PlatformPei/MemDetect.c +++ b/OvmfPkg/PlatformPei/MemDetect.c @@ -84,14 +84,30 @@ GetSystemMemorySizeAbove4gb ( } return LShiftU64 (Size, 16); } /** + Return the highest address that DXE could possibly use, plus one. +**/ +STATIC +UINT64 +GetFirstNonAddress ( + VOID + ) +{ + UINT64 FirstNonAddress; + + FirstNonAddress = BASE_4GB + GetSystemMemorySizeAbove4gb (); + return FirstNonAddress; +} + + +/** Initialize the mPhysMemAddressWidth variable, based on guest RAM size. **/ VOID AddressWidthInitialization ( VOID ) { @@ -99,15 +115,15 @@ AddressWidthInitialization ( // // As guest-physical memory size grows, the permanent PEI RAM requirements // are dominated by the identity-mapping page tables built by the DXE IPL. // The DXL IPL keys off of the physical address bits advertized in the CPU // HOB. To conserve memory, we calculate the minimum address width here. // - FirstNonAddress = BASE_4GB + GetSystemMemorySizeAbove4gb (); + FirstNonAddress = GetFirstNonAddress (); mPhysMemAddressWidth = (UINT8)HighBitSet64 (FirstNonAddress); // // If FirstNonAddress is not an integral power of two, then we need an // additional bit. // if ((FirstNonAddress & (FirstNonAddress - 1)) != 0) {