summaryrefslogtreecommitdiff
path: root/src/base
diff options
context:
space:
mode:
authorAli Saidi <Ali.Saidi@arm.com>2010-08-23 11:18:40 -0500
committerAli Saidi <Ali.Saidi@arm.com>2010-08-23 11:18:40 -0500
commit8ed4f0a02cd936f717f5af0c15b64fedddd5af54 (patch)
tree7df224367beaf3c5b0bb12372bb124a5e4fe7aab /src/base
parent38cf6a164d7081f1a2f40ab210169681b4cd6929 (diff)
downloadgem5-8ed4f0a02cd936f717f5af0c15b64fedddd5af54.tar.xz
ARM: Add I/O devices for booting linux
--HG-- rename : src/dev/arm/Versatile.py => src/dev/arm/RealView.py rename : src/dev/arm/versatile.cc => src/dev/arm/realview.cc rename : src/dev/arm/versatile.hh => src/dev/arm/realview.hh
Diffstat (limited to 'src/base')
-rw-r--r--src/base/intmath.hh22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/base/intmath.hh b/src/base/intmath.hh
index a2960e750..b8c83f05a 100644
--- a/src/base/intmath.hh
+++ b/src/base/intmath.hh
@@ -33,6 +33,7 @@
#include <cassert>
+#include "base/misc.hh"
#include "base/types.hh"
// Returns the prime number one less than n.
@@ -74,6 +75,27 @@ isPowerOf2(T n)
return n != 0 && leastSigBit(n) == n;
}
+inline uint64_t
+power(uint32_t n, uint32_t e)
+{
+ if (e > 20)
+ warn("Warning, power() function is quite slow for large exponents\n");
+
+ if (e == 0)
+ return 1;
+
+ uint64_t result = n;
+ uint64_t old_result = 0;
+ for (int x = 1; x < e; x++) {
+ old_result = result;
+ result *= n;
+ if (old_result > result)
+ warn("power() overflowed!\n");
+ }
+ return result;
+}
+
+
inline int
floorLog2(unsigned x)
{