Module: xenomai-gch
Branch: for-forge
Commit: 7b55e76c6f60a389fafaf9aff07a7091ecaa40b1
URL:    
http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=7b55e76c6f60a389fafaf9aff07a7091ecaa40b1

Author: Gilles Chanteperdrix <gilles.chanteperd...@xenomai.org>
Date:   Tue Jul  1 13:12:51 2014 +0200

cobalt/arm: make kuser tsc the only supported emulation

---

 configure.ac                                       |   48 +-----------
 .../arch/arm/include/asm/xenomai/uapi/features.h   |    7 --
 .../cobalt/arch/arm/include/asm/xenomai/uapi/tsc.h |    4 -
 kernel/cobalt/arch/arm/syscall.c                   |   45 ++---------
 lib/cobalt/arch/arm/features.c                     |   65 ++++------------
 lib/cobalt/arch/arm/include/asm/xenomai/tsc.h      |   81 +-------------------
 6 files changed, 24 insertions(+), 226 deletions(-)

diff --git a/configure.ac b/configure.ac
index 3900e41..9daad31 100644
--- a/configure.ac
+++ b/configure.ac
@@ -286,7 +286,7 @@ AC_ARG_ENABLE(registry,
 AC_MSG_RESULT(${use_registry:-no})
 
 if test x$use_registry = xy; then
-        PKG_CHECK_MODULES(FUSE, fuse)
+       PKG_CHECK_MODULES(FUSE, fuse)
        FUSE_CFLAGS="$FUSE_CFLAGS -DFUSE_USE_VERSION=25"
        AC_DEFINE(CONFIG_XENO_REGISTRY,1,[config])
 fi
@@ -325,48 +325,8 @@ fi
 dnl ARCH support for ARM (default: 4)
 
 if test $XENO_TARGET_ARCH = arm ; then
-
   unset CONFIG_XENO_ARM_SA1100
   unset CONFIG_XENO_CPU_XSC3
-  CONFIG_XENO_ARM_TSC_TYPE=__XN_TSC_TYPE_KUSER
-
-  AC_MSG_CHECKING(for ARM tsc type)
-  AC_ARG_ENABLE(arm-tsc,
-       AS_HELP_STRING([--enable-arm-tsc], [You only need this option
-  if you get the following message when starting an application:
-Xenomai: incompatible feature set
-(userland requires "kuser_tsc ...", kernel provides "...", 
missing="kuser_tsc").
-In that case, this option allows to select the machine for which a
-user-space tsc emulation should be generated. Valid machines are at91,
-kuser, imx, ixp4xx, omap, orion, pxa, s3c24x, sa1100. [default=kuser]]),
-       [case "$enableval" in
-       at91*)      
CONFIG_XENO_ARM_TSC_TYPE=__XN_TSC_TYPE_FREERUNNING_FAST_WRAP;;
-
-       integrator) unset tsc_type;;
-
-       ixp4xx)     CONFIG_XENO_ARM_TSC_TYPE=__XN_TSC_TYPE_FREERUNNING;;
-
-       imx*|mx*)   CONFIG_XENO_ARM_TSC_TYPE=__XN_TSC_TYPE_FREERUNNING;;
-
-       generic|kuser)      CONFIG_XENO_ARM_TSC_TYPE=__XN_TSC_TYPE_KUSER;;
-
-       omap*)      CONFIG_XENO_ARM_TSC_TYPE=__XN_TSC_TYPE_FREERUNNING;;
-
-       orion)      
CONFIG_XENO_ARM_TSC_TYPE=__XN_TSC_TYPE_FREERUNNING_COUNTDOWN;;
-
-       pxa*)       CONFIG_XENO_CPU_XSC3=y
-                   CONFIG_XENO_ARM_TSC_TYPE=__XN_TSC_TYPE_FREERUNNING;;
-
-       s3c24*)     CONFIG_XENO_ARM_TSC_TYPE=__XN_TSC_TYPE_DECREMENTER;;
-
-       sa1100)     CONFIG_XENO_ARM_SA1100=y
-                   CONFIG_XENO_ARM_TSC_TYPE=__XN_TSC_TYPE_FREERUNNING;;
-
-       n | no)     unset CONFIG_XENO_ARM_TSC_TYPE;;
-
-       *)AC_MSG_ERROR([Invalid SOC selected: "$enableval"]);;
-       esac])
-  AC_MSG_RESULT(${enable_arm_tsc:-kuser})
 
   AC_ARG_ENABLE(arm-quirks,
        AS_HELP_STRING([--enable-arm-quirks], [Enable quirks for
@@ -426,7 +386,7 @@ AC_MSG_CHECKING(for LaTeX mode)
 AC_ARG_ENABLE(verbose-latex,
        AS_HELP_STRING([--enable-nonstop-latex], [Use LaTeX non-stop mode]),
        [case "$enableval" in
-       y | yes) 
+       y | yes)
           LATEX_BATCHMODE=NO
           LATEX_MODE=non-stop
           ;;
@@ -750,12 +710,12 @@ fi
 
 unset want_fortify
 AC_MSG_CHECKING(for fortify support)
-AC_ARG_ENABLE([fortify], 
+AC_ARG_ENABLE([fortify],
              AC_HELP_STRING([--enable-fortify],
                             [Enable support for applications compiled
                             with _FORTIFY_SOURCE]),
              [case "$enableval" in
-              y | yes) want_fortify=yes;;
+             y | yes) want_fortify=yes;;
              *) want_fortify=no;;
              esac])
 AC_MSG_RESULT(${want_fortify:-autodetect})
diff --git a/kernel/cobalt/arch/arm/include/asm/xenomai/uapi/features.h 
b/kernel/cobalt/arch/arm/include/asm/xenomai/uapi/features.h
index f392a4b..9453d67 100644
--- a/kernel/cobalt/arch/arm/include/asm/xenomai/uapi/features.h
+++ b/kernel/cobalt/arch/arm/include/asm/xenomai/uapi/features.h
@@ -21,13 +21,6 @@
 #ifndef _COBALT_ARM_ASM_UAPI_FEATURES_H
 #define _COBALT_ARM_ASM_UAPI_FEATURES_H
 
-#define __XN_TSC_TYPE_NONE                  0
-#define __XN_TSC_TYPE_KUSER                 1
-#define __XN_TSC_TYPE_FREERUNNING           2
-#define __XN_TSC_TYPE_DECREMENTER           3
-#define __XN_TSC_TYPE_FREERUNNING_FAST_WRAP 4
-#define __XN_TSC_TYPE_FREERUNNING_COUNTDOWN 5
-
 /* The ABI revision level we use on this arch. */
 #define XENOMAI_ABI_REV   7UL
 
diff --git a/kernel/cobalt/arch/arm/include/asm/xenomai/uapi/tsc.h 
b/kernel/cobalt/arch/arm/include/asm/xenomai/uapi/tsc.h
index 31ff0c0..b17cfb2 100644
--- a/kernel/cobalt/arch/arm/include/asm/xenomai/uapi/tsc.h
+++ b/kernel/cobalt/arch/arm/include/asm/xenomai/uapi/tsc.h
@@ -19,11 +19,7 @@
 #define _COBALT_ARM_ASM_UAPI_TSC_H
 
 struct __xn_tscinfo {
-       int type;               /* Must remain first member */
-       unsigned mask;
        volatile unsigned int *counter;
-       volatile unsigned int *last_cnt; /* Only used by decrementers */
-       volatile unsigned long long *tsc;
 };
 
 #endif /* !_COBALT_ARM_ASM_UAPI_TSC_H */
diff --git a/kernel/cobalt/arch/arm/syscall.c b/kernel/cobalt/arch/arm/syscall.c
index 7814de5..fd62200 100644
--- a/kernel/cobalt/arch/arm/syscall.c
+++ b/kernel/cobalt/arch/arm/syscall.c
@@ -39,53 +39,18 @@ int xnarch_local_syscall(unsigned long a1, unsigned long a2,
                return ret;
 
        switch (p->type) {
-       case IPIPE_TSC_TYPE_FREERUNNING:
-               info.type = __XN_TSC_TYPE_FREERUNNING;
-               info.counter = p->u.fr.counter;
-               info.mask = p->u.fr.mask;
-               info.tsc = p->u.fr.tsc;
-               break;
        case IPIPE_TSC_TYPE_DECREMENTER:
-               info.type = __XN_TSC_TYPE_DECREMENTER;
                info.counter = p->u.dec.counter;
-               info.mask = p->u.dec.mask;
-               info.last_cnt = p->u.dec.last_cnt;
-               info.tsc = p->u.dec.tsc;
-               break;
-#ifdef IPIPE_TSC_TYPE_FREERUNNING_COUNTDOWN
-       case IPIPE_TSC_TYPE_FREERUNNING_COUNTDOWN:
-               info.type = __XN_TSC_TYPE_FREERUNNING_COUNTDOWN;
-               info.counter = p->u.fr.counter;
-               info.mask = p->u.fr.mask;
-               info.tsc = p->u.fr.tsc;
-               break;
-#endif /* IPIPE_TSC_TYPE_FREERUNNING_COUNTDOWN */
-#ifdef IPIPE_TSC_TYPE_FREERUNNING_TWICE
-       case IPIPE_TSC_TYPE_FREERUNNING_TWICE:
-               /*
-                * Requires kuser, not backward compatible with old
-                * xenomai versions
-                */
-               info.type = __XN_TSC_TYPE_KUSER;
-               info.counter = p->u.fr.counter;
-               info.mask = p->u.fr.mask;
-               info.tsc = p->u.fr.tsc;
-               break;
-#endif /* IPIPE_TSC_TYPE_FREERUNNING_TWICE */
-       default:
-               /*
-                * Newer tsc types, require kuser, not backward
-                * compatible with old xenomai versions
-                */
-               info.type = __XN_TSC_TYPE_KUSER;
-               info.counter = (void *)p->u.counter_paddr;
-               info.mask = p->u.mask;
-               info.tsc = p->u.fr.tsc;
                break;
        case IPIPE_TSC_TYPE_NONE:
                return -ENOSYS;
+       default:
+               info.counter = p->u.fr.counter;
+               break;
        }
 
+       printk("counter: %x\n", info.counter);
+
        if (__xn_copy_to_user((void *)a2, &info, sizeof(info)))
                return -EFAULT;
 
diff --git a/lib/cobalt/arch/arm/features.c b/lib/cobalt/arch/arm/features.c
index ef60441..e9f0bc2 100644
--- a/lib/cobalt/arch/arm/features.c
+++ b/lib/cobalt/arch/arm/features.c
@@ -33,25 +33,28 @@
 
 struct __xn_full_tscinfo __xn_tscinfo = {
        .kinfo = {
-               .type = -1,
+               .counter = NULL,
        },
 };
 
 void cobalt_check_features(struct xnfeatinfo *finfo)
 {
-#ifdef CONFIG_XENO_ARM_TSC_TYPE
        unsigned long phys_addr;
        unsigned page_size;
        int err, fd;
        void *addr;
 
-       if (__xn_tscinfo.kinfo.type != -1)
+       if (__xn_tscinfo.kinfo.counter != NULL)
                return;
 
        err = XENOMAI_SYSCALL2(sc_nucleus_arch,
-                              XENOMAI_SYSARCH_TSCINFO, &__xn_tscinfo);
-       if (err)
-               goto error;
+                              XENOMAI_SYSARCH_TSCINFO, &__xn_tscinfo.kinfo);
+       if (err) {
+               report_error("Your board/configuration does not "
+                            "allow TSC emulation in user-space: %s ",
+                            strerror(-err));
+               exit(EXIT_FAILURE);
+       }
 
        fd = __STD(open("/dev/mem", O_RDONLY | O_SYNC));
        if (fd == -1) {
@@ -61,52 +64,13 @@ void cobalt_check_features(struct xnfeatinfo *finfo)
 
        page_size = sysconf(_SC_PAGESIZE);
 
-       switch(__xn_tscinfo.kinfo.type) {
-#if CONFIG_XENO_ARM_TSC_TYPE == __XN_TSC_TYPE_KUSER
-       default:
-               __xn_tscinfo.kuser_tsc_get =
-                       (__xn_rdtsc_t *)(0xffff1004 -
-                                        ((*(unsigned *)(0xffff0ffc) + 3) << 
5));
-               goto domap;
-
-#elif CONFIG_XENO_ARM_TSC_TYPE == __XN_TSC_TYPE_FREERUNNING            \
-       || CONFIG_XENO_ARM_TSC_TYPE == __XN_TSC_TYPE_FREERUNNING_COUNTDOWN \
-       || CONFIG_XENO_ARM_TSC_TYPE == __XN_TSC_TYPE_FREERUNNING_FAST_WRAP
-       case __XN_TSC_TYPE_FREERUNNING:
-       case __XN_TSC_TYPE_FREERUNNING_COUNTDOWN:
-#if CONFIG_XENO_ARM_TSC_TYPE == __XN_TSC_TYPE_FREERUNNING_FAST_WRAP
-               if (__xn_tscinfo.kinfo.mask >= ((1 << 28) - 1)) {
-                       report_error("Hardware TSC is not a fast wrapping "
-                                    "one, select the correct platform, or 
fix\n"
-                                    "configure.in");
-                       exit(EXIT_FAILURE);
-               }
-#endif /* __XN_TSC_TYPE_FREERUNNING_FAST_WRAP */
-               goto domap;
-
-       default:
-               report_error("kernel/user TSC emulation mismatch");
-               exit(EXIT_FAILURE);
-               break;
-#elif CONFIG_XENO_ARM_TSC_TYPE == __XN_TSC_TYPE_DECREMENTER
-       case __XN_TSC_TYPE_DECREMENTER:
-               goto domap;
+       __xn_tscinfo.kuser_tsc_get =
+               (__xn_rdtsc_t *)(0xffff1004 -
+                               ((*(unsigned *)(0xffff0ffc) + 3) << 5));
 
-       default:
-               report_error("kernel/user TSC emulation mismatch");
-               exit(EXIT_FAILURE);
-               break;
-#endif /* CONFIG_XENO_ARM_TSC_TYPE == __XN_TSC_TYPE_DECREMENTER */
-       case __XN_TSC_TYPE_NONE:
-         error:
-               report_error("Your board/configuration does not "
-                            "allow TSC emulation in user-space: %s ",
-                            strerror(-err));
-               exit(EXIT_FAILURE);
-       }
+       phys_addr = (unsigned long)__xn_tscinfo.kinfo.counter;
 
-  domap:
-       phys_addr = (unsigned long) __xn_tscinfo.kinfo.counter;
+       fprintf(stderr, "phys_addr: %p\n", (void *)phys_addr);
 
        addr = mmap(NULL, page_size, PROT_READ, MAP_SHARED,
                    fd, phys_addr & ~(page_size - 1));
@@ -120,7 +84,6 @@ void cobalt_check_features(struct xnfeatinfo *finfo)
                 ((char *) addr + (phys_addr & (page_size - 1))));
 
        __STD(close(fd));
-#endif /* CONFIG_XENO_ARM_TSC_TYPE */
 }
 
 int cobalt_fp_detect(void)
diff --git a/lib/cobalt/arch/arm/include/asm/xenomai/tsc.h 
b/lib/cobalt/arch/arm/include/asm/xenomai/tsc.h
index 7885ad2..b91bb8c 100644
--- a/lib/cobalt/arch/arm/include/asm/xenomai/tsc.h
+++ b/lib/cobalt/arch/arm/include/asm/xenomai/tsc.h
@@ -28,99 +28,20 @@
 #include <asm/xenomai/uapi/tsc.h>
 #include <asm/xenomai/features.h>
 
-#ifndef CONFIG_XENO_ARM_TSC_TYPE
-#error "no TSC type defined for ARM platform"
-#endif
-
 /*
  * 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;
+       struct __xn_tscinfo kinfo;
 };
 extern struct __xn_full_tscinfo __xn_tscinfo;
 
 static inline unsigned long long cobalt_read_tsc(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 int *const counterp = __xn_tscinfo.kinfo.counter;
-       const unsigned int mask = __xn_tscinfo.kinfo.mask;
-       register unsigned long long result;
-       unsigned int 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 int *const counterp = __xn_tscinfo.kinfo.counter;
-       const unsigned int mask = __xn_tscinfo.kinfo.mask;
-       register unsigned long long result;
-       unsigned int 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 int *const counterp = __xn_tscinfo.kinfo.counter;
-       const unsigned int mask = __xn_tscinfo.kinfo.mask;
-       register unsigned long long after, before;
-       unsigned int 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 int *const counterp = __xn_tscinfo.kinfo.counter;
-       volatile unsigned int *const last_cntp = __xn_tscinfo.kinfo.last_cnt;
-       const unsigned int mask = __xn_tscinfo.kinfo.mask;
-       register unsigned long long after, before;
-       unsigned int 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 /* !_LIB_COBALT_ARM_TSC_H */


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

Reply via email to