aboutsummaryrefslogtreecommitdiff
path: root/frontend/pcnt.h
diff options
context:
space:
mode:
authortwinaphex2012-11-28 06:35:30 +0100
committertwinaphex2012-11-28 06:35:30 +0100
commitb194a2ecd43debbb3724e332b660b993725acd52 (patch)
treea41deacfa7a6841e97d67fce60bb7f39b54b12be /frontend/pcnt.h
parentb6514bd168106e978a0af0f5043d5da6fd35800a (diff)
parent06d2e1a58b6eb7fb449f79f7e807343bd8d39b59 (diff)
downloadpcsx_rearmed-b194a2ecd43debbb3724e332b660b993725acd52.tar.gz
pcsx_rearmed-b194a2ecd43debbb3724e332b660b993725acd52.tar.bz2
pcsx_rearmed-b194a2ecd43debbb3724e332b660b993725acd52.zip
Merge git://github.com/notaz/pcsx_rearmed
Diffstat (limited to 'frontend/pcnt.h')
-rw-r--r--frontend/pcnt.h26
1 files changed, 24 insertions, 2 deletions
diff --git a/frontend/pcnt.h b/frontend/pcnt.h
index 0213ca1..9ddd500 100644
--- a/frontend/pcnt.h
+++ b/frontend/pcnt.h
@@ -11,6 +11,13 @@ enum pcounters {
#ifdef PCNT
+#if defined(__ARM_ARCH_7A__) || defined(ARM1176)
+#define PCNT_DIV 1000
+#else
+#include <sys/time.h>
+#define PCNT_DIV 1
+#endif
+
static const char *pcnt_names[PCNT_CNT] = { "", "gpu", "spu", "blit", "gte", "test" };
#define PCNT_FRAMES 10
@@ -33,7 +40,7 @@ static inline void pcnt_print(float fps)
int i;
for (i = 0; i < PCNT_CNT; i++)
- pcounters[i] /= 1000 * PCNT_FRAMES;
+ pcounters[i] /= PCNT_DIV * PCNT_FRAMES;
rem = total = pcounters[PCNT_ALL];
for (i = 1; i < PCNT_CNT; i++)
@@ -78,8 +85,17 @@ static inline unsigned int pcnt_get(void)
#ifdef __ARM_ARCH_7A__
__asm__ volatile("mrc p15, 0, %0, c9, c13, 0"
: "=r"(val));
+#elif defined(ARM1176)
+ __asm__ volatile("mrc p15, 0, %0, c15, c12, 1"
+ : "=r"(val));
#else
- val = 0;
+ // all slow on ARM :(
+ //struct timespec tv;
+ //clock_gettime(CLOCK_MONOTONIC_RAW, &tv);
+ //val = tv.tv_sec * 1000000000 + tv.tv_nsec;
+ struct timeval tv;
+ gettimeofday(&tv, NULL);
+ val = tv.tv_sec * 1000000 + tv.tv_usec;
#endif
return val;
}
@@ -94,6 +110,12 @@ static inline void pcnt_init(void)
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));
+#elif defined(ARM1176)
+ int v;
+ asm volatile("mrc p15, 0, %0, c15, c12, 0" : "=r"(v));
+ v |= 5; // master enable, ccnt reset
+ v &= ~8; // ccnt divider 0
+ asm volatile("mcr p15, 0, %0, c15, c12, 0" :: "r"(v));
#endif
}