summaryrefslogtreecommitdiff
path: root/sys/src/9/teg2/v7-arch.c
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@gmx.de>2013-01-26 17:33:21 +0100
committercinap_lenrek <cinap_lenrek@gmx.de>2013-01-26 17:33:21 +0100
commitea108c8ca6e726ac008f75775ab83775ec233171 (patch)
tree982816b58d50e1b12b7eeb2c29fe22ca8d9c195b /sys/src/9/teg2/v7-arch.c
parent43e09c468b4c6562c93c9375a316012e238d21b2 (diff)
add tegra2 soc kernel (from sources)
Diffstat (limited to 'sys/src/9/teg2/v7-arch.c')
-rw-r--r--sys/src/9/teg2/v7-arch.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/sys/src/9/teg2/v7-arch.c b/sys/src/9/teg2/v7-arch.c
new file mode 100644
index 000000000..40b1e09fa
--- /dev/null
+++ b/sys/src/9/teg2/v7-arch.c
@@ -0,0 +1,51 @@
+/*
+ * arm arch v7 routines other than cache-related ones.
+ *
+ * calling this arch-v7.c would confuse the mk scripts,
+ * to which a filename arch*.c is magic.
+ */
+#include "u.h"
+#include "../port/lib.h"
+#include "mem.h"
+#include "dat.h"
+#include "fns.h"
+#include "../port/error.h"
+#include "io.h"
+#include "arm.h"
+
+/*
+ * these routines should be cheap enough that there will
+ * be no hesitation to use them.
+ *
+ * once 5c in-lines vlong ops, just use the vlong versions.
+ */
+
+/* see Hacker's Delight if this isn't obvious */
+#define ISPOW2(i) (((i) & ((i) - 1)) == 0)
+
+int
+ispow2(uvlong uvl)
+{
+ /* see Hacker's Delight if this isn't obvious */
+ return ISPOW2(uvl);
+}
+
+static int
+isulpow2(ulong ul) /* temporary speed hack */
+{
+ return ISPOW2(ul);
+}
+
+/*
+ * return exponent of smallest power of 2 ≥ n
+ */
+int
+log2(ulong n)
+{
+ int i;
+
+ i = BI2BY*BY2WD - 1 - clz(n);
+ if (n == 0 || !ISPOW2(n))
+ i++;
+ return i;
+}