Hi, I want to use ARM A8 performance counter. I find a post on line, but I do not understand its grammar. ARM inforcenter does not help much. I especially do not understand the '::'. Could you explain it to me? Or point to some links for it.
Thanks,
................. Accessing the performance counters isn't difficult, but you have to enable them from kernel-mode. By default the counters are disabled.
In a nutshell you have to execute the following two lines inside the kernel. Either as a loadable module or just adding the two lines somewhere in the board-init will do:
/* enable user-mode access to the performance counter*/ asm ("MCR p15, 0, %0, C9, C14, 0\n\t" :: "r"(1));
/* disable counter overflow interrupts (just in case)*/ asm ("MCR p15, 0, %0, C9, C14, 2\n\t" :: "r"(0x8000000f));
Once you did this the cycle counter will start incrementing for each cycle. Overflows of the register will go unnoticed and don't cause any problems (except they might mess up your measurements).
Now you want to access the cycle-counter from the user-mode:
We start with a function that reads the register:
static inline unsigned int get_cyclecount (void) { unsigned int value; // Read CCNT Register asm volatile ("MRC p15, 0, %0, c9, c13, 0\t\n": "=r"(value)); return value; }