Module: xenomai-3
Branch: next
Commit: acc64aac44340dc2d0730188648322452f2d5578
URL:    
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=acc64aac44340dc2d0730188648322452f2d5578

Author: Don Mahurin <d...@mperpetuo.com>
Date:   Wed May 13 09:36:25 2015 -0700

lib/cobalt/arm64: replace tsc counter

---

 lib/cobalt/arch/arm64/include/asm/xenomai/tsc.h |   19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/lib/cobalt/arch/arm64/include/asm/xenomai/tsc.h 
b/lib/cobalt/arch/arm64/include/asm/xenomai/tsc.h
index 594c4ad..a055427 100644
--- a/lib/cobalt/arch/arm64/include/asm/xenomai/tsc.h
+++ b/lib/cobalt/arch/arm64/include/asm/xenomai/tsc.h
@@ -27,6 +27,8 @@
 
 #include <asm/xenomai/uapi/tsc.h>
 #include <asm/xenomai/features.h>
+#include <inttypes.h>
+#include <sys/time.h>
 
 /*
  * Putting kuser_tsc_get and kinfo.counter in the same struct results
@@ -39,10 +41,27 @@ struct __xn_full_tscinfo {
 };
 extern struct __xn_full_tscinfo __xn_tscinfo;
 
+static inline uint64_t get_counter(void)
+{
+        uint64_t cval;
+
+#ifdef __aarch64__
+       asm volatile("isb; mrs %0, cntvct_el0; isb; " : "=r" (cval) :: 
"memory");
+#else
+       asm volatile("isb; mrrc p15, 1, %Q0, %R0, c14; isb" : "=r" (cval) :: 
"memory");
+#endif
+
+       return cval;
+}
+
 static inline __attribute__((always_inline))
 unsigned long long cobalt_read_tsc(void)
 {
+#ifndef __aarch64__
        return __xn_tscinfo.kuser_tsc_get(__xn_tscinfo.kinfo.counter);
+#else
+       return get_counter();
+#endif
 }
 
 #endif /* !_LIB_COBALT_ARM_TSC_H */


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git

Reply via email to