diff mbox

[edk2,v6,10/23] ArmPkg: move TimerDxe and ArmArchTimerLib to new ArmGenericTimerCounterLib

Message ID 1409743096-14919-11-git-send-email-ard.biesheuvel@linaro.org
State New
Headers show

Commit Message

Ard Biesheuvel Sept. 3, 2014, 11:18 a.m. UTC
Update TimerDxe and ArmArchTimerLib to use ArmGenericTimerCounterLib, and update
all platforms to select the physical counter instance they have been using
implicitly all along.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 ArmPkg/Drivers/TimerDxe/TimerDxe.c                 |   1 +
 ArmPkg/Drivers/TimerDxe/TimerDxe.inf               |   1 +
 ArmPkg/Include/Library/ArmArchTimer.h              |  66 ------------
 ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.c   |   2 +-
 ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.inf |   1 +
 ArmPkg/Library/ArmLib/AArch64/AArch64ArchTimer.c   | 119 ---------------------
 ArmPkg/Library/ArmLib/ArmV7/ArmV7ArchTimer.c       | 119 ---------------------
 .../ArmRealViewEbPkg/ArmRealViewEb.dsc.inc         |   1 +
 ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc  |   1 +
 9 files changed, 6 insertions(+), 305 deletions(-)
diff mbox

Patch

diff --git a/ArmPkg/Drivers/TimerDxe/TimerDxe.c b/ArmPkg/Drivers/TimerDxe/TimerDxe.c
index 6c4494ed4ce6..99a8665afa3f 100644
--- a/ArmPkg/Drivers/TimerDxe/TimerDxe.c
+++ b/ArmPkg/Drivers/TimerDxe/TimerDxe.c
@@ -24,6 +24,7 @@ 
 #include <Library/UefiLib.h>
 #include <Library/PcdLib.h>
 #include <Library/IoLib.h>
+#include <Library/ArmGenericTimerCounterLib.h>
 #include <Library/ArmArchTimer.h>
 
 #include <Protocol/Timer.h>
diff --git a/ArmPkg/Drivers/TimerDxe/TimerDxe.inf b/ArmPkg/Drivers/TimerDxe/TimerDxe.inf
index 161d286d9c57..9e9768fbb567 100644
--- a/ArmPkg/Drivers/TimerDxe/TimerDxe.inf
+++ b/ArmPkg/Drivers/TimerDxe/TimerDxe.inf
@@ -41,6 +41,7 @@ 
   DebugLib
   UefiDriverEntryPoint
   IoLib
+  ArmGenericTimerCounterLib
 
 [Guids]
 
diff --git a/ArmPkg/Include/Library/ArmArchTimer.h b/ArmPkg/Include/Library/ArmArchTimer.h
index c41b53ee4143..876c1f65c525 100644
--- a/ArmPkg/Include/Library/ArmArchTimer.h
+++ b/ArmPkg/Include/Library/ArmArchTimer.h
@@ -52,70 +52,4 @@  ArmArchTimerWriteReg (
   IN   VOID                  *SrcBuf
   );
 
-VOID
-EFIAPI
-ArmArchTimerEnableTimer (
-  VOID
-  );
-
-VOID
-EFIAPI
-ArmArchTimerDisableTimer (
-  VOID
-  );
-
-VOID
-EFIAPI
-ArmArchTimerSetTimerFreq (
-  IN   UINTN  FreqInHz
-  );
-
-UINTN
-EFIAPI
-ArmArchTimerGetTimerFreq (
-  VOID
-  );
-
-VOID
-EFIAPI
-ArmArchTimerSetTimerVal (
-  IN   UINTN   Val
-  );
-
-UINTN
-EFIAPI
-ArmArchTimerGetTimerVal (
-  VOID
-  );
-
-UINT64
-EFIAPI
-ArmArchTimerGetSystemCount (
-  VOID
-  );
-
-UINTN
-EFIAPI
-ArmArchTimerGetTimerCtrlReg (
-  VOID
-  );
-
-VOID
-EFIAPI
-ArmArchTimerSetTimerCtrlReg (
-  UINTN Val
-  );
-
-UINT64
-EFIAPI
-ArmArchTimerGetCompareVal (
-  VOID
-  );
-
-VOID
-EFIAPI
-ArmArchTimerSetCompareVal (
-  IN   UINT64   Val
-  );
-
 #endif // __ARM_ARCH_TIMER_H__
diff --git a/ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.c b/ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.c
index ec4c39dbc989..137491187f14 100644
--- a/ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.c
+++ b/ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.c
@@ -20,7 +20,7 @@ 
 #include <Library/TimerLib.h>
 #include <Library/DebugLib.h>
 #include <Library/PcdLib.h>
-#include <Library/ArmArchTimer.h>
+#include <Library/ArmGenericTimerCounterLib.h>
 
 #define TICKS_PER_MICRO_SEC     (PcdGet32 (PcdArmArchTimerFreqInHz)/1000000U)
 
