On 09/04/14 08:32, Ard Biesheuvel wrote:
> On 4 September 2014 04:09, Laszlo Ersek <ler...@redhat.com> wrote:
>> Hi Ard,
>>
>> I started to review your v6 patchset in reverse order -- I first created
>> a map between your v5 and v6 patches (as much as it was possible), then
>> started to look at the DSC file(s) first. The requirement to dynamically
>> determine the UART base address from the DTB is a very intrusive one,
>> unfortunately. So, the first thing that caught my eye was the various
>> new instances of the SerialPortLib class.
>>
>> As we discussed on #linaro-enterprise, "EarlyFdtPL011SerialPortLib" is
>> not appropriate for DXE_CORE, because it accesses the initial copy of
>> the DTB (at the bottom of the system DRAM), and at that point, when the
>> DXE_CORE is already running, that memory area is no longer protected
>> (because we decided to relocate it instead of protecting it in-place).
>>
>> So, I didn't get very far in the v6 review, but I do think I can propose
>> an improvement for the DXE_CORE's serial port library. Please see the
>> following patches.
>>
> 
> Looks great, thanks! I will look in more detail later today, but one
> thing comes to mind already:
> since the PcdGet() call in the constructor of the ordinary FdtPL011
> library is causing dependency hell and the need for a cloned
> UefiBootServicesTableLib, is there any reason we can't use your
> DXE_CORE version for *all* stages after DXE_CORE as well?

I'm very pleased that you too realized this possibility.

Unfortunately, it doesn't work. I tested it, and only upon seeing that
it didn't work did I elect to post this version of the fixup series.
(This is the reason I posted the series after 4AM, and not at 01:30AM.)

Namely, the HobLib class has three instances:

  HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf
  HobLib|MdePkg/Library/DxeCoreHobLib/DxeCoreHobLib.inf
  HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf

