]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmVirtualizationPkg: VirtFdtDxe: forward FwCfg addresses from DTB to PCDs
authorLaszlo Ersek <lersek@redhat.com>
Fri, 2 Jan 2015 12:04:05 +0000 (12:04 +0000)
committerlersek <lersek@Edk2>
Fri, 2 Jan 2015 12:04:05 +0000 (12:04 +0000)
Qemu's firmware configuration interface for ARM consists of two MMIO
registers, a 16-bit selector, and a 64-bit data register that allows the
guest to transfer data with 8, 16, 32, and 64-bit wide accesses. Parse the
base address from the DTB, and expose the registers to the rest of DXE via
dynamic PCDs.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16566 6f19259b-4bc3-4df7-8a09-765794883524

ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationPkg.dec
ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc
ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c
ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf

index b581add024aa02830e264a4e2ef3f48761cf4899..99411548aff6a5bcd37df903db7cd6d54bef7a99 100644 (file)
@@ -53,3 +53,6 @@
   # PcdArmPsciMethod == 2 : use SMC\r
   #\r
   gArmVirtualizationTokenSpaceGuid.PcdArmPsciMethod|0|UINT32|0x00000003\r
+\r
+  gArmVirtualizationTokenSpaceGuid.PcdFwCfgSelectorAddress|0x0|UINT64|0x00000004\r
+  gArmVirtualizationTokenSpaceGuid.PcdFwCfgDataAddress|0x0|UINT64|0x00000005\r
index 66052f56abec45149007c4dfbb8bc9b64e66290f..d23832fc013024be5dd65e43ab92bd4dfcad120e 100644 (file)
 \r
   gArmVirtualizationTokenSpaceGuid.PcdArmPsciMethod|0\r
 \r
+  gArmVirtualizationTokenSpaceGuid.PcdFwCfgSelectorAddress|0x0\r
+  gArmVirtualizationTokenSpaceGuid.PcdFwCfgDataAddress|0x0\r
+\r
 ################################################################################\r
 #\r
 # Components Section - list of all EDK II Modules needed by this Platform\r
index d002e668aa48ac1f7419fe1e8c8971e42df2f689..95e91eb82282ec7a829429926d792bae214384e8 100644 (file)
@@ -44,6 +44,7 @@ typedef enum {
   PropertyTypeUart,\r
   PropertyTypeTimer,\r
   PropertyTypePsci,\r
+  PropertyTypeFwCfg,\r
 } PROPERTY_TYPE;\r
 \r
 typedef struct {\r
@@ -59,6 +60,7 @@ STATIC CONST PROPERTY CompatibleProperties[] = {
   { PropertyTypeTimer,   "arm,armv7-timer"     },\r
   { PropertyTypeTimer,   "arm,armv8-timer"     },\r
   { PropertyTypePsci,    "arm,psci-0.2"        },\r
+  { PropertyTypeFwCfg,   "qemu,fw-cfg-mmio"    },\r
   { PropertyTypeUnknown, ""                    }\r
 };\r
 \r
@@ -115,6 +117,10 @@ InitializeVirtFdtDxe (
   CONST INTERRUPT_PROPERTY       *InterruptProp;\r
   INT32                          SecIntrNum, IntrNum, VirtIntrNum, HypIntrNum;\r
   CONST CHAR8                    *PsciMethod;\r
+  UINT64                         FwCfgSelectorAddress;\r
+  UINT64                         FwCfgSelectorSize;\r
+  UINT64                         FwCfgDataAddress;\r
+  UINT64                         FwCfgDataSize;\r
 \r
   DeviceTreeBase = (VOID *)(UINTN)PcdGet64 (PcdDeviceTreeBaseAddress);\r
   ASSERT (DeviceTreeBase != NULL);\r
@@ -160,6 +166,34 @@ InitializeVirtFdtDxe (
       (PropType == PropertyTypePsci));\r
 \r
     switch (PropType) {\r
+    case PropertyTypeFwCfg:\r
+      ASSERT (Len == 2 * sizeof (UINT64));\r
+\r
+      FwCfgDataAddress     = fdt64_to_cpu (((UINT64 *)RegProp)[0]);\r
+      FwCfgDataSize        = 8;\r
+      FwCfgSelectorAddress = FwCfgDataAddress + FwCfgDataSize;\r
+      FwCfgSelectorSize    = 2;\r
+\r
+      //\r
+      // The following ASSERT()s express\r
+      //\r
+      //   Address + Size - 1 <= MAX_UINTN\r
+      //\r
+      // for both registers, that is, that the last byte in each MMIO range is\r
+      // expressible as a MAX_UINTN. The form below is mathematically\r
+      // equivalent, and it also prevents any unsigned overflow before the\r
+      // comparison.\r
+      //\r
+      ASSERT (FwCfgSelectorAddress <= MAX_UINTN - FwCfgSelectorSize + 1);\r
+      ASSERT (FwCfgDataAddress     <= MAX_UINTN - FwCfgDataSize     + 1);\r
+\r
+      PcdSet64 (PcdFwCfgSelectorAddress, FwCfgSelectorAddress);\r
+      PcdSet64 (PcdFwCfgDataAddress,     FwCfgDataAddress);\r
+\r
+      DEBUG ((EFI_D_INFO, "Found FwCfg @ 0x%Lx/0x%Lx\n", FwCfgSelectorAddress,\r
+        FwCfgDataAddress));\r
+      break;\r
+\r
     case PropertyTypeVirtio:\r
       ASSERT (Len == 16);\r
       //\r
index 1c9dd20580c4d1944b64c8667b7f136eac69ceb4..daafe6cb5a893215685b4a41db24441ad478fa6d 100644 (file)
@@ -47,6 +47,8 @@
 [Pcd]\r
   gArmVirtualizationTokenSpaceGuid.PcdDeviceTreeBaseAddress\r
   gArmVirtualizationTokenSpaceGuid.PcdArmPsciMethod\r
+  gArmVirtualizationTokenSpaceGuid.PcdFwCfgSelectorAddress\r
+  gArmVirtualizationTokenSpaceGuid.PcdFwCfgDataAddress\r
   gArmTokenSpaceGuid.PcdGicDistributorBase\r
   gArmTokenSpaceGuid.PcdGicInterruptInterfaceBase\r
   gArmTokenSpaceGuid.PcdArmArchTimerSecIntrNum\r