From 4f6d34b434c0f063c68bdd4445da9097358b9afc Mon Sep 17 00:00:00 2001 From: Ard Biesheuvel Date: Tue, 9 Sep 2014 16:10:18 +0000 Subject: 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 Signed-off-by: Ard Biesheuvel Signed-off-By: Olivier Martin git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16078 6f19259b-4bc3-4df7-8a09-765794883524 --- .../ArmCpuLib/ArmCortexA15Lib/ArmCortexA15Lib.c | 5 ++-- .../ArmCpuLib/ArmCortexA15Lib/ArmCortexA15Lib.inf | 4 ++-- .../ArmCpuLib/ArmCortexA5xLib/ArmCortexA5xLib.c | 5 ++-- .../ArmCpuLib/ArmCortexA5xLib/ArmCortexA5xLib.inf | 2 +- .../ArmCortexAEMv8Lib/ArmCortexAEMv8Lib.c | 4 ++-- .../ArmCortexAEMv8Lib/ArmCortexAEMv8Lib.inf | 3 +-- ArmPkg/Drivers/TimerDxe/TimerDxe.c | 27 +++++++++++----------- ArmPkg/Drivers/TimerDxe/TimerDxe.inf | 1 + 8 files changed, 25 insertions(+), 26 deletions(-) (limited to 'ArmPkg/Drivers') diff --git a/ArmPkg/Drivers/ArmCpuLib/ArmCortexA15Lib/ArmCortexA15Lib.c b/ArmPkg/Drivers/ArmCpuLib/ArmCortexA15Lib/ArmCortexA15Lib.c index 585695a7dd..a1678febc4 100644 --- a/ArmPkg/Drivers/ArmCpuLib/ArmCortexA15Lib/ArmCortexA15Lib.c +++ b/ArmPkg/Drivers/ArmCpuLib/ArmCortexA15Lib/ArmCortexA15Lib.c @@ -15,9 +15,8 @@ #include #include #include -#include +#include #include -#include #include #include @@ -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 diff --git a/ArmPkg/Drivers/ArmCpuLib/ArmCortexA15Lib/ArmCortexA15Lib.inf b/ArmPkg/Drivers/ArmCpuLib/ArmCortexA15Lib/ArmCortexA15Lib.inf index ed4bdc377d..bd9a733b46 100644 --- a/ArmPkg/Drivers/ArmCpuLib/ArmCortexA15Lib/ArmCortexA15Lib.inf +++ b/ArmPkg/Drivers/ArmCpuLib/ArmCortexA15Lib/ArmCortexA15Lib.inf @@ -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] diff --git a/ArmPkg/Drivers/ArmCpuLib/ArmCortexA5xLib/ArmCortexA5xLib.c b/ArmPkg/Drivers/ArmCpuLib/ArmCortexA5xLib/ArmCortexA5xLib.c index 97f1ced413..135bd6b86d 100644 --- a/ArmPkg/Drivers/ArmCpuLib/ArmCortexA5xLib/ArmCortexA5xLib.c +++ b/ArmPkg/Drivers/ArmCpuLib/ArmCortexA5xLib/ArmCortexA5xLib.c @@ -15,9 +15,8 @@ #include #include #include -#include +#include #include -#include #include #include @@ -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 diff --git a/ArmPkg/Drivers/ArmCpuLib/ArmCortexA5xLib/ArmCortexA5xLib.inf b/ArmPkg/Drivers/ArmCpuLib/ArmCortexA5xLib/ArmCortexA5xLib.inf index acfa98d41d..e270220326 100644 --- a/ArmPkg/Drivers/ArmCpuLib/ArmCortexA5xLib/ArmCortexA5xLib.inf +++ b/ArmPkg/Drivers/ArmCpuLib/ArmCortexA5xLib/ArmCortexA5xLib.inf @@ -25,7 +25,7 @@ [LibraryClasses] ArmLib - IoLib + ArmGenericTimerCounterLib PcdLib [Sources.common] diff --git a/ArmPkg/Drivers/ArmCpuLib/ArmCortexAEMv8Lib/ArmCortexAEMv8Lib.c b/ArmPkg/Drivers/ArmCpuLib/ArmCortexAEMv8Lib/ArmCortexAEMv8Lib.c index 3e7fa124ce..9b1815f8f2 100644 --- a/ArmPkg/Drivers/ArmCpuLib/ArmCortexAEMv8Lib/ArmCortexAEMv8Lib.c +++ b/ArmPkg/Drivers/ArmCpuLib/ArmCortexAEMv8Lib/ArmCortexAEMv8Lib.c @@ -14,7 +14,7 @@ #include #include -#include +#include #include #include @@ -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)); } diff --git a/ArmPkg/Drivers/ArmCpuLib/ArmCortexAEMv8Lib/ArmCortexAEMv8Lib.inf b/ArmPkg/Drivers/ArmCpuLib/ArmCortexAEMv8Lib/ArmCortexAEMv8Lib.inf index 0109cc53a3..1c8122082d 100644 --- a/ArmPkg/Drivers/ArmCpuLib/ArmCortexAEMv8Lib/ArmCortexAEMv8Lib.inf +++ b/ArmPkg/Drivers/ArmCpuLib/ArmCortexAEMv8Lib/ArmCortexAEMv8Lib.inf @@ -24,8 +24,7 @@ ArmPkg/ArmPkg.dec [LibraryClasses] - ArmLib - IoLib + ArmGenericTimerCounterLib PcdLib [Sources.common] diff --git a/ArmPkg/Drivers/TimerDxe/TimerDxe.c b/ArmPkg/Drivers/TimerDxe/TimerDxe.c index 239a353269..3e5d8e72be 100644 --- a/ArmPkg/Drivers/TimerDxe/TimerDxe.c +++ b/ArmPkg/Drivers/TimerDxe/TimerDxe.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -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); diff --git a/ArmPkg/Drivers/TimerDxe/TimerDxe.inf b/ArmPkg/Drivers/TimerDxe/TimerDxe.inf index 161d286d9c..9e9768fbb5 100644 --- a/ArmPkg/Drivers/TimerDxe/TimerDxe.inf +++ b/ArmPkg/Drivers/TimerDxe/TimerDxe.inf @@ -41,6 +41,7 @@ DebugLib UefiDriverEntryPoint IoLib + ArmGenericTimerCounterLib [Guids] -- cgit v1.2.3