From patchwork Tue Feb 24 18:02:47 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 44964 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f72.google.com (mail-wg0-f72.google.com [74.125.82.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B46112029F for ; Tue, 24 Feb 2015 18:05:35 +0000 (UTC) Received: by wghb13 with SMTP id b13sf5280503wgh.2 for ; Tue, 24 Feb 2015 10:05:34 -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=CvXZHDU+VaLFfIFWScc/0r21Ww1EgB5YQ/pdWGFFAAlIqNpZGx5XNiyYuJiCCw3RUh Mlnleh6jRXD3O2G/BblkU++ujpdIp5u3oLZqTmGeQrRvZfRP9d/X4SJdbaElALS1vH9m zFIT0RLkbldSkigdXMKQIvJGtohDOq4a5Z68bodEFPq6jium68y7Fw0c4JzmhrE0HN7a oHuQE5SXs+peSUx4E3pjb1wBWWSNYrG62qAKjhL8yLRZB8KWdqZMA2zKCXkZ0tdrVcfq kAgNyH/tQ83T2mQZLUUgd0KFuynumuY4ybJUhjxnOChYvM9W8fzPJYepAux8/IfR0efW EJjg== X-Gm-Message-State: ALoCoQkQhQXCkbucm9uo/x4wif1SUuTKRFvf7u9P6XSVLgqVfr7oznIGu9gWTcbBkISPjkYtqPQq X-Received: by 10.112.219.102 with SMTP id pn6mr1706764lbc.12.1424801134881; Tue, 24 Feb 2015 10:05:34 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.115.207 with SMTP id jq15ls713614lab.107.gmail; Tue, 24 Feb 2015 10:05:34 -0800 (PST) X-Received: by 10.112.133.132 with SMTP id pc4mr15535379lbb.33.1424801134733; Tue, 24 Feb 2015 10:05:34 -0800 (PST) Received: from mail-la0-f43.google.com (mail-la0-f43.google.com. [209.85.215.43]) by mx.google.com with ESMTPS id b5si28960215laa.156.2015.02.24.10.05.34 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Feb 2015 10:05:34 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.43 as permitted sender) client-ip=209.85.215.43; Received: by lams18 with SMTP id s18so27526705lam.13 for ; Tue, 24 Feb 2015 10:05:34 -0800 (PST) X-Received: by 10.152.21.100 with SMTP id u4mr15158271lae.41.1424801134616; Tue, 24 Feb 2015 10:05:34 -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 h5csp2078626lbj; Tue, 24 Feb 2015 10:05:33 -0800 (PST) X-Received: by 10.236.16.162 with SMTP id h22mr2746806yhh.93.1424801128519; Tue, 24 Feb 2015 10:05:28 -0800 (PST) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id p13si33497666qaa.10.2015.02.24.10.05.27 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 24 Feb 2015 10:05:28 -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 1YQJqP-0001hr-5g; Tue, 24 Feb 2015 18:04:29 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YQJqN-0001gC-M8 for xen-devel@lists.xen.org; Tue, 24 Feb 2015 18:04:27 +0000 Received: from [193.109.254.147] by server-13.bemta-14.messagelabs.com id BF/A2-02635-B2DBCE45; Tue, 24 Feb 2015 18:04:27 +0000 X-Env-Sender: ard.biesheuvel@linaro.org X-Msg-Ref: server-16.tower-27.messagelabs.com!1424801066!7165691!1 X-Originating-IP: [74.125.82.50] 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 8044 invoked from network); 24 Feb 2015 18:04:26 -0000 Received: from mail-wg0-f50.google.com (HELO mail-wg0-f50.google.com) (74.125.82.50) by server-16.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 24 Feb 2015 18:04:26 -0000 Received: by wghn12 with SMTP id n12so6993894wgh.1 for ; Tue, 24 Feb 2015 10:04:25 -0800 (PST) X-Received: by 10.194.175.202 with SMTP id cc10mr19707933wjc.27.1424801065606; Tue, 24 Feb 2015 10:04:25 -0800 (PST) Received: from ards-macbook-pro.lan (bl11-65-113.dsl.telepac.pt. [85.244.65.113]) by mx.google.com with ESMTPSA id w8sm12792521wja.4.2015.02.24.10.04.22 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 24 Feb 2015 10:04:24 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.sourceforge.net, olivier.martin@arm.com, lersek@redhat.com, roy.franz@linaro.org, leif.lindholm@linaro.org, stefano.stabellini@eu.citrix.com, ian.campbell@citrix.com, anthony.perard@citrix.com, xen-devel@lists.xen.org, julien.grall@linaro.org, jordan.l.justen@intel.com, michael.d.kinney@intel.com Date: Tue, 24 Feb 2015 18:02:47 +0000 Message-Id: <1424800990-15777-7-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1424800990-15777-1-git-send-email-ard.biesheuvel@linaro.org> References: <1424800990-15777-1-git-send-email-ard.biesheuvel@linaro.org> Cc: wei.liu2@citrix.com, Ard Biesheuvel Subject: [Xen-devel] [PATCH v5 06/29] 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.43 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