OK, just tried that kernel and the provided omap3beagle_defconfig but
with "enable userspace access to performance counters".
I tried my userspace program to measure instructions issued, still
nothing.
I'm going to post the code for the userspace program. Can someone test
it on a known working system?
=-=-=-=-=-=-=-
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <inttypes.h>
#define PMNCTRL_MASK 0x3f
#define PMNCTRL_E 0x1
#define PMNCTRL_P 0x2
#define PMNCTRL_C 0x4
#define PMNCTRL_D 0x8
#define PMNCTRL_X 0x10
#define PMNCTRL_DP 0x20
int main(int argc, char * argv[]) {
int i = 0;
uint32_t value = 0;
uint32_t test = 0;
uint32_t count = 0;
// read the current value of useren register, it should be 0x1
__asm__ __volatile__ (
"mrc p15, 0, %0, c9, c14, 0"
: "=r" (value));
printf("value of usren reg is: 0x%X\n", value);
// enable all counters
__asm__ __volatile__ (
"mcr p15, 0, %0, c9, c12, 1"
::"r" (0x8000000f));
// select counter 0, setup events to use
__asm__ __volatile__(
"mcr p15, 0, %0, c9, c12, 5"
::"r" (0x0));
__asm__ __volatile__ (
"mcr p15, 0, %0, c9, c13, 1"
::"r"(0x57));
// reset all counters and start counting
__asm__ __volatile__ (
"mrc p15, 0, %0, c9, c12, 0"
: "=r" (value));
printf("control value before: 0x%X\n", value);
value &= ~PMNCTRL_MASK;
value |= PMNCTRL_C | PMNCTRL_P | PMNCTRL_E;
printf("writing control value: 0x%X\n", value);
__asm__ __volatile__ (
"mcr p15, 0, %0, c9, c12, 0"
:: "r" (value));
// loop test
for(i = 0; i < 1000; i++) {
test += i;
}
printf("test = %u\n", test);
// Stop counting
__asm__ __volatile__ (
"mrc p15, 0, %0, c9, c12, 0"
: "=r" (value));
printf("control value before: 0x%X\n", value);
value &= ~PMNCTRL_MASK;
printf("writing control value: 0x%X\n", value);
__asm__ __volatile__ (
"mcr p15, 0, %0, c9, c12, 0"
:: "r" (value));
// select counter and read result
__asm__ __volatile__
"mcr p15, 0, %0, c9, c12, 5"
::"r" (0x0));
__asm__ __volatile__ (
"mrc P15, 0, %0, c9, c13, 2"
: "=r" (count));
printf("counter value = %u\n", count);
return 0;
}
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
for me this prints out:
value of usren reg is: 0x1
control value before: 0x41002000
writing control value: 0x41002007
test = 499500
control value before: 0x41002001
writing control value: 0x41002000
counter value = 0
Can anyone show me where I'm going wrong?
Etienne