Browse Source

read system timer on AARCH64

Steffen Jaeckel 5 years ago
parent
commit
7d57bae82c
1 changed files with 4 additions and 0 deletions
  1. 4 0
      demos/timing.c

+ 4 - 0
demos/timing.c

@@ -86,6 +86,10 @@ static ulong64 rdtsc (void)
            __asm__ __volatile__ ("rd %%tick, %0; clruw %0, %1; srlx %0, 32, %0" : "=r" (x), "=r" (y) : "0" (x), "1" (y));
            __asm__ __volatile__ ("rd %%tick, %0; clruw %0, %1; srlx %0, 32, %0" : "=r" (x), "=r" (y) : "0" (x), "1" (y));
            return ((unsigned long long) x << 32) | y;
            return ((unsigned long long) x << 32) | y;
          #endif
          #endif
+      #elif defined(__aarch64__)
+         ulong64 CNTVCT_EL0;
+         __asm__ __volatile__ ("mrs %0, cntvct_el0" : "=r"(CNTVCT_EL0));
+         return CNTVCT_EL0;
       #else
       #else
          return XCLOCK();
          return XCLOCK();
       #endif
       #endif