]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmVirtPkg: implement DT-based ArmGicArchLib
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Tue, 28 Jul 2015 20:45:36 +0000 (20:45 +0000)
committerabiesheuvel <abiesheuvel@Edk2>
Tue, 28 Jul 2015 20:45:36 +0000 (20:45 +0000)
Since it is arguably incorrect to infer the GIC revision from CPU
ID and GIC feature registers on platforms that describe the GIC in
the device tree, this implements the library class ArmGicArchLib
tailored for such platforms.

The supported GIC revision is retrieved from the dynamic PCD that
is set based on the GIC DT node.

This means this library can only execute post DXE core, but this is
not a problem for any of the virt platforms.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
Tested-by: Leif Lindholm <leif.lindholm@linaro.org>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18102 6f19259b-4bc3-4df7-8a09-765794883524

ArmVirtPkg/ArmVirt.dsc.inc
ArmVirtPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.c [new file with mode: 0644]
ArmVirtPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.inf [new file with mode: 0644]

index eaafe51a7dab8c8d19a376da40b9965c4e432bdc..b2003a58be04ac30ad9e993d86f1b9a2dd365307 100644 (file)
@@ -76,7 +76,7 @@
   ArmDisassemblerLib|ArmPkg/Library/ArmDisassemblerLib/ArmDisassemblerLib.inf\r
   DmaLib|ArmPkg/Library/ArmDmaLib/ArmDmaLib.inf\r
   ArmGicLib|ArmPkg/Drivers/ArmGic/ArmGicLib.inf\r
-  ArmGicArchLib|ArmPkg/Library/ArmGicArchLib/ArmGicArchLib.inf\r
+  ArmGicArchLib|ArmVirtPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.inf\r
   ArmPlatformStackLib|ArmPlatformPkg/Library/ArmPlatformStackLib/ArmPlatformStackLib.inf\r
   ArmSmcLib|ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf\r
   ArmHvcLib|ArmPkg/Library/ArmHvcLib/ArmHvcLib.inf\r
diff --git a/ArmVirtPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.c b/ArmVirtPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.c
new file mode 100644 (file)
index 0000000..732860c
--- /dev/null
@@ -0,0 +1,75 @@
+/** @file\r
+  ArmGicArchLib library class implementation for DT based virt platforms\r
+\r
+  Copyright (c) 2015, Linaro Ltd. All rights reserved.<BR>\r
+\r
+  This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include <Base.h>\r
+\r
+#include <Library/ArmGicLib.h>\r
+#include <Library/ArmGicArchLib.h>\r
+#include <Library/PcdLib.h>\r
+#include <Library/DebugLib.h>\r
+\r
+STATIC ARM_GIC_ARCH_REVISION        mGicArchRevision;\r
+\r
+RETURN_STATUS\r
+EFIAPI\r
+ArmVirtGicArchLibConstructor (\r
+  VOID\r
+  )\r
+{\r
+  UINT32  IccSre;\r
+\r
+  switch (PcdGet32 (PcdArmGicRevision)) {\r
+\r
+  case 3:\r
+    //\r
+    // The default implementation of ArmGicArchLib is responsible for enabling\r
+    // the system register interface on the GICv3 if one is found. So let's do\r
+    // the same here.\r
+    //\r
+    IccSre = ArmGicV3GetControlSystemRegisterEnable ();\r
+    if (!(IccSre & ICC_SRE_EL2_SRE)) {\r
+      ArmGicV3SetControlSystemRegisterEnable (IccSre | ICC_SRE_EL2_SRE);\r
+      IccSre = ArmGicV3GetControlSystemRegisterEnable ();\r
+    }\r
+\r
+    //\r
+    // Unlike the default implementation, there is no fall through to GICv2\r
+    // mode if this GICv3 cannot be driven in native mode due to the fact\r
+    // that the System Register interface is unavailable.\r
+    //\r
+    ASSERT (IccSre & ICC_SRE_EL2_SRE);\r
+\r
+    mGicArchRevision = ARM_GIC_ARCH_REVISION_3;\r
+    break;\r
+\r
+  case 2:\r
+    mGicArchRevision = ARM_GIC_ARCH_REVISION_2;\r
+    break;\r
+\r
+  default:\r
+    DEBUG ((EFI_D_ERROR, "%a: No GIC revision specified!\n", __FUNCTION__));\r
+    return RETURN_NOT_FOUND;\r
+  }\r
+  return RETURN_SUCCESS;\r
+}\r
+\r
+ARM_GIC_ARCH_REVISION\r
+EFIAPI\r
+ArmGicGetSupportedArchRevision (\r
+  VOID\r
+  )\r
+{\r
+  return mGicArchRevision;\r
+}\r
diff --git a/ArmVirtPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.inf b/ArmVirtPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.inf
new file mode 100644 (file)
index 0000000..c85b2d4
--- /dev/null
@@ -0,0 +1,40 @@
+#/** @file\r
+#\r
+#  Component description file for ArmVirtGicArchLib module\r
+#\r
+#  Copyright (c) 2015, Linaro Ltd. All rights reserved.<BR>\r
+#\r
+#  This program and the accompanying materials\r
+#  are licensed and made available under the terms and conditions of the BSD License\r
+#  which accompanies this distribution.  The full text of the license may be found at\r
+#  http://opensource.org/licenses/bsd-license.php\r
+#\r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#**/\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = ArmVirtGicArchLib\r
+  FILE_GUID                      = 87b0dc84-4661-4deb-a789-97977ff636ed\r
+  MODULE_TYPE                    = BASE\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = ArmGicArchLib|DXE_DRIVER UEFI_DRIVER UEFI_APPLICATION\r
+  CONSTRUCTOR                    = ArmVirtGicArchLibConstructor\r
+\r
+[Sources]\r
+  ArmVirtGicArchLib.c\r
+\r
+[LibraryClasses]\r
+  PcdLib\r
+  DebugLib\r
+  ArmGicLib\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  ArmPkg/ArmPkg.dec\r
+  ArmVirtPkg/ArmVirtPkg.dec\r
+\r
+[Pcd]\r
+  gArmVirtTokenSpaceGuid.PcdArmGicRevision\r