mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-31 01:24:12 +02:00
ArmPkg/ArmArchTimerLib: add GetTimeInNanoSecond() to ArmArchTimerLib
FirmwarePerformanceDxe.c utilizes the Timer Library function GetTimeInNanoSecond() which was not implemented by the ArmArchTimerLib. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Evan Lloyd <evan.lloyd@arm.com> Reviewed-by: Ryan Harkin <ryan.harkin@linaro.org> Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
This commit is contained in:
parent
cbdece1769
commit
96a80ae3ce
@ -1,7 +1,7 @@
|
|||||||
/** @file
|
/** @file
|
||||||
Generic ARM implementation of TimerLib.h
|
Generic ARM implementation of TimerLib.h
|
||||||
|
|
||||||
Copyright (c) 2011-2014, ARM Limited. All rights reserved.
|
Copyright (c) 2011-2016, ARM Limited. All rights reserved.
|
||||||
|
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
@ -242,3 +242,52 @@ GetPerformanceCounterProperties (
|
|||||||
|
|
||||||
return (UINT64)ArmGenericTimerGetTimerFreq ();
|
return (UINT64)ArmGenericTimerGetTimerFreq ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Converts elapsed ticks of performance counter to time in nanoseconds.
|
||||||
|
|
||||||
|
This function converts the elapsed ticks of running performance counter to
|
||||||
|
time value in unit of nanoseconds.
|
||||||
|
|
||||||
|
@param Ticks The number of elapsed ticks of running performance counter.
|
||||||
|
|
||||||
|
@return The elapsed time in nanoseconds.
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINT64
|
||||||
|
EFIAPI
|
||||||
|
GetTimeInNanoSecond (
|
||||||
|
IN UINT64 Ticks
|
||||||
|
)
|
||||||
|
{
|
||||||
|
UINT64 NanoSeconds;
|
||||||
|
UINT32 Remainder;
|
||||||
|
UINT32 TimerFreq;
|
||||||
|
|
||||||
|
TimerFreq = GetPlatformTimerFreq ();
|
||||||
|
//
|
||||||
|
// Ticks
|
||||||
|
// Time = --------- x 1,000,000,000
|
||||||
|
// Frequency
|
||||||
|
//
|
||||||
|
NanoSeconds = MultU64xN (
|
||||||
|
DivU64x32Remainder (
|
||||||
|
Ticks,
|
||||||
|
TimerFreq,
|
||||||
|
&Remainder),
|
||||||
|
1000000000U
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Frequency < 0x100000000, so Remainder < 0x100000000, then (Remainder * 1,000,000,000)
|
||||||
|
// will not overflow 64-bit.
|
||||||
|
//
|
||||||
|
NanoSeconds += DivU64x32 (
|
||||||
|
MultU64xN (
|
||||||
|
(UINT64) Remainder,
|
||||||
|
1000000000U),
|
||||||
|
TimerFreq
|
||||||
|
);
|
||||||
|
|
||||||
|
return NanoSeconds;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user