]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmVirtPkg: Support for kvmtool virtual platform
authorSami Mujawar <sami.mujawar@arm.com>
Fri, 2 Oct 2020 21:14:05 +0000 (22:14 +0100)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Fri, 16 Oct 2020 17:21:04 +0000 (17:21 +0000)
Kvmtool is a virtual machine manager that enables hosting
KVM guests. Kvmtool emulates certain devices like serial
port, RTC, etc. essentially providing a virtual platform.

This patch adds support for kvmtool virtual platform.

Following is a brief description of the firmware
implementation choices:

- Serial Port: 16550 UART
  On some platforms the 16550 UART is interfaced using
  PCI. Therefore, the 16550 Serial port library is
  dependent on the PCI library. The 16550 UART driver
  checks the Device ID represented using the PCD
  gEfiMdeModulePkgTokenSpaceGuid.PcdSerialPciDeviceInfo
  to determine if the UART is behind PCI.
  If the Device ID is 0xFF then the serial 16550 UART
  is not behind PCI.

  On Kvmtool the Serial 16550 UART is not behind PCI,
  and therefore a combination of BasePciLibPciExpress
  and BasePciExpressLib is used to satisfy the PCI
  library dependency.

  The PcdSerialPciDeviceInfo is also set to 0xFF to
  indicate that the Serial 16550 UART is not behind
  PCI. The PCD PcdSerialUseMmio is also set to TRUE
  to indicate MMIO accesses are required for the
  UART registers.

  Additionally two instances of PlatformHookLibs are
  provided EarlyFdt16550SerialPortHookLib and
  Fdt16550SerialPortHookLib to patch the
  PcdSerialRegisterBase so that BaseSerialPortLib16550
  and retrieve the base address of the 16550 UART.

- Dependency order for Flash
  FaultTolerantWriteDxe makes use of PCDs (e.g.
  PcdFlashNvStorageFtwSpareBase64 etc.), which in
  case of kvmtool will be evaluated based on the CFI
  flash base address read from the DT. These variables
  are populated in the NorFlashPlatformLib loaded by
  ArmVeNorFlashDxe.

  This results in a dependency issue with
  FaultTolerantWriteDxe. To resolve this make the
  NorFlashPlatformLib as a library dependency for
  FaultTolerantWriteDxe.

- RTC Controller
  A separate patch updates the MC146818 RTC controller
  driver to support MMIO accesses.
  A KvmtoolRtcFdtClientLib has been introduced to
  extract the base addresses of the RTC controller
  from the platform device tree and map the RTC
  register space as Runtime Memory.

Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
ArmVirtPkg/ArmVirtKvmTool.dsc [new file with mode: 0644]
ArmVirtPkg/ArmVirtKvmTool.fdf [new file with mode: 0644]