diff --git a/ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.inf b/ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.inf
index ecdf0837f121..03a4b1efa657 100644
--- a/ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.inf
+++ b/ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.inf
@@ -32,6 +32,7 @@ 
   DebugLib
   ArmLib
   BaseLib
+  ArmGenericTimerCounterLib
 
 [Pcd]
   gArmTokenSpaceGuid.PcdArmArchTimerFreqInHz
diff --git a/ArmPkg/Library/ArmLib/AArch64/AArch64ArchTimer.c b/ArmPkg/Library/ArmLib/AArch64/AArch64ArchTimer.c
index 66a979f7046a..63ce1978c091 100644
--- a/ArmPkg/Library/ArmLib/AArch64/AArch64ArchTimer.c
+++ b/ArmPkg/Library/ArmLib/AArch64/AArch64ArchTimer.c
@@ -166,122 +166,3 @@  ArmArchTimerWriteReg (
     ASSERT (0);
   }
 }
-
-VOID
-EFIAPI
-ArmArchTimerEnableTimer (
-    VOID
-    )
-{
-  UINTN TimerCtrlReg;
-
-  ArmArchTimerReadReg (CntpCtl, (VOID *)&TimerCtrlReg);
-  TimerCtrlReg |= ARM_ARCH_TIMER_ENABLE;
-  ArmArchTimerWriteReg (CntpCtl, (VOID *)&TimerCtrlReg);
-}
-
-VOID
-EFIAPI
-ArmArchTimerDisableTimer (
-    VOID
-    )
-{
-  UINTN TimerCtrlReg;
-
-  ArmArchTimerReadReg (CntpCtl, (VOID *)&TimerCtrlReg);
-  TimerCtrlReg &= ~ARM_ARCH_TIMER_ENABLE;
-  ArmArchTimerWriteReg (CntpCtl, (VOID *)&TimerCtrlReg);
-}
-
-VOID
-EFIAPI
-ArmArchTimerSetTimerFreq (
-    IN   UINTN  FreqInHz
-    )
-{
-  ArmArchTimerWriteReg (CntFrq, (VOID *)&FreqInHz);
-}
-
-UINTN
-EFIAPI
-ArmArchTimerGetTimerFreq (
-    VOID
-    )
-{
-  UINTN ArchTimerFreq = 0;
-  ArmArchTimerReadReg (CntFrq, (VOID *)&ArchTimerFreq);
-  return ArchTimerFreq;
-}
-
-UINTN
-EFIAPI
-ArmArchTimerGetTimerVal (
-    VOID
-    )
-{
-  UINTN ArchTimerVal;
-  ArmArchTimerReadReg (CntpTval, (VOID *)&ArchTimerVal);
-  return ArchTimerVal;
-}
-
-
-VOID
-EFIAPI
-ArmArchTimerSetTimerVal (
-    IN   UINTN   Val
-    )
-{
-  ArmArchTimerWriteReg (CntpTval, (VOID *)&Val);
-}
-
-UINT64
-EFIAPI
-ArmArchTimerGetSystemCount (
-    VOID
-    )
-{
-  UINT64 SystemCount;
-  ArmArchTimerReadReg (CntPct, (VOID *)&SystemCount);
-  return SystemCount;
-}
-
-UINTN
-EFIAPI
-ArmArchTimerGetTimerCtrlReg (
-    VOID
-    )
-{
-  UINTN  Val;
-  ArmArchTimerReadReg (CntpCtl, (VOID *)&Val);
-  return Val;
-}
-
-VOID
-EFIAPI
-ArmArchTimerSetTimerCtrlReg (
-    UINTN Val
-    )
-{
-  ArmArchTimerWriteReg (CntpCtl, (VOID *)&Val);
-}
-
-UINT64
-EFIAPI
-ArmArchTimerGetCompareVal (
-    VOID
-    )
-{
-  UINT64  Val;
-  ArmArchTimerReadReg (CntpCval, (VOID *)&Val);
-
-  return Val;
-}
-
-VOID
-EFIAPI
-ArmArchTimerSetCompareVal (
-    IN   UINT64   Val
-    )
-{
-  ArmArchTimerWriteReg (CntpCval, (VOID *)&Val);
-}
diff --git a/ArmPkg/Library/ArmLib/ArmV7/ArmV7ArchTimer.c b/ArmPkg/Library/ArmLib/ArmV7/ArmV7ArchTimer.c
index 836c27329eca..49be71bbe088 100644
--- a/ArmPkg/Library/ArmLib/ArmV7/ArmV7ArchTimer.c
+++ b/ArmPkg/Library/ArmLib/ArmV7/ArmV7ArchTimer.c
@@ -166,122 +166,3 @@  ArmArchTimerWriteReg (
     ASSERT (0);
   }
 }
