ArmPkg: Move TimerDxe and ArmArchTimerLib to new ArmGenericTimerCounterLib

Move TimerDxe and ArmArchTimerLib to 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
Acked-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-By: Olivier Martin <olivier.martin@arm.com>



git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16078 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Ard Biesheuvel 2014-09-09 16:10:18 +00:00 committed by oliviermartin
parent 2785509b57
commit 4f6d34b434
17 changed files with 37 additions and 307 deletions

View File

@ -64,6 +64,7 @@
CpuLib|MdePkg/Library/BaseCpuLib/BaseCpuLib.inf
ArmGicLib|ArmPkg/Drivers/ArmGic/ArmGicLib.inf
ArmGenericTimerCounterLib|ArmPkg/Library/ArmGenericTimerPhyCounterLib/ArmGenericTimerPhyCounterLib.inf
ArmSmcLib|ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf
ArmDisassemblerLib|ArmPkg/Library/ArmDisassemblerLib/ArmDisassemblerLib.inf
DmaLib|ArmPkg/Library/ArmDmaLib/ArmDmaLib.inf

View File

@ -15,9 +15,8 @@
#include <Base.h>
#include <Library/ArmLib.h>
#include <Library/ArmCpuLib.h>
#include <Library/ArmArchTimer.h>
#include <Library/ArmGenericTimerCounterLib.h>
#include <Library/DebugLib.h>
#include <Library/IoLib.h>
#include <Library/PcdLib.h>
#include <Chipset/ArmCortexA15.h>
@ -39,7 +38,7 @@ ArmCpuSetup (
// Note: System Counter frequency can only be set in Secure privileged mode,
// if security extensions are implemented.
ArmArchTimerSetTimerFreq (PcdGet32 (PcdArmArchTimerFreqInHz));
ArmGenericTimerSetTimerFreq (PcdGet32 (PcdArmArchTimerFreqInHz));
if (ArmIsMpCore()) {
// Turn on SMP coherency

View File

@ -1,5 +1,5 @@
#/* @file
# Copyright (c) 2011-2012, ARM Limited. All rights reserved.
# Copyright (c) 2011-2014, ARM Limited. All rights reserved.
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@ -25,7 +25,7 @@
[LibraryClasses]
ArmLib
IoLib
ArmGenericTimerCounterLib
PcdLib
[Sources.common]

View File

@ -15,9 +15,8 @@
#include <Base.h>
#include <Library/ArmLib.h>
#include <Library/ArmCpuLib.h>
#include <Library/ArmArchTimer.h>
#include <Library/ArmGenericTimerCounterLib.h>
#include <Library/DebugLib.h>
#include <Library/IoLib.h>
#include <Library/PcdLib.h>
#include <Chipset/ArmCortexA5x.h>
@ -33,7 +32,7 @@ ArmCpuSetup (
// Note: System Counter frequency can only be set in Secure privileged mode,
// if security extensions are implemented.
ArmArchTimerSetTimerFreq (PcdGet32 (PcdArmArchTimerFreqInHz));
ArmGenericTimerSetTimerFreq (PcdGet32 (PcdArmArchTimerFreqInHz));
if (ArmIsMpCore ()) {
// Turn on SMP coherency

View File

@ -25,7 +25,7 @@
[LibraryClasses]
ArmLib
IoLib
ArmGenericTimerCounterLib
PcdLib
[Sources.common]

View File

@ -14,7 +14,7 @@
#include <Base.h>
#include <Library/ArmCpuLib.h>
#include <Library/ArmArchTimer.h>
#include <Library/ArmGenericTimerCounterLib.h>
#include <Library/PcdLib.h>
#include <Chipset/ArmAemV8.h>
@ -26,7 +26,7 @@ ArmCpuSetup (
{
// Note: System Counter frequency can only be set in Secure privileged mode,
// if security extensions are implemented.
ArmArchTimerSetTimerFreq (PcdGet32 (PcdArmArchTimerFreqInHz));
ArmGenericTimerSetTimerFreq (PcdGet32 (PcdArmArchTimerFreqInHz));
}

View File

@ -24,8 +24,7 @@
ArmPkg/ArmPkg.dec
[LibraryClasses]
ArmLib
IoLib
ArmGenericTimerCounterLib
PcdLib
[Sources.common]

View File

@ -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>
@ -101,7 +102,7 @@ ExitBootServicesEvent (
IN VOID *Context
)
{
ArmArchTimerDisableTimer ();
ArmGenericTimerDisableTimer ();
}
/**
@ -144,7 +145,7 @@ TimerDriverSetTimerPeriod (
EFI_TPL OriginalTPL;
// Always disable the timer
ArmArchTimerDisableTimer ();
ArmGenericTimerDisableTimer ();
if (TimerPeriod != 0) {
// mTimerTicks = TimerPeriod in 1ms unit x Frequency.10^-3
@ -163,13 +164,13 @@ TimerDriverSetTimerPeriod (
gBS->RestoreTPL (OriginalTPL);
// Get value of the current physical timer
CounterValue = ArmReadCntPct ();
// Get value of the current timer
CounterValue = ArmGenericTimerGetSystemCount ();
// Set the interrupt in Current Time + mTimerTick
ArmWriteCntpCval (CounterValue + mTimerTicks);
ArmGenericTimerSetCompareVal (CounterValue + mTimerTicks);
// Enable the timer
ArmArchTimerEnableTimer ();
ArmGenericTimerEnableTimer ();
} else {
// Save the new timer period
mTimerPeriod = TimerPeriod;
@ -307,7 +308,7 @@ TimerInterruptHandler (
OriginalTPL = gBS->RaiseTPL (TPL_HIGH_LEVEL);
// Check if the timer interrupt is active
if ((ArmArchTimerGetTimerCtrlReg () ) & ARM_ARCH_TIMER_ISTATUS) {
if ((ArmGenericTimerGetTimerCtrlReg () ) & ARM_ARCH_TIMER_ISTATUS) {
// Signal end of interrupt early to help avoid losing subsequent ticks from long duration handlers
gInterrupt->EndOfInterrupt (gInterrupt, Source);
@ -321,9 +322,9 @@ TimerInterruptHandler (
//
// Get current counter value
CurrentValue = ArmReadCntPct ();
CurrentValue = ArmGenericTimerGetSystemCount ();
// Get the counter value to compare with
CompareValue = ArmReadCntpCval ();
CompareValue = ArmGenericTimerGetCompareVal ();
// This loop is needed in case we missed interrupts (eg: case when the interrupt handling
// has taken longer than mTickPeriod).
@ -335,7 +336,7 @@ TimerInterruptHandler (
} while (CompareValue < CurrentValue);
// Set next compare value
ArmWriteCntpCval (CompareValue);
ArmGenericTimerSetCompareVal (CompareValue);
}
// Enable timer interrupts
@ -379,10 +380,10 @@ TimerInitialize (
ASSERT_EFI_ERROR (Status);
// Disable the timer
TimerCtrlReg = ArmArchTimerGetTimerCtrlReg ();
TimerCtrlReg = ArmGenericTimerGetTimerCtrlReg ();
TimerCtrlReg |= ARM_ARCH_TIMER_IMASK;
TimerCtrlReg &= ~ARM_ARCH_TIMER_ENABLE;
ArmArchTimerSetTimerCtrlReg (TimerCtrlReg);
ArmGenericTimerSetTimerCtrlReg (TimerCtrlReg);
Status = TimerDriverSetTimerPeriod (&gTimer, 0);
ASSERT_EFI_ERROR (Status);
@ -416,7 +417,7 @@ TimerInitialize (
// Everything is ready, unmask and enable timer interrupts
TimerCtrlReg = ARM_ARCH_TIMER_ENABLE;
ArmArchTimerSetTimerCtrlReg (TimerCtrlReg);
ArmGenericTimerSetTimerCtrlReg (TimerCtrlReg);
// Register for an ExitBootServicesEvent
Status = gBS->CreateEvent (EVT_SIGNAL_EXIT_BOOT_SERVICES, TPL_NOTIFY, ExitBootServicesEvent, NULL, &EfiExitBootServicesEvent);

View File

@ -41,6 +41,7 @@
DebugLib
UefiDriverEntryPoint
IoLib
ArmGenericTimerCounterLib
[Guids]

View File

@ -52,64 +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
);
VOID
EFIAPI
ArmArchTimerSetCompareVal (
IN UINT64 Val
);
#endif // __ARM_ARCH_TIMER_H__

View File

@ -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)
@ -47,13 +47,13 @@ TimerConstructor (
// Only set the frequency for ARMv7. We expect the secure firmware to have already do it
// If the security extensions are not implemented set Timer Frequency
if ((ArmReadIdPfr1 () & ARM_PFR1_SEC) == 0x0) {
ArmArchTimerSetTimerFreq (PcdGet32 (PcdArmArchTimerFreqInHz));
ArmGenericTimerSetTimerFreq (PcdGet32 (PcdArmArchTimerFreqInHz));
}
#endif
// Architectural Timer Frequency must be set in the Secure privileged(if secure extensions are supported) mode.
// If the reset value (0) is returned just ASSERT.
TimerFreq = ArmArchTimerGetTimerFreq ();
TimerFreq = ArmGenericTimerGetTimerFreq ();
ASSERT (TimerFreq != 0);
} else {
@ -88,13 +88,13 @@ MicroSecondDelay (
TimerTicks64 = (MicroSeconds * PcdGet32 (PcdArmArchTimerFreqInHz)) / 1000000U;
// Read System Counter value
SystemCounterVal = ArmArchTimerGetSystemCount ();
SystemCounterVal = ArmGenericTimerGetSystemCount ();
TimerTicks64 += SystemCounterVal;
// Wait until delay count is expired.
while (SystemCounterVal < TimerTicks64) {
SystemCounterVal = ArmArchTimerGetSystemCount ();
SystemCounterVal = ArmGenericTimerGetSystemCount ();
}
return MicroSeconds;
@ -149,7 +149,7 @@ GetPerformanceCounter (
)
{
// Just return the value of system count
return ArmArchTimerGetSystemCount ();
return ArmGenericTimerGetSystemCount ();
}
/**
@ -192,5 +192,5 @@ GetPerformanceCounterProperties (
*EndValue = 0xFFFFFFFFFFFFFFFFUL;
}
return (UINT64)ArmArchTimerGetTimerFreq ();
return (UINT64)ArmGenericTimerGetTimerFreq ();
}

View File

@ -32,6 +32,7 @@
DebugLib
ArmLib
BaseLib
ArmGenericTimerCounterLib
[Pcd]
gArmTokenSpaceGuid.PcdArmArchTimerFreqInHz

View File

@ -166,110 +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);
}
VOID
EFIAPI
ArmArchTimerSetCompareVal (
IN UINT64 Val
)
{
ArmArchTimerWriteReg (CntpCval, (VOID *)&Val);
}

View File

@ -166,110 +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);
}
VOID
EFIAPI
ArmArchTimerSetCompareVal (
IN UINT64 Val
)
{
ArmArchTimerWriteReg (CntpCval, (VOID *)&Val);
}

View File

@ -120,6 +120,7 @@
[LibraryClasses.AARCH64]
ArmLib|ArmPkg/Library/ArmLib/AArch64/AArch64Lib.inf
ArmCpuLib|ArmPkg/Drivers/ArmCpuLib/ArmCortexAEMv8Lib/ArmCortexAEMv8Lib.inf
ArmGenericTimerCounterLib|ArmPkg/Library/ArmGenericTimerPhyCounterLib/ArmGenericTimerPhyCounterLib.inf
[LibraryClasses.common.SEC]
ArmPlatformSecLib|ArmPlatformPkg/Library/ArmPlatformSecLibNull/ArmPlatformLibNullSec.inf

View File

@ -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/ArmGenericTimerPhyCounterLib/ArmGenericTimerPhyCounterLib.inf
# RealView Emulation Board Specific Libraries
EfiResetSystemLib|ArmPlatformPkg/ArmRealViewEbPkg/Library/ResetSystemLib/ResetSystemLib.inf

View File

@ -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/ArmGenericTimerPhyCounterLib/ArmGenericTimerPhyCounterLib.inf
# Versatile Express Specific Libraries
ArmPlatformSysConfigLib|ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressSysConfigLib/ArmVExpressSysConfigLib.inf