Module: xenomai-rpm
Branch: for-upstream
Commit: 85bf021fcf8c5b1d604635271e9fce07611eab61
URL:    
http://git.xenomai.org/?p=xenomai-rpm.git;a=commit;h=85bf021fcf8c5b1d604635271e9fce07611eab61

Author: Philippe Gerum <r...@xenomai.org>
Date:   Sun Mar  7 16:29:04 2010 +0100

timeconv: init time conversion helper with hrclock frequency

The nucleus relies on the high-resolution clock frequency value
returned by ipipe_get_sysinfo() when SYSINFO v2 support is available
from the underlying pipeline patch.

1e9/hrclock_freq is the time unit used to express delays internally,
which is rescaled to timer ticks when programming the hardware
timer. The legacy implementation based on SYSINFO v1 would express
them as 1e9/cpufreq instead, relying on a bad misnomer between CPU and
hrclock frequencies leaking from older pipeline code.

This patch propagates the proper timeconv init value to user-space,
fixing a bug affecting nios2, which is fortunately the only SYSINFO v2
enabled architecture so far.

---

 include/asm-generic/syscall.h |    2 +-
 include/asm-generic/system.h  |    5 +++++
 ksrc/nucleus/shadow.c         |    2 +-
 src/skins/common/timeconv.c   |   14 +++++++-------
 4 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/include/asm-generic/syscall.h b/include/asm-generic/syscall.h
index 315822e..c3cefdd 100644
--- a/include/asm-generic/syscall.h
+++ b/include/asm-generic/syscall.h
@@ -51,7 +51,7 @@
 #define XENOMAI_XENO_DOMAIN   1
 
 typedef struct xnsysinfo {
-       unsigned long long cpufreq;     /* CPU frequency */
+       unsigned long long clockfreq;   /* Real-time clock frequency */
        unsigned long tickval;          /* Tick duration (ns) */
        unsigned long vdso;             /* Offset of nkvdso in the sem heap */
 } xnsysinfo_t;
diff --git a/include/asm-generic/system.h b/include/asm-generic/system.h
index bff7140..a2c8fb9 100644
--- a/include/asm-generic/system.h
+++ b/include/asm-generic/system.h
@@ -290,6 +290,11 @@ static inline unsigned long long xnarch_get_cpu_freq(void)
        return RTHAL_CPU_FREQ;
 }
 
+static inline unsigned long long xnarch_get_clock_freq(void)
+{
+       return RTHAL_CLOCK_FREQ;
+}
+
 #define xnarch_get_cpu_tsc                     rthal_rdtsc
 
 #define xnarch_halt(emsg)                              \
diff --git a/ksrc/nucleus/shadow.c b/ksrc/nucleus/shadow.c
index d82d6c7..d5e5539 100644
--- a/ksrc/nucleus/shadow.c
+++ b/ksrc/nucleus/shadow.c
@@ -1759,7 +1759,7 @@ static int xnshadow_sys_info(struct pt_regs *regs)
 
        xnlock_put_irqrestore(&nklock, s);
 
-       info.cpufreq = xnarch_get_cpu_freq();
+       info.clockfreq = xnarch_get_clock_freq();
 
        info.vdso =
                xnheap_mapped_offset(&xnsys_ppd_get(1)->sem_heap, nkvdso);
diff --git a/src/skins/common/timeconv.c b/src/skins/common/timeconv.c
index 931c5eb..e7f7ebe 100644
--- a/src/skins/common/timeconv.c
+++ b/src/skins/common/timeconv.c
@@ -25,25 +25,25 @@
 #include <asm/xenomai/syscall.h>
 #include <asm-generic/xenomai/bits/timeconv.h>
 
-static unsigned long long xeno_cpufreq;
+static unsigned long long hrclock_freq;
 
 static void xeno_init_timeconv_inner(void)
 {
-       xnarch_init_timeconv(xeno_cpufreq);
+       xnarch_init_timeconv(hrclock_freq);
 }
 
 void xeno_init_timeconv(int muxid)
 {
        static pthread_once_t init_timeconv_once = PTHREAD_ONCE_INIT;
        xnsysinfo_t sysinfo;
-       int err;
+       int ret;
 
-       err = XENOMAI_SYSCALL2(__xn_sys_info, muxid, &sysinfo);
-       if (err) {
+       ret = XENOMAI_SYSCALL2(__xn_sys_info, muxid, &sysinfo);
+       if (ret) {
                fprintf(stderr, "Xenomai: sys_info failed: %s\n",
-                       strerror(-err));
+                       strerror(-ret));
                exit(EXIT_FAILURE);
        }
-       xeno_cpufreq = sysinfo.cpufreq;
+       hrclock_freq = sysinfo.clockfreq;
        pthread_once(&init_timeconv_once, &xeno_init_timeconv_inner);
 }


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

Reply via email to