Revision: 16956
          http://sourceforge.net/p/edk2/code/16956
Author:   lersek
Date:     2015-02-28 20:25:26 +0000 (Sat, 28 Feb 2015)
Log Message:
-----------
ArmVirtualizationPkg: add GICv3 detection to VirtFdtDxe

This adds support for detecting the presence of a GICv3 interrupt
controller from the device tree, and recording its distributor and
redistributor base addresses in their respective PCDs.

Contributed-under: TianoCore Contribution Agreement 1.0
Reviewed-by: Olivier Martin <[email protected]>
Acked-by: Laszlo Ersek <[email protected]>
Signed-off-by: Ard Biesheuvel <[email protected]>
Signed-off-by: Laszlo Ersek <[email protected]>

Modified Paths:
--------------
    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/ArmVirtualizationQemu.dsc
===================================================================
--- trunk/edk2/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc    
2015-02-28 20:25:17 UTC (rev 16955)
+++ trunk/edk2/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc    
2015-02-28 20:25:26 UTC (rev 16956)
@@ -188,6 +188,7 @@
   # ARM General Interrupt Controller
   #
   gArmTokenSpaceGuid.PcdGicDistributorBase|0x0
+  gArmTokenSpaceGuid.PcdGicRedistributorsBase|0x0
   gArmTokenSpaceGuid.PcdGicInterruptInterfaceBase|0x0
 
   ## PL031 RealTimeClock

Modified: trunk/edk2/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c
===================================================================
--- trunk/edk2/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c      
2015-02-28 20:25:17 UTC (rev 16955)
+++ trunk/edk2/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c      
2015-02-28 20:25:26 UTC (rev 16956)
@@ -47,6 +47,7 @@
   PropertyTypePsci,
   PropertyTypeFwCfg,
   PropertyTypePciHost,
+  PropertyTypeGicV3,
 } PROPERTY_TYPE;
 
 typedef struct {
@@ -64,6 +65,7 @@
   { PropertyTypePsci,    "arm,psci-0.2"          },
   { PropertyTypeFwCfg,   "qemu,fw-cfg-mmio"      },
   { PropertyTypePciHost, "pci-host-ecam-generic" },
+  { PropertyTypeGicV3,   "arm,gic-v3"            },
   { PropertyTypeUnknown, ""                      }
 };
 
@@ -286,7 +288,7 @@
   VIRTIO_TRANSPORT_DEVICE_PATH   *DevicePath;
   EFI_HANDLE                     Handle;
   UINT64                         RegBase;
-  UINT64                         DistBase, CpuBase;
+  UINT64                         DistBase, CpuBase, RedistBase;
   CONST INTERRUPT_PROPERTY       *InterruptProp;
   INT32                          SecIntrNum, IntrNum, VirtIntrNum, HypIntrNum;
   CONST CHAR8                    *PsciMethod;
@@ -434,6 +436,36 @@
       DEBUG ((EFI_D_INFO, "Found GIC @ 0x%Lx/0x%Lx\n", DistBase, CpuBase));
       break;
 
+    case PropertyTypeGicV3:
+      //
+      // The GIC v3 DT binding describes a series of at least 3 physical (base
+      // addresses, size) pairs: the distributor interface (GICD), at least one
+      // redistributor region (GICR) containing dedicated redistributor
+      // interfaces for all individual CPUs, and the CPU interface (GICC).
+      // Under virtualization, we assume that the first redistributor region
+      // listed covers the boot CPU. Also, our GICv3 driver only supports the
+      // system register CPU interface, so we can safely ignore the MMIO 
version
+      // which is listed after the sequence of redistributor interfaces.
+      // This means we are only interested in the first two memory regions
+      // supplied, and ignore everything else.
+      //
+      ASSERT (Len >= 32);
+
+      // RegProp[0..1] == { GICD base, GICD size }
+      DistBase = fdt64_to_cpu (((UINT64 *)RegProp)[0]);
+      ASSERT (DistBase < MAX_UINT32);
+
+      // RegProp[2..3] == { GICR base, GICR size }
+      RedistBase = fdt64_to_cpu (((UINT64 *)RegProp)[2]);
+      ASSERT (RedistBase < MAX_UINT32);
+
+      PcdSet32 (PcdGicDistributorBase, (UINT32)DistBase);
+      PcdSet32 (PcdGicRedistributorsBase, (UINT32)RedistBase);
+
+      DEBUG ((EFI_D_INFO, "Found GIC v3 (re)distributor @ 0x%Lx (0x%Lx)\n",
+        DistBase, RedistBase));
+      break;
+
     case PropertyTypeRtc:
       ASSERT (Len == 16);
 

Modified: 
trunk/edk2/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf
===================================================================
--- trunk/edk2/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf    
2015-02-28 20:25:17 UTC (rev 16955)
+++ trunk/edk2/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf    
2015-02-28 20:25:26 UTC (rev 16956)
@@ -52,6 +52,7 @@
   gArmVirtualizationTokenSpaceGuid.PcdFwCfgSelectorAddress
   gArmVirtualizationTokenSpaceGuid.PcdFwCfgDataAddress
   gArmTokenSpaceGuid.PcdGicDistributorBase
+  gArmTokenSpaceGuid.PcdGicRedistributorsBase
   gArmTokenSpaceGuid.PcdGicInterruptInterfaceBase
   gArmTokenSpaceGuid.PcdArmArchTimerSecIntrNum
   gArmTokenSpaceGuid.PcdArmArchTimerIntrNum


------------------------------------------------------------------------------
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