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

Author: Gilles Chanteperdrix <gilles.chanteperd...@xenomai.org>
Date:   Fri Aug  3 00:50:09 2012 +0200

hal: pass to ipipe_timer_set a delay in hrclock ticks

---

 include/asm-arm/bits/timer.h     |    7 +++++++
 include/asm-generic/wrappers.h   |    8 ++++++++
 include/asm-nios2/bits/timer.h   |    5 +++++
 include/asm-powerpc/bits/timer.h |    4 ++++
 include/asm-sh/bits/timer.h      |    4 ++++
 include/asm-x86/bits/timer.h     |    4 ++++
 ksrc/arch/arm/hal.c              |   20 ++++++++++++++++----
 ksrc/arch/blackfin/hal.c         |    2 +-
 ksrc/arch/generic/hal.c          |   17 +++++++----------
 ksrc/arch/powerpc/hal.c          |    2 +-
 ksrc/arch/x86/hal_32.c           |    2 +-
 ksrc/arch/x86/hal_64.c           |    2 +-
 12 files changed, 59 insertions(+), 18 deletions(-)

diff --git a/include/asm-arm/bits/timer.h b/include/asm-arm/bits/timer.h
index 880fdfe..fcc17c1 100644
--- a/include/asm-arm/bits/timer.h
+++ b/include/asm-arm/bits/timer.h
@@ -29,6 +29,7 @@
 
 #include <asm/xenomai/arith.h>
 
+#if !defined(CONFIG_IPIPE_CORE) || IPIPE_CORE_APIREV < 2
 extern rthal_u32frac_t rthal_tsc_to_timer;
 
 static inline void xnarch_program_timer_shot(unsigned long delay)
@@ -36,6 +37,12 @@ static inline void xnarch_program_timer_shot(unsigned long 
delay)
        rthal_timer_program_shot(
                rthal_nodiv_imuldiv_ceil(delay, rthal_tsc_to_timer));
 }
+#else
+static inline void xnarch_program_timer_shot(unsigned long delay)
+{
+       rthal_timer_program_shot(delay);
+}
+#endif
 
 static inline void xnarch_send_timer_ipi(xnarch_cpumask_t mask)
 {
diff --git a/include/asm-generic/wrappers.h b/include/asm-generic/wrappers.h
index 0a5f528..be01c4f 100644
--- a/include/asm-generic/wrappers.h
+++ b/include/asm-generic/wrappers.h
@@ -739,4 +739,12 @@ static inline void __FD_ZERO(__kernel_fd_set *__p)
 }
 #endif
 
+#ifdef CONFIG_IPIPE_CORE
+#if IPIPE_CORE_APIREV >= 2
+#define wrap_ipipe_timers_request(mask) ipipe_timers_request(mask)
+#else /* IPIPE_CORE_APIREV < 2 */
+#define wrap_ipipe_timers_request(mask) ipipe_timers_request()
+#endif /* IPIPE_CORE_APIREV < 2 */
+#endif /* I-pipe core */
+
 #endif /* _XENO_ASM_GENERIC_WRAPPERS_H */
diff --git a/include/asm-nios2/bits/timer.h b/include/asm-nios2/bits/timer.h
index d6de5b5..ce95dfc 100644
--- a/include/asm-nios2/bits/timer.h
+++ b/include/asm-nios2/bits/timer.h
@@ -26,9 +26,14 @@
 
 static inline void xnarch_program_timer_shot(unsigned long delay)
 {
+#if !defined(CONFIG_IPIPE_CORE) || IPIPE_CORE_APIREV < 2
+
        unsigned long d;
        d = rthal_imuldiv_ceil(delay, RTHAL_TIMER_FREQ, RTHAL_CLOCK_FREQ);
        rthal_timer_program_shot(d);
+#else
+       rthal_timer_program_shot(delay);
+#endif
 }
 
 static inline void xnarch_send_timer_ipi(xnarch_cpumask_t mask)
diff --git a/include/asm-powerpc/bits/timer.h b/include/asm-powerpc/bits/timer.h
index bfea7a6..b73a514 100644
--- a/include/asm-powerpc/bits/timer.h
+++ b/include/asm-powerpc/bits/timer.h
@@ -29,6 +29,7 @@
 
 static inline void xnarch_program_timer_shot(unsigned long delay)
 {
+#if !defined(CONFIG_IPIPE_CORE) || IPIPE_CORE_APIREV < 2
        /*
         * Even though some architectures may use a 64 bits delay
         * here, we voluntarily limit to 32 bits, 4 billions ticks
@@ -38,6 +39,9 @@ static inline void xnarch_program_timer_shot(unsigned long 
delay)
         */
        rthal_timer_program_shot(rthal_imuldiv_ceil
                                 (delay, RTHAL_TIMER_FREQ, RTHAL_CLOCK_FREQ));
+#else
+       rthal_timer_program_shot(delay)
+#endif
 }
 
 static inline void xnarch_send_timer_ipi(xnarch_cpumask_t mask)
