Revision: 16566
          http://sourceforge.net/p/edk2/code/16566
Author:   lersek
Date:     2015-01-02 12:04:05 +0000 (Fri, 02 Jan 2015)
Log Message:
-----------
ArmVirtualizationPkg: VirtFdtDxe: forward FwCfg addresses from DTB to PCDs

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 <[email protected]>

Modified Paths:
--------------
    trunk/edk2/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationPkg.dec
    trunk/edk2/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc
    trunk/edk2/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c
    trunk/edk2/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf

Modified: 
trunk/edk2/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationPkg.dec
===================================================================
--- trunk/edk2/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationPkg.dec     
2014-12-31 01:47:39 UTC (rev 16565)
+++ trunk/edk2/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationPkg.dec     
2015-01-02 12:04:05 UTC (rev 16566)
@@ -53,3 +53,6 @@
   # PcdArmPsciMethod == 2 : use SMC
   #
   gArmVirtualizationTokenSpaceGuid.PcdArmPsciMethod|0|UINT32|0x00000003
+
+  
gArmVirtualizationTokenSpaceGuid.PcdFwCfgSelectorAddress|0x0|UINT64|0x00000004
+  gArmVirtualizationTokenSpaceGuid.PcdFwCfgDataAddress|0x0|UINT64|0x00000005

Modified: 
trunk/edk2/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc
===================================================================
--- trunk/edk2/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc    
2014-12-31 01:47:39 UTC (rev 16565)
+++ trunk/edk2/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc    
2015-01-02 12:04:05 UTC (rev 16566)
@@ -173,6 +173,9 @@
 
   gArmVirtualizationTokenSpaceGuid.PcdArmPsciMethod|0
 
+  gArmVirtualizationTokenSpaceGuid.PcdFwCfgSelectorAddress|0x0
+  gArmVirtualizationTokenSpaceGuid.PcdFwCfgDataAddress|0x0
+
 
################################################################################
 #
 # Components Section - list of all EDK II Modules needed by this Platform

Modified: trunk/edk2/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c
===================================================================
--- trunk/edk2/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c      
2014-12-31 01:47:39 UTC (rev 16565)
+++ trunk/edk2/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c      
2015-01-02 12:04:05 UTC (rev 16566)
@@ -44,6 +44,7 @@
   PropertyTypeUart,
   PropertyTypeTimer,
   PropertyTypePsci,
+  PropertyTypeFwCfg,
 } PROPERTY_TYPE;
 
 typedef struct {
@@ -59,6 +60,7 @@
   { PropertyTypeTimer,   "arm,armv7-timer"     },
   { PropertyTypeTimer,   "arm,armv8-timer"     },
   { PropertyTypePsci,    "arm,psci-0.2"        },
+  { PropertyTypeFwCfg,   "qemu,fw-cfg-mmio"    },
   { PropertyTypeUnknown, ""                    }
 };
 
@@ -115,6 +117,10 @@
   CONST INTERRUPT_PROPERTY       *InterruptProp;
   INT32                          SecIntrNum, IntrNum, VirtIntrNum, HypIntrNum;
   CONST CHAR8                    *PsciMethod;
+  UINT64                         FwCfgSelectorAddress;
+  UINT64                         FwCfgSelectorSize;
+  UINT64                         FwCfgDataAddress;
+  UINT64                         FwCfgDataSize;
 
   DeviceTreeBase = (VOID *)(UINTN)PcdGet64 (PcdDeviceTreeBaseAddress);
   ASSERT (DeviceTreeBase != NULL);
@@ -160,6 +166,34 @@
       (PropType == PropertyTypePsci));
 
     switch (PropType) {
+    case PropertyTypeFwCfg:
+      ASSERT (Len == 2 * sizeof (UINT64));
+
+      FwCfgDataAddress     = fdt64_to_cpu (((UINT64 *)RegProp)[0]);
+      FwCfgDataSize        = 8;
+      FwCfgSelectorAddress = FwCfgDataAddress + FwCfgDataSize;
+      FwCfgSelectorSize    = 2;
+
+      //
+      // The following ASSERT()s express
+      //
+      //   Address + Size - 1 <= MAX_UINTN
+      //
+      // for both registers, that is, that the last byte in each MMIO range is
+      // expressible as a MAX_UINTN. The form below is mathematically
+      // equivalent, and it also prevents any unsigned overflow before the
+      // comparison.
+      //
+      ASSERT (FwCfgSelectorAddress <= MAX_UINTN - FwCfgSelectorSize + 1);
+      ASSERT (FwCfgDataAddress     <= MAX_UINTN - FwCfgDataSize     + 1);
+
+      PcdSet64 (PcdFwCfgSelectorAddress, FwCfgSelectorAddress);
+      PcdSet64 (PcdFwCfgDataAddress,     FwCfgDataAddress);
+
+      DEBUG ((EFI_D_INFO, "Found FwCfg @ 0x%Lx/0x%Lx\n", FwCfgSelectorAddress,
+        FwCfgDataAddress));
+      break;
+
     case PropertyTypeVirtio:
       ASSERT (Len == 16);
       //

Modified: 
trunk/edk2/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf
===================================================================
--- trunk/edk2/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf    
2014-12-31 01:47:39 UTC (rev 16565)
+++ trunk/edk2/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf    
2015-01-02 12:04:05 UTC (rev 16566)
@@ -47,6 +47,8 @@
 [Pcd]
   gArmVirtualizationTokenSpaceGuid.PcdDeviceTreeBaseAddress
   gArmVirtualizationTokenSpaceGuid.PcdArmPsciMethod
+  gArmVirtualizationTokenSpaceGuid.PcdFwCfgSelectorAddress
+  gArmVirtualizationTokenSpaceGuid.PcdFwCfgDataAddress
   gArmTokenSpaceGuid.PcdGicDistributorBase
   gArmTokenSpaceGuid.PcdGicInterruptInterfaceBase
   gArmTokenSpaceGuid.PcdArmArchTimerSecIntrNum


------------------------------------------------------------------------------
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to