frontnd: pcnt: enable counters to avoid using ext tools
authornotaz <notasas@gmail.com>
Mon, 1 Aug 2011 20:22:04 +0000 (23:22 +0300)
committernotaz <notasas@gmail.com>
Mon, 1 Aug 2011 20:32:21 +0000 (23:32 +0300)
frontend/pcnt.h
frontend/plugin.c

index 232ae07..3969aa4 100644 (file)
@@ -83,6 +83,19 @@ static inline unsigned int pcnt_get(void)
        return val;
 }
 
+static inline void pcnt_init(void)
+{
+#ifdef __ARM_ARCH_7A__
+       int v;
+       asm volatile("mrc p15, 0, %0, c9, c12, 0" : "=r"(v));
+       v |= 5; // master enable, ccnt reset
+       v &= ~8; // ccnt divider 0
+       asm volatile("mcr p15, 0, %0, c9, c12, 0" :: "r"(v));
+       // enable cycle counter
+       asm volatile("mcr p15, 0, %0, c9, c12, 1" :: "r"(1<<31));
+#endif
+}
+
 #else
 
 #define pcnt_start(id)
index cbb5558..7b0d301 100644 (file)
@@ -271,8 +271,7 @@ pc_hook_func              (SPU_playCDDAchannel, (short *a0, int a1), (a0, a1), P
 
 void pcnt_hook_plugins(void)
 {
-       /* test it first */
-       pcnt_get();
+       pcnt_init();
 
        hook_it(GPU_writeStatus);
        hook_it(GPU_writeData);