diff --git a/include/asm-sh/bits/timer.h b/include/asm-sh/bits/timer.h
index c8af46d..d8e7981 100644
--- a/include/asm-sh/bits/timer.h
+++ b/include/asm-sh/bits/timer.h
@@ -26,9 +26,13 @@
 
 static inline void xnarch_program_timer_shot(unsigned long delay)
 {
+#if !defined(CONFIG_IPIPE_CORE) || IPIPE_CORE_APIREV < 2
        unsigned long d;
        d = rthal_imuldiv_ceil(delay, RTHAL_TIMER_FREQ, RTHAL_CLOCK_FREQ);
        rthal_timer_program_shot(d);
+#else
+       rthal_timer_program_shot(delay);
+#endif
 }
 
 static inline void xnarch_send_timer_ipi(xnarch_cpumask_t mask)
diff --git a/include/asm-x86/bits/timer.h b/include/asm-x86/bits/timer.h
index 9e9b863..a0cfa02 100644
--- a/include/asm-x86/bits/timer.h
+++ b/include/asm-x86/bits/timer.h
@@ -26,6 +26,7 @@
 
 static inline void xnarch_program_timer_shot(unsigned long delay)
 {
+#if !defined(CONFIG_IPIPE_CORE) || IPIPE_CORE_APIREV < 2
        /*
         * Even though we may use a 64 bits delay here, we voluntarily
         * limit to 32 bits, 4 billions ticks should be enough for
@@ -34,6 +35,9 @@ static inline void xnarch_program_timer_shot(unsigned long 
delay)
         */
        rthal_timer_program_shot(rthal_imuldiv_ceil
                                 (delay, RTHAL_TIMER_FREQ, RTHAL_CPU_FREQ));
+#else
+       rthal_timer_program_shot(delay);
+#endif
 }
 
 static inline void xnarch_send_timer_ipi(xnarch_cpumask_t mask)
diff --git a/ksrc/arch/arm/hal.c b/ksrc/arch/arm/hal.c
index 7db1288..cfa243c 100644
--- a/ksrc/arch/arm/hal.c
+++ b/ksrc/arch/arm/hal.c
@@ -49,8 +49,6 @@
 #endif /* CONFIG_PROC_FS */
 #include <stdarg.h>
 
-rthal_u32frac_t rthal_tsc_to_timer;
-EXPORT_SYMBOL_GPL(rthal_tsc_to_timer);
 
 #define RTHAL_CALIBRATE_LOOPS 10
 
@@ -65,6 +63,11 @@ static int cpu_timers_requested;
 
 #ifdef CONFIG_IPIPE_CORE
 
+#if IPIPE_CORE_APIREV < 2
+rthal_u32frac_t rthal_tsc_to_timer;
+EXPORT_SYMBOL_GPL(rthal_tsc_to_timer);
+#endif
+
 #define steal_timer(stolen) do { } while (0)
 #define force_oneshot_hw_mode() do { } while (0)
 #define restore_normal_hw_mode() do { } while (0)
@@ -72,7 +75,7 @@ static int cpu_timers_requested;
 #define rthal_timer_set_periodic() do { } while (0)
 
 #define rthal_tickdev_select() \
-       ipipe_timers_request()
+       wrap_ipipe_timers_request(&rthal_supported_cpus)
 
 #define rthal_tickdev_unselect() \
        ipipe_timers_release()
@@ -88,6 +91,9 @@ static int cpu_timers_requested;
 
 #else /* !I-pipe core */
 
+rthal_u32frac_t rthal_tsc_to_timer;
+EXPORT_SYMBOL_GPL(rthal_tsc_to_timer);
+
 #define RTHAL_SET_ONESHOT_XENOMAI      1
 #define RTHAL_SET_ONESHOT_LINUX                2
 #define RTHAL_SET_PERIODIC             3
