diff options
author | Sami Mujawar <sami.mujawar@arm.com> | 2016-03-03 15:28:16 +0000 |
---|---|---|
committer | Ard Biesheuvel <ard.biesheuvel@linaro.org> | 2016-04-01 15:52:16 +0200 |
commit | cbdece176953cf2be63b322f53600e2136b94744 (patch) | |
tree | d8acd25071e9a8d4a48734f0a27f2f7785616675 /ArmPkg/Library/ArmArchTimerLib | |
parent | 37b680116dcd4a3517cb87794c33fc84beea8dd2 (diff) | |
download | edk2-cbdece176953cf2be63b322f53600e2136b94744.zip edk2-cbdece176953cf2be63b322f53600e2136b94744.tar.gz edk2-cbdece176953cf2be63b322f53600e2136b94744.tar.bz2 |
ArmPkg/ArchArmTimerLib: refactor MultU64xN and TimerFreq definitions
This refactors some timer code to define MultU64xN as a preprocessor
symbol rather than a function pointer, and to factor out the code that
obtains the timer frequency into GetPlatformTimerFreq ().
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Evan Lloyd <evan.lloyd@arm.com>
Reviewed-by: Ryan Harkin <ryan.harkin@linaro.org>
Contributed-under: TianoCore Contribution Agreement 1.0
[ard.biesheuvel: split off from 'add GetTimeInNanoSecond() to ArmArchTimerLib']
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Diffstat (limited to 'ArmPkg/Library/ArmArchTimerLib')
-rw-r--r-- | ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.c | 49 |
1 files changed, 31 insertions, 18 deletions
diff --git a/ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.c b/ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.c index a0e4f58..4361905 100644 --- a/ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.c +++ b/ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.c @@ -24,6 +24,14 @@ #define TICKS_PER_MICRO_SEC (PcdGet32 (PcdArmArchTimerFreqInHz)/1000000U)
+// Select appropriate multiply function for platform architecture.
+#ifdef MDE_CPU_ARM
+#define MultU64xN MultU64x32
+#else
+#define MultU64xN MultU64x64
+#endif
+
+
RETURN_STATUS
EFIAPI
TimerConstructor (
@@ -76,6 +84,28 @@ TimerConstructor ( return RETURN_SUCCESS;
}
+/**
+ A local utility function that returns the PCD value, if specified.
+ Otherwise it defaults to ArmGenericTimerGetTimerFreq.
+
+ @return The timer frequency.
+
+**/
+STATIC
+UINTN
+EFIAPI
+GetPlatformTimerFreq (
+ )
+{
+ UINTN TimerFreq;
+
+ TimerFreq = PcdGet32 (PcdArmArchTimerFreqInHz);
+ if (TimerFreq == 0) {
+ TimerFreq = ArmGenericTimerGetTimerFreq ();
+ }
+ return TimerFreq;
+}
+
/**
Stalls the CPU for the number of microseconds specified by MicroSeconds.
@@ -93,23 +123,6 @@ MicroSecondDelay ( {
UINT64 TimerTicks64;
UINT64 SystemCounterVal;
- UINT64 (EFIAPI
- *MultU64xN) (
- IN UINT64 Multiplicand,
- IN UINTN Multiplier
- );
- UINTN TimerFreq;
-
-#ifdef MDE_CPU_ARM
- MultU64xN = MultU64x32;
-#else
- MultU64xN = MultU64x64;
-#endif
-
- TimerFreq = PcdGet32 (PcdArmArchTimerFreqInHz);
- if (TimerFreq == 0) {
- TimerFreq = ArmGenericTimerGetTimerFreq ();
- }
// Calculate counter ticks that can represent requested delay:
// = MicroSeconds x TICKS_PER_MICRO_SEC
@@ -117,7 +130,7 @@ MicroSecondDelay ( TimerTicks64 = DivU64x32 (
MultU64xN (
MicroSeconds,
- TimerFreq
+ GetPlatformTimerFreq ()
),
1000000U
);
|