From 19e57cbf170d1ce49f00097f3cc3a4ed96d77374 Mon Sep 17 00:00:00 2001 From: notaz Date: Mon, 1 Aug 2011 23:22:04 +0300 Subject: [PATCH] frontnd: pcnt: enable counters to avoid using ext tools --- frontend/pcnt.h | 13 +++++++++++++ frontend/plugin.c | 3 +-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/frontend/pcnt.h b/frontend/pcnt.h index 232ae077..3969aa4e 100644 --- a/frontend/pcnt.h +++ b/frontend/pcnt.h @@ -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) diff --git a/frontend/plugin.c b/frontend/plugin.c index cbb5558d..7b0d3011 100644 --- a/frontend/plugin.c +++ b/frontend/plugin.c @@ -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); -- 2.39.2