diff options
author | Kun Qin <kuqin@microsoft.com> | 2024-10-10 15:40:12 -0700 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2024-12-11 18:21:29 +0000 |
commit | 9d0f3dd35d86fba542d38467ff679fd961e0f6f0 (patch) | |
tree | 77140ab9ca286c10b33ead406f61c941f505babb | |
parent | 77d32b179661739ce9a7e59141338c460da54e47 (diff) | |
download | edk2-9d0f3dd35d86fba542d38467ff679fd961e0f6f0.tar.gz |
ArmPkg: ArmArchTimerLib: Update operations to be 64 bit wide
The existing operation in ArmArchTimerLib is operating on UINT32 or
UINT64 based on the target system. This casting game originates from the
fact that timer frequency is UINTN type.
This change will simply promote all operations to UINT64 based, which
will remove the casting and conditional #if in the code for better
portability and readability.
Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Signed-off-by: Kun Qin <kun.qin@microsoft.com>
-rw-r--r-- | ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.c | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.c b/ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.c index cc1be0125b..8fb183a35d 100644 --- a/ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.c +++ b/ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.c @@ -17,13 +17,6 @@ #define TICKS_PER_MICRO_SEC (ArmGenericTimerGetTimerFreq ()/1000000U)
-// Select appropriate multiply function for platform architecture.
-#ifdef MDE_CPU_ARM
-#define MULT_U64_X_N MultU64x32
-#else
-#define MULT_U64_X_N MultU64x64
-#endif
-
/**
A local utility function that returns the PCD value, if specified.
Otherwise it defaults to ArmGenericTimerGetTimerFreq.
@@ -69,7 +62,7 @@ MicroSecondDelay ( // = MicroSeconds x TICKS_PER_MICRO_SEC
// = MicroSeconds x Frequency.10^-6
TimerTicks64 = DivU64x32 (
- MULT_U64_X_N (
+ MultU64x64 (
MicroSeconds,
GetPlatformTimerFreq ()
),
@@ -205,8 +198,8 @@ GetTimeInNanoSecond ( )
{
UINT64 NanoSeconds;
- UINT32 Remainder;
- UINT32 TimerFreq;
+ UINT64 Remainder;
+ UINT64 TimerFreq;
TimerFreq = GetPlatformTimerFreq ();
//
@@ -214,8 +207,8 @@ GetTimeInNanoSecond ( // Time = --------- x 1,000,000,000
// Frequency
//
- NanoSeconds = MULT_U64_X_N (
- DivU64x32Remainder (
+ NanoSeconds = MultU64x64 (
+ DivU64x64Remainder (
Ticks,
TimerFreq,
&Remainder
@@ -227,12 +220,13 @@ GetTimeInNanoSecond ( // Frequency < 0x100000000, so Remainder < 0x100000000, then (Remainder * 1,000,000,000)
// will not overflow 64-bit.
//
- NanoSeconds += DivU64x32 (
- MULT_U64_X_N (
- (UINT64)Remainder,
+ NanoSeconds += DivU64x64Remainder (
+ MultU64x64 (
+ Remainder,
1000000000U
),
- TimerFreq
+ TimerFreq,
+ NULL
);
return NanoSeconds;
|