[Xenomai-git] Gilles Chanteperdrix : cobalt/mqueue: use rtdm fd flags

2014-10-25 Thread git repository hosting
Module: xenomai-gch
Branch: for-forge
Commit: 80190d3a2bd5a7e4269c0d5937558ac01df6b251
URL:
http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=80190d3a2bd5a7e4269c0d5937558ac01df6b251

Author: Gilles Chanteperdrix 
Date:   Sat Oct 25 21:52:07 2014 +0200

cobalt/mqueue: use rtdm fd flags

---

 include/cobalt/uapi/syscall.h |2 +-
 kernel/cobalt/posix/mqueue.c  |   79 +
 kernel/cobalt/posix/syscall.c |2 --
 lib/cobalt/mq.c   |   19 --
 4 files changed, 27 insertions(+), 75 deletions(-)

diff --git a/include/cobalt/uapi/syscall.h b/include/cobalt/uapi/syscall.h
index 025d2ff..0f74f37 100644
--- a/include/cobalt/uapi/syscall.h
+++ b/include/cobalt/uapi/syscall.h
@@ -63,7 +63,7 @@
 #define sc_cobalt_mq_close 40
 #define sc_cobalt_mq_unlink41
 #define sc_cobalt_mq_getattr   42
-#define sc_cobalt_mq_setattr   43
+/* 43 unimp */
 #define sc_cobalt_mq_timedsend 44
 #define sc_cobalt_mq_timedreceive  45
 #define sc_cobalt_mq_notify46
diff --git a/kernel/cobalt/posix/mqueue.c b/kernel/cobalt/posix/mqueue.c
index f5a69f9..5d17ec7 100644
--- a/kernel/cobalt/posix/mqueue.c
+++ b/kernel/cobalt/posix/mqueue.c
@@ -31,7 +31,7 @@
 
 #define COBALT_MSGMAX  65536
 #define COBALT_MSGSIZEMAX  (16*1024*1024)
