From patchwork Tue Feb 24 18:02:48 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 44963 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id AFEC22029F for ; Tue, 24 Feb 2015 18:05:32 +0000 (UTC) Received: by mail-wi0-f199.google.com with SMTP id bs8sf16309096wib.2 for ; Tue, 24 Feb 2015 10:05:32 -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=Ua2rDyObU3jrkQxGCM5HUqoLdXoqffKWRupbNrPFnJg=; b=VNWGYNhNf82mLHPwF/9rBDPUL1RiHspEEq1B9ib6Q8OfZl4hTfSvvc5kTVWvEZPRYM Cqa9OiWA6+58WjlGgVpelNSgaifcq8SJG+wRRYQAwiR4TRJXTC3vFJzK1EDkbd5zbS2D 0/7QdUfbnZQmj7KJyqaNSVldoDJESHSgVKbfIAiMB9LjaQi8rRZv+rfNagajr9coNd63 D7Ta7HIXimvAtVaUEpyEiHpxl+fuyektTL4cbyOKPckrNK2BUy74+VtddfGeNTDMpOzi LYgeHXzp28n1veP8szm3Huiyw+BNgz2i1RW5Bn6VbWbkeTSCbcrUxQ3IiVuRaNHP3D+l HpNA== X-Gm-Message-State: ALoCoQmNBACEtEeiGA/n7mjw4lJdcnOq1pgFGEr8+KVHJpJo34X8kBsFHqPFRgKMpYWWcd/iCFty X-Received: by 10.112.35.135 with SMTP id h7mr2331878lbj.23.1424801131927; Tue, 24 Feb 2015 10:05:31 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.28.132 with SMTP id b4ls723091lah.33.gmail; Tue, 24 Feb 2015 10:05:31 -0800 (PST) X-Received: by 10.152.234.43 with SMTP id ub11mr15564623lac.42.1424801131630; Tue, 24 Feb 2015 10:05:31 -0800 (PST) Received: from mail-la0-f44.google.com (mail-la0-f44.google.com. [209.85.215.44]) by mx.google.com with ESMTPS id z7si26720749laj.61.2015.02.24.10.05.31 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Feb 2015 10:05:31 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) client-ip=209.85.215.44; Received: by labgd6 with SMTP id gd6so27447701lab.7 for ; Tue, 24 Feb 2015 10:05:31 -0800 (PST) X-Received: by 10.152.22.67 with SMTP id b3mr15126389laf.117.1424801131518; Tue, 24 Feb 2015 10:05:31 -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 h5csp2078593lbj; Tue, 24 Feb 2015 10:05:30 -0800 (PST) X-Received: by 10.229.3.8 with SMTP id 8mr8168435qcl.12.1424801125748; Tue, 24 Feb 2015 10:05:25 -0800 (PST) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id 14si9773722qgt.23.2015.02.24.10.05.22 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 24 Feb 2015 10:05:25 -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 1YQJqT-0001na-Qm; Tue, 24 Feb 2015 18:04:33 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YQJqR-0001k6-Cj for xen-devel@lists.xen.org; Tue, 24 Feb 2015 18:04:31 +0000 Received: from [85.158.139.211] by server-3.bemta-5.messagelabs.com id 7D/38-02994-E2DBCE45; Tue, 24 Feb 2015 18:04:30 +0000 X-Env-Sender: ard.biesheuvel@linaro.org X-Msg-Ref: server-16.tower-206.messagelabs.com!1424801069!8214095!1 X-Originating-IP: [209.85.212.173] 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 14848 invoked from network); 24 Feb 2015 18:04:29 -0000 Received: from mail-wi0-f173.google.com (HELO mail-wi0-f173.google.com) (209.85.212.173) by server-16.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 24 Feb 2015 18:04:29 -0000 Received: by mail-wi0-f173.google.com with SMTP id bs8so27556236wib.0 for ; Tue, 24 Feb 2015 10:04:29 -0800 (PST) X-Received: by 10.194.239.65 with SMTP id vq1mr10489011wjc.98.1424801069342; Tue, 24 Feb 2015 10:04:29 -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.25 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 24 Feb 2015 10:04:27 -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:48 +0000 Message-Id: <1424800990-15777-8-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 07/29] ArmVirtualizationPkg: use a HOB to store device tree blob 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.44 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: Instead of using a dynamic PCD, store the device tree address in a HOB so that we can also run under a configuration that does not support dynamic PCDs. This also adds MemoryAllocationLib to the [LibraryClasses] section of ArmVirtualizationPlatformLib/ArmVirtualizationPlatformLib.inf, as this dependency was formerly satisfied transitively through one of the library dependencies that were dropped. Contributed-under: TianoCore Contribution Agreement 1.0 Reviewed-by: Laszlo Ersek Reviewed-by: Olivier Martin Signed-off-by: Ard Biesheuvel --- .../ArmVirtualizationPkg/ArmVirtualizationPkg.dec | 2 -- .../ArmVirtualizationPkg/ArmVirtualizationQemu.dsc | 3 --- .../ArmVirtualizationPlatformLib.inf | 3 +-- .../Library/PlatformPeiLib/PlatformPeiLib.c | 11 ++++++--- .../Library/PlatformPeiLib/PlatformPeiLib.inf | 4 +--- .../ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c | 10 +++++++-- .../ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf | 3 ++- EmbeddedPkg/EmbeddedPkg.dec | 2 ++ EmbeddedPkg/Include/Guid/FdtHob.h | 26 ++++++++++++++++++++++ 9 files changed, 48 insertions(+), 16 deletions(-) create mode 100644 EmbeddedPkg/Include/Guid/FdtHob.h diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationPkg.dec b/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationPkg.dec index ddb79904fa85..7ab2405b8848 100644 --- a/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationPkg.dec +++ b/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationPkg.dec @@ -44,8 +44,6 @@ gArmVirtualizationTokenSpaceGuid.PcdDeviceTreeInitialBaseAddress|0x0|UINT64|0x00000001 [PcdsDynamic, PcdsFixedAtBuild] - gArmVirtualizationTokenSpaceGuid.PcdDeviceTreeBaseAddress|0x0|UINT64|0x00000002 - # # ARM PSCI function invocations can be done either through hypervisor # calls (HVC) or secure monitor calls (SMC). diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc b/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc index 035437482c1d..0dc072e70fbd 100644 --- a/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc +++ b/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc @@ -191,9 +191,6 @@ # System Memory Size -- 1 MB initially, actual size will be fetched from DT gArmTokenSpaceGuid.PcdSystemMemorySize|0x00100000 - # location of the device tree blob passed by QEMU - gArmVirtualizationTokenSpaceGuid.PcdDeviceTreeBaseAddress|0x0 - gArmTokenSpaceGuid.PcdArmArchTimerSecIntrNum|0x0 gArmTokenSpaceGuid.PcdArmArchTimerIntrNum|0x0 gArmTokenSpaceGuid.PcdArmArchTimerVirtIntrNum|0x0 diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/Library/ArmVirtualizationPlatformLib/ArmVirtualizationPlatformLib.inf b/ArmPlatformPkg/ArmVirtualizationPkg/Library/ArmVirtualizationPlatformLib/ArmVirtualizationPlatformLib.inf index 43b3c6ca1bef..2cff4b62ea0c 100644 --- a/ArmPlatformPkg/ArmVirtualizationPkg/Library/ArmVirtualizationPlatformLib/ArmVirtualizationPlatformLib.inf +++ b/ArmPlatformPkg/ArmVirtualizationPkg/Library/ArmVirtualizationPlatformLib/ArmVirtualizationPlatformLib.inf @@ -30,11 +30,10 @@ [LibraryClasses] IoLib + MemoryAllocationLib ArmLib PrintLib FdtLib - SerialPortLib - HobLib [Sources.common] Virt.c diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformPeiLib/PlatformPeiLib.c b/ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformPeiLib/PlatformPeiLib.c index 58bc2b828dcd..c500d5964b25 100644 --- a/ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformPeiLib/PlatformPeiLib.c +++ b/ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformPeiLib/PlatformPeiLib.c @@ -22,6 +22,7 @@ #include #include +#include EFI_STATUS EFIAPI @@ -32,6 +33,7 @@ PlatformPeim ( VOID *Base; VOID *NewBase; UINTN FdtSize; + UINT64 *FdtHobData; UINT64 *UartHobData; INT32 Node, Prev; CONST CHAR8 *Compatible; @@ -41,15 +43,18 @@ PlatformPeim ( UINT64 UartBase; - Base = (VOID*)(UINTN)FixedPcdGet64 (PcdDeviceTreeInitialBaseAddress); + Base = (VOID*)(UINTN)PcdGet64 (PcdDeviceTreeInitialBaseAddress); + ASSERT (Base != NULL); ASSERT (fdt_check_header (Base) == 0); FdtSize = fdt_totalsize (Base); NewBase = AllocatePages (EFI_SIZE_TO_PAGES (FdtSize)); ASSERT (NewBase != NULL); - CopyMem (NewBase, Base, FdtSize); - PcdSet64 (PcdDeviceTreeBaseAddress, (UINT64)(UINTN)NewBase); + + FdtHobData = BuildGuidHob (&gFdtHobGuid, sizeof *FdtHobData); + ASSERT (FdtHobData != NULL); + *FdtHobData = (UINTN)NewBase; UartHobData = BuildGuidHob (&gEarlyPL011BaseAddressGuid, sizeof *UartHobData); ASSERT (UartHobData != NULL); diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformPeiLib/PlatformPeiLib.inf b/ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformPeiLib/PlatformPeiLib.inf index a376fbd1f345..96019e4009ff 100644 --- a/ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformPeiLib/PlatformPeiLib.inf +++ b/ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformPeiLib/PlatformPeiLib.inf @@ -41,11 +41,9 @@ gArmTokenSpaceGuid.PcdFvSize gArmVirtualizationTokenSpaceGuid.PcdDeviceTreeInitialBaseAddress -[Pcd] - gArmVirtualizationTokenSpaceGuid.PcdDeviceTreeBaseAddress - [Guids] gEarlyPL011BaseAddressGuid + gFdtHobGuid [Depex] gEfiPeiMemoryDiscoveredPpiGuid diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c b/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c index 041ad88e10bc..e63294a12e11 100644 --- a/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c +++ b/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c @@ -24,10 +24,12 @@ #include #include #include +#include #include #include #include +#include #pragma pack (1) typedef struct { @@ -277,6 +279,7 @@ InitializeVirtFdtDxe ( IN EFI_SYSTEM_TABLE *SystemTable ) { + VOID *Hob; VOID *DeviceTreeBase; INT32 Node, Prev; INT32 RtcNode; @@ -297,8 +300,11 @@ InitializeVirtFdtDxe ( UINT64 FwCfgDataAddress; UINT64 FwCfgDataSize; - DeviceTreeBase = (VOID *)(UINTN)PcdGet64 (PcdDeviceTreeBaseAddress); - ASSERT (DeviceTreeBase != NULL); + Hob = GetFirstGuidHob(&gFdtHobGuid); + if (Hob == NULL || GET_GUID_HOB_DATA_SIZE (Hob) != sizeof (UINT64)) { + return EFI_NOT_FOUND; + } + DeviceTreeBase = (VOID *)(UINTN)*(UINT64 *)GET_GUID_HOB_DATA (Hob); if (fdt_check_header (DeviceTreeBase) != 0) { DEBUG ((EFI_D_ERROR, "%a: No DTB found @ 0x%p\n", __FUNCTION__, DeviceTreeBase)); diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf b/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf index cdfca610604a..bca0f0b5f39b 100644 --- a/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf +++ b/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf @@ -41,13 +41,14 @@ DxeServicesLib FdtLib VirtioMmioDeviceLib + HobLib [Guids] gFdtTableGuid gVirtioMmioTransportGuid + gFdtHobGuid [Pcd] - gArmVirtualizationTokenSpaceGuid.PcdDeviceTreeBaseAddress gArmVirtualizationTokenSpaceGuid.PcdArmPsciMethod gArmVirtualizationTokenSpaceGuid.PcdFwCfgSelectorAddress gArmVirtualizationTokenSpaceGuid.PcdFwCfgDataAddress diff --git a/EmbeddedPkg/EmbeddedPkg.dec b/EmbeddedPkg/EmbeddedPkg.dec index 600d0e54c4b3..2f261ece9212 100644 --- a/EmbeddedPkg/EmbeddedPkg.dec +++ b/EmbeddedPkg/EmbeddedPkg.dec @@ -52,6 +52,8 @@ ## FDT Configuration Table # Include/Guid/Fdt.h gFdtTableGuid = { 0xb1b621d5, 0xf19c, 0x41a5, { 0x83, 0x0b, 0xd9, 0x15, 0x2c, 0x69, 0xaa, 0xe0 } } + # Include/Guid/FdtHob.h + gFdtHobGuid = { 0x16958446, 0x19B7, 0x480B, { 0xB0, 0x47, 0x74, 0x85, 0xAD, 0x3F, 0x71, 0x6D } } [Protocols.common] gHardwareInterruptProtocolGuid = { 0x2890B3EA, 0x053D, 0x1643, { 0xAD, 0x0C, 0xD6, 0x48, 0x08, 0xDA, 0x3F, 0xF1 } } diff --git a/EmbeddedPkg/Include/Guid/FdtHob.h b/EmbeddedPkg/Include/Guid/FdtHob.h new file mode 100644 index 000000000000..287729e0c350 --- /dev/null +++ b/EmbeddedPkg/Include/Guid/FdtHob.h @@ -0,0 +1,26 @@ +/** @file + GUID for the HOB that contains the copy of the flattened device tree blob + + Copyright (C) 2014, Linaro Ltd. + + This program and the accompanying materials are licensed and made available + under the terms and conditions of the BSD License that accompanies this + distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php. + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT + WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef __FDT_HOB_H__ +#define __FDT_HOB_H__ + +#define FDT_HOB_GUID { \ + 0x16958446, 0x19B7, 0x480B, \ + { 0xB0, 0x47, 0x74, 0x85, 0xAD, 0x3F, 0x71, 0x6D } \ + } + +extern EFI_GUID gFdtHobGuid; + +#endif