From patchwork Mon Jan 26 19:03:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 43779 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-we0-f197.google.com (mail-we0-f197.google.com [74.125.82.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B1DEB20D5D for ; Mon, 26 Jan 2015 19:04:30 +0000 (UTC) Received: by mail-we0-f197.google.com with SMTP id l61sf5290223wev.0 for ; Mon, 26 Jan 2015 11:04:30 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:subject:precedence:reply-to:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version :content-type:content-transfer-encoding:errors-to:x-original-sender :x-original-authentication-results:mailing-list; bh=7jpuXC0yw+puLKgykWniL4hTdJEVXVPp2w6TDF+zKNI=; b=eJXRGxTA63yzhn/9PxFN8caIl5zouf9VBnCK1Z9AyPqYvamGmdi5yGwTA6DZ3JQGFP aZ0M9ri8UunN8STSRfYdo6MANg4jwLXoieycfnIBDaACxqe0LDlTIe2k+wjsVIGo1ZBb /OFP5XYTHX8egz+Y7RcJ9bYbMHY6OCDRmb8ZWN5mt6l0kX5nJaLgB1rlwst/W9ybsx6M hmmMeQ5nHWAoOaRAe3OPDvpv8XdNr0IQprvz5cmh2z2FoWA9WCA5RU8NBPcrD9FzNR4S AnMHB+Wpc/m03VG5tE8fWh7ixUMWPMdYzjlnV6nbe4msktJr70nSlz9qYVTSIKMF1QI1 NjRg== X-Gm-Message-State: ALoCoQmvc1z495P9VMlq8wCrBtHn4W3k5ElQ9Ko8VFDCUFP15iJkc3zuxcYXokdOsdJJGhA/lqfq X-Received: by 10.194.86.1 with SMTP id l1mr2808901wjz.0.1422299070023; Mon, 26 Jan 2015 11:04:30 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.204.104 with SMTP id kx8ls539335lac.82.gmail; Mon, 26 Jan 2015 11:04:29 -0800 (PST) X-Received: by 10.152.191.165 with SMTP id gz5mr22292031lac.37.1422299069852; Mon, 26 Jan 2015 11:04:29 -0800 (PST) Received: from mail-lb0-f174.google.com (mail-lb0-f174.google.com. [209.85.217.174]) by mx.google.com with ESMTPS id ld5si9825502lbb.29.2015.01.26.11.04.29 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 26 Jan 2015 11:04:29 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.174 as permitted sender) client-ip=209.85.217.174; Received: by mail-lb0-f174.google.com with SMTP id f15so9286890lbj.5 for ; Mon, 26 Jan 2015 11:04:29 -0800 (PST) X-Received: by 10.152.8.1 with SMTP id n1mr543567laa.47.1422299069740; Mon, 26 Jan 2015 11:04:29 -0800 (PST) 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.112.35.133 with SMTP id h5csp870296lbj; Mon, 26 Jan 2015 11:04:28 -0800 (PST) X-Received: by 10.42.26.69 with SMTP id e5mr22076845icc.83.1422299067315; Mon, 26 Jan 2015 11:04:27 -0800 (PST) Received: from lists.sourceforge.net (lists.sourceforge.net. [216.34.181.88]) by mx.google.com with ESMTPS id y7si8580009icf.29.2015.01.26.11.04.26 (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 26 Jan 2015 11:04:27 -0800 (PST) Received-SPF: pass (google.com: domain of edk2-devel-bounces@lists.sourceforge.net designates 216.34.181.88 as permitted sender) client-ip=216.34.181.88; Received: from localhost ([127.0.0.1] helo=sfs-ml-3.v29.ch3.sourceforge.com) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1YFoxM-0004qM-TH; Mon, 26 Jan 2015 19:04:16 +0000 Received: from sog-mx-1.v43.ch3.sourceforge.com ([172.29.43.191] helo=mx.sourceforge.net) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1YFoxL-0004qB-Jd for edk2-devel@lists.sourceforge.net; Mon, 26 Jan 2015 19:04:15 +0000 Received-SPF: pass (sog-mx-1.v43.ch3.sourceforge.com: domain of linaro.org designates 74.125.82.54 as permitted sender) client-ip=74.125.82.54; envelope-from=ard.biesheuvel@linaro.org; helo=mail-wg0-f54.google.com; Received: from mail-wg0-f54.google.com ([74.125.82.54]) by sog-mx-1.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1YFoxG-0005c5-4N for edk2-devel@lists.sourceforge.net; Mon, 26 Jan 2015 19:04:15 +0000 Received: by mail-wg0-f54.google.com with SMTP id b13so10703274wgh.13 for ; Mon, 26 Jan 2015 11:04:05 -0800 (PST) X-Received: by 10.194.236.1 with SMTP id uq1mr48065201wjc.28.1422299045205; Mon, 26 Jan 2015 11:04:05 -0800 (PST) Received: from ards-macbook-pro.local ([197.129.8.190]) by mx.google.com with ESMTPSA id fo17sm15471007wjc.19.2015.01.26.11.04.02 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 26 Jan 2015 11:04:04 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.sourceforge.net, lersek@redhat.com, olivier.martin@arm.com, roy.franz@linaro.org, leif.lindholm@linaro.org, stefano.stabellini@eu.citrix.com, ian.campbell@citrix.com, anthony.perard@citrix.com, christoffer.dall@linaro.org, xen-devel@lists.xen.org, ilias.biris@linaro.org Date: Mon, 26 Jan 2015 19:03:08 +0000 Message-Id: <1422299011-2409-7-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1422299011-2409-1-git-send-email-ard.biesheuvel@linaro.org> References: <1422299011-2409-1-git-send-email-ard.biesheuvel@linaro.org> X-Spam-Score: -1.5 (-) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain -0.0 SPF_PASS SPF: sender matches SPF record -0.0 AWL AWL: Adjusted score from AWL reputation of From: address X-Headers-End: 1YFoxG-0005c5-4N Subject: [edk2] [PATCH v2 06/29] ArmVirtualizationPkg: move early UART discovery to PlatformPeim X-BeenThere: edk2-devel@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list Reply-To: edk2-devel@lists.sourceforge.net List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.sourceforge.net X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ard.biesheuvel@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.174 as permitted sender) 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 This is partially motivated by the desire to use PrePi in a virt environment, and in that configuration, ArmPlatformInitializeSystemMemory() is never called. But actually, this is a more suitable place anyway. Contributed-under: TianoCore Contribution Agreement 1.0 Reviewed-by: Laszlo Ersek Reviewed-by: Olivier Martin Signed-off-by: Ard Biesheuvel --- .../ArmVirtualizationPkg/Library/ArmVirtualizationPlatformLib/ArmVirtualizationPlatformLib.inf | 3 --- ArmPlatformPkg/ArmVirtualizationPkg/Library/ArmVirtualizationPlatformLib/Virt.c | 46 ++-------------------------------------------- ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformPeiLib/PlatformPeiLib.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformPeiLib/PlatformPeiLib.inf | 3 +++ 4 files changed, 53 insertions(+), 47 deletions(-) diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/Library/ArmVirtualizationPlatformLib/ArmVirtualizationPlatformLib.inf b/ArmPlatformPkg/ArmVirtualizationPkg/Library/ArmVirtualizationPlatformLib/ArmVirtualizationPlatformLib.inf index d1572882af1b..43b3c6ca1bef 100644 --- a/ArmPlatformPkg/ArmVirtualizationPkg/Library/ArmVirtualizationPlatformLib/ArmVirtualizationPlatformLib.inf +++ b/ArmPlatformPkg/ArmVirtualizationPkg/Library/ArmVirtualizationPlatformLib/ArmVirtualizationPlatformLib.inf @@ -62,6 +62,3 @@ gArmTokenSpaceGuid.PcdArmPrimaryCore gArmTokenSpaceGuid.PcdFdBaseAddress gArmTokenSpaceGuid.PcdFdSize - -[Guids] - gEarlyPL011BaseAddressGuid diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/Library/ArmVirtualizationPlatformLib/Virt.c b/ArmPlatformPkg/ArmVirtualizationPkg/Library/ArmVirtualizationPlatformLib/Virt.c index 3e3074af72f1..17f268697583 100644 --- a/ArmPlatformPkg/ArmVirtualizationPkg/Library/ArmVirtualizationPlatformLib/Virt.c +++ b/ArmPlatformPkg/ArmVirtualizationPkg/Library/ArmVirtualizationPlatformLib/Virt.c @@ -24,9 +24,6 @@ #include #include #include -#include -#include -#include /** Return the current Boot Mode @@ -77,25 +74,13 @@ ArmPlatformInitializeSystemMemory ( INT32 Node, Prev; UINT64 NewBase; UINT64 NewSize; - BOOLEAN HaveMemory, HaveUART; - UINT64 *HobData; CONST CHAR8 *Type; - CONST CHAR8 *Compatible; - CONST CHAR8 *CompItem; INT32 Len; CONST UINT64 *RegProp; - UINT64 UartBase; NewBase = 0; NewSize = 0; - HaveMemory = FALSE; - HaveUART = FALSE; - - HobData = BuildGuidHob (&gEarlyPL011BaseAddressGuid, sizeof *HobData); - ASSERT (HobData != NULL); - *HobData = 0; - DeviceTreeBase = (VOID *)(UINTN)PcdGet64 (PcdDeviceTreeInitialBaseAddress); ASSERT (DeviceTreeBase != NULL); @@ -107,7 +92,7 @@ ArmPlatformInitializeSystemMemory ( // // Look for a memory node // - for (Prev = 0; !(HaveMemory && HaveUART); Prev = Node) { + for (Prev = 0;; Prev = Node) { Node = fdt_next_node (DeviceTreeBase, Prev, NULL); if (Node < 0) { break; @@ -140,34 +125,7 @@ ArmPlatformInitializeSystemMemory ( DEBUG ((EFI_D_ERROR, "%a: Failed to parse FDT memory node\n", __FUNCTION__)); } - HaveMemory = TRUE; - continue; - } - - // - // Check for UART node - // - Compatible = fdt_getprop (DeviceTreeBase, Node, "compatible", &Len); - - // - // Iterate over the NULL-separated items in the compatible string - // - for (CompItem = Compatible; CompItem != NULL && CompItem < Compatible + Len; - CompItem += 1 + AsciiStrLen (CompItem)) { - - if (AsciiStrCmp (CompItem, "arm,pl011") == 0) { - RegProp = fdt_getprop (DeviceTreeBase, Node, "reg", &Len); - ASSERT (Len == 16); - - UartBase = fdt64_to_cpu (ReadUnaligned64 (RegProp)); - - DEBUG ((EFI_D_INFO, "%a: PL011 UART @ 0x%lx\n", __FUNCTION__, UartBase)); - - *HobData = UartBase; - - HaveUART = TRUE; - continue; - } + break; } } diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformPeiLib/PlatformPeiLib.c b/ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformPeiLib/PlatformPeiLib.c index af0d6e87da9f..58bc2b828dcd 100644 --- a/ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformPeiLib/PlatformPeiLib.c +++ b/ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformPeiLib/PlatformPeiLib.c @@ -21,6 +21,8 @@ #include #include +#include + EFI_STATUS EFIAPI PlatformPeim ( @@ -30,6 +32,14 @@ PlatformPeim ( VOID *Base; VOID *NewBase; UINTN FdtSize; + UINT64 *UartHobData; + INT32 Node, Prev; + CONST CHAR8 *Compatible; + CONST CHAR8 *CompItem; + INT32 Len; + CONST UINT64 *RegProp; + UINT64 UartBase; + Base = (VOID*)(UINTN)FixedPcdGet64 (PcdDeviceTreeInitialBaseAddress); ASSERT (fdt_check_header (Base) == 0); @@ -41,6 +51,44 @@ PlatformPeim ( CopyMem (NewBase, Base, FdtSize); PcdSet64 (PcdDeviceTreeBaseAddress, (UINT64)(UINTN)NewBase); + UartHobData = BuildGuidHob (&gEarlyPL011BaseAddressGuid, sizeof *UartHobData); + ASSERT (UartHobData != NULL); + *UartHobData = 0; + + // + // Look for a UART node + // + for (Prev = 0;; Prev = Node) { + Node = fdt_next_node (Base, Prev, NULL); + if (Node < 0) { + break; + } + + // + // Check for UART node + // + Compatible = fdt_getprop (Base, Node, "compatible", &Len); + + // + // Iterate over the NULL-separated items in the compatible string + // + for (CompItem = Compatible; CompItem != NULL && CompItem < Compatible + Len; + CompItem += 1 + AsciiStrLen (CompItem)) { + + if (AsciiStrCmp (CompItem, "arm,pl011") == 0) { + RegProp = fdt_getprop (Base, Node, "reg", &Len); + ASSERT (Len == 16); + + UartBase = fdt64_to_cpu (ReadUnaligned64 (RegProp)); + + DEBUG ((EFI_D_INFO, "%a: PL011 UART @ 0x%lx\n", __FUNCTION__, UartBase)); + + *UartHobData = UartBase; + break; + } + } + } + BuildFvHob (PcdGet64 (PcdFvBaseAddress), PcdGet32 (PcdFvSize)); return EFI_SUCCESS; diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformPeiLib/PlatformPeiLib.inf b/ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformPeiLib/PlatformPeiLib.inf index e544b528d261..a376fbd1f345 100644 --- a/ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformPeiLib/PlatformPeiLib.inf +++ b/ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformPeiLib/PlatformPeiLib.inf @@ -44,5 +44,8 @@ [Pcd] gArmVirtualizationTokenSpaceGuid.PcdDeviceTreeBaseAddress +[Guids] + gEarlyPL011BaseAddressGuid + [Depex] gEfiPeiMemoryDiscoveredPpiGuid