-#define COBALT_MSGPRIOMAX  32768
+#define COBALT_MSGPRIOMAX  32768
 
 struct cobalt_mq {
unsigned magic;
@@ -62,7 +62,6 @@ struct cobalt_mq {
 };
 
 struct cobalt_mqd {
-   long flags;
struct cobalt_mq *mq;
struct rtdm_fd fd;
 };
@@ -228,7 +227,7 @@ mqd_select(struct rtdm_fd *fd, struct xnselector *selector,
switch(type) {
case XNSELECT_READ:
err = -EBADF;
-   if ((mqd->flags & COBALT_PERMS_MASK) == O_WRONLY)
+   if ((rtdm_fd_flags(fd) & COBALT_PERMS_MASK) == O_WRONLY)
goto unlock_and_error;
 
err = xnselect_bind(&mq->read_select, binding,
@@ -240,7 +239,7 @@ mqd_select(struct rtdm_fd *fd, struct xnselector *selector,
 
case XNSELECT_WRITE:
err = -EBADF;
-   if ((mqd->flags & COBALT_PERMS_MASK) == O_RDONLY)
+   if ((rtdm_fd_flags(fd) & COBALT_PERMS_MASK) == O_RDONLY)
goto unlock_and_error;
 
err = xnselect_bind(&mq->write_select, binding,
@@ -275,7 +274,7 @@ static inline int mqd_create(struct cobalt_mq *mq, unsigned 
long flags, int ufd)
if (mqd == NULL)
return -ENOSPC;
 
-   mqd->flags = flags;
+   mqd->fd.oflags = flags;
mqd->mq = mq;
 
return rtdm_fd_enter(&mqd->fd, ufd, COBALT_MQD_MAGIC, &mqd_ops);
@@ -416,7 +415,7 @@ mq_trysend(struct cobalt_mqd *mqd, size_t len)
unsigned flags;
 
mq = mqd->mq;
-   flags = mqd->flags & COBALT_PERMS_MASK;
+   flags = rtdm_fd_flags(&mqd->fd) & COBALT_PERMS_MASK;
 
if (flags != O_WRONLY && flags != O_RDWR)
return ERR_PTR(-EBADF);
@@ -442,7 +441,7 @@ mq_tryrcv(struct cobalt_mqd *mqd, size_t len)
struct cobalt_mq *mq;
 
mq = mqd->mq;
-   flags = mqd->flags & COBALT_PERMS_MASK;
+   flags = rtdm_fd_flags(&mqd->fd) & COBALT_PERMS_MASK;
 
if (flags != O_RDONLY && flags != O_RDWR)
return ERR_PTR(-EBADF);
@@ -485,7 +484,7 @@ redo:
if (msg != ERR_PTR(-EAGAIN))
goto out;
 
-   if (mqd->flags & O_NONBLOCK)
+   if (rtdm_fd_flags(&mqd->fd) & O_NONBLOCK)
goto out;
 
if (fetch_timeout) {
@@ -614,7 +613,7 @@ redo:
if (msg != ERR_PTR(-EAGAIN))
goto out;
 
-   if (mqd->flags & O_NONBLOCK)
+   if (rtdm_fd_flags(&mqd->fd) & O_NONBLOCK)
goto out;
 
if (fetch_timeout) {
@@ -668,36 +667,13 @@ static inline int mq_getattr(struct cobalt_mqd *mqd, 
struct mq_attr *attr)
mq = mqd->mq;
*attr = mq->attr;
xnlock_get_irqsave(&nklock, s);
-   attr->mq_flags = mqd->flags;
+   attr->mq_flags = rtdm_fd_flags(&mqd->fd);
attr->mq_curmsgs = mq->nrqueued;
xnlock_put_irqrestore(&nklock, s);
 
return 0;
 }
 
-static inline int mq_setattr(struct cobalt_mqd *mqd,
-const struct mq_attr *__restrict__ attr,
-struct mq_attr *__restrict__ oattr)
-{
-   struct cobalt_mq *mq;
-   long flags;
-   spl_t s;
-
-   xnlock_get_irqsave(&nklock, s);
-   mq = mqd->mq;
-   if (oattr) {
-   *oattr = mq->attr;
-   oattr->mq_flags = mqd->flags;
-   oattr->mq_curmsgs = mq->nrqueued;
-   }
-   flags = (mqd->flags & COBALT_PERMS_MASK)
-   | (attr->mq_flags & ~COBALT_PERMS_MASK);
-   mqd->flags = flags;
-   xnlock_put_irqrestore(&nklock, s);
-
-   return 0;
-}
-
 static inline int
 mq_noti

[Xenomai-git] Gilles Chanteperdrix : cobalt/spinlocks: rebase on linux spinlocks

2014-10-25 Thread git repository hosting
Module: xenomai-gch
Branch: for-forge
Commit: 75431f17f45f61425de7e4c809536f11722eb4d2
URL:
http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=75431f17f45f61425de7e4c809536f11722eb4d2

Author: Gilles Chanteperdrix 
Date:   Sun Oct 19 21:43:37 2014 +0200

cobalt/spinlocks: rebase on linux spinlocks

---

 include/cobalt/kernel/lock.h |   35 ++-
 kernel/cobalt/debug.c|2 +-
 kernel/cobalt/lock.c |   15 ---
 3 files changed, 19 insertions(+), 33 deletions(-)

diff --git a/include/cobalt/kernel/lock.h b/include/cobalt/kernel/lock.h
index b0c34bf..e590b85 100644
--- a/include/cobalt/kernel/lock.h
+++ b/include/cobalt/kernel/lock.h
@@ -66,7 +66,8 @@ typedef unsigned long spl_t;
 #if XENO_DEBUG(LOCKING)
 
 struct xnlock {
-   atomic_t owner;
+   unsigned owner;
+   arch_spinlock_t alock;
const char *file;
const char *function;
unsigned int line;
@@ -84,7 +85,8 @@ struct xnlockinfo {
 };
 
 #define XNARCH_LOCK_UNLOCKED (struct xnlock) { \
-   { ~0 }, \
+   ~0, \
+   __ARCH_SPIN_LOCK_UNLOCKED,  \
NULL,   \
NULL,   \
0,  \
@@ -117,10 +119,15 @@ DECLARE_PER_CPU(struct xnlockinfo, xnlock_stats);
 #else /* !XENO_DEBUG(LOCKING) */
 
 struct xnlock {
-   atomic_t owner;
+   unsigned owner;
+   arch_spinlock_t alock;
 };
 
-#define XNARCH_LOCK_UNLOCKED   (struct xnlock) { { ~0 } }
+#define XNARCH_LOCK_UNLOCKED   \
+   (struct xnlock) {   \
+   ~0, \
+   __ARCH_SPIN_LOCK_UNLOCKED,  \
+   }
 
 #define XNLOCK_DBG_CONTEXT
 #define XNLOCK_DBG_CONTEXT_ARGS
@@ -175,20 +182,18 @@ static inline void xnlock_init (struct xnlock *lock)
 #define DEFINE_XNLOCK(lock)struct xnlock lock = 
XNARCH_LOCK_UNLOCKED
 #define DEFINE_PRIVATE_XNLOCK(lock)static DEFINE_XNLOCK(lock)
 
-void __xnlock_spin(int cpu, struct xnlock *lock /*, */ 
XNLOCK_DBG_CONTEXT_ARGS);
-
 static inline int xnlock_get(struct xnlock *lock /*, */ 
XNLOCK_DBG_CONTEXT_ARGS)
 {
int cpu = ipipe_processor_id();
unsigned long long start;
 
-   if (atomic_read(&lock->owner) == cpu)
+   if (lock->owner == cpu)
return 2;
 
xnlock_dbg_prepare_acquire(&start);
 
-   if (unlikely(atomic_cmpxchg(&lock->owner, ~0, cpu) != ~0))
-   __xnlock_spin(cpu, lock /*, */ XNLOCK_DBG_PASS_CONTEXT);
+   arch_spin_lock(&lock->alock);
+   lock->owner = cpu;
 
xnlock_dbg_acquired(lock, cpu, &start /*, */ XNLOCK_DBG_PASS_CONTEXT);
 
@@ -200,12 +205,8 @@ static inline void xnlock_put(struct xnlock *lock /*, 
*/ XNLOCK_DBG_CONTEXT_
if (xnlock_dbg_release(lock /*, */ XNLOCK_DBG_PASS_CONTEXT))
return;
 
-   /*
-* Make sure all data written inside the lock is visible to
-* other CPUs before we release the lock.
-*/
-   mb();
-   atomic_set(&lock->owner, ~0);
+   lock->owner = ~0U;
+   arch_spin_unlock(&lock->alock);
 }
 
 #ifndef CONFIG_XENO_ARCH_OUTOFLINE_XNLOCK
@@ -250,7 +251,7 @@ static inline void __xnlock_put_irqrestore(struct xnlock 
*lock, spl_t flags
 static inline int xnlock_is_owner(struct xnlock *lock)
 {
if (__locking_active__)
-   return atomic_read(&lock->owner) == ipipe_processor_id();
+   return lock->owner == ipipe_processor_id();
 
return 1;
 }
@@ -266,7 +267,7 @@ static inline int __xnlock_get(struct xnlock *lock /*, */ 
XNLOCK_DBG_CONTEXT_ARG
 static inline void __xnlock_put(struct xnlock *lock /*, */ 
XNLOCK_DBG_CONTEXT_ARGS)
 {
if (__locking_active__)
-   ___xnlock_put(lock /*, */ XNLOCK_DBG_PASS_CONTEXT); 
+   ___xnlock_put(lock /*, */ XNLOCK_DBG_PASS_CONTEXT);
 }
 
 #undef __locking_active__
diff --git a/kernel/cobalt/debug.c b/kernel/cobalt/debug.c
index ad72a3e..ef46e0b 100644
--- a/kernel/cobalt/debug.c
+++ b/kernel/cobalt/debug.c
@@ -598,7 +598,7 @@ int xnlock_dbg_release(struct xnlock *lock,
lock->function = "invalid";
}
 
-   if (unlikely(atomic_read(&lock->owner) != cpu)) {
+   if (unlikely(lock->owner != cpu)) {
ipipe_prepare_panic();
printk(XENO_ERR "lock %p already unlocked on CPU #%d\n"
"  last owner = %s:%u (%s(), CPU 
#%d)\n",
diff --git a/kernel/cobalt/lock.c b/kernel/cobalt/lock.c
index 5c339b5..a1b2e37 100644
--- a/kernel/cobalt/lock.c
+++ b/kernel/cobalt/lock.c
@@ -42,21 +42,6 @@ DEFINE_XNLOCK(nklock);
 #if defined(CONFIG_SMP) || XENO_DEBUG(LOCKING)
 EXPORT_SYMBOL_GPL(nklock);
 
-void __xnlock_spin(int cpu, struct xnlock *lock /*, */ XNLOCK_DBG_CONTEXT_ARGS)
-{
-   unsigned int spin_li

[Xenomai-git] Gilles Chanteperdrix : cobalt/rtdm: add fcntl syscall

2014-10-25 Thread git repository hosting
Module: xenomai-gch
Branch: for-forge
Commit: a75970033d9c6e3ac9f8099dbcfc0de8eee798d7
URL:
http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=a75970033d9c6e3ac9f8099dbcfc0de8eee798d7

Author: Gilles Chanteperdrix 
Date:   Sat Oct 25 21:11:16 2014 +0200

cobalt/rtdm: add fcntl syscall

---

 include/cobalt/fcntl.h|2 +
 include/cobalt/kernel/rtdm/fd.h   |2 +
 include/cobalt/kernel/rtdm/rtdm.h |3 +
 include/cobalt/uapi/syscall.h |  133 +++--
 kernel/cobalt/posix/io.c  |6 ++
 kernel/cobalt/posix/io.h  |2 +
 kernel/cobalt/posix/syscall.c |   10 +--
 kernel/cobalt/rtdm/fd.c   |   42 +++-
 lib/cobalt/rtdm.c |   18 +
 lib/cobalt/wrappers.c |   13 
 10 files changed, 158 insertions(+), 73 deletions(-)

diff --git a/include/cobalt/fcntl.h b/include/cobalt/fcntl.h
index ed96dd7..2a83a7a 100644
--- a/include/cobalt/fcntl.h
+++ b/include/cobalt/fcntl.h
@@ -29,6 +29,8 @@ extern "C" {
 
 COBALT_DECL(int, open(const char *path, int oflag, ...));
 
+COBALT_DECL(int, fcntl(int fd, int cmd, ...));
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/include/cobalt/kernel/rtdm/fd.h b/include/cobalt/kernel/rtdm/fd.h
index ccf0332..5685b3a 100644
--- a/include/cobalt/kernel/rtdm/fd.h
+++ b/include/cobalt/kernel/rtdm/fd.h
@@ -353,6 +353,8 @@ void rtdm_fd_put(struct rtdm_fd *fd);
 
 void rtdm_fd_unlock(struct rtdm_fd *fd);
 
+int rtdm_fd_fcntl(int ufd, int cmd, ...);
+
 int rtdm_fd_ioctl(int ufd, unsigned int request, ...);
 
 ssize_t rtdm_fd_read(int ufd, void __user *buf, size_t size);
diff --git a/include/cobalt/kernel/rtdm/rtdm.h 
b/include/cobalt/kernel/rtdm/rtdm.h
index db1e270..2b1c8fd 100644
--- a/include/cobalt/kernel/rtdm/rtdm.h
+++ b/include/cobalt/kernel/rtdm/rtdm.h
@@ -50,6 +50,9 @@ int __rtdm_dev_socket(int protocol_family,
 #define rt_dev_close(fd)   \
rtdm_fd_close(fd, RTDM_FD_MAGIC)
 
+#define rt_dev_fcntl(fd, cmd, ...) \
+   rtdm_fd_fcntl(fd,cmd, __VA_ARGS__)
+
 #define rt_dev_ioctl(fd, request, ...) \
rtdm_fd_ioctl(fd, request, __VA_ARGS__)
 
diff --git a/include/cobalt/uapi/syscall.h b/include/cobalt/uapi/syscall.h
index aa364a1..025d2ff 100644
--- a/include/cobalt/uapi/syscall.h
+++ b/include/cobalt/uapi/syscall.h
@@ -21,63 +21,63 @@
 #include 
 
 #define sc_cobalt_bind 0
-#define sc_cobalt_thread_create1
-#define sc_cobalt_thread_getpid2
-#define sc_cobalt_thread_setmode   3
-#define sc_cobalt_thread_setname   4
-#define sc_cobalt_thread_join  5
-#define sc_cobalt_thread_kill  6
+#define sc_cobalt_thread_create1
+#define sc_cobalt_thread_getpid2
+#define sc_cobalt_thread_setmode   3
+#define sc_cobalt_thread_setname   4
+#define sc_cobalt_thread_join  5
+#define sc_cobalt_thread_kill  6
 #define sc_cobalt_thread_setschedparam_ex  7
 #define sc_cobalt_thread_getschedparam_ex  8
-#define sc_cobalt_thread_getstat   9
+#define sc_cobalt_thread_getstat   9
 /* 10 unimp */
-#define sc_cobalt_sem_init 11
-#define sc_cobalt_sem_destroy  12
-#define sc_cobalt_sem_post 13
-#define sc_cobalt_sem_wait 14
-#define sc_cobalt_sem_trywait  15
-#define sc_cobalt_sem_getvalue 16
-#define sc_cobalt_sem_open 17
-#define sc_cobalt_sem_close18
-#define sc_cobalt_sem_unlink   19
-#define sc_cobalt_sem_timedwait20
-#define sc_cobalt_sem_inquire  21
+#define sc_cobalt_sem_init 11
+#define sc_cobalt_sem_destroy  12
+#define sc_cobalt_sem_post 13
+#define sc_cobalt_sem_wait 14
+#define sc_cobalt_sem_trywait  15
+#define sc_cobalt_sem_getvalue 16
+#define sc_cobalt_sem_open 17
+#define sc_cobalt_sem_close18
+#define sc_cobalt_sem_unlink   19
+#define sc_cobalt_sem_timedwait20
+#define sc_cobalt_sem_inquire  21
 /* 22 unimp */
-#define sc_cobalt_sem_broadcast_np 23
-#define sc_cobalt_clock_getres 24
-#define sc_cobalt_clock_gettime25
-#define sc_cobalt_clock_settime26
-#define sc_cobalt_clock_nanosleep  27
-#define sc_cobalt_mutex_init   28
-#define sc_cobalt_mutex_check_init 29
-#define sc_cobalt_mutex_destroy30
-#define sc_cobalt_mutex_lock   31
-#define sc_cobalt_mutex_timedlock  32
-#define sc_cobalt_mutex_tryloc

[Xenomai-git] Gilles Chanteperdrix : lib/cobalt: wrap time and gettimeofday calls

2014-10-25 Thread git repository hosting
Module: xenomai-gch
Branch: for-forge
Commit: 8d79307f9bc02d363791f998150d8e4fb2195061
URL:
http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=8d79307f9bc02d363791f998150d8e4fb2195061

Author: Gilles Chanteperdrix 
Date:   Sat Sep 20 23:06:02 2014 +0200

lib/cobalt: wrap time and gettimeofday calls

---

 include/cobalt/time.h   |2 ++
 lib/cobalt/assert_context.c |7 ---
 lib/cobalt/clock.c  |   23 +++
 lib/cobalt/cobalt.wrappers  |1 +
 4 files changed, 26 insertions(+), 7 deletions(-)

diff --git a/include/cobalt/time.h b/include/cobalt/time.h
index c5d7412..fed8957 100644
--- a/include/cobalt/time.h
+++ b/include/cobalt/time.h
@@ -44,6 +44,8 @@ COBALT_DECL(int, clock_nanosleep(clockid_t clock_id,
 const struct timespec *rqtp,
 struct timespec *rmtp));
 
+COBALT_DECL(time_t, time(time_t *t));
+
 COBALT_DECL(int, nanosleep(const struct timespec *rqtp,
   struct timespec *rmtp));
 
diff --git a/lib/cobalt/assert_context.c b/lib/cobalt/assert_context.c
index 6b49f3d..48690dc 100644
--- a/lib/cobalt/assert_context.c
+++ b/lib/cobalt/assert_context.c
@@ -75,10 +75,3 @@ COBALT_IMPL(void, free, (void *ptr))
assert_nrt();
__STD(free(ptr));
 }
-
-/* vsyscall-based services */
-COBALT_IMPL(int, gettimeofday, (struct timeval *tv, struct timezone *tz))
-{
-   assert_nrt();
-   return __STD(gettimeofday(tv, tz));
-}
diff --git a/lib/cobalt/clock.c b/lib/cobalt/clock.c
index b31517f..d17ea56 100644
--- a/lib/cobalt/clock.c
+++ b/lib/cobalt/clock.c
@@ -25,6 +25,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -356,4 +357,26 @@ COBALT_IMPL(unsigned int, sleep, (unsigned int seconds))
return 0;
 }
 
+COBALT_IMPL(int, gettimeofday, (struct timeval *tv, struct timezone *tz))
+{
+   struct timespec ts;
+   int ret = __WRAP(clock_gettime(CLOCK_REALTIME, &ts));
+   if (ret == 0) {
+   tv->tv_sec = ts.tv_sec;
+   tv->tv_usec = ts.tv_nsec / 1000;
+   }
+   return ret;
+}
+
+COBALT_IMPL(time_t, time, (time_t *t))
+{
+   struct timespec ts;
+   int ret = __WRAP(clock_gettime(CLOCK_REALTIME, &ts));
+   if (ret)
+   return (time_t)-1;
+
+   if (t)
+   *t = ts.tv_sec;
+   return ts.tv_sec;
+}
 /** @} */
diff --git a/lib/cobalt/cobalt.wrappers b/lib/cobalt/cobalt.wrappers
index 10cb36a..329ff3b 100644
--- a/lib/cobalt/cobalt.wrappers
+++ b/lib/cobalt/cobalt.wrappers
@@ -104,3 +104,4 @@
 --wrap kill
 --wrap sleep
 --wrap mmap
+--wrap time


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


[Xenomai-git] Gilles Chanteperdrix : cobalt/mqueue: use rtdm fd flags

2014-10-25 Thread git repository hosting
Module: xenomai-gch
Branch: for-forge
Commit: 10131f2e6095945bb336616c2775503c2a2e3cd1
URL:
http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=10131f2e6095945bb336616c2775503c2a2e3cd1

Author: Gilles Chanteperdrix 
Date:   Sat Oct 25 21:52:07 2014 +0200

cobalt/mqueue: use rtdm fd flags

---

 include/cobalt/uapi/syscall.h |2 +-
 kernel/cobalt/posix/mqueue.c  |   79 +
 kernel/cobalt/posix/syscall.c |2 --
 lib/cobalt/mq.c   |   19 --
 4 files changed, 27 insertions(+), 75 deletions(-)

diff --git a/include/cobalt/uapi/syscall.h b/include/cobalt/uapi/syscall.h
index 025d2ff..0f74f37 100644
--- a/include/cobalt/uapi/syscall.h
+++ b/include/cobalt/uapi/syscall.h
@@ -63,7 +63,7 @@
 #define sc_cobalt_mq_close 40
 #define sc_cobalt_mq_unlink41
 #define sc_cobalt_mq_getattr   42
-#define sc_cobalt_mq_setattr   43
+/* 43 unimp */
 #define sc_cobalt_mq_timedsend 44
 #define sc_cobalt_mq_timedreceive  45
 #define sc_cobalt_mq_notify46
diff --git a/kernel/cobalt/posix/mqueue.c b/kernel/cobalt/posix/mqueue.c
index f5a69f9..5d17ec7 100644
--- a/kernel/cobalt/posix/mqueue.c
+++ b/kernel/cobalt/posix/mqueue.c
@@ -31,7 +31,7 @@
 
 #define COBALT_MSGMAX  65536
 #define COBALT_MSGSIZEMAX  (16*1024*1024)
-#define COBALT_MSGPRIOMAX  32768
+#define COBALT_MSGPRIOMAX  32768
 
 struct cobalt_mq {
unsigned magic;
@@ -62,7 +62,6 @@ struct cobalt_mq {
 };
 
 struct cobalt_mqd {
-   long flags;
struct cobalt_mq *mq;
struct rtdm_fd fd;
 };
@@ -228,7 +227,7 @@ mqd_select(struct rtdm_fd *fd, struct xnselector *selector,
switch(type) {
case XNSELECT_READ:
err = -EBADF;
-   if ((mqd->flags & COBALT_PERMS_MASK) == O_WRONLY)
+   if ((rtdm_fd_flags(fd) & COBALT_PERMS_MASK) == O_WRONLY)
goto unlock_and_error;
 
err = xnselect_bind(&mq->read_select, binding,
@@ -240,7 +239,7 @@ mqd_select(struct rtdm_fd *fd, struct xnselector *selector,
 
case XNSELECT_WRITE:
err = -EBADF;
-   if ((mqd->flags & COBALT_PERMS_MASK) == O_RDONLY)
+   if ((rtdm_fd_flags(fd) & COBALT_PERMS_MASK) == O_RDONLY)
goto unlock_and_error;
 
err = xnselect_bind(&mq->write_select, binding,
@@ -275,7 +274,7 @@ static inline int mqd_create(struct cobalt_mq *mq, unsigned 
long flags, int ufd)
if (mqd == NULL)
return -ENOSPC;
 
-   mqd->flags = flags;
+   mqd->fd.oflags = flags;
mqd->mq = mq;
 
return rtdm_fd_enter(&mqd->fd, ufd, COBALT_MQD_MAGIC, &mqd_ops);
@@ -416,7 +415,7 @@ mq_trysend(struct cobalt_mqd *mqd, size_t len)
unsigned flags;
 
mq = mqd->mq;
-   flags = mqd->flags & COBALT_PERMS_MASK;
+   flags = rtdm_fd_flags(&mqd->fd) & COBALT_PERMS_MASK;
 
if (flags != O_WRONLY && flags != O_RDWR)
return ERR_PTR(-EBADF);
@@ -442,7 +441,7 @@ mq_tryrcv(struct cobalt_mqd *mqd, size_t len)
struct cobalt_mq *mq;
 
mq = mqd->mq;
-   flags = mqd->flags & COBALT_PERMS_MASK;
+   flags = rtdm_fd_flags(&mqd->fd) & COBALT_PERMS_MASK;
 
if (flags != O_RDONLY && flags != O_RDWR)
return ERR_PTR(-EBADF);
@@ -485,7 +484,7 @@ redo:
if (msg != ERR_PTR(-EAGAIN))
goto out;
 
-   if (mqd->flags & O_NONBLOCK)
+   if (rtdm_fd_flags(&mqd->fd) & O_NONBLOCK)
goto out;
 
if (fetch_timeout) {
@@ -614,7 +613,7 @@ redo:
if (msg != ERR_PTR(-EAGAIN))
goto out;
 
-   if (mqd->flags & O_NONBLOCK)
+   if (rtdm_fd_flags(&mqd->fd) & O_NONBLOCK)
goto out;
 
if (fetch_timeout) {
@@ -668,36 +667,13 @@ static inline int mq_getattr(struct cobalt_mqd *mqd, 
struct mq_attr *attr)
mq = mqd->mq;
*attr = mq->attr;
xnlock_get_irqsave(&nklock, s);
-   attr->mq_flags = mqd->flags;
+   attr->mq_flags = rtdm_fd_flags(&mqd->fd);
attr->mq_curmsgs = mq->nrqueued;
xnlock_put_irqrestore(&nklock, s);
 
return 0;
 }
 
-static inline int mq_setattr(struct cobalt_mqd *mqd,
-const struct mq_attr *__restrict__ attr,
-struct mq_attr *__restrict__ oattr)
-{
-   struct cobalt_mq *mq;
-   long flags;
-   spl_t s;
-
-   xnlock_get_irqsave(&nklock, s);
-   mq = mqd->mq;
-   if (oattr) {
-   *oattr = mq->attr;
-   oattr->mq_flags = mqd->flags;
-   oattr->mq_curmsgs = mq->nrqueued;
-   }
-   flags = (mqd->flags & COBALT_PERMS_MASK)
-   | (attr->mq_flags & ~COBALT_PERMS_MASK);
-   mqd->flags = flags;
-   xnlock_put_irqrestore(&nklock, s);
-
-   return 0;
-}
-
 static inline int
 mq_noti

[Xenomai-git] Gilles Chanteperdrix : cobalt/rtdm: add fcntl syscall

2014-10-25 Thread git repository hosting
Module: xenomai-gch
Branch: for-forge
Commit: 33a65f3dc39c5ef886f7ef485cfc738707ae7bfb
URL:
http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=33a65f3dc39c5ef886f7ef485cfc738707ae7bfb

Author: Gilles Chanteperdrix 
Date:   Sat Oct 25 21:11:16 2014 +0200

cobalt/rtdm: add fcntl syscall

---

 include/cobalt/fcntl.h|2 +
 include/cobalt/kernel/rtdm/fd.h   |2 +
 include/cobalt/kernel/rtdm/rtdm.h |3 +
 include/cobalt/uapi/syscall.h |  133 +++--
 kernel/cobalt/posix/io.c  |6 ++
 kernel/cobalt/posix/io.h  |2 +
 kernel/cobalt/posix/syscall.c |   10 +--
 kernel/cobalt/rtdm/fd.c   |   42 +++-
 lib/cobalt/rtdm.c |   18 +
 lib/cobalt/wrappers.c |   13 
 10 files changed, 158 insertions(+), 73 deletions(-)

diff --git a/include/cobalt/fcntl.h b/include/cobalt/fcntl.h
index ed96dd7..2a83a7a 100644
--- a/include/cobalt/fcntl.h
+++ b/include/cobalt/fcntl.h
@@ -29,6 +29,8 @@ extern "C" {
 
 COBALT_DECL(int, open(const char *path, int oflag, ...));
 
+COBALT_DECL(int, fcntl(int fd, int cmd, ...));
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/include/cobalt/kernel/rtdm/fd.h b/include/cobalt/kernel/rtdm/fd.h
index ccf0332..5685b3a 100644
--- a/include/cobalt/kernel/rtdm/fd.h
+++ b/include/cobalt/kernel/rtdm/fd.h
@@ -353,6 +353,8 @@ void rtdm_fd_put(struct rtdm_fd *fd);
 
 void rtdm_fd_unlock(struct rtdm_fd *fd);
 
+int rtdm_fd_fcntl(int ufd, int cmd, ...);
+
 int rtdm_fd_ioctl(int ufd, unsigned int request, ...);
 
 ssize_t rtdm_fd_read(int ufd, void __user *buf, size_t size);
diff --git a/include/cobalt/kernel/rtdm/rtdm.h 
b/include/cobalt/kernel/rtdm/rtdm.h
index db1e270..2b1c8fd 100644
--- a/include/cobalt/kernel/rtdm/rtdm.h
+++ b/include/cobalt/kernel/rtdm/rtdm.h
@@ -50,6 +50,9 @@ int __rtdm_dev_socket(int protocol_family,
 #define rt_dev_close(fd)   \
rtdm_fd_close(fd, RTDM_FD_MAGIC)
 
+#define rt_dev_fcntl(fd, cmd, ...) \
+   rtdm_fd_fcntl(fd,cmd, __VA_ARGS__)
+
 #define rt_dev_ioctl(fd, request, ...) \
rtdm_fd_ioctl(fd, request, __VA_ARGS__)
 
diff --git a/include/cobalt/uapi/syscall.h b/include/cobalt/uapi/syscall.h
index aa364a1..025d2ff 100644
--- a/include/cobalt/uapi/syscall.h
+++ b/include/cobalt/uapi/syscall.h
@@ -21,63 +21,63 @@
 #include 
 
 #define sc_cobalt_bind 0
-#define sc_cobalt_thread_create1
-#define sc_cobalt_thread_getpid2
-#define sc_cobalt_thread_setmode   3
-#define sc_cobalt_thread_setname   4
-#define sc_cobalt_thread_join  5
-#define sc_cobalt_thread_kill  6
+#define sc_cobalt_thread_create1
+#define sc_cobalt_thread_getpid2
+#define sc_cobalt_thread_setmode   3
+#define sc_cobalt_thread_setname   4
+#define sc_cobalt_thread_join  5
+#define sc_cobalt_thread_kill  6
 #define sc_cobalt_thread_setschedparam_ex  7
 #define sc_cobalt_thread_getschedparam_ex  8
-#define sc_cobalt_thread_getstat   9
+#define sc_cobalt_thread_getstat   9
 /* 10 unimp */
-#define sc_cobalt_sem_init 11
-#define sc_cobalt_sem_destroy  12
-#define sc_cobalt_sem_post 13
-#define sc_cobalt_sem_wait 14
-#define sc_cobalt_sem_trywait  15
-#define sc_cobalt_sem_getvalue 16
-#define sc_cobalt_sem_open 17
-#define sc_cobalt_sem_close18
-#define sc_cobalt_sem_unlink   19
-#define sc_cobalt_sem_timedwait20
-#define sc_cobalt_sem_inquire  21
+#define sc_cobalt_sem_init 11
+#define sc_cobalt_sem_destroy  12
+#define sc_cobalt_sem_post 13
+#define sc_cobalt_sem_wait 14
+#define sc_cobalt_sem_trywait  15
+#define sc_cobalt_sem_getvalue 16
+#define sc_cobalt_sem_open 17
+#define sc_cobalt_sem_close18
+#define sc_cobalt_sem_unlink   19
+#define sc_cobalt_sem_timedwait20
+#define sc_cobalt_sem_inquire  21
 /* 22 unimp */
-#define sc_cobalt_sem_broadcast_np 23
-#define sc_cobalt_clock_getres 24
-#define sc_cobalt_clock_gettime25
-#define sc_cobalt_clock_settime26
-#define sc_cobalt_clock_nanosleep  27
-#define sc_cobalt_mutex_init   28
-#define sc_cobalt_mutex_check_init 29
-#define sc_cobalt_mutex_destroy30
-#define sc_cobalt_mutex_lock   31
-#define sc_cobalt_mutex_timedlock  32
-#define sc_cobalt_mutex_tryloc

[Xenomai-git] Gilles Chanteperdrix : cobalt/mqueue: use rtdm fd flags

2014-10-25 Thread git repository hosting
Module: xenomai-gch
Branch: for-forge
Commit: e80f952eafe8c7d467e50e00ff100d7b4289c61b
URL:
http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=e80f952eafe8c7d467e50e00ff100d7b4289c61b

Author: Gilles Chanteperdrix 
Date:   Sat Oct 25 21:52:07 2014 +0200

cobalt/mqueue: use rtdm fd flags

---

 include/cobalt/uapi/syscall.h |2 +-
 kernel/cobalt/posix/mqueue.c  |   79 +
 kernel/cobalt/posix/syscall.c |2 --
 lib/cobalt/mq.c   |   19 --
 4 files changed, 27 insertions(+), 75 deletions(-)

diff --git a/include/cobalt/uapi/syscall.h b/include/cobalt/uapi/syscall.h
index 025d2ff..0f74f37 100644
--- a/include/cobalt/uapi/syscall.h
+++ b/include/cobalt/uapi/syscall.h
@@ -63,7 +63,7 @@
 #define sc_cobalt_mq_close 40
 #define sc_cobalt_mq_unlink41
 #define sc_cobalt_mq_getattr   42
-#define sc_cobalt_mq_setattr   43
+/* 43 unimp */
 #define sc_cobalt_mq_timedsend 44
 #define sc_cobalt_mq_timedreceive  45
 #define sc_cobalt_mq_notify46
diff --git a/kernel/cobalt/posix/mqueue.c b/kernel/cobalt/posix/mqueue.c
index f5a69f9..5d17ec7 100644
--- a/kernel/cobalt/posix/mqueue.c
+++ b/kernel/cobalt/posix/mqueue.c
@@ -31,7 +31,7 @@
 
 #define COBALT_MSGMAX  65536
 #define COBALT_MSGSIZEMAX  (16*1024*1024)
-#define COBALT_MSGPRIOMAX  32768
+#define COBALT_MSGPRIOMAX  32768
 
 struct cobalt_mq {
unsigned magic;
@@ -62,7 +62,6 @@ struct cobalt_mq {
 };
 
 struct cobalt_mqd {
-   long flags;
struct cobalt_mq *mq;
struct rtdm_fd fd;
 };
@@ -228,7 +227,7 @@ mqd_select(struct rtdm_fd *fd, struct xnselector *selector,
switch(type) {
case XNSELECT_READ:
err = -EBADF;
-   if ((mqd->flags & COBALT_PERMS_MASK) == O_WRONLY)
+   if ((rtdm_fd_flags(fd) & COBALT_PERMS_MASK) == O_WRONLY)
goto unlock_and_error;
 
err = xnselect_bind(&mq->read_select, binding,
@@ -240,7 +239,7 @@ mqd_select(struct rtdm_fd *fd, struct xnselector *selector,
 
case XNSELECT_WRITE:
err = -EBADF;
-   if ((mqd->flags & COBALT_PERMS_MASK) == O_RDONLY)
+   if ((rtdm_fd_flags(fd) & COBALT_PERMS_MASK) == O_RDONLY)
goto unlock_and_error;
 
err = xnselect_bind(&mq->write_select, binding,
@@ -275,7 +274,7 @@ static inline int mqd_create(struct cobalt_mq *mq, unsigned 
long flags, int ufd)
if (mqd == NULL)
return -ENOSPC;
 
-   mqd->flags = flags;
+   mqd->fd.oflags = flags;
mqd->mq = mq;
 
return rtdm_fd_enter(&mqd->fd, ufd, COBALT_MQD_MAGIC, &mqd_ops);
@@ -416,7 +415,7 @@ mq_trysend(struct cobalt_mqd *mqd, size_t len)
unsigned flags;
 
mq = mqd->mq;
-   flags = mqd->flags & COBALT_PERMS_MASK;
+   flags = rtdm_fd_flags(&mqd->fd) & COBALT_PERMS_MASK;
 
if (flags != O_WRONLY && flags != O_RDWR)
return ERR_PTR(-EBADF);
@@ -442,7 +441,7 @@ mq_tryrcv(struct cobalt_mqd *mqd, size_t len)
struct cobalt_mq *mq;
 
mq = mqd->mq;
-   flags = mqd->flags & COBALT_PERMS_MASK;
+   flags = rtdm_fd_flags(&mqd->fd) & COBALT_PERMS_MASK;
 
if (flags != O_RDONLY && flags != O_RDWR)
return ERR_PTR(-EBADF);
@@ -485,7 +484,7 @@ redo:
if (msg != ERR_PTR(-EAGAIN))
goto out;
 
-   if (mqd->flags & O_NONBLOCK)
+   if (rtdm_fd_flags(&mqd->fd) & O_NONBLOCK)
goto out;
 
if (fetch_timeout) {
@@ -614,7 +613,7 @@ redo:
if (msg != ERR_PTR(-EAGAIN))
goto out;
 
-   if (mqd->flags & O_NONBLOCK)
+   if (rtdm_fd_flags(&mqd->fd) & O_NONBLOCK)
goto out;
 
if (fetch_timeout) {
@@ -668,36 +667,13 @@ static inline int mq_getattr(struct cobalt_mqd *mqd, 
struct mq_attr *attr)
mq = mqd->mq;
*attr = mq->attr;
xnlock_get_irqsave(&nklock, s);
-   attr->mq_flags = mqd->flags;
+   attr->mq_flags = rtdm_fd_flags(&mqd->fd);
attr->mq_curmsgs = mq->nrqueued;
xnlock_put_irqrestore(&nklock, s);
 
return 0;
 }
 
-static inline int mq_setattr(struct cobalt_mqd *mqd,
-const struct mq_attr *__restrict__ attr,
-struct mq_attr *__restrict__ oattr)
-{
-   struct cobalt_mq *mq;
-   long flags;
-   spl_t s;
-
-   xnlock_get_irqsave(&nklock, s);
-   mq = mqd->mq;
-   if (oattr) {
-   *oattr = mq->attr;
-   oattr->mq_flags = mqd->flags;
-   oattr->mq_curmsgs = mq->nrqueued;
-   }
-   flags = (mqd->flags & COBALT_PERMS_MASK)
-   | (attr->mq_flags & ~COBALT_PERMS_MASK);
-   mqd->flags = flags;
-   xnlock_put_irqrestore(&nklock, s);
-
-   return 0;
-}
-
 static inline int
 mq_noti

[Xenomai-git] Gilles Chanteperdrix : cobalt/mqueue: use rtdm fd flags

2014-10-25 Thread git repository hosting
Module: xenomai-gch
Branch: for-forge
Commit: b6c2a3084430998d80b735c3992d17f1e443cc1e
URL:
http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=b6c2a3084430998d80b735c3992d17f1e443cc1e

Author: Gilles Chanteperdrix 
Date:   Sat Oct 25 21:52:07 2014 +0200

cobalt/mqueue: use rtdm fd flags

---

 include/cobalt/uapi/syscall.h |2 +-
 kernel/cobalt/posix/mqueue.c  |   79 +
 kernel/cobalt/posix/syscall.c |2 --
 lib/cobalt/mq.c   |   21 +--
 4 files changed, 29 insertions(+), 75 deletions(-)

diff --git a/include/cobalt/uapi/syscall.h b/include/cobalt/uapi/syscall.h
index 025d2ff..0f74f37 100644
--- a/include/cobalt/uapi/syscall.h
+++ b/include/cobalt/uapi/syscall.h
@@ -63,7 +63,7 @@
 #define sc_cobalt_mq_close 40
 #define sc_cobalt_mq_unlink41
 #define sc_cobalt_mq_getattr   42
-#define sc_cobalt_mq_setattr   43
+/* 43 unimp */
 #define sc_cobalt_mq_timedsend 44
 #define sc_cobalt_mq_timedreceive  45
 #define sc_cobalt_mq_notify46
diff --git a/kernel/cobalt/posix/mqueue.c b/kernel/cobalt/posix/mqueue.c
index f5a69f9..5d17ec7 100644
--- a/kernel/cobalt/posix/mqueue.c
+++ b/kernel/cobalt/posix/mqueue.c
@@ -31,7 +31,7 @@
 
 #define COBALT_MSGMAX  65536
 #define COBALT_MSGSIZEMAX  (16*1024*1024)
-#define COBALT_MSGPRIOMAX  32768
+#define COBALT_MSGPRIOMAX  32768
 
 struct cobalt_mq {
unsigned magic;
@@ -62,7 +62,6 @@ struct cobalt_mq {
 };
 
 struct cobalt_mqd {
-   long flags;
struct cobalt_mq *mq;
struct rtdm_fd fd;
 };
@@ -228,7 +227,7 @@ mqd_select(struct rtdm_fd *fd, struct xnselector *selector,
switch(type) {
case XNSELECT_READ:
err = -EBADF;
-   if ((mqd->flags & COBALT_PERMS_MASK) == O_WRONLY)
+   if ((rtdm_fd_flags(fd) & COBALT_PERMS_MASK) == O_WRONLY)
goto unlock_and_error;
 
err = xnselect_bind(&mq->read_select, binding,
@@ -240,7 +239,7 @@ mqd_select(struct rtdm_fd *fd, struct xnselector *selector,
 
case XNSELECT_WRITE:
err = -EBADF;
-   if ((mqd->flags & COBALT_PERMS_MASK) == O_RDONLY)
+   if ((rtdm_fd_flags(fd) & COBALT_PERMS_MASK) == O_RDONLY)
goto unlock_and_error;
 
err = xnselect_bind(&mq->write_select, binding,
@@ -275,7 +274,7 @@ static inline int mqd_create(struct cobalt_mq *mq, unsigned 
long flags, int ufd)
if (mqd == NULL)
return -ENOSPC;
 
-   mqd->flags = flags;
+   mqd->fd.oflags = flags;
mqd->mq = mq;
 
return rtdm_fd_enter(&mqd->fd, ufd, COBALT_MQD_MAGIC, &mqd_ops);
@@ -416,7 +415,7 @@ mq_trysend(struct cobalt_mqd *mqd, size_t len)
unsigned flags;
 
mq = mqd->mq;
-   flags = mqd->flags & COBALT_PERMS_MASK;
+   flags = rtdm_fd_flags(&mqd->fd) & COBALT_PERMS_MASK;
 
if (flags != O_WRONLY && flags != O_RDWR)
return ERR_PTR(-EBADF);
@@ -442,7 +441,7 @@ mq_tryrcv(struct cobalt_mqd *mqd, size_t len)
struct cobalt_mq *mq;
 
mq = mqd->mq;
-   flags = mqd->flags & COBALT_PERMS_MASK;
+   flags = rtdm_fd_flags(&mqd->fd) & COBALT_PERMS_MASK;
 
if (flags != O_RDONLY && flags != O_RDWR)
return ERR_PTR(-EBADF);
@@ -485,7 +484,7 @@ redo:
if (msg != ERR_PTR(-EAGAIN))
goto out;
 
-   if (mqd->flags & O_NONBLOCK)
+   if (rtdm_fd_flags(&mqd->fd) & O_NONBLOCK)
goto out;
 
if (fetch_timeout) {
@@ -614,7 +613,7 @@ redo:
if (msg != ERR_PTR(-EAGAIN))
goto out;
 
-   if (mqd->flags & O_NONBLOCK)
+   if (rtdm_fd_flags(&mqd->fd) & O_NONBLOCK)
goto out;
 
if (fetch_timeout) {
@@ -668,36 +667,13 @@ static inline int mq_getattr(struct cobalt_mqd *mqd, 
struct mq_attr *attr)
mq = mqd->mq;
*attr = mq->attr;
xnlock_get_irqsave(&nklock, s);
-   attr->mq_flags = mqd->flags;
+   attr->mq_flags = rtdm_fd_flags(&mqd->fd);
attr->mq_curmsgs = mq->nrqueued;
xnlock_put_irqrestore(&nklock, s);
 
return 0;
 }
 
-static inline int mq_setattr(struct cobalt_mqd *mqd,
-const struct mq_attr *__restrict__ attr,
-struct mq_attr *__restrict__ oattr)
-{
-   struct cobalt_mq *mq;
-   long flags;
-   spl_t s;
-
-   xnlock_get_irqsave(&nklock, s);
-   mq = mqd->mq;
-   if (oattr) {
-   *oattr = mq->attr;
-   oattr->mq_flags = mqd->flags;
-   oattr->mq_curmsgs = mq->nrqueued;
-   }
-   flags = (mqd->flags & COBALT_PERMS_MASK)
-   | (attr->mq_flags & ~COBALT_PERMS_MASK);
-   mqd->flags = flags;
-   xnlock_put_irqrestore(&nklock, s);
-
-   return 0;
-}
-
 static inline int
 mq_not

[Xenomai-git] Gilles Chanteperdrix : cobalt/mqueue: use rtdm fd flags

2014-10-25 Thread git repository hosting
Module: xenomai-gch
Branch: for-forge
Commit: 79da6afda4b680c3c028917d80145e503d3fb8b6
URL:
http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=79da6afda4b680c3c028917d80145e503d3fb8b6

Author: Gilles Chanteperdrix 
Date:   Sat Oct 25 21:52:07 2014 +0200

cobalt/mqueue: use rtdm fd flags

---

 include/cobalt/uapi/syscall.h |2 +-
 kernel/cobalt/posix/mqueue.c  |   79 +
 kernel/cobalt/posix/syscall.c |2 --
 lib/cobalt/mq.c   |   23 ++--
 4 files changed, 31 insertions(+), 75 deletions(-)

diff --git a/include/cobalt/uapi/syscall.h b/include/cobalt/uapi/syscall.h
index 025d2ff..0f74f37 100644
--- a/include/cobalt/uapi/syscall.h
+++ b/include/cobalt/uapi/syscall.h
@@ -63,7 +63,7 @@
 #define sc_cobalt_mq_close 40
 #define sc_cobalt_mq_unlink41
 #define sc_cobalt_mq_getattr   42
-#define sc_cobalt_mq_setattr   43
+/* 43 unimp */
 #define sc_cobalt_mq_timedsend 44
 #define sc_cobalt_mq_timedreceive  45
 #define sc_cobalt_mq_notify46
diff --git a/kernel/cobalt/posix/mqueue.c b/kernel/cobalt/posix/mqueue.c
index f5a69f9..5d17ec7 100644
--- a/kernel/cobalt/posix/mqueue.c
+++ b/kernel/cobalt/posix/mqueue.c
@@ -31,7 +31,7 @@
 
 #define COBALT_MSGMAX  65536
 #define COBALT_MSGSIZEMAX  (16*1024*1024)
-#define COBALT_MSGPRIOMAX  32768
+#define COBALT_MSGPRIOMAX  32768
 
 struct cobalt_mq {
unsigned magic;
@@ -62,7 +62,6 @@ struct cobalt_mq {
 };
 
 struct cobalt_mqd {
-   long flags;
struct cobalt_mq *mq;
struct rtdm_fd fd;
 };
@@ -228,7 +227,7 @@ mqd_select(struct rtdm_fd *fd, struct xnselector *selector,
switch(type) {
case XNSELECT_READ:
err = -EBADF;
-   if ((mqd->flags & COBALT_PERMS_MASK) == O_WRONLY)
+   if ((rtdm_fd_flags(fd) & COBALT_PERMS_MASK) == O_WRONLY)
goto unlock_and_error;
 
err = xnselect_bind(&mq->read_select, binding,
@@ -240,7 +239,7 @@ mqd_select(struct rtdm_fd *fd, struct xnselector *selector,
 
case XNSELECT_WRITE:
err = -EBADF;
-   if ((mqd->flags & COBALT_PERMS_MASK) == O_RDONLY)
+   if ((rtdm_fd_flags(fd) & COBALT_PERMS_MASK) == O_RDONLY)
goto unlock_and_error;
 
err = xnselect_bind(&mq->write_select, binding,
@@ -275,7 +274,7 @@ static inline int mqd_create(struct cobalt_mq *mq, unsigned 
long flags, int ufd)
if (mqd == NULL)
return -ENOSPC;
 
-   mqd->flags = flags;
+   mqd->fd.oflags = flags;
mqd->mq = mq;
 
return rtdm_fd_enter(&mqd->fd, ufd, COBALT_MQD_MAGIC, &mqd_ops);
@@ -416,7 +415,7 @@ mq_trysend(struct cobalt_mqd *mqd, size_t len)
unsigned flags;
 
mq = mqd->mq;
-   flags = mqd->flags & COBALT_PERMS_MASK;
+   flags = rtdm_fd_flags(&mqd->fd) & COBALT_PERMS_MASK;
 
if (flags != O_WRONLY && flags != O_RDWR)
return ERR_PTR(-EBADF);
@@ -442,7 +441,7 @@ mq_tryrcv(struct cobalt_mqd *mqd, size_t len)
struct cobalt_mq *mq;
 
mq = mqd->mq;
-   flags = mqd->flags & COBALT_PERMS_MASK;
+   flags = rtdm_fd_flags(&mqd->fd) & COBALT_PERMS_MASK;
 
if (flags != O_RDONLY && flags != O_RDWR)
return ERR_PTR(-EBADF);
@@ -485,7 +484,7 @@ redo:
if (msg != ERR_PTR(-EAGAIN))
goto out;
 
-   if (mqd->flags & O_NONBLOCK)
+   if (rtdm_fd_flags(&mqd->fd) & O_NONBLOCK)
goto out;
 
if (fetch_timeout) {
@@ -614,7 +613,7 @@ redo:
if (msg != ERR_PTR(-EAGAIN))
goto out;
 
-   if (mqd->flags & O_NONBLOCK)
+   if (rtdm_fd_flags(&mqd->fd) & O_NONBLOCK)
goto out;
 
if (fetch_timeout) {
@@ -668,36 +667,13 @@ static inline int mq_getattr(struct cobalt_mqd *mqd, 
struct mq_attr *attr)
mq = mqd->mq;
*attr = mq->attr;
xnlock_get_irqsave(&nklock, s);
-   attr->mq_flags = mqd->flags;
+   attr->mq_flags = rtdm_fd_flags(&mqd->fd);
attr->mq_curmsgs = mq->nrqueued;
xnlock_put_irqrestore(&nklock, s);
 
return 0;
 }
 
-static inline int mq_setattr(struct cobalt_mqd *mqd,
-const struct mq_attr *__restrict__ attr,
-struct mq_attr *__restrict__ oattr)
-{
-   struct cobalt_mq *mq;
-   long flags;
-   spl_t s;
-
-   xnlock_get_irqsave(&nklock, s);
-   mq = mqd->mq;
-   if (oattr) {
-   *oattr = mq->attr;
-   oattr->mq_flags = mqd->flags;
-   oattr->mq_curmsgs = mq->nrqueued;
-   }
-   flags = (mqd->flags & COBALT_PERMS_MASK)
-   | (attr->mq_flags & ~COBALT_PERMS_MASK);
-   mqd->flags = flags;
-   xnlock_put_irqrestore(&nklock, s);
-
-   return 0;
-}
-
 static inline int
 mq_no

[Xenomai-git] Gilles Chanteperdrix : lib/cobalt: wrap time and gettimeofday calls

2014-10-25 Thread git repository hosting
Module: xenomai-gch
Branch: for-forge
Commit: fb9724f7f9ae3e70c3ad89d5f6191cd280e89c73
URL:
http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=fb9724f7f9ae3e70c3ad89d5f6191cd280e89c73

Author: Gilles Chanteperdrix 
Date:   Sat Sep 20 23:06:02 2014 +0200

lib/cobalt: wrap time and gettimeofday calls

---

 include/cobalt/time.h   |2 ++
 lib/cobalt/assert_context.c |7 ---
 lib/cobalt/clock.c  |   23 +++
 lib/cobalt/cobalt.wrappers  |2 ++
 4 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/include/cobalt/time.h b/include/cobalt/time.h
index c5d7412..fed8957 100644
--- a/include/cobalt/time.h
+++ b/include/cobalt/time.h
@@ -44,6 +44,8 @@ COBALT_DECL(int, clock_nanosleep(clockid_t clock_id,
 const struct timespec *rqtp,
 struct timespec *rmtp));
 
+COBALT_DECL(time_t, time(time_t *t));
+
 COBALT_DECL(int, nanosleep(const struct timespec *rqtp,
   struct timespec *rmtp));
 
diff --git a/lib/cobalt/assert_context.c b/lib/cobalt/assert_context.c
index 6b49f3d..48690dc 100644
--- a/lib/cobalt/assert_context.c
+++ b/lib/cobalt/assert_context.c
@@ -75,10 +75,3 @@ COBALT_IMPL(void, free, (void *ptr))
assert_nrt();
__STD(free(ptr));
 }
-
-/* vsyscall-based services */
-COBALT_IMPL(int, gettimeofday, (struct timeval *tv, struct timezone *tz))
-{
-   assert_nrt();
-   return __STD(gettimeofday(tv, tz));
-}
diff --git a/lib/cobalt/clock.c b/lib/cobalt/clock.c
index b31517f..d17ea56 100644
--- a/lib/cobalt/clock.c
+++ b/lib/cobalt/clock.c
@@ -25,6 +25,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -356,4 +357,26 @@ COBALT_IMPL(unsigned int, sleep, (unsigned int seconds))
return 0;
 }
 
+COBALT_IMPL(int, gettimeofday, (struct timeval *tv, struct timezone *tz))
+{
+   struct timespec ts;
+   int ret = __WRAP(clock_gettime(CLOCK_REALTIME, &ts));
+   if (ret == 0) {
+   tv->tv_sec = ts.tv_sec;
+   tv->tv_usec = ts.tv_nsec / 1000;
+   }
+   return ret;
+}
+
+COBALT_IMPL(time_t, time, (time_t *t))
+{
+   struct timespec ts;
+   int ret = __WRAP(clock_gettime(CLOCK_REALTIME, &ts));
+   if (ret)
+   return (time_t)-1;
+
+   if (t)
+   *t = ts.tv_sec;
+   return ts.tv_sec;
+}
 /** @} */
diff --git a/lib/cobalt/cobalt.wrappers b/lib/cobalt/cobalt.wrappers
index 10cb36a..b8c9942 100644
--- a/lib/cobalt/cobalt.wrappers
+++ b/lib/cobalt/cobalt.wrappers
@@ -104,3 +104,5 @@
 --wrap kill
 --wrap sleep
 --wrap mmap
+--wrap gettimeofday
+--wrap time


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


[Xenomai-git] Gilles Chanteperdrix : cobalt/spinlocks: rebase on linux spinlocks

2014-10-25 Thread git repository hosting
Module: xenomai-gch
Branch: for-forge
Commit: 7ffdec1e9b0d489a5356079f1bafe90715633870
URL:
http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=7ffdec1e9b0d489a5356079f1bafe90715633870

Author: Gilles Chanteperdrix 
Date:   Sun Oct 19 21:43:37 2014 +0200

cobalt/spinlocks: rebase on linux spinlocks

---

 include/cobalt/kernel/lock.h |   35 ++-
 kernel/cobalt/debug.c|2 +-
 kernel/cobalt/lock.c |   15 ---
 3 files changed, 19 insertions(+), 33 deletions(-)

diff --git a/include/cobalt/kernel/lock.h b/include/cobalt/kernel/lock.h
index b0c34bf..e590b85 100644
--- a/include/cobalt/kernel/lock.h
+++ b/include/cobalt/kernel/lock.h
@@ -66,7 +66,8 @@ typedef unsigned long spl_t;
 #if XENO_DEBUG(LOCKING)
 
 struct xnlock {
-   atomic_t owner;
+   unsigned owner;
+   arch_spinlock_t alock;
const char *file;
const char *function;
unsigned int line;
@@ -84,7 +85,8 @@ struct xnlockinfo {
 };
 
 #define XNARCH_LOCK_UNLOCKED (struct xnlock) { \
-   { ~0 }, \
+   ~0, \
+   __ARCH_SPIN_LOCK_UNLOCKED,  \
NULL,   \
NULL,   \
0,  \
@@ -117,10 +119,15 @@ DECLARE_PER_CPU(struct xnlockinfo, xnlock_stats);
 #else /* !XENO_DEBUG(LOCKING) */
 
 struct xnlock {
-   atomic_t owner;
+   unsigned owner;
+   arch_spinlock_t alock;
 };
 
-#define XNARCH_LOCK_UNLOCKED   (struct xnlock) { { ~0 } }
+#define XNARCH_LOCK_UNLOCKED   \
+   (struct xnlock) {   \
+   ~0, \
+   __ARCH_SPIN_LOCK_UNLOCKED,  \
+   }
 
 #define XNLOCK_DBG_CONTEXT
 #define XNLOCK_DBG_CONTEXT_ARGS
@@ -175,20 +182,18 @@ static inline void xnlock_init (struct xnlock *lock)
 #define DEFINE_XNLOCK(lock)struct xnlock lock = 
XNARCH_LOCK_UNLOCKED
 #define DEFINE_PRIVATE_XNLOCK(lock)static DEFINE_XNLOCK(lock)
 
-void __xnlock_spin(int cpu, struct xnlock *lock /*, */ 
XNLOCK_DBG_CONTEXT_ARGS);
-
 static inline int xnlock_get(struct xnlock *lock /*, */ 
XNLOCK_DBG_CONTEXT_ARGS)
 {
int cpu = ipipe_processor_id();
unsigned long long start;
 
-   if (atomic_read(&lock->owner) == cpu)
+   if (lock->owner == cpu)
return 2;
 
xnlock_dbg_prepare_acquire(&start);
 
-   if (unlikely(atomic_cmpxchg(&lock->owner, ~0, cpu) != ~0))
-   __xnlock_spin(cpu, lock /*, */ XNLOCK_DBG_PASS_CONTEXT);
+   arch_spin_lock(&lock->alock);
+   lock->owner = cpu;
 
xnlock_dbg_acquired(lock, cpu, &start /*, */ XNLOCK_DBG_PASS_CONTEXT);
 
@@ -200,12 +205,8 @@ static inline void xnlock_put(struct xnlock *lock /*, 
*/ XNLOCK_DBG_CONTEXT_
if (xnlock_dbg_release(lock /*, */ XNLOCK_DBG_PASS_CONTEXT))
return;
 
-   /*
-* Make sure all data written inside the lock is visible to
-* other CPUs before we release the lock.
-*/
-   mb();
-   atomic_set(&lock->owner, ~0);
+   lock->owner = ~0U;
+   arch_spin_unlock(&lock->alock);
 }
 
 #ifndef CONFIG_XENO_ARCH_OUTOFLINE_XNLOCK
@@ -250,7 +251,7 @@ static inline void __xnlock_put_irqrestore(struct xnlock 
*lock, spl_t flags
 static inline int xnlock_is_owner(struct xnlock *lock)
 {
if (__locking_active__)
-   return atomic_read(&lock->owner) == ipipe_processor_id();
+   return lock->owner == ipipe_processor_id();
 
return 1;
 }
@@ -266,7 +267,7 @@ static inline int __xnlock_get(struct xnlock *lock /*, */ 
XNLOCK_DBG_CONTEXT_ARG
 static inline void __xnlock_put(struct xnlock *lock /*, */ 
XNLOCK_DBG_CONTEXT_ARGS)
 {
if (__locking_active__)
-   ___xnlock_put(lock /*, */ XNLOCK_DBG_PASS_CONTEXT); 
+   ___xnlock_put(lock /*, */ XNLOCK_DBG_PASS_CONTEXT);
 }
 
 #undef __locking_active__
diff --git a/kernel/cobalt/debug.c b/kernel/cobalt/debug.c
index ad72a3e..ef46e0b 100644
--- a/kernel/cobalt/debug.c
+++ b/kernel/cobalt/debug.c
@@ -598,7 +598,7 @@ int xnlock_dbg_release(struct xnlock *lock,
lock->function = "invalid";
}
 
-   if (unlikely(atomic_read(&lock->owner) != cpu)) {
+   if (unlikely(lock->owner != cpu)) {
ipipe_prepare_panic();
printk(XENO_ERR "lock %p already unlocked on CPU #%d\n"
"  last owner = %s:%u (%s(), CPU 
#%d)\n",
diff --git a/kernel/cobalt/lock.c b/kernel/cobalt/lock.c
index 5c339b5..a1b2e37 100644
--- a/kernel/cobalt/lock.c
+++ b/kernel/cobalt/lock.c
@@ -42,21 +42,6 @@ DEFINE_XNLOCK(nklock);
 #if defined(CONFIG_SMP) || XENO_DEBUG(LOCKING)
 EXPORT_SYMBOL_GPL(nklock);
 
-void __xnlock_spin(int cpu, struct xnlock *lock /*, */ XNLOCK_DBG_CONTEXT_ARGS)
-{
-   unsigned int spin_li

[Xenomai-git] Gilles Chanteperdrix : cobalt/rtdm: add fcntl syscall

2014-10-25 Thread git repository hosting
Module: xenomai-gch
Branch: for-forge
Commit: 81aec220a4cc257da43c3f368652f1c70fd6a8b5
URL:
http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=81aec220a4cc257da43c3f368652f1c70fd6a8b5

Author: Gilles Chanteperdrix 
Date:   Sat Oct 25 21:11:16 2014 +0200

cobalt/rtdm: add fcntl syscall

---

 include/cobalt/fcntl.h  |2 +
 include/cobalt/kernel/rtdm/fd.h |2 +
 include/cobalt/uapi/syscall.h   |  133 ---
 kernel/cobalt/posix/io.c|6 ++
 kernel/cobalt/posix/io.h|2 +
 kernel/cobalt/posix/syscall.c   |   10 +--
 kernel/cobalt/rtdm/fd.c |   35 ++-
 lib/cobalt/rtdm.c   |   18 ++
 lib/cobalt/wrappers.c   |   13 
 9 files changed, 148 insertions(+), 73 deletions(-)

diff --git a/include/cobalt/fcntl.h b/include/cobalt/fcntl.h
index ed96dd7..2a83a7a 100644
--- a/include/cobalt/fcntl.h
+++ b/include/cobalt/fcntl.h
@@ -29,6 +29,8 @@ extern "C" {
 
 COBALT_DECL(int, open(const char *path, int oflag, ...));
 
+COBALT_DECL(int, fcntl(int fd, int cmd, ...));
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/include/cobalt/kernel/rtdm/fd.h b/include/cobalt/kernel/rtdm/fd.h
index ccf0332..e84c7cb 100644
--- a/include/cobalt/kernel/rtdm/fd.h
+++ b/include/cobalt/kernel/rtdm/fd.h
@@ -353,6 +353,8 @@ void rtdm_fd_put(struct rtdm_fd *fd);
 
 void rtdm_fd_unlock(struct rtdm_fd *fd);
 
+int rtdm_fd_fcntl(int ufd, int cmd, int arg);
+
 int rtdm_fd_ioctl(int ufd, unsigned int request, ...);
 
 ssize_t rtdm_fd_read(int ufd, void __user *buf, size_t size);
diff --git a/include/cobalt/uapi/syscall.h b/include/cobalt/uapi/syscall.h
index aa364a1..025d2ff 100644
--- a/include/cobalt/uapi/syscall.h
+++ b/include/cobalt/uapi/syscall.h
@@ -21,63 +21,63 @@
 #include 
 
 #define sc_cobalt_bind 0
-#define sc_cobalt_thread_create1
-#define sc_cobalt_thread_getpid2
-#define sc_cobalt_thread_setmode   3
-#define sc_cobalt_thread_setname   4
-#define sc_cobalt_thread_join  5
-#define sc_cobalt_thread_kill  6
+#define sc_cobalt_thread_create1
+#define sc_cobalt_thread_getpid2
+#define sc_cobalt_thread_setmode   3
+#define sc_cobalt_thread_setname   4
+#define sc_cobalt_thread_join  5
+#define sc_cobalt_thread_kill  6
 #define sc_cobalt_thread_setschedparam_ex  7
 #define sc_cobalt_thread_getschedparam_ex  8
-#define sc_cobalt_thread_getstat   9
+#define sc_cobalt_thread_getstat   9
 /* 10 unimp */
-#define sc_cobalt_sem_init 11
-#define sc_cobalt_sem_destroy  12
-#define sc_cobalt_sem_post 13
-#define sc_cobalt_sem_wait 14
-#define sc_cobalt_sem_trywait  15
-#define sc_cobalt_sem_getvalue 16
-#define sc_cobalt_sem_open 17
-#define sc_cobalt_sem_close18
-#define sc_cobalt_sem_unlink   19
-#define sc_cobalt_sem_timedwait20
-#define sc_cobalt_sem_inquire  21
+#define sc_cobalt_sem_init 11
+#define sc_cobalt_sem_destroy  12
+#define sc_cobalt_sem_post 13
+#define sc_cobalt_sem_wait 14
+#define sc_cobalt_sem_trywait  15
+#define sc_cobalt_sem_getvalue 16
+#define sc_cobalt_sem_open 17
+#define sc_cobalt_sem_close18
+#define sc_cobalt_sem_unlink   19
+#define sc_cobalt_sem_timedwait20
+#define sc_cobalt_sem_inquire  21
 /* 22 unimp */
-#define sc_cobalt_sem_broadcast_np 23
-#define sc_cobalt_clock_getres 24
-#define sc_cobalt_clock_gettime25
-#define sc_cobalt_clock_settime26
-#define sc_cobalt_clock_nanosleep  27
-#define sc_cobalt_mutex_init   28
-#define sc_cobalt_mutex_check_init 29
-#define sc_cobalt_mutex_destroy30
-#define sc_cobalt_mutex_lock   31
-#define sc_cobalt_mutex_timedlock  32
-#define sc_cobalt_mutex_trylock33
-#define sc_cobalt_mutex_unlock 34
-#define sc_cobalt_cond_init35
-#define sc_cobalt_cond_destroy 36
-#define sc_cobalt_cond_wait_prologue   37
-#define sc_cobalt_cond_wait_epilogue   38
-#define sc_cobalt_mq_open  39
-#define sc_cobalt_mq_close 40
-#define sc_cobalt_mq_unlink41
-#define sc_cobalt_mq_getattr   42
-#define sc_cobalt_mq_setattr   43
-#define sc_cobalt_mq_timedsend 44
-#define sc_cobalt_mq_timedreceive  45
-#define sc_coba

[Xenomai-git] Philippe Gerum : drivers/rtipc: fixup for 32bit emulation

2014-10-25 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 3e65688b956fad5a9236b7e9d1fd837685994154
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=3e65688b956fad5a9236b7e9d1fd837685994154

Author: Philippe Gerum 
Date:   Wed Oct 22 15:20:21 2014 +0200

drivers/rtipc: fixup for 32bit emulation

---

 kernel/drivers/ipc/bufp.c |  115 ++---
 kernel/drivers/ipc/iddp.c |  123 +++---
 kernel/drivers/ipc/internal.h |   41 -
 kernel/drivers/ipc/rtipc.c|  365 -
 kernel/drivers/ipc/xddp.c |  113 ++---
 5 files changed, 520 insertions(+), 237 deletions(-)

diff --git a/kernel/drivers/ipc/bufp.c b/kernel/drivers/ipc/bufp.c
index 1e5ecf3..5ae166a 100644
--- a/kernel/drivers/ipc/bufp.c
+++ b/kernel/drivers/ipc/bufp.c
@@ -375,17 +375,16 @@ static ssize_t bufp_recvmsg(struct rtdm_fd *fd,
return -EINVAL;
 
/* Copy I/O vector in */
-   if (rtipc_get_arg(fd, iov, msg->msg_iov,
- sizeof(iov[0]) * msg->msg_iovlen))
-   return -EFAULT;
+   ret = rtipc_get_iovec(fd, iov, msg);
+   if (ret)
+   return ret;
 
ret = __bufp_recvmsg(fd, iov, msg->msg_iovlen, flags, &saddr);
if (ret <= 0)
return ret;
 
/* Copy the updated I/O vector back */
-   if (rtipc_put_arg(fd, msg->msg_iov, iov,
- sizeof(iov[0]) * msg->msg_iovlen))
+   if (rtipc_put_iovec(fd, iov, msg))
return -EFAULT;
 
/* Copy the source address if required. */
@@ -620,8 +619,7 @@ static ssize_t bufp_sendmsg(struct rtdm_fd *fd,
return -EINVAL;
 
/* Fetch the destination address to send to. */
-   if (rtipc_get_arg(fd, &daddr,
- msg->msg_name, sizeof(daddr)))
+   if (rtipc_get_arg(fd, &daddr, msg->msg_name, sizeof(daddr)))
return -EFAULT;
 
if (daddr.sipc_port < 0 ||
@@ -639,20 +637,16 @@ static ssize_t bufp_sendmsg(struct rtdm_fd *fd,
return -EINVAL;
 
/* Copy I/O vector in */
-   if (rtipc_get_arg(fd, iov, msg->msg_iov,
- sizeof(iov[0]) * msg->msg_iovlen))
-   return -EFAULT;
+   ret = rtipc_get_iovec(fd, iov, msg);
+   if (ret)
+   return ret;
 
ret = __bufp_sendmsg(fd, iov, msg->msg_iovlen, flags, &daddr);
if (ret <= 0)
return ret;
 
/* Copy updated I/O vector back */
-   if (rtipc_put_arg(fd, msg->msg_iov, iov,
- sizeof(iov[0]) * msg->msg_iovlen))
-   return -EFAULT;
-
-   return ret;
+   return rtipc_put_iovec(fd, iov, msg) ?: ret;
 }
 
 static ssize_t bufp_write(struct rtdm_fd *fd,
@@ -829,30 +823,27 @@ static int __bufp_setsockopt(struct bufp_socket *sk,
struct rtipc_port_label plabel;
struct timeval tv;
rtdm_lockctx_t s;
-   int ret = 0;
size_t len;
+   int ret;
 
-   if (rtipc_get_arg(fd, &sopt, arg, sizeof(sopt)))
-   return -EFAULT;
+   ret = rtipc_get_sockoptin(fd, &sopt, arg);
+   if (ret)
+   return ret;
 
if (sopt.level == SOL_SOCKET) {
switch (sopt.optname) {
 
case SO_RCVTIMEO:
-   if (sopt.optlen != sizeof(tv))
-   return -EINVAL;
-   if (rtipc_get_arg(fd, &tv,
- sopt.optval, sizeof(tv)))
-   return -EFAULT;
+   ret = rtipc_get_timeval(fd, &tv, sopt.optval, 
sopt.optlen);
+   if (ret)
+   return ret;
sk->rx_timeout = rtipc_timeval_to_ns(&tv);
break;
 
case SO_SNDTIMEO:
-   if (sopt.optlen != sizeof(tv))
-   return -EINVAL;
-   if (rtipc_get_arg(fd, &tv,
- sopt.optval, sizeof(tv)))
-   return -EFAULT;
+   ret = rtipc_get_timeval(fd, &tv, sopt.optval, 
sopt.optlen);
+   if (ret)
+   return ret;
sk->tx_timeout = rtipc_timeval_to_ns(&tv);
break;
 
@@ -869,11 +860,9 @@ static int __bufp_setsockopt(struct bufp_socket *sk,
switch (sopt.optname) {
 
case BUFP_BUFSZ:
-   if (sopt.optlen != sizeof(len))
-   return -EINVAL;
-   if (rtipc_get_arg(fd, &len,
- sopt.optval, sizeof(len)))
-   return -EFAULT;
+   ret = rtipc_get_length(fd, &len, sopt.optval, sopt.optlen);
+   if (ret)
+   return ret;
if (len == 0)
   

[Xenomai-git] Philippe Gerum : cobalt/testsuite: fixup for 32bit emulation

2014-10-25 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 7cff5969a7952d75f7b10f35cccaf5f969eb6f8c
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=7cff5969a7952d75f7b10f35cccaf5f969eb6f8c

Author: Philippe Gerum 
Date:   Wed Oct 22 10:53:36 2014 +0200

cobalt/testsuite: fixup for 32bit emulation

---

 demo/alchemy/altency.c  |   44 ++--
 include/rtdm/uapi/autotune.h|2 +
 include/rtdm/uapi/testing.h |   78 ++-
 kernel/drivers/testing/switchtest.c |2 +-
 kernel/drivers/testing/timerbench.c |   28 ++---
 testsuite/latency/latency.c |   53 
 testsuite/switchtest/switchtest.c   |6 +--
 7 files changed, 90 insertions(+), 123 deletions(-)

diff --git a/demo/alchemy/altency.c b/demo/alchemy/altency.c
index ef1a694..2e4d093 100644
--- a/demo/alchemy/altency.c
+++ b/demo/alchemy/altency.c
@@ -25,9 +25,9 @@ RT_SEM display_sem;
 #define TEN_MILLIONS1000
 
 unsigned max_relaxed;
-long minjitter, maxjitter, avgjitter;
-long gminjitter = TEN_MILLIONS, gmaxjitter = -TEN_MILLIONS, goverrun = 0;
-long long gavgjitter = 0;
+int32_t minjitter, maxjitter, avgjitter;
+int32_t gminjitter = TEN_MILLIONS, gmaxjitter = -TEN_MILLIONS, goverrun = 0;
+int64_t gavgjitter = 0;
 
 long long period_ns = 0;
 int test_duration = 0; /* sec of testing, via -T , 0 is inf */
@@ -57,7 +57,7 @@ int test_loops = 0;   /* outer loop count */
 #define WARMUP_TIME 1
 #define HISTOGRAM_CELLS 300
 int histogram_size = HISTOGRAM_CELLS;
-long *histogram_avg = NULL, *histogram_max = NULL, *histogram_min = NULL;
+int32_t *histogram_avg = NULL, *histogram_max = NULL, *histogram_min = NULL;
 
 char *do_gnuplot = NULL;
 int do_histogram = 0, do_stats = 0, finished = 0;
@@ -65,10 +65,10 @@ int bucketsize = 1000;  /* default = 1000ns, -B 
 to override */
 
 #define need_histo() (do_histogram || do_stats || do_gnuplot)
 
-static inline void add_histogram(long *histogram, long addval)
+static inline void add_histogram(int32_t *histogram, int32_t addval)
 {
/* bucketsize steps */
-   long inabs = (addval >= 0 ? addval : -addval) / bucketsize;
+   int inabs = (addval >= 0 ? addval : -addval) / bucketsize;
histogram[inabs < histogram_size ? inabs : histogram_size - 1]++;
 }
 
@@ -77,7 +77,7 @@ static void latency(void *cookie)
RTIME expected_ns, start_ns, fault_threshold;
unsigned int old_relaxed = 0, new_relaxed;
int ret, count, nsamples, warmup = 1;
-   long minj, maxj, dt, overrun, sumj;
+   int32_t minj, maxj, dt, overrun, sumj;
unsigned long ov;
 
fault_threshold = CONFIG_XENO_DEFAULT_PERIOD;
@@ -100,7 +100,7 @@ static void latency(void *cookie)
 
for (count = sumj = 0; count < nsamples; count++) {
ret = rt_task_wait_period(&ov);
-   dt = (long)(rt_timer_read() - expected_ns);
+   dt = (int32_t)(rt_timer_read() - expected_ns);
new_relaxed = sampling_relaxed;
if (dt > maxj) {
if (new_relaxed != old_relaxed
@@ -213,7 +213,7 @@ static void display(void *cookie)
test_duration);
 
for (;;) {
-   long minj, gminj, maxj, gmaxj, avgj;
+   int32_t minj, gminj, maxj, gmaxj, avgj;
 
if (test_mode == USER_TASK) {
ret = rt_sem_p(&display_sem, TM_INFINITE);
@@ -268,7 +268,7 @@ static void display(void *cookie)
   "lat max", "-overrun", "---msw",
   "---lat best", "--lat worst");
}
-   
printf("RTD|%11.3f|%11.3f|%11.3f|%8ld|%6u|%11.3f|%11.3f\n",
+   
printf("RTD|%11.3f|%11.3f|%11.3f|%8d|%6u|%11.3f|%11.3f\n",
   (double)minj / 1000,
   (double)avgj / 1000,
   (double)maxj / 1000,
@@ -279,7 +279,7 @@ static void display(void *cookie)
}
 }
 
-static double dump_histogram(long *histogram, char *kind)
+static double dump_histogram(int32_t *histogram, char *kind)
 {
int n, total_hits = 0;
double avg = 0; /* used to sum hits 1st */
@@ -288,13 +288,13 @@ static double dump_histogram(long *histogram, char *kind)
printf("---|--param|range-|--samples\n");
 
for (n = 0; n < histogram_size; n++) {
-   long hits = histogram[n];
+   int32_t hits = histogram[n];
 
if (hits) {
total_hits += hits;
avg += n * hits;
if (do_histogram)
-   printf("HSD|%s| %3d -%3d | %8ld\n",
+   printf("HSD|%s| %3d -%3d | %8d\n",
   kind, n, n + 1, hit

[Xenomai-git] Philippe Gerum : cobalt/autotune: fixup for 32bit emulation

2014-10-25 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 0962c2f5099d4f8b6e77670816fa9b65f0907e94
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=0962c2f5099d4f8b6e77670816fa9b65f0907e94

Author: Philippe Gerum 
Date:   Wed Oct 22 10:10:04 2014 +0200

cobalt/autotune: fixup for 32bit emulation

---

 include/rtdm/uapi/autotune.h   |8 
 kernel/drivers/autotune/autotune.c |4 ++--
 utils/autotune/autotune.c  |8 
 3 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/include/rtdm/uapi/autotune.h b/include/rtdm/uapi/autotune.h
index 4a75d72..225f2f8 100644
--- a/include/rtdm/uapi/autotune.h
+++ b/include/rtdm/uapi/autotune.h
@@ -24,15 +24,15 @@
 #define RTDM_SUBCLASS_AUTOTUNE 0
 
 struct autotune_setup {
-   int period;
-   int quiet;
+   __u32 period;
+   __u32 quiet;
 };
 
 #define AUTOTUNE_RTIOC_IRQ _IOW(RTDM_CLASS_AUTOTUNE, 0, struct 
autotune_setup)
 #define AUTOTUNE_RTIOC_KERN_IOW(RTDM_CLASS_AUTOTUNE, 1, struct 
autotune_setup)
 #define AUTOTUNE_RTIOC_USER_IOW(RTDM_CLASS_AUTOTUNE, 2, struct 
autotune_setup)
-#define AUTOTUNE_RTIOC_PULSE   _IOW(RTDM_CLASS_AUTOTUNE, 3, 
nanosecs_abs_t)
-#define AUTOTUNE_RTIOC_RUN _IOR(RTDM_CLASS_AUTOTUNE, 4, unsigned 
long)
+#define AUTOTUNE_RTIOC_PULSE   _IOW(RTDM_CLASS_AUTOTUNE, 3, __u64)
+#define AUTOTUNE_RTIOC_RUN _IOR(RTDM_CLASS_AUTOTUNE, 4, __u32)
 #define AUTOTUNE_RTIOC_RESET   _IO(RTDM_CLASS_AUTOTUNE, 5)
 
 #endif /* !_RTDM_UAPI_AUTOTUNE_H */
diff --git a/kernel/drivers/autotune/autotune.c 
b/kernel/drivers/autotune/autotune.c
index 34ba9d5..79608b3 100644
--- a/kernel/drivers/autotune/autotune.c
+++ b/kernel/drivers/autotune/autotune.c
@@ -675,8 +675,8 @@ static int autotune_ioctl_rt(struct rtdm_fd *fd, unsigned 
int request, void *arg
 {
struct autotune_context *context;
struct gravity_tuner *tuner;
-   nanosecs_abs_t timestamp;
-   unsigned int gravity;
+   __u64 timestamp;
+   __u32 gravity;
int ret;
 
context = rtdm_fd_to_private(fd);
diff --git a/utils/autotune/autotune.c b/utils/autotune/autotune.c
index 5a18310..fe2f621 100644
--- a/utils/autotune/autotune.c
+++ b/utils/autotune/autotune.c
@@ -87,8 +87,8 @@ static const struct option base_options[] = {
 
 static void *sampler_thread(void *arg)
 {
-   nanosecs_abs_t timestamp = 0;
int fd = (long)arg, ret, n = 0;
+   __u64 timestamp = 0;
struct timespec now;
 
for (;;) {
@@ -101,7 +101,7 @@ static void *sampler_thread(void *arg)
} else {
n++;
clock_gettime(CLOCK_MONOTONIC, &now);
-   timestamp = (nanosecs_abs_t)now.tv_sec * 10 + 
now.tv_nsec;
+   timestamp = (__u64)now.tv_sec * 10 + 
now.tv_nsec;
}
}
 
@@ -206,8 +206,8 @@ static void usage(void)
 static void run_tuner(int fd, int op, int period, const char *type)
 {
struct autotune_setup setup;
-   unsigned long gravity;
pthread_t sampler;
+   __u32 gravity;
int ret;
 
setup.period = period;
@@ -232,7 +232,7 @@ static void run_tuner(int fd, int op, int period, const 
char *type)
pthread_cancel(sampler);
 
if (!quiet)
-   printf("%lu ns\n", gravity);
+   printf("%u ns\n", gravity);
 }
 
 int main(int argc, char *const argv[])


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


[Xenomai-git] Jorge Ramirez-Ortiz : drivers/analogy: NI_M - retrieve the sampling period via A4L_CMD_SIMUL

2014-10-25 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: da6ebb3f647d024bc1d69738f9afaae8d2d5d6c0
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=da6ebb3f647d024bc1d69738f9afaae8d2d5d6c0

Author: Jorge Ramirez-Ortiz 
Date:   Tue Aug 19 14:13:08 2014 -0400

drivers/analogy: NI_M - retrieve the sampling period via A4L_CMD_SIMUL

---

 kernel/drivers/analogy/national_instruments/mio_common.c |   10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/kernel/drivers/analogy/national_instruments/mio_common.c 
b/kernel/drivers/analogy/national_instruments/mio_common.c
index f0f2abf..e5ccf7a 100644
--- a/kernel/drivers/analogy/national_instruments/mio_common.c
+++ b/kernel/drivers/analogy/national_instruments/mio_common.c
@@ -2067,12 +2067,14 @@ static int ni_ai_cmdtest(struct a4l_subdevice *subd, 
struct a4l_cmd_desc * cmd)
   
cmd->nb_chan)) {
cmd->scan_begin_arg =
ni_min_ai_scan_period_ns(dev, cmd->nb_chan);
-   return -EINVAL;
-   }
-   if (cmd->scan_begin_arg > devpriv->clock_ns * 0xff) {
+
+   if (cmd->scan_begin_arg > devpriv->clock_ns * 0xff)
cmd->scan_begin_arg = devpriv->clock_ns * 0xff;
-   return -EINVAL;
+
+   /* required for calibration */
+   return 0;
}
+
} else if (cmd->scan_begin_src == TRIG_EXT) {
/* external trigger */
unsigned int tmp = CR_CHAN(cmd->scan_begin_arg);


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


[Xenomai-git] Philippe Gerum : scripts/xeno-config: fix variable quoting

2014-10-25 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: aa78eab89436fc1003465f8aa29894514f11b7eb
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=aa78eab89436fc1003465f8aa29894514f11b7eb

Author: Philippe Gerum 
Date:   Fri Oct 17 11:35:22 2014 +0200

scripts/xeno-config: fix variable quoting

---

 scripts/xeno-config-cobalt.in  |2 +-
 scripts/xeno-config-mercury.in |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/xeno-config-cobalt.in b/scripts/xeno-config-cobalt.in
index 42ee2af..c6c6da5 100644
--- a/scripts/xeno-config-cobalt.in
+++ b/scripts/xeno-config-cobalt.in
@@ -70,7 +70,7 @@ dump_info ()
 version=${XENO_VERSION}
 if test -x $XENO_PREFIX/sbin/version; then
_version=`$XENO_PREFIX/sbin/version 2>/dev/null`
-   test x$_version = x || version=$_version
+   test x"$_version" = x || version="$_version"
 fi
 echo "Xenomai version: ${version}"
 if test -r /proc/ipipe/version; then
diff --git a/scripts/xeno-config-mercury.in b/scripts/xeno-config-mercury.in
index 2ac6fd8..9311f4c 100644
--- a/scripts/xeno-config-mercury.in
+++ b/scripts/xeno-config-mercury.in
@@ -63,7 +63,7 @@ dump_info ()
 version=${XENO_VERSION}
 if test -x $XENO_PREFIX/sbin/version; then
_version=`$XENO_PREFIX/sbin/version 2>/dev/null`
-   test x$_version = x || version=$_version
+   test x"$_version" = x || version="$_version"
 fi
 echo "Xenomai version: ${version}"
 uname -a 2>/dev/null || echo "Cannot determine system information (uname?)"


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


[Xenomai-git] Philippe Gerum : cobalt/arm: disable 32bit syscall emulation

2014-10-25 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 50a49b55e854be62411871e5950401f0f7261a8b
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=50a49b55e854be62411871e5950401f0f7261a8b

Author: Philippe Gerum 
Date:   Thu Oct 16 14:22:01 2014 +0200

cobalt/arm: disable 32bit syscall emulation

---

 kernel/cobalt/arch/arm/Kconfig   |3 +++
 kernel/cobalt/arch/arm/syscall.c |5 +
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/kernel/cobalt/arch/arm/Kconfig b/kernel/cobalt/arch/arm/Kconfig
index 03826de..dc6485d 100644
--- a/kernel/cobalt/arch/arm/Kconfig
+++ b/kernel/cobalt/arch/arm/Kconfig
@@ -32,6 +32,9 @@ config XENO_ARCH_WANT_TIP
 config XENO_ARCH_FPU
def_bool VFP
 
+config XENO_ARCH_SYS3264
+def_bool n
+
 config XENO_ARCH_OUTOFLINE_XNLOCK
bool
default y
diff --git a/kernel/cobalt/arch/arm/syscall.c b/kernel/cobalt/arch/arm/syscall.c
index 8e9c801..735208b 100644
--- a/kernel/cobalt/arch/arm/syscall.c
+++ b/kernel/cobalt/arch/arm/syscall.c
@@ -49,8 +49,5 @@ int xnarch_local_syscall(unsigned long a1, unsigned long a2,
break;
}
 
-   if (__xn_copy_to_user((void *)a2, &info, sizeof(info)))
-   return -EFAULT;
-
-   return 0;
+   return __xn_safe_copy_to_user((void *)a2, &info, sizeof(info));
 }


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


[Xenomai-git] Jorge Ramirez-Ortiz : utils/analogy: calibration - implement calibrated insn_read

2014-10-25 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 7361c3ad2322727679d28bee48185560eec3a07f
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=7361c3ad2322727679d28bee48185560eec3a07f

Author: Jorge Ramirez-Ortiz 
Date:   Fri Oct 24 09:01:09 2014 -0400

utils/analogy: calibration - implement calibrated insn_read

---

 utils/analogy/insn_read.c |   85 +++--
 1 file changed, 82 insertions(+), 3 deletions(-)

diff --git a/utils/analogy/insn_read.c b/utils/analogy/insn_read.c
index 842bddb..3592aac 100644
--- a/utils/analogy/insn_read.c
+++ b/utils/analogy/insn_read.c
@@ -39,6 +39,7 @@ static int idx_subd = -1;
 static int idx_chan;
 static int idx_rng = -1;
 static unsigned int scan_size = SCAN_CNT;
+static char *calibration_file = NULL;
 
 struct option insn_read_opts[] = {
{"verbose", no_argument, NULL, 'v'},
@@ -47,6 +48,7 @@ struct option insn_read_opts[] = {
{"scan-count", required_argument, NULL, 'S'},
{"channel", required_argument, NULL, 'c'},
{"range", required_argument, NULL, 'R'},
+   {"cal", required_argument, NULL, 'y'},
{"raw", no_argument, NULL, 'w'},
{"help", no_argument, NULL, 'h'},
{0},
@@ -63,6 +65,7 @@ static void do_print_usage(void)
fprintf(stdout, "\t\t -c, --channel: channel to use\n");
fprintf(stdout, "\t\t -R, --range: range to use\n");
fprintf(stdout, "\t\t -w, --raw: dump data in raw format\n");
+   fprintf(stdout, "\t\t -y, --cal: /path/to/calibration.bin \n");
fprintf(stdout, "\t\t -h, --help: print this help\n");
 }
 
@@ -118,9 +121,8 @@ static int dump_text(a4l_desc_t *dsc, unsigned char *buf, 
int size)
if (err < 0)
goto out;
 
-   for (i = 0; i < tmp_cnt; i++) {
+   for (i = 0; i < tmp_cnt; i++)
fprintf(stdout, fmt, values[i]);
-   }
 
tmp_size += tmp_cnt * width;
}
@@ -162,6 +164,7 @@ static int dump_converted(a4l_desc_t *dsc, unsigned char 
*buf, int size)
goto out;
}
 
+   fprintf(stdout, "Non Calibrated values: \n");
while (size - tmp_size > 0) {
double values[64];
int i, tmp_cnt = ((size - tmp_size) / width > 64) ?
@@ -182,6 +185,78 @@ out:
return err;
 }
 
+static int dump_calibrated(a4l_desc_t *dsc, unsigned char *buf, int size)
+{
+   struct a4l_calibration_data cal_info;
+   struct a4l_polynomial converter;
+   int err = 0, width, tmp_size = 0;
+   a4l_chinfo_t *chan;
+   a4l_rnginfo_t *rng;
+
+
+   /* Retrieve the channel info */
+   err = a4l_get_chinfo(dsc, idx_subd, idx_chan, &chan);
+   if (err < 0) {
+   fprintf(stderr,
+   "insn_read: info for channel %d "
+   "on subdevice %d not available (err=%d)\n",
+   idx_chan, idx_subd, err);
+   goto out;
+   }
+
+   /* Retrieve the range info */
+   err = a4l_get_rnginfo(dsc, idx_subd, idx_chan, idx_rng, &rng);
+   if (err < 0) {
+   fprintf(stderr,
+   "insn_read: failed to recover range descriptor\n");
+   goto out;
+   }
+
+   width = a4l_sizeof_chan(chan);
+   if (width < 0) {
+   fprintf(stderr,
+   "insn_read: incoherent info for channel %d\n",
+   idx_chan);
+   err = width;
+   goto out;
+   }
+
+   err = a4l_read_calibration_file(calibration_file, &cal_info);
+   if (err < 0) {
+   fprintf(stderr,
+   "insn_read: failed to read /tmp/calibration.txt \n");
+   goto out;
+   }
+
+   err = a4l_get_softcal_converter(&converter, idx_subd, idx_chan, idx_rng,
+   &cal_info);
+   if (err < 0) {
+   fprintf(stderr,
+   "insn_read: failed to get the softcal converter  \n");
+   goto out;
+   }
+
+   fprintf(stdout, "Calibrated values: \n");
+   while (size - tmp_size > 0) {
+   double values[64];
+   int i, tmp_cnt = ((size - tmp_size) / width > 64) ?
+   64 : ((size - tmp_size) / width);
+
+   err = a4l_rawtodcal(chan, values, buf + tmp_size, tmp_cnt,
+   &converter);
+   if (err < 0)
+   goto out;
+
+   for (i = 0; i < tmp_cnt; i++)
+   fprintf(stdout, "%F\n", values[i]);
+
+   tmp_size += tmp_cnt * width;
+   }
+
+out:
+   return err;
+}
+
 int main(int argc, char *argv[])
 {
int err = 0;
@@ -196,7 +271,7 @@ int main(int argc, char *argv[])
/* Compute arguments */
while ((err = getopt_long(argc,
  argv,
- "vrd:s:S:c:R:w

[Xenomai-git] Philippe Gerum : cobalt/posix: 32bit syscall wrappers

2014-10-25 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: e34b18e0f5de26254b774977acae119cbd7f1f1d
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=e34b18e0f5de26254b774977acae119cbd7f1f1d

Author: Philippe Gerum 
Date:   Thu Oct 16 14:43:59 2014 +0200

cobalt/posix: 32bit syscall wrappers

---

 kernel/cobalt/posix/Makefile|2 +-
 kernel/cobalt/posix/syscall32.c | 1149 ++-
 kernel/cobalt/posix/syscall32.h |  267 +
 3 files changed, 1403 insertions(+), 15 deletions(-)

diff --git a/kernel/cobalt/posix/Makefile b/kernel/cobalt/posix/Makefile
index e965846..22d5f2b 100644
--- a/kernel/cobalt/posix/Makefile
+++ b/kernel/cobalt/posix/Makefile
@@ -20,6 +20,6 @@ xenomai-y :=  \
timer.o \
timerfd.o
 
-xenomai-$(CONFIG_XENO_OPT_SYS3264) += syscall32.o
+xenomai-$(CONFIG_XENO_ARCH_SYS3264) += syscall32.o
 
 ccflags-y := -Iarch/$(SRCARCH)/xenomai/include -Iinclude/xenomai -Ikernel
diff --git a/kernel/cobalt/posix/syscall32.c b/kernel/cobalt/posix/syscall32.c
index 3b0b71c..603c379 100644
--- a/kernel/cobalt/posix/syscall32.c
+++ b/kernel/cobalt/posix/syscall32.c
@@ -17,19 +17,1140 @@
  */
 #include 
 #include 
-#include 
 #include 
+#include 
 #include "internal.h"
-#include "thread.h"
-#include "sched.h"
-#include "mutex.h"
-#include "cond.h"
-#include "mqueue.h"
-#include "sem.h"
-#include "signal.h"
-#include "timer.h"
-#include "monitor.h"
-#include "clock.h"
-#include "event.h"
-#include "timerfd.h"
-#include "io.h"
+#include "syscall32.h"
+#include "../debug.h"
+
+static int sys32_get_timespec(struct timespec *ts,
+ const struct compat_timespec __user *cts)
+{
+   return (cts == NULL ||
+   !access_rok(cts, sizeof(*cts)) ||
+   __xn_get_user(ts->tv_sec, &cts->tv_sec) ||
+   __xn_get_user(ts->tv_nsec, &cts->tv_nsec)) ? -EFAULT : 0;
+}
+
+static int sys32_put_timespec(struct compat_timespec __user *cts,
+ const struct timespec *ts)
+{
+   return (cts == NULL ||
+   !access_wok(cts, sizeof(*cts)) ||
+   __xn_put_user(ts->tv_sec, &cts->tv_sec) ||
+   __xn_put_user(ts->tv_nsec, &cts->tv_nsec)) ? -EFAULT : 0;
+}
+
+static int sys32_get_itimerspec(struct itimerspec *its,
+   const struct compat_itimerspec __user *cits)
+{
+   int ret = sys32_get_timespec(&its->it_value, &cits->it_value);
+
+   return ret ?: sys32_get_timespec(&its->it_interval, &cits->it_interval);
+}
+
+static int sys32_put_itimerspec(struct compat_itimerspec __user *cits,
+   const struct itimerspec *its)
+{
+   int ret = sys32_put_timespec(&cits->it_value, &its->it_value);
+
+   return ret ?: sys32_put_timespec(&cits->it_interval, &its->it_interval);
+}
+
+static int sys32_get_timeval(struct timeval *tv,
+const struct compat_timeval __user *ctv)
+{
+   return (ctv == NULL ||
+   !access_rok(ctv, sizeof(*ctv)) ||
+   __xn_get_user(tv->tv_sec, &ctv->tv_sec) ||
+   __xn_get_user(tv->tv_usec, &ctv->tv_usec)) ? -EFAULT : 0;
+}
+
+static int sys32_put_timeval(struct compat_timeval __user *ctv,
+const struct timeval *tv)
+{
+   return (ctv == NULL ||
+   !access_wok(ctv, sizeof(*ctv)) ||
+   __xn_put_user(tv->tv_sec, &ctv->tv_sec) ||
+   __xn_put_user(tv->tv_usec, &ctv->tv_usec)) ? -EFAULT : 0;
+}
+
+static ssize_t sys32_get_fdset(fd_set *fds, const compat_fd_set __user *cfds,
+  size_t cfdsize)
+{
+   int rdpos, wrpos, rdlim = cfdsize / sizeof(compat_ulong_t);
+
+   if (cfds == NULL || !access_rok(cfds, cfdsize))
+   return -EFAULT;
+
+   for (rdpos = 0, wrpos = 0; rdpos < rdlim; rdpos++, wrpos++)
+   if (__xn_get_user(fds->fds_bits[wrpos], cfds->fds_bits + rdpos))
+   return -EFAULT;
+
+   return (ssize_t)rdlim * sizeof(long);
+}
+
+static ssize_t sys32_put_fdset(compat_fd_set __user *cfds, const fd_set *fds,
+  size_t fdsize)
+{
+   int rdpos, wrpos, wrlim = fdsize / sizeof(long);
+
+   if (cfds == NULL || !access_wok(cfds, wrlim * sizeof(compat_ulong_t)))
+   return -EFAULT;
+
+   for (rdpos = 0, wrpos = 0; wrpos < wrlim; rdpos++, wrpos++)
+   if (__xn_put_user(fds->fds_bits[rdpos], cfds->fds_bits + wrpos))
+   return -EFAULT;
+
+   return (ssize_t)wrlim * sizeof(compat_ulong_t);
+}
+
+static int sys32_get_param_ex(int policy,
+ struct sched_param_ex *p,
+ const struct compat_sched_param_ex __user *u_cp)
+{
+   struct compat_sched_param_ex cpex;
+
+   if (u_cp == NULL || __xn_safe_copy_from_user(&cpex, u_cp, sizeof(cpex)))
+   return -EFAULT;
+
+   p->sched_priority = cpex.sched_priority;

[Xenomai-git] Jorge Ramirez-Ortiz : drivers/analogy: fix warning

2014-10-25 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 4bc876b2b76e772f407c960675ce9301df744dc7
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=4bc876b2b76e772f407c960675ce9301df744dc7

Author: Jorge Ramirez-Ortiz 
Date:   Tue Aug 26 13:51:08 2014 -0400

drivers/analogy: fix warning

---

 kernel/drivers/analogy/instruction.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/drivers/analogy/instruction.c 
b/kernel/drivers/analogy/instruction.c
index 7e7704f..1cbdb14 100644
--- a/kernel/drivers/analogy/instruction.c
+++ b/kernel/drivers/analogy/instruction.c
@@ -205,7 +205,7 @@ int a4l_do_special_insn(struct a4l_device_context * cxt, 
struct a4l_kernel_instr
 
 int a4l_do_insn(struct a4l_device_context * cxt, struct a4l_kernel_instruction 
* dsc)
 {
-   int ret;
+   int ret = 0;
struct a4l_subdevice *subd;
struct a4l_device *dev = a4l_get_dev(cxt);
int (*hdlr) (struct a4l_subdevice *, struct a4l_kernel_instruction *) = 
NULL;


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


[Xenomai-git] Jorge Ramirez-Ortiz : utils/analogy: calibration - use analogy lib to read /write the calibration file

2014-10-25 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 40003000e9692d89e4ec3ce930eebeb62d442935
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=40003000e9692d89e4ec3ce930eebeb62d442935

Author: Jorge Ramirez-Ortiz 
Date:   Sat Oct 11 14:25:26 2014 -0400

utils/analogy: calibration - use analogy lib to read/write the calibration file

---

 include/rtdm/analogy.h|   11 +
 include/rtdm/uapi/analogy.h   |   28 +++
 lib/analogy/Makefile.am   |   11 +-
 lib/analogy/calibration.c |  211 +++
 lib/analogy/calibration.h |   44 
 utils/analogy/Makefile.am |5 +-
 utils/analogy/analogy_calibrate.c |   73 +--
 utils/analogy/analogy_calibrate.h |  131 +---
 utils/analogy/calibration_ni_m.c  |  422 -
 utils/analogy/calibration_ni_m.h  |   36 +---
 10 files changed, 456 insertions(+), 516 deletions(-)

diff --git a/include/rtdm/analogy.h b/include/rtdm/analogy.h
index 57f2ec0..fd26f58 100644
--- a/include/rtdm/analogy.h
+++ b/include/rtdm/analogy.h
@@ -21,9 +21,12 @@
 #ifndef _RTDM_ANALOGY_H
 #define _RTDM_ANALOGY_H
 
+#include 
 #include 
 #include 
 
+#include "boilerplate/list.h"
+
 /*!
   @addtogroup analogy_lib_descriptor
   @{
@@ -227,6 +230,14 @@ int a4l_ftoraw(a4l_chinfo_t *chan,
 int a4l_dtoraw(a4l_chinfo_t *chan,
   a4l_rnginfo_t *rng, void *dst, double *src, int cnt);
 
+void a4l_write_calibration_file(FILE *dst, struct list *l,
+   struct a4l_calibration_subdev *subd,
+   a4l_desc_t *desc);
+
+int a4l_read_calibration_file(char *name, struct a4l_calibration_data *data);
+
+
+
 #endif /* !DOXYGEN_CPP */
 
 #ifdef __cplusplus
diff --git a/include/rtdm/uapi/analogy.h b/include/rtdm/uapi/analogy.h
index 9806c82..669ded7 100644
--- a/include/rtdm/uapi/analogy.h
+++ b/include/rtdm/uapi/analogy.h
@@ -706,4 +706,32 @@ typedef struct a4l_instruction_list a4l_insnlst_t;
 
 /*! @} analogy_lib_sync1 */
 
+struct a4l_calibration_subdev {
+   a4l_sbinfo_t *info;
+   int slen;
+   int idx;
+   char *name;
+};
+
+struct a4l_calibration_subdev_data {
+   int index;
+   int channel;
+   int range;
+   int expansion;
+   int nb_coeff;
+   double *coeff;
+
+};
+
+struct a4l_calibration_data {
+   char *driver_name;
+   char *board_name;
+   int nb_ai;
+   struct a4l_calibration_subdev_data *ai;
+   int nb_ao;
+   struct a4l_calibration_subdev_data *ao;
+};
+
+
+
 #endif /* _RTDM_UAPI_ANALOGY_H */
diff --git a/lib/analogy/Makefile.am b/lib/analogy/Makefile.am
index 4d242ff..500453d 100644
--- a/lib/analogy/Makefile.am
+++ b/lib/analogy/Makefile.am
@@ -7,11 +7,16 @@ libanalogy_la_SOURCES =   \
descriptor.c\
info.c  \
internal.h  \
+   calibration.c   \
range.c \
root_leaf.h \
sync.c  \
sys.c
 
-libanalogy_la_CPPFLAGS =   \
-   @XENO_USER_CFLAGS@  \
-   -I$(top_srcdir)/include
+libanalogy_la_CPPFLAGS =   \
+   @XENO_USER_CFLAGS@  \
+   -I$(top_srcdir)/include \
+   -I$(top_srcdir)/lib/boilerplate 
+
+libanalogy_la_LIBADD = \
+   ../boilerplate/libboilerplate.la
diff --git a/lib/analogy/calibration.c b/lib/analogy/calibration.c
new file mode 100644
index 000..74b2789
--- /dev/null
+++ b/lib/analogy/calibration.c
@@ -0,0 +1,211 @@
+#include 
+#include 
+#include 
+#include 
+#include "iniparser/iniparser.h"
+#include "boilerplate/list.h"
+#include "calibration.h"
+
+#define ARRAY_LEN(a)  (sizeof(a) / sizeof((a)[0]))
+
+static inline int read_dbl(double *d, struct _dictionary_ *f,const char *subd,
+  int subd_idx, char *type, int type_idx)
+{
+   char *str;
+   int ret;
+
+   /* if only contains doubles as coefficients */
+   if (strncmp(type, COEFF_STR, strlen(COEFF_STR) != 0))
+   return -ENOENT;
+
+   ret = asprintf(&str, COEFF_FMT, subd, subd_idx, type, type_idx);
+   if (ret < 0)
+   return ret;
+
+   *d = iniparser_getdouble(f, str, -255.0);
+   if (*d == -255.0)
+   ret = -ENOENT;
+   free(str);
+
+   return ret;
+}
+
+static inline int read_int(int *val, struct _dictionary_ *f, const char *subd,
+  int subd_idx, char *type)
+{
+   char *str;
+   int ret;
+
+   ret = (subd_idx >= 0) ?
+ asprintf(&str, ELEMENT_FIELD_FMT, subd, subd_idx, type):
+ asprintf(&str, ELEMENT_FMT, subd, type);
+   if (ret < 0)
+   return ret;
+
+   *val = iniparser_getint(f, str, 0x);
+   if (*val == 0x)
+   ret = -ENOENT;
+   free(str);
+
+   return ret;
+}
+
+static inline int read_str(char **val, struct _dictionary_ *f, const char 
*subd,
+  const char *type)
+{
+   char *str;
+   int ret;
+
+   ret 

[Xenomai-git] Philippe Gerum : cobalt/blackfin: disable 32bit syscall emulation

2014-10-25 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 4ed2ff124b301752d5eada7e6ba2d157f23ba017
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=4ed2ff124b301752d5eada7e6ba2d157f23ba017

Author: Philippe Gerum 
Date:   Thu Oct 16 14:22:40 2014 +0200

cobalt/blackfin: disable 32bit syscall emulation

---

 kernel/cobalt/arch/blackfin/Kconfig |3 +++
 1 file changed, 3 insertions(+)

diff --git a/kernel/cobalt/arch/blackfin/Kconfig 
b/kernel/cobalt/arch/blackfin/Kconfig
index 9f19382..1ca0278 100644
--- a/kernel/cobalt/arch/blackfin/Kconfig
+++ b/kernel/cobalt/arch/blackfin/Kconfig
@@ -1,5 +1,8 @@
 config XENO_ARCH_FPU
def_bool n
 
+config XENO_ARCH_SYS3264
+def_bool n
+
 source "kernel/xenomai/Kconfig"
 source "drivers/xenomai/Kconfig"


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


[Xenomai-git] Philippe Gerum : testsuite/smokey: xddp: fix race on connection setup

2014-10-25 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: ef7bee345533718c31ecfd63f3ffdf1fc26d3d3e
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=ef7bee345533718c31ecfd63f3ffdf1fc26d3d3e

Author: Philippe Gerum 
Date:   Fri Oct 17 17:43:52 2014 +0200

testsuite/smokey: xddp: fix race on connection setup

---

 testsuite/smokey/xddp/xddp.c |   22 ++
 1 file changed, 22 insertions(+)

diff --git a/testsuite/smokey/xddp/xddp.c b/testsuite/smokey/xddp/xddp.c
index e447fab..6dca6e6 100644
--- a/testsuite/smokey/xddp/xddp.c
+++ b/testsuite/smokey/xddp/xddp.c
@@ -10,6 +10,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -23,6 +24,8 @@ smokey_test_plugin(xddp,
 
 static pthread_t rt1, rt2, nrt;
 
+static sem_t semsync;
+
 #define XDDP_PORT_LABEL  "xddp-smokey"
 
 static void fail(const char *reason)
@@ -59,6 +62,7 @@ static void *realtime_thread1(void *arg)
 
FD_ZERO(&set);
FD_SET(s, &set);
+   sem_post(&semsync); /* unleash client RT thread */
 
for (;;) {
control++;
@@ -89,6 +93,19 @@ static void *realtime_thread1(void *arg)
return NULL;
 }
 
+static void sem_sync(sem_t *sem)
+{
+   int ret;
+
+   for (;;) {
+   ret = sem_wait(sem);
+   if (ret == 0)
+   return;
+   if (errno != EINTR)
+   fail("sem_wait");
+   }
+}
+
 static void *realtime_thread2(void *arg)
 {
struct rtipc_port_label plabel;
@@ -119,6 +136,9 @@ static void *realtime_thread2(void *arg)
if (ret)
fail("setsockopt");
 
+   sem_sync(&semsync);
+   sem_post(&semsync); /* unleash regular thread */
+
memset(&saddr, 0, sizeof(saddr));
saddr.sipc_family = AF_RTIPC;
saddr.sipc_port = -1;   /* Tell XDDP to search by label. */
@@ -200,6 +220,8 @@ static int run_xddp(struct smokey_test *t, int argc, char 
*const argv[])
struct sched_param param = { .sched_priority = 42 };
pthread_attr_t rtattr, regattr;
 
+   sem_init(&semsync, 0, 0);
+
pthread_attr_init(&rtattr);
pthread_attr_setdetachstate(&rtattr, PTHREAD_CREATE_JOINABLE);
pthread_attr_setinheritsched(&rtattr, PTHREAD_EXPLICIT_SCHED);


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


[Xenomai-git] Philippe Gerum : cobalt/x86: enable 32bit syscall emulation

2014-10-25 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 410b376b82a28208d5640bc5037f2c43a6706d02
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=410b376b82a28208d5640bc5037f2c43a6706d02

Author: Philippe Gerum 
Date:   Thu Oct 16 14:21:56 2014 +0200

cobalt/x86: enable 32bit syscall emulation

---

 kernel/cobalt/arch/x86/Kconfig |5 +-
 .../cobalt/arch/x86/include/asm/xenomai/syscall.h  |8 +-
 .../arch/x86/include/asm/xenomai/syscall32-table.h |   54 ---
 .../arch/x86/include/asm/xenomai/syscall32.h   |  147 ++--
 4 files changed, 180 insertions(+), 34 deletions(-)

diff --git a/kernel/cobalt/arch/x86/Kconfig b/kernel/cobalt/arch/x86/Kconfig
index 72e539a..9adbbf7 100644
--- a/kernel/cobalt/arch/x86/Kconfig
+++ b/kernel/cobalt/arch/x86/Kconfig
@@ -1,9 +1,8 @@
 config XENO_ARCH_FPU
def_bool y
 
-config XENO_ARCH_X32
-def_bool X86_X32
-   select XENO_OPT_SYS3264
+config XENO_ARCH_SYS3264
+def_bool IA32_EMULATION
 
 source "kernel/xenomai/Kconfig"
 source "drivers/xenomai/Kconfig"
diff --git a/kernel/cobalt/arch/x86/include/asm/xenomai/syscall.h 
b/kernel/cobalt/arch/x86/include/asm/xenomai/syscall.h
index ddbb3df..5901e4d 100644
--- a/kernel/cobalt/arch/x86/include/asm/xenomai/syscall.h
+++ b/kernel/cobalt/arch/x86/include/asm/xenomai/syscall.h
@@ -42,8 +42,12 @@
 #define __xn_reg_sp(regs) ((regs)->sp)
 
 #define __xn_syscall_p(regs)  (__xn_reg_sys(regs) & __COBALT_SYSCALL_BIT)
-#define __xn_syscall(regs)(__xn_reg_sys(regs) & \
-  ~(__COBALT_SYSCALL_BIT|__COBALT_SYSCALL_MASK))
+#ifdef CONFIG_XENO_ARCH_SYS3264
+#define __xn_syscall(regs)__COBALT_CALL32_SYSNR(__xn_reg_sys(regs) \
+   & ~__COBALT_SYSCALL_BIT)
+#else
+#define __xn_syscall(regs)(__xn_reg_sys(regs) & ~__COBALT_SYSCALL_BIT)
+#endif
 
 static inline void __xn_success_return(struct pt_regs *regs, int v)
 {
diff --git a/kernel/cobalt/arch/x86/include/asm/xenomai/syscall32-table.h 
b/kernel/cobalt/arch/x86/include/asm/xenomai/syscall32-table.h
index b7da23b..1c84ef3 100644
--- a/kernel/cobalt/arch/x86/include/asm/xenomai/syscall32-table.h
+++ b/kernel/cobalt/arch/x86/include/asm/xenomai/syscall32-table.h
@@ -24,22 +24,42 @@
  * table. Only preprocessor stuff and syscall entries here.
  */
 
-#ifdef CONFIG_X86_X32
-
-/*
- * When x32 support is enabled, we need thunks for dealing with
- * 32<->64 argument conversion. An additional entry for each
- * __COBALT_CALL_X32 syscall is generated into the table, at a
- * position equal to the original syscall number + __COBALT_X32_BASE
- * as defined in asm/xenomai/syscall32.h.
- */
-
-#define __sysx32__(__name) \
-   ((cobalt_syshand)(cobalt32x_ ## __name))
-
-#define __COBALT_CALL_X32(__name)  \
-   [sc_cobalt_ ## __name + __COBALT_X32_BASE] = __sysx32__(__name),
-
-#endif
+__COBALT_CALL32emu_THUNK(thread_create)
+__COBALT_CALL32emu_THUNK(thread_setschedparam_ex)
+__COBALT_CALL32emu_THUNK(thread_getschedparam_ex)
+__COBALT_CALL32emu_THUNK(sem_open)
+__COBALT_CALL32emu_THUNK(sem_timedwait)
+__COBALT_CALL32emu_THUNK(clock_getres)
+__COBALT_CALL32emu_THUNK(clock_gettime)
+__COBALT_CALL32emu_THUNK(clock_settime)
+__COBALT_CALL32emu_THUNK(clock_nanosleep)
+__COBALT_CALL32emu_THUNK(mutex_timedlock)
+__COBALT_CALL32emu_THUNK(cond_wait_prologue)
+__COBALT_CALL32emu_THUNK(mq_open)
+__COBALT_CALL32emu_THUNK(mq_getattr)
+__COBALT_CALL32emu_THUNK(mq_setattr)
+__COBALT_CALL32emu_THUNK(mq_timedsend)
+__COBALT_CALL32emu_THUNK(mq_timedreceive)
+__COBALT_CALL32emu_THUNK(mq_notify)
+__COBALT_CALL32emu_THUNK(sched_weightprio)
+__COBALT_CALL32emu_THUNK(sched_setconfig_np)
+__COBALT_CALL32emu_THUNK(sched_getconfig_np)
+__COBALT_CALL32emu_THUNK(timer_create)
+__COBALT_CALL32emu_THUNK(timer_settime)
+__COBALT_CALL32emu_THUNK(timer_gettime)
+__COBALT_CALL32emu_THUNK(timerfd_settime)
+__COBALT_CALL32emu_THUNK(timerfd_gettime)
+__COBALT_CALL32emu_THUNK(sigwait)
+__COBALT_CALL32emu_THUNK(sigtimedwait)
+__COBALT_CALL32emu_THUNK(sigwaitinfo)
+__COBALT_CALL32emu_THUNK(sigpending)
+__COBALT_CALL32emu_THUNK(sigqueue)
+__COBALT_CALL32emu_THUNK(monitor_wait)
+__COBALT_CALL32emu_THUNK(event_wait)
+__COBALT_CALL32emu_THUNK(select)
+__COBALT_CALL32emu_THUNK(recvmsg)
+__COBALT_CALL32emu_THUNK(sendmsg)
+__COBALT_CALL32emu_THUNK(mmap)
+__COBALT_CALL32emu_THUNK(backtrace)
 
 #endif /* !_COBALT_X86_ASM_SYSCALL32_TABLE_H */
diff --git a/kernel/cobalt/arch/x86/include/asm/xenomai/syscall32.h 
b/kernel/cobalt/arch/x86/include/asm/xenomai/syscall32.h
index b83aaf4..e4890a6 100644
--- a/kernel/cobalt/arch/x86/include/asm/xenomai/syscall32.h
+++ b/kernel/cobalt/arch/x86/include/asm/xenomai/syscall32.h
@@ -19,26 +19,50 @@
 #ifndef _COBALT_X86_ASM_SYSCALL32_H
 #define _COBALT_X86_ASM_SYSCALL32_H
 
+#include 
+
 #ifdef CONFIG_X86_X32
 
-#include 
+#define __COBALT_X32_BASE  128
+
+#define __COBALT_SYSNR32x(__reg)   \
+   ({   

[Xenomai-git] Jorge Ramirez-Ortiz : utils/analogy: calibration - parse the calibration file

2014-10-25 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: b7da3d6cc1992ab38c279dd32e6130905727c997
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=b7da3d6cc1992ab38c279dd32e6130905727c997

Author: Jorge Ramirez-Ortiz 
Date:   Wed Sep 17 09:30:13 2014 -0700

utils/analogy: calibration - parse the calibration file

---

 lib/boilerplate/iniparser/iniparser.c |6 +-
 utils/analogy/analogy_calibrate.c |   42 ++--
 utils/analogy/analogy_calibrate.h |  123 +++---
 utils/analogy/calibration_ni_m.c  |  184 -
 utils/analogy/calibration_ni_m.h  |9 +-
 5 files changed, 241 insertions(+), 123 deletions(-)

diff --git a/lib/boilerplate/iniparser/iniparser.c 
b/lib/boilerplate/iniparser/iniparser.c
index 0e1621d..5b2094a 100644
--- a/lib/boilerplate/iniparser/iniparser.c
+++ b/lib/boilerplate/iniparser/iniparser.c
@@ -619,11 +619,13 @@ dictionary * iniparser_load(const char * ininame)
 
case LINE_ERROR:
 #if 0
-warning(anon_scope, "iniparser: syntax error in %s (%d):\n",
+printf("iniparser: syntax error in %s (%d):\n",
 ininame,
 lineno);
-warning(anon_scope, "-> %s\n", line);
+printf( "-> %s\n", line);
+
 #endif
+
ret = EINVAL;
 errs++ ;
 break;
diff --git a/utils/analogy/analogy_calibrate.c 
b/utils/analogy/analogy_calibrate.c
index b2ac286..8404811 100644
--- a/utils/analogy/analogy_calibrate.c
+++ b/utils/analogy/analogy_calibrate.c
@@ -87,22 +87,22 @@ apply_calibration_set_globals(char *info)
params.name = strtok(info, ":");
p = strtok(NULL, ",");
if (!p)
-   error(EXIT, 0, "missing --apply parameter \n");
+   error(EXIT, 0, "missing --apply parameter subd \n");
params.subd = strtol(p, NULL, 0);
 
p = strtok(NULL, ",");
if (!p)
-   error(EXIT, 0, "missing --apply parameter \n");
+   error(EXIT, 0, "missing --apply parameter channel \n");
params.channel = strtol(p, NULL, 0);
 
p = strtok(NULL, ",");
if (!p)
-   error(EXIT, 0, "missing --apply parameter \n");
+   error(EXIT, 0, "missing --apply parameter range \n");
params.range = strtol(p, NULL, 0);
 
p = strtok(NULL, "");
if (!p)
-   error(EXIT, 0, "missing --apply parameter \n");
+   error(EXIT, 0, "missing --apply parameter aref \n");
params.aref = strtol(p, NULL, 0);
 
return 0;
@@ -114,10 +114,8 @@ static void __attribute__ ((constructor)) 
__analogy_calibrate_init(void)
 }
 int main(int argc, char *argv[])
 {
-   struct sched_param param = {.sched_priority = 99};
char *device = NULL, *file = NULL, *apply_info = NULL;
int v, i, fd, err = 0;
-   struct rlimit rl;
 
__debug("version: git commit %s, revision %s \n", GIT_STAMP, revision);
 
@@ -152,26 +150,6 @@ int main(int argc, char *argv[])
if (apply_info)
apply_calibration_set_globals(apply_info);
 
-   err = getrlimit(RLIMIT_STACK, &rl);
-   if (!err) {
-   if (rl.rlim_cur < rl.rlim_max) {
-   rl.rlim_cur = rl.rlim_max;
-   err = setrlimit(RLIMIT_STACK, &rl);
-   if (err)
-   __debug("setrlimit errno (%d) \n", errno);
-   else
-   __debug("Program Stack Size: %ld MB \n\n", 
rl.rlim_cur/(1024*1024));
-   }
-   }
-
-   err = mlockall(MCL_CURRENT | MCL_FUTURE);
-   if (err < 0)
-   error(EXIT, errno, "mlockall error");
-
-   err = pthread_setschedparam(pthread_self(), SCHED_FIFO, ¶m);
-   if (err)
-   error(EXIT, 0, "pthread_setschedparam failed (0x%x)", err);
-
fd = a4l_open(&descriptor, device);
if (fd < 0)
error(EXIT, 0, "open %s failed (%d)", device, fd);
@@ -184,17 +162,19 @@ int main(int argc, char *argv[])
/*
 * TODO: modify the meaning of board/driver in the proc
 */
-   push_to_cal_file("[platform] \n");
-   push_to_cal_file("driver_name: %s \n", descriptor.board_name);
-   push_to_cal_file("board_name: %s \n", descriptor.driver_name);
+   push_to_cal_file("[%s] \n",PLATFORM_STR);
+   push_to_cal_file(DRIVER_STR" = %s;\n", descriptor.board_name);
+   push_to_cal_file(BOARD_STR" = %s;\n", descriptor.driver_name);
 
err = ni_m_software_calibrate();
if (err)
error(CONT, 0, "software calibration failed (%d)", err);
 
+   err = ni_m_apply_calibration();
+   if (err)
+   error(CONT, 0, "applying calibration failed (%d)", err);
+
a4l_close(&descriptor);
-   if (cal)
-   fclose(cal);
 
return err;
 }
diff --git a/utils/analogy/analogy_calibrate.h 
b/utils/analogy/analogy_calibrate.h
index

[Xenomai-git] Jorge Ramirez-Ortiz : lib/boilerplate: add iniparser to boilerplate

2014-10-25 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 1b9bb80f6fc5696ec757727273f75a89f754c366
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=1b9bb80f6fc5696ec757727273f75a89f754c366

Author: Jorge Ramirez-Ortiz 
Date:   Fri Sep 12 10:01:45 2014 -0400

lib/boilerplate: add iniparser to boilerplate

---

 lib/boilerplate/Makefile.am|   21 +-
 lib/boilerplate/iniparser/LICENSE  |   21 +
 lib/boilerplate/iniparser/README   |1 +
 lib/boilerplate/iniparser/dictionary.c |  405 +++
 lib/boilerplate/iniparser/dictionary.h |  174 +
 lib/boilerplate/iniparser/iniparser.c  |  667 
 lib/boilerplate/iniparser/iniparser.h  |  281 ++
 7 files changed, 1567 insertions(+), 3 deletions(-)

diff --git a/lib/boilerplate/Makefile.am b/lib/boilerplate/Makefile.am
index 0a14d18..e2275c1 100644
--- a/lib/boilerplate/Makefile.am
+++ b/lib/boilerplate/Makefile.am
@@ -31,10 +31,25 @@ libboilerplate_la_CPPFLAGS =
\
-I$(top_srcdir) \
-I$(top_srcdir)/include
 
+libboilerplate_la_LIBADD = libiniparser.la
+noinst_LTLIBRARIES += libiniparser.la
+
+libiniparser_la_SOURCES=   \
+   iniparser/dictionary.c  \
+   iniparser/dictionary.h  \
+   iniparser/iniparser.h   \
+   iniparser/iniparser.c
+
+libiniparser_la_CPPFLAGS   =   \
+   -Iiniparser @XENO_USER_CFLAGS@  \
+   -I$(top_srcdir)/include
+
+EXTRA_DIST = iniparser/README iniparser/LICENSE
+
 # We always build the tlsf/malloc support. In the pshared case, it
 # will provide for private memory allocation.
 if XENO_TLSF
-libboilerplate_la_LIBADD = libtlsf.la
+libboilerplate_la_LIBADD +=libtlsf.la
 noinst_LTLIBRARIES += libtlsf.la
 endif
 
@@ -48,11 +63,11 @@ libtlsf_la_CPPFLAGS =   
\
-I$(top_srcdir)/include \
-DTLSF_USE_LOCKS=1 -DUSE_MMAP=1 -DTLSF_STATISTIC=1
 
-EXTRA_DIST = tlsf/README
+EXTRA_DIST += tlsf/README
 
 SPARSE = sparse
 
 sparse:
-   @for i in $(libboilerplate_la_SOURCES) $(libtlsf_la_SOURCES); do \
+   @for i in $(libboilerplate_la_SOURCES) $(libtlsf_la_SOURCES) 
$(libiniparser_la_SOURCES; do \
$(SPARSE) $(CHECKFLAGS) $(srcdir)/$$i; \
done
diff --git a/lib/boilerplate/iniparser/LICENSE 
b/lib/boilerplate/iniparser/LICENSE
new file mode 100644
index 000..dbfa45d
--- /dev/null
+++ b/lib/boilerplate/iniparser/LICENSE
@@ -0,0 +1,21 @@
+Copyright (c) 2000-2007 by Nicolas Devillard.
+MIT License
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+the rights to use, copy, modify, merge, publish, distribute, sublicense,
+and/or sell copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
+
diff --git a/lib/boilerplate/iniparser/README b/lib/boilerplate/iniparser/README
new file mode 100644
index 000..dfa43c8
--- /dev/null
+++ b/lib/boilerplate/iniparser/README
@@ -0,0 +1 @@
+See http://ndevilla.free.fr/iniparser/
diff --git a/lib/boilerplate/iniparser/dictionary.c 
b/lib/boilerplate/iniparser/dictionary.c
new file mode 100644
index 000..5299b77
--- /dev/null
+++ b/lib/boilerplate/iniparser/dictionary.c
@@ -0,0 +1,405 @@
+/*-*/
+/**
+   @file   dictionary.c
+   @author N. Devillard
+   @date   Sep 2007
+   @version$Revision: 1.27 $
+   @brief  Implements a dictionary for string variables.
+
+   This module implements a simple dictionary object, i.e. a list
+   of string/string associations. This object is useful to store e.g.
+   informations retrieved from a configuration file (ini files).
+*/
+/*--*/
+
+/*
+   $Id: dictionary.c,v 1.27 2007-11-23 21:39:18 ndevilla Exp $
+   $Revision: 1.27 $
+*/
+/*---
+   Includes
+ ---*/
+#include

[Xenomai-git] Jorge Ramirez-Ortiz : rtdm/uapi: define PACK_FLAGS using previous definition of PACK

2014-10-25 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 1afb1b18234678324d03875d58db48777efeeaf5
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=1afb1b18234678324d03875d58db48777efeeaf5

Author: Jorge Ramirez-Ortiz 
Date:   Thu Sep 11 18:03:07 2014 -0400

rtdm/uapi: define PACK_FLAGS using previous definition of PACK

---

 include/rtdm/uapi/analogy.h |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/rtdm/uapi/analogy.h b/include/rtdm/uapi/analogy.h
index 458d5f7..9806c82 100644
--- a/include/rtdm/uapi/analogy.h
+++ b/include/rtdm/uapi/analogy.h
@@ -248,7 +248,7 @@ typedef struct a4l_dev_info a4l_dvinfo_t;
 /**
  * Channel + range + reference + flags definition macro
  */
-#define PACK_FLAGS(a, b, c, d) (CHAN(a) | RNG(b) | AREF(c) | FLAGS(d))
+#define PACK_FLAGS(a, b, c, d) (PACK(a, b, c) | FLAGS(d))
 
 /**
  * Analog reference is analog ground


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


[Xenomai-git] Jorge Ramirez-Ortiz : drivers/analogy: NI M - cmd test update (from comedi )

2014-10-25 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: add4ebedafb2ede14a4bd7ad61b1cfc72d5fc630
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=add4ebedafb2ede14a4bd7ad61b1cfc72d5fc630

Author: Jorge Ramirez-Ortiz 
Date:   Tue Aug 26 13:45:23 2014 -0400

drivers/analogy: NI M - cmd test update (from comedi)

In order to mimic the comedi behaviour, the simulation comand shall update
command fields specifics to the driver.

To that end, the a4l_cmd_t structure defines a driver specific bitfield to
indidate which states are allowed by the driver to not be reported as errors.

---

 include/rtdm/uapi/analogy.h|   33 +--
 .../analogy/national_instruments/mio_common.c  |  256 +---
 2 files changed, 190 insertions(+), 99 deletions(-)

diff --git a/include/rtdm/uapi/analogy.h b/include/rtdm/uapi/analogy.h
index 98c6154..458d5f7 100644
--- a/include/rtdm/uapi/analogy.h
+++ b/include/rtdm/uapi/analogy.h
@@ -236,7 +236,7 @@ typedef struct a4l_dev_info a4l_dvinfo_t;
 /**
  * Reference definition macro
  */
-#define AREF(a) (((a) & 0xf) << 24)
+#define AREF(a) (((a) & 0x03) << 24)
 /**
  * Flags definition macro
  */
@@ -244,7 +244,7 @@ typedef struct a4l_dev_info a4l_dvinfo_t;
 /**
  * Channel + range + reference definition macro
  */
-#define PACK(a, b, c) (CHAN(a) | RNG(b) | AREF(c))
+#define PACK(a, b, c) (a | RNG(b) | AREF(c))
 /**
  * Channel + range + reference + flags definition macro
  */
@@ -276,8 +276,8 @@ typedef struct a4l_dev_info a4l_dvinfo_t;
 #define CR_DITHER CR_ALT_FILTER
 #define CR_DEGLITCH CR_ALT_FILTER
 #define CR_ALT_SOURCE (1<<27)
-#define CR_EDGE(1<<28)
-#define CR_INVERT (1<<29)
+#define CR_EDGE(1<<30)
+#define CR_INVERT (1<<31)
 
 #endif /* !DOXYGEN_CPP */
 
@@ -288,43 +288,46 @@ typedef struct a4l_dev_info a4l_dvinfo_t;
 
 struct a4l_cmd_desc {
unsigned char idx_subd;
-   /**< Subdevice to which the command will be 
applied. */
+  /**< Subdevice to which the command will be 
applied. */
 
unsigned long flags;
-/**< Command flags */
+  /**< Command flags */
 
/* Command trigger characteristics */
unsigned int start_src;
-   /**< Start trigger type */
+  /**< Start trigger type */
unsigned int start_arg;
-   /**< Start trigger argument */
+  /**< Start trigger argument */
unsigned int scan_begin_src;
-/**< Scan begin trigger type */
+  /**< Scan begin trigger type */
unsigned int scan_begin_arg;
-/**< Scan begin trigger argument */
+  /**< Scan begin trigger argument */
unsigned int convert_src;
- /**< Convert trigger type */
+  /**< Convert trigger type */
unsigned int convert_arg;
- /**< Convert trigger argument */
+  /**< Convert trigger argument */
unsigned int scan_end_src;
   /**< Scan end trigger type */
unsigned int scan_end_arg;
   /**< Scan end trigger argument */
unsigned int stop_src;
-  /**< Stop trigger type */
+  /**< Stop trigger type */
unsigned int stop_arg;
   /**< Stop trigger argument */
 
unsigned char nb_chan;
   /**< Count of channels related with the command */
unsigned int *chan_descs;
- /**< Tab containing channels descriptors */
+   /**< Tab containing channels descriptors */
 
/* Driver specific fields */
+   unsigned int valid_simul_stages;
+  /** < cmd simulation valid stages (driver dependent) 
*/
+
unsigned int data_len;
   /**< Driver specific buffer size */
sampl_t *data;
-  /**< Driver specific buffer pointer */
+  /**< Driver specific buffer pointer */
 };
 typedef struct a4l_cmd_desc a4l_cmd_t;
 
diff --git a/kernel/drivers/analogy/national_instruments/mio_common.c 
b/kernel/drivers/analogy/national_instruments/mio_common.c
index e5ccf7a..6c5bba0 100644
--- a/kernel/drivers/analogy/national_instruments/mio_common.c
+++ b/kernel/drivers/analogy/national_instruments/mio_common.c
@@ -2029,52 +2029,145 @@ int ni_ai_inttrig(struct a4l_subdevice *subd, lsampl_t 
trignum)
return 1;
 }
 
-static int ni_ai_cmdtest(struct a4l_subdevice *subd, struct a4l_cmd_desc * cmd)
+#define cfc_check_trigger_arg_is(a,b) __cfc_check_trigger_arg_is(a,b, dev, 
__LINE__)
+static inline int __cfc_check_trigger_arg_is(unsigned int *arg,
+

[Xenomai-git] Jorge Ramirez-Ortiz : utils/analogy: calibration - use the analogy' s math utils

2014-10-25 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 9d04cc5ee852c064cad2f28002db883d11131299
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=9d04cc5ee852c064cad2f28002db883d11131299

Author: Jorge Ramirez-Ortiz 
Date:   Tue Oct 14 21:03:05 2014 -0400

utils/analogy: calibration - use the analogy's math utils

---

 include/rtdm/analogy.h|   12 ++
 include/rtdm/uapi/analogy.h   |2 +-
 lib/analogy/Makefile.am   |5 +-
 lib/analogy/calibration.c |   22 ++
 lib/analogy/calibration.h |   21 ++
 lib/analogy/math.c|  418 +
 utils/analogy/Makefile.am |2 +-
 utils/analogy/analogy_calibrate.c |6 +-
 utils/analogy/calibration_ni_m.c  |  106 +++---
 utils/analogy/calibration_ni_m.h  |6 +-
 10 files changed, 515 insertions(+), 85 deletions(-)

diff --git a/include/rtdm/analogy.h b/include/rtdm/analogy.h
index fd26f58..c03d2b1 100644
--- a/include/rtdm/analogy.h
+++ b/include/rtdm/analogy.h
@@ -236,6 +236,18 @@ void a4l_write_calibration_file(FILE *dst, struct list *l,
 
 int a4l_read_calibration_file(char *name, struct a4l_calibration_data *data);
 
+int a4l_math_polyfit(unsigned order, double *r,double orig,
+const unsigned dim, double *x, double *y);
+
+void a4l_math_mean(double *pmean, double *val, unsigned nr);
+
+void a4l_math_stddev(double *pstddev,
+double mean, double *val, unsigned nr);
+
+void a4l_math_stddev_of_mean(double *pstddevm,
+double mean, double *val, unsigned nr);
+
+
 
 
 #endif /* !DOXYGEN_CPP */
diff --git a/include/rtdm/uapi/analogy.h b/include/rtdm/uapi/analogy.h
index 669ded7..a0a1e59 100644
--- a/include/rtdm/uapi/analogy.h
+++ b/include/rtdm/uapi/analogy.h
@@ -708,9 +708,9 @@ typedef struct a4l_instruction_list a4l_insnlst_t;
 
 struct a4l_calibration_subdev {
a4l_sbinfo_t *info;
+   char *name;
int slen;
int idx;
-   char *name;
 };
 
 struct a4l_calibration_subdev_data {
diff --git a/lib/analogy/Makefile.am b/lib/analogy/Makefile.am
index 500453d..b79d4cb 100644
--- a/lib/analogy/Makefile.am
+++ b/lib/analogy/Makefile.am
@@ -7,6 +7,7 @@ libanalogy_la_SOURCES = \
descriptor.c\
info.c  \
internal.h  \
+   math.c  \
calibration.c   \
range.c \
root_leaf.h \
@@ -19,4 +20,6 @@ libanalogy_la_CPPFLAGS =  \
-I$(top_srcdir)/lib/boilerplate 
 
 libanalogy_la_LIBADD = \
-   ../boilerplate/libboilerplate.la
+   ../boilerplate/libboilerplate.la\
+   -lm
+
diff --git a/lib/analogy/calibration.c b/lib/analogy/calibration.c
index 74b2789..85860d1 100644
--- a/lib/analogy/calibration.c
+++ b/lib/analogy/calibration.c
@@ -1,3 +1,25 @@
+/**
+ * @file
+ * Analogy for Linux, device, subdevice, etc. related features
+ *
+ * @note Copyright (C) 1997-2000 David A. Schleef 
+ * @note Copyright (C) 2014 Jorge A. Ramirez-Ortiz 
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
+ */
+
 #include 
 #include 
 #include 
diff --git a/lib/analogy/calibration.h b/lib/analogy/calibration.h
index 04a7e72..4080c60 100644
--- a/lib/analogy/calibration.h
+++ b/lib/analogy/calibration.h
@@ -1,3 +1,24 @@
+/**
+ * @file
+ * Analogy for Linux, internal calibration declarations
+ *
+ * @note Copyright (C) 2014 Jorge A Ramirez-Ortiz 
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
+ */
+
 #ifndef __ANALOGY_CALIBRATION_H__
 #define __ANALOGY_CALIBRATION_H__
 
diff --git a/lib/analogy/math.c b/lib/analogy/math.c
new 

[Xenomai-git] Philippe Gerum : cobalt/testsuite: fixup for 32bit emulation

2014-10-25 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 8b793f7dab4b9b0d046755d76c4027794c8ac54e
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=8b793f7dab4b9b0d046755d76c4027794c8ac54e

Author: Philippe Gerum 
Date:   Wed Oct 22 10:53:36 2014 +0200

cobalt/testsuite: fixup for 32bit emulation

---

 demo/alchemy/altency.c  |   44 ++--
 include/rtdm/uapi/autotune.h|2 +
 include/rtdm/uapi/testing.h |   78 ++-
 kernel/drivers/testing/switchtest.c |2 +-
 kernel/drivers/testing/timerbench.c |   28 ++---
 testsuite/latency/latency.c |   53 
 testsuite/switchtest/switchtest.c   |6 +--
 7 files changed, 90 insertions(+), 123 deletions(-)

diff --git a/demo/alchemy/altency.c b/demo/alchemy/altency.c
index ef1a694..2e4d093 100644
--- a/demo/alchemy/altency.c
+++ b/demo/alchemy/altency.c
@@ -25,9 +25,9 @@ RT_SEM display_sem;
 #define TEN_MILLIONS1000
 
 unsigned max_relaxed;
-long minjitter, maxjitter, avgjitter;
-long gminjitter = TEN_MILLIONS, gmaxjitter = -TEN_MILLIONS, goverrun = 0;
-long long gavgjitter = 0;
+int32_t minjitter, maxjitter, avgjitter;
+int32_t gminjitter = TEN_MILLIONS, gmaxjitter = -TEN_MILLIONS, goverrun = 0;
+int64_t gavgjitter = 0;
 
 long long period_ns = 0;
 int test_duration = 0; /* sec of testing, via -T , 0 is inf */
@@ -57,7 +57,7 @@ int test_loops = 0;   /* outer loop count */
 #define WARMUP_TIME 1
 #define HISTOGRAM_CELLS 300
 int histogram_size = HISTOGRAM_CELLS;
-long *histogram_avg = NULL, *histogram_max = NULL, *histogram_min = NULL;
+int32_t *histogram_avg = NULL, *histogram_max = NULL, *histogram_min = NULL;
 
 char *do_gnuplot = NULL;
 int do_histogram = 0, do_stats = 0, finished = 0;
@@ -65,10 +65,10 @@ int bucketsize = 1000;  /* default = 1000ns, -B 
 to override */
 
 #define need_histo() (do_histogram || do_stats || do_gnuplot)
 
-static inline void add_histogram(long *histogram, long addval)
+static inline void add_histogram(int32_t *histogram, int32_t addval)
 {
/* bucketsize steps */
-   long inabs = (addval >= 0 ? addval : -addval) / bucketsize;
+   int inabs = (addval >= 0 ? addval : -addval) / bucketsize;
histogram[inabs < histogram_size ? inabs : histogram_size - 1]++;
 }
 
@@ -77,7 +77,7 @@ static void latency(void *cookie)
RTIME expected_ns, start_ns, fault_threshold;
unsigned int old_relaxed = 0, new_relaxed;
int ret, count, nsamples, warmup = 1;
-   long minj, maxj, dt, overrun, sumj;
+   int32_t minj, maxj, dt, overrun, sumj;
unsigned long ov;
 
fault_threshold = CONFIG_XENO_DEFAULT_PERIOD;
@@ -100,7 +100,7 @@ static void latency(void *cookie)
 
for (count = sumj = 0; count < nsamples; count++) {
ret = rt_task_wait_period(&ov);
-   dt = (long)(rt_timer_read() - expected_ns);
+   dt = (int32_t)(rt_timer_read() - expected_ns);
new_relaxed = sampling_relaxed;
if (dt > maxj) {
if (new_relaxed != old_relaxed
@@ -213,7 +213,7 @@ static void display(void *cookie)
test_duration);
 
for (;;) {
-   long minj, gminj, maxj, gmaxj, avgj;
+   int32_t minj, gminj, maxj, gmaxj, avgj;
 
if (test_mode == USER_TASK) {
ret = rt_sem_p(&display_sem, TM_INFINITE);
@@ -268,7 +268,7 @@ static void display(void *cookie)
   "lat max", "-overrun", "---msw",
   "---lat best", "--lat worst");
}
-   
printf("RTD|%11.3f|%11.3f|%11.3f|%8ld|%6u|%11.3f|%11.3f\n",
+   
printf("RTD|%11.3f|%11.3f|%11.3f|%8d|%6u|%11.3f|%11.3f\n",
   (double)minj / 1000,
   (double)avgj / 1000,
   (double)maxj / 1000,
@@ -279,7 +279,7 @@ static void display(void *cookie)
}
 }
 
-static double dump_histogram(long *histogram, char *kind)
+static double dump_histogram(int32_t *histogram, char *kind)
 {
int n, total_hits = 0;
double avg = 0; /* used to sum hits 1st */
@@ -288,13 +288,13 @@ static double dump_histogram(long *histogram, char *kind)
printf("---|--param|range-|--samples\n");
 
for (n = 0; n < histogram_size; n++) {
-   long hits = histogram[n];
+   int32_t hits = histogram[n];
 
if (hits) {
total_hits += hits;
avg += n * hits;
if (do_histogram)
-   printf("HSD|%s| %3d -%3d | %8ld\n",
+   printf("HSD|%s| %3d -%3d | %8d\n",
   kind, n, n + 1, hit

[Xenomai-git] Philippe Gerum : cobalt: fix 32/64bit code neutrality issues

2014-10-25 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: daa824592f21fc102fd7edb5aa036412d49f6b2e
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=daa824592f21fc102fd7edb5aa036412d49f6b2e

Author: Philippe Gerum 
Date:   Sun Oct 19 19:15:38 2014 +0200

cobalt: fix 32/64bit code neutrality issues

---

 include/boilerplate/compiler.h |4 +
 include/cobalt/kernel/ppd.h|2 +-
 include/cobalt/kernel/rtdm/Makefile.am |1 +
 include/cobalt/kernel/rtdm/compat.h|   73 ++
 include/cobalt/kernel/rtdm/fd.h|4 +-
 include/cobalt/uapi/cond.h |   10 +-
 include/cobalt/uapi/event.h|9 +-
 include/cobalt/uapi/kernel/vdso.h  |   11 +-
 include/cobalt/uapi/monitor.h  |9 +-
 include/cobalt/uapi/mutex.h|7 +-
 include/cobalt/uapi/sem.h  |4 +-
 kernel/cobalt/arch/arm/mayday.c|   26 +-
 kernel/cobalt/arch/blackfin/mayday.c   |   26 +-
 kernel/cobalt/arch/nios2/mayday.c  |   26 +-
 kernel/cobalt/arch/powerpc/mayday.c|   26 +-
 kernel/cobalt/arch/sh/mayday.c |   26 +-
 kernel/cobalt/arch/x86/mayday.c|   51 +-
 kernel/cobalt/include/asm-generic/xenomai/mayday.h |6 +-
 kernel/cobalt/posix/clock.c|4 +-
 kernel/cobalt/posix/cond.c |   12 +-
 kernel/cobalt/posix/event.c|   52 +-
 kernel/cobalt/posix/event.h|2 +-
 kernel/cobalt/posix/io.h   |2 +-
 kernel/cobalt/posix/monitor.c  |   56 +-
 kernel/cobalt/posix/monitor.h  |2 +-
 kernel/cobalt/posix/mutex.c|   32 +-
 kernel/cobalt/posix/nsem.c |   54 +-
 kernel/cobalt/posix/process.c  |   70 +-
 kernel/cobalt/posix/sched.c|   29 +-
 kernel/cobalt/posix/sched.h|2 +-
 kernel/cobalt/posix/sem.c  |   42 +-
 kernel/cobalt/posix/sem.h  |   11 +-
 kernel/cobalt/posix/syscall.c  |  776 ++--
 kernel/cobalt/posix/thread.c   |   38 +-
 kernel/cobalt/posix/thread.h   |   24 +-
 lib/cobalt/clock.c |4 +-
 lib/cobalt/cond.c  |   32 +-
 lib/cobalt/current.h   |4 +-
 lib/cobalt/internal.c  |  104 ++-
 lib/cobalt/internal.h  |   10 +-
 lib/cobalt/mutex.c |   75 +-
 lib/cobalt/semaphore.c |   45 +-
 testsuite/clocktest/clocktest.c|   14 +-
 43 files changed, 1008 insertions(+), 809 deletions(-)

diff --git a/include/boilerplate/compiler.h b/include/boilerplate/compiler.h
index b52a585..e27d165 100644
--- a/include/boilerplate/compiler.h
+++ b/include/boilerplate/compiler.h
@@ -50,4 +50,8 @@
 #define __maybe_unused __attribute__((__unused__))
 #endif
 
+#ifndef __aligned
+#define __aligned(__n) __attribute__((aligned (__n)))
+#endif
+
 #endif /* _BOILERPLATE_COMPILER_H */
diff --git a/include/cobalt/kernel/ppd.h b/include/cobalt/kernel/ppd.h
index 4d42427..d5cfc69 100644
--- a/include/cobalt/kernel/ppd.h
+++ b/include/cobalt/kernel/ppd.h
@@ -32,7 +32,7 @@ struct cobalt_umm {
 
 struct cobalt_ppd {
struct cobalt_umm umm;
-   unsigned long mayday_addr;
+   unsigned long mayday_tramp;
atomic_t refcnt;
char *exe_path;
struct rb_root fds;
diff --git a/include/cobalt/kernel/rtdm/Makefile.am 
b/include/cobalt/kernel/rtdm/Makefile.am
index 6279168..2c04cac 100644
--- a/include/cobalt/kernel/rtdm/Makefile.am
+++ b/include/cobalt/kernel/rtdm/Makefile.am
@@ -3,6 +3,7 @@ noinst_HEADERS =\
autotune.h  \
can.h   \
cobalt.h\
+   compat.h\
driver.h\
fd.h\
ipc.h   \
diff --git a/include/cobalt/kernel/rtdm/compat.h 
b/include/cobalt/kernel/rtdm/compat.h
new file mode 100644
index 000..fdf493f
--- /dev/null
+++ b/include/cobalt/kernel/rtdm/compat.h
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2014 Philippe Gerum 
+ *
+ * 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

[Xenomai-git] Jorge Ramirez-Ortiz : drivers/analogy: remove unnecessary lock

2014-10-25 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 8f594b229925a96ddeb65e662bbf86fb8ba0849d
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=8f594b229925a96ddeb65e662bbf86fb8ba0849d

Author: Jorge Ramirez-Ortiz 
Date:   Thu Aug 14 13:41:50 2014 -0400

drivers/analogy: remove unnecessary lock

---

 kernel/drivers/analogy/transfer.c |   13 ++---
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/kernel/drivers/analogy/transfer.c 
b/kernel/drivers/analogy/transfer.c
index 2594f00..bf19c8c 100644
--- a/kernel/drivers/analogy/transfer.c
+++ b/kernel/drivers/analogy/transfer.c
@@ -154,26 +154,17 @@ int a4l_request_irq(struct a4l_device * dev,
unsigned long flags, void *cookie)
 {
int ret;
-   unsigned long __flags;
 
if (dev->transfer.irq_desc.irq != A4L_IRQ_UNUSED)
return -EBUSY;
 
-   /* A spinlock is used so as to prevent race conditions
-  on the field "irq" of the IRQ descriptor
-  (even if such a case is bound not to happen) */
-   rtdm_lock_get_irqsave(&dev->lock, __flags);
-
-   ret = __a4l_request_irq(&dev->transfer.irq_desc,
-   irq, handler, flags, cookie);
-
+   ret = __a4l_request_irq(&dev->transfer.irq_desc, irq, handler, flags,
+   cookie);
if (ret != 0) {
__a4l_err("a4l_request_irq: IRQ registration failed\n");
dev->transfer.irq_desc.irq = A4L_IRQ_UNUSED;
}
 
-   rtdm_lock_put_irqrestore(&dev->lock, __flags);
-
return ret;
 }
 


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


[Xenomai-git] Jorge Ramirez-Ortiz : utils/analogy: calibration - use iniparser

2014-10-25 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: df614aa783e03623da14a022cb7d43c08616eac4
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=df614aa783e03623da14a022cb7d43c08616eac4

Author: Jorge Ramirez-Ortiz 
Date:   Fri Sep 12 11:55:40 2014 -0400

utils/analogy: calibration - use iniparser

---

 utils/analogy/Makefile.am |4 ++-
 utils/analogy/analogy_calibrate.c |   57 -
 utils/analogy/analogy_calibrate.h |   11 ++-
 utils/analogy/calibration_ni_m.c  |   40 ++
 4 files changed, 103 insertions(+), 9 deletions(-)

diff --git a/utils/analogy/Makefile.am b/utils/analogy/Makefile.am
index fe2f317..40c09f3 100644
--- a/utils/analogy/Makefile.am
+++ b/utils/analogy/Makefile.am
@@ -12,7 +12,9 @@ bin_PROGRAMS = \
 CPPFLAGS = \
@XENO_USER_CFLAGS@  \
-ggdb   \
-   -I$(top_srcdir)/include
+   -I$(top_srcdir)/include \
+   -I$(top_srcdir)/lib/boilerplate 
+
 
 LDFLAGS =
 
diff --git a/utils/analogy/analogy_calibrate.c 
b/utils/analogy/analogy_calibrate.c
index 586a38a..b2ac286 100644
--- a/utils/analogy/analogy_calibrate.c
+++ b/utils/analogy/analogy_calibrate.c
@@ -31,7 +31,7 @@
 #include "analogy_calibrate.h"
 #include "calibration_ni_m.h"
 
-
+struct apply_calibration_params params = {.name = NULL,} ;
 struct timespec calibration_start_time;
 static const char *revision = "0.0.1";
 a4l_desc_t descriptor;
@@ -57,28 +57,65 @@ static const struct option options[] = {
.flag = NULL,
},
{
+#define apply_opt  3
+   .name = "apply",
+   .has_arg = 1,
+   .flag = NULL,
+   },
+   {
.name = NULL,
}
 };
 
-static void print_usage(void)
+static void
+print_usage(void)
 {
fprintf(stderr, "Usage: analogy_calibrate \n"
-  "  --help: this menu \n"
-  "  --device /dev/analogyX: analogy device to calibrate 
\n"
-  "  --output filename : calibration results \n"
+  "  --help: this menu \n"
+  "  --device /dev/analogyX: analogy 
device to calibrate \n"
+  "  --output filename : calibration 
results \n"
+  "  --apply filename:subd,channel,range,aref  : apply the 
calibration file \n"
+  "  ex: /home/foo/calib.rc:0,1,255,255 - use 255 for dont 
care \n"
  );
 }
 
+static int
+apply_calibration_set_globals(char *info)
+{
+   char *p;
+
+   params.name = strtok(info, ":");
+   p = strtok(NULL, ",");
+   if (!p)
+   error(EXIT, 0, "missing --apply parameter \n");
+   params.subd = strtol(p, NULL, 0);
+
+   p = strtok(NULL, ",");
+   if (!p)
+   error(EXIT, 0, "missing --apply parameter \n");
+   params.channel = strtol(p, NULL, 0);
+
+   p = strtok(NULL, ",");
+   if (!p)
+   error(EXIT, 0, "missing --apply parameter \n");
+   params.range = strtol(p, NULL, 0);
+
+   p = strtok(NULL, "");
+   if (!p)
+   error(EXIT, 0, "missing --apply parameter \n");
+   params.aref = strtol(p, NULL, 0);
+
+   return 0;
+}
+
 static void __attribute__ ((constructor)) __analogy_calibrate_init(void)
 {
clock_gettime(CLOCK_MONOTONIC, &calibration_start_time);
 }
-
 int main(int argc, char *argv[])
 {
struct sched_param param = {.sched_priority = 99};
-   char *device = NULL, *file = NULL;
+   char *device = NULL, *file = NULL, *apply_info = NULL;
int v, i, fd, err = 0;
struct rlimit rl;
 
@@ -103,12 +140,18 @@ int main(int argc, char *argv[])
error(EXIT, errno, "calibration file");
__debug("calibration output: %s \n", file);
break;
+   case apply_opt:
+   apply_info = optarg;
+   break;
default:
print_usage();
exit(EXIT_FAILURE);
}
}
 
+   if (apply_info)
+   apply_calibration_set_globals(apply_info);
+
err = getrlimit(RLIMIT_STACK, &rl);
if (!err) {
if (rl.rlim_cur < rl.rlim_max) {
diff --git a/utils/analogy/analogy_calibrate.h 
b/utils/analogy/analogy_calibrate.h
index 1fb548e..c2b539a 100644
--- a/utils/analogy/analogy_calibrate.h
+++ b/utils/analogy/analogy_calibrate.h
@@ -38,8 +38,17 @@ extern struct timespec calibration_start_time;
 extern a4l_desc_t descriptor;
 extern FILE *cal;
 
-#define ARRAY_LEN(a)  (sizeof(a) / sizeof((a)[0]))
+struct apply_calibration_params {
+   int channel;
+   char *name;
+   int range;
+   int subd;
+

[Xenomai-git] Philippe Gerum : drivers/rtipc: fixup for 32bit emulation

2014-10-25 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 053df824650bb072381ce83e3928165eea2ce03e
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=053df824650bb072381ce83e3928165eea2ce03e

Author: Philippe Gerum 
Date:   Wed Oct 22 15:20:21 2014 +0200

drivers/rtipc: fixup for 32bit emulation

---

 kernel/drivers/ipc/bufp.c |  115 ++---
 kernel/drivers/ipc/iddp.c |  123 +++---
 kernel/drivers/ipc/internal.h |   41 -
 kernel/drivers/ipc/rtipc.c|  365 -
 kernel/drivers/ipc/xddp.c |  113 ++---
 5 files changed, 520 insertions(+), 237 deletions(-)

diff --git a/kernel/drivers/ipc/bufp.c b/kernel/drivers/ipc/bufp.c
index 1e5ecf3..5ae166a 100644
--- a/kernel/drivers/ipc/bufp.c
+++ b/kernel/drivers/ipc/bufp.c
@@ -375,17 +375,16 @@ static ssize_t bufp_recvmsg(struct rtdm_fd *fd,
return -EINVAL;
 
/* Copy I/O vector in */
-   if (rtipc_get_arg(fd, iov, msg->msg_iov,
- sizeof(iov[0]) * msg->msg_iovlen))
-   return -EFAULT;
+   ret = rtipc_get_iovec(fd, iov, msg);
+   if (ret)
+   return ret;
 
ret = __bufp_recvmsg(fd, iov, msg->msg_iovlen, flags, &saddr);
if (ret <= 0)
return ret;
 
/* Copy the updated I/O vector back */
-   if (rtipc_put_arg(fd, msg->msg_iov, iov,
- sizeof(iov[0]) * msg->msg_iovlen))
+   if (rtipc_put_iovec(fd, iov, msg))
return -EFAULT;
 
/* Copy the source address if required. */
@@ -620,8 +619,7 @@ static ssize_t bufp_sendmsg(struct rtdm_fd *fd,
return -EINVAL;
 
/* Fetch the destination address to send to. */
-   if (rtipc_get_arg(fd, &daddr,
- msg->msg_name, sizeof(daddr)))
+   if (rtipc_get_arg(fd, &daddr, msg->msg_name, sizeof(daddr)))
return -EFAULT;
 
if (daddr.sipc_port < 0 ||
@@ -639,20 +637,16 @@ static ssize_t bufp_sendmsg(struct rtdm_fd *fd,
return -EINVAL;
 
/* Copy I/O vector in */
-   if (rtipc_get_arg(fd, iov, msg->msg_iov,
- sizeof(iov[0]) * msg->msg_iovlen))
-   return -EFAULT;
+   ret = rtipc_get_iovec(fd, iov, msg);
+   if (ret)
+   return ret;
 
ret = __bufp_sendmsg(fd, iov, msg->msg_iovlen, flags, &daddr);
if (ret <= 0)
return ret;
 
/* Copy updated I/O vector back */
-   if (rtipc_put_arg(fd, msg->msg_iov, iov,
- sizeof(iov[0]) * msg->msg_iovlen))
-   return -EFAULT;
-
-   return ret;
+   return rtipc_put_iovec(fd, iov, msg) ?: ret;
 }
 
 static ssize_t bufp_write(struct rtdm_fd *fd,
@@ -829,30 +823,27 @@ static int __bufp_setsockopt(struct bufp_socket *sk,
struct rtipc_port_label plabel;
struct timeval tv;
rtdm_lockctx_t s;
-   int ret = 0;
size_t len;
+   int ret;
 
-   if (rtipc_get_arg(fd, &sopt, arg, sizeof(sopt)))
-   return -EFAULT;
+   ret = rtipc_get_sockoptin(fd, &sopt, arg);
+   if (ret)
+   return ret;
 
if (sopt.level == SOL_SOCKET) {
switch (sopt.optname) {
 
case SO_RCVTIMEO:
-   if (sopt.optlen != sizeof(tv))
-   return -EINVAL;
-   if (rtipc_get_arg(fd, &tv,
- sopt.optval, sizeof(tv)))
-   return -EFAULT;
+   ret = rtipc_get_timeval(fd, &tv, sopt.optval, 
sopt.optlen);
+   if (ret)
+   return ret;
sk->rx_timeout = rtipc_timeval_to_ns(&tv);
break;
 
case SO_SNDTIMEO:
-   if (sopt.optlen != sizeof(tv))
-   return -EINVAL;
-   if (rtipc_get_arg(fd, &tv,
- sopt.optval, sizeof(tv)))
-   return -EFAULT;
+   ret = rtipc_get_timeval(fd, &tv, sopt.optval, 
sopt.optlen);
+   if (ret)
+   return ret;
sk->tx_timeout = rtipc_timeval_to_ns(&tv);
break;
 
@@ -869,11 +860,9 @@ static int __bufp_setsockopt(struct bufp_socket *sk,
switch (sopt.optname) {
 
case BUFP_BUFSZ:
-   if (sopt.optlen != sizeof(len))
-   return -EINVAL;
-   if (rtipc_get_arg(fd, &len,
- sopt.optval, sizeof(len)))
-   return -EFAULT;
+   ret = rtipc_get_length(fd, &len, sopt.optval, sopt.optlen);
+   if (ret)
+   return ret;
if (len == 0)
   

[Xenomai-git] Jorge Ramirez-Ortiz : drivers/analogy: NI M - 622x ranges changed to bipolar

2014-10-25 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 5f5ade69e909ad5e6c3698cfcb477035f7a9a1c0
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=5f5ade69e909ad5e6c3698cfcb477035f7a9a1c0

Author: Jorge Ramirez-Ortiz 
Date:   Thu Sep  4 10:35:26 2014 -0400

drivers/analogy: NI M - 622x ranges changed to bipolar

---

 kernel/drivers/analogy/national_instruments/pcimio.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/drivers/analogy/national_instruments/pcimio.c 
b/kernel/drivers/analogy/national_instruments/pcimio.c
index e7a2ab3..8a3 100644
--- a/kernel/drivers/analogy/national_instruments/pcimio.c
+++ b/kernel/drivers/analogy/national_instruments/pcimio.c
@@ -801,7 +801,7 @@ static ni_board ni_boards[]={
n_aochan:   2,
aobits: 16,
ao_fifo_depth:  8191,
-   .ao_range_table = &range_ni_M_622x_ao,
+   .ao_range_table = &a4l_range_bipolar10,
reg_type:   ni_reg_622x,
ao_unipolar:0,
ao_speed:   1200,
@@ -819,7 +819,7 @@ static ni_board ni_boards[]={
n_aochan:   2,
aobits: 16,
ao_fifo_depth:  8191,
-   .ao_range_table = &range_ni_M_622x_ao,
+   .ao_range_table = &a4l_range_bipolar10,
reg_type:   ni_reg_622x,
ao_unipolar:0,
ao_speed:   1200,


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


[Xenomai-git] Jorge Ramirez-Ortiz : drivers/analogy: let A4L_CMD_SIMUL calls return driver specific values

2014-10-25 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: c06eb701e1f9baae98185fd077bca1546a4bcfeb
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=c06eb701e1f9baae98185fd077bca1546a4bcfeb

Author: Jorge Ramirez-Ortiz 
Date:   Tue Aug 19 14:02:23 2014 -0400

drivers/analogy: let A4L_CMD_SIMUL calls return driver specific values

---

 kernel/drivers/analogy/command.c |   17 +
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/kernel/drivers/analogy/command.c b/kernel/drivers/analogy/command.c
index 1c544bf..213591d 100644
--- a/kernel/drivers/analogy/command.c
+++ b/kernel/drivers/analogy/command.c
@@ -26,7 +26,6 @@
 #include 
 
 /* --- Command descriptor management functions --- */
-
 int a4l_fill_cmddesc(struct a4l_device_context * cxt, struct a4l_cmd_desc * 
desc, void *arg)
 {
int ret = 0;
@@ -284,11 +283,11 @@ int a4l_check_specific_cmdcnt(struct a4l_device_context * 
cxt, struct a4l_cmd_de
 
 /* --- IOCTL / FOPS function --- */
 
-int a4l_ioctl_cmd(struct a4l_device_context * cxt, void *arg)
+int a4l_ioctl_cmd(struct a4l_device_context * ctx, void *arg)
 {
int ret = 0, simul_flag = 0;
struct a4l_cmd_desc *cmd_desc = NULL;
-   struct a4l_device *dev = a4l_get_dev(cxt);
+   struct a4l_device *dev = a4l_get_dev(ctx);
struct a4l_subdevice *subd;
 
/* The command launching cannot be done in real-time because
@@ -310,12 +309,12 @@ int a4l_ioctl_cmd(struct a4l_device_context * cxt, void 
*arg)
memset(cmd_desc, 0, sizeof(struct a4l_cmd_desc));
 
/* Gets the command */
-   ret = a4l_fill_cmddesc(cxt, cmd_desc, arg);
+   ret = a4l_fill_cmddesc(ctx, cmd_desc, arg);
if (ret != 0)
goto out_ioctl_cmd;
 
/* Checks the command */
-   ret = a4l_check_cmddesc(cxt, cmd_desc);
+   ret = a4l_check_cmddesc(ctx, cmd_desc);
if (ret != 0)
goto out_ioctl_cmd;
 
@@ -323,7 +322,7 @@ int a4l_ioctl_cmd(struct a4l_device_context * cxt, void 
*arg)
if (ret != 0)
goto out_ioctl_cmd;
 
-   ret = a4l_check_specific_cmdcnt(cxt, cmd_desc);
+   ret = a4l_check_specific_cmdcnt(ctx, cmd_desc);
if (ret != 0)
goto out_ioctl_cmd;
 
@@ -347,7 +346,7 @@ int a4l_ioctl_cmd(struct a4l_device_context * cxt, void 
*arg)
}
 
/* Gets the transfer system ready */
-   ret = a4l_setup_buffer(cxt, cmd_desc);
+   ret = a4l_setup_buffer(ctx, cmd_desc);
if (ret < 0)
goto out_ioctl_cmd;
 
@@ -355,12 +354,14 @@ int a4l_ioctl_cmd(struct a4l_device_context * cxt, void 
*arg)
ret = subd->do_cmd(subd, cmd_desc);
 
if (ret != 0) {
-   a4l_cancel_buffer(cxt);
+   a4l_cancel_buffer(ctx);
goto out_ioctl_cmd;
}
 
 out_ioctl_cmd:
if (ret != 0 || simul_flag == 1) {
+   rtdm_safe_copy_to_user(rtdm_private_to_fd(ctx), arg, cmd_desc,
+   sizeof(struct a4l_cmd_desc));
a4l_free_cmddesc(cmd_desc);
rtdm_free(cmd_desc);
}


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


[Xenomai-git] Jorge Ramirez-Ortiz : lib/analogy: fix a4l_sync_read wait call

2014-10-25 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 82b05d1040ce7ba19610203ddb812eb4f607010e
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=82b05d1040ce7ba19610203ddb812eb4f607010e

Author: Jorge Ramirez-Ortiz 
Date:   Thu Aug 21 15:22:05 2014 -0400

lib/analogy: fix a4l_sync_read wait call

---

 lib/analogy/sync.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/analogy/sync.c b/lib/analogy/sync.c
index 6dd49f9..fee5fc9 100644
--- a/lib/analogy/sync.c
+++ b/lib/analogy/sync.c
@@ -211,13 +211,13 @@ int a4l_sync_read(a4l_desc_t * dsc,
.type = A4L_INSN_READ,
.idx_subd = idx_subd,
.chan_desc = chan_desc,
-   .data_size = 0,
+   .data_size = nbyte,
.data = buf},
{
.type = A4L_INSN_WAIT,
.idx_subd = idx_subd,
.chan_desc = chan_desc,
-   .data_size = 1,
+   .data_size = sizeof(unsigned int),
.data = NULL}
};
 


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


[Xenomai-git] Jorge Ramirez-Ortiz : drivers/analogy: modify the cmd test behaviour

2014-10-25 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: b3c9e4e62186896e933d5873c609b8b46e0b5ae6
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=b3c9e4e62186896e933d5873c609b8b46e0b5ae6

Author: Jorge Ramirez-Ortiz 
Date:   Tue Aug 26 13:50:41 2014 -0400

drivers/analogy: modify the cmd test behaviour

---

 kernel/drivers/analogy/command.c |   66 +-
 1 file changed, 44 insertions(+), 22 deletions(-)

diff --git a/kernel/drivers/analogy/command.c b/kernel/drivers/analogy/command.c
index 213591d..7420bc5 100644
--- a/kernel/drivers/analogy/command.c
+++ b/kernel/drivers/analogy/command.c
@@ -26,16 +26,18 @@
 #include 
 
 /* --- Command descriptor management functions --- */
-int a4l_fill_cmddesc(struct a4l_device_context * cxt, struct a4l_cmd_desc * 
desc, void *arg)
+int a4l_fill_cmddesc(struct a4l_device_context *cxt, struct a4l_cmd_desc *desc,
+unsigned int **chan_descs, void *arg)
 {
-   int ret = 0;
unsigned int *tmpchans = NULL;
+   int ret = 0;
 
ret = rtdm_safe_copy_from_user(rtdm_private_to_fd(cxt),
   desc, arg, sizeof(struct a4l_cmd_desc));
if (ret != 0)
goto out_cmddesc;
 
+
if (desc->nb_chan == 0) {
ret = -EINVAL;
goto out_cmddesc;
@@ -50,13 +52,16 @@ int a4l_fill_cmddesc(struct a4l_device_context * cxt, 
struct a4l_cmd_desc * desc
ret = rtdm_safe_copy_from_user(rtdm_private_to_fd(cxt),
   tmpchans,
   desc->chan_descs,
-  desc->nb_chan * sizeof(unsigned long));
-   if (ret != 0)
+  desc->nb_chan * sizeof(unsigned int));
+   if (ret != 0) {
+   __a4l_err("%s invalid arguments \n", __FUNCTION__);
goto out_cmddesc;
+   }
 
+   *chan_descs = desc->chan_descs;
desc->chan_descs = tmpchans;
 
-   __a4l_dbg(1, core_dbg, "desc dump\n");
+   __a4l_dbg(1, core_dbg, "desc dump: \n");
__a4l_dbg(1, core_dbg, "\t->idx_subd=%u\n", desc->idx_subd);
__a4l_dbg(1, core_dbg, "\t->flags=%lu\n", desc->flags);
__a4l_dbg(1, core_dbg, "\t->nb_chan=%u\n", desc->nb_chan);
@@ -64,9 +69,10 @@ int a4l_fill_cmddesc(struct a4l_device_context * cxt, struct 
a4l_cmd_desc * desc
__a4l_dbg(1, core_dbg, "\t->data_len=%u\n", desc->data_len);
__a4l_dbg(1, core_dbg, "\t->pdata=0x%p\n", desc->data);
 
-  out_cmddesc:
+   out_cmddesc:
 
if (ret != 0) {
+   __a4l_err("a4l_fill_cmddesc: %d \n", ret);
if (tmpchans != NULL)
rtdm_free(tmpchans);
desc->chan_descs = NULL;
@@ -113,7 +119,7 @@ int a4l_check_cmddesc(struct a4l_device_context * cxt, 
struct a4l_cmd_desc * des
}
 
return a4l_check_chanlist(dev->transfer.subds[desc->idx_subd],
-desc->nb_chan, desc->chan_descs);
+ desc->nb_chan, desc->chan_descs);
 }
 
 /* --- Command checking functions --- */
@@ -124,7 +130,7 @@ int a4l_check_generic_cmdcnt(struct a4l_cmd_desc * desc)
 
/* Makes sure trigger sources are trivially valid */
tmp1 =
-   desc->start_src & ~(TRIG_NOW | TRIG_INT | TRIG_EXT | TRIG_FOLLOW);
+   desc->start_src & ~(TRIG_NOW | TRIG_INT | TRIG_EXT | TRIG_FOLLOW);
tmp2 = desc->start_src & (TRIG_NOW | TRIG_INT | TRIG_EXT | TRIG_FOLLOW);
if (tmp1 != 0 || tmp2 == 0) {
__a4l_err("a4l_check_cmddesc: start_src, weird trigger\n");
@@ -288,6 +294,7 @@ int a4l_ioctl_cmd(struct a4l_device_context * ctx, void 
*arg)
int ret = 0, simul_flag = 0;
struct a4l_cmd_desc *cmd_desc = NULL;
struct a4l_device *dev = a4l_get_dev(ctx);
+   unsigned int *chan_descs, *tmp;
struct a4l_subdevice *subd;
 
/* The command launching cannot be done in real-time because
@@ -309,7 +316,7 @@ int a4l_ioctl_cmd(struct a4l_device_context * ctx, void 
*arg)
memset(cmd_desc, 0, sizeof(struct a4l_cmd_desc));
 
/* Gets the command */
-   ret = a4l_fill_cmddesc(ctx, cmd_desc, arg);
+   ret = a4l_fill_cmddesc(ctx, cmd_desc, &chan_descs, arg);
if (ret != 0)
goto out_ioctl_cmd;
 
@@ -327,24 +334,28 @@ int a4l_ioctl_cmd(struct a4l_device_context * ctx, void 
*arg)
goto out_ioctl_cmd;
 
__a4l_dbg(1, core_dbg,"1st cmd checks passed\n");
-
subd = dev->transfer.subds[cmd_desc->idx_subd];
 
/* Tests the command with the cmdtest function */
-   if (subd->do_cmdtest != NULL)
-   ret = subd->do_cmdtest(subd, cmd_desc);
-   if (ret != 0) {
-   __a4l_err("a4l_ioctl_cmd: driver's cmd_test failed\n");
-   goto out_ioctl_cmd;
-   }
-
-   __a4l_dbg(1, core_dbg, "driver's cmd checks passed\n");
-
if (cmd_des

[Xenomai-git] Jorge Ramirez-Ortiz : lib/analogy: calibration - a4l_rawtodcal & a4l_dcaltoraw

2014-10-25 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 3a4768dc4f3370f989a3ebdbd08b8580aa2cb1ba
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=3a4768dc4f3370f989a3ebdbd08b8580aa2cb1ba

Author: Jorge Ramirez-Ortiz 
Date:   Fri Oct 24 08:59:31 2014 -0400

lib/analogy: calibration - a4l_rawtodcal & a4l_dcaltoraw

---

 include/rtdm/analogy.h  |9 ++
 include/rtdm/uapi/analogy.h |6 ++
 lib/analogy/calibration.c   |  237 ++-
 lib/analogy/math.c  |8 +-
 utils/analogy/Makefile.am   |2 +-
 5 files changed, 252 insertions(+), 10 deletions(-)

diff --git a/include/rtdm/analogy.h b/include/rtdm/analogy.h
index a87ce54..066d05a 100644
--- a/include/rtdm/analogy.h
+++ b/include/rtdm/analogy.h
@@ -232,6 +232,15 @@ int a4l_dtoraw(a4l_chinfo_t *chan,
 
 int a4l_read_calibration_file(char *name, struct a4l_calibration_data *data);
 
+int a4l_get_softcal_converter(struct a4l_polynomial *converter,
+ int subd, int chan, int range,
+ struct a4l_calibration_data *data );
+
+int a4l_rawtodcal(a4l_chinfo_t *chan, double *dst, void *src,
+ int cnt, struct a4l_polynomial *converter);
+int a4l_dcaltoraw(a4l_chinfo_t * chan, void *dst, double *src, int cnt,
+ struct a4l_polynomial *converter);
+
 int a4l_math_polyfit(unsigned order, double *r,double orig,
 const unsigned dim, double *x, double *y);
 
diff --git a/include/rtdm/uapi/analogy.h b/include/rtdm/uapi/analogy.h
index a0a1e59..2d53168 100644
--- a/include/rtdm/uapi/analogy.h
+++ b/include/rtdm/uapi/analogy.h
@@ -732,6 +732,12 @@ struct a4l_calibration_data {
struct a4l_calibration_subdev_data *ao;
 };
 
+struct a4l_polynomial {
+   int expansion;
+   int order;
+   int nb_coeff;
+   double *coeff;
+};
 
 
 #endif /* _RTDM_UAPI_ANALOGY_H */
diff --git a/lib/analogy/calibration.c b/lib/analogy/calibration.c
index dcec16d..9fd944c 100644
--- a/lib/analogy/calibration.c
+++ b/lib/analogy/calibration.c
@@ -20,6 +20,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
  */
 
+#include 
 #include 
 #include 
 #include 
@@ -28,8 +29,39 @@
 #include "boilerplate/list.h"
 #include "calibration.h"
 
+
 #define ARRAY_LEN(a)  (sizeof(a) / sizeof((a)[0]))
 
+static lsampl_t data32_get(void *src)
+{
+   return (lsampl_t) * ((lsampl_t *) (src));
+}
+
+static lsampl_t data16_get(void *src)
+{
+   return (lsampl_t) * ((sampl_t *) (src));
+}
+
+static lsampl_t data8_get(void *src)
+{
+   return (lsampl_t) * ((unsigned char *)(src));
+}
+
+static void data32_set(void *dst, lsampl_t val)
+{
+   *((lsampl_t *) (dst)) = val;
+}
+
+static void data16_set(void *dst, lsampl_t val)
+{
+   *((sampl_t *) (dst)) = (sampl_t) (0x & val);
+}
+
+static void data8_set(void *dst, lsampl_t val)
+{
+   *((unsigned char *)(dst)) = (unsigned char)(0xff & val);
+}
+
 static inline int read_dbl(double *d, struct _dictionary_ *f,const char *subd,
   int subd_idx, char *type, int type_idx)
 {
@@ -73,7 +105,7 @@ static inline int read_int(int *val, struct _dictionary_ *f, 
const char *subd,
 }
 
 static inline int read_str(char **val, struct _dictionary_ *f, const char 
*subd,
-  const char *type)
+  const char *type)
 {
char *str;
int ret;
@@ -105,7 +137,7 @@ static inline void write_calibration(FILE *file, char *fmt, 
...)
 
 void
 write_calibration_file(FILE *dst, struct list *l,
-  struct a4l_calibration_subdev *subd, a4l_desc_t *desc)
+  struct a4l_calibration_subdev *subd, a4l_desc_t *desc)
 {
struct subdevice_calibration_node *e, *t;
int i, j = 0;
@@ -205,7 +237,7 @@ int a4l_read_calibration_file(char *name, struct 
a4l_calibration_data *data)
if (strncmp(subdevice[k], AI_SUBD_STR,
strlen(AI_SUBD_STR)) == 0) {
data->ai = malloc(nb_elements *
-  sizeof(struct a4l_calibration_subdev_data));
+ sizeof(struct 
a4l_calibration_subdev_data));
data->nb_ai = nb_elements;
p  = data->ai;
}
@@ -213,7 +245,7 @@ int a4l_read_calibration_file(char *name, struct 
a4l_calibration_data *data)
if (strncmp(subdevice[k], AO_SUBD_STR,
strlen(AO_SUBD_STR)) == 0) {
data->ao = malloc(nb_elements *
-  sizeof(struct a4l_calibration_subdev_data));
+ sizeof(struct 
a4l_calibration_subdev_data));
data->nb_ao = nb_elements;
p = data->ao;
}
@@ -232,7 +264,7 @@ int a4l_read_calibration_file(char *name, struct 
a4l_calibration_data *data)
 
 

[Xenomai-git] Jorge Ramirez-Ortiz : utils/analogy: NI-M software calibration [Part I]

2014-10-25 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 269b5563068a900c58589ce8abc1553b3c2655d5
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=269b5563068a900c58589ce8abc1553b3c2655d5

Author: Jorge Ramirez-Ortiz 
Date:   Wed Aug 13 12:24:16 2014 -0400

utils/analogy: NI-M software calibration [Part I]

Generates a calibration file as per the comedi implementation.

---

 utils/analogy/Makefile.am |   24 +-
 utils/analogy/analogy_calibrate.c |  157 +
 utils/analogy/analogy_calibrate.h |  182 +
 utils/analogy/calibration_ni_m.c  | 1406 +
 utils/analogy/calibration_ni_m.h  |  280 
 5 files changed, 2048 insertions(+), 1 deletion(-)

diff --git a/utils/analogy/Makefile.am b/utils/analogy/Makefile.am
index c731b7a..fe2f317 100644
--- a/utils/analogy/Makefile.am
+++ b/utils/analogy/Makefile.am
@@ -1,4 +1,4 @@
-sbin_PROGRAMS = analogy_config
+sbin_PROGRAMS = analogy_config analogy_calibrate
 
 bin_PROGRAMS = \
cmd_read \
@@ -29,6 +29,24 @@ analogy_config_LDADD = \
@XENO_USER_LDADD@   \
-lpthread -lrt
 
+analogy_calibrate_SOURCES = analogy_calibrate.c calibration_ni_m.c
+analogy_calibrate.c: git-stamp.h calibration_ni_m.h
+git-stamp.h: git-stamp
+   @set -x; if test -r $(top_srcdir)/.git; then
\
+ stamp=`git --git-dir=$(top_srcdir)/.git rev-list --abbrev-commit -1 
HEAD`;\
+ if test \! -s $@ || grep -wvq $$stamp $@; then
\
+   date=`git --git-dir=$(top_srcdir)/.git log -1 $$stamp 
--pretty=format:%ci`; \
+   echo "#define GIT_STAMP \"#$$stamp ($$date)\"" > $@;
\
+ fi;   
\
+   elif test \! -r $@ -o -s $@; then   
\
+   rm -f $@ && touch $@;   
\
+   fi; true
+analogy_calibrate_LDADD = \
+   ../../lib/analogy/libanalogy.la \
+   ../../lib/cobalt/libcobalt.la   \
+   @XENO_USER_LDADD@   \
+   -lpthread -lrt -lgsl -lgslcblas -lm
+
 cmd_read_SOURCES = cmd_read.c
 cmd_read_LDADD = \
../../lib/analogy/libanalogy.la \
@@ -77,3 +95,7 @@ insn_bits_LDADD = \
 
 wf_generate_SOURCES = wf_generate.c
 wf_generate_LDADD = ./libwaveform.la -lm
+
+
+.PHONY: git-stamp
+
diff --git a/utils/analogy/analogy_calibrate.c 
b/utils/analogy/analogy_calibrate.c
new file mode 100644
index 000..586a38a
--- /dev/null
+++ b/utils/analogy/analogy_calibrate.c
@@ -0,0 +1,157 @@
+/**
+ * @file
+ * Analogy for Linux, calibration program
+ *
+ * @note Copyright (C) 2014 Jorge A. Ramirez-Ortiz 
+ *
+ * from original code from the Comedi project
+ *
+ * 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.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "analogy_calibrate.h"
+#include "calibration_ni_m.h"
+
+
+struct timespec calibration_start_time;
+static const char *revision = "0.0.1";
+a4l_desc_t descriptor;
+FILE *cal = NULL;
+
+static const struct option options[] = {
+   {
+#define help_opt   0
+   .name = "help",
+   .has_arg = 0,
+   .flag = NULL,
+   },
+   {
+#define device_opt 1
+   .name = "device",
+   .has_arg = 1,
+   .flag = NULL,
+   },
+   {
+#define output_opt 2
+   .name = "output",
+   .has_arg = 1,
+   .flag = NULL,
+   },
+   {
+   .name = NULL,
+   }
+};
+
+static void print_usage(void)
+{
+   fprintf(stderr, "Usage: analogy_calibrate \n"
+  "  --help: this menu \n"
+  "  --device /dev/analogyX: analogy device to calibrate 
\n"
+  "  --output filename : calibration results \n"
+ );
+}
+
+static void __attribute__ ((constructor)) __analogy_calibrate_init(void)
+{
+   clock_gettime(CLOCK_MONOTONIC, &calibration_start_time);
+}
+
+int main(int argc, char *argv[])
+{
+   struct sched_param param = {.sched_priority = 99};
+   char *device = NULL, *file = NULL;
+  

[Xenomai-git] Jorge Ramirez-Ortiz : utils/analogy: calibration - generating the calibration file is not a user API

2014-10-25 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: eb4230d0c647be89fa06e863959aa33f84b3a38e
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=eb4230d0c647be89fa06e863959aa33f84b3a38e

Author: Jorge Ramirez-Ortiz 
Date:   Tue Oct 14 21:53:25 2014 -0400

utils/analogy: calibration - generating the calibration file is not a user API

---

 include/rtdm/analogy.h|4 --
 lib/analogy/calibration.c |  103 +
 lib/analogy/calibration.h |3 ++
 lib/analogy/math.c|   51 +-
 utils/analogy/analogy_calibrate.c |6 +++
 utils/analogy/calibration_ni_m.c  |   15 +++---
 6 files changed, 125 insertions(+), 57 deletions(-)

diff --git a/include/rtdm/analogy.h b/include/rtdm/analogy.h
index c03d2b1..a87ce54 100644
--- a/include/rtdm/analogy.h
+++ b/include/rtdm/analogy.h
@@ -230,10 +230,6 @@ int a4l_ftoraw(a4l_chinfo_t *chan,
 int a4l_dtoraw(a4l_chinfo_t *chan,
   a4l_rnginfo_t *rng, void *dst, double *src, int cnt);
 
-void a4l_write_calibration_file(FILE *dst, struct list *l,
-   struct a4l_calibration_subdev *subd,
-   a4l_desc_t *desc);
-
 int a4l_read_calibration_file(char *name, struct a4l_calibration_data *data);
 
 int a4l_math_polyfit(unsigned order, double *r,double orig,
diff --git a/lib/analogy/calibration.c b/lib/analogy/calibration.c
index 85860d1..dcec16d 100644
--- a/lib/analogy/calibration.c
+++ b/lib/analogy/calibration.c
@@ -103,6 +103,64 @@ static inline void write_calibration(FILE *file, char 
*fmt, ...)
va_end(ap);
 }
 
+void
+write_calibration_file(FILE *dst, struct list *l,
+  struct a4l_calibration_subdev *subd, a4l_desc_t *desc)
+{
+   struct subdevice_calibration_node *e, *t;
+   int i, j = 0;
+
+   if (list_empty(l))
+   return;
+
+   /* TODO: modify the meaning of board/driver in the proc */
+   if (desc) {
+   write_calibration(dst, "[%s] \n",PLATFORM_STR);
+   write_calibration(dst, DRIVER_STR" = %s;\n", desc->board_name);
+   write_calibration(dst, BOARD_STR" = %s;\n", desc->driver_name);
+   }
+
+   write_calibration(dst, "\n[%s] \n", subd->name);
+   write_calibration(dst, INDEX_STR" = %d;\n", subd->idx);
+   list_for_each_entry_safe(e, t, l, node) {
+   j++;
+   }
+   write_calibration(dst, ELEMENTS_STR" = %d;\n", j);
+
+   j = 0;
+   list_for_each_entry_safe(e, t, l, node) {
+   write_calibration(dst, "[%s_%d] \n", subd->name, j);
+   write_calibration(dst, CHANNEL_STR" = %d;\n", e->channel);
+   write_calibration(dst, RANGE_STR" = %d;\n", e->range);
+   write_calibration(dst, EXPANSION_STR" = %g;\n",
+ e->polynomial->expansion_origin);
+   write_calibration(dst, NBCOEFF_STR"= %d;\n",
+ e->polynomial->nb_coefficients);
+
+   for (i = 0; i < e->polynomial->nb_coefficients; i++)
+   write_calibration(dst, COEFF_STR"_%d = %g;\n",
+ i,
+ e->polynomial->coefficients[i]);
+   j++;
+   }
+
+   return;
+}
+
+/*!
+ * @ingroup analogy_lib_level2
+ * @defgroup analogy_lib_calibration Software calibration API
+ * @{
+ */
+
+/**
+ * @brief Read the analogy generated calibration file
+ *
+ * @param[in] name Name of the calibration file
+ * @param[out] data Pointer to the calibration file contents
+ *
+ */
+
 int a4l_read_calibration_file(char *name, struct a4l_calibration_data *data)
 {
const char *subdevice[2] = { AI_SUBD_STR, AO_SUBD_STR };
@@ -186,48 +244,5 @@ int a4l_read_calibration_file(char *name, struct 
a4l_calibration_data *data)
return 0;
 }
 
-void a4l_write_calibration_file(FILE *dst, struct list *l,
-   struct a4l_calibration_subdev *subd,
-   a4l_desc_t *desc)
-{
-   struct subdevice_calibration_node *e, *t;
-   int i, j = 0;
-
-   if (list_empty(l))
-   return;
-
-   /* TODO: modify the meaning of board/driver in the proc */
-   if (desc) {
-   write_calibration(dst, "[%s] \n",PLATFORM_STR);
-   write_calibration(dst, DRIVER_STR" = %s;\n", desc->board_name);
-   write_calibration(dst, BOARD_STR" = %s;\n", desc->driver_name);
-   }
-
-   write_calibration(dst, "\n[%s] \n", subd->name);
-   write_calibration(dst, INDEX_STR" = %d;\n", subd->idx);
-   list_for_each_entry_safe(e, t, l, node) {
-   j++;
-   }
-   write_calibration(dst, ELEMENTS_STR" = %d;\n", j);
-
-   j = 0;
-   list_for_each_entry_safe(e, t, l, node) {
-   write_calibration(dst, "[%s_%d] \n", subd->name, j);
-   write_calibration(dst, CHANNEL_STR" = %d;\n", e->chann

[Xenomai-git] Philippe Gerum : cobalt/sh: disable 32bit syscall emulation

2014-10-25 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 37574aa22533942cfd7cd19d26754a99371192b7
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=37574aa22533942cfd7cd19d26754a99371192b7

Author: Philippe Gerum 
Date:   Thu Oct 16 14:22:25 2014 +0200

cobalt/sh: disable 32bit syscall emulation

---

 kernel/cobalt/arch/sh/Kconfig |3 +++
 1 file changed, 3 insertions(+)

diff --git a/kernel/cobalt/arch/sh/Kconfig b/kernel/cobalt/arch/sh/Kconfig
index 3f92993..af23fa0 100644
--- a/kernel/cobalt/arch/sh/Kconfig
+++ b/kernel/cobalt/arch/sh/Kconfig
@@ -4,6 +4,9 @@ config IPIPE_WANT_ACTIVE_MM
 config XENO_ARCH_FPU
def_bool SH_FPU
 
+config XENO_ARCH_SYS3264
+def_bool n
+
 menu "Machine/platform-specific options"
 
 config IPIPE_WANT_PREEMPTIBLE_SWITCH


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


[Xenomai-git] Philippe Gerum : cobalt/autotune: fixup for 32bit emulation

2014-10-25 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: c97bc3096fef3d4245aa760d56b989e4022eb071
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=c97bc3096fef3d4245aa760d56b989e4022eb071

Author: Philippe Gerum 
Date:   Wed Oct 22 10:10:04 2014 +0200

cobalt/autotune: fixup for 32bit emulation

---

 include/rtdm/uapi/autotune.h   |8 
 kernel/drivers/autotune/autotune.c |4 ++--
 utils/autotune/autotune.c  |8 
 3 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/include/rtdm/uapi/autotune.h b/include/rtdm/uapi/autotune.h
index 4a75d72..225f2f8 100644
--- a/include/rtdm/uapi/autotune.h
+++ b/include/rtdm/uapi/autotune.h
@@ -24,15 +24,15 @@
 #define RTDM_SUBCLASS_AUTOTUNE 0
 
 struct autotune_setup {
-   int period;
-   int quiet;
+   __u32 period;
+   __u32 quiet;
 };
 
 #define AUTOTUNE_RTIOC_IRQ _IOW(RTDM_CLASS_AUTOTUNE, 0, struct 
autotune_setup)
 #define AUTOTUNE_RTIOC_KERN_IOW(RTDM_CLASS_AUTOTUNE, 1, struct 
autotune_setup)
 #define AUTOTUNE_RTIOC_USER_IOW(RTDM_CLASS_AUTOTUNE, 2, struct 
autotune_setup)
-#define AUTOTUNE_RTIOC_PULSE   _IOW(RTDM_CLASS_AUTOTUNE, 3, 
nanosecs_abs_t)
-#define AUTOTUNE_RTIOC_RUN _IOR(RTDM_CLASS_AUTOTUNE, 4, unsigned 
long)
+#define AUTOTUNE_RTIOC_PULSE   _IOW(RTDM_CLASS_AUTOTUNE, 3, __u64)
+#define AUTOTUNE_RTIOC_RUN _IOR(RTDM_CLASS_AUTOTUNE, 4, __u32)
 #define AUTOTUNE_RTIOC_RESET   _IO(RTDM_CLASS_AUTOTUNE, 5)
 
 #endif /* !_RTDM_UAPI_AUTOTUNE_H */
diff --git a/kernel/drivers/autotune/autotune.c 
b/kernel/drivers/autotune/autotune.c
index 34ba9d5..79608b3 100644
--- a/kernel/drivers/autotune/autotune.c
+++ b/kernel/drivers/autotune/autotune.c
@@ -675,8 +675,8 @@ static int autotune_ioctl_rt(struct rtdm_fd *fd, unsigned 
int request, void *arg
 {
struct autotune_context *context;
struct gravity_tuner *tuner;
-   nanosecs_abs_t timestamp;
-   unsigned int gravity;
+   __u64 timestamp;
+   __u32 gravity;
int ret;
 
context = rtdm_fd_to_private(fd);
diff --git a/utils/autotune/autotune.c b/utils/autotune/autotune.c
index 5a18310..fe2f621 100644
--- a/utils/autotune/autotune.c
+++ b/utils/autotune/autotune.c
@@ -87,8 +87,8 @@ static const struct option base_options[] = {
 
 static void *sampler_thread(void *arg)
 {
-   nanosecs_abs_t timestamp = 0;
int fd = (long)arg, ret, n = 0;
+   __u64 timestamp = 0;
struct timespec now;
 
for (;;) {
@@ -101,7 +101,7 @@ static void *sampler_thread(void *arg)
} else {
n++;
clock_gettime(CLOCK_MONOTONIC, &now);
-   timestamp = (nanosecs_abs_t)now.tv_sec * 10 + 
now.tv_nsec;
+   timestamp = (__u64)now.tv_sec * 10 + 
now.tv_nsec;
}
}
 
@@ -206,8 +206,8 @@ static void usage(void)
 static void run_tuner(int fd, int op, int period, const char *type)
 {
struct autotune_setup setup;
-   unsigned long gravity;
pthread_t sampler;
+   __u32 gravity;
int ret;
 
setup.period = period;
@@ -232,7 +232,7 @@ static void run_tuner(int fd, int op, int period, const 
char *type)
pthread_cancel(sampler);
 
if (!quiet)
-   printf("%lu ns\n", gravity);
+   printf("%u ns\n", gravity);
 }
 
 int main(int argc, char *const argv[])


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


[Xenomai-git] Jorge Ramirez-Ortiz : drivers/analogy: disable chanlist check on calibration instructions

2014-10-25 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 51a0ebe4024abcceb39d35dbc3274a4df3cfc689
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=51a0ebe4024abcceb39d35dbc3274a4df3cfc689

Author: Jorge Ramirez-Ortiz 
Date:   Wed Aug 20 15:58:07 2014 -0400

drivers/analogy: disable chanlist check on calibration instructions

---

 kernel/drivers/analogy/instruction.c |   10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/kernel/drivers/analogy/instruction.c 
b/kernel/drivers/analogy/instruction.c
index 95c4419..7e7704f 100644
--- a/kernel/drivers/analogy/instruction.c
+++ b/kernel/drivers/analogy/instruction.c
@@ -228,10 +228,12 @@ int a4l_do_insn(struct a4l_device_context * cxt, struct 
a4l_kernel_instruction *
}
 
/* Checks the channel descriptor */
-   ret = a4l_check_chanlist(dev->transfer.subds[dsc->idx_subd],
-1, &dsc->chan_desc);
-   if (ret < 0)
-   return ret;
+   if ((subd->flags & A4L_SUBD_TYPES) != A4L_SUBD_CALIB) {
+   ret = a4l_check_chanlist(dev->transfer.subds[dsc->idx_subd],
+1, &dsc->chan_desc);
+   if (ret < 0)
+   return ret;
+   }
 
/* Choose the proper handler, we can check the pointer because
   the subdevice was memset to 0 at allocation time */


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


[Xenomai-git] Philippe Gerum : cobalt/powerpc: disable 32bit syscall emulation

2014-10-25 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: d6df3c655e6345e3c4d26efa53ed0b4857acfa09
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=d6df3c655e6345e3c4d26efa53ed0b4857acfa09

Author: Philippe Gerum 
Date:   Thu Oct 16 14:22:18 2014 +0200

cobalt/powerpc: disable 32bit syscall emulation

---

 kernel/cobalt/arch/powerpc/Kconfig |3 +++
 1 file changed, 3 insertions(+)

diff --git a/kernel/cobalt/arch/powerpc/Kconfig 
b/kernel/cobalt/arch/powerpc/Kconfig
index bc519a5..ef49798 100644
--- a/kernel/cobalt/arch/powerpc/Kconfig
+++ b/kernel/cobalt/arch/powerpc/Kconfig
@@ -20,6 +20,9 @@ config XENO_ARCH_WANT_TIP
 config XENO_ARCH_FPU
def_bool PPC_FPU
 
+config XENO_ARCH_SYS3264
+def_bool n
+
 menu "Machine/platform-specific options"
 
 config XENO_ARCH_UNLOCKED_SWITCH


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


[Xenomai-git] Philippe Gerum : cobalt/nios2: disable 32bit syscall emulation

2014-10-25 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: a12f2af328a6d6c540f5b72c84f22b705d1f445c
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=a12f2af328a6d6c540f5b72c84f22b705d1f445c

Author: Philippe Gerum 
Date:   Thu Oct 16 14:22:33 2014 +0200

cobalt/nios2: disable 32bit syscall emulation

---

 kernel/cobalt/arch/nios2/Kconfig |3 +++
 1 file changed, 3 insertions(+)

diff --git a/kernel/cobalt/arch/nios2/Kconfig b/kernel/cobalt/arch/nios2/Kconfig
index 9f19382..1ca0278 100644
--- a/kernel/cobalt/arch/nios2/Kconfig
+++ b/kernel/cobalt/arch/nios2/Kconfig
@@ -1,5 +1,8 @@
 config XENO_ARCH_FPU
def_bool n
 
+config XENO_ARCH_SYS3264
+def_bool n
+
 source "kernel/xenomai/Kconfig"
 source "drivers/xenomai/Kconfig"


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