All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
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
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Subject: [PATCH v3 07/27] ArmVirtualizationPkg: use a HOB to store device tree blob
Date: Tue,  3 Feb 2015 19:19:52 +0000	[thread overview]
Message-ID: <1422991212-9257-8-git-send-email-ard.biesheuvel__25005.3403470249$1422991305$gmane$org@linaro.org> (raw)
In-Reply-To: <1422991212-9257-1-git-send-email-ard.biesheuvel@linaro.org>

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 <lersek@redhat.com>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 .../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 d83117fc6abe..868488906643 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 f38ffd034a59..4f447b8e1da4 100644
--- a/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc
+++ b/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc
@@ -160,9 +160,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 <libfdt.h>
 
 #include <Guid/EarlyPL011BaseAddress.h>
+#include <Guid/FdtHob.h>
 
 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 e8bbea0847c0..3e8ca8da627e 100644
--- a/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c
+++ b/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c
@@ -24,10 +24,12 @@
 #include <Library/DevicePathLib.h>
 #include <Library/PcdLib.h>
 #include <Library/DxeServicesLib.h>
+#include <Library/HobLib.h>
 #include <libfdt.h>
 
 #include <Guid/Fdt.h>
 #include <Guid/VirtioMmioTransport.h>
+#include <Guid/FdtHob.h>
 
 #pragma pack (1)
 typedef struct {
@@ -105,6 +107,7 @@ InitializeVirtFdtDxe (
   IN EFI_SYSTEM_TABLE     *SystemTable
   )
 {
+  VOID                           *Hob;
   VOID                           *DeviceTreeBase;
   INT32                          Node, Prev;
   INT32                          RtcNode;
@@ -125,8 +128,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 dbf0f8eb54bc..2768d7be8093 100644
--- a/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf
+++ b/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf
@@ -40,13 +40,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
-- 
1.8.3.2

  parent reply	other threads:[~2015-02-03 19:19 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-03 19:19 [PATCH v3 00/27] Xen/ARM guest support Ard Biesheuvel
2015-02-03 19:19 ` [PATCH v3 01/27] ArmPkg: allow HYP timer interrupt to be omitted Ard Biesheuvel
2015-02-03 19:19 ` [PATCH v3 02/27] ArmPkg: allow patchable PCDs for memory, FD and FV addresses Ard Biesheuvel
2015-02-03 19:19 ` [PATCH v3 03/27] ArmPlatformPkg: allow patchable PCD for FD base address Ard Biesheuvel
2015-02-03 19:19 ` [PATCH v3 04/27] ArmVirtualizationPkg: add GICv3 detection to VirtFdtDxe Ard Biesheuvel
2015-02-03 19:19 ` [PATCH v3 05/27] ArmVirtualizationPkg: allow patchable PCD for device tree base address Ard Biesheuvel
2015-02-03 19:19 ` [PATCH v3 06/27] ArmVirtualizationPkg: move early UART discovery to PlatformPeim Ard Biesheuvel
2015-02-03 19:19 ` Ard Biesheuvel [this message]
2015-02-03 19:19 ` [PATCH v3 08/27] ArmVirtualizationPkg: add padding to FDT allocation Ard Biesheuvel
2015-02-03 19:19 ` [PATCH v3 09/27] ArmVirtualizationPkg: add a relocatable version of PrePi Ard Biesheuvel
2015-02-11  6:27   ` Olivier Martin
2015-02-03 19:19 ` [PATCH v3 10/27] ArmVirtualizationPkg: implement custom MemoryInitPeiLib Ard Biesheuvel
2015-02-11  6:40   ` Olivier Martin
2015-02-03 19:19 ` [PATCH v3 11/27] ArmVirtualizationPkg: allow patchable PCD for FV and DT base addresses Ard Biesheuvel
2015-02-03 19:19 ` [PATCH v3 12/27] ArmVirtualizationPkg: Xen/PV relocatable platformlib instance Ard Biesheuvel
2015-02-03 19:19 ` [PATCH v3 13/27] Ovmf/Xen: move Xen interface version to <xen.h> Ard Biesheuvel
2015-02-03 19:19 ` [PATCH v3 14/27] Ovmf/Xen: fix pointer to int cast in XenBusDxe Ard Biesheuvel
2015-02-03 19:20 ` [PATCH v3 15/27] Ovmf/Xen: refactor XenBusDxe hypercall implementation Ard Biesheuvel
2015-02-03 19:20 ` [PATCH v3 16/27] Ovmf/Xen: move XenBusDxe hypercall code to separate library Ard Biesheuvel
2015-02-03 19:20 ` [PATCH v3 17/27] Ovmf/Xen: introduce XENIO_PROTOCOL Ard Biesheuvel
2015-02-03 19:20 ` [PATCH v3 18/27] Ovmf/Xen: add separate driver for Xen PCI device Ard Biesheuvel
2015-02-03 19:20 ` [PATCH v3 19/27] Ovmf/Xen: move XenBusDxe to abstract XENIO_PROTOCOL Ard Biesheuvel
2015-02-03 19:20 ` [PATCH v3 20/27] Ovmf/Xen: implement XenHypercallLib for ARM Ard Biesheuvel
2015-02-03 19:20 ` [PATCH v3 21/27] Ovmf/Xen: add ARM and AArch64 support to XenBusDxe Ard Biesheuvel
2015-02-03 19:20 ` [PATCH v3 22/27] Ovmf/Xen: add Xen PV console SerialPortLib driver Ard Biesheuvel
2015-02-03 19:20 ` [PATCH v3 23/27] Ovmf/Xen: implement dummy RealTimeClockLib for Xen Ard Biesheuvel
2015-02-10 12:50   ` Laszlo Ersek
2015-02-11  6:45   ` Olivier Martin
2015-02-03 19:20 ` [PATCH v3 24/27] Ovfm/Xen: add a Vendor Hardware device path GUID for the XenBus root Ard Biesheuvel
2015-02-03 19:20 ` [PATCH v3 25/27] ArmVirtualizationPkg: add XenIoMmioLib Ard Biesheuvel
2015-02-03 19:20 ` [PATCH v3 26/27] ArmVirtualizationPkg/VirtFdtDxe: wire up XenBusDxe to "xen, xen" DT node Ard Biesheuvel
2015-02-03 19:20 ` [PATCH v3 27/27] ArmVirtualizationPkg: add platform description for Xen guests Ard Biesheuvel
     [not found] ` <1422991212-9257-22-git-send-email-ard.biesheuvel@linaro.org>
2015-02-04 16:48   ` [PATCH v3 21/27] Ovmf/Xen: add ARM and AArch64 support to XenBusDxe Stefano Stabellini
2015-02-04 21:10   ` [edk2] " Jordan Justen
     [not found]   ` <20150204211035.11847.54872@jljusten-ivy>
2015-02-05  9:56     ` Ard Biesheuvel
     [not found]     ` <CAKv+Gu-viz4uHj5PxZ1rQz8yc=qtqZGxcC4hgTO2=AdvXbdUgA@mail.gmail.com>
2015-02-07 22:00       ` Jordan Justen
     [not found]       ` <20150207220049.4180.15991@jljusten-ivy>
2015-02-10  3:41         ` Olivier Martin
     [not found] ` <1422991212-9257-8-git-send-email-ard.biesheuvel@linaro.org>
2015-02-09  5:06   ` [PATCH v3 07/27] ArmVirtualizationPkg: use a HOB to store device tree blob Olivier Martin
     [not found] ` <1422991212-9257-9-git-send-email-ard.biesheuvel@linaro.org>
2015-02-09  5:08   ` [PATCH v3 08/27] ArmVirtualizationPkg: add padding to FDT allocation Olivier Martin
     [not found] ` <1422991212-9257-5-git-send-email-ard.biesheuvel@linaro.org>
2015-02-10  4:05   ` [PATCH v3 04/27] ArmVirtualizationPkg: add GICv3 detection to VirtFdtDxe olimar01
     [not found] ` <1422991212-9257-12-git-send-email-ard.biesheuvel@linaro.org>
2015-02-10  9:10   ` [PATCH v3 11/27] ArmVirtualizationPkg: allow patchable PCD for FV and DT base addresses Olivier Martin
     [not found] ` <1422991212-9257-19-git-send-email-ard.biesheuvel@linaro.org>
2015-02-10 11:53   ` [PATCH v3 18/27] Ovmf/Xen: add separate driver for Xen PCI device Laszlo Ersek
     [not found] ` <1422991212-9257-23-git-send-email-ard.biesheuvel@linaro.org>
2015-02-10 12:46   ` [PATCH v3 22/27] Ovmf/Xen: add Xen PV console SerialPortLib driver Laszlo Ersek
     [not found] ` <1422991212-9257-26-git-send-email-ard.biesheuvel@linaro.org>
2015-02-10 13:52   ` [PATCH v3 25/27] ArmVirtualizationPkg: add XenIoMmioLib Laszlo Ersek
     [not found] ` <1422991212-9257-13-git-send-email-ard.biesheuvel@linaro.org>
2015-02-11  3:11   ` [PATCH v3 12/27] ArmVirtualizationPkg: Xen/PV relocatable platformlib instance Olivier Martin
     [not found] ` <1422991212-9257-27-git-send-email-ard.biesheuvel@linaro.org>
2015-02-11  6:46   ` [PATCH v3 26/27] ArmVirtualizationPkg/VirtFdtDxe: wire up XenBusDxe to "xen, xen" DT node Olivier Martin
     [not found] ` <1422991212-9257-28-git-send-email-ard.biesheuvel@linaro.org>
2015-02-11  6:50   ` [PATCH v3 27/27] ArmVirtualizationPkg: add platform description for Xen guests Olivier Martin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='1422991212-9257-8-git-send-email-ard.biesheuvel__25005.3403470249$1422991305$gmane$org@linaro.org' \
    --to=ard.biesheuvel@linaro.org \
    --cc=anthony.perard@citrix.com \
    --cc=christoffer.dall@linaro.org \
    --cc=edk2-devel@lists.sourceforge.net \
    --cc=ian.campbell@citrix.com \
    --cc=ilias.biris@linaro.org \
    --cc=julien.grall@linaro.org \
    --cc=leif.lindholm@linaro.org \
    --cc=lersek@redhat.com \
    --cc=olivier.martin@arm.com \
    --cc=roy.franz@linaro.org \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.