Module: xenomai-2.6
Branch: master
Commit: ff61dfa037420389ddb3e574cca3b20ba278f550
URL:    
http://git.xenomai.org/?p=xenomai-2.6.git;a=commit;h=ff61dfa037420389ddb3e574cca3b20ba278f550

Author: Gilles Chanteperdrix <gilles.chanteperd...@xenomai.org>
Date:   Sat Apr 27 23:14:53 2013 +0200

hal/nios2: move __xn_rdtsc definition to asm/tsc.h

---

 include/asm-nios2/Makefile.am |    2 +-
 include/asm-nios2/Makefile.in |    2 +-
 include/asm-nios2/syscall.h   |   53 +---------------------------
 include/asm-nios2/tsc.h       |   79 +++++++++++++++++++++++++++++++++++++++++
 4 files changed, 82 insertions(+), 54 deletions(-)

diff --git a/include/asm-nios2/Makefile.am b/include/asm-nios2/Makefile.am
index 6fff82b..36f4a70 100644
--- a/include/asm-nios2/Makefile.am
+++ b/include/asm-nios2/Makefile.am
@@ -1,6 +1,6 @@
 includesubdir = $(includedir)/asm-nios2
 
 includesub_HEADERS = arith.h atomic.h calibration.h features.h fptest.h \
-               hal.h syscall.h system.h wrappers.h
+               hal.h syscall.h system.h tsc.h wrappers.h
 
 SUBDIRS = bits
diff --git a/include/asm-nios2/Makefile.in b/include/asm-nios2/Makefile.in
index a0fe236..fd9fcd7 100644
--- a/include/asm-nios2/Makefile.in
+++ b/include/asm-nios2/Makefile.in
@@ -283,7 +283,7 @@ top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 includesubdir = $(includedir)/asm-nios2
 includesub_HEADERS = arith.h atomic.h calibration.h features.h fptest.h \
-               hal.h syscall.h system.h wrappers.h
+               hal.h syscall.h system.h tsc.h wrappers.h
 
 SUBDIRS = bits
 all: all-recursive
diff --git a/include/asm-nios2/syscall.h b/include/asm-nios2/syscall.h
index 92cf01c..44badc6 100644
--- a/include/asm-nios2/syscall.h
+++ b/include/asm-nios2/syscall.h
@@ -21,6 +21,7 @@
 #define _XENO_ASM_NIOS2_SYSCALL_H
 
 #include <asm-generic/xenomai/syscall.h>
+#include <asm/xenomai/tsc.h>
 
 #define __xn_mux_shifted_id(id)             (id << 24)
 #define __xn_mux_code(shifted_id,op) (shifted_id|((op << 16) & 
0xff0000)|(__xn_sys_mux & 0xffff))
@@ -223,58 +224,6 @@ static inline int __xn_interrupted_p(struct pt_regs *regs)
 #define XENOMAI_SKINCALL4(id,op,a1,a2,a3,a4)    
XENOMAI_DO_SYSCALL(4,id,op,a1,a2,a3,a4)
 #define XENOMAI_SKINCALL5(id,op,a1,a2,a3,a4,a5) 
XENOMAI_DO_SYSCALL(5,id,op,a1,a2,a3,a4,a5)
 
