diff mbox

[edk2,2/4] ArmPkg: split off ArmGicArchLib from ArmGicLib

Message ID 1423132136-19349-3-git-send-email-ard.biesheuvel@linaro.org
State New
Headers show

Commit Message

Ard Biesheuvel Feb. 5, 2015, 10:28 a.m. UTC
The current implementation of ArmGicGetSupportedArchRevision ()
that is used by all ARM platforms is entirely stateless (in order
to support being executed from flash) so it needs to interrogate
the hardware for the supported GIC revision upon each invocation.

However, on platforms that execute under virtualization, every read
or write to a system register may require handling by the host, which
on KVM incurs two (!) world switches, i.e., from guest to host and vice
versa. Considering how often ArmGicGetSupportedArchRevision () is called,
it would be preferable to allow platforms that execute under virtualization
to supply a custom version of this function.

This patch introduces the ArmGicArchLib library class and default
implementation, and moves just this function to it.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 ArmPkg/ArmPkg.dec                                  |  1 +
 ArmPkg/ArmPkg.dsc                                  |  1 +
 ArmPkg/Drivers/ArmGic/ArmGicArchLib.inf            | 33 ++++++++++++++++++++++
 ArmPkg/Drivers/ArmGic/ArmGicLib.inf                |  3 +-
 ArmPkg/Drivers/ArmGic/ArmGicSecLib.inf             |  3 +-
 ArmPkg/Include/Library/ArmGicArchLib.h             | 33 ++++++++++++++++++++++
 ArmPkg/Include/Library/ArmGicLib.h                 | 14 +--------
 ArmPlatformPkg/ArmPlatformPkg-2ndstage.dsc         |  1 +
 ArmPlatformPkg/ArmPlatformPkg.dsc                  |  1 +
 .../ArmRealViewEbPkg/ArmRealViewEb.dsc.inc         |  1 +
 ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc  |  1 +
 .../ArmVirtualizationPkg/ArmVirtualization.dsc.inc |  1 +
 12 files changed, 76 insertions(+), 17 deletions(-)
 create mode 100644 ArmPkg/Drivers/ArmGic/ArmGicArchLib.inf
 create mode 100644 ArmPkg/Include/Library/ArmGicArchLib.h
diff mbox

Patch

diff --git a/ArmPkg/ArmPkg.dec b/ArmPkg/ArmPkg.dec
index c8d7f50d8072..37d7fd1e50dd 100644
--- a/ArmPkg/ArmPkg.dec
+++ b/ArmPkg/ArmPkg.dec
@@ -38,6 +38,7 @@ 
   UncachedMemoryAllocationLib|Include/Library/UncachedMemoryAllocationLib.h
   DefaultExceptionHandlerLib|Include/Library/DefaultExceptionHandlerLib.h
   ArmDisassemblerLib|Include/Library/ArmDisassemblerLib.h
+  ArmGicArchLib|Include/Library/ArmGicArchLib.h
 
 [Guids.common]
   gArmTokenSpaceGuid       = { 0xBB11ECFE, 0x820F, 0x4968, { 0xBB, 0xA6, 0xF7, 0x6A, 0xFE, 0x30, 0x25, 0x96 } }
diff --git a/ArmPkg/ArmPkg.dsc b/ArmPkg/ArmPkg.dsc
index be5126ccefd9..0e32f500c8b0 100644
--- a/ArmPkg/ArmPkg.dsc
+++ b/ArmPkg/ArmPkg.dsc
@@ -66,6 +66,7 @@ 
 
   CpuLib|MdePkg/Library/BaseCpuLib/BaseCpuLib.inf
   ArmGicLib|ArmPkg/Drivers/ArmGic/ArmGicLib.inf
+  ArmGicArchLib|ArmPkg/Drivers/ArmGic/ArmGicArchLib.inf
   ArmGenericTimerCounterLib|ArmPkg/Library/ArmGenericTimerPhyCounterLib/ArmGenericTimerPhyCounterLib.inf
   ArmSmcLib|ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf
   ArmDisassemblerLib|ArmPkg/Library/ArmDisassemblerLib/ArmDisassemblerLib.inf
