From patchwork Tue Feb 3 19:19:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 44306 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 68D482034D for ; Tue, 3 Feb 2015 19:23:06 +0000 (UTC) Received: by mail-wi0-f200.google.com with SMTP id fb4sf26960216wid.3 for ; Tue, 03 Feb 2015 11:23:05 -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:cc:subject:precedence:list-id:list-unsubscribe:list-post :list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:sender:errors-to:x-original-sender :x-original-authentication-results:mailing-list:list-archive; bh=K51kPHe3oygOXstmWxnQzGOhWmuLtfxoPaWM07FnJdk=; b=jC39pG3xhwTuKdBIENUnY+oj4q5H6/JyvQ/XOWwdhstRolto2JRYmJkwGp3+LiX73/ ex6AWrzAovqsTtwHVVq5d/IjWGIOekFVSFg0hbInCDjNdTqX0KvX2q0XOPiFvVjgJ/2T xCkH4nbk1E3JdbXBfRrhgbFV56TJFoLK/fLEm1g+vCuQThdABt/4zxPtk5DNIn4uv9hw uvfqEv2rHQ4Jrl/hDeWRzhFmToLEJgw0wAl/d3YPmIccs93yUSOK6CTZC3hdRNj8kQqL zp4RirDb8/DRgZC7OFl4WgRpx9U65QGYgrFxkPPCdfBFTjI3S7qBAyaOk8L04jKg414H pO8g== X-Gm-Message-State: ALoCoQnGTmUfihpXgOvd79W+6/R30SxueDookCGNZ0mp/0kvuEDbiHyVxUK+Otx52Rut4JGQR0bT X-Received: by 10.112.30.131 with SMTP id s3mr3425465lbh.13.1422991385719; Tue, 03 Feb 2015 11:23:05 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.21.99 with SMTP id u3ls245827lae.29.gmail; Tue, 03 Feb 2015 11:23:05 -0800 (PST) X-Received: by 10.112.159.137 with SMTP id xc9mr27017465lbb.6.1422991385502; Tue, 03 Feb 2015 11:23:05 -0800 (PST) Received: from mail-la0-f47.google.com (mail-la0-f47.google.com. [209.85.215.47]) by mx.google.com with ESMTPS id eq1si14582703lac.11.2015.02.03.11.23.05 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 03 Feb 2015 11:23:05 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.47 as permitted sender) client-ip=209.85.215.47; Received: by mail-la0-f47.google.com with SMTP id hz20so54119571lab.6 for ; Tue, 03 Feb 2015 11:23:05 -0800 (PST) X-Received: by 10.152.203.230 with SMTP id kt6mr25965950lac.38.1422991385240; Tue, 03 Feb 2015 11:23:05 -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 h5csp34776lbj; Tue, 3 Feb 2015 11:23:04 -0800 (PST) X-Received: by 10.52.13.73 with SMTP id f9mr5449352vdc.7.1422991379184; Tue, 03 Feb 2015 11:22:59 -0800 (PST) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id l17si11485048vcp.91.2015.02.03.11.22.58 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 03 Feb 2015 11:22:59 -0800 (PST) Received-SPF: none (google.com: xen-devel-bounces@lists.xen.org does not designate permitted sender hosts) client-ip=50.57.142.19; Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YIj21-0004LP-Cz; Tue, 03 Feb 2015 19:21:05 +0000 Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YIj20-0004K6-7j for xen-devel@lists.xen.org; Tue, 03 Feb 2015 19:21:04 +0000 Received: from [85.158.143.35] by server-1.bemta-4.messagelabs.com id AE/0E-03000-F9F11D45; Tue, 03 Feb 2015 19:21:03 +0000 X-Env-Sender: ard.biesheuvel@linaro.org X-Msg-Ref: server-11.tower-21.messagelabs.com!1422991262!12256461!1 X-Originating-IP: [74.125.82.41] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 6.13.4; banners=-,-,- X-VirusChecked: Checked Received: (qmail 30451 invoked from network); 3 Feb 2015 19:21:02 -0000 Received: from mail-wg0-f41.google.com (HELO mail-wg0-f41.google.com) (74.125.82.41) by server-11.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 3 Feb 2015 19:21:02 -0000 Received: by mail-wg0-f41.google.com with SMTP id a1so46458046wgh.0 for ; Tue, 03 Feb 2015 11:21:02 -0800 (PST) X-Received: by 10.180.74.52 with SMTP id q20mr38099947wiv.0.1422991255747; Tue, 03 Feb 2015 11:20:55 -0800 (PST) Received: from ards-macbook-pro.local (73.233.28.37.rev.vodafone.pt. [37.28.233.73]) by mx.google.com with ESMTPSA id eb7sm25860139wic.11.2015.02.03.11.20.52 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 03 Feb 2015 11:20:54 -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, julien.grall@linaro.org Date: Tue, 3 Feb 2015 19:19:51 +0000 Message-Id: <1422991212-9257-7-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1422991212-9257-1-git-send-email-ard.biesheuvel@linaro.org> References: <1422991212-9257-1-git-send-email-ard.biesheuvel@linaro.org> Cc: Ard Biesheuvel Subject: [Xen-devel] [PATCH v3 06/27] ArmVirtualizationPkg: move early UART discovery to PlatformPeim X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org 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.215.47 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 List-Archive: 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 --- .../ArmVirtualizationPlatformLib.inf | 3 -- .../Library/ArmVirtualizationPlatformLib/Virt.c | 46 +-------------------- .../Library/PlatformPeiLib/PlatformPeiLib.c | 48 ++++++++++++++++++++++ .../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