The PEI flavor allows linking against PEIM PEI_CORE SEC, but it doesn't
work in SEC (at least with the other lib resolutions that are used in
ArmPlatformPkg -- FWIW I didn't test it out elsewhere). It is not
relevant right now, I'm just mentioning it because originally I even
tried to set the HOB in SEC, so that *all* SerialPortLib instances would
the HOB based approach, but it didn't fly.  PeiHobLib doesn't work in
SEC, because needed PEI services are not available. And, in PEI itself,
it would be a mess to order some PEIMs (providing those services)
against other PEIMs. Hence I preserved your EarlyFdt implementation for
PEIM PEI_CORE SEC; it works fine.

The DxeCoreHobLib instance is only usable with DXE_CORE, and it has no
CONSTRUCTOR. (You do see where this is going!) This allows the
DxeCoreSerialPortLib instance I posted to work "automagically", even
though it depends on HobLib. (Because, DxeCoreHobLib depends on DebugLib
depends on DxeCoreSerialPortLib...) It all works because DxeCoreHobLib
uses "gHobList", without a constructor, which just comes from
"MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint.c". IOW we do
exploit that we're in the DXE_CORE -- the DXE_CORE has a special HobLib
instance.

No such luck with DxeHobLib. That one has a CONSTRUCTOR, and BuildTools
immediately detect a circular dependency involving DxeHobLib (depending
on DebugLib depending on this new SerialPortLib depending on HobLib). If
I update the new, HOB-dependent SerialPortLib instance, removing its
constructor, and initializing it in its SerialPortInitialize() function
instead, then BuildTools don't detect a cycle -- and upon realizing
this, I *mistakenly* posted "I've seen the light" in the other thread.
Except it doesn't work, because the *exact same* constructor call order
problem hits. Namely, in the VirtFdtDxe module, DebugLib's constructor
calls SerialPortInitialize() manually, which calls GetFirstGuidHob(),
and that blows up because DxeHobLib's CONSTRUCTOR has not yet run.

This is a pity because this approach otherwise allowed me to completely
remove both PcdPL011BaseAddress and the forked UefiBootServicesTableLib.
To my dismay however, replacing our dependency on dynamic PCDs in
SerialPortLib with a dependency on HOBs reintroduces the exact same kind
of circular mess. This clearly shows that SerialPortLib had always been
designed to be 100% self-contained, and we're violating that by trying
to use dynamic PCDs *or* HOBs in it, generally. We only get lucky in
DXE_CORE with HOBs (because there a HOB dependency happens to work), and
in the other (later) DXE module types with dynamic PCDs (because you
hacked around the construction order with your forked
UefiBootServicesTableLib).

My proposal is to go with this mixed approach (and pray that the above
luck not run out), or to own up to the design constraints of
SerialPortLib, and stick with a FixedAtBuild UART base address.
(Honestly, I don't perceive that to be a grave limitation.)

> Getting the
> base address from a HOB and caching it doesn't seem more heavy weight
> than getting it from a Dynamic PCD, and it would allow us to drop some
> of the nasty stuff.

Yes, it does, but it also reintroduces the same kind of circular
dependencies, just with different names. I guess it could be worked
around by cloning DxeHobLib, and removing its DebugLib dependency, but
then again you did the exact same thing with UefiBootServicesTableLib,
and that one is actually a much simpler library.

I can send you this version of the "fixup patchset" if you'd like to
experiment with it. As far as I see, *everything* in edk2 seems to
depend on DebugLib, whose serial port instance depends on SerialPortLib,
which is expected to be fully standalone. It is not just an
implementation shortcoming, it's a theoretical problem -- if you need
some HOB to be able to log a message, then you can't log messages in the
HOB library itself, especially not in its CONSTRUCTOR.

Note that such problems don't occur in OVMF due to a very simple reason:
we have our DebugLib instance that plainly hardwires the qemu debug
ioport (it's not even a serial port). Which would correspond, on ARM, to
using a fixed UART base address.

In summary, there are three options:
- revert the dynamic UART base address feature, stick with fixed

- use your approach (UefiBootServicesTableLib dependency hack), just
  fix it up with this followup series for the DXE_CORE

- opt for a clean HOB-based approach, and sever the circular
  dependencies by cloning every library instance that inconveniently
  depends on DebugLib (like DxeHobLib), and kill those DebugLib deps.
  At least determining the set of these libraries is fairly simple,
  because SerialPortLib's CONSTRUCTOR (if it has one) triggers the
  cycle check.

Basically, by enabling SerialPortLib to depend on other facilities, we
must shift the "100% self-reliance" property to some of those other
facilities.

You know what, I'm attaching the HOB-based approach; perhaps you'd like
to experiment with option #3. The first four patches are shared between
the two versions (up to and including "ArmVirtualizationPlatformLib:
lock down client module types"), they diverge at patch #5
("ArmVirtualizationPlatformLib: stash dynamic UART base in a HOB in the
PEI code").

Thanks,
Laszlo
From 80e2f8427dd3790d241fd3d245b64c5db971b0cb Mon Sep 17 00:00:00 2001
From: Laszlo Ersek <ler...@redhat.com>
Date: Wed, 3 Sep 2014 22:06:53 +0200
Subject: [PATCH 01/12] ArmVirtualizationPkg: DSC: fix line endings

they all should be CRLF.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <ler...@redhat.com>
---
 .../ArmVirtualizationPkg/ArmVirtualization.dsc.inc | 44 +++++++++++-----------
 1 file changed, 22 insertions(+), 22 deletions(-)

diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualization.dsc.inc b/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualization.dsc.inc
index ff38b76..43aeb59 100644
--- a/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualization.dsc.inc
+++ b/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualization.dsc.inc
@@ -54,12 +54,12 @@
   #BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
   BaseMemoryLib|ArmPkg/Library/BaseMemoryLibStm/BaseMemoryLibStm.inf
 
-  # Networking Requirements
-  NetLib|MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf
-  DpcLib|MdeModulePkg/Library/DxeDpcLib/DxeDpcLib.inf
-  UdpIoLib|MdeModulePkg/Library/DxeUdpIoLib/DxeUdpIoLib.inf
-  IpIoLib|MdeModulePkg/Library/DxeIpIoLib/DxeIpIoLib.inf
-
+  # Networking Requirements
+  NetLib|MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf
+  DpcLib|MdeModulePkg/Library/DxeDpcLib/DxeDpcLib.inf
+  UdpIoLib|MdeModulePkg/Library/DxeUdpIoLib/DxeUdpIoLib.inf
+  IpIoLib|MdeModulePkg/Library/DxeIpIoLib/DxeIpIoLib.inf
+
   # ARM Architectural Libraries
   CacheMaintenanceLib|ArmPkg/Library/ArmCacheMaintenanceLib/ArmCacheMaintenanceLib.inf
   DefaultExceptionHandlerLib|ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLib.inf
@@ -317,19 +317,19 @@
   #
   gArmTokenSpaceGuid.PcdArmUncachedMemoryMask|0x0000000000000000
 
-[Components.common]
-  #
-  # Networking stack
-  #
-  MdeModulePkg/Universal/Network/DpcDxe/DpcDxe.inf
-  MdeModulePkg/Universal/Network/ArpDxe/ArpDxe.inf
-  MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Dxe.inf
-  MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDxe.inf
-  MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Dxe.inf
-  MdeModulePkg/Universal/Network/MnpDxe/MnpDxe.inf
-  MdeModulePkg/Universal/Network/VlanConfigDxe/VlanConfigDxe.inf
-  MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Dxe.inf
-  MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Dxe.inf
-  MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Dxe.inf
-  MdeModulePkg/Universal/Network/UefiPxeBcDxe/UefiPxeBcDxe.inf
-  MdeModulePkg/Universal/Network/IScsiDxe/IScsiDxe.inf
+[Components.common]
+  #
+  # Networking stack
+  #
+  MdeModulePkg/Universal/Network/DpcDxe/DpcDxe.inf
+  MdeModulePkg/Universal/Network/ArpDxe/ArpDxe.inf
+  MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Dxe.inf
+  MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDxe.inf
+  MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Dxe.inf
+  MdeModulePkg/Universal/Network/MnpDxe/MnpDxe.inf
+  MdeModulePkg/Universal/Network/VlanConfigDxe/VlanConfigDxe.inf
+  MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Dxe.inf
+  MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Dxe.inf
+  MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Dxe.inf
+  MdeModulePkg/Universal/Network/UefiPxeBcDxe/UefiPxeBcDxe.inf
+  MdeModulePkg/Universal/Network/IScsiDxe/IScsiDxe.inf
-- 
1.8.3.1

From 82c9821849516c664c26cb7e1c76cc2232e2e449 Mon Sep 17 00:00:00 2001
From: Laszlo Ersek <ler...@redhat.com>
Date: Wed, 3 Sep 2014 20:35:16 +0200
Subject: [PATCH 02/12] ArmVirtualizationPkg: introduce
 gEarlyPL011BaseAddressGuid

This GUID will identify a customized HOB that carries the base address of
the PL011 serial port, for clients that cannot access PCDs.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <ler...@redhat.com>
---
 .../Include/Guid/EarlyPL011BaseAddress.h           | 27 ++++++++++++++++++++++
 .../ArmVirtualizationPkg/ArmVirtualizationPkg.dec  |  1 +
 2 files changed, 28 insertions(+)
 create mode 100644 ArmPlatformPkg/ArmVirtualizationPkg/Include/Guid/EarlyPL011BaseAddress.h

diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/Include/Guid/EarlyPL011BaseAddress.h b/ArmPlatformPkg/ArmVirtualizationPkg/Include/Guid/EarlyPL011BaseAddress.h
new file mode 100644
index 0000000..1b703a81
--- /dev/null
+++ b/ArmPlatformPkg/ArmVirtualizationPkg/Include/Guid/EarlyPL011BaseAddress.h
@@ -0,0 +1,27 @@
+/** @file
+  GUID for the HOB that caches the base address of the PL011 serial port, for
+  when PCD access is not available.
+
+  Copyright (C) 2014, Red Hat, Inc.
+
+  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 __EARLY_PL011_BASE_ADDRESS_H__
+#define __EARLY_PL011_BASE_ADDRESS_H__
+
+#define EARLY_PL011_BASE_ADDRESS_GUID { \
+          0xB199DEA9, 0xFD5C, 0x4A84, \
+          { 0x80, 0x82, 0x2F, 0x41, 0x70, 0x78, 0x03, 0x05 } \
+        }
+
+extern EFI_GUID gEarlyPL011BaseAddressGuid;
+
+#endif
diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationPkg.dec b/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationPkg.dec
index 37f00a2..34833aa 100644
--- a/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationPkg.dec
+++ b/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationPkg.dec
@@ -32,6 +32,7 @@
 
 [Guids.common]
   gArmVirtualizationTokenSpaceGuid = { 0x0B6F5CA7, 0x4F53, 0x445A, { 0xB7, 0x6E, 0x2E, 0x36, 0x5B, 0x80, 0x63, 0x66 } }
+  gEarlyPL011BaseAddressGuid       = { 0xB199DEA9, 0xFD5C, 0x4A84, { 0x80, 0x82, 0x2F, 0x41, 0x70, 0x78, 0x03, 0x05 } }
 
 [PcdsFixedAtBuild]
   #
-- 
1.8.3.1

From 2639e31570592ee042c65ea44c113817788d693a Mon Sep 17 00:00:00 2001
From: Laszlo Ersek <ler...@redhat.com>
Date: Wed, 3 Sep 2014 21:40:07 +0200
Subject: [PATCH 03/12] ArmVirtualizationPkg: DSC: resolve HobLib dependencies
 for SEC

In the next patch we'll add HobLib client code to the PEI half of our
ArmVirtualizationPlatformLib library. However, the library as a whole is
used in both SEC and PEI modules. Although HobLib is unusable in SEC
(because we don't have the necessary PEI services ready yet), and we
actually don't use HobLib in the SEC-invoked part of the library, we add
the necessary library resolutions for SEC, so that the module compiles for
SEC.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <ler...@redhat.com>
---
 ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualization.dsc.inc | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualization.dsc.inc b/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualization.dsc.inc
index 43aeb59..682113d 100644
--- a/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualization.dsc.inc
+++ b/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualization.dsc.inc
@@ -116,6 +116,10 @@
   DebugAgentLib|ArmPkg/Library/DebugAgentSymbolsBaseLib/DebugAgentSymbolsBaseLib.inf
   DefaultExceptionHandlerLib|ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLibBase.inf
   SerialPortLib|ArmPlatformPkg/ArmVirtualizationPkg/Library/FdtPL011SerialPortLib/EarlyFdtPL011SerialPortLib.inf
+  HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf
+  PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf
+  PeiServicesTablePointerLib|ArmPlatformPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
+  MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf
   
 [LibraryClasses.common.PEI_CORE]
   PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf
-- 
1.8.3.1

From b5b96fa9b86cb4b85a1380e6cd5b7e5c86e8d7f5 Mon Sep 17 00:00:00 2001
From: Laszlo Ersek <ler...@redhat.com>
Date: Wed, 3 Sep 2014 21:45:16 +0200
Subject: [PATCH 04/12] ArmVirtualizationPlatformLib: lock down client module
 types

Also, clean up a number of phase-related comments.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <ler...@redhat.com>
---
 .../ArmVirtualizationPlatformLib/ArmVirtualizationPlatformLib.inf | 2 +-
 .../Library/ArmVirtualizationPlatformLib/Virt.c                   | 8 +++-----
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/Library/ArmVirtualizationPlatformLib/ArmVirtualizationPlatformLib.inf b/ArmPlatformPkg/ArmVirtualizationPkg/Library/ArmVirtualizationPlatformLib/ArmVirtualizationPlatformLib.inf
index 5bb7f07..241766b 100644
--- a/ArmPlatformPkg/ArmVirtualizationPkg/Library/ArmVirtualizationPlatformLib/ArmVirtualizationPlatformLib.inf
+++ b/ArmPlatformPkg/ArmVirtualizationPkg/Library/ArmVirtualizationPlatformLib/ArmVirtualizationPlatformLib.inf
@@ -18,7 +18,7 @@
   FILE_GUID                      = 00214cc1-06d1-45fe-9700-dca5726ad7bf
   MODULE_TYPE                    = BASE
   VERSION_STRING                 = 1.0
-  LIBRARY_CLASS                  = ArmPlatformLib
+  LIBRARY_CLASS                  = ArmPlatformLib|SEC PEIM
 
 [Packages]
   MdePkg/MdePkg.dec
diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/Library/ArmVirtualizationPlatformLib/Virt.c b/ArmPlatformPkg/ArmVirtualizationPkg/Library/ArmVirtualizationPlatformLib/Virt.c
index c1820d5..c10ef91 100644
--- a/ArmPlatformPkg/ArmVirtualizationPkg/Library/ArmVirtualizationPlatformLib/Virt.c
+++ b/ArmPlatformPkg/ArmVirtualizationPkg/Library/ArmVirtualizationPlatformLib/Virt.c
@@ -38,11 +38,7 @@ ArmPlatformGetBootMode (
 }
 
 /**
-  Initialize controllers that must setup in the normal world
-
-  This function is called by the ArmPlatformPkg/Pei or ArmPlatformPkg/Pei/PlatformPeim
-  in the PEI phase.
-
+  This function is called by PrePeiCore, in the SEC phase.
 **/
 RETURN_STATUS
 ArmPlatformInitialize (
@@ -62,6 +58,8 @@ ArmPlatformInitialize (
 
   This memory is generally represented by the DRAM.
 
+  This function is called from InitializeMemory() in MemoryInitPeim, in the PEI
+  phase.
 **/
 VOID
 ArmPlatformInitializeSystemMemory (
-- 
1.8.3.1

From 2a1dc695033a93cb1c30bde75ea3feb62b43a496 Mon Sep 17 00:00:00 2001
From: Laszlo Ersek <ler...@redhat.com>
Date: Wed, 3 Sep 2014 21:32:35 +0200
Subject: [PATCH 05/12] ArmVirtualizationPlatformLib: stash dynamic UART base
 in a HOB in the PEI code

In this patch we stash the dynamic UART base in a HOB, for the DXE_CORE
and later modules, instead of a dynamic PCD.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <ler...@redhat.com>
---
 .../ArmVirtualizationPlatformLib.inf                      |  5 ++++-
 .../Library/ArmVirtualizationPlatformLib/Virt.c           | 15 ++++++++++++++-
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/Library/ArmVirtualizationPlatformLib/ArmVirtualizationPlatformLib.inf b/ArmPlatformPkg/ArmVirtualizationPkg/Library/ArmVirtualizationPlatformLib/ArmVirtualizationPlatformLib.inf
index 241766b..b635975 100644
--- a/ArmPlatformPkg/ArmVirtualizationPkg/Library/ArmVirtualizationPlatformLib/ArmVirtualizationPlatformLib.inf
+++ b/ArmPlatformPkg/ArmVirtualizationPkg/Library/ArmVirtualizationPlatformLib/ArmVirtualizationPlatformLib.inf
@@ -34,6 +34,7 @@
   PrintLib
   FdtLib
   SerialPortLib
+  HobLib
 
 [Sources.common]
   Virt.c
@@ -51,7 +52,6 @@
 
 [Pcd]
   gArmTokenSpaceGuid.PcdSystemMemorySize
-  gArmVirtualizationTokenSpaceGuid.PcdPL011BaseAddress
 
 [FixedPcd]
   gArmVirtualizationTokenSpaceGuid.PcdDeviceTreeInitialBaseAddress
@@ -61,3 +61,6 @@
   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 c10ef91..f4c32b1 100644
--- a/ArmPlatformPkg/ArmVirtualizationPkg/Library/ArmVirtualizationPlatformLib/Virt.c
+++ b/ArmPlatformPkg/ArmVirtualizationPkg/Library/ArmVirtualizationPlatformLib/Virt.c
@@ -2,6 +2,7 @@
 *
 *  Copyright (c) 2011-2013, ARM Limited. All rights reserved.
 *  Copyright (c) 2014, Linaro Limited. All rights reserved.
+*  Copyright (c) 2014, Red Hat, Inc.
 *
 *
 *  This program and the accompanying materials
@@ -20,6 +21,12 @@
 #include <Library/PcdLib.h>
 #include <ArmPlatform.h>
 #include <libfdt.h>
+#include <Pi/PiBootMode.h>
+#include <Uefi/UefiBaseType.h>
+#include <Uefi/UefiMultiPhase.h>
+#include <Pi/PiHob.h>
+#include <Library/HobLib.h>
+#include <Guid/EarlyPL011BaseAddress.h>
 
 /**
   Return the current Boot Mode
@@ -71,6 +78,7 @@ ArmPlatformInitializeSystemMemory (
   UINT64  NewBase;
   UINT64  NewSize;
   BOOLEAN HaveMemory, HaveUART;
+  UINT64  *HobData;
 
   NewBase = 0;
   NewSize = 0;
@@ -78,6 +86,10 @@ ArmPlatformInitializeSystemMemory (
   HaveMemory = FALSE;
   HaveUART = FALSE;
 
+  HobData = BuildGuidHob (&gEarlyPL011BaseAddressGuid, sizeof *HobData);
+  ASSERT (HobData != NULL);
+  *HobData = 0;
+
   DeviceTreeBase = (VOID *)(UINTN)FixedPcdGet64 (PcdDeviceTreeInitialBaseAddress);
   ASSERT (DeviceTreeBase != NULL);
 
@@ -154,7 +166,8 @@ ArmPlatformInitializeSystemMemory (
 
         DEBUG ((EFI_D_INFO, "%a: PL011 UART @ 0x%lx\n", __FUNCTION__, UartBase));
 
-        PcdSet64 (PcdPL011BaseAddress, UartBase);
+        *HobData = UartBase;
+
         HaveUART = TRUE;
         continue;
       }
-- 
1.8.3.1

From c46280351622ec844307792a2043c5c3c9349a9e Mon Sep 17 00:00:00 2001
From: Laszlo Ersek <ler...@redhat.com>
Date: Wed, 3 Sep 2014 21:36:14 +0200
Subject: [PATCH 06/12] ArmVirtualizationPkg: FdtPL011SerialPortLib: lock down
 allowed clients

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <ler...@redhat.com>
---
 .../Library/FdtPL011SerialPortLib/EarlyFdtPL011SerialPortLib.inf        | 2 +-
 .../Library/FdtPL011SerialPortLib/FdtPL011SerialPortLib.inf             | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/Library/FdtPL011SerialPortLib/EarlyFdtPL011SerialPortLib.inf b/ArmPlatformPkg/ArmVirtualizationPkg/Library/FdtPL011SerialPortLib/EarlyFdtPL011SerialPortLib.inf
index 4db0513..d62f87b 100644
--- a/ArmPlatformPkg/ArmVirtualizationPkg/Library/FdtPL011SerialPortLib/EarlyFdtPL011SerialPortLib.inf
+++ b/ArmPlatformPkg/ArmVirtualizationPkg/Library/FdtPL011SerialPortLib/EarlyFdtPL011SerialPortLib.inf
@@ -20,7 +20,7 @@
   FILE_GUID                      = 0983616A-49BC-4732-B531-4AF98D2056F0
   MODULE_TYPE                    = BASE
   VERSION_STRING                 = 1.0
-  LIBRARY_CLASS                  = SerialPortLib
+  LIBRARY_CLASS                  = SerialPortLib|SEC PEI_CORE PEIM
 
 [Sources.common]
   EarlyFdtPL011SerialPortLib.c
diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/Library/FdtPL011SerialPortLib/FdtPL011SerialPortLib.inf b/ArmPlatformPkg/ArmVirtualizationPkg/Library/FdtPL011SerialPortLib/FdtPL011SerialPortLib.inf
index b4fc712..826ddb8 100644
--- a/ArmPlatformPkg/ArmVirtualizationPkg/Library/FdtPL011SerialPortLib/FdtPL011SerialPortLib.inf
+++ b/ArmPlatformPkg/ArmVirtualizationPkg/Library/FdtPL011SerialPortLib/FdtPL011SerialPortLib.inf
@@ -20,7 +20,7 @@
   FILE_GUID                      = 0983616A-49BC-4732-B531-4AF98D2056F0
   MODULE_TYPE                    = BASE
   VERSION_STRING                 = 1.0
-  LIBRARY_CLASS                  = SerialPortLib
+  LIBRARY_CLASS                  = SerialPortLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER UEFI_DRIVER
   CONSTRUCTOR                    = FdtPL011SerialPortLibInitialize
 
 [Sources.common]
-- 
1.8.3.1

From 29b6cfa93ba94c371c83fe888b67d376122ab42e Mon Sep 17 00:00:00 2001
From: Laszlo Ersek <ler...@redhat.com>
Date: Wed, 3 Sep 2014 23:30:03 +0200
Subject: [PATCH 07/12] FdtPL011SerialPortLib.inf: drop bogus
 PcdSystemMemorySize reference

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <ler...@redhat.com>
---
 .../Library/FdtPL011SerialPortLib/FdtPL011SerialPortLib.inf              | 1 -
 1 file changed, 1 deletion(-)

diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/Library/FdtPL011SerialPortLib/FdtPL011SerialPortLib.inf b/ArmPlatformPkg/ArmVirtualizationPkg/Library/FdtPL011SerialPortLib/FdtPL011SerialPortLib.inf
index 826ddb8..b77ede9 100644
--- a/ArmPlatformPkg/ArmVirtualizationPkg/Library/FdtPL011SerialPortLib/FdtPL011SerialPortLib.inf
+++ b/ArmPlatformPkg/ArmVirtualizationPkg/Library/FdtPL011SerialPortLib/FdtPL011SerialPortLib.inf
@@ -47,4 +47,3 @@
 
 [Pcd]
   gArmVirtualizationTokenSpaceGuid.PcdPL011BaseAddress
-  gArmTokenSpaceGuid.PcdSystemMemorySize
-- 
1.8.3.1

From df533f85f279c8a60eaba64f64c028951594091b Mon Sep 17 00:00:00 2001
From: Laszlo Ersek <ler...@redhat.com>
Date: Wed, 3 Sep 2014 23:15:26 +0200
Subject: [PATCH 08/12] FdtPL011SerialPortLib: add DXE implementation

By rebasing this library from a dynamic PCD to a HOB, we can:
- eliminate the false dependency on UefiBootServicesTableLib
- employ the library in DXE_CORE (where no dynamic PCD servies are
  available)

In addition, this library cannot have a constructor, otherwise a circular
dependency emerges between DxeHobLib and BaseDebugLibSerialPort. (This
explains why BaseTools excludes constructor-less libraries from dependency
tracking, and why we have a manual SerialPortInitialize() function.)

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <ler...@redhat.com>
---
 .../DxePL011SerialPortLib.inf                      |  45 +++++++
 .../FdtPL011SerialPortLib.inf                      |  49 -------
 .../FdtPL011SerialPortLib/DxePL011SerialPortLib.c  | 141 ++++++++++++++++++++
 .../FdtPL011SerialPortLib/FdtPL011SerialPortLib.c  | 145 ---------------------
 4 files changed, 186 insertions(+), 194 deletions(-)
 create mode 100644 ArmPlatformPkg/ArmVirtualizationPkg/Library/FdtPL011SerialPortLib/DxePL011SerialPortLib.inf
 delete mode 100644 ArmPlatformPkg/ArmVirtualizationPkg/Library/FdtPL011SerialPortLib/FdtPL011SerialPortLib.inf
 create mode 100644 ArmPlatformPkg/ArmVirtualizationPkg/Library/FdtPL011SerialPortLib/DxePL011SerialPortLib.c
 delete mode 100644 ArmPlatformPkg/ArmVirtualizationPkg/Library/FdtPL011SerialPortLib/FdtPL011SerialPortLib.c

diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/Library/FdtPL011SerialPortLib/DxePL011SerialPortLib.inf b/ArmPlatformPkg/ArmVirtualizationPkg/Library/FdtPL011SerialPortLib/DxePL011SerialPortLib.inf
new file mode 100644
index 0000000..b38e478
--- /dev/null
+++ b/ArmPlatformPkg/ArmVirtualizationPkg/Library/FdtPL011SerialPortLib/DxePL011SerialPortLib.inf
@@ -0,0 +1,45 @@
+#/** @file
+#
+#  Component description file for DxePL011SerialPortLib module
+#
+#  Copyright (c) 2011-2012, ARM Ltd. All rights reserved.<BR>
+#
+#  This program and the accompanying materials
+#  are licensed and made available under the terms and conditions of the BSD License
+#  which 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.
+#
+#**/
+
+[Defines]
+  INF_VERSION                    = 0x00010005
+  BASE_NAME                      = DxePL011SerialPortLib
+  FILE_GUID                      = 0983616A-49BC-4732-B531-4AF98D2056F0
+  MODULE_TYPE                    = BASE
+  VERSION_STRING                 = 1.0
+  LIBRARY_CLASS                  = SerialPortLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER UEFI_DRIVER
+
+[Sources.common]
+  DxePL011SerialPortLib.c
+
+[LibraryClasses]
+  PL011UartLib
+  PcdLib
+  HobLib
+
+[Packages]
+  MdePkg/MdePkg.dec
+  ArmPlatformPkg/ArmPlatformPkg.dec
+  ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationPkg.dec
+
+[FixedPcd]
+  gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate
+  gEfiMdePkgTokenSpaceGuid.PcdUartDefaultDataBits
+  gEfiMdePkgTokenSpaceGuid.PcdUartDefaultParity
+  gEfiMdePkgTokenSpaceGuid.PcdUartDefaultStopBits
+
+[Guids]
+  gEarlyPL011BaseAddressGuid
diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/Library/FdtPL011SerialPortLib/FdtPL011SerialPortLib.inf b/ArmPlatformPkg/ArmVirtualizationPkg/Library/FdtPL011SerialPortLib/FdtPL011SerialPortLib.inf
deleted file mode 100644
index b77ede9..0000000
--- a/ArmPlatformPkg/ArmVirtualizationPkg/Library/FdtPL011SerialPortLib/FdtPL011SerialPortLib.inf
+++ /dev/null
@@ -1,49 +0,0 @@
-#/** @file
-#
-#  Component description file for PL011SerialPortLib module
-#
-#  Copyright (c) 2011-2012, ARM Ltd. All rights reserved.<BR>
-#
-#  This program and the accompanying materials
-#  are licensed and made available under the terms and conditions of the BSD License
-#  which 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.
-#
-#**/
-
-[Defines]
-  INF_VERSION                    = 0x00010005
-  BASE_NAME                      = FdtPL011SerialPortLib
-  FILE_GUID                      = 0983616A-49BC-4732-B531-4AF98D2056F0
-  MODULE_TYPE                    = BASE
-  VERSION_STRING                 = 1.0
-  LIBRARY_CLASS                  = SerialPortLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER UEFI_DRIVER
-  CONSTRUCTOR                    = FdtPL011SerialPortLibInitialize
-
-[Sources.common]
-  FdtPL011SerialPortLib.c
-
-[LibraryClasses]
-  PL011UartLib
-  PcdLib
-  UefiBootServicesTableLib
-
-[Packages]
-  EmbeddedPkg/EmbeddedPkg.dec
-  MdePkg/MdePkg.dec
-  MdeModulePkg/MdeModulePkg.dec
-  ArmPlatformPkg/ArmPlatformPkg.dec
-  ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationPkg.dec
-  ArmPkg/ArmPkg.dec
-
-[FixedPcd]
-  gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate
-  gEfiMdePkgTokenSpaceGuid.PcdUartDefaultDataBits
-  gEfiMdePkgTokenSpaceGuid.PcdUartDefaultParity
-  gEfiMdePkgTokenSpaceGuid.PcdUartDefaultStopBits
-
-[Pcd]
-  gArmVirtualizationTokenSpaceGuid.PcdPL011BaseAddress
diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/Library/FdtPL011SerialPortLib/DxePL011SerialPortLib.c b/ArmPlatformPkg/ArmVirtualizationPkg/Library/FdtPL011SerialPortLib/DxePL011SerialPortLib.c
new file mode 100644
index 0000000..e695452
--- /dev/null
+++ b/ArmPlatformPkg/ArmVirtualizationPkg/Library/FdtPL011SerialPortLib/DxePL011SerialPortLib.c
@@ -0,0 +1,141 @@
+/** @file
+  Serial I/O Port library functions with base address discovered from FDT
+
+  Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>
+  Copyright (c) 2012 - 2013, ARM Ltd. All rights reserved.<BR>
+  Copyright (c) 2014, Linaro Ltd. All rights reserved.<BR>
+  Copyright (c) 2014, Red Hat, Inc.<BR>
+
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD License
+  which 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.
+
+**/
+
+#include <Base.h>
+
+#include <Library/PcdLib.h>
+#include <Library/SerialPortLib.h>
+#include <Pi/PiBootMode.h>
+#include <Uefi/UefiBaseType.h>
+#include <Uefi/UefiMultiPhase.h>
+#include <Pi/PiHob.h>
+#include <Library/HobLib.h>
+#include <Guid/EarlyPL011BaseAddress.h>
+
+#include <Drivers/PL011Uart.h>
+
+UINTN mSerialBaseAddress;
+
+/**
+
+  Program hardware of Serial port
+
+  @return    RETURN_NOT_FOUND if no PL011 base address could be found
+             Otherwise, result of PL011UartInitializePort () is returned
+
+**/
+RETURN_STATUS
+EFIAPI
+SerialPortInitialize (
+  VOID
+  )
+{
+  VOID                *Hob;
+  CONST UINT64        *UartBase;
+  UINT64              BaudRate;
+  UINT32              ReceiveFifoDepth;
+  EFI_PARITY_TYPE     Parity;
+  UINT8               DataBits;
+  EFI_STOP_BITS_TYPE  StopBits;
+
+  Hob = GetFirstGuidHob (&gEarlyPL011BaseAddressGuid);
+  if (Hob == NULL || GET_GUID_HOB_DATA_SIZE (Hob) != sizeof *UartBase) {
+    return RETURN_NOT_FOUND;
+  }
+  UartBase = GET_GUID_HOB_DATA (Hob);
+
+  mSerialBaseAddress = (UINTN)*UartBase;
+  if (mSerialBaseAddress == 0) {
+    return RETURN_NOT_FOUND;
+  }
+
+  BaudRate = (UINTN)PcdGet64 (PcdUartDefaultBaudRate);
+  ReceiveFifoDepth = 0; // Use the default value for Fifo depth
+  Parity = (EFI_PARITY_TYPE)PcdGet8 (PcdUartDefaultParity);
+  DataBits = PcdGet8 (PcdUartDefaultDataBits);
+  StopBits = (EFI_STOP_BITS_TYPE) PcdGet8 (PcdUartDefaultStopBits);
+
+  return PL011UartInitializePort (
+           mSerialBaseAddress, &BaudRate, &ReceiveFifoDepth,
+           &Parity, &DataBits, &StopBits);
+}
+
+/**
+  Write data to serial device.
+
+  @param  Buffer           Point of data buffer which need to be written.
+  @param  NumberOfBytes    Number of output bytes which are cached in Buffer.
+
+  @retval 0                Write data failed.
+  @retval !0               Actual number of bytes written to serial device.
+
+**/
+UINTN
+EFIAPI
+SerialPortWrite (
+  IN UINT8     *Buffer,
+  IN UINTN     NumberOfBytes
+  )
+{
+  if (mSerialBaseAddress != 0) {
+    return PL011UartWrite (mSerialBaseAddress, Buffer, NumberOfBytes);
+  }
+  return 0;
+}
+
+/**
+  Read data from serial device and save the data in buffer.
+
+  @param  Buffer           Point of data buffer which need to be written.
+  @param  NumberOfBytes    Number of output bytes which are cached in Buffer.
+
+  @retval 0                Read data failed.
+  @retval !0               Actual number of bytes read from serial device.
+
+**/
+UINTN
+EFIAPI
+SerialPortRead (
+  OUT UINT8     *Buffer,
+  IN  UINTN     NumberOfBytes
+)
+{
+  if (mSerialBaseAddress != 0) {
+    return PL011UartRead (mSerialBaseAddress, Buffer, NumberOfBytes);
+  }
+  return 0;
+}
+
+/**
+  Check to see if any data is available to be read from the debug device.
+
+  @retval TRUE       At least one byte of data is available to be read
+  @retval FALSE      No data is available to be read
+
+**/
+BOOLEAN
+EFIAPI
+SerialPortPoll (
+  VOID
+  )
+{
+  if (mSerialBaseAddress != 0) {
+    return PL011UartPoll (mSerialBaseAddress);
+  }
+  return FALSE;
+}
diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/Library/FdtPL011SerialPortLib/FdtPL011SerialPortLib.c b/ArmPlatformPkg/ArmVirtualizationPkg/Library/FdtPL011SerialPortLib/FdtPL011SerialPortLib.c
deleted file mode 100644
index 39c1ab0..0000000
--- a/ArmPlatformPkg/ArmVirtualizationPkg/Library/FdtPL011SerialPortLib/FdtPL011SerialPortLib.c
+++ /dev/null
@@ -1,145 +0,0 @@
-/** @file
-  Serial I/O Port library functions with base address discovered from FDT
-
-  Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>
-  Copyright (c) 2012 - 2013, ARM Ltd. All rights reserved.<BR>
-  Copyright (c) 2014, Linaro Ltd. All rights reserved.<BR>
-
-  This program and the accompanying materials
-  are licensed and made available under the terms and conditions of the BSD License
-  which 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.
-
-**/
-
-#include <Base.h>
-
-#include <Library/IoLib.h>
-#include <Library/PcdLib.h>
-#include <Library/DebugLib.h>
-#include <Library/SerialPortLib.h>
-#include <Library/SerialPortExtLib.h>
-
-//
-// This is an artifical dependency on UefiBootServicesTableLib.h, which is
-// needed to make sure PcdGet64 () is callable once we get to our constructor
-//
-#include <Uefi/UefiSpec.h>
-#include <Library/UefiBootServicesTableLib.h>
-
-#include <Drivers/PL011Uart.h>
-
-UINTN mSerialBaseAddress;
-
-/**
-
-  Program hardware of Serial port
-
-  @return    RETURN_NOT_FOUND if no PL011 base address could be found
-             Otherwise, result of PL011UartInitializePort () is returned
-
-**/
-RETURN_STATUS
-EFIAPI
-SerialPortInitialize (
-  VOID
-  )
-{
-  return RETURN_SUCCESS;
-}
-
-RETURN_STATUS
-EFIAPI
-FdtPL011SerialPortLibInitialize (
-  VOID
-  )
-{
-  UINT64              BaudRate;
-  UINT32              ReceiveFifoDepth;
-  EFI_PARITY_TYPE     Parity;
-  UINT8               DataBits;
-  EFI_STOP_BITS_TYPE  StopBits;
-
-  mSerialBaseAddress = (UINTN)PcdGet64 (PcdPL011BaseAddress);
-  if (mSerialBaseAddress == 0) {
-    return RETURN_NOT_FOUND;
-  }
-
-  BaudRate = (UINTN)PcdGet64 (PcdUartDefaultBaudRate);
-  ReceiveFifoDepth = 0; // Use the default value for Fifo depth
-  Parity = (EFI_PARITY_TYPE)PcdGet8 (PcdUartDefaultParity);
-  DataBits = PcdGet8 (PcdUartDefaultDataBits);
-  StopBits = (EFI_STOP_BITS_TYPE) PcdGet8 (PcdUartDefaultStopBits);
-
-  return PL011UartInitializePort (
-           mSerialBaseAddress, &BaudRate, &ReceiveFifoDepth,
-           &Parity, &DataBits, &StopBits);
-}
-
-/**
-  Write data to serial device.
-
-  @param  Buffer           Point of data buffer which need to be written.
-  @param  NumberOfBytes    Number of output bytes which are cached in Buffer.
-
-  @retval 0                Write data failed.
-  @retval !0               Actual number of bytes written to serial device.
-
-**/
-UINTN
-EFIAPI
-SerialPortWrite (
-  IN UINT8     *Buffer,
-  IN UINTN     NumberOfBytes
-  )
-{
-  if (mSerialBaseAddress != 0) {
-    return PL011UartWrite (mSerialBaseAddress, Buffer, NumberOfBytes);
-  }
-  return 0;
-}
-
-/**
-  Read data from serial device and save the data in buffer.
-
-  @param  Buffer           Point of data buffer which need to be written.
-  @param  NumberOfBytes    Number of output bytes which are cached in Buffer.
-
-  @retval 0                Read data failed.
-  @retval !0               Actual number of bytes read from serial device.
-
-**/
-UINTN
-EFIAPI
-SerialPortRead (
-  OUT UINT8     *Buffer,
-  IN  UINTN     NumberOfBytes
-)
-{
-  if (mSerialBaseAddress != 0) {
-    return PL011UartRead (mSerialBaseAddress, Buffer, NumberOfBytes);
-  }
-  return 0;
-}
-
-/**
-  Check to see if any data is available to be read from the debug device.
-
-  @retval TRUE       At least one byte of data is available to be read
-  @retval FALSE      No data is available to be read
-
-**/
-BOOLEAN
-EFIAPI
-SerialPortPoll (
-  VOID
-  )
-{
-  if (mSerialBaseAddress != 0) {
-    return PL011UartPoll (mSerialBaseAddress);
-  }
-  return FALSE;
-}
-- 
1.8.3.1

From 147c570e19ee2c7052740b62275e93ba0c6e7ddf Mon Sep 17 00:00:00 2001
From: Laszlo Ersek <ler...@redhat.com>
Date: Wed, 3 Sep 2014 23:51:26 +0200
Subject: [PATCH 09/12] ArmVirtualizationPkg: DSC: put DxePL011SerialPortLib to
 use

All module types different from SEC, PEI_CORE and PEI should use the
HOB-based DxePL011SerialPortLib, including DXE_CORE.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <ler...@redhat.com>
---
 ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualization.dsc.inc | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualization.dsc.inc b/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualization.dsc.inc
index 682113d..43ec205 100644
--- a/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualization.dsc.inc
+++ b/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualization.dsc.inc
@@ -81,7 +81,7 @@
   RealTimeClockLib|ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.inf
   # ARM PL011 UART Driver
   PL011UartLib|ArmPlatformPkg/Drivers/PL011Uart/PL011Uart.inf
-  SerialPortLib|ArmPlatformPkg/ArmVirtualizationPkg/Library/FdtPL011SerialPortLib/FdtPL011SerialPortLib.inf
+  SerialPortLib|ArmPlatformPkg/ArmVirtualizationPkg/Library/FdtPL011SerialPortLib/DxePL011SerialPortLib.inf
   SerialPortExtLib|ArmPlatformPkg/ArmVirtualizationPkg/Library/FdtPL011SerialPortLib/NullSerialPortExtLib.inf
   UefiBootServicesTableLib|ArmPlatformPkg/ArmVirtualizationPkg/Library/ArmVirtualizationUefiBootServicesTableLib/ArmVirtualizationUefiBootServicesTableLib.inf
 
@@ -165,7 +165,6 @@
   UefiDecompressLib|MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.inf
   DxeServicesLib|MdePkg/Library/DxeServicesLib/DxeServicesLib.inf
   PerformanceLib|MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.inf
-  SerialPortLib|ArmPlatformPkg/ArmVirtualizationPkg/Library/FdtPL011SerialPortLib/EarlyFdtPL011SerialPortLib.inf
 
 [LibraryClasses.common.DXE_DRIVER]
   ReportStatusCodeLib|IntelFrameworkModulePkg/Library/DxeReportStatusCodeLibFramework/DxeReportStatusCodeLib.inf
-- 
1.8.3.1

From aa74a668ed2f7dd1df3d7af0b2712b45f53c2720 Mon Sep 17 00:00:00 2001
From: Laszlo Ersek <ler...@redhat.com>
Date: Thu, 4 Sep 2014 02:56:32 +0200
Subject: [PATCH 10/12] drop PcdPL011BaseAddress

There are no more users.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <ler...@redhat.com>
---
 ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationPkg.dec  | 1 -
 ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc | 5 -----
 2 files changed, 6 deletions(-)

diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationPkg.dec b/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationPkg.dec
index 34833aa..c07fce9 100644
--- a/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationPkg.dec
+++ b/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationPkg.dec
@@ -45,4 +45,3 @@
 
 [PcdsDynamic,PcdsFixedAtBuild]
   gArmVirtualizationTokenSpaceGuid.PcdDeviceTreeBaseAddress|0x0|UINT64|0x00000002
-  gArmVirtualizationTokenSpaceGuid.PcdPL011BaseAddress|0x0|UINT64|0x00000003
diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc b/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc
index 65964f6..4272f90 100644
--- a/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc
+++ b/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc
@@ -143,11 +143,6 @@
   # System Memory Size -- 1 MB initially, actual size will be fetched from DT
   gArmTokenSpaceGuid.PcdSystemMemorySize|0x00100000
 
-  #
-  # Register base address of the dynamically discovered PL011 UART
-  #
-  gArmVirtualizationTokenSpaceGuid.PcdPL011BaseAddress|0x0
-
   # location of the device tree blob passed by QEMU
   gArmVirtualizationTokenSpaceGuid.PcdDeviceTreeBaseAddress|0x0
 
-- 
1.8.3.1

From ecfad5e77cafe3d74eb38462abf8c273bd6c4449 Mon Sep 17 00:00:00 2001
From: Laszlo Ersek <ler...@redhat.com>
Date: Thu, 4 Sep 2014 03:11:38 +0200
Subject: [PATCH 11/12] Revert "ArmVirtualizationPkg: add private
 UefiBootServicesTableLib implementation"

This reverts the following commit:

  In order to support a dynamically discovered base address for the serial
  port, we need to break the dependency cycle between DebugLib depending
  on SerialPortLib depending on PcdLib depending on
  UefiBootServicesTableLib, which completes the cycle by depending on
  DebugLib.

  Instead, supply a private implementation whose ASSERTs have been
  defused, so that we can drop the dependency on DebugLib.

Using a HOB rather than a dynamic PCD in DxePL011SerialPortLib, we don't
need this any longer.

Signed-off-by: Laszlo Ersek <ler...@redhat.com>
---
 .../ArmVirtualizationUefiBootServicesTableLib.inf  | 34 -----------
 .../ArmVirtualizationUefiBootServicesTableLib.c    | 65 ----------------------
 2 files changed, 99 deletions(-)
 delete mode 100644 ArmPlatformPkg/ArmVirtualizationPkg/Library/ArmVirtualizationUefiBootServicesTableLib/ArmVirtualizationUefiBootServicesTableLib.inf
 delete mode 100644 ArmPlatformPkg/ArmVirtualizationPkg/Library/ArmVirtualizationUefiBootServicesTableLib/ArmVirtualizationUefiBootServicesTableLib.c

diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/Library/ArmVirtualizationUefiBootServicesTableLib/ArmVirtualizationUefiBootServicesTableLib.inf b/ArmPlatformPkg/ArmVirtualizationPkg/Library/ArmVirtualizationUefiBootServicesTableLib/ArmVirtualizationUefiBootServicesTableLib.inf
deleted file mode 100644
index 53923ba..0000000
--- a/ArmPlatformPkg/ArmVirtualizationPkg/Library/ArmVirtualizationUefiBootServicesTableLib/ArmVirtualizationUefiBootServicesTableLib.inf
+++ /dev/null
@@ -1,34 +0,0 @@
-## @file
-# UEFI Boot Services Table Library implementation for ArmVirtualizationPkg
-#
-# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
-#
-#  This program and the accompanying materials
-#  are licensed and made available under the terms and conditions of the BSD License
-#  which 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.
-#
-#
-##
-
-[Defines]
-  INF_VERSION                    = 0x00010005
-  BASE_NAME                      = ArmVirtualizationUefiBootServicesTableLib
-  FILE_GUID                      = C32831C9-E611-43ED-B812-FC3EBC8DCE99
-  MODULE_TYPE                    = UEFI_DRIVER
-  VERSION_STRING                 = 1.0
-  LIBRARY_CLASS                  = UefiBootServicesTableLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER SMM_CORE
-
-  CONSTRUCTOR                    = UefiBootServicesTableLibConstructor
-
-#
-#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC
-#
-
-[Sources]
-  ArmVirtualizationUefiBootServicesTableLib.c
-
-[Packages]
-  MdePkg/MdePkg.dec
diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/Library/ArmVirtualizationUefiBootServicesTableLib/ArmVirtualizationUefiBootServicesTableLib.c b/ArmPlatformPkg/ArmVirtualizationPkg/Library/ArmVirtualizationUefiBootServicesTableLib/ArmVirtualizationUefiBootServicesTableLib.c
deleted file mode 100644
index bbe171e..0000000
--- a/ArmPlatformPkg/ArmVirtualizationPkg/Library/ArmVirtualizationUefiBootServicesTableLib/ArmVirtualizationUefiBootServicesTableLib.c
+++ /dev/null
@@ -1,65 +0,0 @@
-/** @file
-  This library retrieves the EFI_BOOT_SERVICES pointer from EFI system table in
-  library's constructor. This version has no dependency on DebugLib
-
-  Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
-  This program and the accompanying materials
-  are licensed and made available under the terms and conditions of the BSD License
-  which 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.
-
-**/
-
-
-#include <Uefi.h>
-
-#include <Library/UefiBootServicesTableLib.h>
-
-EFI_HANDLE         gImageHandle = NULL;
-EFI_SYSTEM_TABLE   *gST         = NULL;
-EFI_BOOT_SERVICES  *gBS         = NULL;
-
-#define ASSERT(x)
-
-/**
-  The constructor function caches the pointer of Boot Services Table.
-
-  The constructor function caches the pointer of Boot Services Table through System Table.
-  It will always return EFI_SUCCESS.
-
-  @param  ImageHandle   The firmware allocated handle for the EFI image.
-  @param  SystemTable   A pointer to the EFI System Table.
-
-  @retval EFI_SUCCESS   The constructor always returns EFI_SUCCESS.
-
-**/
-EFI_STATUS
-EFIAPI
-UefiBootServicesTableLibConstructor (
-  IN EFI_HANDLE        ImageHandle,
-  IN EFI_SYSTEM_TABLE  *SystemTable
-  )
-{
-  //
-  // Cache the Image Handle
-  //
-  gImageHandle = ImageHandle;
-  ASSERT (gImageHandle != NULL);
-
-  //
-  // Cache pointer to the EFI System Table
-  //
-  gST = SystemTable;
-  ASSERT (gST != NULL);
-
-  //
-  // Cache pointer to the EFI Boot Services Table
-  //
-  gBS = SystemTable->BootServices;
-  ASSERT (gBS != NULL);
-
-  return EFI_SUCCESS;
-}
-- 
1.8.3.1

From 5c6e09d71a8a88c0cca19cda551758eadc435a1d Mon Sep 17 00:00:00 2001
From: Laszlo Ersek <ler...@redhat.com>
Date: Thu, 4 Sep 2014 03:19:09 +0200
Subject: [PATCH 12/12] drop references to
 ArmVirtualizationUefiBootServicesTableLib

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <ler...@redhat.com>
---
 ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualization.dsc.inc | 1 -
 1 file changed, 1 deletion(-)

diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualization.dsc.inc b/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualization.dsc.inc
index 43ec205..1817891 100644
--- a/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualization.dsc.inc
+++ b/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualization.dsc.inc
@@ -83,7 +83,6 @@
   PL011UartLib|ArmPlatformPkg/Drivers/PL011Uart/PL011Uart.inf
   SerialPortLib|ArmPlatformPkg/ArmVirtualizationPkg/Library/FdtPL011SerialPortLib/DxePL011SerialPortLib.inf
   SerialPortExtLib|ArmPlatformPkg/ArmVirtualizationPkg/Library/FdtPL011SerialPortLib/NullSerialPortExtLib.inf
-  UefiBootServicesTableLib|ArmPlatformPkg/ArmVirtualizationPkg/Library/ArmVirtualizationUefiBootServicesTableLib/ArmVirtualizationUefiBootServicesTableLib.inf
 
   # EBL Related Libraries  
   EblCmdLib|ArmPlatformPkg/Library/EblCmdLib/EblCmdLib.inf
-- 
1.8.3.1

------------------------------------------------------------------------------
Slashdot TV.  
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to