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

Author: Gilles Chanteperdrix <gilles.chanteperd...@xenomai.org>
Date:   Sat Apr 14 22:32:19 2012 +0200

arm: simplify tsc emulation

---

 include/asm-arm/bits/bind.h   |   34 +++++++---------------------------
 include/asm-arm/bits/shadow.h |   31 +++----------------------------
 include/asm-arm/syscall.h     |   14 ++++----------
 3 files changed, 14 insertions(+), 65 deletions(-)

diff --git a/include/asm-arm/bits/bind.h b/include/asm-arm/bits/bind.h
index ce37126..c72702c 100644
--- a/include/asm-arm/bits/bind.h
+++ b/include/asm-arm/bits/bind.h
@@ -13,9 +13,7 @@
 #include <asm-generic/xenomai/bits/bind.h>
 #include <asm/xenomai/syscall.h>
 
-__attribute__((weak)) struct __xn_tscinfo __xn_tscinfo = {
-  type: -1
-};
+__attribute__((weak)) struct __xn_tscinfo __xn_tscinfo;
 
 static inline void xeno_arm_features_check(struct xnfeatinfo *finfo)
 {
@@ -24,13 +22,16 @@ static inline void xeno_arm_features_check(struct 
xnfeatinfo *finfo)
        int err, fd;
        void *addr;
 
-       if (__xn_tscinfo.type != -1)
+       if (__xn_tscinfo.counter != NULL)
                return;
 
        err = XENOMAI_SYSCALL2(sc_nucleus_arch,
                               XENOMAI_SYSARCH_TSCINFO, &__xn_tscinfo);
-       if (err)
-               goto error;
+       if (err) {
+               fprintf(stderr, "Xenomai init: error when retrieving ARM tsc"
+                       " emulation information.\n");
+               exit(EXIT_FAILURE);
+       }
 
        fd = open("/dev/mem", O_RDONLY | O_SYNC);
        if (fd == -1) {
@@ -40,27 +41,6 @@ static inline void xeno_arm_features_check(struct xnfeatinfo 
*finfo)
 
        page_size = sysconf(_SC_PAGESIZE);
 
-       switch(__xn_tscinfo.type) {
-       case __XN_TSC_TYPE_FREERUNNING:
-       case __XN_TSC_TYPE_FREERUNNING_COUNTDOWN:
-       case __XN_TSC_TYPE_FREERUNNING_FAST_WRAP:
-       case __XN_TSC_TYPE_DECREMENTER:
-               goto domap;
-
-       case __XN_TSC_TYPE_NONE:
-         error:
-               fprintf(stderr, "Xenomai: Your board/configuration does not"
-                       " allow tsc emulation in user-space: %d\n", err);
-               exit(EXIT_FAILURE);
-               break;
-
-       default:
-               fprintf(stderr,
-                       "Xenomai: kernel/user tsc emulation mismatch.\n");
-               exit(EXIT_FAILURE);
-       }
-
-  domap:
        phys_addr = (unsigned long) __xn_tscinfo.counter;
 
        addr = mmap(NULL, page_size, PROT_READ, MAP_SHARED,
diff --git a/include/asm-arm/bits/shadow.h b/include/asm-arm/bits/shadow.h
index 25457b4..396aaaa 100644
--- a/include/asm-arm/bits/shadow.h
+++ b/include/asm-arm/bits/shadow.h
@@ -72,34 +72,9 @@ int xnarch_local_syscall(unsigned long a1, unsigned long a2,
                if (error)
                        return error;
 
-               switch (RTHAL_TSC_INFO(&ipipe_info).type) {
-               case IPIPE_TSC_TYPE_FREERUNNING:
-                       info.type = __XN_TSC_TYPE_FREERUNNING,
-                       info.counter = RTHAL_TSC_INFO(&ipipe_info).u.fr.counter;
-                       info.mask = RTHAL_TSC_INFO(&ipipe_info).u.fr.mask;
-                       info.tsc = RTHAL_TSC_INFO(&ipipe_info).u.fr.tsc;
-                       break;
-               case IPIPE_TSC_TYPE_DECREMENTER:
-                       info.type = __XN_TSC_TYPE_DECREMENTER,
-                       info.counter = 
RTHAL_TSC_INFO(&ipipe_info).u.dec.counter;
-                       info.mask = RTHAL_TSC_INFO(&ipipe_info).u.dec.mask;
-                       info.last_cnt = 
RTHAL_TSC_INFO(&ipipe_info).u.dec.last_cnt;
-                       info.tsc = RTHAL_TSC_INFO(&ipipe_info).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 = RTHAL_TSC_INFO(&ipipe_info).u.fr.counter;
-                       info.mask = RTHAL_TSC_INFO(&ipipe_info).u.fr.mask;
-                       info.tsc = RTHAL_TSC_INFO(&ipipe_info).u.fr.tsc;
-                       break;
-#endif /* IPIPE_TSC_TYPE_FREERUNNING_COUNTDOWN */
-               case IPIPE_TSC_TYPE_NONE:
-                       return -ENOSYS;
-
-               default:
-                       return -EINVAL;
-               }
+               info.counter = RTHAL_TSC_INFO(&ipipe_info).u.fr.counter;
+               info.tsc_get =
+                       (__xn_rdtsc_t *)(((char *)&__ipipe_tsc_get) + 4);
 
                if (__xn_copy_to_user((void *)a2, &info, sizeof(info)))
                        return -EFAULT;
diff --git a/include/asm-arm/syscall.h b/include/asm-arm/syscall.h
index 3f9c7e5..0977681 100644
--- a/include/asm-arm/syscall.h
+++ b/include/asm-arm/syscall.h
@@ -230,12 +230,11 @@ static inline int __xn_interrupted_p(struct pt_regs *regs)
 #define XENOMAI_SYSARCH_XCHG                   3
 #define XENOMAI_SYSARCH_TSCINFO                 4
 
+typedef unsigned long long __xn_rdtsc_t(volatile unsigned *);
+
 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;
+       __xn_rdtsc_t *tsc_get;
 };
 
 #ifndef __KERNEL__
@@ -243,12 +242,7 @@ extern struct __xn_tscinfo __xn_tscinfo;
 
 static inline unsigned long long __xn_rdtsc(void)
 {
-       typedef unsigned long long rdtsc_t(volatile unsigned *vaddr);
-       rdtsc_t *const kuser_tsc_get =
-               (rdtsc_t *)(0xffff1004 -
-                           ((*(unsigned *)(0xffff0ffc) + 3) << 5));
-
-       return kuser_tsc_get(__xn_tscinfo.counter);
+       return __xn_tscinfo.tsc_get(__xn_tscinfo.counter);
 }
 #endif /* !__KERNEL__ */
 


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

Reply via email to