merge libminlib with libc
[minix3.git] / minix / lib / libc / arch / arm / read_tsc.c
blobde829f8b0b59df0177cf39515fbbcdb2b36494da
1 #include <sys/types.h>
2 #include <minix/minlib.h>
4 void
5 read_tsc(u32_t *hi, u32_t *lo)
7 /* Read Clock Cycle Counter (CCNT). Intel calls it Time Stamp Counter (TSC) */
8 u32_t ccnt;
10 /* Get value from the Performance Monitors Cycle Counter Register.
11 * See ARM Architecture Reference Manual B5.1.113.
13 asm volatile ("MRC p15, 0, %0, c9, c13, 0\t\n" : "=r" (ccnt) : : "%0");
15 /* The ARMv7-A clock cycle counter is only 32-bits, but read_tsc is
16 * expected to return a 64-bit value. hi is therefore always 0.
18 *hi = 0;
19 *lo = ccnt;