Commits

Eric Van Hensbergen committed 248a6f3

arm: add ARM PMU getticks() implementation

This will require the use of a kernel module to unlock the ARM PMU
for user mode access.

Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>

  • Participants
  • Parent commits e40944b

Comments (0)

Files changed (2)

 CC = cc
 # Note the -O0. You should *never* optimize this benchmark!
-CFLAGS = -Wall -O0
+CFLAGS = -Wall -O0 -DARM -DARM_PMU
 LIBS =
 LDFLAGS = $(USER_OPT)
 
 #define HAVE_TICK_COUNTER
 #endif
 
+#if defined(ARM_PMU)
+/*
+ * Internal macros for acessing PM registers
+ * PMU access has to be enabled from supervisor mode
+ * (in other words from a kernel driver)
+ *
+ */
+
+#define READ_REG(reg,v)  asm volatile("mrc " reg : "=r"(v))
+#define WRITE_REG(reg,v) asm volatile("mcr " reg : : "r"(v))
+
+#define PMCCNTR    "p15, 0, %0, c9, c13, 0"
+#define PMOVSR     "p15, 0, %0, c9, c12, 3"
+
+typedef unsigned long long ticks;
+static __inline__ ticks getticks(void)
+{
+       unsigned v;
+       unsigned ov;
+       static unsigned long long base = 0;
+       READ_REG(PMCCNTR,v);
+       READ_REG(PMOVSR,ov);
+       if(ov) {
+               WRITE_REG(PMOVSR,0x80000000); // clear overflow bit 
+               base = base + ((long long)1<<32);
+       }       
+       return (base | v);
+}
+
+INLINE_ELAPSED(__inline__)
+
+#define HAVE_TICK_COUNTER
+#endif /* ARM_PMU */
+