ArmVirtualizationPkg: add Include/ArmPlatform.h

This include file contains platform specific defines, and is shared by
various modules.

Contributed-under: TianoCore Contribution Agreement 1.0
Acked-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-By: Olivier Martin <olivier.martin@arm.com>



git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16132 6f19259b-4bc3-4df7-8a09-765794883524
ArmVirtualizationPkg: add driver for QEMU's NOR flash

This adds an implementation of NorFlashPlatformLib that exposes the
two 64 MB NOR flash banks that are provided by QEMU's mach-virt
emulation both in 32-bit and 64-bit mode.

Contributed-under: TianoCore Contribution Agreement 1.0
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Olivier Martin <olivier.martin@arm.com>



git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16133 6f19259b-4bc3-4df7-8a09-765794883524
ArmPlatformPkg/ArmVirtualizationPkg: Add private HobLib implementation for DXE phase

To allow a dynamically discovered UART base address, we parse the device
tree early and store the base address in a HOB. To prevent circular
constructor dependencies from interfering with bringing up the serial port
using this dynamic base address, use our own private HobLib with no
dependencies on DebugLib either directly or indirectly through UefiLib.

Contributed-under: TianoCore Contribution Agreement 1.0
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Olivier Martin <olivier.martin@arm.com>



git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16134 6f19259b-4bc3-4df7-8a09-765794883524
ArmPlatformPkg/ArmVirtualizationPkg: introduce PCDs for device tree base address

Introduce gArmVirtualizationTokenSpaceGuid.PcdDeviceTreeBaseAddress and
PcdDeviceTreeInitialBaseAddress, which will be used by virtual machine ports
that discover the system configuration from a flattened device tree DTB image.

The latter is FixedPcd only, and should contain the initial offset of the DTB,
the former may be declared as dynamic, and updated at runtime if the DTB is
relocated before the DXE phase.

Contributed-under: TianoCore Contribution Agreement 1.0
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Olivier Martin <olivier.martin@arm.com>



git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16135 6f19259b-4bc3-4df7-8a09-765794883524
ArmPlatformPkg/ArmVirtualizationPkg: Add PlatformPeiLib library

This is a fork of the ARM PlatformPeiLib for virtual machines. The main
purpose of having this specific implementation is that it allows us to
preserve the device tree blob if it was passed to us in system DRAM.

Contributed-under: TianoCore Contribution Agreement 1.0
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Olivier Martin <olivier.martin@arm.com>



git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16136 6f19259b-4bc3-4df7-8a09-765794883524
ArmPlatformPkg/ArmVirtualizationPkg: Add VirtFdtDxe driver

This driver enumerates the device nodes in the device tree located at the
base address passed in gArmTokenSpaceGuid.PcdDeviceTreeBaseAddress, and
installs drivers for devices it cares about (GIC interrupt controller, RTC,
architected timer interrupt)

Contributed-under: TianoCore Contribution Agreement 1.0
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Olivier Martin <olivier.martin@arm.com>



git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16137 6f19259b-4bc3-4df7-8a09-765794883524
ArmPlatformPkg/ArmVirtualizationPkg: add ArmVirtualizationPlatformLib library

This is an implementation of ArmPlatformLib that discovers the size of system
DRAM from a device tree blob located at the address passed in
gArmTokenSpaceGuid.PcdDeviceTreeBaseAddress, which should equal the value in
gArmTokenSpaceGuid.PcdSystemMemoryBase.

As the device tree blob is passed in system DRAM, this library can only be used
if sufficient DRAM is available (>= 128 MB) and if not using shadowed NOR. The
reason for this is that it makes it easier to guarantee that such a device tree
blob at base of DRAM will not be clobbered before we get a chance to preserve it.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael Casadevall <michael.casadevall@linaro.org>
Acked-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-By: Olivier Martin <olivier.martin@arm.com>



git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16138 6f19259b-4bc3-4df7-8a09-765794883524
ArmPlatformPkg/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 <lersek@redhat.com>
Reviewed-By: Olivier Martin <olivier.martin@arm.com>



git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16139 6f19259b-4bc3-4df7-8a09-765794883524
ArmVirtualizationPkg: add device tree based PL011 SerialPortLib

This adds 2 implementations of SerialPortLib for device tree based platforms
using a PL011 UART:
- an 'early' one which is completely stateless and uses only fixed PCDs
- a normal one which takes its base address from a HOB containing the base
  address discovered in the PEI phase

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-with-remarks-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-By: Olivier Martin <olivier.martin@arm.com>