diff --git a/ArmVirtPkg/ArmVirtKvmTool.dsc b/ArmVirtPkg/ArmVirtKvmTool.dsc
new file mode 100644 (file)
index 0000000..bf008be
--- /dev/null
@@ -0,0 +1,321 @@
+#  @file\r
+#  Workspace file for KVMTool virtual platform.\r
+#\r
+#  Copyright (c) 2018 - 2020, ARM Limited. All rights reserved.\r
+#\r
+#  SPDX-License-Identifier: BSD-2-Clause-Patent\r
+#\r
+#\r
+\r
+################################################################################\r
+#\r
+# Defines Section - statements that will be processed to create a Makefile.\r
+#\r
+################################################################################\r
+[Defines]\r
+  PLATFORM_NAME                  = ArmVirtKvmTool\r
+  PLATFORM_GUID                  = 4CB2C61E-FA32-4130-8E37-54ABC71A1A43\r
+  PLATFORM_VERSION               = 0.1\r
+  DSC_SPECIFICATION              = 0x0001001B\r
+!ifdef $(EDK2_OUT_DIR)\r
+  OUTPUT_DIRECTORY               = $(EDK2_OUT_DIR)\r
+!else\r
+  OUTPUT_DIRECTORY               = Build/ArmVirtKvmTool-$(ARCH)\r
+!endif\r
+  SUPPORTED_ARCHITECTURES        = AARCH64|ARM\r
+  BUILD_TARGETS                  = DEBUG|RELEASE\r
+  SKUID_IDENTIFIER               = DEFAULT\r
+  FLASH_DEFINITION               = ArmVirtPkg/ArmVirtKvmTool.fdf\r
+\r
+!include ArmVirtPkg/ArmVirt.dsc.inc\r
+\r
+[LibraryClasses.common]\r
+  ArmLib|ArmPkg/Library/ArmLib/ArmBaseLib.inf\r
+  ArmMmuLib|ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf\r
+\r
+  # Virtio Support\r
+  VirtioLib|OvmfPkg/Library/VirtioLib/VirtioLib.inf\r
+  VirtioMmioDeviceLib|OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceLib.inf\r
+\r
+  ArmPlatformLib|ArmPlatformPkg/Library/ArmPlatformLibNull/ArmPlatformLibNull.inf\r
+  ArmVirtMemInfoLib|ArmVirtPkg/Library/KvmtoolVirtMemInfoLib/KvmtoolVirtMemInfoLib.inf\r
+\r
+  TimerLib|ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.inf\r
+  NorFlashPlatformLib|ArmVirtPkg/Library/NorFlashKvmtoolLib/NorFlashKvmtoolLib.inf\r
+\r
+  CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf\r
+\r
+  # BDS Libraries\r
+  UefiBootManagerLib|MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf\r
+  PlatformBootManagerLib|ArmPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf\r
+  BootLogoLib|MdeModulePkg/Library/BootLogoLib/BootLogoLib.inf\r
+\r
+  CustomizedDisplayLib|MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.inf\r
+  FrameBufferBltLib|MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.inf\r
+\r
+  FileExplorerLib|MdeModulePkg/Library/FileExplorerLib/FileExplorerLib.inf\r
+\r
+  PciPcdProducerLib|ArmVirtPkg/Library/FdtPciPcdProducerLib/FdtPciPcdProducerLib.inf\r
+  PciSegmentLib|MdePkg/Library/BasePciSegmentLibPci/BasePciSegmentLibPci.inf\r
+  PciHostBridgeLib|ArmVirtPkg/Library/FdtPciHostBridgeLib/FdtPciHostBridgeLib.inf\r
+\r
+  TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf\r
+  AuthVariableLib|MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf\r
+\r
+  PlatformPeiLib|ArmVirtPkg/Library/KvmtoolPlatformPeiLib/KvmtoolPlatformPeiLib.inf\r
+\r
+  PciExpressLib|MdePkg/Library/BasePciExpressLib/BasePciExpressLib.inf\r
+  PlatformHookLib|ArmVirtPkg/Library/Fdt16550SerialPortHookLib/Fdt16550SerialPortHookLib.inf\r
+  SerialPortLib|MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.inf\r
+\r
+[LibraryClasses.common.SEC, LibraryClasses.common.PEI_CORE, LibraryClasses.common.PEIM]\r
+  PciExpressLib|MdePkg/Library/BasePciExpressLib/BasePciExpressLib.inf\r
+  PlatformHookLib|ArmVirtPkg/Library/Fdt16550SerialPortHookLib/EarlyFdt16550SerialPortHookLib.inf\r
+  SerialPortLib|MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.inf\r
+\r
+[LibraryClasses.common.UEFI_DRIVER]\r
+  UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf\r
+\r
+[BuildOptions]\r
+  *_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES\r
+  #\r
+  # We need to avoid jump tables in SEC and BASE modules, so that the PE/COFF\r
+  # self-relocation code itself is guaranteed to be position independent.\r
+  #\r
+  GCC:*_*_*_CC_XIPFLAGS = -fno-jump-tables\r
+\r
+################################################################################\r
+#\r
+# Pcd Section - list of all EDK II PCD Entries defined by this Platform\r
+#\r
+################################################################################\r
+\r
+[PcdsFeatureFlag.common]\r
+  ## If TRUE, Graphics Output Protocol will be installed on virtual handle created by ConsplitterDxe.\r
+  #  It could be set FALSE to save size.\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE\r
+\r
+  # Use MMIO for accessing RTC controller registers.\r
+  gPcAtChipsetPkgTokenSpaceGuid.PcdRtcUseMmio|TRUE\r
+\r
+[PcdsFixedAtBuild.common]\r
+  gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x8000000F\r
+\r
+  gArmPlatformTokenSpaceGuid.PcdCoreCount|1\r
+\r
+!if $(ARCH) == AARCH64\r
+  gArmTokenSpaceGuid.PcdVFPEnabled|1\r
+!endif\r
+\r
+  gArmPlatformTokenSpaceGuid.PcdCPUCorePrimaryStackSize|0x4000\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize|0x2000\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdMaxAuthVariableSize|0x2800\r
+\r
+  # Size of the region used by UEFI in permanent memory (Reserved 64MB)\r
+  gArmPlatformTokenSpaceGuid.PcdSystemMemoryUefiRegionSize|0x04000000\r
+\r
+  #\r
+  # TTY Terminal Type\r
+  # 0-PCANSI, 1-VT100, 2-VT00+, 3-UTF8, 4-TTYTERM\r
+  gEfiMdePkgTokenSpaceGuid.PcdDefaultTerminalType|4\r
+\r
+  #\r
+  # ARM Virtual Architectural Timer -- fetch frequency from KVM\r
+  #\r
+  gArmTokenSpaceGuid.PcdArmArchTimerFreqInHz|0\r
+\r
+  # Use MMIO for accessing Serial port registers.\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdSerialUseMmio|TRUE\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdSerialPciDeviceInfo|{0xFF}\r
+\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|FALSE\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdBootManagerMenuFile|{ 0x21, 0xaa, 0x2c, 0x46, 0x14, 0x76, 0x03, 0x45, 0x83, 0x6e, 0x8a, 0xb6, 0xf4, 0x66, 0x23, 0x31 }\r
+\r
+  #\r
+  # The maximum physical I/O addressability of the processor, set with\r
+  # BuildCpuHob().\r
+  #\r
+  gEmbeddedTokenSpaceGuid.PcdPrePiCpuIoSize|16\r
+\r
+[PcdsPatchableInModule.common]\r
+  #\r
+  # This will be overridden in the code\r
+  #\r
+  gArmTokenSpaceGuid.PcdSystemMemoryBase|0x0\r
+  gArmTokenSpaceGuid.PcdSystemMemorySize|0x0\r
+\r
+  #\r
+  # The device tree base address is handed off by kvmtool.\r
+  # We are booting from RAM using the Linux kernel boot protocol,\r
+  # x0 will point to the DTB image in memory.\r
+  #\r
+  gArmVirtTokenSpaceGuid.PcdDeviceTreeInitialBaseAddress|0x0\r
+\r
+  gArmTokenSpaceGuid.PcdFdBaseAddress|0x0\r
+  gArmTokenSpaceGuid.PcdFvBaseAddress|0x0\r
+\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase|0x0\r
+\r
+[PcdsDynamicDefault.common]\r
+  gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut|3\r
+\r
+  gArmTokenSpaceGuid.PcdArmArchTimerSecIntrNum|0x0\r
+  gArmTokenSpaceGuid.PcdArmArchTimerIntrNum|0x0\r
+  gArmTokenSpaceGuid.PcdArmArchTimerVirtIntrNum|0x0\r
+  gArmTokenSpaceGuid.PcdArmArchTimerHypIntrNum|0x0\r
+\r
+  #\r
+  # ARM General Interrupt Controller\r
+  #\r
+  gArmTokenSpaceGuid.PcdGicDistributorBase|0x0\r
+  gArmTokenSpaceGuid.PcdGicRedistributorsBase|0x0\r
+  gArmTokenSpaceGuid.PcdGicInterruptInterfaceBase|0x0\r
+\r
+  #\r
+  # Set video resolution for boot options and for text setup.\r
+  # PlatformDxe can set the former at runtime.\r
+  #\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution|800\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdVideoVerticalResolution|600\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoHorizontalResolution|640\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoVerticalResolution|480\r
+\r
+  ## Force DTB\r
+  gArmVirtTokenSpaceGuid.PcdForceNoAcpi|TRUE\r
+\r
+  # Setup Flash storage variables\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase|0\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize|0x40000\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase|0\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize|0x40000\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase|0\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize|0x40000\r
+\r
+  ## RTC Register address in MMIO space.\r
+  gPcAtChipsetPkgTokenSpaceGuid.PcdRtcIndexRegister64|0x0\r
+  gPcAtChipsetPkgTokenSpaceGuid.PcdRtcTargetRegister64|0x0\r
+\r
+################################################################################\r
+#\r
+# Components Section - list of all EDK II Modules needed by this Platform\r
+#\r
+################################################################################\r
+[Components.common]\r
+  #\r
+  # PEI Phase modules\r
+  #\r
+  ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf {\r
+    <LibraryClasses>\r
+      ExtractGuidedSectionLib|EmbeddedPkg/Library/PrePiExtractGuidedSectionLib/PrePiExtractGuidedSectionLib.inf\r
+      LzmaDecompressLib|MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf\r
+      PrePiLib|EmbeddedPkg/Library/PrePiLib/PrePiLib.inf\r
+      HobLib|EmbeddedPkg/Library/PrePiHobLib/PrePiHobLib.inf\r
+      PrePiHobListPointerLib|ArmPlatformPkg/Library/PrePiHobListPointerLib/PrePiHobListPointerLib.inf\r
+      MemoryAllocationLib|EmbeddedPkg/Library/PrePiMemoryAllocationLib/PrePiMemoryAllocationLib.inf\r
+  }\r
+\r
+  #\r
+  # DXE\r
+  #\r
+  MdeModulePkg/Core/Dxe/DxeMain.inf {\r
+    <LibraryClasses>\r
+      NULL|MdeModulePkg/Library/DxeCrc32GuidedSectionExtractLib/DxeCrc32GuidedSectionExtractLib.inf\r
+      DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf\r
+  }\r
+  MdeModulePkg/Universal/PCD/Dxe/Pcd.inf {\r
+    <LibraryClasses>\r
+      PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf\r
+  }\r
+\r
+  #\r
+  # Architectural Protocols\r
+  #\r
+  ArmPkg/Drivers/CpuDxe/CpuDxe.inf\r
+  MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf\r
+  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf {\r
+    <LibraryClasses>\r
+      NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf\r
+      NULL|EmbeddedPkg/Library/NvVarStoreFormattedLib/NvVarStoreFormattedLib.inf\r
+      BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf\r
+  }\r
+\r
+  MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf\r
+  MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf\r
+  MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf {\r
+    <LibraryClasses>\r
+      NULL|ArmVirtPkg/Library/NorFlashKvmtoolLib/NorFlashKvmtoolLib.inf\r
+  }\r
+\r
+  MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf\r
+  MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf\r
+  MdeModulePkg/Universal/Metronome/Metronome.inf\r
+  PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf {\r
+    <LibraryClasses>\r
+      NULL|ArmVirtPkg/Library/KvmtoolRtcFdtClientLib/KvmtoolRtcFdtClientLib.inf\r
+  }\r
+\r
+  MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf\r
+  MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf\r
+  MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf\r
+  MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf\r
+  MdeModulePkg/Universal/SerialDxe/SerialDxe.inf\r
+\r
+  MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf\r
+\r
+  ArmPkg/Drivers/ArmGic/ArmGicDxe.inf\r
+  ArmPkg/Drivers/TimerDxe/TimerDxe.inf {\r
+    <LibraryClasses>\r
+      NULL|ArmVirtPkg/Library/ArmVirtTimerFdtClientLib/ArmVirtTimerFdtClientLib.inf\r
+  }\r
+\r
+  ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf\r
+\r
+  MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf\r
+\r
+  #\r
+  # Platform Driver\r
+  #\r
+  ArmVirtPkg/KvmtoolPlatformDxe/KvmtoolPlatformDxe.inf\r
+  ArmVirtPkg/VirtioFdtDxe/VirtioFdtDxe.inf\r
+  ArmVirtPkg/FdtClientDxe/FdtClientDxe.inf\r
+  ArmVirtPkg/HighMemDxe/HighMemDxe.inf\r
+  OvmfPkg/VirtioBlkDxe/VirtioBlk.inf\r
+  OvmfPkg/VirtioScsiDxe/VirtioScsi.inf\r
+  OvmfPkg/VirtioNetDxe/VirtioNet.inf\r
+  OvmfPkg/VirtioRngDxe/VirtioRng.inf\r
+\r
+  #\r
+  # FAT filesystem + GPT/MBR partitioning + UDF filesystem\r
+  #\r
+  MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf\r
+  MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf\r
+  MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf\r
+  FatPkg/EnhancedFatDxe/Fat.inf\r
+  MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf\r
+\r
+  #\r
+  # Bds\r
+  #\r
+  MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf {\r
+    <LibraryClasses>\r
+      DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf\r
+      PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf\r
+  }\r
+  MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf\r
+  MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf\r
+  MdeModulePkg/Universal/DriverHealthManagerDxe/DriverHealthManagerDxe.inf\r
+  MdeModulePkg/Universal/BdsDxe/BdsDxe.inf\r
+  MdeModulePkg/Logo/LogoDxe.inf\r
+  MdeModulePkg/Application/UiApp/UiApp.inf {\r
+    <LibraryClasses>\r
+      NULL|MdeModulePkg/Library/DeviceManagerUiLib/DeviceManagerUiLib.inf\r
+      NULL|MdeModulePkg/Library/BootManagerUiLib/BootManagerUiLib.inf\r
+      NULL|MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManagerUiLib.inf\r
+  }\r
+\r
+  #\r
+  # SCSI Bus and Disk Driver\r
+  #\r
+  MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf\r
+  MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf\r
diff --git a/ArmVirtPkg/ArmVirtKvmTool.fdf b/ArmVirtPkg/ArmVirtKvmTool.fdf
new file mode 100644 (file)
index 0000000..ebc82c5
--- /dev/null
@@ -0,0 +1,234 @@
+#\r
+#  Copyright (c) 2018 - 2020, ARM Limited. All rights reserved.\r
+#\r
+#  SPDX-License-Identifier: BSD-2-Clause-Patent\r
+#\r
+#\r
+\r
+################################################################################\r
+#\r
+# FD Section\r
+# The [FD] Section is made up of the definition statements and a\r
+# description of what goes into  the Flash Device Image.  Each FD section\r
+# defines one flash "device" image.  A flash device image may be one of\r
+# the following: Removable media bootable image (like a boot floppy\r
+# image,) an Option ROM image (that would be "flashed" into an add-in\r
+# card,) a System "Flash"  image (that would be burned into a system's\r
+# flash) or an Update ("Capsule") image that will be used to update and\r
+# existing system flash.\r
+#\r
+################################################################################\r
+\r
+[FD.KVMTOOL_EFI]\r
+BaseAddress   = 0x00000000|gArmTokenSpaceGuid.PcdFdBaseAddress\r
+# The size in bytes of the FLASH Device\r
+Size          = 0x00200000|gArmTokenSpaceGuid.PcdFdSize\r
+ErasePolarity = 1\r
+\r
+# This one is tricky, it must be: BlockSize * NumBlocks = Size\r
+BlockSize     = 0x00001000\r
+NumBlocks     = 0x200\r
+\r
+################################################################################\r
+#\r
+# Following are lists of FD Region layout which correspond to the locations of different\r
+# images within the flash device.\r
+#\r
+# Regions must be defined in ascending order and may not overlap.\r
+#\r
+# A Layout Region start with a eight digit hex offset (leading "0x" required) followed by\r
+# the pipe "|" character, followed by the size of the region, also in hex with the leading\r
+# "0x" characters. Like:\r
+# Offset|Size\r
+# PcdOffsetCName|PcdSizeCName\r
+# RegionType <FV, DATA, or FILE>\r
+#\r
+################################################################################\r
+\r
+#\r
+# Implement the Linux kernel header layout so that the loader will identify\r
+# it as something bootable, and execute it with a FDT pointer in x0 or r2.\r
+# This area will be reused to store a copy of the FDT so round it up to 32 KB.\r
+#\r
+0x00000000|0x00008000\r
+DATA = {\r
+!if $(ARCH) == AARCH64\r
+  0x01, 0x00, 0x00, 0x10,                         # code0: adr x1, .\r
+  0xff, 0x1f, 0x00, 0x14,                         # code1: b 0x8000\r
+  0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, # text_offset: 512 KB\r
+  0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, # image_size: 2 MB\r
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, # flags\r
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, # res2\r
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, # res3\r
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, # res4\r
+  0x41, 0x52, 0x4d, 0x64,                         # magic: "ARM\x64"\r
+  0x00, 0x00, 0x00, 0x00                          # res5\r
+!else\r
+  0x08, 0x10, 0x4f, 0xe2, # adr r1, .\r
+  0x02, 0x00, 0xa0, 0xe1, # mov r0, r2 (DTB)\r
+  0x00, 0x00, 0xa0, 0xe1, # nop\r
+  0x00, 0x00, 0xa0, 0xe1, # nop\r
+  0x00, 0x00, 0xa0, 0xe1, # nop\r
+  0x00, 0x00, 0xa0, 0xe1, # nop\r
+  0x00, 0x00, 0xa0, 0xe1, # nop\r
+  0x00, 0x00, 0xa0, 0xe1, # nop\r
+\r
+  0xf6, 0x1f, 0x00, 0xea, # b 0x8000\r
+  0x18, 0x28, 0x6f, 0x01, # magic\r
+  0x00, 0x00, 0x00, 0x00, # start\r
+  0x00, 0x00, 0x20, 0x00, # image size: 2 MB\r
+  0x01, 0x02, 0x03, 0x04  # endiannness flag\r
+!endif\r
+}\r
+\r
+0x00008000|0x001f8000\r
+gArmTokenSpaceGuid.PcdFvBaseAddress|gArmTokenSpaceGuid.PcdFvSize\r
+FV = FVMAIN_COMPACT\r
+\r
+################################################################################\r
+#\r
+# FV Section\r
+#\r
+# [FV] section is used to define what components or modules are placed within a flash\r
+# device file.  This section also defines order the components and modules are positioned\r
+# within the image.  The [FV] section consists of define statements, set statements and\r
+# module statements.\r
+#\r
+################################################################################\r
+\r
+[FV.FvMain]\r
+FvNameGuid         = 8A91C08E-7D9D-4933-84D6-901D26D0766E\r
+BlockSize          = 0x40\r
+NumBlocks          = 0         # This FV gets compressed so make it just big enough\r
+FvAlignment        = 16        # FV alignment and FV attributes setting.\r
+ERASE_POLARITY     = 1\r
+MEMORY_MAPPED      = TRUE\r
+STICKY_WRITE       = TRUE\r
+LOCK_CAP           = TRUE\r
+LOCK_STATUS        = TRUE\r
+WRITE_DISABLED_CAP = TRUE\r
+WRITE_ENABLED_CAP  = TRUE\r
+WRITE_STATUS       = TRUE\r
+WRITE_LOCK_CAP     = TRUE\r
+WRITE_LOCK_STATUS  = TRUE\r
+READ_DISABLED_CAP  = TRUE\r
+READ_ENABLED_CAP   = TRUE\r
+READ_STATUS        = TRUE\r
+READ_LOCK_CAP      = TRUE\r
+READ_LOCK_STATUS   = TRUE\r
+\r
+  INF MdeModulePkg/Core/Dxe/DxeMain.inf\r
+  INF MdeModulePkg/Universal/PCD/Dxe/Pcd.inf\r
+  INF ArmVirtPkg/VirtioFdtDxe/VirtioFdtDxe.inf\r
+  INF ArmVirtPkg/FdtClientDxe/FdtClientDxe.inf\r
+  INF ArmVirtPkg/KvmtoolPlatformDxe/KvmtoolPlatformDxe.inf\r
+  INF ArmVirtPkg/HighMemDxe/HighMemDxe.inf\r
+\r
+  #\r
+  # PI DXE Drivers producing Architectural Protocols (EFI Services)\r
+  #\r
+  INF ArmPkg/Drivers/CpuDxe/CpuDxe.inf\r
+  INF MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf\r
+  INF MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf\r
+  INF MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf\r
+  INF MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf\r
+  INF MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf\r
+\r
+  INF MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf\r
+  INF MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf\r
+\r
+  INF  MdeModulePkg/Universal/Metronome/Metronome.inf\r
+  INF  PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf\r
+\r
+  INF MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf\r
+\r
+  #\r
+  # Multiple Console IO support\r
+  #\r
+  INF MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf\r
+  INF MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf\r
+  INF MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf\r
+  INF MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf\r
+  INF MdeModulePkg/Universal/SerialDxe/SerialDxe.inf\r
+\r
+  INF ArmPkg/Drivers/ArmGic/ArmGicDxe.inf\r
+  INF ArmPkg/Drivers/TimerDxe/TimerDxe.inf\r
+  INF MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf\r
+  INF ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf\r
+\r
+  #\r
+  # FAT filesystem + GPT/MBR partitioning + UDF filesystem\r
+  #\r
+  INF MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf\r
+  INF MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf\r
+  INF FatPkg/EnhancedFatDxe/Fat.inf\r
+  INF MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf\r
+  INF MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf\r
+\r
+  #\r
+  # Platform Driver\r
+  #\r
+  INF OvmfPkg/VirtioBlkDxe/VirtioBlk.inf\r
+  INF OvmfPkg/VirtioNetDxe/VirtioNet.inf\r
+  INF OvmfPkg/VirtioScsiDxe/VirtioScsi.inf\r
+  INF OvmfPkg/VirtioRngDxe/VirtioRng.inf\r
+\r
+  #\r
+  # UEFI application (Shell Embedded Boot Loader)\r
+  #\r
+  INF ShellPkg/Application/Shell/Shell.inf\r
+  INF ShellPkg/DynamicCommand/TftpDynamicCommand/TftpDynamicCommand.inf\r
+\r
+  #\r
+  # Bds\r
+  #\r
+  INF MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf\r
+  INF MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf\r
+  INF MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf\r
+  INF MdeModulePkg/Universal/DriverHealthManagerDxe/DriverHealthManagerDxe.inf\r
+  INF MdeModulePkg/Universal/BdsDxe/BdsDxe.inf\r
+  INF MdeModulePkg/Application/UiApp/UiApp.inf\r
+\r
+  #\r
+  # SCSI Bus and Disk Driver\r
+  #\r
+  INF MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf\r
+  INF MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf\r
+\r
+  #\r
+  # TianoCore logo (splash screen)\r
+  #\r
+  INF MdeModulePkg/Logo/LogoDxe.inf\r
+\r
+  #\r
+  # Ramdisk support\r
+  #\r
+  INF MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskDxe.inf\r
+\r
+[FV.FVMAIN_COMPACT]\r
+FvAlignment        = 16\r
+ERASE_POLARITY     = 1\r
+MEMORY_MAPPED      = TRUE\r
+STICKY_WRITE       = TRUE\r
+LOCK_CAP           = TRUE\r
+LOCK_STATUS        = TRUE\r
+WRITE_DISABLED_CAP = TRUE\r
+WRITE_ENABLED_CAP  = TRUE\r
+WRITE_STATUS       = TRUE\r
+WRITE_LOCK_CAP     = TRUE\r
+WRITE_LOCK_STATUS  = TRUE\r
+READ_DISABLED_CAP  = TRUE\r
+READ_ENABLED_CAP   = TRUE\r
+READ_STATUS        = TRUE\r
+READ_LOCK_CAP      = TRUE\r
+READ_LOCK_STATUS   = TRUE\r
+\r
+  INF RuleOverride = SELF_RELOC ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf\r
+\r
+  FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 {\r
+    SECTION GUIDED EE4E5898-3914-4259-9D6E-DC7BD79403CF PROCESSING_REQUIRED = TRUE {\r
+      SECTION FV_IMAGE = FVMAIN\r
+    }\r
+  }\r
+\r
+!include ArmVirtRules.fdf.inc\r