Revision: 16329
http://sourceforge.net/p/edk2/code/16329
Author: oliviermartin
Date: 2014-11-11 00:52:46 +0000 (Tue, 11 Nov 2014)
Log Message:
-----------
ArmPkg/ArmArchTimerLib: Promotes 32bit value to prevent overflow
Both MicroSeconds and PcdArmArchTimerFreqInHz are 32-bit values on
AArch32 so their multiplication produces 32-bit result that might
cause wrong calculation.
Example: With MicroSeconds = 200 us, PcdArmArchTimerFreqInHz = 24MHz.
200*24000000 = 0x1_1E1A_3000 => So 0x1E1A_3000 when the type is UINT32.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Olivier Martin <[email protected]>
Modified Paths:
--------------
trunk/edk2/ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.c
Modified: trunk/edk2/ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.c
===================================================================
--- trunk/edk2/ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.c 2014-11-11
00:52:11 UTC (rev 16328)
+++ trunk/edk2/ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.c 2014-11-11
00:52:46 UTC (rev 16329)
@@ -85,7 +85,7 @@
// Calculate counter ticks that can represent requested delay:
// = MicroSeconds x TICKS_PER_MICRO_SEC
// = MicroSeconds x Frequency.10^-6
- TimerTicks64 = (MicroSeconds * PcdGet32 (PcdArmArchTimerFreqInHz)) /
1000000U;
+ TimerTicks64 = ((UINT64)MicroSeconds * PcdGet32 (PcdArmArchTimerFreqInHz)) /
1000000U;
// Read System Counter value
SystemCounterVal = ArmGenericTimerGetSystemCount ();
------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://pubads.g.doubleclick.net/gampad/clk?id=154624111&iu=/4140/ostg.clktrk
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits