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

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

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

---

 include/asm-arm/Makefile.am |    1 +
 include/asm-arm/Makefile.in |    1 +
 include/asm-arm/bits/bind.h |    4 +-
 include/asm-arm/syscall.h   |  106 +---------------------------------
 include/asm-arm/tsc.h       |  134 +++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 139 insertions(+), 107 deletions(-)

diff --git a/include/asm-arm/Makefile.am b/include/asm-arm/Makefile.am
index 986aa73..9c89ab0 100644
--- a/include/asm-arm/Makefile.am
+++ b/include/asm-arm/Makefile.am
@@ -10,6 +10,7 @@ includesub_HEADERS = \
        hal.h \
        syscall.h \
        system.h \
+       tsc.h \
        wrappers.h
 
 SUBDIRS = bits
diff --git a/include/asm-arm/Makefile.in b/include/asm-arm/Makefile.in
index 9e6052e..2505bb7 100644
--- a/include/asm-arm/Makefile.in
+++ b/include/asm-arm/Makefile.in
@@ -292,6 +292,7 @@ includesub_HEADERS = \
        hal.h \
        syscall.h \
        system.h \
+       tsc.h \
        wrappers.h
 
 SUBDIRS = bits
diff --git a/include/asm-arm/bits/bind.h b/include/asm-arm/bits/bind.h
index d12f8e2..a88df91 100644
--- a/include/asm-arm/bits/bind.h
+++ b/include/asm-arm/bits/bind.h
@@ -47,8 +47,8 @@ static inline void xeno_arm_features_check(struct xnfeatinfo 
*finfo)
 #if CONFIG_XENO_ARM_TSC_TYPE == __XN_TSC_TYPE_KUSER
        default:
                __xn_tscinfo.kuser_tsc_get =
-                       (rdtsc_t *)(0xffff1004 -
-                                   ((*(unsigned *)(0xffff0ffc) + 3) << 5));
+                       (__xn_rdtsc_t *)(0xffff1004 -
+                                        ((*(unsigned *)(0xffff0ffc) + 3) << 
5));
                goto domap;
 
 #elif CONFIG_XENO_ARM_TSC_TYPE == __XN_TSC_TYPE_FREERUNNING            \
diff --git a/include/asm-arm/syscall.h b/include/asm-arm/syscall.h
index 8161d39..10dae11 100644
--- a/include/asm-arm/syscall.h
+++ b/include/asm-arm/syscall.h
@@ -4,9 +4,6 @@
  * ARM port
  *   Copyright (C) 2005 Stelian Pop
  *
- * Copyright (C) 2007 Sebastian Smolorz <se...@gmx.net>
- *     Support for TSC emulation in user space for decrementing counters
- *
  * 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,
@@ -28,6 +25,7 @@
 
 #include <asm-generic/xenomai/syscall.h>
 #include <asm/xenomai/features.h>
+#include <asm/xenomai/tsc.h>
 
 #define __xn_mux_code(shifted_id,op) ((op << 24)|shifted_id|(__xn_sys_mux & 
0xffff))
 #define __xn_mux_shifted_id(id) ((id << 16) & 0xff0000)
@@ -232,108 +230,6 @@ static inline int __xn_interrupted_p(struct pt_regs *regs)
 #define XENOMAI_SYSARCH_XCHG                   3
 #define XENOMAI_SYSARCH_TSCINFO                 4
 
-struct __xn_tscinfo {
-       int type;               /* Must remain first member */
-       unsigned mask;
-       volatile unsigned *counter;
-       volatile unsigned *last_cnt; /* Only used by decrementers */
-       volatile unsigned long long *tsc;
-};
-
-#ifndef __KERNEL__
-/* Putting kuser_tsc_get and kinfo.counter in the same struct results
-   in less operations in PIC code, thus optimizes */
-typedef unsigned long long rdtsc_t(volatile unsigned *vaddr);
-struct __xn_full_tscinfo {
-       struct __xn_tscinfo kinfo;
-       rdtsc_t *kuser_tsc_get;
-};
-extern struct __xn_full_tscinfo __xn_tscinfo;
-
-#ifdef CONFIG_XENO_ARM_TSC_TYPE
-static inline unsigned long long __xn_rdtsc(void)
-{
-#if CONFIG_XENO_ARM_TSC_TYPE == __XN_TSC_TYPE_KUSER
-       return __xn_tscinfo.kuser_tsc_get(__xn_tscinfo.kinfo.counter);
-
-#elif CONFIG_XENO_ARM_TSC_TYPE == __XN_TSC_TYPE_FREERUNNING
-       volatile unsigned long long *const tscp = __xn_tscinfo.kinfo.tsc;
-       volatile unsigned *const counterp = __xn_tscinfo.kinfo.counter;
-       const unsigned mask = __xn_tscinfo.kinfo.mask;
-       register unsigned long long result;
-       unsigned counter;
-
-       __asm__ ("ldmia %1, %M0\n": "=r"(result): "r"(tscp), "m"(*tscp));
-       __asm__ __volatile__ ("" : /* */ : /* */ : "memory");
-       counter = *counterp;
-
-       if ((counter & mask) < ((unsigned) result & mask))
-               result += mask + 1ULL;
-       return (result & ~((unsigned long long) mask)) | (counter & mask);
-
-#elif CONFIG_XENO_ARM_TSC_TYPE == __XN_TSC_TYPE_FREERUNNING_COUNTDOWN
-       volatile unsigned long long *const tscp = __xn_tscinfo.kinfo.tsc;
-       volatile unsigned *const counterp = __xn_tscinfo.kinfo.counter;
-       const unsigned mask = __xn_tscinfo.kinfo.mask;
-       register unsigned long long result;
-       unsigned counter;
-
-       __asm__ ("ldmia %1, %M0\n": "=r"(result): "r"(tscp), "m"(*tscp));
-       __asm__ __volatile__ ("" : /* */ : /* */ : "memory");
-       counter = mask - *counterp;
-
-       if ((counter & mask) > ((unsigned) result & mask))
-               result += mask + 1ULL;
-       return (result & ~((unsigned long long) mask)) | (counter & mask);
-
-#elif CONFIG_XENO_ARM_TSC_TYPE == __XN_TSC_TYPE_FREERUNNING_FAST_WRAP
-       volatile unsigned long long *const tscp = __xn_tscinfo.kinfo.tsc;
-       volatile unsigned *const counterp = __xn_tscinfo.kinfo.counter;
-       const unsigned mask = __xn_tscinfo.kinfo.mask;
-       register unsigned long long after, before;
-       unsigned counter;
-
-       __asm__ ("ldmia %1, %M0\n": "=r"(after): "r"(tscp), "m"(*tscp));
-       do {
-               before = after;
-               counter = *counterp;
-               __asm__ __volatile__ ("" : /* */ : /* */ : "memory");
-               __asm__ ("ldmia %1, %M0\n" : "=r"(after): "r"(tscp), 
"m"(*tscp));
-       } while (((unsigned) after) != ((unsigned) before));
-       if ((counter & mask) < ((unsigned) before & mask))
-               before += mask + 1;
-       return (before & ~((unsigned long long) mask)) | (counter & mask);
-
-#elif CONFIG_XENO_ARM_TSC_TYPE == __XN_TSC_TYPE_DECREMENTER
-       volatile unsigned long long *const tscp = __xn_tscinfo.kinfo.tsc;
-       volatile unsigned *const counterp = __xn_tscinfo.kinfo.counter;
-       volatile unsigned *const last_cntp = __xn_tscinfo.kinfo.last_cnt;
-       const unsigned mask = __xn_tscinfo.kinfo.mask;
-       register unsigned long long after, before;
-       unsigned counter, last_cnt;
-
-       __asm__ ("ldmia %1, %M0\n": "=r"(after): "r"(tscp), "m"(*tscp));
-       do {
-               before = after;
-               counter = *counterp;
-               last_cnt = *last_cntp;
-               /* compiler barrier. */
-               __asm__ __volatile__ ("" : /* */ : /* */ : "memory");
-               __asm__ ("ldmia %1, %M0\n": "=r"(after): "r"(tscp), "m"(*tscp));
-       } while (after != before);
-
-       counter &= mask;
-       last_cnt &= mask;
-       if (counter > last_cnt)
-               before += mask + 1ULL;
-       return (before + last_cnt - counter);
-
-#endif /* CONFIG_XENO_ARM_TSC_TYPE == __XN_TSC_TYPE_DECREMENTER */
-}
-#endif /* CONFIG_XENO_ARM_TSC_TYPE */
-
-#endif /* !__KERNEL__ */
-
 #endif /* !_XENO_ASM_ARM_SYSCALL_H */
 
 // vim: ts=4 et sw=4 sts=4
