Is it possible to read / access the cycle count register in userspace? (I'm on a DM365)

I attempted to read the register with the following code - but the application dies with an invalid instruction.

Regards

--
Kieran Bingham


<<< Code Segment cpu-cycles.c >>>

static inline void ccnt_start(void) { __asm__ volatile ("mcr p15, 0, %0, c9, c12, 1" :: "r"(1<<31));

}

static inline void ccnt_stop(void)
{ __asm__ volatile ("mcr p15, 0, %0, c9, c12, 2" :: "r"(1<<31));

}

static inline unsigned ccnt_read(void)
{ unsigned cc; __asm__ volatile ("mrc p15, 0, %0, c9, c13, 0" : "=r"(cc)); return cc;
}

static inline void ccnt_init(void)
{
   ccnt_stop();
   __asm__ volatile ("mcr p15, 0, %0, c9, c12, 0" :: "r"(5));

}

static inline void enable_user_pmon(void)
{
       __asm__ volatile ("mov     r0, #1");
       __asm__ volatile ("mcr     p15, 0, r0, c9, c14, 0");
}

#include <stdio.h>
#include <stdlib.h>

void main(void)
{
       int start;
       int stop;

       enable_user_pmon();

       ccnt_init();

       start = ccnt_read();

       ccnt_start();

       usleep(1000);

       stop = ccnt_read();

       printf("CCNT Ran for %d cycles\n", stop - start);
}

_______________________________________________
Davinci-linux-open-source mailing list
[email protected]
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source

Reply via email to