diff --git a/ArmPkg/Drivers/ArmGic/ArmGicArchLib.inf b/ArmPkg/Drivers/ArmGic/ArmGicArchLib.inf
new file mode 100644
index 000000000000..d71b2adc3027
--- /dev/null
+++ b/ArmPkg/Drivers/ArmGic/ArmGicArchLib.inf
@@ -0,0 +1,33 @@ 
+#/* @file
+#  Copyright (c) 2015, Linaro Ltd. All rights reserved.
+#
+#  This program and the accompanying materials
+#  are licensed and made available under the terms and conditions of the BSD License
+#  which accompanies this distribution.  The full text of the license may be found at
+#  http://opensource.org/licenses/bsd-license.php
+#
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+#*/
+
+[Defines]
+  INF_VERSION                    = 0x00010005
+  BASE_NAME                      = ArmGicArchLib
+  FILE_GUID                      = cd67f41a-26e9-4482-90c9-a9aff803382a
+  MODULE_TYPE                    = BASE
+  VERSION_STRING                 = 1.0
+  LIBRARY_CLASS                  = ArmGicArchLib
+
+[Sources.ARM]
+  Arm/ArmGicArchLib.c
+
+[Sources.AARCH64]
+  AArch64/ArmGicArchLib.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  ArmPkg/ArmPkg.dec
+
+[LibraryClasses]
+  ArmGicLib
diff --git a/ArmPkg/Drivers/ArmGic/ArmGicLib.inf b/ArmPkg/Drivers/ArmGic/ArmGicLib.inf
index 9f466792e996..62f20eb55294 100644
--- a/ArmPkg/Drivers/ArmGic/ArmGicLib.inf
+++ b/ArmPkg/Drivers/ArmGic/ArmGicLib.inf
@@ -27,18 +27,17 @@ 
   GicV2/ArmGicV2NonSecLib.c
 
 [Sources.ARM]
-  Arm/ArmGicArchLib.c
   GicV3/Arm/ArmGicV3.S     | GCC
   GicV3/Arm/ArmGicV3.asm   | RVCT
 
 [Sources.AARCH64]
-  AArch64/ArmGicArchLib.c
   GicV3/AArch64/ArmGicV3.S
 
 [LibraryClasses]
   ArmLib
   DebugLib
   IoLib
+  ArmGicArchLib
 
 [Packages]
   ArmPkg/ArmPkg.dec
diff --git a/ArmPkg/Drivers/ArmGic/ArmGicSecLib.inf b/ArmPkg/Drivers/ArmGic/ArmGicSecLib.inf
index 9097b37f2b81..efea9c828170 100644
--- a/ArmPkg/Drivers/ArmGic/ArmGicSecLib.inf
+++ b/ArmPkg/Drivers/ArmGic/ArmGicSecLib.inf
@@ -27,12 +27,10 @@ 
   GicV2/ArmGicV2SecLib.c
 
 [Sources.ARM]
-  Arm/ArmGicArchLib.c
   GicV3/Arm/ArmGicV3.S     | GCC
   GicV3/Arm/ArmGicV3.asm   | RVCT
 
 [Sources.AARCH64]
-  AArch64/ArmGicArchLib.c
   GicV3/AArch64/ArmGicV3.S
 
 [Packages]
@@ -45,6 +43,7 @@ 
   ArmLib
   DebugLib
   IoLib
+  ArmGicArchLib
 
 [Pcd]
   gArmPlatformTokenSpaceGuid.PcdCoreCount
diff --git a/ArmPkg/Include/Library/ArmGicArchLib.h b/ArmPkg/Include/Library/ArmGicArchLib.h
new file mode 100644
index 000000000000..e6964a2d5790
--- /dev/null
+++ b/ArmPkg/Include/Library/ArmGicArchLib.h
@@ -0,0 +1,33 @@ 
+/** @file
+*
+*  Copyright (c) 2015, Linaro Ltd. All rights reserved.
+*
+*  This program and the accompanying materials are licensed and made available
+*  under the terms and conditions of the BSD License which accompanies this
+*  distribution.  The full text of the license may be found at
+*  http://opensource.org/licenses/bsd-license.php
+*
+*  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+*
+**/
+
+#ifndef __ARM_GIC_ARCH_LIB_H__
+#define __ARM_GIC_ARCH_LIB_H__
+
+//
+// GIC definitions
+//
+typedef enum {
+  ARM_GIC_ARCH_REVISION_2,
+  ARM_GIC_ARCH_REVISION_3
+} ARM_GIC_ARCH_REVISION;
+
+
+ARM_GIC_ARCH_REVISION
+EFIAPI
+ArmGicGetSupportedArchRevision (
+  VOID
+  );
+
+#endif
diff --git a/ArmPkg/Include/Library/ArmGicLib.h b/ArmPkg/Include/Library/ArmGicLib.h
index e2a4818c4c0c..a13f7d6c8b4a 100644
--- a/ArmPkg/Include/Library/ArmGicLib.h
+++ b/ArmPkg/Include/Library/ArmGicLib.h
@@ -15,13 +15,7 @@ 
 #ifndef __ARMGIC_H
 #define __ARMGIC_H
 
-//
-// GIC definitions
-//
-typedef enum {
-  ARM_GIC_ARCH_REVISION_2,
-  ARM_GIC_ARCH_REVISION_3
-} ARM_GIC_ARCH_REVISION;
+#include <Library/ArmGicArchLib.h>
 
 //
 // GIC Distributor