@@ -193,7 +199,7 @@ static void rthal_timer_set_periodic(void)
 unsigned long rthal_timer_calibrate(void)
 {
        unsigned long long start, end, sum = 0, sum_sq = 0;
-       volatile unsigned const_delay = rthal_timerfreq_arg / HZ;
+       volatile unsigned const_delay = rthal_clockfreq_arg / HZ;
        unsigned long result, flags, tsc_lat;
        unsigned int delay = const_delay;
        long long diff;
@@ -221,8 +227,12 @@ unsigned long rthal_timer_calibrate(void)
                for (j = 0; j < RTHAL_CALIBRATE_LOOPS; j++) {
                        rthal_read_tsc(start);
                        barrier();
+#if !defined(CONFIG_IPIPE_CORE) || IPIPE_CORE_APIREV < 2
                        rthal_timer_program_shot(
                                rthal_nodiv_imuldiv_ceil(delay, 
rthal_tsc_to_timer));
+#else
+                       rthal_timer_program_shot(delay);
+#endif
                        barrier();
                        rthal_read_tsc(end);
                        diff = end - start - tsc_lat;
@@ -541,8 +551,10 @@ int rthal_arch_init(void)
        if (rthal_clockfreq_arg == 0)
                rthal_clockfreq_arg = rthal_get_clockfreq();
 
+#if !defined(CONFIG_IPIPE_CORE) || IPIPE_CORE_APIREV < 2
        xnarch_init_u32frac(&rthal_tsc_to_timer,
                            rthal_timerfreq_arg, rthal_clockfreq_arg);
+#endif
 
        return 0;
 }
diff --git a/ksrc/arch/blackfin/hal.c b/ksrc/arch/blackfin/hal.c
index 9d64be8..ad203a2 100644
--- a/ksrc/arch/blackfin/hal.c
+++ b/ksrc/arch/blackfin/hal.c
@@ -53,7 +53,7 @@ enum rthal_ktimer_mode rthal_ktimer_saved_mode;
 #ifdef CONFIG_IPIPE_CORE
 
 #define rthal_tickdev_select() \
-       ipipe_timers_request()
+       wrap_ipipe_timers_request(&rthal_supported_cpus)
 
 #define rthal_tickdev_unselect() \
        ipipe_timers_release()
diff --git a/ksrc/arch/generic/hal.c b/ksrc/arch/generic/hal.c
index 6453f45..3199792 100644
--- a/ksrc/arch/generic/hal.c
+++ b/ksrc/arch/generic/hal.c
@@ -535,22 +535,19 @@ static inline void cleanup_apc_handler(void) { }
 int rthal_init(void)
 {
     int err;
+#ifdef CONFIG_SMP
+    int cpu;
+    cpus_clear(rthal_supported_cpus);
+    for (cpu = 0; cpu < BITS_PER_LONG; cpu++)
+           if (supported_cpus_arg & (1 << cpu))
+                   cpu_set(cpu, rthal_supported_cpus);
+#endif /* CONFIG_SMP */
 
     err = rthal_arch_init();
 
     if (err)
        goto out;
 
-#ifdef CONFIG_SMP
-    {
-       int cpu;
-       cpus_clear(rthal_supported_cpus);
-       for (cpu = 0; cpu < BITS_PER_LONG; cpu++)
-           if (supported_cpus_arg & (1 << cpu))
-               cpu_set(cpu, rthal_supported_cpus);
-    }
-#endif /* CONFIG_SMP */
-
     /*
      * The arch-dependent support must have updated the various
      * frequency args as required.
diff --git a/ksrc/arch/powerpc/hal.c b/ksrc/arch/powerpc/hal.c
index 6f58b3a..a3b2270 100644
--- a/ksrc/arch/powerpc/hal.c
+++ b/ksrc/arch/powerpc/hal.c
@@ -138,7 +138,7 @@ static inline void rthal_tickdev_release(int cpu)
 
 static inline int rthal_tickdev_select(void)
 {
-       return ipipe_timers_request();
+       return wrap_ipipe_timers_request(&rthal_supported_cpus);
 }
 
 #else /* !CONFIG_IPIPE_CORE */
diff --git a/ksrc/arch/x86/hal_32.c b/ksrc/arch/x86/hal_32.c
index 1221065..f009642 100644
--- a/ksrc/arch/x86/hal_32.c
+++ b/ksrc/arch/x86/hal_32.c
@@ -342,7 +342,7 @@ rthal_time_t rthal_get_8254_tsc(void)
 int rthal_arch_init(void)
 {
 #ifdef CONFIG_IPIPE_CORE
-       int rc = ipipe_timers_request();
+       int rc = wrap_ipipe_timers_request(&rthal_supported_cpus);
        if (rc < 0)
                return rc;
 #else /* !I-pipe core */
diff --git a/ksrc/arch/x86/hal_64.c b/ksrc/arch/x86/hal_64.c
index b0ef716..ea6a508 100644
--- a/ksrc/arch/x86/hal_64.c
+++ b/ksrc/arch/x86/hal_64.c
@@ -81,7 +81,7 @@ unsigned long rthal_timer_calibrate(void)
 int rthal_arch_init(void)
 {
 #ifdef CONFIG_IPIPE_CORE
-       int rc = ipipe_timers_request();
+       int rc = wrap_ipipe_timers_request(&rthal_supported_cpus);
        if (rc < 0)
                return rc;
 #endif /* I-pipe core */


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

Reply via email to