diff --git a/include/asm-arm/tsc.h b/include/asm-arm/tsc.h
new file mode 100644
index 0000000..f03e221
--- /dev/null
+++ b/include/asm-arm/tsc.h
@@ -0,0 +1,134 @@
+/*
+ * Copyright (C) 2001,2002,2003,2004 Philippe Gerum <r...@xenomai.org>.
+ * Copyright (C) 2013 Gilles Chanteperdrix <g...@xenomai.org>.
+ *
+ * ARM port
+ *   Copyright (C) 2005 Stelian Pop
+ *
+ * Copyright (C) 2007 Sebastian Smolorz <se...@gmx.net>
+ *     Support for TSC emulation in user space for decrementing counters
+ *
+ * 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_ARM_TSC_H
+#define _XENO_ASM_ARM_TSC_H
+
+#include <asm/xenomai/features.h>
+
+struct __xn_tscinfo {
+       int type;               /* Must remain first member */
+       unsigned mask;
+       volatile unsigned *counter;
+       volatile unsigned *last_cnt; /* Only used by decrementers */
+       volatile unsigned long long *tsc;
+};
+
+#ifndef __KERNEL__
+/* Putting kuser_tsc_get and kinfo.counter in the same struct results
+   in less operations in PIC code, thus optimizes */
+typedef unsigned long long __xn_rdtsc_t(volatile unsigned *vaddr);
+struct __xn_full_tscinfo {
+       struct __xn_tscinfo kinfo;
+       __xn_rdtsc_t *kuser_tsc_get;
+};
+extern struct __xn_full_tscinfo __xn_tscinfo;
+
+#ifdef CONFIG_XENO_ARM_TSC_TYPE
+static inline unsigned long long __xn_rdtsc(void)
+{
+#if CONFIG_XENO_ARM_TSC_TYPE == __XN_TSC_TYPE_KUSER
+       return __xn_tscinfo.kuser_tsc_get(__xn_tscinfo.kinfo.counter);
+
+#elif CONFIG_XENO_ARM_TSC_TYPE == __XN_TSC_TYPE_FREERUNNING
+       volatile unsigned long long *const tscp = __xn_tscinfo.kinfo.tsc;
+       volatile unsigned *const counterp = __xn_tscinfo.kinfo.counter;
+       const unsigned mask = __xn_tscinfo.kinfo.mask;
+       register unsigned long long result;
+       unsigned counter;
+
+       __asm__ ("ldmia %1, %M0\n": "=r"(result): "r"(tscp), "m"(*tscp));
+       __asm__ __volatile__ ("" : /* */ : /* */ : "memory");
+       counter = *counterp;
+
+       if ((counter & mask) < ((unsigned) result & mask))
+               result += mask + 1ULL;
+       return (result & ~((unsigned long long) mask)) | (counter & mask);
+
+#elif CONFIG_XENO_ARM_TSC_TYPE == __XN_TSC_TYPE_FREERUNNING_COUNTDOWN
+       volatile unsigned long long *const tscp = __xn_tscinfo.kinfo.tsc;
+       volatile unsigned *const counterp = __xn_tscinfo.kinfo.counter;
+       const unsigned mask = __xn_tscinfo.kinfo.mask;
+       register unsigned long long result;
+       unsigned counter;
+
+       __asm__ ("ldmia %1, %M0\n": "=r"(result): "r"(tscp), "m"(*tscp));
+       __asm__ __volatile__ ("" : /* */ : /* */ : "memory");
+       counter = mask - *counterp;
+
+       if ((counter & mask) > ((unsigned) result & mask))
+               result += mask + 1ULL;
+       return (result & ~((unsigned long long) mask)) | (counter & mask);
+
+#elif CONFIG_XENO_ARM_TSC_TYPE == __XN_TSC_TYPE_FREERUNNING_FAST_WRAP
+       volatile unsigned long long *const tscp = __xn_tscinfo.kinfo.tsc;
+       volatile unsigned *const counterp = __xn_tscinfo.kinfo.counter;
+       const unsigned mask = __xn_tscinfo.kinfo.mask;
+       register unsigned long long after, before;
+       unsigned counter;
+
+       __asm__ ("ldmia %1, %M0\n": "=r"(after): "r"(tscp), "m"(*tscp));
+       do {
+               before = after;
+               counter = *counterp;
+               __asm__ __volatile__ ("" : /* */ : /* */ : "memory");
+               __asm__ ("ldmia %1, %M0\n" : "=r"(after): "r"(tscp), 
"m"(*tscp));
+       } while (((unsigned) after) != ((unsigned) before));
+       if ((counter & mask) < ((unsigned) before & mask))
+               before += mask + 1;
+       return (before & ~((unsigned long long) mask)) | (counter & mask);
+
+#elif CONFIG_XENO_ARM_TSC_TYPE == __XN_TSC_TYPE_DECREMENTER
+       volatile unsigned long long *const tscp = __xn_tscinfo.kinfo.tsc;
+       volatile unsigned *const counterp = __xn_tscinfo.kinfo.counter;
+       volatile unsigned *const last_cntp = __xn_tscinfo.kinfo.last_cnt;
+       const unsigned mask = __xn_tscinfo.kinfo.mask;
+       register unsigned long long after, before;
+       unsigned counter, last_cnt;
+
+       __asm__ ("ldmia %1, %M0\n": "=r"(after): "r"(tscp), "m"(*tscp));
+       do {
+               before = after;
+               counter = *counterp;
+               last_cnt = *last_cntp;
+               /* compiler barrier. */
+               __asm__ __volatile__ ("" : /* */ : /* */ : "memory");
+               __asm__ ("ldmia %1, %M0\n": "=r"(after): "r"(tscp), "m"(*tscp));
+       } while (after != before);
+
+       counter &= mask;
+       last_cnt &= mask;
+       if (counter > last_cnt)
+               before += mask + 1ULL;
+       return (before + last_cnt - counter);
+
+#endif /* CONFIG_XENO_ARM_TSC_TYPE == __XN_TSC_TYPE_DECREMENTER */
+}
+#endif /* CONFIG_XENO_ARM_TSC_TYPE */
+
+#endif /* !__KERNEL__ */
+
+#endif /* _XENO_ASM_ARM_TSC_H */


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

Reply via email to