@@ -103,12 +97,6 @@  typedef enum {
 // Bit Mask for
 #define ARM_GIC_ICCIAR_ACKINTID                 0x3FF
 
-ARM_GIC_ARCH_REVISION
-EFIAPI
-ArmGicGetSupportedArchRevision (
-  VOID
-  );
-
 UINTN
 EFIAPI
 ArmGicGetInterfaceIdentification (
diff --git a/ArmPlatformPkg/ArmPlatformPkg-2ndstage.dsc b/ArmPlatformPkg/ArmPlatformPkg-2ndstage.dsc
index 66a9797a1c03..8bcd8cc819af 100644
--- a/ArmPlatformPkg/ArmPlatformPkg-2ndstage.dsc
+++ b/ArmPlatformPkg/ArmPlatformPkg-2ndstage.dsc
@@ -78,6 +78,7 @@ 
   ArmDisassemblerLib|ArmPkg/Library/ArmDisassemblerLib/ArmDisassemblerLib.inf
   DmaLib|ArmPkg/Library/ArmDmaLib/ArmDmaLib.inf
   ArmGicLib|ArmPkg/Drivers/ArmGic/ArmGicLib.inf
+  ArmGicArchLib|ArmPkg/Drivers/ArmGic/ArmGicArchLib.inf
   ArmPlatformStackLib|ArmPlatformPkg/Library/ArmPlatformStackLib/ArmPlatformStackLib.inf
   ArmSmcLib|ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf
 
diff --git a/ArmPlatformPkg/ArmPlatformPkg.dsc b/ArmPlatformPkg/ArmPlatformPkg.dsc
index 81402da5b303..d332fed7b0bd 100644
--- a/ArmPlatformPkg/ArmPlatformPkg.dsc
+++ b/ArmPlatformPkg/ArmPlatformPkg.dsc
@@ -78,6 +78,7 @@ 
   ArmDisassemblerLib|ArmPkg/Library/ArmDisassemblerLib/ArmDisassemblerLib.inf
   DmaLib|ArmPkg/Library/ArmDmaLib/ArmDmaLib.inf
   ArmGicLib|ArmPkg/Drivers/ArmGic/ArmGicLib.inf
+  ArmGicArchLib|ArmPkg/Drivers/ArmGic/ArmGicArchLib.inf
   ArmSmcLib|ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf
 
   SerialPortLib|MdePkg/Library/BaseSerialPortLibNull/BaseSerialPortLibNull.inf
diff --git a/ArmPlatformPkg/ArmRealViewEbPkg/ArmRealViewEb.dsc.inc b/ArmPlatformPkg/ArmRealViewEbPkg/ArmRealViewEb.dsc.inc
index 2a6a5b755af6..dd551739a6ce 100644
--- a/ArmPlatformPkg/ArmRealViewEbPkg/ArmRealViewEb.dsc.inc
+++ b/ArmPlatformPkg/ArmRealViewEbPkg/ArmRealViewEb.dsc.inc
@@ -61,6 +61,7 @@ 
   ArmDisassemblerLib|ArmPkg/Library/ArmDisassemblerLib/ArmDisassemblerLib.inf
   DmaLib|ArmPkg/Library/ArmDmaLib/ArmDmaLib.inf
   ArmGicLib|ArmPkg/Drivers/ArmGic/ArmGicLib.inf
+  ArmGicArchLib|ArmPkg/Drivers/ArmGic/ArmGicArchLib.inf
   ArmSmcLib|ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf
   ArmGenericTimerCounterLib|ArmPkg/Library/ArmGenericTimerPhyCounterLib/ArmGenericTimerPhyCounterLib.inf
 
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc
index ddc796dc0410..9a0bbcd2056d 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc
@@ -67,6 +67,7 @@ 
   ArmDisassemblerLib|ArmPkg/Library/ArmDisassemblerLib/ArmDisassemblerLib.inf
   DmaLib|ArmPkg/Library/ArmDmaLib/ArmDmaLib.inf
   ArmGicLib|ArmPkg/Drivers/ArmGic/ArmGicLib.inf
+  ArmGicArchLib|ArmPkg/Drivers/ArmGic/ArmGicArchLib.inf
   ArmPlatformStackLib|ArmPlatformPkg/Library/ArmPlatformStackLib/ArmPlatformStackLib.inf
   ArmSmcLib|ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf
   ArmGenericTimerCounterLib|ArmPkg/Library/ArmGenericTimerPhyCounterLib/ArmGenericTimerPhyCounterLib.inf
diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualization.dsc.inc b/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualization.dsc.inc
index e7a03cd13d3a..c72591ff48b7 100644
--- a/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualization.dsc.inc
+++ b/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualization.dsc.inc
@@ -68,6 +68,7 @@ 
   ArmDisassemblerLib|ArmPkg/Library/ArmDisassemblerLib/ArmDisassemblerLib.inf
   DmaLib|ArmPkg/Library/ArmDmaLib/ArmDmaLib.inf
   ArmGicLib|ArmPkg/Drivers/ArmGic/ArmGicLib.inf
+  ArmGicArchLib|ArmPkg/Drivers/ArmGic/ArmGicArchLib.inf
   ArmPlatformStackLib|ArmPlatformPkg/Library/ArmPlatformStackLib/ArmPlatformStackLib.inf
   ArmSmcLib|ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf
   ArmHvcLib|ArmPkg/Library/ArmHvcLib/ArmHvcLib.inf