-
-VOID
-EFIAPI
-ArmArchTimerEnableTimer (
-    VOID
-    )
-{
-  UINTN TimerCtrlReg;
-
-  ArmArchTimerReadReg (CntpCtl, (VOID *)&TimerCtrlReg);
-  TimerCtrlReg |= ARM_ARCH_TIMER_ENABLE;
-  ArmArchTimerWriteReg (CntpCtl, (VOID *)&TimerCtrlReg);
-}
-
-VOID
-EFIAPI
-ArmArchTimerDisableTimer (
-    VOID
-    )
-{
-  UINTN TimerCtrlReg;
-
-  ArmArchTimerReadReg (CntpCtl, (VOID *)&TimerCtrlReg);
-  TimerCtrlReg &= ~ARM_ARCH_TIMER_ENABLE;
-  ArmArchTimerWriteReg (CntpCtl, (VOID *)&TimerCtrlReg);
-}
-
-VOID
-EFIAPI
-ArmArchTimerSetTimerFreq (
-    IN   UINTN  FreqInHz
-    )
-{
-  ArmArchTimerWriteReg (CntFrq, (VOID *)&FreqInHz);
-}
-
-UINTN
-EFIAPI
-ArmArchTimerGetTimerFreq (
-    VOID
-    )
-{
-  UINTN ArchTimerFreq;
-  ArmArchTimerReadReg (CntFrq, (VOID *)&ArchTimerFreq);
-  return ArchTimerFreq;
-}
-
-UINTN
-EFIAPI
-ArmArchTimerGetTimerVal (
-    VOID
-    )
-{
-  UINTN ArchTimerVal;
-  ArmArchTimerReadReg (CntpTval, (VOID *)&ArchTimerVal);
-  return ArchTimerVal;
-}
-
-
-VOID
-EFIAPI
-ArmArchTimerSetTimerVal (
-    IN   UINTN   Val
-    )
-{
-  ArmArchTimerWriteReg (CntpTval, (VOID *)&Val);
-}
-
-UINT64
-EFIAPI
-ArmArchTimerGetSystemCount (
-    VOID
-    )
-{
-  UINT64 SystemCount;
-  ArmArchTimerReadReg (CntPct, (VOID *)&SystemCount);
-  return SystemCount;
-}
-
-UINTN
-EFIAPI
-ArmArchTimerGetTimerCtrlReg (
-    VOID
-    )
-{
-  UINTN  Val;
-  ArmArchTimerReadReg (CntpCtl, (VOID *)&Val);
-  return Val;
-}
-
-VOID
-EFIAPI
-ArmArchTimerSetTimerCtrlReg (
-    UINTN Val
-    )
-{
-  ArmArchTimerWriteReg (CntpCtl, (VOID *)&Val);
-}
-
-UINT64
-EFIAPI
-ArmArchTimerGetCompareVal (
-    VOID
-    )
-{
-  UINT64  Val;
-  ArmArchTimerReadReg (CntpCval, (VOID *)&Val);
-
-  return Val;
-}
-
-VOID
-EFIAPI
-ArmArchTimerSetCompareVal (
-    IN   UINT64   Val
-    )
-{
-  ArmArchTimerWriteReg (CntpCval, (VOID *)&Val);
-}
diff --git a/ArmPlatformPkg/ArmRealViewEbPkg/ArmRealViewEb.dsc.inc b/ArmPlatformPkg/ArmRealViewEbPkg/ArmRealViewEb.dsc.inc
index 28a18eda3a50..bb6eb70fd458 100644
--- a/ArmPlatformPkg/ArmRealViewEbPkg/ArmRealViewEb.dsc.inc
+++ b/ArmPlatformPkg/ArmRealViewEbPkg/ArmRealViewEb.dsc.inc
@@ -62,6 +62,7 @@ 
   DmaLib|ArmPkg/Library/ArmDmaLib/ArmDmaLib.inf
   ArmGicLib|ArmPkg/Drivers/ArmGic/ArmGicLib.inf
   ArmSmcLib|ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf
+  ArmGenericTimerCounterLib|ArmPkg/Library/ArmGenericTimerPhysCounterLib/ArmGenericTimerPhysCounterLib.inf
 
   # RealView Emulation Board Specific Libraries
   EfiResetSystemLib|ArmPlatformPkg/ArmRealViewEbPkg/Library/ResetSystemLib/ResetSystemLib.inf
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc
index 424c1311c55d..8e76e748fc5a 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc
@@ -69,6 +69,7 @@ 
   ArmGicLib|ArmPkg/Drivers/ArmGic/ArmGicLib.inf
   ArmPlatformStackLib|ArmPlatformPkg/Library/ArmPlatformStackLib/ArmPlatformStackLib.inf
   ArmSmcLib|ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf
+  ArmGenericTimerCounterLib|ArmPkg/Library/ArmGenericTimerPhysCounterLib/ArmGenericTimerPhysCounterLib.inf
 
   # Versatile Express Specific Libraries
   ArmPlatformSysConfigLib|ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressSysConfigLib/ArmVExpressSysConfigLib.inf