What I want to do is trying to run a short code in Raspberry pi 1(ARMv6), and get the number of clock cycles it took. So I have to read the Cycle Counter Register, which is in CP15 c15. In the document(ARM11->ARM1176->ARM1176JZF-S Technical Reference Manual->System Control Coprocessor->System control processor registers->c15, Cycle Counter Register) it says that I need to access the user mode firstly. But I have no idea how to do it.
In Raspberry pi 2(ARMv7) I know this could be done with a kernel module of following code:
/* enable user-mode access */
asm ("MCR p15, 0, %0, C9, C14, 0\n\t" :: "r"(1));
but since the registers of ARMv6 and ARMv7 are different, I don't know how to write the assembler for Raspberry 1. Until now I couldn't find anything about this in the manual. Does anyone know how to do it?
Btw, my purpose is just getting the clock cycles of running a code. If anyone knows other approaches to do it, I'm also glad to see. Thank you!