git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16140 6f19259b-4bc3-4df7-8a09-765794883524
ArmPlatformPkg/ArmVirtualizationPkg: Add ArmVirtualizationQemu platform

This adds support for executing UEFI in a QEMU/mach-virt emulated environment.
The following assumptions are made about the target:
- DRAM base at 0x4000_0000, containing the device tree blob
- DRAM size at least 1 MB
- device tree uses 64-bit physical base addresses and sizes
- ARM architected timer
- Cortex-A15 CPU (if built for 32-bit)

The following information is retrieved from the device tree:
- PL011 UART base address
- GIC base addresses
- virtual timer interrupt
- PL031 RTC base address
- DRAM size, must be at least 128 MB
- virtio MMIO transports
- PSCI 0.2 availability (for reset and poweroff)

The device tree image is relocated and installed as a configuration table
so an EFI stub enabled kernel can be booted directly without the need for
a bootloader.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael Casadevall <michael.casadevall@linaro.org>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Tested-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-By: Olivier Martin <olivier.martin@arm.com>



git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16141 6f19259b-4bc3-4df7-8a09-765794883524
StdLib: Produce DevMedia as a library class alternative to DevShell.
AppPkg: Replace existing DevShell dependencies with DevMedia.
  
These patches will NOT cause existing code which uses DevShell to break.
During an interim period, either DevShell or DevMedia may be used.
In the future, DevShell will be removed from the code base.

During the interim, DevShell and DevMedia refer to the same library.

StdLib/LibC/Uefi/Devices/daShell.inf
  Make this library also satisfy the DevMedia library class.
StdLib/StdLib.inc
  Add a library class definition for DevMedia

AppPkg/Applications/OrderedCollectionTest/OrderedCollectionTest.inf
AppPkg/Applications/Python/PythonCore.inf
AppPkg/Applications/Sockets/GetAddrInfo/GetAddrInfo.inf
AppPkg/Applications/Sockets/GetHostByAddr/GetHostByAddr.inf
AppPkg/Applications/Sockets/GetHostByDns/GetHostByDns.inf
AppPkg/Applications/Sockets/GetHostByName/GetHostByName.inf
AppPkg/Applications/Sockets/GetNameInfo/GetNameInfo.inf
AppPkg/Applications/Sockets/GetNetByAddr/GetNetByAddr.inf
AppPkg/Applications/Sockets/GetNetByName/GetNetByName.inf
AppPkg/Applications/Sockets/GetServByName/GetServByName.inf
AppPkg/Applications/Sockets/GetServByPort/GetServByPort.inf
AppPkg/Applications/Sockets/RecvDgram/RecvDgram.inf
AppPkg/Applications/Sockets/SetHostName/SetHostName.inf
AppPkg/Applications/Sockets/SetSockOpt/SetSockOpt.inf
AppPkg/Applications/Sockets/TftpServer/TftpServer.inf
AppPkg/Applications/Sockets/WebServer/WebServer.inf
  Change LibraryClass dependency from DevShell to DevMedia
  
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by:  Daryl McDaniel  <daryl.mcdaniel@intel.com>
Reviewed-by:  Jaben Carsey <Jaben.carsey@intel.com>


git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16142 6f19259b-4bc3-4df7-8a09-765794883524
ArmPlatformPkg: Introduced ArmPlatformSysConfigLib NULL library

Some platforms do not have SysConfig controller used by the ARM
Versatile Express.
Some peripheral drivers currently rely on SysConfigLib (eg: PL031
RTC driver, LCD driver).

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Olivier Martin <olivier.martin@arm.com>



git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16143 6f19259b-4bc3-4df7-8a09-765794883524
ArmPkg/TimerDxe: add workaround for KVM timer interrupt handling

KVM on ARM currently masks the timer interrupt on the timer side when
delivering an interrupt to the guest. This itself is a workaround for an
issue where the interrupt is reraised and trapped by the host as soon as
the guest is entered, resulting in the guest being starved.

Work around this by calling ArmGenericTimerEnable () after servicing each
interrupt. The virtual version of ArmGenericTimerCounterLib will then
make sure to unmask the interrupt again.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-By: Olivier Martin <olivier.martin@arm.com>



git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16144 6f19259b-4bc3-4df7-8a09-765794883524
EmbeddedPkg: Introduced NULL library for SerialPortExtLib

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Olivier Martin <olivier.martin@arm.com>



git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16145 6f19259b-4bc3-4df7-8a09-765794883524
Merge branch 'master' of https://github.com/tianocore/edk2