]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmVirtualizationPkg: add GICv3 detection to VirtFdtDxe
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Sat, 28 Feb 2015 20:25:26 +0000 (20:25 +0000)
committerlersek <lersek@Edk2>
Sat, 28 Feb 2015 20:25:26 +0000 (20:25 +0000)
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 <olivier.martin@arm.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16956 6f19259b-4bc3-4df7-8a09-765794883524

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

index 1547273956ebd06de6d172e01caf2635199d8cc9..0da1224649dc4eaa8c0f4382f248548e43f02319 100644 (file)
   # ARM General Interrupt Controller\r
   #\r
   gArmTokenSpaceGuid.PcdGicDistributorBase|0x0\r
+  gArmTokenSpaceGuid.PcdGicRedistributorsBase|0x0\r
   gArmTokenSpaceGuid.PcdGicInterruptInterfaceBase|0x0\r
 \r
   ## PL031 RealTimeClock\r
index 274cdeb8c8f49e5cced2d6e01261a715814df989..041ad88e10bcb2cfb06cf77e2ba5f1f6cf36dbf7 100644 (file)
@@ -47,6 +47,7 @@ typedef enum {
   PropertyTypePsci,\r
   PropertyTypeFwCfg,\r
   PropertyTypePciHost,\r
+  PropertyTypeGicV3,\r
 } PROPERTY_TYPE;\r
 \r
 typedef struct {\r
@@ -64,6 +65,7 @@ STATIC CONST PROPERTY CompatibleProperties[] = {
   { PropertyTypePsci,    "arm,psci-0.2"          },\r
   { PropertyTypeFwCfg,   "qemu,fw-cfg-mmio"      },\r
   { PropertyTypePciHost, "pci-host-ecam-generic" },\r
+  { PropertyTypeGicV3,   "arm,gic-v3"            },\r
   { PropertyTypeUnknown, ""                      }\r
 };\r
 \r
@@ -286,7 +288,7 @@ InitializeVirtFdtDxe (
   VIRTIO_TRANSPORT_DEVICE_PATH   *DevicePath;\r
   EFI_HANDLE                     Handle;\r
   UINT64                         RegBase;\r
-  UINT64                         DistBase, CpuBase;\r
+  UINT64                         DistBase, CpuBase, RedistBase;\r
   CONST INTERRUPT_PROPERTY       *InterruptProp;\r
   INT32                          SecIntrNum, IntrNum, VirtIntrNum, HypIntrNum;\r
   CONST CHAR8                    *PsciMethod;\r
@@ -434,6 +436,36 @@ InitializeVirtFdtDxe (
       DEBUG ((EFI_D_INFO, "Found GIC @ 0x%Lx/0x%Lx\n", DistBase, CpuBase));\r
       break;\r
 \r
+    case PropertyTypeGicV3:\r
+      //\r
+      // The GIC v3 DT binding describes a series of at least 3 physical (base\r
+      // addresses, size) pairs: the distributor interface (GICD), at least one\r
+      // redistributor region (GICR) containing dedicated redistributor\r
+      // interfaces for all individual CPUs, and the CPU interface (GICC).\r
+      // Under virtualization, we assume that the first redistributor region\r
+      // listed covers the boot CPU. Also, our GICv3 driver only supports the\r
+      // system register CPU interface, so we can safely ignore the MMIO version\r
+      // which is listed after the sequence of redistributor interfaces.\r
+      // This means we are only interested in the first two memory regions\r
+      // supplied, and ignore everything else.\r
+      //\r
+      ASSERT (Len >= 32);\r
+\r
+      // RegProp[0..1] == { GICD base, GICD size }\r
+      DistBase = fdt64_to_cpu (((UINT64 *)RegProp)[0]);\r
+      ASSERT (DistBase < MAX_UINT32);\r
+\r
+      // RegProp[2..3] == { GICR base, GICR size }\r
+      RedistBase = fdt64_to_cpu (((UINT64 *)RegProp)[2]);\r
+      ASSERT (RedistBase < MAX_UINT32);\r
+\r
+      PcdSet32 (PcdGicDistributorBase, (UINT32)DistBase);\r
+      PcdSet32 (PcdGicRedistributorsBase, (UINT32)RedistBase);\r
+\r
+      DEBUG ((EFI_D_INFO, "Found GIC v3 (re)distributor @ 0x%Lx (0x%Lx)\n",\r
+        DistBase, RedistBase));\r
+      break;\r
+\r
     case PropertyTypeRtc:\r
       ASSERT (Len == 16);\r
 \r
index ff05c5e058fb3e198e854a28b54fc5899bffed8f..cdfca610604a8f3fd9ed35ccb7bdef9a5b71ae1f 100644 (file)
@@ -52,6 +52,7 @@
   gArmVirtualizationTokenSpaceGuid.PcdFwCfgSelectorAddress\r
   gArmVirtualizationTokenSpaceGuid.PcdFwCfgDataAddress\r
   gArmTokenSpaceGuid.PcdGicDistributorBase\r
+  gArmTokenSpaceGuid.PcdGicRedistributorsBase\r
   gArmTokenSpaceGuid.PcdGicInterruptInterfaceBase\r
   gArmTokenSpaceGuid.PcdArmArchTimerSecIntrNum\r
   gArmTokenSpaceGuid.PcdArmArchTimerIntrNum\r