-extern volatile void *xeno_nios2_hrclock;
-
-static inline unsigned long long __xn_rdtsc(void)
-{
-       volatile unsigned short *hrclock;
-       int64_t t0, t1;
-
-       hrclock = xeno_nios2_hrclock;
-
-#define hrclock_wrsnap(reg, val)               \
-       (*(hrclock + (12 + ((reg) * 2)))) = (val)
-
-#define hrclock_rdsnap(reg)                    \
-       (int64_t)(*(hrclock + (12 + ((reg) * 2)))) << (reg * 16)
-
-#define hrclock_peeksnap()                                             \
-       ({                                                              \
-               int64_t __snap;                                         \
-               __snap = hrclock_rdsnap(3) | hrclock_rdsnap(2) |        \
-                       hrclock_rdsnap(1) | hrclock_rdsnap(0);          \
-               __snap;                                                 \
-       })
-
-#define hrclock_getsnap()                                              \
-       ({                                                              \
-               hrclock_wrsnap(0, 0);                                   \
-               hrclock_peeksnap();                                     \
-       })
-
-       /*
-        * We compete with both the kernel and userland applications
-        * which may request a snapshot as well, but we don't have any
-        * simple mutual exclusion mechanism at hand to avoid
-        * races. In order to keep the overhead of reading the hrclock
-        * from userland low, we make sure to read two consecutive
-        * coherent snapshots. In case both readings do not match, we
-        * have to request a fresh snapshot anew, since it means that
-        * we have been preempted in the middle of the operation.
-        */
-       do {
-               t0 = hrclock_getsnap(); /* Request snapshot and read it */
-               __asm__ __volatile__("": : :"memory");
-               t1 = hrclock_peeksnap(); /* Confirm first reading */
-       } while (t0 != t1);
-
-#undef hrclock_getsnap
-#undef hrclock_rdsnap
-#undef hrclock_wrsnap
-
-       return ~t0;
-}
-
 /*
  * uClibc does not always provide the following symbols for this arch;
  * provide placeholders here. Note: let the compiler decides whether
diff --git a/include/asm-nios2/tsc.h b/include/asm-nios2/tsc.h
new file mode 100644
index 0000000..90be757
--- /dev/null
+++ b/include/asm-nios2/tsc.h
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2009 Philippe Gerum <r...@xenomai.org>.
+ *
+ * Xenomai is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2 of the License,
+ * or (at your option) any later version.
+ *
+ * Xenomai is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Xenomai; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#ifndef _XENO_ASM_NIOS2_TSC_H
+#define _XENO_ASM_NIOS2_TSC_H
+
+#ifndef __KERNEL__
+
+extern volatile void *xeno_nios2_hrclock;
+
+static inline unsigned long long __xn_rdtsc(void)
+{
+       volatile unsigned short *hrclock;
+       int64_t t0, t1;
+
+       hrclock = xeno_nios2_hrclock;
+
+#define hrclock_wrsnap(reg, val)               \
+       (*(hrclock + (12 + ((reg) * 2)))) = (val)
+
+#define hrclock_rdsnap(reg)                    \
+       (int64_t)(*(hrclock + (12 + ((reg) * 2)))) << (reg * 16)
+
+#define hrclock_peeksnap()                                             \
+       ({                                                              \
+               int64_t __snap;                                         \
+               __snap = hrclock_rdsnap(3) | hrclock_rdsnap(2) |        \
+                       hrclock_rdsnap(1) | hrclock_rdsnap(0);          \
+               __snap;                                                 \
+       })
+
+#define hrclock_getsnap()                                              \
+       ({                                                              \
+               hrclock_wrsnap(0, 0);                                   \
+               hrclock_peeksnap();                                     \
+       })
+
+       /*
+        * We compete with both the kernel and userland applications
+        * which may request a snapshot as well, but we don't have any
+        * simple mutual exclusion mechanism at hand to avoid
+        * races. In order to keep the overhead of reading the hrclock
+        * from userland low, we make sure to read two consecutive
+        * coherent snapshots. In case both readings do not match, we
+        * have to request a fresh snapshot anew, since it means that
+        * we have been preempted in the middle of the operation.
+        */
+       do {
+               t0 = hrclock_getsnap(); /* Request snapshot and read it */
+               __asm__ __volatile__("": : :"memory");
+               t1 = hrclock_peeksnap(); /* Confirm first reading */
+       } while (t0 != t1);
+
+#undef hrclock_getsnap
+#undef hrclock_rdsnap
+#undef hrclock_wrsnap
+
+       return ~t0;
+}
+
+#endif /* __KERNEL__ */
+
+#endif /* _XENO_ASM_NIOS2_TSC_H */


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

Reply via email to