aboutsummaryrefslogtreecommitdiffstats
path: root/src/vppinfra
diff options
context:
space:
mode:
authorGabriel Ganne <gabriel.ganne@enea.com>2017-03-20 15:13:02 +0100
committerDamjan Marion <dmarion.lists@gmail.com>2017-03-21 13:29:20 +0000
commit1dc2f9284e5b5eb8b300d63cdb8f74ee36cdecb0 (patch)
treed8cf0585250ef1b2f35f380dd41121e20780a149 /src/vppinfra
parenteb743fad56b32cb20ad2d2cadc4760f9c25be5e1 (diff)
armv8 - fix os_cpu_clock_frequency for armv8
System timer of ARMv8 runs at a different frequency than the CPU's. The frequency is fixed, typically in the range 1-50MHz. It can be read at CNTFRQ special register. Change-Id: I6a21a6a9e2df783559df0caec63d5525c2258227 Signed-off-by: Gabriel Ganne <gabriel.ganne@enea.com>
Diffstat (limited to 'src/vppinfra')
-rw-r--r--src/vppinfra/time.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/vppinfra/time.c b/src/vppinfra/time.c
index 2bdb9da4..168d7375 100644
--- a/src/vppinfra/time.c
+++ b/src/vppinfra/time.c
@@ -147,6 +147,12 @@ os_cpu_clock_frequency (void)
if (clib_cpu_supports_invariant_tsc ())
return estimate_clock_frequency (1e-3);
+#if defined (__aarch64__)
+ u64 tsc;
+ asm volatile ("mrs %0, CNTFRQ_EL0":"=r" (tsc));
+ return (f64) tsc;
+#endif
+
/* First try /sys version. */
cpu_freq = clock_frequency_from_sys_filesystem ();
if (cpu_freq != 0)