[Xenomai-git] Philippe Gerum : cobalt/posix/cond: fix error path in failed init

2014-09-21 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: 8f70e7783b8da52f97434e8dd1f99d322e192cdd
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=8f70e7783b8da52f97434e8dd1f99d322e192cdd

Author: Philippe Gerum 
Date:   Sun Sep 21 21:28:51 2014 +0200

cobalt/posix/cond: fix error path in failed init

---

 kernel/cobalt/posix/cond.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/cobalt/posix/cond.c b/kernel/cobalt/posix/cond.c
index fb5a028..3c47608 100644
--- a/kernel/cobalt/posix/cond.c
+++ b/kernel/cobalt/posix/cond.c
@@ -121,7 +121,7 @@ do_init:
return 0;
 fail_register:
xnlock_put_irqrestore(&nklock, s);
-   cobalt_umm_free(&cobalt_ppd_get(cond->attr.pshared)->umm, state);
+   cobalt_umm_free(&sys_ppd->umm, state);
 fail_umm:
xnfree(cond);
 


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


[Xenomai-git] Gilles Chanteperdrix : vfile/snapshot: avoid starvation by spinning 1us after every iteration

2014-09-21 Thread git repository hosting
Module: xenomai-2.6
Branch: master
Commit: b0ece7f1365464fea6cffd93a1e3155adf1064ad
URL:
http://git.xenomai.org/?p=xenomai-2.6.git;a=commit;h=b0ece7f1365464fea6cffd93a1e3155adf1064ad

Author: Gilles Chanteperdrix 
Date:   Sun Sep 21 20:46:37 2014 +0200

vfile/snapshot: avoid starvation by spinning 1us after every iteration

---

 ksrc/nucleus/vfile.c |9 +
 1 file changed, 9 insertions(+)

diff --git a/ksrc/nucleus/vfile.c b/ksrc/nucleus/vfile.c
index c8e0363..066c12f 100644
--- a/ksrc/nucleus/vfile.c
+++ b/ksrc/nucleus/vfile.c
@@ -279,6 +279,15 @@ redo:
data += vfile->datasz;
it->nrdata++;
}
+#ifdef CONFIG_SMP
+   {
+   /* Leave some time for other cpus to get the lock */
+   xnticks_t wakeup = xnarch_get_cpu_tsc();
+   wakeup += xnarch_ns_to_tsc(1000);
+   while ((xnsticks_t)(xnarch_get_cpu_tsc() - wakeup) < 0)
+   cpu_relax();
+   }
+#endif
}
 
if (ret < 0) {


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


[Xenomai-git] Gilles Chanteperdrix : xnlock: add missing barriers

2014-09-21 Thread git repository hosting
Module: xenomai-2.6
Branch: master
Commit: 546d1fd7d4313394610d830cf0deca12d6eb7721
URL:
http://git.xenomai.org/?p=xenomai-2.6.git;a=commit;h=546d1fd7d4313394610d830cf0deca12d6eb7721

Author: Gilles Chanteperdrix 
Date:   Sun Sep 21 20:47:26 2014 +0200

xnlock: add missing barriers

and optimize by removing useless barriers on x86

---

 include/asm-generic/system.h |   18 ++
 include/asm-x86/atomic.h |9 ++---
 2 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/include/asm-generic/system.h b/include/asm-generic/system.h
index 25bd83f..798eb9d 100644
--- a/include/asm-generic/system.h
+++ b/include/asm-generic/system.h
@@ -93,6 +93,14 @@ static inline unsigned xnarch_current_cpu(void)
return rthal_processor_id();
 }
 
+#ifndef xnarch_mb_before_unlock
+#define xnarch_mb_before_unlock() xnarch_memory_barrier()
+#endif
+
+#ifndef xnarch_mb_after_unlock
+#define xnarch_mb_after_unlock() xnarch_memory_barrier()
+#endif
+
 #if XENO_DEBUG(XNLOCK)
 
 typedef struct {
@@ -375,9 +383,11 @@ static inline void xnlock_put(xnlock_t *lock)
 * Make sure all data written inside the lock is visible to
 * other CPUs before we release the lock.
 */
-   xnarch_memory_barrier();
+   xnarch_mb_before_unlock();
 
atomic_set(&lock->owner, ~0);
+
+   xnarch_mb_after_unlock();
 }
 
 static inline spl_t
@@ -456,9 +466,9 @@ static inline int xnarch_remap_io_page_range(struct file 
*filp,
 unsigned long size,
 pgprot_t prot)
 {
-   return wrap_remap_io_page_range(vma, from, to, size,
-   wrap_phys_mem_prot(filp, (to) >> 
PAGE_SHIFT,
-  size, prot));
+   return wrap_remap_io_page_range(vma, from, to, size,
+   wrap_phys_mem_prot(filp, (to) >> 
PAGE_SHIFT,
+  size, prot));
 }
 
 static inline int xnarch_remap_kmem_page_range(struct vm_area_struct *vma,
diff --git a/include/asm-x86/atomic.h b/include/asm-x86/atomic.h
index ca6bbdb..f35fd54 100644
--- a/include/asm-x86/atomic.h
+++ b/include/asm-x86/atomic.h
@@ -54,6 +54,9 @@ typedef atomic_long_t xnarch_atomic_t;
 #define xnarch_read_memory_barrier()rmb()
 #define xnarch_write_memory_barrier()   wmb()
 
+#define xnarch_mb_before_unlock()  barrier()
+#define xnarch_mb_after_unlock()   barrier()
+
 #else /* !__KERNEL__ */
 
 #include 
@@ -70,9 +73,9 @@ typedef struct { unsigned long counter; } xnarch_atomic_t;
 #define xnarch_write_memory_barrier() xnarch_memory_barrier()
 
 #define xnarch_atomic_cmpxchg(v, o, n)  \
-__sync_val_compare_and_swap(&(v)->counter,  \
-(unsigned long)(o), \
-(unsigned long)(n))
+   __sync_val_compare_and_swap(&(v)->counter,  \
+   (unsigned long)(o), \
+   (unsigned long)(n))
 
 static inline void cpu_relax(void)
 {


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


[Xenomai-git] Philippe Gerum : scripts/prepare-kernel: remove support for legacy patches

2014-09-21 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: 948ba43ddac5f442878f4664b3457251273fcdb7
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=948ba43ddac5f442878f4664b3457251273fcdb7

Author: Philippe Gerum 
Date:   Tue Sep  9 16:59:57 2014 +0200

scripts/prepare-kernel: remove support for legacy patches

---

 scripts/prepare-kernel.sh |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/scripts/prepare-kernel.sh b/scripts/prepare-kernel.sh
index 7111d3f..f1791ca 100755
--- a/scripts/prepare-kernel.sh
+++ b/scripts/prepare-kernel.sh
@@ -321,9 +321,9 @@ if test -r $linux_tree/include/linux/ipipe.h; then
 fi
 else
if test x$ipipe_patch = x; then
-  # We pick ipipe-core-* patches first over adeos-ipipe-* ones,
-  # then the highest numbered sequence/release number.
-  default_ipipe_patch="`( ls 
$xenomai_root/kernel/cobalt/arch/$linux_arch/patches/ipipe-core-$linux_version*-$linux_arch-*
 
$xenomai_root/kernel/cobalt/arch/$linux_arch/patches/adeos-ipipe-$linux_version*-$linux_arch-*|sort
 -r ) 2>/dev/null | head -n1`"
+  # Pick ipipe-core-* patches based on the highest numbered
+  # sequence/release number.
+  default_ipipe_patch="`( ls 
$xenomai_root/kernel/cobalt/arch/$linux_arch/patches/ipipe-core-$linux_version*-$linux_arch-*|sort
 -r ) 2>/dev/null | head -n1`"
fi
if test x$default_ipipe_patch = x; then
   if test x$verbose = x1; then


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


[Xenomai-git] Philippe Gerum : cobalt/rtdm: allow omitting open/socket/close handlers

2014-09-21 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: 1977217455154a43bfdbcdf256b4233317f18806
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=1977217455154a43bfdbcdf256b4233317f18806

Author: Philippe Gerum 
Date:   Tue Sep  9 17:38:34 2014 +0200

cobalt/rtdm: allow omitting open/socket/close handlers

Although unusual, omitting open/socket/close handlers in drivers is
perfectly legitimate, and nothing justifies to keep them required.

---

 kernel/cobalt/rtdm/core.c   |   37 ++---
 kernel/cobalt/rtdm/device.c |   16 
 2 files changed, 18 insertions(+), 35 deletions(-)

diff --git a/kernel/cobalt/rtdm/core.c b/kernel/cobalt/rtdm/core.c
index 18cf0c6..f84d8b0 100644
--- a/kernel/cobalt/rtdm/core.c
+++ b/kernel/cobalt/rtdm/core.c
@@ -56,7 +56,8 @@ static void cleanup_instance(struct rtdm_device *device,
 void __rt_dev_close(struct rtdm_fd *fd)
 {
struct rtdm_dev_context *context = rtdm_fd_to_context(fd);
-   context->reserved.close(fd);
+   if (context->reserved.close)
+   context->reserved.close(fd);
cleanup_instance(context->device, context);
 }
 
@@ -168,13 +169,13 @@ int __rt_dev_open(struct xnsys_ppd *p, int ufd, const 
char *path, int oflag)
 
trace_cobalt_fd_open(current, &context->fd, ufd, oflag);
 
-   ret = device->ops.open(&context->fd, oflag);
-
-   if (!XENO_ASSERT(COBALT, !spltest()))
-   splnone();
-
-   if (ret < 0)
-   goto cleanup_out;
+   if (device->ops.open) {
+   ret = device->ops.open(&context->fd, oflag);
+   if (!XENO_ASSERT(COBALT, !spltest()))
+   splnone();
+   if (ret < 0)
+   goto cleanup_out;
+   }
 
trace_cobalt_fd_created(&context->fd, ufd);
 
@@ -195,9 +196,8 @@ int __rt_dev_socket(struct xnsys_ppd *p, int ufd, int 
protocol_family,
int ret;
 
device = __rtdm_get_protocol_device(protocol_family, socket_type);
-   ret = -EAFNOSUPPORT;
-   if (!device)
-   goto err_out;
+   if (device == NULL)
+   return -EAFNOSUPPORT;
 
ret = create_instance(p, ufd, device, &context);
if (ret < 0)
@@ -206,13 +206,13 @@ int __rt_dev_socket(struct xnsys_ppd *p, int ufd, int 
protocol_family,
 
trace_cobalt_fd_socket(current, &context->fd, ufd, protocol_family);
 
-   ret = device->ops.socket(&context->fd, protocol);
-
-   if (!XENO_ASSERT(COBALT, !spltest()))
-   splnone();
-
-   if (unlikely(ret < 0))
-   goto cleanup_out;
+   if (device->ops.socket) {
+   ret = device->ops.socket(&context->fd, protocol);
+   if (!XENO_ASSERT(COBALT, !spltest()))
+   splnone();
+   if (ret < 0)
+   goto cleanup_out;
+   }
 
trace_cobalt_fd_created(&context->fd, ufd);
 
@@ -221,7 +221,6 @@ int __rt_dev_socket(struct xnsys_ppd *p, int ufd, int 
protocol_family,
 cleanup_out:
cleanup_instance(device, context);
 
-err_out:
return ret;
 }
 EXPORT_SYMBOL_GPL(__rt_dev_socket);
diff --git a/kernel/cobalt/rtdm/device.c b/kernel/cobalt/rtdm/device.c
index 14e4492..d513685 100644
--- a/kernel/cobalt/rtdm/device.c
+++ b/kernel/cobalt/rtdm/device.c
@@ -195,20 +195,10 @@ int rtdm_dev_register(struct rtdm_device *device)
 
switch (device->device_flags & RTDM_DEVICE_TYPE_MASK) {
case RTDM_NAMED_DEVICE:
-   /* Sanity check: any open handler? */
-   if (device->ops.open == NULL) {
-   printk(XENO_ERR "missing open handler for RTDM 
device\n");
-   return -EINVAL;
-   }
device->ops.socket = (typeof(device->ops.socket))enosys;
break;
 
case RTDM_PROTOCOL_DEVICE:
-   /* Sanity check: any socket handler? */
-   if (device->ops.socket == NULL) {
-   printk(XENO_ERR "missing socket handler for RTDM 
device\n");
-   return -EINVAL;
-   }
device->ops.open = (typeof(device->ops.open))enosys;
break;
 
@@ -216,12 +206,6 @@ int rtdm_dev_register(struct rtdm_device *device)
return -EINVAL;
}
 
-   /* Sanity check: driver-defined close handler?
-* (Always required for forced cleanup) */
-   if (device->ops.close == NULL) {
-   printk(XENO_ERR "missing close handler for RTDM device\n");
-   return -EINVAL;
-   }
device->reserved.close = device->ops.close;
device->ops.close = __rt_dev_close;
atomic_set(&device->reserved.refcount, 0);


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


[Xenomai-git] Philippe Gerum : cobalt/rtdm: privatize local data

2014-09-21 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: 2dab013261774f075583750edcf70422a2677477
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=2dab013261774f075583750edcf70422a2677477

Author: Philippe Gerum 
Date:   Sat Sep 20 19:06:28 2014 +0200

cobalt/rtdm: privatize local data

---

 kernel/cobalt/rtdm/device.c   |   21 ++---
 kernel/cobalt/rtdm/internal.h |6 --
 2 files changed, 10 insertions(+), 17 deletions(-)

diff --git a/kernel/cobalt/rtdm/device.c b/kernel/cobalt/rtdm/device.c
index 951a35d..98ff9cd 100644
--- a/kernel/cobalt/rtdm/device.c
+++ b/kernel/cobalt/rtdm/device.c
@@ -47,11 +47,10 @@
 
 #define RTDM_DEVICE_MAGIC  0x82846877
 
-struct list_head rtdm_named_devices;   /* hash table */
-struct rb_root rtdm_protocol_devices;
-
-struct semaphore nrt_dev_lock;
-DEFINE_XNLOCK(rt_dev_lock);
+static struct list_head named_devices;
+static struct rb_root protocol_devices;
+static struct semaphore nrt_dev_lock;
+DEFINE_PRIVATE_XNLOCK(rt_dev_lock);
 
 static struct class *rtdm_class;
 
@@ -117,7 +116,7 @@ struct rtdm_device *__rtdm_get_protodev(int 
protocol_family, int socket_type)
 
xnlock_get_irqsave(&rt_dev_lock, s);
 
-   xnid = xnid_fetch(&rtdm_protocol_devices, id);
+   xnid = xnid_fetch(&protocol_devices, id);
if (xnid) {
device = container_of(xnid, struct rtdm_device, proto.id);
__rtdm_get_device(device);
@@ -358,7 +357,7 @@ int rtdm_dev_register(struct rtdm_device *device)
}
 
xnlock_get_irqsave(&rt_dev_lock, s);
-   list_add_tail(&device->named.entry, &rtdm_named_devices);
+   list_add_tail(&device->named.entry, &named_devices);
xnlock_put_irqrestore(&rt_dev_lock, s);
} else {
device->name = kstrdup(device->label, GFP_KERNEL);
@@ -377,7 +376,7 @@ int rtdm_dev_register(struct rtdm_device *device)
 
id = get_proto_id(drv->protocol_family, drv->socket_type);
xnlock_get_irqsave(&rt_dev_lock, s);
-   ret = xnid_enter(&rtdm_protocol_devices, &device->proto.id, id);
+   ret = xnid_enter(&protocol_devices, &device->proto.id, id);
xnlock_put_irqrestore(&rt_dev_lock, s);
if (ret < 0)
goto fail;
@@ -441,7 +440,7 @@ void rtdm_dev_unregister(struct rtdm_device *device)
handle = device->named.handle;
list_del(&device->named.entry);
} else
-   xnid_remove(&rtdm_protocol_devices, &device->proto.id);
+   xnid_remove(&protocol_devices, &device->proto.id);
 
xnlock_put_irqrestore(&rt_dev_lock, s);
 
@@ -464,8 +463,8 @@ int __init rtdm_init(void)
 {
sema_init(&nrt_dev_lock, 1);
 
-   INIT_LIST_HEAD(&rtdm_named_devices);
-   xntree_init(&rtdm_protocol_devices);
+   INIT_LIST_HEAD(&named_devices);
+   xntree_init(&protocol_devices);
 
rtdm_class = class_create(THIS_MODULE, "rtdm");
if (IS_ERR(rtdm_class)) {
diff --git a/kernel/cobalt/rtdm/internal.h b/kernel/cobalt/rtdm/internal.h
index 58c8f93..2d64c6a 100644
--- a/kernel/cobalt/rtdm/internal.h
+++ b/kernel/cobalt/rtdm/internal.h
@@ -29,12 +29,6 @@
 #include 
 #include 
 
-DECLARE_EXTERN_XNLOCK(rt_dev_lock);
-
-extern struct semaphore nrt_dev_lock;
-extern struct list_head rtdm_named_devices;
-extern struct rb_root rtdm_protocol_devices;
-
 static inline void __rtdm_get_device(struct rtdm_device *device)
 {
atomic_inc(&device->refcount);


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


[Xenomai-git] Philippe Gerum : doc: fixups

2014-09-21 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: 0df694856350255201d1e8fb382eb31b214a7f51
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=0df694856350255201d1e8fb382eb31b214a7f51

Author: Philippe Gerum 
Date:   Sun Sep 21 15:04:34 2014 +0200

doc: fixups

---

 doc/asciidoc/MIGRATION.adoc |  589 ---
 doc/doxygen/xeno3prm-common.conf.in |   12 +-
 include/cobalt/kernel/rtdm/driver.h |6 +-
 include/cobalt/kernel/thread.h  |8 +-
 include/rtdm/can.h  |8 +-
 include/rtdm/serial.h   |   13 +-
 include/rtdm/testing.h  |   14 +-
 include/rtdm/uapi/ipc.h |8 +-
 kernel/cobalt/heap.c|4 +-
 kernel/cobalt/rtdm/device.c |4 +-
 kernel/drivers/can/README   |2 +-
 lib/psos/README |5 +-
 lib/trank/native.c  |2 +-
 lib/vxworks/README  |7 +-
 14 files changed, 533 insertions(+), 149 deletions(-)

diff --git a/doc/asciidoc/MIGRATION.adoc b/doc/asciidoc/MIGRATION.adoc
index f87fffb..0790e9f 100644
--- a/doc/asciidoc/MIGRATION.adoc
+++ b/doc/asciidoc/MIGRATION.adoc
@@ -361,13 +361,307 @@ rtdm/rtipc.h -> rtdm/ipc.h
 
 === Driver API ===
 
-- Changes in the +rtdm_device+ descriptor
+ New device description model 
+
+Several changes have taken place in the device description passed to
++rtdm_dev_register()+ (i.e. +struct rtdm_device+). Aside of fixing
+consistency issues, the bulk of changes is aimed at narrowing the gap
+between the regular Linux device driver model and RTDM.
+
+To this end, RTDM in Xenomai 3 shares the Linux namespace for named
+devices, which are now backed by common character device objects from
+the regular Linux device model. As a consequence of this, file
+descriptors obtained on named RTDM devices are regular file
+descriptors, visible from the +/proc//fd+ interface.
+
+= Named device description =
+
+The major change required for supporting this closer integration of
+RTDM into the regular Linux driver model involved splitting the device
+driver properties from the device instance definitions, which used to
+be combined in Xenomai 2.x into the +rtdm_device+ descriptor.
+
+.Xenomai 2.x named device description
+-
+static struct rtdm_device foo_device0 = {
+   .struct_version =   RTDM_DEVICE_STRUCT_VER,
+   .device_flags   =   RTDM_NAMED_DEVICE|RTDM_EXCLUSIVE,
+   .device_id  =   0
+   .context_size   =   sizeof(struct foo_context),
+   .ops = {
+   .open   =   foo_open,
+   .ioctl_rt   =   foo_ioctl_rt,
+   .ioctl_nrt  =   foo_ioctl_nrt,
+   .close  =   foo_close,
+   },
+   .device_class   =   RTDM_CLASS_EXPERIMENTAL,
+   .device_sub_class   =   RTDM_SUBCLASS_FOO,
+   .profile_version=   42,
+   .device_name=   "foo0",
+   .driver_name=   "foo driver",
+   .driver_version =   RTDM_DRIVER_VER(1, 0, 0),
+   .peripheral_name=   "Ultra-void IV board driver",
+   .proc_name  =   device.device_name,
+   .provider_name  =   "Whoever",
+};
+
+static struct rtdm_device foo_device1 = {
+   .struct_version =   RTDM_DEVICE_STRUCT_VER,
+   .device_flags   =   RTDM_NAMED_DEVICE|RTDM_EXCLUSIVE,
+   .device_id  =   1
+   .context_size   =   sizeof(struct foo_context),
+   .ops = {
+   .open   =   foo_open,
+   .ioctl_rt   =   foo_ioctl_rt,
+   .ioctl_nrt  =   foo_ioctl_nrt,
+   .close  =   foo_close,
+   },
+   .device_class   =   RTDM_CLASS_EXPERIMENTAL,
+   .device_sub_class   =   RTDM_SUBCLASS_FOO,
+   .profile_version=   42,
+   .device_name=   "foo1",
+   .device_data=   NULL,
+   .driver_name=   "foo driver",
+   .driver_version =   RTDM_DRIVER_VER(1, 0, 0),
+   .peripheral_name=   "Ultra-void IV board driver",
+   .proc_name  =   device.device_name,
+   .provider_name  =   "Whoever",
+};
+
+foo0.device_data = &some_driver_data0;
+ret = rtdm_dev_register(&foo0);
+...
+foo1.device_data = &some_driver_data1;
+ret = rtdm_dev_register(&foo1);
+
+-
+
+The legacy description above would only create "virtual" device
+entries, private to the RTDM device namespace, with no visible
+counterparts into the Linux device namespace.
+
+.Xenomai 3.x named device description
+-
+
+static struct rtdm_driver foo_driver = {

[Xenomai-git] Philippe Gerum : drivers/timerbench, drivers/switchtest: instantiate a single device

2014-09-21 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: dbdc0ebda2f671c7b9845bbbd11858256e40e73e
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=dbdc0ebda2f671c7b9845bbbd11858256e40e73e

Author: Philippe Gerum 
Date:   Thu Sep 18 09:15:16 2014 +0200

drivers/timerbench, drivers/switchtest: instantiate a single device

Those drivers can already multiplex any number of connections on a
single device, so we don't need them to instantiate more than a single
device.

As a result of this change, the /dev/rtdm/{switchtest,
timerbench}[0-9] series of devices become single devnodes
/dev/rtdm/{switchtest, timerbench}.

---

 doc/asciidoc/man1/latency.adoc  |3 --
 kernel/drivers/testing/switchtest.c |   66 ---
 kernel/drivers/testing/timerbench.c |   30 +++-
 testsuite/latency/latency.c |   18 ++
 testsuite/switchtest/switchtest.c   |   43 ++-
 5 files changed, 42 insertions(+), 118 deletions(-)

diff --git a/doc/asciidoc/man1/latency.adoc b/doc/asciidoc/man1/latency.adoc
index 3931a4f..42a1ae1 100644
--- a/doc/asciidoc/man1/latency.adoc
+++ b/doc/asciidoc/man1/latency.adoc
@@ -64,9 +64,6 @@ default=0, so ^C to end
 *-q*::
 suppresses RTD, RTH lines if -T is used
 
-*-D *::
-number of testing device, default=0
-
 *-t *::
 0=user task (default), 1=kernel task, 2=timer IRQ
 
diff --git a/kernel/drivers/testing/switchtest.c 
b/kernel/drivers/testing/switchtest.c
index f32782d..0bb5981 100644
--- a/kernel/drivers/testing/switchtest.c
+++ b/kernel/drivers/testing/switchtest.c
@@ -26,8 +26,6 @@
 #include 
 #include 
 
-#define NR_DEVICES  4
-
 #define RTSWITCH_RT  0x1
 #define RTSWITCH_NRT 0
 #define RTSWITCH_KERNEL  0x2
@@ -37,22 +35,22 @@ struct rtswitch_task {
rtdm_event_t rt_synch;
struct semaphore nrt_synch;
struct xnthread ktask;  /* For kernel-space real-time tasks. */
-   unsigned last_switch;
+   unsigned int last_switch;
 };
 
 struct rtswitch_context {
struct rtswitch_task *tasks;
-   unsigned tasks_count;
-   unsigned next_index;
+   unsigned int tasks_count;
+   unsigned int next_index;
struct semaphore lock;
-   unsigned cpu;
-   unsigned switches_count;
+   unsigned int cpu;
+   unsigned int switches_count;
 
unsigned long pause_us;
-   unsigned next_task;
+   unsigned int next_task;
rtdm_timer_t wake_up_delay;
 
-   unsigned failed;
+   unsigned int failed;
struct rttst_swtest_error error;
 
struct rtswitch_task *utask;
@@ -76,10 +74,10 @@ static int report(const char *fmt, ...)
return ret;
 }
 
-static void handle_ktask_error(struct rtswitch_context *ctx, unsigned fp_val)
+static void handle_ktask_error(struct rtswitch_context *ctx, unsigned int 
fp_val)
 {
struct rtswitch_task *cur = &ctx->tasks[ctx->error.last_switch.to];
-   unsigned i;
+   unsigned int i;
 
ctx->failed = 1;
ctx->error.fp_val = fp_val;
@@ -110,7 +108,7 @@ static void handle_ktask_error(struct rtswitch_context 
*ctx, unsigned fp_val)
 }
 
 static int rtswitch_pend_rt(struct rtswitch_context *ctx,
-   unsigned idx)
+   unsigned int idx)
 {
struct rtswitch_task *task;
int rc;
@@ -151,8 +149,8 @@ static void timed_wake_up(rtdm_timer_t *timer)
 }
 
 static int rtswitch_to_rt(struct rtswitch_context *ctx,
- unsigned from_idx,
- unsigned to_idx)
+ unsigned int from_idx,
+ unsigned int to_idx)
 {
struct rtswitch_task *from, *to;
int rc;
@@ -212,7 +210,7 @@ static int rtswitch_to_rt(struct rtswitch_context *ctx,
 }
 
 static int rtswitch_pend_nrt(struct rtswitch_context *ctx,
-unsigned idx)
+unsigned int idx)
 {
struct rtswitch_task *task;
 
@@ -233,11 +231,11 @@ static int rtswitch_pend_nrt(struct rtswitch_context *ctx,
 }
 
 static int rtswitch_to_nrt(struct rtswitch_context *ctx,
-  unsigned from_idx,
-  unsigned to_idx)
+  unsigned int from_idx,
+  unsigned int to_idx)
 {
struct rtswitch_task *from, *to;
-   unsigned expected, fp_val;
+   unsigned int expected, fp_val;
int fp_check;
 
if (from_idx > ctx->tasks_count || to_idx > ctx->tasks_count)
@@ -348,7 +346,7 @@ static int rtswitch_to_nrt(struct rtswitch_context *ctx,
return 0;
 }
 
-static int rtswitch_set_tasks_count(struct rtswitch_context *ctx, unsigned 
count)
+static int rtswitch_set_tasks_count(struct rtswitch_context *ctx, unsigned int 
count)
 {
struct rtswitch_task *tasks;
 
@@ -550,7 +548,7 @@ static int rtswitch_open(struct rtdm_fd *fd, int oflags)
 static void rtswitch_close(struct rtdm_fd *fd)
 {
struct rtswitch_

[Xenomai-git] Philippe Gerum : cobalt/kernel: omit .owner for internal fops

2014-09-21 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: a190257503a75871588ced27f1fbdfa339ee9b52
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=a190257503a75871588ced27f1fbdfa339ee9b52

Author: Philippe Gerum 
Date:   Tue Sep  9 17:06:48 2014 +0200

cobalt/kernel: omit .owner for internal fops

---

 kernel/cobalt/pipe.c  |1 -
 kernel/cobalt/vfile.c |2 --
 2 files changed, 3 deletions(-)

diff --git a/kernel/cobalt/pipe.c b/kernel/cobalt/pipe.c
index 4e55448..a649ecf 100644
--- a/kernel/cobalt/pipe.c
+++ b/kernel/cobalt/pipe.c
@@ -1093,7 +1093,6 @@ static unsigned xnpipe_poll(struct file *file, poll_table 
*pt)
 }
 
 static struct file_operations xnpipe_fops = {
-   .owner = THIS_MODULE,
.read = xnpipe_read,
.write = xnpipe_write,
.poll = xnpipe_poll,
diff --git a/kernel/cobalt/vfile.c b/kernel/cobalt/vfile.c
index 925f2f6..553b4c0 100644
--- a/kernel/cobalt/vfile.c
+++ b/kernel/cobalt/vfile.c
@@ -339,7 +339,6 @@ ssize_t vfile_snapshot_write(struct file *file, const char 
__user *buf,
 }
 
 static struct file_operations vfile_snapshot_fops = {
-   .owner = THIS_MODULE,
.open = vfile_snapshot_open,
.read = seq_read,
.write = vfile_snapshot_write,
@@ -592,7 +591,6 @@ ssize_t vfile_regular_write(struct file *file, const char 
__user *buf,
 }
 
 static struct file_operations vfile_regular_fops = {
-   .owner = THIS_MODULE,
.open = vfile_regular_open,
.read = seq_read,
.write = vfile_regular_write,


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


[Xenomai-git] Philippe Gerum : configure: require shm_open() with --enable-pshared

2014-09-21 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: 07652bbb322fe55b07ddcb8067dc4ae992942104
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=07652bbb322fe55b07ddcb8067dc4ae992942104

Author: Philippe Gerum 
Date:   Tue Sep  9 18:51:05 2014 +0200

configure: require shm_open() with --enable-pshared

---

 configure|   10 ++
 configure.ac |7 +++
 2 files changed, 17 insertions(+)

diff --git a/configure b/configure
index e1c1871..248ac6c 100755
--- a/configure
+++ b/configure
@@ -13784,6 +13784,16 @@ $as_echo "#define 
CONFIG_XENO_COPPERPLATE_CLOCK_RESTRICTED 1" >>confdefs.h
 fi
 
 
+if test x$use_pshared = xy;  then
+  ac_fn_c_check_func "$LINENO" "shm_open" "ac_cv_func_shm_open"
+if test "x$ac_cv_func_shm_open" = xyes; then :
+
+else
+  as_fn_error $? "shm_open() is missing, --disable-pshared is required" 
"$LINENO" 5
+fi
+
+fi
+
 
 
 cat >>confdefs.h <<_ACEOF
diff --git a/configure.ac b/configure.ac
index 023d270..e50d875 100644
--- a/configure.ac
+++ b/configure.ac
@@ -531,6 +531,13 @@ dnl won't vary for a given Xenomai installation.
 AC_CHECK_FUNC(pthread_condattr_setclock,,
 [AC_DEFINE(CONFIG_XENO_COPPERPLATE_CLOCK_RESTRICTED, 1,[config])])
 
+dnl Check that Copperplate can implement a shared heap if
+dnl --enable-pshared was given.
+if test x$use_pshared = xy;  then
+  AC_CHECK_FUNC(shm_open,,
+  [AC_MSG_ERROR([shm_open() is missing, --disable-pshared is required])])
+fi
+
 dnl
 dnl Produce the info needed to build xeno_config.h
 dnl


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


[Xenomai-git] Philippe Gerum : cobalt/registry, cobalt/synch: prepare for embedding more special bits in handles

2014-09-21 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: a8c182b0a065c64d7b7679add49cf9be433f0ef9
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=a8c182b0a065c64d7b7679add49cf9be433f0ef9

Author: Philippe Gerum 
Date:   Thu Sep 11 10:26:50 2014 +0200

cobalt/registry, cobalt/synch: prepare for embedding more special bits in 
handles

---

 include/cobalt/kernel/registry.h   |1 +
 include/cobalt/kernel/synch.h  |8 
 include/cobalt/kernel/thread.h |2 +-
 include/cobalt/uapi/kernel/synch.h |   26 --
 include/cobalt/uapi/kernel/types.h |   30 --
 kernel/cobalt/registry.c   |6 ++
 kernel/cobalt/synch.c  |   11 ++-
 7 files changed, 54 insertions(+), 30 deletions(-)

diff --git a/include/cobalt/kernel/registry.h b/include/cobalt/kernel/registry.h
index 383754c..25c8f48 100644
--- a/include/cobalt/kernel/registry.h
+++ b/include/cobalt/kernel/registry.h
@@ -138,6 +138,7 @@ static inline struct xnobject 
*xnregistry_validate(xnhandle_t handle)
 * unexported carries a NULL objaddr, so we have to check this
 * as well.
 */
+   handle = xnhandle_get_index(handle);
if (likely(handle && handle < CONFIG_XENO_OPT_REGISTRY_NRSLOTS)) {
object = ®istry_obj_slots[handle];
return object->objaddr ? object : NULL;
diff --git a/include/cobalt/kernel/synch.h b/include/cobalt/kernel/synch.h
index d4df940..98d7a43 100644
--- a/include/cobalt/kernel/synch.h
+++ b/include/cobalt/kernel/synch.h
@@ -30,8 +30,6 @@
  */
 #define XNSYNCH_CLAIMED 0x10   /* Claimed by other thread(s) w/ PIP */
 
-#define XNSYNCH_FLCLAIM XN_HANDLE_SPARE3 /* Corresponding bit in fast lock */
-
 /* Spare flags usable by upper interfaces */
 #define XNSYNCH_SPARE0  0x0100
 #define XNSYNCH_SPARE1  0x0200
@@ -103,12 +101,6 @@ static inline struct xnthread *xnsynch_owner(struct 
xnsynch *synch)
 #define xnsynch_owner_check(synch, thread) \
xnsynch_fast_owner_check((synch)->fastlock, thread->handle)
 
-#define xnsynch_fast_is_claimed(fastlock) \
-   xnhandle_test_spare(fastlock, XNSYNCH_FLCLAIM)
-#define xnsynch_fast_set_claimed(fastlock, enable) \
-   (((fastlock) & ~XNSYNCH_FLCLAIM) | ((enable) ? XNSYNCH_FLCLAIM : 0))
-#define xnsynch_fast_mask_claimed(fastlock) ((fastlock & ~XNSYNCH_FLCLAIM))
-
 #if XENO_DEBUG(USER)
 
 void xnsynch_detect_relaxed_owner(struct xnsynch *synch,
diff --git a/include/cobalt/kernel/thread.h b/include/cobalt/kernel/thread.h
index 03faf8f..e41ac06 100644
--- a/include/cobalt/kernel/thread.h
+++ b/include/cobalt/kernel/thread.h
@@ -288,7 +288,7 @@ static inline
 struct xnthread *xnthread_lookup(xnhandle_t threadh)
 {
struct xnthread *thread = xnregistry_lookup(threadh, NULL);
-   return thread && thread->handle == threadh ? thread : NULL;
+   return thread && thread->handle == xnhandle_get_index(threadh) ? thread 
: NULL;
 }
 
 static inline void xnthread_sync_window(struct xnthread *thread)
diff --git a/include/cobalt/uapi/kernel/synch.h 
b/include/cobalt/uapi/kernel/synch.h
index 263213a..2a8c40c 100644
--- a/include/cobalt/uapi/kernel/synch.h
+++ b/include/cobalt/uapi/kernel/synch.h
@@ -29,20 +29,26 @@
 #define XNSYNCH_DREORD  0x4
 #define XNSYNCH_OWNER   0x8
 
-#define XNSYNCH_FLCLAIM XN_HANDLE_SPARE3 /* Corresponding bit in fast lock */
+/* Fast lock API */
+static inline int xnsynch_fast_is_claimed(xnhandle_t handle)
+{
+   return (handle & XNSYNCH_FLCLAIM) != 0;
+}
 
-#define xnhandle_mask_spare(handle)  ((handle) & ~XN_HANDLE_SPARE_MASK)
-#define xnhandle_test_spare(handle, bits)  (!!((handle) & (bits)))
-#define xnhandle_set_spare(handle, bits) \
-   do { (handle) |= (bits); } while (0)
-#define xnhandle_clear_spare(handle, bits) \
-   do { (handle) &= ~(bits); } while (0)
+static inline xnhandle_t xnsynch_fast_claimed(xnhandle_t handle)
+{
+   return handle | XNSYNCH_FLCLAIM;
+}
+
+static inline xnhandle_t xnsynch_fast_not_claimed(xnhandle_t handle)
+{
+   return handle & ~XNSYNCH_FLCLAIM;
+}
 
-/* Fast lock API */
 static inline int
 xnsynch_fast_owner_check(atomic_t *fastlock, xnhandle_t ownerh)
 {
-   return (xnhandle_mask_spare(atomic_read(fastlock)) == ownerh) ?
+   return (xnhandle_get_id(atomic_read(fastlock)) == ownerh) ?
0 : -EPERM;
 }
 
@@ -53,7 +59,7 @@ int xnsynch_fast_acquire(atomic_t *fastlock, xnhandle_t 
new_ownerh)
 
h = atomic_cmpxchg(fastlock, XN_NO_HANDLE, new_ownerh);
if (h != XN_NO_HANDLE) {
-   if (xnhandle_mask_spare(h) == new_ownerh)
+   if (xnhandle_get_id(h) == new_ownerh)
return -EBUSY;
 
return -EAGAIN;
diff --git a/include/cobalt/uapi/kernel/types.h 
b/include/cobalt/uapi/kernel/types.h
index 0c86a62..4454536 100644
--- a/include/cobalt/uapi/kernel/types.h
+++ b/include/cobalt/uapi/kernel/types.h
@@ -27,12 +27,30 @@ typedef __s64 xnsticks_t;
 
 typedef __

[Xenomai-git] Philippe Gerum : cobalt/x86: enable x32 (WIP)

2014-09-21 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: 45de86b2b015b331a13de1ef3d3d839d6e6bd93b
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=45de86b2b015b331a13de1ef3d3d839d6e6bd93b

Author: Philippe Gerum 
Date:   Tue Sep  2 19:25:10 2014 +0200

cobalt/x86: enable x32 (WIP)

---

 kernel/cobalt/arch/x86/Kconfig |4 ++
 .../cobalt/arch/x86/include/asm/xenomai/syscall.h  |   12 +++---
 .../arch/x86/include/asm/xenomai/syscall32-table.h |   45 
 .../arch/x86/include/asm/xenomai/syscall32.h   |5 +++
 .../arch/x86/include/asm/xenomai/uapi/syscall.h|   10 -
 5 files changed, 67 insertions(+), 9 deletions(-)

diff --git a/kernel/cobalt/arch/x86/Kconfig b/kernel/cobalt/arch/x86/Kconfig
index c6abcf9..21587b0 100644
--- a/kernel/cobalt/arch/x86/Kconfig
+++ b/kernel/cobalt/arch/x86/Kconfig
@@ -4,5 +4,9 @@ config XENO_HW_FPU
 config XENO_HW_AUTOTUNE
def_bool y
 
+config XENO_HW_X32
+def_bool X86_X32
+   select XENO_OPT_SYS3264
+
 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 beb5674..ddbb3df 100644
--- a/kernel/cobalt/arch/x86/include/asm/xenomai/syscall.h
+++ b/kernel/cobalt/arch/x86/include/asm/xenomai/syscall.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2001,2002,2003,2007 Philippe Gerum .
+ * Copyright (C) 2001-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
@@ -16,7 +16,6 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  * 02111-1307, USA.
  */
-
 #ifndef _COBALT_X86_ASM_SYSCALL_H
 #define _COBALT_X86_ASM_SYSCALL_H
 
@@ -36,16 +35,15 @@
 #define __xn_reg_arg1(regs)   ((regs)->di)
 #define __xn_reg_arg2(regs)   ((regs)->si)
 #define __xn_reg_arg3(regs)   ((regs)->dx)
-#define __xn_reg_arg4(regs)   ((regs)->r10) /* entry.S convention here. */
+#define __xn_reg_arg4(regs)   ((regs)->r10)
 #define __xn_reg_arg5(regs)   ((regs)->r8)
 #endif /* x86_64 */
 #define __xn_reg_pc(regs) ((regs)->ip)
 #define __xn_reg_sp(regs) ((regs)->sp)
 
-#define __xn_syscall_p(regs)  ((__xn_reg_sys(regs) & 0x7fff) == 
cobalt_syscall_tag)
-#define __xn_syscall(regs) ((__xn_reg_sys(regs) >> 24) & 0xff)
-
-#define __xn_syslinux_p(regs, nr)  (__xn_reg_sys(regs) == (nr))
+#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))
 
 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
new file mode 100644
index 000..b7da23b
--- /dev/null
+++ b/kernel/cobalt/arch/x86/include/asm/xenomai/syscall32-table.h
@@ -0,0 +1,45 @@
+/*
+ * 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 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.
+ */
+#ifndef _COBALT_X86_ASM_SYSCALL32_TABLE_H
+#define _COBALT_X86_ASM_SYSCALL32_TABLE_H
+
+/*
+ * CAUTION: This file is read verbatim into the main syscall
+ * 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
+
+#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 7d804e4..b83aaf4 100644
--- a/kernel/cobalt/arch/x86/include/asm/xenomai/syscall32.h
+++ b/kernel/cobalt/arch/x86/include/asm/xenomai/syscall32.h
@@ -24,6 +24,7 @@
 #include 
 
 #define __COBALT_X32_BASE  128
+#define __COBALT_SYSCALL_MASK  __X32_SYSCALL

[Xenomai-git] Philippe Gerum : build: drop /dev/rtheap installation

2014-09-21 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: 6e0a625ee6a3d462aaddd5469c6ba916b1dc8bbe
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=6e0a625ee6a3d462aaddd5469c6ba916b1dc8bbe

Author: Philippe Gerum 
Date:   Wed Sep 10 11:13:09 2014 +0200

build: drop /dev/rtheap installation

---

 Makefile.am |5 +
 Makefile.in |5 +
 2 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 2900cef..7b3c9e7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -67,10 +67,7 @@ echo '*** privileges.' ; \
   if test \! -c $$f ; then \
  $$sudo mknod -m 666 $$f c 150 $$n ; \
   fi ; \
-   done ; \
-   if test \! -c $(DESTDIR)/dev/rtheap ; then \
- $$sudo mknod -m 666 $(DESTDIR)/dev/rtheap c 10 254 ; \
-   fi
+   done
 endif
 
 install-exec-local: devices
diff --git a/Makefile.in b/Makefile.in
index 434ee40..53dc8bc 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -889,10 +889,7 @@ dev devices:
 @XENO_COBALT_TRUE@if test \! -c $$f ; then \
 @XENO_COBALT_TRUE@   $$sudo mknod -m 666 $$f c 150 $$n ; \
 @XENO_COBALT_TRUE@fi ; \
-@XENO_COBALT_TRUE@ done ; \
-@XENO_COBALT_TRUE@ if test \! -c $(DESTDIR)/dev/rtheap ; then \
-@XENO_COBALT_TRUE@   $$sudo mknod -m 666 $(DESTDIR)/dev/rtheap c 10 254 ; \
-@XENO_COBALT_TRUE@ fi
+@XENO_COBALT_TRUE@ done
 
 install-exec-local: devices
 


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


[Xenomai-git] Philippe Gerum : cobalt/tree: abstract key type

2014-09-21 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: 86a5cc0b57d72a37a750cebb758b4733087416b5
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=86a5cc0b57d72a37a750cebb758b4733087416b5

Author: Philippe Gerum 
Date:   Sat Sep 13 17:26:27 2014 +0200

cobalt/tree: abstract key type

---

 include/cobalt/kernel/rtdm/fd.h |5 
 include/cobalt/kernel/tree.h|   23 ++--
 kernel/cobalt/posix/nsem.c  |2 +-
 kernel/cobalt/rtdm/fd.c |   57 ++-
 kernel/cobalt/tree.c|8 +++---
 5 files changed, 46 insertions(+), 49 deletions(-)

diff --git a/include/cobalt/kernel/rtdm/fd.h b/include/cobalt/kernel/rtdm/fd.h
index 4282209..de440cf 100644
--- a/include/cobalt/kernel/rtdm/fd.h
+++ b/include/cobalt/kernel/rtdm/fd.h
@@ -338,11 +338,6 @@ struct rtdm_fd {
struct list_head cleanup;
 };
 
-struct rtdm_fd_index {
-   struct xnid id;
-   struct rtdm_fd *fd;
-};
-
 #define XNFD_MAGIC_ANY 0
 
 static inline struct xnsys_ppd *rtdm_fd_owner(struct rtdm_fd *fd)
diff --git a/include/cobalt/kernel/tree.h b/include/cobalt/kernel/tree.h
index da7738c..9c751cc 100644
--- a/include/cobalt/kernel/tree.h
+++ b/include/cobalt/kernel/tree.h
@@ -22,8 +22,15 @@
 #include 
 #include 
 
+typedef unsigned long long xnkey_t;
+
+static inline xnkey_t PTR_KEY(void *p)
+{
+   return (xnkey_t)(long)p;
+}
+
 struct xnid {
-   unsigned long long id;
+   xnkey_t key;
struct rb_node link;
 };
 
@@ -48,24 +55,24 @@ static inline void xntree_init(struct rb_root *t)
 void xntree_cleanup(struct rb_root *t, void *cookie,
void (*destroy)(void *cookie, struct xnid *id));
 
-int xnid_enter(struct rb_root *t, struct xnid *xnid, unsigned long long id);
+int xnid_enter(struct rb_root *t, struct xnid *xnid, xnkey_t key);
 
-static inline unsigned long long xnid_id(struct xnid *i)
+static inline xnkey_t xnid_key(struct xnid *i)
 {
-   return i->id;
+   return i->key;
 }
 
 static inline
-struct xnid *xnid_fetch(struct rb_root *t, unsigned long long id)
+struct xnid *xnid_fetch(struct rb_root *t, xnkey_t key)
 {
struct rb_node *node = t->rb_node;
 
while (node) {
struct xnid *i = container_of(node, struct xnid, link);
 
-   if (id < i->id)
+   if (key < i->key)
node = node->rb_left;
-   else if (id > i->id)
+   else if (key > i->key)
node = node->rb_right;
else
return i;
@@ -77,7 +84,7 @@ struct xnid *xnid_fetch(struct rb_root *t, unsigned long long 
id)
 static inline int xnid_remove(struct rb_root *t, struct xnid *xnid)
 {
 #if XENO_DEBUG(COBALT)
-   if (xnid_fetch(t, xnid->id) != xnid)
+   if (xnid_fetch(t, xnid->key) != xnid)
return -ENOENT;
 #endif
rb_erase(&xnid->link, t);
diff --git a/kernel/cobalt/posix/nsem.c b/kernel/cobalt/posix/nsem.c
index 6d613fb..aa6af60 100644
--- a/kernel/cobalt/posix/nsem.c
+++ b/kernel/cobalt/posix/nsem.c
@@ -279,7 +279,7 @@ static void cleanup_named_sems(void *cookie, struct xnid *i)
cc = cookie;
u = container_of(i, struct named_sem, id);
u->refs = 1;
-   sem_close(cc, xnid_id(i));
+   sem_close(cc, xnid_key(i));
 }
 
 void cobalt_sem_usems_cleanup(struct cobalt_process *cc)
diff --git a/kernel/cobalt/rtdm/fd.c b/kernel/cobalt/rtdm/fd.c
index 655a5e7..9a7bb8c 100644
--- a/kernel/cobalt/rtdm/fd.c
+++ b/kernel/cobalt/rtdm/fd.c
@@ -29,12 +29,17 @@
 #include 
 #include 
 #include "internal.h"
-#include "../posix/process.h"
+#include "posix/process.h"
 
 DEFINE_PRIVATE_XNLOCK(__rtdm_fd_lock);
 static LIST_HEAD(rtdm_fd_cleanup_queue);
 static struct semaphore rtdm_fd_cleanup_sem;
 
+struct rtdm_fd_index {
+   struct xnid id;
+   struct rtdm_fd *fd;
+};
+
 static int enosys(void)
 {
return -ENOSYS;
@@ -50,7 +55,7 @@ static void nop_close(struct rtdm_fd *fd)
 }
 
 static inline struct rtdm_fd_index *
-rtdm_fd_index_fetch(struct xnsys_ppd *p, int ufd)
+fetch_fd_index(struct xnsys_ppd *p, int ufd)
 {
struct xnid *id = xnid_fetch(&p->fds, ufd);
if (id == NULL)
@@ -59,9 +64,9 @@ rtdm_fd_index_fetch(struct xnsys_ppd *p, int ufd)
return container_of(id, struct rtdm_fd_index, id);
 }
 
-static struct rtdm_fd *rtdm_fd_fetch(struct xnsys_ppd *p, int ufd)
+static struct rtdm_fd *fetch_fd(struct xnsys_ppd *p, int ufd)
 {
-   struct rtdm_fd_index *idx = rtdm_fd_index_fetch(p, ufd);
+   struct rtdm_fd_index *idx = fetch_fd_index(p, ufd);
if (idx == NULL)
return NULL;
 
@@ -173,7 +178,7 @@ struct rtdm_fd *rtdm_fd_get(struct xnsys_ppd *p, int ufd, 
unsigned int magic)
spl_t s;
 
xnlock_get_irqsave(&__rtdm_fd_lock, s);
-   res = rtdm_fd_fetch(p, ufd);
+   res = fetch_fd(p, ufd);
if (res == NULL || (magic != XNFD_MAGIC_ANY && res->magic != magic)) {
res = ERR_PTR(-

[Xenomai-git] Philippe Gerum : cobalt/posix/memory: omit empty .open/ .close handlers in memdev

2014-09-21 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: 6247f95e2f8d458148358e6b22939327ad97d27b
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=6247f95e2f8d458148358e6b22939327ad97d27b

Author: Philippe Gerum 
Date:   Tue Sep  9 17:49:06 2014 +0200

cobalt/posix/memory: omit empty .open/.close handlers in memdev

---

 kernel/cobalt/posix/memory.c |   14 --
 1 file changed, 14 deletions(-)

diff --git a/kernel/cobalt/posix/memory.c b/kernel/cobalt/posix/memory.c
index 06422ef..126b8c7 100644
--- a/kernel/cobalt/posix/memory.c
+++ b/kernel/cobalt/posix/memory.c
@@ -38,13 +38,6 @@ static struct rtdm_device private_umm_device;
 
 static struct rtdm_device shared_umm_device;
 
-static int umm_open(struct rtdm_fd *fd, int oflags)
-{
-   return 0;
-}
-
-static void umm_close(struct rtdm_fd *fd) { }
-
 static void umm_vmopen(struct vm_area_struct *vma)
 {
struct cobalt_umm *umm = vma->vm_private_data;
@@ -161,8 +154,6 @@ static int sysmem_open(struct rtdm_fd *fd, int oflags)
return 0;
 }
 
-static void sysmem_close(struct rtdm_fd *fd) { }
-
 static int do_sysmem_ioctls(struct rtdm_fd *fd,
unsigned int request, void __user *arg)
 {
@@ -202,11 +193,9 @@ static struct rtdm_device private_umm_device = {
.device_flags   =   RTDM_NAMED_DEVICE,
.context_size   =   0,
.ops = {
-   .open   =   umm_open,
.ioctl_rt   =   umm_ioctl_rt,
.ioctl_nrt  =   umm_ioctl_nrt,
.mmap   =   umm_mmap,
-   .close  =   umm_close,
},
.device_class   =   RTDM_CLASS_MEMORY,
.device_sub_class   =   UMM_PRIVATE,
@@ -223,11 +212,9 @@ static struct rtdm_device shared_umm_device = {
.device_flags   =   RTDM_NAMED_DEVICE,
.context_size   =   0,
.ops = {
-   .open   =   umm_open,
.ioctl_rt   =   umm_ioctl_rt,
.ioctl_nrt  =   umm_ioctl_nrt,
.mmap   =   umm_mmap,
-   .close  =   umm_close,
},
.device_class   =   RTDM_CLASS_MEMORY,
.device_sub_class   =   UMM_SHARED,
@@ -247,7 +234,6 @@ static struct rtdm_device sysmem_device = {
.open   =   sysmem_open,
.ioctl_rt   =   sysmem_ioctl_rt,
.ioctl_nrt  =   sysmem_ioctl_nrt,
-   .close  =   sysmem_close,
},
.device_class   =   RTDM_CLASS_MEMORY,
.device_sub_class   =   SYS_GLOBAL,


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


[Xenomai-git] Philippe Gerum : cobalt/kernel/cond, lib/cobalt: put shadow condvar descriptor on a diet

2014-09-21 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: 4ddc7edd37291c19dd943dd3dc32426162f8702b
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=4ddc7edd37291c19dd943dd3dc32426162f8702b

Author: Philippe Gerum 
Date:   Thu Sep 11 12:35:51 2014 +0200

cobalt/kernel/cond, lib/cobalt: put shadow condvar descriptor on a diet

As we overlay the native pthread_cond_t type, our shadow structure for
the condition variable descriptor (cobalt_cond_shadow) must not exceed
the latter in size, which currently happens with linuxthreads.

This patch shrinks the condvar shadow structure down to 12 bytes on
32bit systems, which meets the requirement.

---

 include/cobalt/uapi/cond.h |   17 +++---
 include/cobalt/uapi/kernel/synch.h |6 ++
 include/cobalt/uapi/kernel/types.h |5 +-
 kernel/cobalt/posix/cond.c |  106 -
 kernel/cobalt/posix/cond.h |2 +-
 lib/cobalt/cond.c  |  115 
 6 files changed, 136 insertions(+), 115 deletions(-)

diff --git a/include/cobalt/uapi/cond.h b/include/cobalt/uapi/cond.h
index cea0737..a6ff148 100644
--- a/include/cobalt/uapi/cond.h
+++ b/include/cobalt/uapi/cond.h
@@ -22,19 +22,22 @@
 
 #define COBALT_COND_MAGIC 0x86860505
 
+struct cobalt_cond_state {
+   __u32 pending_signals;
+   union {
+   __u32 mutex_datp_offset;
+   struct mutex_dat *mutex_datp;
+   };
+};
+
 union cobalt_cond_union {
pthread_cond_t native_cond;
struct cobalt_cond_shadow {
__u32 magic;
-   struct cobalt_condattr attr;
xnhandle_t handle;
union {
-   __u32 pending_signals_offset;
-   __u32 *pending_signals;
-   };
-   union {
-   __u32 mutex_datp_offset;
-   struct mutex_dat *mutex_datp;
+   __u32 state_offset;
+   struct cobalt_cond_state *state;
};
} shadow_cond;
 };
diff --git a/include/cobalt/uapi/kernel/synch.h 
b/include/cobalt/uapi/kernel/synch.h
index 2a8c40c..6947058 100644
--- a/include/cobalt/uapi/kernel/synch.h
+++ b/include/cobalt/uapi/kernel/synch.h
@@ -75,4 +75,10 @@ int xnsynch_fast_release(atomic_t *fastlock, xnhandle_t 
cur_ownerh)
== cur_ownerh;
 }
 
+/* Local/shared property */
+static inline int xnsynch_is_shared(xnhandle_t handle)
+{
+   return (handle & XNSYNCH_PSHARED) != 0;
+}
+
 #endif /* !_COBALT_UAPI_KERNEL_SYNCH_H */
diff --git a/include/cobalt/uapi/kernel/types.h 
b/include/cobalt/uapi/kernel/types.h
index 4454536..6064249 100644
--- a/include/cobalt/uapi/kernel/types.h
+++ b/include/cobalt/uapi/kernel/types.h
@@ -30,7 +30,10 @@ typedef __u32 xnhandle_t;
 #define XN_NO_HANDLE   ((xnhandle_t)0)
 #define XN_HANDLE_INDEX_MASK   ((xnhandle_t)0xf000)
 
-/* 3 spare special bits remaining. */
+/* Fixed bits (part of the identifier) */
+#define XNSYNCH_PSHARED((xnhandle_t)0x4000)
+
+/* Transient bits (expressing a status) */
 #define XNSYNCH_FLCLAIM((xnhandle_t)0x8000)
 
 #define XN_HANDLE_TRANSIENT_MASK   XNSYNCH_FLCLAIM
diff --git a/kernel/cobalt/posix/cond.c b/kernel/cobalt/posix/cond.c
index 4127f59..0e91f29 100644
--- a/kernel/cobalt/posix/cond.c
+++ b/kernel/cobalt/posix/cond.c
@@ -37,24 +37,27 @@ cond_destroy_internal(xnhandle_t handle, struct 
cobalt_kqueues *q)
}
xnregistry_remove(handle);
list_del(&cond->link);
-   /* synchbase wait queue may not be empty only when this function is
-  called from cobalt_cond_pkg_cleanup, hence the absence of
-  xnsched_run(). */
+   /*
+* synchbase wait queue may not be empty only when this
+* function is called from cobalt_cond_pkg_cleanup, in which
+* case we don't have to reschedule.
+*/
xnsynch_destroy(&cond->synchbase);
cobalt_mark_deleted(cond);
xnlock_put_irqrestore(&nklock, s);
cobalt_umm_free(&cobalt_ppd_get(cond->attr.pshared)->umm,
-   cond->pending_signals);
+   cond->state);
xnfree(cond);
 }
 
 static inline int
 pthread_cond_init(struct cobalt_cond_shadow *cnd, const struct cobalt_condattr 
*attr)
 {
-   int synch_flags = XNSYNCH_PRIO | XNSYNCH_NOPIP, err;
+   int synch_flags = XNSYNCH_PRIO | XNSYNCH_NOPIP, ret;
struct cobalt_cond *cond, *old_cond;
-   struct list_head *condq;
+   struct cobalt_cond_state *state;
struct xnsys_ppd *sys_ppd;
+   struct list_head *condq;
spl_t s;
 
cond = xnmalloc(sizeof(*cond));
@@ -62,13 +65,14 @@ pthread_cond_init(struct cobalt_cond_shadow *cnd, const 
struct cobalt_condattr *
return -ENOMEM;
 
sys_ppd = cobalt_ppd_get(attr->pshared);
-   cond->pending_signals = cobalt_umm_alloc(&sys_ppd->umm,
-   

[Xenomai-git] Philippe Gerum : cobalt/kernel: drop module information from purely static parts

2014-09-21 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: 74a9ffb904428e2fe230f072b65752842f1ef8ca
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=74a9ffb904428e2fe230f072b65752842f1ef8ca

Author: Philippe Gerum 
Date:   Wed Sep 10 11:54:13 2014 +0200

cobalt/kernel: drop module information from purely static parts

---

 kernel/cobalt/init.c   |3 ---
 kernel/cobalt/posix/init.c |4 
 kernel/cobalt/rtdm/init.c  |4 
 3 files changed, 11 deletions(-)

diff --git a/kernel/cobalt/init.c b/kernel/cobalt/init.c
index e729b11..aaefabb 100644
--- a/kernel/cobalt/init.c
+++ b/kernel/cobalt/init.c
@@ -46,9 +46,6 @@
  * Cobalt provides an implementation of the POSIX and RTDM interfaces
  * based on a set of generic RTOS building blocks.
  */
-MODULE_DESCRIPTION("Cobalt kernel");
-MODULE_AUTHOR("r...@xenomai.org");
-MODULE_LICENSE("GPL");
 
 static unsigned long timerfreq_arg;
 module_param_named(timerfreq, timerfreq_arg, ulong, 0444);
diff --git a/kernel/cobalt/posix/init.c b/kernel/cobalt/posix/init.c
index 33da67a..e97f96f 100644
--- a/kernel/cobalt/posix/init.c
+++ b/kernel/cobalt/posix/init.c
@@ -30,10 +30,6 @@
 #include "monitor.h"
 #include "event.h"
 
-MODULE_DESCRIPTION("Xenomai/cobalt POSIX interface");
-MODULE_AUTHOR("gilles.chanteperd...@xenomai.org");
-MODULE_LICENSE("GPL");
-
 struct cobalt_kqueues cobalt_global_kqueues;
 
 void cobalt_cleanup(void)
diff --git a/kernel/cobalt/rtdm/init.c b/kernel/cobalt/rtdm/init.c
index 140e313..50cb4ad 100644
--- a/kernel/cobalt/rtdm/init.c
+++ b/kernel/cobalt/rtdm/init.c
@@ -34,10 +34,6 @@
  * to extend a device profile with more hardware-specific functions.
  */
 
-MODULE_DESCRIPTION("Real-Time Driver Model");
-MODULE_AUTHOR("jan.kis...@web.de");
-MODULE_LICENSE("GPL");
-
 void rtdm_cleanup(void)
 {
rtdm_proc_cleanup();


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


[Xenomai-git] Philippe Gerum : testsuite/smokey: cope with missing fork() in fork-exec test

2014-09-21 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: 91b7e10e380d65f1afb68a4262435a03de05f3ab
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=91b7e10e380d65f1afb68a4262435a03de05f3ab

Author: Philippe Gerum 
Date:   Thu Sep 11 08:55:19 2014 +0200

testsuite/smokey: cope with missing fork() in fork-exec test

We still use fork() when present, in order to check for
the several pthread_atfork() handlers we have in libcobalt.

---

 testsuite/smokey/fork-exec/fork-exec.c |   14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/testsuite/smokey/fork-exec/fork-exec.c 
b/testsuite/smokey/fork-exec/fork-exec.c
index 5e620da..79fe234 100644
--- a/testsuite/smokey/fork-exec/fork-exec.c
+++ b/testsuite/smokey/fork-exec/fork-exec.c
@@ -19,6 +19,12 @@ smokey_test_plugin(fork_exec,
   "Check fork->exec sequence."
 );
 
+#ifdef HAVE_FORK
+#define do_fork fork
+#else
+#define do_fork vfork
+#endif
+
 /*
  * The purpose of this test is to check whether Cobalt detects and
  * handles a fork->exec sequence properly for Xenomai-enabled threads,
@@ -33,13 +39,9 @@ static int run_fork_exec(struct smokey_test *t, int argc, 
char *const argv[])
 {
struct timespec req;
 
-   switch (fork()) {
+   switch (do_fork()) {
case -1:
-   if (errno == ENOSYS) {
-   smokey_note("fork() not available -- discarding test");
-   return 0;
-   }
-   error(1, errno, "fork");
+   error(1, errno, "fork/vfork");
case 0:
/*
 * Re-exec ourselves without running any test, this is


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


[Xenomai-git] Philippe Gerum : cobalt/rtdm/fd: assume current context is target for all fd ops

2014-09-21 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: 41374b4f946c4b55760d66ab1f6d0ae8d59f45b9
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=41374b4f946c4b55760d66ab1f6d0ae8d59f45b9

Author: Philippe Gerum 
Date:   Fri Sep 19 18:14:37 2014 +0200

cobalt/rtdm/fd: assume current context is target for all fd ops

Except in the only weird case of forcing a close on any random
kernel-originated connection through the procfs interface
(open_fildes), but this case is on its way out.

For the sake of mental sanity, we really want to assume that only the
current thread may affect its own file table, which is what this patch
enforces.

The rtdm_fd cleanup thread is a non-issue, as we are not supposed to
run any fd ops recursively on behalf of a ->close() handler anyway.

This change also fixes a rampant inconsistency where a Cobalt user
thread running some driver code would actually look up into the wrong
RTDM file table when using the rt_dev_* interface
(i.e. __xnsys_global_ppd would not be the right context in such a
case).

---

 include/cobalt/kernel/rtdm/fd.h   |   32 +--
 include/cobalt/kernel/rtdm/rtdm.h |   12 +++
 kernel/cobalt/posix/io.c  |   14 -
 kernel/cobalt/posix/mqueue.c  |   12 +++
 kernel/cobalt/posix/timerfd.c |5 ++-
 kernel/cobalt/rtdm/core.c |   22 +++--
 kernel/cobalt/rtdm/fd.c   |   63 ++---
 kernel/cobalt/rtdm/proc.c |8 +++--
 8 files changed, 85 insertions(+), 83 deletions(-)

diff --git a/include/cobalt/kernel/rtdm/fd.h b/include/cobalt/kernel/rtdm/fd.h
index 6b50cef..d4a97b2 100644
--- a/include/cobalt/kernel/rtdm/fd.h
+++ b/include/cobalt/kernel/rtdm/fd.h
@@ -296,7 +296,7 @@ struct rtdm_fd_ops {
 struct rtdm_fd {
unsigned int magic;
struct rtdm_fd_ops *ops;
-   struct xnsys_ppd *cont;
+   struct xnsys_ppd *owner;
unsigned int refs;
int minor;
struct list_head cleanup;
@@ -306,7 +306,7 @@ struct rtdm_fd {
 
 static inline struct xnsys_ppd *rtdm_fd_owner(struct rtdm_fd *fd)
 {
-   return fd->cont;
+   return fd->owner;
 }
 
 static inline int rtdm_fd_minor(struct rtdm_fd *fd)
@@ -314,11 +314,10 @@ static inline int rtdm_fd_minor(struct rtdm_fd *fd)
return fd->minor;
 }
 
-int rtdm_fd_enter(struct xnsys_ppd *p, struct rtdm_fd *rtdm_fd, int ufd,
+int rtdm_fd_enter(struct rtdm_fd *rtdm_fd, int ufd,
  unsigned int magic, struct rtdm_fd_ops *ops);
 
-struct rtdm_fd *rtdm_fd_get(struct xnsys_ppd *p,
-   int ufd, unsigned int magic);
+struct rtdm_fd *rtdm_fd_get(int ufd, unsigned int magic);
 
 int rtdm_fd_lock(struct rtdm_fd *fd);
 
@@ -326,24 +325,23 @@ void rtdm_fd_put(struct rtdm_fd *fd);
 
 void rtdm_fd_unlock(struct rtdm_fd *fd);
 
-int rtdm_fd_ioctl(struct xnsys_ppd *p, int ufd, unsigned int request, ...);
+int rtdm_fd_ioctl(int ufd, unsigned int request, ...);
 
-ssize_t rtdm_fd_read(struct xnsys_ppd *p, int ufd,
-void __user *buf, size_t size);
+ssize_t rtdm_fd_read(int ufd, void __user *buf, size_t size);
 
-ssize_t rtdm_fd_write(struct xnsys_ppd *p, int ufd,
- const void __user *buf, size_t size);
+ssize_t rtdm_fd_write(int ufd, const void __user *buf, size_t size);
 
-int rtdm_fd_close(struct xnsys_ppd *p, int ufd, unsigned int magic);
+int __rtdm_fd_close(struct xnsys_ppd *ppd,
+   int ufd, unsigned int magic);
 
-ssize_t rtdm_fd_recvmsg(struct xnsys_ppd *p, int ufd,
-   struct msghdr *msg, int flags);
+int rtdm_fd_close(int ufd, unsigned int magic);
 
-ssize_t rtdm_fd_sendmsg(struct xnsys_ppd *p, int ufd,
-   const struct msghdr *msg, int flags);
+ssize_t rtdm_fd_recvmsg(int ufd, struct msghdr *msg, int flags);
 
-int rtdm_fd_mmap(struct xnsys_ppd *p, int ufd,
-struct _rtdm_mmap_request *rma,
+ssize_t rtdm_fd_sendmsg(int ufd, const struct msghdr *msg,
+   int flags);
+
+int rtdm_fd_mmap(int ufd, struct _rtdm_mmap_request *rma,
 void * __user *u_addrp);
 
 int rtdm_fd_valid_p(int ufd);
diff --git a/include/cobalt/kernel/rtdm/rtdm.h 
b/include/cobalt/kernel/rtdm/rtdm.h
index 98f0d3a..b1ffab3 100644
--- a/include/cobalt/kernel/rtdm/rtdm.h
+++ b/include/cobalt/kernel/rtdm/rtdm.h
@@ -53,22 +53,22 @@ __rt_dev_ioctl_fallback(struct rtdm_fd *fd, unsigned 
request, void __user *arg);
__rtdm_dev_ksocket(protocol_family, socket_type, protocol)
 
 #define rt_dev_close(fd)   \
-   rtdm_fd_close(&__xnsys_global_ppd, fd, RTDM_FD_MAGIC)
+   rtdm_fd_close(fd, RTDM_FD_MAGIC)
 
 #define rt_dev_ioctl(fd, request, ...) \
-   rtdm_fd_ioctl(&__xnsys_global_ppd, fd, request, __VA_ARGS__)
+   rtdm_fd_ioctl(fd, request, __VA_ARGS__)
 
 #define rt_dev_read(fd, buf, nbyte)\
-   rtdm_fd_read(&__xnsys_global_ppd, fd, buf, nbyte

[Xenomai-git] Philippe Gerum : cobalt/rtdm, lib/cobalt: open named device on allocated devnode

2014-09-21 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: 058ac4537d6e237504ad2df4cc4c22392387ee93
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=058ac4537d6e237504ad2df4cc4c22392387ee93

Author: Philippe Gerum 
Date:   Wed Sep 17 16:40:21 2014 +0200

cobalt/rtdm, lib/cobalt: open named device on allocated devnode

Now that named devices exist in the linux namespace (/dev/rtdm), file
descriptors can be obtained on the associated chrdev, instead of the
anon inode.

With this change, active connections to RTDM named devices are visible
from /proc//fd.

---

 kernel/cobalt/posix/io.c   |   51 ++--
 kernel/cobalt/rtdm/core.c  |6 +
 kernel/cobalt/rtdm/device.c|   13 +
 kernel/cobalt/rtdm/internal.h  |2 ++
 kernel/drivers/testing/rtdmtest.c  |2 +-
 lib/cobalt/umm.c   |4 ++-
 testsuite/latency/latency.c|7 ++---
 testsuite/regression/posix/leaks.c |8 +++---
 testsuite/smokey/rtdm/rtdm.c   |4 +--
 testsuite/switchtest/switchtest.c  |8 +++---
 utils/autotune/autotune.c  |2 +-
 11 files changed, 79 insertions(+), 28 deletions(-)

diff --git a/kernel/cobalt/posix/io.c b/kernel/cobalt/posix/io.c
index 9810c32..d6d5dc3 100644
--- a/kernel/cobalt/posix/io.c
+++ b/kernel/cobalt/posix/io.c
@@ -32,20 +32,55 @@
 COBALT_SYSCALL(open, lostage,
   int, (const char __user *u_path, int oflag))
 {
-   char path[RTDM_MAX_DEVNAME_LEN + 1];
+   struct rtdm_device *device;
+   struct filename *filename;
struct xnsys_ppd *ppd;
+   struct file *filp;
int ufd, ret;
 
-   if (__xn_safe_strncpy_from_user(path, u_path, sizeof(path)-1) < 0)
-   return -EFAULT;
+   filename = getname(u_path);
+   if (IS_ERR(filename))
+   return PTR_ERR(filename);
+
+   /*
+* Lookup for the device into the RTDM registry: if we don't
+* own the device, tell userland to forward to the regular
+* open() service.
+*/
+   device = __rtdm_get_namedev(filename->name);
+   if (device == NULL) {
+   ret = -ENODEV;
+   goto fail_lookup;
+   }
 
-   path[sizeof(path)-1] = '\0';
-   ppd = cobalt_ppd_get(0);
-   ufd = anon_inode_getfd("[rtdm-named]", &rtdm_dumb_fops, ppd, oflag);
+   ufd = get_unused_fd_flags(oflag);
+   if (ufd < 0) {
+   ret = ufd;
+   goto fail_ufd;
+   }
 
-   ret = __rt_dev_open(ppd, ufd, path, oflag);
+   filp = filp_open(filename->name, oflag, 0);
+   if (IS_ERR(filp)) {
+   ret = PTR_ERR(filp);
+   goto fail;
+   }
+
+   ppd = cobalt_ppd_get(0);
+   ret = __rt_dev_open(ppd, ufd, filename->name, oflag);
if (ret < 0)
-   __close_fd(current->files, ufd);
+   goto fail;
+
+   rtdm_dereference_device(device);
+   fd_install(ufd, filp);
+   putname(filename);
+
+   return ufd;
+fail:
+   put_unused_fd(ufd);
+fail_ufd:
+   rtdm_dereference_device(device);
+fail_lookup:
+   putname(filename);
 
return ret;
 }
diff --git a/kernel/cobalt/rtdm/core.c b/kernel/cobalt/rtdm/core.c
index 56ecbaa..d46e7a0 100644
--- a/kernel/cobalt/rtdm/core.c
+++ b/kernel/cobalt/rtdm/core.c
@@ -155,11 +155,7 @@ int __rt_dev_open(struct xnsys_ppd *p, int ufd, const char 
*path, int oflag)
struct rtdm_device *device;
int ret, minor;
 
-   /* skip common /dev prefix */
-   if (strncmp(path, "/dev/", 5) == 0)
-   path += 5;
-
-   device = __rtdm_get_named_device(path, &minor);
+   device = __rtdm_get_namedev(path);
if (device == NULL)
return -ENODEV;
 
diff --git a/kernel/cobalt/rtdm/device.c b/kernel/cobalt/rtdm/device.c
index 4727d67..bbe5be0 100644
--- a/kernel/cobalt/rtdm/device.c
+++ b/kernel/cobalt/rtdm/device.c
@@ -142,6 +142,19 @@ __rtdm_get_protocol_device(int protocol_family, int 
socket_type)
return device;
 }
 
+struct rtdm_device *__rtdm_get_namedev(const char *path)
+{
+   /* skip common /dev prefix */
+   if (strncmp(path, "/dev/", 5) == 0)
+   path += 5;
+
+   /* skip RTDM devnode root */
+   if (strncmp(path, "rtdm/", 5) == 0)
+   path += 5;
+
+   return __rtdm_get_named_device(path);
+}
+
 /**
  * @ingroup rtdm_driver_interface
  * @defgroup rtdm_device_register Device Registration Services
diff --git a/kernel/cobalt/rtdm/internal.h b/kernel/cobalt/rtdm/internal.h
index 985e01f..f6ab158 100644
--- a/kernel/cobalt/rtdm/internal.h
+++ b/kernel/cobalt/rtdm/internal.h
@@ -77,6 +77,8 @@ void __rt_dev_unref(struct rtdm_fd *fd, unsigned int idx);
 int __rtdm_mmap_from_fdop(struct rtdm_fd *fd, size_t len, off_t offset,
  int prot, int flags, void *__user *pptr);
 
+struct rtdm_device *__rtdm_get_namedev(const char *path);
+
 int rtdm_init(void);
 
 void rtdm_cleanup(void);
diff 

[Xenomai-git] Philippe Gerum : cobalt/sched: drop unreachable code path

2014-09-21 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: 4c53d3d037842d6486d8023f43e74018d9c587bb
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=4c53d3d037842d6486d8023f43e74018d9c587bb

Author: Philippe Gerum 
Date:   Fri Sep 19 12:15:02 2014 +0200

cobalt/sched: drop unreachable code path

As deletion requests are now advisory, and will trigger a full relax
from the victim before it invokes do_exit() all by itself, we just
can't schedule in with a NULL shadow extension.

i.e. thread_info->thread is cleared from the task_exit handler, which
is invoked indirectly from do_exit().

Replace this useless code with a debug assertion.

---

 kernel/cobalt/sched.c |   26 +-
 1 file changed, 5 insertions(+), 21 deletions(-)

diff --git a/kernel/cobalt/sched.c b/kernel/cobalt/sched.c
index 19e3f71..465fe52 100644
--- a/kernel/cobalt/sched.c
+++ b/kernel/cobalt/sched.c
@@ -859,14 +859,9 @@ reschedule:
 
/*
 * Test whether we transitioned from primary mode to secondary
-* over a shadow thread. This may happen in two cases:
-*
-* 1) the shadow thread just relaxed.
-* 2) the shadow TCB has just been deleted, in which case
-* we have to reap the mated Linux side as well.
-*
-* In both cases, we are running over the epilogue of Linux's
-* schedule, and should skip our epilogue code.
+* over a shadow thread, caused by a call to xnthread_relax().
+* In such a case, we are running over the regular schedule()
+* tail code, so we have to skip our tail code.
 */
if (shadow && ipipe_root_p)
goto shadow_epilogue;
@@ -880,7 +875,6 @@ reschedule:
curr = sched->curr;
xnthread_switch_fpu(sched);
xntrace_pid(current->pid, xnthread_current_priority(curr));
-
 out:
if (switched &&
xnsched_maybe_resched_after_unlocked_switch(sched))
@@ -894,19 +888,9 @@ out:
return switched;
 
 shadow_epilogue:
-
__ipipe_complete_domain_migration();
-   /*
-* Shadow on entry and root without shadow extension on exit?
-* Mmmm... This must be the user-space mate of a deleted
-* real-time shadow we've just rescheduled in the Linux domain
-* to have it exit properly.  Reap it now.
-*/
-   if (xnthread_current() == NULL) {
-   splnone();
-   __ipipe_reenter_root();
-   do_exit(0);
-   }
+
+   XENO_BUGON(COBALT, xnthread_current() == NULL);
 
/*
 * Interrupts must be disabled here (has to be done on entry


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


[Xenomai-git] Philippe Gerum : lib/smokey: fix glob matching for tests

2014-09-21 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: c657ab5a5588c483a1215a38c4af7f0e3c80eb83
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=c657ab5a5588c483a1215a38c4af7f0e3c80eb83

Author: Philippe Gerum 
Date:   Wed Sep 10 09:43:28 2014 +0200

lib/smokey: fix glob matching for tests

---

 lib/smokey/init.c |   25 +
 1 file changed, 25 insertions(+)

diff --git a/lib/smokey/init.c b/lib/smokey/init.c
index 965bef5..a77d420 100644
--- a/lib/smokey/init.c
+++ b/lib/smokey/init.c
@@ -333,6 +333,25 @@ static int resolve_id(const char *s)
return -1;
 }
 
+static int glob_match(const char *s)
+{
+   struct smokey_test *t, *tmp;
+   int matches = 0;
+
+   if (pvlist_empty(®ister_list))
+   return 0;
+
+   pvlist_for_each_entry_safe(t, tmp, ®ister_list, __reserved.next) {
+   if (!fnmatch(s, t->name, FNM_PATHNAME)) {
+   pvlist_remove(&t->__reserved.next);
+   pvlist_append(&t->__reserved.next, &smokey_test_list);
+   matches++;
+   }
+   }
+
+   return matches;
+}
+
 static int build_test_list(const char *test_enum)
 {
char *s = strdup(test_enum), *n, *range, *range_p = NULL, *id, *id_r;
@@ -347,6 +366,12 @@ static int build_test_list(const char *test_enum)
end = test_count - 1;
id = strtok_r(range, "-", &id_r);
if (id) {
+   if (glob_match(id)) {
+   if (strtok_r(NULL, "-", &id_r))
+   goto fail;
+   n = NULL;
+   continue;
+   }
start = resolve_id(id);
if (*range == '-') {
end = start;


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


[Xenomai-git] Philippe Gerum : cobalt/rtdm, kernel/drivers: split device class / instance abstractions

2014-09-21 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: 1909729e00dd8d89f084f67ae654daa06b141750
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=1909729e00dd8d89f084f67ae654daa06b141750

Author: Philippe Gerum 
Date:   Sun Sep 14 18:52:18 2014 +0200

cobalt/rtdm, kernel/drivers: split device class / instance abstractions

How devices are described for registration with rtdm_dev_register() is
significantly modified, affecting both named and protocol device
drivers exactly the same way. Aside of fixing consistency issues, the
bulk of changes is aimed at narrowing the gap between the regular
Linux device driver model and RTDM.

RTDM now shares the Linux namespace for named devices, which are
backed by common character device objects from the regular Linux
device model. As a consequence of this, file descriptors obtained on
named RTDM devices are regular file descriptors on real chrdevs,
visible from the /proc//fd interface.

The major change required for supporting this closer integration of
RTDM into the regular Linux driver model involved splitting the device
class properties from the device instance definitions, which used to
be combined in Xenomai 2.x into the rtdm_device descriptor.

A new rtdm_device_class descriptor is introduced, for describing the
general static properties of the devices exposed by a
driver. rtdm_device now represents an instance of such class.

rtdm_device objects link to the descriptor of the rtdm_device class
they belong to.

Hotplug support
---

RTDM first allocates and reserves a major and a range of device minors
when the first device of a named device class is registered via
rtdm_dev_register(). Up to class->device_count minors will be
reserved. Minor number are assigned to devices in order of
registration, starting from minor #0.

Device nodes for named RTDM devices are automatically visible from the
/dev/rtdm/ hierarchy with hotplug-enabled device fs (DEVTMPFS now
recommended).

---

 include/cobalt/kernel/rtdm/analogy/context.h |2 +-
 include/cobalt/kernel/rtdm/driver.h  |  202 ++--
 include/cobalt/kernel/rtdm/udd.h |   11 +-
 kernel/cobalt/posix/io.c |   43 
 kernel/cobalt/posix/memory.c |   63 +++--
 kernel/cobalt/rtdm/core.c|   43 ++--
 kernel/cobalt/rtdm/device.c  |  318 +-
 kernel/cobalt/rtdm/drvlib.c  |   10 +-
 kernel/cobalt/rtdm/fd.c  |   43 
 kernel/cobalt/rtdm/internal.h|2 +-
 kernel/cobalt/rtdm/proc.c|   68 +++---
 kernel/cobalt/trace/cobalt-rtdm.h|   24 +-
 kernel/drivers/analogy/rtdm_interface.c  |   76 +++---
 kernel/drivers/autotune/autotune.c   |   17 +-
 kernel/drivers/can/rtcan_raw.c   |   21 +-
 kernel/drivers/ipc/rtipc.c   |   28 ++-
 kernel/drivers/serial/16550A.c   |   40 ++--
 kernel/drivers/serial/Kconfig|2 +-
 kernel/drivers/serial/mpc52xx_uart.c |   59 +++--
 kernel/drivers/serial/rt_imx_uart.c  |   28 +--
 kernel/drivers/testing/rtdmtest.c|   63 +++--
 kernel/drivers/testing/switchtest.c  |   58 +++--
 kernel/drivers/testing/timerbench.c  |   60 +++--
 kernel/drivers/udd/udd.c |   86 +++
 24 files changed, 789 insertions(+), 578 deletions(-)

diff --git a/include/cobalt/kernel/rtdm/analogy/context.h 
b/include/cobalt/kernel/rtdm/analogy/context.h
index 35d356d..71a292c 100644
--- a/include/cobalt/kernel/rtdm/analogy/context.h
+++ b/include/cobalt/kernel/rtdm/analogy/context.h
@@ -43,7 +43,7 @@ static inline int a4l_get_minor(struct a4l_device_context 
*cxt)
/* Get a pointer on the container structure */
struct rtdm_fd *fd = rtdm_private_to_fd(cxt);
/* Get the minor index */
-   return rtdm_fd_device(fd)->device_id;
+   return rtdm_fd_minor(fd);
 }
 
 #endif /* !_COBALT_RTDM_ANALOGY_CONTEXT_H */
diff --git a/include/cobalt/kernel/rtdm/driver.h 
b/include/cobalt/kernel/rtdm/driver.h
index 29045cc..fc0f056 100644
--- a/include/cobalt/kernel/rtdm/driver.h
+++ b/include/cobalt/kernel/rtdm/driver.h
@@ -27,7 +27,7 @@
 
 #include 
 #include 
-
+#include 
 #include 
 #include 
 #include 
@@ -51,7 +51,7 @@
 #endif /* CONFIG_PCI */
 #include 
 
-struct rtdm_dev_context;
+struct class;
 typedef struct xnselector rtdm_selector_t;
 enum rtdm_selecttype;
 
@@ -81,23 +81,17 @@ enum rtdm_selecttype;
 
 /** Mask selecting the device type. */
 #define RTDM_DEVICE_TYPE_MASK  0x00F0
+
+/** Flag indicating a secure variant of RTDM (not supported here) */
+#define RTDM_SECURE_DEVICE 0x8000
 /** @} Device Flags */
 
 /*!
  * @anchor drv_versioning @name Driver Versioning
- * Current revisions of RTDM structures, encoding of driver versions. See
+ * Encoding of driver versions. See
  * @ref rtdm_api_versioning "API Versioning" for the interf

[Xenomai-git] Philippe Gerum : cobalt/rtdm: drop poll_delay from rtdm_dev_unregister()

2014-09-21 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: 0b21549f5188655ddda7da9e969fbba46cb03cab
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=0b21549f5188655ddda7da9e969fbba46cb03cab

Author: Philippe Gerum 
Date:   Thu Sep 18 21:02:09 2014 +0200

cobalt/rtdm: drop poll_delay from rtdm_dev_unregister()

Sleep indefinitely on a plain waitqueue instead of polling, until the
device becomes idle. For this reason, the routine loses its return
value as well, as drivers are most often not willing to deal with
receiving a device busy condition from a module exit routine (which is
the place devices should be unregistered from).

Drivers which really want to deal with such condition should simply
use module refcounting in their own code.

---

 include/cobalt/kernel/rtdm/driver.h |5 +-
 include/cobalt/kernel/rtdm/udd.h|3 +-
 kernel/cobalt/posix/io.c|   12 ++--
 kernel/cobalt/posix/memory.c|   10 ++--
 kernel/cobalt/rtdm/core.c   |4 +-
 kernel/cobalt/rtdm/device.c |   93 ++-
 kernel/cobalt/rtdm/internal.h   |   28 ++
 kernel/cobalt/trace/cobalt-rtdm.h   |   10 ++--
 kernel/drivers/analogy/rtdm_interface.c |4 +-
 kernel/drivers/can/rtcan_raw.c  |2 +-
 kernel/drivers/ipc/rtipc.c  |2 +-
 kernel/drivers/serial/16550A.c  |2 +-
 kernel/drivers/serial/mpc52xx_uart.c|2 +-
 kernel/drivers/serial/rt_imx_uart.c |2 +-
 kernel/drivers/testing/rtdmtest.c   |4 +-
 kernel/drivers/testing/switchtest.c |2 +-
 kernel/drivers/testing/timerbench.c |2 +-
 kernel/drivers/udd/udd.c|   46 +++
 18 files changed, 112 insertions(+), 121 deletions(-)

diff --git a/include/cobalt/kernel/rtdm/driver.h 
b/include/cobalt/kernel/rtdm/driver.h
index 765f557..da5bcbd 100644
--- a/include/cobalt/kernel/rtdm/driver.h
+++ b/include/cobalt/kernel/rtdm/driver.h
@@ -29,6 +29,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -348,6 +349,7 @@ struct rtdm_device {
atomic_t refcount;
struct rtdm_dev_context *exclusive_context;
struct rtdm_fd_ops ops;
+   wait_queue_head_t putwq;
};
 };
 
@@ -357,8 +359,7 @@ struct rtdm_device {
 
 int rtdm_dev_register(struct rtdm_device *device);
 
-int rtdm_dev_unregister(struct rtdm_device *device,
-   unsigned int poll_delay);
+void rtdm_dev_unregister(struct rtdm_device *device);
 
 /* --- inter-driver API --- */
 
diff --git a/include/cobalt/kernel/rtdm/udd.h b/include/cobalt/kernel/rtdm/udd.h
index 8fc4715..a78e428 100644
--- a/include/cobalt/kernel/rtdm/udd.h
+++ b/include/cobalt/kernel/rtdm/udd.h
@@ -294,8 +294,7 @@ struct udd_device {
 
 int udd_register_device(struct udd_device *udd);
 
-int udd_unregister_device(struct udd_device *udd,
- unsigned int poll_delay);
+int udd_unregister_device(struct udd_device *udd);
 
 struct udd_device *udd_get_device(struct rtdm_fd *fd);
 
diff --git a/kernel/cobalt/posix/io.c b/kernel/cobalt/posix/io.c
index d6d5dc3..8038bd3 100644
--- a/kernel/cobalt/posix/io.c
+++ b/kernel/cobalt/posix/io.c
@@ -62,23 +62,25 @@ COBALT_SYSCALL(open, lostage,
filp = filp_open(filename->name, oflag, 0);
if (IS_ERR(filp)) {
ret = PTR_ERR(filp);
-   goto fail;
+   goto fail_fopen;
}
 
ppd = cobalt_ppd_get(0);
ret = __rt_dev_open(ppd, ufd, filename->name, oflag);
if (ret < 0)
-   goto fail;
+   goto fail_devopen;
 
-   rtdm_dereference_device(device);
+   __rtdm_put_device(device);
fd_install(ufd, filp);
putname(filename);
 
return ufd;
-fail:
+fail_devopen:
+   filp_close(filp, current->files);
+fail_fopen:
put_unused_fd(ufd);
 fail_ufd:
-   rtdm_dereference_device(device);
+   __rtdm_put_device(device);
 fail_lookup:
putname(filename);
 
diff --git a/kernel/cobalt/posix/memory.c b/kernel/cobalt/posix/memory.c
index 5f97f59..f99bb40 100644
--- a/kernel/cobalt/posix/memory.c
+++ b/kernel/cobalt/posix/memory.c
@@ -292,9 +292,9 @@ int cobalt_memdev_init(void)
return 0;
 
 fail_sysmem:
-   rtdm_dev_unregister(umm_devices + UMM_SHARED, 0);
+   rtdm_dev_unregister(umm_devices + UMM_SHARED);
 fail_shared:
-   rtdm_dev_unregister(umm_devices + UMM_PRIVATE, 0);
+   rtdm_dev_unregister(umm_devices + UMM_PRIVATE);
 fail_private:
cobalt_umm_free(&__xnsys_global_ppd.umm, nkvdso);
 fail_vdso:
@@ -305,9 +305,9 @@ fail_vdso:
 
 void cobalt_memdev_cleanup(void)
 {
-   rtdm_dev_unregister(&sysmem_device, 0);
-   rtdm_dev_unregister(umm_devices + UMM_SHARED, 0);
-   rtdm_dev_unregister(umm_devices + UMM_PRIVATE, 0);
+   rtdm_dev_unregister(&sysmem_device);
+   rtdm_dev_unregister(umm_devices + UMM_SHARED);
+   rtdm_d

[Xenomai-git] Philippe Gerum : cobalt/rtdm, cobalt/posix/process: extend mmap() support to MMU-less

2014-09-21 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: 5f8c21ce4b6d7accaf6b0c9da7b20890775ccb5a
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=5f8c21ce4b6d7accaf6b0c9da7b20890775ccb5a

Author: Philippe Gerum 
Date:   Wed Sep 10 21:29:27 2014 +0200

cobalt/rtdm, cobalt/posix/process: extend mmap() support to MMU-less

A file mapping on no-MMU requires the backing device to advertise
direct mapping capabilities (i.e. BDI_CAP_MAP_DIRECT), which a file
hooked on the anon inode doesn't.

To fix this, we issue our internal mapping requests (i.e. for memdev
heaps and mayday page) on a file pointer to /dev/mem instead, on
MMU-mess systems (only).

In addition, the .get_unmapped_area handler is added to the RTDM file
descriptor operations, since this will be a prerequisite for allowing
drivers to honor mapping requests to (quasi-)memory devices on
MMU-less the same way.

---

 include/cobalt/kernel/rtdm/fd.h |   43 +
 kernel/cobalt/posix/io.c|2 +-
 kernel/cobalt/posix/memory.c|   47 +++---
 kernel/cobalt/posix/process.c   |   77 +---
 kernel/cobalt/rtdm/drvlib.c |  187 +--
 5 files changed, 218 insertions(+), 138 deletions(-)

diff --git a/include/cobalt/kernel/rtdm/fd.h b/include/cobalt/kernel/rtdm/fd.h
index 815ef5d..4282209 100644
--- a/include/cobalt/kernel/rtdm/fd.h
+++ b/include/cobalt/kernel/rtdm/fd.h
@@ -227,10 +227,48 @@ int rtdm_select_handler(struct rtdm_fd *fd, struct 
xnselector *selector,
  *
  * @see @c mmap() in POSIX.1-2001,
  * http://pubs.opengroup.org/onlinepubs/7908799/xsh/mmap.html
+ *
+ * @note The address hint passed to the mmap() request is deliberately
+ * ignored by RTDM.
  */
 int rtdm_mmap_handler(struct rtdm_fd *fd, struct vm_area_struct *vma);
 
 /**
+ * Allocate mapping region in address space
+ *
+ * When present, this optional handler should return the start address
+ * of a free region in the process's address space, large enough to
+ * cover the ongoing mmap() operation. If unspecified, the default
+ * architecture-defined handler is invoked.
+ *
+ * Most drivers can omit this handler, except on MMU-less platforms
+ * (see second note).
+ *
+ * @param[in] fd File descriptor
+ * @param[in] len Length of the requested region
+ * @param[in] pgoff Page frame number to map to (see second note).
+ * @param[in] flags Requested mapping flags
+ *
+ * @return The start address of the mapping region on success. On
+ * failure, a negative error code should be returned, with -ENOSYS
+ * meaning that the driver does not want to provide such information,
+ * in which case the ongoing mmap() operation will fail.
+ *
+ * @note The address hint passed to the mmap() request is deliberately
+ * ignored by RTDM, and therefore not passed to this handler.
+ *
+ * @note On MMU-less platforms, this handler is required because RTDM
+ * issues mapping requests over a shareable character device
+ * internally. In such context, the RTDM core may pass a null @a pgoff
+ * argument to the handler, for probing for the logical start address
+ * of the memory region to map to. Otherwise, when @a pgoff is
+ * non-zero, pgoff << PAGE_SHIFT is usually returned.
+ */
+unsigned long
+rtdm_get_unmapped_area_handler(struct rtdm_fd *fd,
+  unsigned long len, unsigned long pgoff,
+  unsigned long flags);
+/**
  * @anchor rtdm_fd_ops
  * @brief RTDM file operation descriptor.
  *
@@ -282,6 +320,11 @@ struct rtdm_fd_ops {
/** See rtdm_mmap_handler(). */
int (*mmap)(struct rtdm_fd *fd,
struct vm_area_struct *vma);
+   /** See rtdm_get_unmapped_area_handler(). */
+   unsigned long (*get_unmapped_area)(struct rtdm_fd *fd,
+  unsigned long len,
+  unsigned long pgoff,
+  unsigned long flags);
 };
 
 /** @} File operation handlers */
diff --git a/kernel/cobalt/posix/io.c b/kernel/cobalt/posix/io.c
index bafc5e2..4d549bb 100644
--- a/kernel/cobalt/posix/io.c
+++ b/kernel/cobalt/posix/io.c
@@ -169,7 +169,7 @@ COBALT_SYSCALL(mmap, lostage,
 void __user **u_addrp))
 {
struct _rtdm_mmap_request rma;
-   void *u_addr;
+   void *u_addr = NULL;
int ret;
 
if (__xn_copy_from_user(&rma, u_rma, sizeof(rma)))
diff --git a/kernel/cobalt/posix/memory.c b/kernel/cobalt/posix/memory.c
index 126b8c7..78cae01 100644
--- a/kernel/cobalt/posix/memory.c
+++ b/kernel/cobalt/posix/memory.c
@@ -99,6 +99,27 @@ static int umm_mmap(struct rtdm_fd *fd, struct 
vm_area_struct *vma)
return 0;
 }
 
+#ifndef CONFIG_MMU
+static unsigned long umm_get_unmapped_area(struct rtdm_fd *fd,
+  unsigned long len,
+  unsigned long pgoff,
+  unsigned long flags)
+{
+   struct cobalt_umm *umm;

[Xenomai-git] Philippe Gerum : cobalt: rename CONFIG_XENO_HW to CONFIG_XENO_ARCH

2014-09-21 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: 70e617fc32c903353d6283ece5d605dc77810579
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=70e617fc32c903353d6283ece5d605dc77810579

Author: Philippe Gerum 
Date:   Sun Sep 21 10:54:22 2014 +0200

cobalt: rename CONFIG_XENO_HW to CONFIG_XENO_ARCH

This option class is for machine/platform-specific tunables,
"hardware" has always been too generic.

---

 include/cobalt/kernel/lock.h   |2 +-
 include/cobalt/kernel/ppd.h|4 ++--
 include/cobalt/kernel/rtdm/fd.h|8 +++
 include/cobalt/kernel/sched.h  |   10 -
 include/cobalt/kernel/thread.h |4 ++--
 kernel/cobalt/Kconfig  |4 ++--
 kernel/cobalt/arch/arm/Kconfig |   14 ++---
 .../cobalt/arch/arm/include/asm/xenomai/thread.h   |   12 +--
 kernel/cobalt/arch/arm/switch.S|2 +-
 kernel/cobalt/arch/arm/thread.c|4 ++--
 kernel/cobalt/arch/blackfin/Kconfig|2 +-
 kernel/cobalt/arch/nios2/Kconfig   |2 +-
 kernel/cobalt/arch/powerpc/Kconfig |   16 +++---
 kernel/cobalt/arch/powerpc/Makefile|2 +-
 .../arch/powerpc/include/asm/xenomai/fptest.h  |4 ++--
 .../arch/powerpc/include/asm/xenomai/thread.h  |8 +++
 kernel/cobalt/arch/powerpc/thread.c|4 ++--
 kernel/cobalt/arch/sh/Kconfig  |8 +++
 kernel/cobalt/arch/sh/include/asm/xenomai/thread.h |8 +++
 kernel/cobalt/arch/sh/thread.c |4 ++--
 kernel/cobalt/arch/x86/Kconfig |6 +++---
 .../cobalt/arch/x86/include/asm/xenomai/thread.h   |6 +++---
 kernel/cobalt/arch/x86/thread.c|4 ++--
 kernel/cobalt/debug.c  |2 +-
 kernel/cobalt/include/asm-generic/xenomai/thread.h |4 ++--
 kernel/cobalt/init.c   |2 +-
 kernel/cobalt/lock.c   |2 +-
 kernel/cobalt/posix/cond.c |2 +-
 kernel/cobalt/posix/mutex.c|2 +-
 kernel/cobalt/posix/process.c  |   16 +++---
 kernel/cobalt/posix/process.h  |4 ++--
 kernel/cobalt/posix/sem.c  |2 +-
 kernel/cobalt/rtdm/fd.c|   16 +++---
 kernel/cobalt/sched.c  |   22 ++--
 kernel/cobalt/thread.c |   18 
 35 files changed, 115 insertions(+), 115 deletions(-)

diff --git a/include/cobalt/kernel/lock.h b/include/cobalt/kernel/lock.h
index d576c0a..b0c34bf 100644
--- a/include/cobalt/kernel/lock.h
+++ b/include/cobalt/kernel/lock.h
@@ -208,7 +208,7 @@ static inline void xnlock_put(struct xnlock *lock /*, 
*/ XNLOCK_DBG_CONTEXT_
atomic_set(&lock->owner, ~0);
 }
 
-#ifndef CONFIG_XENO_HW_OUTOFLINE_XNLOCK
+#ifndef CONFIG_XENO_ARCH_OUTOFLINE_XNLOCK
 #define ___xnlock_get xnlock_get
 #define ___xnlock_put xnlock_put
 #else /* out of line xnlock */
diff --git a/include/cobalt/kernel/ppd.h b/include/cobalt/kernel/ppd.h
index e76350c..4d42427 100644
--- a/include/cobalt/kernel/ppd.h
+++ b/include/cobalt/kernel/ppd.h
@@ -30,7 +30,7 @@ struct cobalt_umm {
void (*release)(struct cobalt_umm *umm);
 };
 
-struct xnsys_ppd {
+struct cobalt_ppd {
struct cobalt_umm umm;
unsigned long mayday_addr;
atomic_t refcnt;
@@ -38,6 +38,6 @@ struct xnsys_ppd {
struct rb_root fds;
 };
 
-extern struct xnsys_ppd __xnsys_global_ppd;
+extern struct cobalt_ppd __xnsys_global_ppd;
 
 #endif /* _COBALT_KERNEL_PPD_H */
diff --git a/include/cobalt/kernel/rtdm/fd.h b/include/cobalt/kernel/rtdm/fd.h
index 920b276..ec327b3 100644
--- a/include/cobalt/kernel/rtdm/fd.h
+++ b/include/cobalt/kernel/rtdm/fd.h
@@ -29,7 +29,7 @@ struct vm_area_struct;
 struct rtdm_fd;
 struct _rtdm_mmap_request;
 struct xnselector;
-struct xnsys_ppd;
+struct cobalt_ppd;
 
 /**
  * @file
@@ -295,7 +295,7 @@ struct rtdm_fd_ops {
 struct rtdm_fd {
unsigned int magic;
struct rtdm_fd_ops *ops;
-   struct xnsys_ppd *owner;
+   struct cobalt_ppd *owner;
unsigned int refs;
int minor;
struct list_head cleanup;
@@ -307,7 +307,7 @@ int __rtdm_anon_getfd(const char *name, int flags);
 
 void __rtdm_anon_putfd(int ufd);
 
-static inline struct xnsys_ppd *rtdm_fd_owner(struct rtdm_fd *fd)
+static inline struct cobalt_ppd *rtdm_fd_owner(struct rtdm_fd *fd)
 {
return fd->owner;
 }
@@ -349,7 +349,7 @@ int rtdm_fd_valid_p(int ufd);
 int rtdm_fd_select(int ufd, struct xnselector *selector,
   unsigned int type);
 
-void rtdm_fd_cleanup(struct xnsys_ppd *p);
+void rtdm_fd_cleanup(struct co

[Xenomai-git] Philippe Gerum : cobalt/rtdm/device: sanitize locking

2014-09-21 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: e61997c56880a3f394d6bda86a82724e2c6069fb
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=e61997c56880a3f394d6bda86a82724e2c6069fb

Author: Philippe Gerum 
Date:   Sat Sep 20 20:55:40 2014 +0200

cobalt/rtdm/device: sanitize locking

All device registration, open and close operations may only run from
secondary mode, so we don't need the hard spinlock for these anymore.

Cover all the relevant code sections by the registration mutex
instead.

At this chance, we also stop tracking named devices in a separate
list, as we have no use for such information since the recent move
from procfs to sysfs.

---

 include/cobalt/kernel/rtdm/driver.h |1 -
 kernel/cobalt/rtdm/device.c |  156 ---
 2 files changed, 70 insertions(+), 87 deletions(-)

diff --git a/include/cobalt/kernel/rtdm/driver.h 
b/include/cobalt/kernel/rtdm/driver.h
index 922c8d0..5d92bf8 100644
--- a/include/cobalt/kernel/rtdm/driver.h
+++ b/include/cobalt/kernel/rtdm/driver.h
@@ -336,7 +336,6 @@ struct rtdm_device {
char *name;
union {
struct {
-   struct list_head entry;
xnhandle_t handle;
} named;
struct {
diff --git a/kernel/cobalt/rtdm/device.c b/kernel/cobalt/rtdm/device.c
index daf71be..be91504 100644
--- a/kernel/cobalt/rtdm/device.c
+++ b/kernel/cobalt/rtdm/device.c
@@ -47,10 +47,9 @@
 
 #define RTDM_DEVICE_MAGIC  0x82846877
 
-static struct list_head named_devices;
 static struct rb_root protocol_devices;
+
 static DEFINE_MUTEX(register_lock);
-DEFINE_PRIVATE_XNLOCK(rt_dev_lock);
 
 static struct class *rtdm_class;
 
@@ -59,12 +58,12 @@ static int enosys(void)
return -ENOSYS;
 }
 
-void __rtdm_put_device(struct rtdm_device *device)
+void __rtdm_put_device(struct rtdm_device *dev)
 {
secondary_mode_only();
 
-   if (atomic_dec_and_test(&device->refcount))
-   wake_up(&device->putwq);
+   if (atomic_dec_and_test(&dev->refcount))
+   wake_up(&dev->putwq);
 }
 
 static inline xnkey_t get_proto_id(int pf, int type)
@@ -75,10 +74,11 @@ static inline xnkey_t get_proto_id(int pf, int type)
 
 struct rtdm_device *__rtdm_get_namedev(const char *path)
 {
-   struct rtdm_device *device;
+   struct rtdm_device *dev;
xnhandle_t handle;
int ret;
-   spl_t s;
+
+   secondary_mode_only();
 
/* skip common /dev prefix */
if (strncmp(path, "/dev/", 5) == 0)
@@ -92,39 +92,40 @@ struct rtdm_device *__rtdm_get_namedev(const char *path)
if (ret)
return NULL;
 
-   xnlock_get_irqsave(&rt_dev_lock, s);
+   mutex_lock(®ister_lock);
 
-   device = xnregistry_lookup(handle, NULL);
-   if (device && device->magic == RTDM_DEVICE_MAGIC)
-   __rtdm_get_device(device);
+   dev = xnregistry_lookup(handle, NULL);
+   if (dev && dev->magic == RTDM_DEVICE_MAGIC)
+   __rtdm_get_device(dev);
else
-   device = NULL;
+   dev = NULL;
 
-   xnlock_put_irqrestore(&rt_dev_lock, s);
+   mutex_unlock(®ister_lock);
 
-   return device;
+   return dev;
 }
 
 struct rtdm_device *__rtdm_get_protodev(int protocol_family, int socket_type)
 {
-   struct rtdm_device *device = NULL;
+   struct rtdm_device *dev = NULL;
struct xnid *xnid;
xnkey_t id;
-   spl_t s;
+
+   secondary_mode_only();
 
id = get_proto_id(protocol_family, socket_type);
 
-   xnlock_get_irqsave(&rt_dev_lock, s);
+   mutex_lock(®ister_lock);
 
xnid = xnid_fetch(&protocol_devices, id);
if (xnid) {
-   device = container_of(xnid, struct rtdm_device, proto.id);
-   __rtdm_get_device(device);
+   dev = container_of(xnid, struct rtdm_device, proto.id);
+   __rtdm_get_device(dev);
}
 
-   xnlock_put_irqrestore(&rt_dev_lock, s);
+   mutex_unlock(®ister_lock);
 
-   return device;
+   return dev;
 }
 
 /**
@@ -141,20 +142,20 @@ static char *rtdm_devnode(struct device *dev, umode_t 
*mode)
 static ssize_t profile_show(struct device *kdev,
struct device_attribute *attr, char *buf)
 {
-   struct rtdm_device *device = dev_get_drvdata(kdev);
+   struct rtdm_device *dev = dev_get_drvdata(kdev);
 
return sprintf(buf, "%d,%d\n",
-  device->driver->profile_info.class_id,
-  device->driver->profile_info.subclass_id);
+  dev->driver->profile_info.class_id,
+  dev->driver->profile_info.subclass_id);
 }
 static DEVICE_ATTR_RO(profile);
 
 static ssize_t refcount_show(struct device *kdev,
 struct device_attribute *attr, char *buf)
 {
-   struct rtdm_device *device = dev_get_drvdata(kdev)

[Xenomai-git] Philippe Gerum : cobalt/rtdm: split user/kernel paths to opening device

2014-09-21 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: e445bb450ad49cc7a00d183e61ff90e217667f8b
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=e445bb450ad49cc7a00d183e61ff90e217667f8b

Author: Philippe Gerum 
Date:   Fri Sep 19 17:10:45 2014 +0200

cobalt/rtdm: split user/kernel paths to opening device

This is preparation work before we may get rid of our private fd
allocation system for in-kernel callers.

---

 include/cobalt/kernel/rtdm/rtdm.h |   10 +-
 kernel/cobalt/posix/io.c  |   61 +--
 kernel/cobalt/rtdm/core.c |  215 ++---
 kernel/cobalt/rtdm/internal.h |   14 ++-
 4 files changed, 194 insertions(+), 106 deletions(-)

diff --git a/include/cobalt/kernel/rtdm/rtdm.h 
b/include/cobalt/kernel/rtdm/rtdm.h
index 645cb9a..98f0d3a 100644
--- a/include/cobalt/kernel/rtdm/rtdm.h
+++ b/include/cobalt/kernel/rtdm/rtdm.h
@@ -32,10 +32,10 @@
 
 typedef u32 socklen_t;
 
-int __rt_dev_open(struct xnsys_ppd *p, int ufd, const char *path, int oflag);
+int __rtdm_dev_kopen(const char *path, int oflag);
 
-int __rt_dev_socket(struct xnsys_ppd *p, int ufd,
-   int protocol_family, int socket_type, int protocol);
+int __rtdm_dev_ksocket(int protocol_family, int socket_type,
+  int protocol);
 
 int
 __rt_dev_ioctl_fallback(struct rtdm_fd *fd, unsigned request, void __user 
*arg);
@@ -47,10 +47,10 @@ __rt_dev_ioctl_fallback(struct rtdm_fd *fd, unsigned 
request, void __user *arg);
 #ifndef RTDM_NO_DEFAULT_USER_API
 
 #define rt_dev_open(path, oflag, ...)  \
-   __rt_dev_open(&__xnsys_global_ppd, -1, path, oflag)
+   __rtdm_dev_kopen(path, oflag)
 
 #define rt_dev_socket(protocol_family, socket_type, protocol)  \
-   __rt_dev_socket(&__xnsys_global_ppd, -1, protocol_family, socket_type, 
protocol)
+   __rtdm_dev_ksocket(protocol_family, socket_type, protocol)
 
 #define rt_dev_close(fd)   \
rtdm_fd_close(&__xnsys_global_ppd, fd, RTDM_FD_MAGIC)
diff --git a/kernel/cobalt/posix/io.c b/kernel/cobalt/posix/io.c
index be58bd6..197d327 100644
--- a/kernel/cobalt/posix/io.c
+++ b/kernel/cobalt/posix/io.c
@@ -18,10 +18,7 @@
  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
 #include 
-#include 
 #include 
-#include 
-#include 
 #include 
 #include 
 #include "process.h"
@@ -32,76 +29,24 @@
 COBALT_SYSCALL(open, lostage,
   int, (const char __user *u_path, int oflag))
 {
-   struct rtdm_device *device;
struct filename *filename;
-   struct xnsys_ppd *ppd;
-   struct file *filp;
-   int ufd, ret;
+   int ufd;
 
filename = getname(u_path);
if (IS_ERR(filename))
return PTR_ERR(filename);
 
-   /*
-* Lookup for the device into the RTDM registry: if we don't
-* own the device, tell userland to forward to the regular
-* open() service.
-*/
-   device = __rtdm_get_namedev(filename->name);
-   if (device == NULL) {
-   ret = -ENODEV;
-   goto fail;
-   }
-   /* __rt_dev_open() will revalidate. */
-   __rtdm_put_device(device);
-
-   ufd = get_unused_fd_flags(oflag);
-   if (ufd < 0) {
-   ret = ufd;
-   goto fail;
-   }
-
-   filp = filp_open(filename->name, oflag, 0);
-   if (IS_ERR(filp)) {
-   ret = PTR_ERR(filp);
-   goto fail_fopen;
-   }
-
-   ppd = cobalt_ppd_get(0);
-   ret = __rt_dev_open(ppd, ufd, filename->name, oflag);
-   if (ret < 0)
-   goto fail_devopen;
-
-   fd_install(ufd, filp);
+   ufd = __rtdm_dev_open(filename->name, oflag);
putname(filename);
 
return ufd;
-fail_devopen:
-   filp_close(filp, current->files);
-fail_fopen:
-   put_unused_fd(ufd);
-fail:
-   putname(filename);
-
-   return ret;
 }
 
 COBALT_SYSCALL(socket, lostage,
   int, (int protocol_family,
 int socket_type, int protocol))
 {
-   struct xnsys_ppd *ppd;
-   int ufd, ret;
-
-   ppd = cobalt_ppd_get(0);
-   ufd = anon_inode_getfd("[rtdm-proto]", &rtdm_dumb_fops, ppd, O_RDWR);
-
-   ret = __rt_dev_socket(cobalt_ppd_get(0), ufd,
- protocol_family, socket_type, protocol);
-   if (ret < 0)
-   __close_fd(current->files, ufd);
-
-   return ret;
+   return __rtdm_dev_socket(protocol_family, socket_type, protocol);
 }
 
 COBALT_SYSCALL(close, lostage, int, (int fd))
diff --git a/kernel/cobalt/rtdm/core.c b/kernel/cobalt/rtdm/core.c
index 5e05b30..9028652 100644
--- a/kernel/cobalt/rtdm/core.c
+++ b/kernel/cobalt/rtdm/core.c
@@ -18,12 +18,17 @@
  */
 #include 
 #include 
+#include 
+#include 
+#include 
+#include 
 #include 
 #include 
 #include 
 #include "rtdm/internal.h"
 #define CREATE_TRACE_POINTS
 #include 
+#include "posix/process.h"
 
 /**
  * @ingroup rtdm
@@ -72

[Xenomai-git] Philippe Gerum : cobalt/rtdm: drop redundant information from rtdm_device_class

2014-09-21 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: 42ba9f06885b5a6af699afa20dbeb67128421c1f
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=42ba9f06885b5a6af699afa20dbeb67128421c1f

Author: Philippe Gerum 
Date:   Thu Sep 18 11:53:58 2014 +0200

cobalt/rtdm: drop redundant information from rtdm_device_class

Convert .provider_name to MODULE_AUTHOR(), .peripheral_name to
MODULE_DESCRIPTION() and .driver_version to MODULE_VERSION()
respectively, if not already present.

Drop .driver_name entirely as it brings no information we could not
get from reading the module name.

---

 include/cobalt/kernel/rtdm/driver.h |   32 +++
 include/cobalt/kernel/rtdm/udd.h|   11 +--
 kernel/cobalt/posix/memory.c|8 
 kernel/cobalt/rtdm/proc.c   |   22 ++---
 kernel/cobalt/trace/cobalt-rtdm.h   |   18 -
 kernel/drivers/analogy/rtdm_interface.c |   11 ---
 kernel/drivers/autotune/autotune.c  |   19 +-
 kernel/drivers/can/rtcan_raw.c  |   28 +++
 kernel/drivers/ipc/rtipc.c  |   10 --
 kernel/drivers/serial/16550A.c  |   12 +---
 kernel/drivers/serial/mpc52xx_uart.c|6 ++
 kernel/drivers/serial/rt_imx_uart.c |   13 +
 kernel/drivers/testing/rtdmtest.c   |8 +++-
 kernel/drivers/testing/switchtest.c |   12 +---
 kernel/drivers/testing/timerbench.c |   12 +---
 kernel/drivers/udd/udd.c|9 -
 16 files changed, 67 insertions(+), 164 deletions(-)

diff --git a/include/cobalt/kernel/rtdm/driver.h 
b/include/cobalt/kernel/rtdm/driver.h
index 9a0ace5..1366746 100644
--- a/include/cobalt/kernel/rtdm/driver.h
+++ b/include/cobalt/kernel/rtdm/driver.h
@@ -27,6 +27,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -83,26 +84,6 @@ enum rtdm_selecttype;
 #define RTDM_SECURE_DEVICE 0x8000
 /** @} Device Flags */
 
-/*!
- * @anchor drv_versioning @name Driver Versioning
- * Encoding of driver versions. See
- * @ref rtdm_api_versioning "API Versioning" for the interface revision.
- * @{
- */
-/** Version code constructor for driver revisions */
-#define RTDM_DRIVER_VER(major, minor, patch) \
-   (((major & 0xFF) << 16) | ((minor & 0xFF) << 8) | (patch & 0xFF))
-
-/** Get major version number from driver revision code */
-#define RTDM_DRIVER_MAJOR_VER(ver) (((ver) >> 16) & 0xFF)
-
-/** Get minor version number from driver revision code */
-#define RTDM_DRIVER_MINOR_VER(ver) (((ver) >> 8) & 0xFF)
-
-/** Get patch version number from driver revision code */
-#define RTDM_DRIVER_PATCH_VER(ver) ((ver) & 0xFF)
-/** @} Driver Versioning */
-
 /** @} rtdm_device_register */
 
 /*!
@@ -231,6 +212,7 @@ struct rtdm_profile_info {
int version;
/** Reserved */
unsigned int magic;
+   struct module *owner;
 }; 
 
 /**
@@ -253,15 +235,6 @@ struct rtdm_device_class {
int protocol_family;
/** Protocol device identification: socket type (SOCK_xxx) */
int socket_type;
-   /** Informational driver name (reported via /proc) */
-   const char *driver_name;
-   /** Driver version, see @ref drv_versioning "Driver Versioning" macros 
*/
-   int driver_version;
-   /** Informational peripheral name the device is attached to
-*  (reported via /proc) */
-   const char *peripheral_name;
-   /** Informational driver provider name (reported via /proc) */
-   const char *provider_name;
/** I/O operation handlers */
struct rtdm_fd_ops ops;
/**
@@ -309,6 +282,7 @@ struct rtdm_device_class {
.subclass_id = (__subid),   \
.version = (__version), \
.magic = ~RTDM_CLASS_MAGIC, \
+   .owner = THIS_MODULE,   \
 }
 
 /**
diff --git a/include/cobalt/kernel/rtdm/udd.h b/include/cobalt/kernel/rtdm/udd.h
index 780c373..8fc4715 100644
--- a/include/cobalt/kernel/rtdm/udd.h
+++ b/include/cobalt/kernel/rtdm/udd.h
@@ -191,7 +191,7 @@ struct udd_memregion {
 struct udd_device {
/**
 * Name of the device managed by the mini-driver, appears
-* automatically in the /dev namespace upon creation.
+* automatically in the /dev/rtdm namespace upon creation.
 */
const char *device_name;
/**
@@ -200,21 +200,12 @@ struct udd_device {
 */
int device_flags;
/**
-* Textual description of the device managed by the
-* mini-driver.
-*/
-   const char *device_description;
-   /**
 * Subclass code of the device managed by the mini-driver (see
 * RTDM_SUBCLASS_xxx definition in the @ref rtdm_profiles
 * "Device Profiles"). The main class code is forced to

[Xenomai-git] Philippe Gerum : cobalt/rtdm: align naming on kernel standards

2014-09-21 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: 29d24b4129eea2bc5f28d99076a8cee03498
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=29d24b4129eea2bc5f28d99076a8cee03498

Author: Philippe Gerum 
Date:   Sat Sep 20 18:45:43 2014 +0200

cobalt/rtdm: align naming on kernel standards

Rename rtdm_device_class to rtdm_driver, since this is basically what
it is.

Some sysfs attributes of devices have been updated to better conform
to the kernel standards as well.

---

 include/cobalt/kernel/rtdm/driver.h |   33 ---
 include/cobalt/kernel/rtdm/fd.h |3 +-
 include/cobalt/kernel/rtdm/rtdm.h   |3 -
 include/cobalt/kernel/rtdm/udd.h|4 +-
 kernel/cobalt/posix/memory.c|   10 +--
 kernel/cobalt/rtdm/core.c   |   80 -
 kernel/cobalt/rtdm/device.c |  144 ---
 kernel/cobalt/rtdm/fd.c |   44 +-
 kernel/cobalt/rtdm/internal.h   |6 +-
 kernel/cobalt/trace/cobalt-rtdm.h   |   60 ++---
 kernel/drivers/analogy/rtdm_interface.c |4 +-
 kernel/drivers/autotune/autotune.c  |4 +-
 kernel/drivers/can/rtcan_raw.c  |4 +-
 kernel/drivers/ipc/rtipc.c  |4 +-
 kernel/drivers/serial/16550A.c  |4 +-
 kernel/drivers/serial/mpc52xx_uart.c|4 +-
 kernel/drivers/serial/rt_imx_uart.c |4 +-
 kernel/drivers/testing/rtdmtest.c   |4 +-
 kernel/drivers/testing/switchtest.c |4 +-
 kernel/drivers/testing/timerbench.c |4 +-
 kernel/drivers/udd/udd.c|   28 +++---
 21 files changed, 227 insertions(+), 228 deletions(-)

diff --git a/include/cobalt/kernel/rtdm/driver.h 
b/include/cobalt/kernel/rtdm/driver.h
index 5b566f2..2a9201b 100644
--- a/include/cobalt/kernel/rtdm/driver.h
+++ b/include/cobalt/kernel/rtdm/driver.h
@@ -73,8 +73,7 @@ enum rtdm_selecttype;
 /**
  * Use fixed minor provided in the rtdm_device description for
  * registering. If this flag is absent, the RTDM core assigns minor
- * numbers to devices in order of registration within the class they
- * belong to.
+ * numbers to devices managed by a driver in order of registration.
  */
 #define RTDM_FIXED_MINOR   0x0002
 
@@ -127,7 +126,7 @@ enum rtdm_selecttype {
  *
  * Drivers can attach arbitrary data immediately after the official
  * structure.  The size of this data is provided via
- * rtdm_device_class.context_size during device registration.
+ * rtdm_driver.context_size during device registration.
  */
 struct rtdm_dev_context {
struct rtdm_fd fd;
@@ -204,7 +203,7 @@ static inline struct rtdm_device *rtdm_fd_device(struct 
rtdm_fd *fd)
  * @brief RTDM profile information
  *
  * This descriptor details the profile information associated to a
- * RTDM device class.
+ * RTDM class of device managed by a driver.
  *
  * @anchor rtdm_profile_info @name RTDM profile information descriptor
  */
@@ -224,12 +223,12 @@ struct rtdm_profile_info {
 }; 
 
 /**
- * @brief RTDM device class
+ * @brief RTDM driver
  *
- * This descriptor describes a RTDM device class. The structure holds
+ * This descriptor describes a RTDM device driver. The structure holds
  * runtime data, therefore it must reside in writable memory.
  */
-struct rtdm_device_class {
+struct rtdm_driver {
/**
 * Class profile information. The RTDM_PROFILE_INFO() macro @b
 * must be used for filling up this field.
@@ -246,8 +245,8 @@ struct rtdm_device_class {
/** I/O operation handlers */
struct rtdm_fd_ops ops;
/**
-* Count of devices which belong to this class. This value is
-* used to allocate a chrdev region for named devices.
+* Count of devices this driver manages. This value is used to
+* allocate a chrdev region for named devices.
 */
int device_count;
/** Reserved area */
@@ -268,7 +267,7 @@ struct rtdm_device_class {
  * @brief Initializer for class profile information.
  *
  * This macro must be used to fill in the @ref rtdm_profile_info
- * "class profile information" field from a RTDM device class.
+ * "class profile information" field from a RTDM driver.
  *
  * @param __name Class name (unquoted).
  *
@@ -299,8 +298,8 @@ struct rtdm_device_class {
  * holds runtime data, therefore it must reside in writable memory.
  */
 struct rtdm_device {
-   /** Device class. */
-   struct rtdm_device_class *class;
+   /** Device driver. */
+   struct rtdm_driver *driver;
/** Driver definable device data */
void *device_data;
/**
@@ -317,11 +316,11 @@ struct rtdm_device {
const char *label;
/**
 * Minor number of the device. If RTDM_FIXED_MINOR is present
-* in the device class flags, the value stored in this field
-* at registration time is read and used verbatim. Otherwise,
-* the RTDM core automatically assigns minor numbers t

[Xenomai-git] Philippe Gerum : config: bump core version

2014-09-21 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: b8a2e306d7fc0c2aafe32c1e22a87e46ae014889
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=b8a2e306d7fc0c2aafe32c1e22a87e46ae014889

Author: Philippe Gerum 
Date:   Sun Sep 21 20:04:14 2014 +0200

config: bump core version

---

 config/version |2 +-
 configure  |   20 ++--
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/config/version b/config/version
index bbb1516..6a81223 100644
--- a/config/version
+++ b/config/version
@@ -1 +1 @@
-2.99.7
+2.99.8
diff --git a/configure b/configure
index 248ac6c..f5285a8 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for Xenomai 2.99.7.
+# Generated by GNU Autoconf 2.69 for Xenomai 2.99.8.
 #
 # Report bugs to .
 #
@@ -590,8 +590,8 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='Xenomai'
 PACKAGE_TARNAME='xenomai'
-PACKAGE_VERSION='2.99.7'
-PACKAGE_STRING='Xenomai 2.99.7'
+PACKAGE_VERSION='2.99.8'
+PACKAGE_STRING='Xenomai 2.99.8'
 PACKAGE_BUGREPORT='xeno...@xenomai.org'
 PACKAGE_URL=''
 
@@ -1420,7 +1420,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures Xenomai 2.99.7 to adapt to many kinds of systems.
+\`configure' configures Xenomai 2.99.8 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1491,7 +1491,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
- short | recursive ) echo "Configuration of Xenomai 2.99.7:";;
+ short | recursive ) echo "Configuration of Xenomai 2.99.8:";;
esac
   cat <<\_ACEOF
 
@@ -1638,7 +1638,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-Xenomai configure 2.99.7
+Xenomai configure 2.99.8
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -2007,7 +2007,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by Xenomai $as_me 2.99.7, which was
+It was created by Xenomai $as_me 2.99.8, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -4764,7 +4764,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='xenomai'
- VERSION='2.99.7'
+ VERSION='2.99.8'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -14856,7 +14856,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by Xenomai $as_me 2.99.7, which was
+This file was extended by Xenomai $as_me 2.99.8, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES= $CONFIG_FILES
@@ -14922,7 +14922,7 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; 
s/[\\""\`\$]/&/g'`"
 ac_cs_version="\\
-Xenomai config.status 2.99.7
+Xenomai config.status 2.99.8
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 


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


[Xenomai-git] Philippe Gerum : lib/cobalt: cope with pthread_atfork() placeholder on MMU-less

2014-09-21 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: b9448efc82999492578788ee6e3204b04d7db003
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=b9448efc82999492578788ee6e3204b04d7db003

Author: Philippe Gerum 
Date:   Thu Sep 11 07:35:11 2014 +0200

lib/cobalt: cope with pthread_atfork() placeholder on MMU-less

---

 lib/cobalt/init.c |   18 +++---
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/lib/cobalt/init.c b/lib/cobalt/init.c
index ed4cbb7..8ba9902 100644
--- a/lib/cobalt/init.c
+++ b/lib/cobalt/init.c
@@ -120,7 +120,6 @@ static void __init_cobalt(void);
 void __libcobalt_init(void)
 {
struct sigaction sa;
-   int ret;
 
low_init();
 
@@ -129,16 +128,21 @@ void __libcobalt_init(void)
sa.sa_flags = SA_SIGINFO;
sigaction(SIGDEBUG, &sa, &__cobalt_orig_sigdebug);
 
+#ifdef HAVE_PTHREAD_ATFORK
/*
 * Upon fork, in case the parent required init deferral, this
 * is the forkee's responsibility to call __libcobalt_init()
-* for bootstrapping the services the same way.
+* for bootstrapping the services the same way. On systems
+* with no fork() support, clients are not supposed to, well,
+* fork in the first place, so we don't take any provision for
+* this event.
+*
+* NOTE: a placeholder for pthread_atfork() may return an
+* error status with uClibc, so we don't check the return
+* value on purpose.
 */
-   ret = pthread_atfork(NULL, NULL, __init_cobalt);
-   if (ret) {
-   report_error("pthread_atfork: %s", strerror(ret));
-   exit(EXIT_FAILURE);
-   }
+   pthread_atfork(NULL, NULL, __init_cobalt);
+#endif
 
if (sizeof(struct cobalt_mutex_shadow) > sizeof(pthread_mutex_t)) {
report_error("sizeof(pthread_mutex_t): %d <"


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


[Xenomai-git] Philippe Gerum : cobalt/rtdm: allow fixing device minor in description

2014-09-21 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: 3b243670bf62d27be79b628a85f37740c98471c2
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=3b243670bf62d27be79b628a85f37740c98471c2

Author: Philippe Gerum 
Date:   Thu Sep 18 14:56:04 2014 +0200

cobalt/rtdm: allow fixing device minor in description

Some RTDM device creation process could depend on an external
enumeration loop which might advertise devices in pseudo-random order,
at least not by monotonically increasing unit ids.

For these devices, we may still want the hardware unit id to match the
logical minor number though, for the sake of consistency. Passing
RTDM_FIXED_MINOR in the device class flags will cause the value stored
in the rtdm_device.minor field at registration time to be read and
used verbatim.

Otherwise (i.e. flag absent), the RTDM core will automatically assign
minor numbers to devices in order of registration within the class
they belong to, storing the resulting values into this field.

---

 include/cobalt/kernel/rtdm/driver.h |   24 +++-
 kernel/cobalt/rtdm/core.c   |5 +
 kernel/cobalt/rtdm/device.c |9 ++---
 3 files changed, 30 insertions(+), 8 deletions(-)

diff --git a/include/cobalt/kernel/rtdm/driver.h 
b/include/cobalt/kernel/rtdm/driver.h
index 1366746..0b4a70c 100644
--- a/include/cobalt/kernel/rtdm/driver.h
+++ b/include/cobalt/kernel/rtdm/driver.h
@@ -70,6 +70,14 @@ enum rtdm_selecttype;
  *  application. */
 #define RTDM_EXCLUSIVE 0x0001
 
+/**
+ * Use fixed minor provided in the rtdm_device description for
+ * registering. If this flag is absent, the RTDM core assigns minor
+ * numbers to devices in order of registration within the class they
+ * belong to.
+ */
+#define RTDM_FIXED_MINOR   0x0002
+
 /** If set, the device is addressed via a clear-text name. */
 #define RTDM_NAMED_DEVICE  0x0010
 
@@ -308,6 +316,21 @@ struct rtdm_device {
 * hotplug-enabled device filesystems (DEVTMPFS).
 */
const char *label;
+   /**
+* Minor number of the device. If RTDM_FIXED_MINOR is present
+* in the device class flags, the value stored in this field
+* at registration time is read and used verbatim. Otherwise,
+* the RTDM core automatically assigns minor numbers to
+* devices in order of registration within the class they
+* belong to, storing the resulting values into this field.
+*
+* Device nodes created for named devices in the Linux /dev
+* hierarchy are assigned this minor number.
+*
+* The minor number of the current device handling an I/O
+* request can be retreived by a call to rtdm_fd_minor().
+*/
+   int minor;
/** Reserved area. */
struct {
unsigned int magic;
@@ -316,7 +339,6 @@ struct rtdm_device {
struct {
struct list_head entry;
xnhandle_t handle;
-   int minor;
} named;
struct {
struct xnid id;
diff --git a/kernel/cobalt/rtdm/core.c b/kernel/cobalt/rtdm/core.c
index 3bf9778..4601dad 100644
--- a/kernel/cobalt/rtdm/core.c
+++ b/kernel/cobalt/rtdm/core.c
@@ -164,10 +164,7 @@ int __rt_dev_open(struct xnsys_ppd *p, int ufd, const char 
*path, int oflag)
goto cleanup_out;
 
ufd = ret;
-   if (device->class->device_flags & RTDM_NAMED_DEVICE)
-   context->fd.minor = device->named.minor;
-   else
-   context->fd.minor = 0;
+   context->fd.minor = device->minor;
 
trace_cobalt_fd_open(current, &context->fd, ufd, oflag);
 
diff --git a/kernel/cobalt/rtdm/device.c b/kernel/cobalt/rtdm/device.c
index a28699f..9825b93 100644
--- a/kernel/cobalt/rtdm/device.c
+++ b/kernel/cobalt/rtdm/device.c
@@ -275,10 +275,13 @@ int rtdm_dev_register(struct rtdm_device *device)
 
device->magic = RTDM_DEVICE_MAGIC;
 
+   if (class->device_flags & RTDM_FIXED_MINOR)
+   minor = device->minor;
+   else
+   device->minor = minor = pos;
+
if (class->device_flags & RTDM_NAMED_DEVICE) {
major = class->named.major;
-   minor = pos;
-   device->named.minor = minor;
device->name = kasformat(device->label, minor);
if (device->name == NULL) {
ret = -ENOMEM;
@@ -413,7 +416,7 @@ int rtdm_dev_unregister(struct rtdm_device *device, 
unsigned int poll_delay)
xnregistry_remove(handle);
device_destroy(class->named.kclass,
   MKDEV(class->named.major,
-device->named.minor));
+device->minor));
}
 
unregister_device_class(class);


___

[Xenomai-git] Philippe Gerum : cobalt/rtdm: fix mmap helper for MMU-less

2014-09-21 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: ce4a1c767e6f787eab51fa38bf447c959dfd16a9
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=ce4a1c767e6f787eab51fa38bf447c959dfd16a9

Author: Philippe Gerum 
Date:   Tue Sep  9 19:17:18 2014 +0200

cobalt/rtdm: fix mmap helper for MMU-less

---

 kernel/cobalt/rtdm/drvlib.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/cobalt/rtdm/drvlib.c b/kernel/cobalt/rtdm/drvlib.c
index aab8725..e147b6e 100644
--- a/kernel/cobalt/rtdm/drvlib.c
+++ b/kernel/cobalt/rtdm/drvlib.c
@@ -1606,7 +1606,7 @@ unsigned long unmapped_area_helper(struct file *filp,
if (pa)
return (unsigned long)__va(pa);
 
-   return (unsigned long)mmap_data->src_vaddr;
+   return (unsigned long)helper_data->src_vaddr;
 }
 
 static unsigned long


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


[Xenomai-git] Philippe Gerum : cobalt/rtdm: sanitize handling of exclusive context

2014-09-21 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: fbafe724267062d2c0e2db9193c8908be711a17a
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=fbafe724267062d2c0e2db9193c8908be711a17a

Author: Philippe Gerum 
Date:   Fri Sep 19 16:38:25 2014 +0200

cobalt/rtdm: sanitize handling of exclusive context

---

 include/cobalt/kernel/rtdm/driver.h |1 -
 kernel/cobalt/posix/io.c|   11 
 kernel/cobalt/rtdm/core.c   |   49 +--
 kernel/cobalt/rtdm/device.c |   19 --
 4 files changed, 23 insertions(+), 57 deletions(-)

diff --git a/include/cobalt/kernel/rtdm/driver.h 
b/include/cobalt/kernel/rtdm/driver.h
index 9db9e1b..5b566f2 100644
--- a/include/cobalt/kernel/rtdm/driver.h
+++ b/include/cobalt/kernel/rtdm/driver.h
@@ -346,7 +346,6 @@ struct rtdm_device {
dev_t rdev;
struct device *kdev;
atomic_t refcount;
-   struct rtdm_dev_context *exclusive_context;
struct rtdm_fd_ops ops;
wait_queue_head_t putwq;
};
diff --git a/kernel/cobalt/posix/io.c b/kernel/cobalt/posix/io.c
index 8038bd3..be58bd6 100644
--- a/kernel/cobalt/posix/io.c
+++ b/kernel/cobalt/posix/io.c
@@ -50,13 +50,15 @@ COBALT_SYSCALL(open, lostage,
device = __rtdm_get_namedev(filename->name);
if (device == NULL) {
ret = -ENODEV;
-   goto fail_lookup;
+   goto fail;
}
+   /* __rt_dev_open() will revalidate. */
+   __rtdm_put_device(device);
 
ufd = get_unused_fd_flags(oflag);
if (ufd < 0) {
ret = ufd;
-   goto fail_ufd;
+   goto fail;
}
 
filp = filp_open(filename->name, oflag, 0);
@@ -70,7 +72,6 @@ COBALT_SYSCALL(open, lostage,
if (ret < 0)
goto fail_devopen;
 
-   __rtdm_put_device(device);
fd_install(ufd, filp);
putname(filename);
 
@@ -79,9 +80,7 @@ fail_devopen:
filp_close(filp, current->files);
 fail_fopen:
put_unused_fd(ufd);
-fail_ufd:
-   __rtdm_put_device(device);
-fail_lookup:
+fail:
putname(filename);
 
return ret;
diff --git a/kernel/cobalt/rtdm/core.c b/kernel/cobalt/rtdm/core.c
index 2baf664..5e05b30 100644
--- a/kernel/cobalt/rtdm/core.c
+++ b/kernel/cobalt/rtdm/core.c
@@ -41,12 +41,8 @@ DEFINE_XNLOCK(rt_fildes_lock);
 static void cleanup_instance(struct rtdm_device *device,
 struct rtdm_dev_context *context)
 {
-   if (context) {
-   if (device->exclusive_context)
-   context->device = NULL;
-   else
-   kfree(context);
-   }
+   if (context)
+   kfree(context);
 
__rtdm_put_device(device);
 }
@@ -80,9 +76,10 @@ static int create_instance(struct xnsys_ppd *p, int fd,
   struct rtdm_device *device,
   struct rtdm_dev_context **context_ptr)
 {
+   struct rtdm_device_class *class = device->class;
struct rtdm_dev_context *context;
spl_t s;
-   int err;
+   int ret;
 
/*
 * Reset to NULL so that we can always use cleanup_files/instance to
@@ -105,34 +102,24 @@ static int create_instance(struct xnsys_ppd *p, int fd,
xnlock_put_irqrestore(&rt_fildes_lock, s);
}
 
-   context = device->exclusive_context;
-   if (context) {
-   xnlock_get_irqsave(&rt_dev_lock, s);
-
-   if (unlikely(context->device != NULL)) {
-   xnlock_put_irqrestore(&rt_dev_lock, s);
-   err = -EBUSY;
-   goto fail;
-   }
-
-   context->device = device;
-
-   xnlock_put_irqrestore(&rt_dev_lock, s);
-   } else {
-   context = kmalloc(sizeof(struct rtdm_dev_context) +
-   device->class->context_size, GFP_KERNEL);
-   if (unlikely(context == NULL)) {
-   err = -ENOMEM;
-   goto fail;
-   }
+   if ((class->device_flags & RTDM_EXCLUSIVE) != 0 &&
+   atomic_read(&device->refcount) > 1) {
+   ret = -EBUSY;
+   goto fail;
+   }
 
-   context->device = device;
+   context = kmalloc(sizeof(struct rtdm_dev_context) +
+ class->context_size, GFP_KERNEL);
+   if (unlikely(context == NULL)) {
+   ret = -ENOMEM;
+   goto fail;
}
 
+   context->device = device;
*context_ptr = context;
 
-   err = rtdm_fd_enter(p, &context->fd, fd, RTDM_FD_MAGIC, &device->ops);
-   if (err < 0)
+   ret = rtdm_fd_enter(p, &context->fd, fd, RTDM_FD_MAGIC, &device->ops);
+   if (ret < 0)
goto fail;
 
return fd;
@@ -144,7 +131,7 @@ fail:
xnlock_put_irqrestore(&rt_fi

[Xenomai-git] Philippe Gerum : doc: prebuild

2014-09-21 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: 293eaa8eccf1ea60074b72ebeeea0e6bd59176d8
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=293eaa8eccf1ea60074b72ebeeea0e6bd59176d8

Author: Philippe Gerum 
Date:   Sun Sep 21 20:07:39 2014 +0200

doc: prebuild

---

 doc/prebuilt/html/MIGRATION/index.html |  781 ++--
 doc/prebuilt/html/README.APPLICATIONS/index.html   |2 +-
 doc/prebuilt/html/README.INSTALL/index.html|2 +-
 .../html/TROUBLESHOOTING.COBALT/index.html |2 +-
 .../html/TROUBLESHOOTING.MERCURY/index.html|2 +-
 doc/prebuilt/html/man1/latency/index.html  |   10 +-
 .../html/xeno3prm/16550A__io_8h_source.html|2 +-
 .../html/xeno3prm/16550A__pci_8h_source.html   |4 +-
 .../html/xeno3prm/16550A__pnp_8h_source.html   |2 +-
 doc/prebuilt/html/xeno3prm/8255_8h_source.html |2 +-
 doc/prebuilt/html/xeno3prm/analogy_2driver_8h.html |4 +-
 .../html/xeno3prm/analogy_2driver_8h__incl.map |   66 +-
 .../html/xeno3prm/analogy_2driver_8h__incl.md5 |2 +-
 .../html/xeno3prm/analogy_2driver_8h__incl.png |  Bin 349636 -> 289834 
bytes
 .../html/xeno3prm/analogy_2driver_8h_source.html   |2 +-
 doc/prebuilt/html/xeno3prm/analogy_8h.html |2 +-
 doc/prebuilt/html/xeno3prm/analogy_8h_source.html  |2 +-
 doc/prebuilt/html/xeno3prm/annotated.html  |   43 +-
 doc/prebuilt/html/xeno3prm/annotated.js|3 +-
 doc/prebuilt/html/xeno3prm/apc_8h_source.html  |2 +-
 doc/prebuilt/html/xeno3prm/api-tags.html   |2 +-
 ..._2include_2asm_2xenomai_2machine_8h_source.html |4 +-
 ...include_2asm_2xenomai_2syscall32_8h_source.html |  132 ++
 ..._2include_2asm_2xenomai_2machine_8h_source.html |2 +-
 ...include_2asm_2xenomai_2syscall32_8h_source.html |  132 ++
 ..._2include_2asm_2xenomai_2machine_8h_source.html |2 +-
 ...include_2asm_2xenomai_2syscall32_8h_source.html |  132 ++
 ..._2include_2asm_2xenomai_2machine_8h_source.html |2 +-
 ...include_2asm_2xenomai_2syscall32_8h_source.html |  132 ++
 ..._2include_2asm_2xenomai_2machine_8h_source.html |2 +-
 ...include_2asm_2xenomai_2syscall32_8h_source.html |  132 ++
 ..._2include_2asm_2xenomai_2machine_8h_source.html |2 +-
 ...include_2asm_2xenomai_2syscall32_8h_source.html |  167 ++
 ...clude_2asm_2xenomai_2calibration_8h_source.html |2 +-
 ...m_2include_2asm_2xenomai_2fptest_8h_source.html |2 +-
 ...lude_2asm_2xenomai_2uapi_2fptest_8h_source.html |2 +-
 doc/prebuilt/html/xeno3prm/assert_8h_source.html   |   70 +-
 doc/prebuilt/html/xeno3prm/async_8c.html   |2 +-
 doc/prebuilt/html/xeno3prm/atomic_8h_source.html   |  126 +-
 doc/prebuilt/html/xeno3prm/bheap_8h_source.html|4 +-
 ...clude_2asm_2xenomai_2calibration_8h_source.html |2 +-
 ...n_2include_2asm_2xenomai_2fptest_8h_source.html |2 +-
 ...lude_2asm_2xenomai_2uapi_2fptest_8h_source.html |2 +-
 .../boilerplate_2ancillaries_8h_source.html|  174 +-
 .../html/xeno3prm/boilerplate_2list_8h_source.html |2 +-
 .../html/xeno3prm/boilerplate_2lock_8h_source.html |4 +-
 .../html/xeno3prm/boilerplate_2time_8h_source.html |2 +-
 doc/prebuilt/html/xeno3prm/bufd_8h_source.html |2 +-
 .../html/xeno3prm/bufp-label_8c-example.html   |6 +-
 .../html/xeno3prm/bufp-readwrite_8c-example.html   |6 +-
 doc/prebuilt/html/xeno3prm/c1e_8h_source.html  |2 +-
 doc/prebuilt/html/xeno3prm/can-rtt_8c-example.html |   15 +-
 doc/prebuilt/html/xeno3prm/channel__range_8h.html  |2 +-
 .../html/xeno3prm/channel__range_8h_source.html|2 +-
 doc/prebuilt/html/xeno3prm/classes.html|   39 +-
 doc/prebuilt/html/xeno3prm/clockobj_8h_source.html |2 +-
 doc/prebuilt/html/xeno3prm/cluster_8h_source.html  |2 +-
 .../html/xeno3prm/cobalt-core_8h_source.html   | 1020 +--
 .../html/xeno3prm/cobalt-posix_8h_source.html  | 1905 ++--
 .../html/xeno3prm/cobalt-rtdm_8h_source.html   |  988 +-
 .../cobalt_2boilerplate_2limits_8h_source.html |2 +-
 .../cobalt_2boilerplate_2trace_8h_source.html  |2 +-
 .../cobalt_2kernel_2ancillaries_8h_source.html |2 +-
 .../xeno3prm/cobalt_2kernel_2list_8h_source.html   |2 +-
 .../xeno3prm/cobalt_2kernel_2lock_8h_source.html   |9 +-
 .../cobalt_2kernel_2registry_8h_source.html|  125 +-
 .../cobalt_2kernel_2rtdm_2autotune_8h_source.html  |2 +-
 .../xeno3prm/cobalt_2kernel_2rtdm_2can_8h.html |2 +-
 .../cobalt_2kernel_2rtdm_2can_8h_source.html   |2 +-
 .../xeno3prm/cobalt_2kernel_2rtdm_2ipc_8h.html |4 +-
 .../cobalt_2kernel_2rtdm_2ipc_8h__incl.map |8 +-
 .../cobalt_2kernel_2rtdm_2ipc_8h__incl.md5 |2 +-
 .../cobalt_2kernel_2rtdm_2ipc_8h__incl.png |  Bin 51763 -> 53810 bytes
 .../cobalt_2kernel_2rtdm_2ipc_8h_source.html   |2 +-
 .../xeno3prm/cobalt_2kernel_2rtdm_2rtdm_8h.html|

[Xenomai-git] Philippe Gerum : cobalt/rtdm, lib/cobalt: drop support for @minor specifier in pathnames

2014-09-21 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: dfc9e081c676ff892bb7c932d1b4bb70d68846dc
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=dfc9e081c676ff892bb7c932d1b4bb70d68846dc

Author: Philippe Gerum 
Date:   Wed Sep 17 17:15:24 2014 +0200

cobalt/rtdm, lib/cobalt: drop support for @minor specifier in pathnames

Now that every named device is backed by a regular chrdev, we need no
virtual minor specification. We may just use the dev_t assigned to the
associated devnode.

---

 include/cobalt/kernel/rtdm/driver.h |8 ++--
 include/cobalt/kernel/rtdm/fd.h |   38 +---
 include/cobalt/kernel/rtdm/udd.h|4 +-
 kernel/cobalt/rtdm/core.c   |6 +--
 kernel/cobalt/rtdm/device.c |   81 ---
 kernel/cobalt/rtdm/internal.h   |5 +--
 kernel/drivers/udd/udd.c|2 +-
 7 files changed, 31 insertions(+), 113 deletions(-)

diff --git a/include/cobalt/kernel/rtdm/driver.h 
b/include/cobalt/kernel/rtdm/driver.h
index fc0f056..9a0ace5 100644
--- a/include/cobalt/kernel/rtdm/driver.h
+++ b/include/cobalt/kernel/rtdm/driver.h
@@ -69,9 +69,6 @@ enum rtdm_selecttype;
  *  application. */
 #define RTDM_EXCLUSIVE 0x0001
 
-/** If set, the device supports minor specification. */
-#define RTDM_MINOR 0x0002
-
 /** If set, the device is addressed via a clear-text name. */
 #define RTDM_NAMED_DEVICE  0x0010
 
@@ -267,7 +264,10 @@ struct rtdm_device_class {
const char *provider_name;
/** I/O operation handlers */
struct rtdm_fd_ops ops;
-   /** Count of devices which belong to this class. */
+   /**
+* Count of devices which belong to this class. This value is
+* used to allocate a chrdev region for named devices.
+*/
int device_count;
/** Reserved area */
struct {
diff --git a/include/cobalt/kernel/rtdm/fd.h b/include/cobalt/kernel/rtdm/fd.h
index de440cf..6b50cef 100644
--- a/include/cobalt/kernel/rtdm/fd.h
+++ b/include/cobalt/kernel/rtdm/fd.h
@@ -47,43 +47,7 @@ struct xnsys_ppd;
  * The file descriptor carries a device minor information which can be
  * retrieved by a call to rtdm_fd_minor(fd). The minor number can be
  * used for distinguishing several instances of the same rtdm_device
- * type. Prior to entering this handler, the device minor information
- * may have been extracted from the path name passed to the @a open()
- * call, according to the following rules:
- *
- * - RTDM first attempts to match the path name exactly as passed by
- * the application, against the registered rtdm_device descriptors. On
- * success, the special minor -1 is assigned to @a fd and this handler
- * is called.
- *
- * - if the original path name does not match any device descriptor,
- * it is scanned backward for a \ suffix, which starts after
- * the first non-digit character found. If present, a second lookup is
- * performed in the device registry for the radix portion of the path
- * name (i.e. stripping the \), looking for a device bearing
- * the RTDM_MINOR flag.  If found, the file descriptor is assigned the
- * minor value retrieved earlier on success, at which point the
- * binding succeeds and the open() handler is called.
- *
- * When present, \ must be a positive or null decimal value,
- * otherwise the open() call fails.
- *
- * For disambiguation, the special \@ character can be used as an
- * explicit separator between the radix and the \, which is
- * ignored in the final lookup for the path name.
- *
- * For instance, with two distinct registered devices bearing the
- * RTDM_MINOR flag, namely "foo" and "foo42", lookups would resolve as
- * follows:
- *
- * @code
- *fd = open("/dev/foo0", ...);// dev = foo, rtdm_fd_minor(fd) = 0
- *fd = open("/dev/foo", ...); // dev = foo, rtdm_fd_minor(fd) = -1
- *fd = open("/dev/foo42@7", ...); // dev = foo42, rtdm_fd_minor(fd) = 7
- *fd = open("/dev/foo42", ...);   // dev = foo42, rtdm_fd_minor(fd) = -1
- * @endcode
- *
- * @note the device minor scheme is not supported by Xenomai 2.x.
+ * class.
  *
  * @return 0 on success. On failure, a negative error code is returned.
  *
diff --git a/include/cobalt/kernel/rtdm/udd.h b/include/cobalt/kernel/rtdm/udd.h
index 8fae461..780c373 100644
--- a/include/cobalt/kernel/rtdm/udd.h
+++ b/include/cobalt/kernel/rtdm/udd.h
@@ -195,8 +195,8 @@ struct udd_device {
 */
const char *device_name;
/**
-* Additional device flags (e.g. RTDM_EXCLUSIVE,
-* RTDM_MINOR. RTDM_NAMED_DEVICE may be omitted).
+* Additional device flags (e.g. RTDM_EXCLUSIVE)
+* RTDM_NAMED_DEVICE may be omitted).
 */
int device_flags;
/**
diff --git a/kernel/cobalt/rtdm/core.c b/kernel/cobalt/rtdm/core.c
index d46e7a0..3bf9778 100644
--- a/kernel/cobalt/rtdm/core.c
+++ b/kernel/cobalt/rtdm/core.c
@@ -153,7 +153,7 @@ int __rt_dev_open(struct xnsys_ppd *p, i

[Xenomai-git] Philippe Gerum : cobalt/rtdm: update copyright information

2014-09-21 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: 781ddd3b35705325f5fbbd25646483ebe626acbf
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=781ddd3b35705325f5fbbd25646483ebe626acbf

Author: Philippe Gerum 
Date:   Sat Sep 20 19:18:41 2014 +0200

cobalt/rtdm: update copyright information

---

 include/cobalt/kernel/rtdm/driver.h |7 ---
 kernel/cobalt/rtdm/core.c   |1 +
 kernel/cobalt/rtdm/device.c |1 +
 kernel/cobalt/rtdm/drvlib.c |1 +
 4 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/include/cobalt/kernel/rtdm/driver.h 
b/include/cobalt/kernel/rtdm/driver.h
index 2a9201b..922c8d0 100644
--- a/include/cobalt/kernel/rtdm/driver.h
+++ b/include/cobalt/kernel/rtdm/driver.h
@@ -2,9 +2,10 @@
  * @file
  * Real-Time Driver Model for Xenomai, driver API header
  *
- * @note Copyright (C) 2005-2007 Jan Kiszka 
- * @note Copyright (C) 2005 Joerg Langenberg 
- * @note Copyright (C) 2008 Gilles Chanteperdrix 

+ * Copyright (C) 2005-2007 Jan Kiszka 
+ * Copyright (C) 2005 Joerg Langenberg 
+ * Copyright (C) 2008 Gilles Chanteperdrix 
+ * 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
diff --git a/kernel/cobalt/rtdm/core.c b/kernel/cobalt/rtdm/core.c
index 5181bdc..896f139 100644
--- a/kernel/cobalt/rtdm/core.c
+++ b/kernel/cobalt/rtdm/core.c
@@ -1,6 +1,7 @@
 /*
  * Copyright (C) 2005 Jan Kiszka 
  * Copyright (C) 2005 Joerg Langenberg 
+ * 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
diff --git a/kernel/cobalt/rtdm/device.c b/kernel/cobalt/rtdm/device.c
index 2111420..daf71be 100644
--- a/kernel/cobalt/rtdm/device.c
+++ b/kernel/cobalt/rtdm/device.c
@@ -3,6 +3,7 @@
  *
  * Copyright (C) 2005 Jan Kiszka 
  * Copyright (C) 2005 Joerg Langenberg 
+ * 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
diff --git a/kernel/cobalt/rtdm/drvlib.c b/kernel/cobalt/rtdm/drvlib.c
index 217b55a..cfc6733 100644
--- a/kernel/cobalt/rtdm/drvlib.c
+++ b/kernel/cobalt/rtdm/drvlib.c
@@ -4,6 +4,7 @@
  * Copyright (C) 2005-2007 Jan Kiszka 
  * Copyright (C) 2005 Joerg Langenberg 
  * Copyright (C) 2008 Gilles Chanteperdrix 
+ * 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


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


[Xenomai-git] Philippe Gerum : lib/cobalt: hint about disabled DEVTMPFS

2014-09-21 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: 9cdf9e3f58065ba5267275e5703dc4a8b8656ab0
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=9cdf9e3f58065ba5267275e5703dc4a8b8656ab0

Author: Philippe Gerum 
Date:   Sun Sep 21 16:14:38 2014 +0200

lib/cobalt: hint about disabled DEVTMPFS

---

 lib/cobalt/umm.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/cobalt/umm.c b/lib/cobalt/umm.c
index 1ec05ec..16b0f31 100644
--- a/lib/cobalt/umm.c
+++ b/lib/cobalt/umm.c
@@ -125,6 +125,7 @@ static void init_bind(void)
if (cobalt_umm_private == MAP_FAILED) {
report_error("cannot map private umm area: %s",
 strerror(errno));
+   report_error_cont("(CONFIG_DEVTMPFS_MOUNT not enabled?)");
exit(EXIT_FAILURE);
}
 }


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


[Xenomai-git] Philippe Gerum : cobalt/posix/memory: group umm devices in a single class

2014-09-21 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: 32d906908d68644ce923760fb4fdd9ab420bcfdb
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=32d906908d68644ce923760fb4fdd9ab420bcfdb

Author: Philippe Gerum 
Date:   Wed Sep 17 17:00:33 2014 +0200

cobalt/posix/memory: group umm devices in a single class

---

 kernel/cobalt/posix/memory.c |   63 ++
 1 file changed, 20 insertions(+), 43 deletions(-)

diff --git a/kernel/cobalt/posix/memory.c b/kernel/cobalt/posix/memory.c
index 92ba6fd..7a5047d 100644
--- a/kernel/cobalt/posix/memory.c
+++ b/kernel/cobalt/posix/memory.c
@@ -34,10 +34,6 @@
 struct xnvdso *nkvdso;
 EXPORT_SYMBOL_GPL(nkvdso);
 
-static struct rtdm_device private_umm_device;
-
-static struct rtdm_device shared_umm_device;
-
 static void umm_vmopen(struct vm_area_struct *vma)
 {
struct cobalt_umm *umm = vma->vm_private_data;
@@ -65,7 +61,7 @@ static struct cobalt_umm *umm_from_fd(struct rtdm_fd *fd)
if (process == NULL)
return NULL;
 
-   if (rtdm_fd_device(fd) == &private_umm_device)
+   if (rtdm_fd_minor(fd) == UMM_PRIVATE)
return &process->sys_ppd.umm;
 
return &__xnsys_global_ppd.umm;
@@ -209,13 +205,13 @@ static int sysmem_ioctl_nrt(struct rtdm_fd *fd,
return do_sysmem_ioctls(fd, request, arg);
 }
 
-static struct rtdm_device_class private_umm = {
-   .profile_info   =   RTDM_PROFILE_INFO(private_umm,
+static struct rtdm_device_class umm = {
+   .profile_info   =   RTDM_PROFILE_INFO(umm,
  RTDM_CLASS_MEMORY,
- UMM_PRIVATE,
+ RTDM_SUBCLASS_GENERIC,
  0),
.device_flags   =   RTDM_NAMED_DEVICE,
-   .device_count   =   1,
+   .device_count   =   2,
.context_size   =   0,
.ops = {
.ioctl_rt   =   umm_ioctl_rt,
@@ -225,38 +221,19 @@ static struct rtdm_device_class private_umm = {
},
.driver_name=   "memdev",
.driver_version =   RTDM_DRIVER_VER(1, 0, 0),
-   .peripheral_name=   "Private user-mapped heap",
+   .peripheral_name=   "User-mapped heap",
.provider_name  =   "Philippe Gerum ",
 };
 
-static struct rtdm_device private_umm_device = {
-   .class = &private_umm,
-   .label = COBALT_MEMDEV_PRIVATE,
-};
-
-static struct rtdm_device_class shared_umm = {
-   .profile_info   =   RTDM_PROFILE_INFO(shared_umm,
- RTDM_CLASS_MEMORY,
- UMM_SHARED,
- 0),
-   .device_flags   =   RTDM_NAMED_DEVICE,
-   .device_count   =   1,
-   .context_size   =   0,
-   .ops = {
-   .ioctl_rt   =   umm_ioctl_rt,
-   .ioctl_nrt  =   umm_ioctl_nrt,
-   .mmap   =   umm_mmap,
-   .get_unmapped_area  =   umm_get_unmapped_area,
+static struct rtdm_device umm_devices[] = {
+   [ UMM_PRIVATE ] = {
+   .class = &umm,
+   .label = COBALT_MEMDEV_PRIVATE,
+   },
+   [ UMM_SHARED ] = {
+   .class = &umm,
+   .label = COBALT_MEMDEV_SHARED,
},
-   .driver_name=   "memdev",
-   .driver_version =   RTDM_DRIVER_VER(1, 0, 0),
-   .peripheral_name=   "Shared user-mapped heap",
-   .provider_name  =   "Philippe Gerum ",
-};
-
-static struct rtdm_device shared_umm_device = {
-   .class = &shared_umm,
-   .label = COBALT_MEMDEV_SHARED,
 };
 
 static struct rtdm_device_class sysmem = {
@@ -308,11 +285,11 @@ int cobalt_memdev_init(void)
 
init_vdso();
 
-   ret = rtdm_dev_register(&private_umm_device);
+   ret = rtdm_dev_register(umm_devices + UMM_PRIVATE);
if (ret)
goto fail_private;
 
-   ret = rtdm_dev_register(&shared_umm_device);
+   ret = rtdm_dev_register(umm_devices + UMM_SHARED);
if (ret)
goto fail_shared;
 
@@ -323,9 +300,9 @@ int cobalt_memdev_init(void)
return 0;
 
 fail_sysmem:
-   rtdm_dev_unregister(&shared_umm_device, 0);
+   rtdm_dev_unregister(umm_devices + UMM_SHARED, 0);
 fail_shared:
-   rtdm_dev_unregister(&private_umm_device, 0);
+   rtdm_dev_unregister(umm_devices + UMM_PRIVATE, 0);
 fail_private:
cobalt_umm_free(&__xnsys_global_ppd.umm, nkvdso);
 fail_vdso:
@@ -337,8 +314,8 @@ fail_vdso:
 void cobalt_memdev_cleanup(void)
 {
rtdm_dev_unregister(&sysmem_device, 0);
-   rtdm_dev_unregister(&shared_umm_device, 0);
-   rtdm_dev_unregister(&private_umm_device, 0);
+   rtd

[Xenomai-git] Philippe Gerum : cobalt/posix/process: fix access to stale memory

2014-09-21 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: dafd7e7dfaf971842edf967c4177faf2a1708225
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=dafd7e7dfaf971842edf967c4177faf2a1708225

Author: Philippe Gerum 
Date:   Sun Sep 21 12:51:08 2014 +0200

cobalt/posix/process: fix access to stale memory

---

 kernel/cobalt/posix/process.c |   44 -
 1 file changed, 13 insertions(+), 31 deletions(-)

diff --git a/kernel/cobalt/posix/process.c b/kernel/cobalt/posix/process.c
index c79c8d7..3c72db8 100644
--- a/kernel/cobalt/posix/process.c
+++ b/kernel/cobalt/posix/process.c
@@ -172,28 +172,6 @@ static void *lookup_context(int xid)
return priv;
 }
 
-static int enter_personality(struct cobalt_process *process,
-struct xnthread_personality *personality)
-{
-   if (personality->module && !try_module_get(personality->module))
-   return -EAGAIN;
-
-   __set_bit(personality->xid, &process->permap);
-   atomic_inc(&personality->refcnt);
-
-   return 0;
-}
-
-static void leave_personality(struct cobalt_process *process,
- struct xnthread_personality *personality)
-{
-   __clear_bit(personality->xid, &process->permap);
-   atomic_dec(&personality->refcnt);
-   XENO_ASSERT(COBALT, atomic_read(&personality->refcnt) >= 0);
-   if (personality->module)
-   module_put(personality->module);
-}
-
 static void remove_process(struct cobalt_process *process)
 {
struct xnthread_personality *personality;
@@ -207,16 +185,20 @@ static void remove_process(struct cobalt_process *process)
continue;
personality = cobalt_personalities[xid];
priv = process->priv[xid];
+   if (priv == NULL)
+   continue;
/*
 * CAUTION: process potentially refers to stale memory
 * upon return from detach_process() for the Cobalt
 * personality, so don't dereference it afterwards.
 */
-   if (priv) {
-   process->priv[xid] = NULL;
-   personality->ops.detach_process(priv);
-   leave_personality(process, personality);
-   }
+   process->priv[xid] = NULL;
+   __clear_bit(personality->xid, &process->permap);
+   personality->ops.detach_process(priv);
+   atomic_dec(&personality->refcnt);
+   XENO_ASSERT(COBALT, atomic_read(&personality->refcnt) >= 0);
+   if (personality->module)
+   module_put(personality->module);
}
 
cobalt_set_process(NULL);
@@ -295,7 +277,6 @@ static int bind_personality(struct xnthread_personality 
*personality)
 {
struct cobalt_process *process;
void *priv;
-   int ret;
 
/*
 * We also check capabilities for stacking a Cobalt extension,
@@ -323,12 +304,13 @@ static int bind_personality(struct xnthread_personality 
*personality)
 * safely bump the module refcount after the attach handler
 * has returned.
 */
-   ret = enter_personality(process, personality);
-   if (ret) {
+   if (personality->module && !try_module_get(personality->module)) {
personality->ops.detach_process(priv);
-   return ret;
+   return -EAGAIN;
}
 
+   __set_bit(personality->xid, &process->permap);
+   atomic_inc(&personality->refcnt);
process->priv[personality->xid] = priv;
 
raise_cap(CAP_SYS_NICE);


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


[Xenomai-git] Philippe Gerum : cobalt/rtdm/core: enable legacy pathnames for named devices

2014-09-21 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: 7d7a1936a2968b1f5415651725835e7790afcbbf
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=7d7a1936a2968b1f5415651725835e7790afcbbf

Author: Philippe Gerum 
Date:   Sun Sep 21 10:16:43 2014 +0200

cobalt/rtdm/core: enable legacy pathnames for named devices

---

 kernel/cobalt/rtdm/core.c |   48 -
 kernel/drivers/Kconfig|   21 
 2 files changed, 68 insertions(+), 1 deletion(-)

diff --git a/kernel/cobalt/rtdm/core.c b/kernel/cobalt/rtdm/core.c
index 896f139..f5c82f7 100644
--- a/kernel/cobalt/rtdm/core.c
+++ b/kernel/cobalt/rtdm/core.c
@@ -96,6 +96,40 @@ static int create_instance(int ufd, struct rtdm_device *dev,
return rtdm_fd_enter(&context->fd, ufd, RTDM_FD_MAGIC, &dev->ops);
 }
 
+#ifdef CONFIG_XENO_OPT_RTDM_COMPAT_DEVNODE
+
+static inline struct file *
+open_devnode(struct rtdm_device *dev, const char *path, int oflag)
+{
+   struct file *filp;
+   char *filename;
+
+#ifdef CONFIG_XENO_OPT_DEBUG_USER
+   if (strncmp(path, "/dev/rtdm/", 10))
+   printk(XENO_WARN
+  "%s[%d] opens obsolete device path: %s\n",
+  current->comm, current->pid, path);
+#endif
+   filename = kasprintf(GFP_KERNEL, "/dev/rtdm/%s", dev->name);
+   if (filename == NULL)
+   return ERR_PTR(-ENOMEM);
+
+   filp = filp_open(filename, oflag, 0);
+   kfree(filename);
+
+   return filp;
+}
+
+#else /* !CONFIG_XENO_OPT_RTDM_COMPAT_DEVNODE */
+
+static inline struct file *
+open_devnode(struct rtdm_device *dev, const char *path, int oflag)
+{
+   return filp_open(path, oflag, 0);
+}
+
+#endif /* !CONFIG_XENO_OPT_RTDM_COMPAT_DEVNODE */
+
 int __rtdm_dev_open(const char *path, int oflag)
 {
struct rtdm_dev_context *context;
@@ -105,6 +139,18 @@ int __rtdm_dev_open(const char *path, int oflag)
 
secondary_mode_only();
 
+   /*
+* CAUTION: we do want a lookup into the registry to happen
+* before any attempt is made to open the devnode, so that we
+* don't inadvertently open a regular (i.e. non-RTDM) device.
+* Reason is that opening, then closing a device - because we
+* don't manage it - may incur side-effects we don't want,
+* e.g. opening then closing one end of a pipe would cause the
+* other side to read the EOF condition.  This is basically
+* why we keep a RTDM registry for named devices, so that we
+* can figure out whether an open() request is going to be
+* valid, without having to open the devnode yet.
+*/
dev = __rtdm_get_namedev(path);
if (dev == NULL)
return -ENODEV;
@@ -115,7 +161,7 @@ int __rtdm_dev_open(const char *path, int oflag)
goto fail_fd;
}
 
-   filp = filp_open(path, oflag, 0);
+   filp = open_devnode(dev, path, oflag);
if (IS_ERR(filp)) {
ret = PTR_ERR(filp);
goto fail_fopen;
diff --git a/kernel/drivers/Kconfig b/kernel/drivers/Kconfig
index 5496f30..a01eb8c 100644
--- a/kernel/drivers/Kconfig
+++ b/kernel/drivers/Kconfig
@@ -1,5 +1,26 @@
 menu "Drivers"
 
+config XENO_OPT_RTDM_COMPAT_DEVNODE
+bool "Enable legacy pathnames for named RTDM devices"
+   default y
+   help
+
+   This compatibility option allows applications to open named
+   RTDM devices using the legacy naming scheme, i.e.
+
+   fd = open("devname", ...);
+  or
+   fd = open("/dev/devname", ...);
+
+   When such a request is received by RTDM, a warning message is
+   issued to the kernel log whenever XENO_OPT_DEBUG_USER is
+   also enabled in the kernel configuration.
+
+   Applications should open named devices via their actual device
+   nodes instead, i.e.
+
+   fd = open("/dev/rtdm/devname", ...);
+
 source "drivers/xenomai/autotune/Kconfig"
 source "drivers/xenomai/serial/Kconfig"
 source "drivers/xenomai/testing/Kconfig"


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


[Xenomai-git] Philippe Gerum : cobalt/rtdm/device: replace legacy sema4 with kernel mutex

2014-09-21 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: dab5f2ebe935a9fb57252dd8144573b6ca44839d
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=dab5f2ebe935a9fb57252dd8144573b6ca44839d

Author: Philippe Gerum 
Date:   Sat Sep 20 19:12:14 2014 +0200

cobalt/rtdm/device: replace legacy sema4 with kernel mutex

---

 kernel/cobalt/rtdm/device.c |   19 ---
 kernel/cobalt/rtdm/fd.c |1 -
 2 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/kernel/cobalt/rtdm/device.c b/kernel/cobalt/rtdm/device.c
index 98ff9cd..2111420 100644
--- a/kernel/cobalt/rtdm/device.c
+++ b/kernel/cobalt/rtdm/device.c
@@ -20,9 +20,8 @@
  */
 #include 
 #include 
-#include 
+#include 
 #include 
-#include 
 #include 
 #include "rtdm/internal.h"
 #include 
@@ -49,7 +48,7 @@
 
 static struct list_head named_devices;
 static struct rb_root protocol_devices;
-static struct semaphore nrt_dev_lock;
+static DEFINE_MUTEX(register_lock);
 DEFINE_PRIVATE_XNLOCK(rt_dev_lock);
 
 static struct class *rtdm_class;
@@ -304,14 +303,14 @@ int rtdm_dev_register(struct rtdm_device *device)
if (!realtime_core_enabled())
return -ENOSYS;
 
-   down(&nrt_dev_lock);
+   mutex_lock(®ister_lock);
 
device->name = NULL;
drv = device->driver;
pos = atomic_read(&drv->refcount);
ret = register_driver(drv);
if (ret) {
-   up(&nrt_dev_lock);
+   mutex_unlock(®ister_lock);
return ret;
}
 
@@ -386,7 +385,7 @@ int rtdm_dev_register(struct rtdm_device *device)
device->kdev = kdev;
device->magic = RTDM_DEVICE_MAGIC;
 
-   up(&nrt_dev_lock);
+   mutex_unlock(®ister_lock);
 
trace_cobalt_device_register(device);
 
@@ -397,7 +396,7 @@ fail:
 
unregister_driver(drv);
 
-   up(&nrt_dev_lock);
+   mutex_unlock(®ister_lock);
 
if (device->name)
kfree(device->name);
@@ -433,7 +432,7 @@ void rtdm_dev_unregister(struct rtdm_device *device)
wait_event(device->putwq,
   atomic_read(&device->refcount) == 0);
 
-   down(&nrt_dev_lock);
+   mutex_lock(®ister_lock);
xnlock_get_irqsave(&rt_dev_lock, s);
 
if (drv->device_flags & RTDM_NAMED_DEVICE) {
@@ -451,7 +450,7 @@ void rtdm_dev_unregister(struct rtdm_device *device)
 
unregister_driver(drv);
 
-   up(&nrt_dev_lock);
+   mutex_unlock(®ister_lock);
 
kfree(device->name);
 }
@@ -461,8 +460,6 @@ EXPORT_SYMBOL_GPL(rtdm_dev_unregister);
 
 int __init rtdm_init(void)
 {
-   sema_init(&nrt_dev_lock, 1);
-
INIT_LIST_HEAD(&named_devices);
xntree_init(&protocol_devices);
 
diff --git a/kernel/cobalt/rtdm/fd.c b/kernel/cobalt/rtdm/fd.c
index 38e712c..8829c44 100644
--- a/kernel/cobalt/rtdm/fd.c
+++ b/kernel/cobalt/rtdm/fd.c
@@ -23,7 +23,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 


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


[Xenomai-git] Philippe Gerum : cobalt/rtdm: group all RTDM devices into a generic sysfs class

2014-09-21 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: 1d82566c28932b825cb39c7efc202a9504d1a8e9
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=1d82566c28932b825cb39c7efc202a9504d1a8e9

Author: Philippe Gerum 
Date:   Fri Sep 19 11:39:08 2014 +0200

cobalt/rtdm: group all RTDM devices into a generic sysfs class

All RTDM device classes are supposed to be unique within the RTDM
namespace, but RTDM class names might conflict with regular device
class names. Move all RTDM devices under the generic /sys/class/rtdm
hierarchy to prevent namespace clashes.

---

 include/cobalt/kernel/rtdm/driver.h |1 -
 kernel/cobalt/rtdm/device.c |   41 +++
 2 files changed, 18 insertions(+), 24 deletions(-)

diff --git a/include/cobalt/kernel/rtdm/driver.h 
b/include/cobalt/kernel/rtdm/driver.h
index da5bcbd..9db9e1b 100644
--- a/include/cobalt/kernel/rtdm/driver.h
+++ b/include/cobalt/kernel/rtdm/driver.h
@@ -258,7 +258,6 @@ struct rtdm_device_class {
int major;
} named;
};
-   struct class *kclass;
atomic_t refcount;
};
 };
diff --git a/kernel/cobalt/rtdm/device.c b/kernel/cobalt/rtdm/device.c
index b381950..69de887 100644
--- a/kernel/cobalt/rtdm/device.c
+++ b/kernel/cobalt/rtdm/device.c
@@ -40,6 +40,8 @@ struct rb_root rtdm_protocol_devices;
 struct semaphore nrt_dev_lock;
 DEFINE_XNLOCK(rt_dev_lock);
 
+static struct class *rtdm_class;
+
 static int enosys(void)
 {
return -ENOSYS;
@@ -187,7 +189,6 @@ ATTRIBUTE_GROUPS(rtdm);
 
 static int register_device_class(struct rtdm_device_class *class)
 {
-   struct class *kclass;
dev_t rdev;
int ret;
 
@@ -210,26 +211,15 @@ static int register_device_class(struct rtdm_device_class 
*class)
if (class->device_count <= 0)
return -EINVAL;
 
-   kclass = class_create(THIS_MODULE, class->profile_info.name);
-   if (IS_ERR(kclass)) {
-   printk(XENO_WARN "cannot create device class %s\n",
-  class->profile_info.name);
-   return PTR_ERR(kclass);
-   }
-   kclass->dev_groups = rtdm_groups;
-   class->kclass = kclass;
-
if ((class->device_flags & RTDM_NAMED_DEVICE) == 0)
goto done;
 
-   kclass->devnode = rtdm_devnode;
-
ret = alloc_chrdev_region(&rdev, 0, class->device_count,
  class->profile_info.name);
if (ret) {
printk(XENO_WARN "cannot allocate chrdev region %s[0..%d]\n",
   class->profile_info.name, class->device_count - 1);
-   goto fail_chrdev;
+   return ret;
}
 
cdev_init(&class->named.cdev, &rtdm_dumb_fops);
@@ -246,8 +236,6 @@ done:
 
 fail_cdev:
unregister_chrdev_region(rdev, class->device_count);
-fail_chrdev:
-   class_destroy(kclass);
 
return ret;
 }
@@ -264,8 +252,6 @@ static void unregister_device_class(struct 
rtdm_device_class *class)
unregister_chrdev_region(MKDEV(class->named.major, 0),
 class->device_count);
}
-
-   class_destroy(class->kclass);
 }
 
 /**
@@ -360,7 +346,7 @@ int rtdm_dev_register(struct rtdm_device *device)
goto fail;
 
rdev = MKDEV(major, minor);
-   kdev = device_create(class->kclass, NULL, rdev,
+   kdev = device_create(rtdm_class, NULL, rdev,
 device, device->label, minor);
if (IS_ERR(kdev)) {
xnregistry_remove(device->named.handle);
@@ -379,7 +365,7 @@ int rtdm_dev_register(struct rtdm_device *device)
}
 
rdev = MKDEV(0, 0);
-   kdev = device_create(class->kclass, NULL, rdev,
+   kdev = device_create(rtdm_class, NULL, rdev,
 device, device->name);
if (IS_ERR(kdev)) {
ret = PTR_ERR(kdev);
@@ -405,7 +391,7 @@ int rtdm_dev_register(struct rtdm_device *device)
return 0;
 fail:
if (kdev)
-   device_destroy(class->kclass, rdev);
+   device_destroy(rtdm_class, rdev);
 
unregister_device_class(class);
 
@@ -462,7 +448,7 @@ void rtdm_dev_unregister(struct rtdm_device *device)
if (handle)
xnregistry_remove(handle);
 
-   device_destroy(class->kclass, device->rdev);
+   device_destroy(rtdm_class, device->rdev);
 
unregister_device_class(class);
 
@@ -484,14 +470,23 @@ int __init rtdm_dev_init(void)
INIT_LIST_HEAD(&rtdm_named_devices);
xntree_init(&rtdm_protocol_devices);
 
+   rtdm_class = class_create(THIS_MODULE, "rtdm");
+   if (IS_ERR(rtdm_class)) {
+   printk(XENO_ERR "cannot create RTDM sysfs class\n");
+   return PTR_ERR(rtdm_class);
+   }
+ 

[Xenomai-git] Philippe Gerum : utils/analogy: drop reference to obsolete procfs information

2014-09-21 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: 386681949cdea45433b1c0ef9e0061718e98d941
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=386681949cdea45433b1c0ef9e0061718e98d941

Author: Philippe Gerum 
Date:   Sat Sep 20 19:02:50 2014 +0200

utils/analogy: drop reference to obsolete procfs information

---

 utils/analogy/analogy_config.c |5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/utils/analogy/analogy_config.c b/utils/analogy/analogy_config.c
index 73ee39d..66c9cb3 100644
--- a/utils/analogy/analogy_config.c
+++ b/utils/analogy/analogy_config.c
@@ -29,7 +29,6 @@
 #include 
 #include 
 
-#define RTDM_DEVICES_PROC"/proc/xenomai/rtdm/named_devices"
 #define ANALOGY_DRIVERS_PROC "/proc/analogy/drivers"
 #define ANALOGY_DEVICES_PROC "/proc/analogy/devices"
 
@@ -294,11 +293,9 @@ int main(int argc, char *argv[])
 done:
 if (err < 0)
fprintf(stderr,
-   "analogy_config: chek the rtdm and analogy procs \n"
-   " - rtdm devices:%s \n"
+   "analogy_config: check the procfs information:\n"
" - analogy devices: %s \n"
" - analogy drivers: %s \n",
-   RTDM_DEVICES_PROC,
ANALOGY_DEVICES_PROC,
ANALOGY_DRIVERS_PROC);
 


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


[Xenomai-git] Philippe Gerum : cobalt/rtdm, lib/cobalt: unify file descriptor management

2014-09-21 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: 90f104d2c6a3ae9b0e65529683278bdf98b18310
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=90f104d2c6a3ae9b0e65529683278bdf98b18310

Author: Philippe Gerum 
Date:   Sat Sep 20 11:09:04 2014 +0200

cobalt/rtdm, lib/cobalt: unify file descriptor management

Use regular kernel file descriptors for all kinds of connection
handles, referring to regular file objects:

- connection to devnode => filp on chrdev inode
- socket => filp on anon inode

User and kernel-originated connection handles are no more
differenciated.

The former procfs interface for RTDM is now entirely gone, as all file
descriptors are now visible from /proc//fd.

Obtaining the list of all named devices can be done this way:

$ grep named /sys/class/rtdm/*/flags

Similarly, the list of all protocol devices can be obtained this way:

$ grep protocol /sys/class/rtdm/*/flags

Force closing a stuck file descriptor (formerly done by writing to
rtdm/open_fildes) makes no sense anymore. Either the owner is a
userland process and all file handles it holds will be automatically
dropped at exit, or it is a kernel driver, in which case the driver
direly needs fixing.

---

 include/cobalt/kernel/rtdm/fd.h   |   11 +-
 include/cobalt/kernel/rtdm/rtdm.h |   12 +-
 kernel/cobalt/Kconfig |   10 --
 kernel/cobalt/posix/io.c  |2 +-
 kernel/cobalt/posix/mqueue.c  |9 +-
 kernel/cobalt/posix/timerfd.c |   10 +-
 kernel/cobalt/rtdm/Makefile   |5 +-
 kernel/cobalt/rtdm/core.c |  157 +---
 kernel/cobalt/rtdm/device.c   |   16 +-
 kernel/cobalt/rtdm/fd.c   |   67 +
 kernel/cobalt/rtdm/init.c |   58 
 kernel/cobalt/rtdm/internal.h |   33 +
 kernel/cobalt/rtdm/proc.c |  295 -
 lib/cobalt/mq.c   |9 +-
 lib/cobalt/rtdm.c |   43 +++---
 15 files changed, 106 insertions(+), 631 deletions(-)

diff --git a/include/cobalt/kernel/rtdm/fd.h b/include/cobalt/kernel/rtdm/fd.h
index d4a97b2..c04cd4d 100644
--- a/include/cobalt/kernel/rtdm/fd.h
+++ b/include/cobalt/kernel/rtdm/fd.h
@@ -302,7 +302,11 @@ struct rtdm_fd {
struct list_head cleanup;
 };
 
-#define XNFD_MAGIC_ANY 0
+#define RTDM_FD_MAGIC 0x5256
+
+int __rtdm_anon_getfd(const char *name, int flags);
+
+void __rtdm_anon_putfd(int ufd);
 
 static inline struct xnsys_ppd *rtdm_fd_owner(struct rtdm_fd *fd)
 {
@@ -331,9 +335,6 @@ ssize_t rtdm_fd_read(int ufd, void __user *buf, size_t 
size);
 
 ssize_t rtdm_fd_write(int ufd, const void __user *buf, size_t size);
 
-int __rtdm_fd_close(struct xnsys_ppd *ppd,
-   int ufd, unsigned int magic);
-
 int rtdm_fd_close(int ufd, unsigned int magic);
 
 ssize_t rtdm_fd_recvmsg(int ufd, struct msghdr *msg, int flags);
@@ -353,6 +354,4 @@ void rtdm_fd_cleanup(struct xnsys_ppd *p);
 
 void rtdm_fd_init(void);
 
-extern const struct file_operations rtdm_dumb_fops;
-
 #endif /* _COBALT_KERNEL_FD_H */
diff --git a/include/cobalt/kernel/rtdm/rtdm.h 
b/include/cobalt/kernel/rtdm/rtdm.h
index b1ffab3..b3a25b4 100644
--- a/include/cobalt/kernel/rtdm/rtdm.h
+++ b/include/cobalt/kernel/rtdm/rtdm.h
@@ -28,14 +28,12 @@
 #include 
 #include 
 
-#define RTDM_FD_MAGIC 0x5256
-
 typedef u32 socklen_t;
 
-int __rtdm_dev_kopen(const char *path, int oflag);
+int __rtdm_dev_open(const char *path, int oflag);
 
-int __rtdm_dev_ksocket(int protocol_family, int socket_type,
-  int protocol);
+int __rtdm_dev_socket(int protocol_family,
+ int socket_type, int protocol);
 
 int
 __rt_dev_ioctl_fallback(struct rtdm_fd *fd, unsigned request, void __user 
*arg);
@@ -47,10 +45,10 @@ __rt_dev_ioctl_fallback(struct rtdm_fd *fd, unsigned 
request, void __user *arg);
 #ifndef RTDM_NO_DEFAULT_USER_API
 
 #define rt_dev_open(path, oflag, ...)  \
-   __rtdm_dev_kopen(path, oflag)
+   __rtdm_dev_open(path, oflag)
 
 #define rt_dev_socket(protocol_family, socket_type, protocol)  \
-   __rtdm_dev_ksocket(protocol_family, socket_type, protocol)
+   __rtdm_dev_socket(protocol_family, socket_type, protocol)
 
 #define rt_dev_close(fd)   \
rtdm_fd_close(fd, RTDM_FD_MAGIC)
diff --git a/kernel/cobalt/Kconfig b/kernel/cobalt/Kconfig
index 6301437..8937d75 100644
--- a/kernel/cobalt/Kconfig
+++ b/kernel/cobalt/Kconfig
@@ -340,16 +340,6 @@ config XENO_OPT_NRTIMERS
given time for each Cobalt process (a timer is created by a
call to the timer_create() service of the Cobalt/POSIX API).
 
-config XENO_OPT_RTDM_FILDES
-   int "Maximum number of RTDM file descriptors"
-   default 128
-   help
-
-   This option defines the system-wide maximum number of RTDM
-   file descriptors which can be opened at the same time (a file
-   descriptor is created by each successful call to the open()
-   service of th

[Xenomai-git] Philippe Gerum : cobalt/rtdm: remove legacy /proc device entries

2014-09-21 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: 77ef96432838eef12d0a3cbda0757f34d558c9e5
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=77ef96432838eef12d0a3cbda0757f34d558c9e5

Author: Philippe Gerum 
Date:   Thu Sep 18 18:53:17 2014 +0200

cobalt/rtdm: remove legacy /proc device entries

As device information is now exported via sysfs, we don't need procfs
support anymore.

---

 include/cobalt/kernel/rtdm/driver.h |5 ---
 kernel/cobalt/rtdm/device.c |   21 -
 kernel/cobalt/rtdm/internal.h   |6 ---
 kernel/cobalt/rtdm/proc.c   |   83 ---
 4 files changed, 115 deletions(-)

diff --git a/include/cobalt/kernel/rtdm/driver.h 
b/include/cobalt/kernel/rtdm/driver.h
index 2896e3d..765f557 100644
--- a/include/cobalt/kernel/rtdm/driver.h
+++ b/include/cobalt/kernel/rtdm/driver.h
@@ -35,7 +35,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -349,10 +348,6 @@ struct rtdm_device {
atomic_t refcount;
struct rtdm_dev_context *exclusive_context;
struct rtdm_fd_ops ops;
-#ifdef CONFIG_XENO_OPT_VFILE
-   struct xnvfile_directory vfroot;
-   struct xnvfile_regular info_vfile;
-#endif
};
 };
 
diff --git a/kernel/cobalt/rtdm/device.c b/kernel/cobalt/rtdm/device.c
index 131c9f1..5b87b8c 100644
--- a/kernel/cobalt/rtdm/device.c
+++ b/kernel/cobalt/rtdm/device.c
@@ -283,13 +283,9 @@ static void unregister_device_class(struct 
rtdm_device_class *class)
  * - -EEXIST is returned if the specified device name of protocol ID is
  * already in use.
  *
- * - -EAGAIN is returned if some /proc entry cannot be created.
- *
  * - -ENOMEM is returned if a memory allocation failed in the process
  * of registering the device.
  *
- * - -EAGAIN is returned if some /proc entry cannot be created.
- *
  * @coretags{secondary-only}
  */
 int rtdm_dev_register(struct rtdm_device *device)
@@ -368,11 +364,6 @@ int rtdm_dev_register(struct rtdm_device *device)
xnlock_get_irqsave(&rt_dev_lock, s);
list_add_tail(&device->named.entry, &rtdm_named_devices);
xnlock_put_irqrestore(&rt_dev_lock, s);
-
-   ret = rtdm_proc_register_device(device);
-   if (ret)
-   goto fail_proc;
-
} else {
device->name = kstrdup(device->label, GFP_KERNEL);
if (device->name == NULL) {
@@ -394,14 +385,6 @@ int rtdm_dev_register(struct rtdm_device *device)
xnlock_put_irqrestore(&rt_dev_lock, s);
if (ret < 0)
goto fail;
-
-   ret = rtdm_proc_register_device(device);
-   if (ret) {
-   xnlock_get_irqsave(&rt_dev_lock, s);
-   xnid_remove(&rtdm_protocol_devices, &device->proto.id);
-   xnlock_put_irqrestore(&rt_dev_lock, s);
-   goto fail;
-   }
}
 
device->rdev = rdev;
@@ -412,8 +395,6 @@ int rtdm_dev_register(struct rtdm_device *device)
trace_cobalt_device_register(device);
 
return 0;
-fail_proc:
-   xnregistry_remove(device->named.handle);
 fail:
if (kdev)
device_destroy(class->kclass, rdev);
@@ -487,8 +468,6 @@ int rtdm_dev_unregister(struct rtdm_device *device, 
unsigned int poll_delay)
 
xnlock_put_irqrestore(&rt_dev_lock, s);
 
-   rtdm_proc_unregister_device(device);
-
if (handle)
xnregistry_remove(handle);
 
diff --git a/kernel/cobalt/rtdm/internal.h b/kernel/cobalt/rtdm/internal.h
index 06c78a6..fa728ed 100644
--- a/kernel/cobalt/rtdm/internal.h
+++ b/kernel/cobalt/rtdm/internal.h
@@ -53,15 +53,9 @@ void rtdm_dev_cleanup(void);
 #ifdef CONFIG_XENO_OPT_VFILE
 int rtdm_proc_init(void);
 void rtdm_proc_cleanup(void);
-int rtdm_proc_register_device(struct rtdm_device *device);
-void rtdm_proc_unregister_device(struct rtdm_device *device);
 #else
 static inline int rtdm_proc_init(void) { return 0; }
 static void inline rtdm_proc_cleanup(void) { }
-static inline int
-rtdm_proc_register_device(struct rtdm_device *device) { return 0; }
-static inline void
-rtdm_proc_unregister_device(struct rtdm_device *device) { }
 #endif
 
 void __rt_dev_close(struct rtdm_fd *fd);
diff --git a/kernel/cobalt/rtdm/proc.c b/kernel/cobalt/rtdm/proc.c
index dbc582f..87b279b 100644
--- a/kernel/cobalt/rtdm/proc.c
+++ b/kernel/cobalt/rtdm/proc.c
@@ -249,89 +249,6 @@ static struct xnvfile_regular allfd_vfile = {
.ops = &allfd_vfile_ops,
 };
 
-static int devinfo_vfile_show(struct xnvfile_regular_iterator *it, void *data)
-{
-   struct rtdm_device_class *class;
-   struct rtdm_device *device;
-
-   if (down_interruptible(&nrt_dev_lock))
-   return -ERESTARTSYS;
-
-   /*
-* As the device may have disappeared while the handler was called,
-* first match the point

[Xenomai-git] Philippe Gerum : config: bump ABI revision levels

2014-09-21 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: a1dbf5a9e61ace9f54606ad1daa106953ffdcc68
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=a1dbf5a9e61ace9f54606ad1daa106953ffdcc68

Author: Philippe Gerum 
Date:   Mon Sep  8 21:19:01 2014 +0200

config: bump ABI revision levels

---

 kernel/cobalt/arch/arm/include/asm/xenomai/uapi/features.h  |2 +-
 kernel/cobalt/arch/blackfin/include/asm/xenomai/uapi/features.h |2 +-
 kernel/cobalt/arch/nios2/include/asm/xenomai/uapi/features.h|2 +-
 kernel/cobalt/arch/powerpc/include/asm/xenomai/uapi/features.h  |2 +-
 kernel/cobalt/arch/sh/include/asm/xenomai/uapi/features.h   |2 +-
 kernel/cobalt/arch/x86/include/asm/xenomai/uapi/features.h  |2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/kernel/cobalt/arch/arm/include/asm/xenomai/uapi/features.h 
b/kernel/cobalt/arch/arm/include/asm/xenomai/uapi/features.h
index acf10a9..1a3baca 100644
--- a/kernel/cobalt/arch/arm/include/asm/xenomai/uapi/features.h
+++ b/kernel/cobalt/arch/arm/include/asm/xenomai/uapi/features.h
@@ -22,7 +22,7 @@
 #define _COBALT_ARM_ASM_UAPI_FEATURES_H
 
 /* The ABI revision level we use on this arch. */
-#define XENOMAI_ABI_REV   9UL
+#define XENOMAI_ABI_REV   10UL
 
 #define XENOMAI_FEAT_DEP (__xn_feat_generic_mask)
 
diff --git a/kernel/cobalt/arch/blackfin/include/asm/xenomai/uapi/features.h 
b/kernel/cobalt/arch/blackfin/include/asm/xenomai/uapi/features.h
index 5300ca7..aaabe1b 100644
--- a/kernel/cobalt/arch/blackfin/include/asm/xenomai/uapi/features.h
+++ b/kernel/cobalt/arch/blackfin/include/asm/xenomai/uapi/features.h
@@ -19,7 +19,7 @@
 #define _COBALT_BLACKFIN_ASM_UAPI_FEATURES_H
 
 /* The ABI revision level we use on this arch. */
-#define XENOMAI_ABI_REV   9UL
+#define XENOMAI_ABI_REV   10UL
 
 #define XENOMAI_FEAT_DEP  __xn_feat_generic_mask
 
diff --git a/kernel/cobalt/arch/nios2/include/asm/xenomai/uapi/features.h 
b/kernel/cobalt/arch/nios2/include/asm/xenomai/uapi/features.h
index 5f3985a..cfeb0c2 100644
--- a/kernel/cobalt/arch/nios2/include/asm/xenomai/uapi/features.h
+++ b/kernel/cobalt/arch/nios2/include/asm/xenomai/uapi/features.h
@@ -21,7 +21,7 @@
 #include 
 
 /* The ABI revision level we use on this arch. */
-#define XENOMAI_ABI_REV   8UL
+#define XENOMAI_ABI_REV   9UL
 
 #define XENOMAI_FEAT_DEP  __xn_feat_generic_mask
 
diff --git a/kernel/cobalt/arch/powerpc/include/asm/xenomai/uapi/features.h 
b/kernel/cobalt/arch/powerpc/include/asm/xenomai/uapi/features.h
index 2317ff2..8a2aee7 100644
--- a/kernel/cobalt/arch/powerpc/include/asm/xenomai/uapi/features.h
+++ b/kernel/cobalt/arch/powerpc/include/asm/xenomai/uapi/features.h
@@ -19,7 +19,7 @@
 #define _COBALT_POWERPC_ASM_UAPI_FEATURES_H
 
 /* The ABI revision level we use on this arch. */
-#define XENOMAI_ABI_REV   9UL
+#define XENOMAI_ABI_REV   10UL
 
 #define XENOMAI_FEAT_DEP  __xn_feat_generic_mask
 
diff --git a/kernel/cobalt/arch/sh/include/asm/xenomai/uapi/features.h 
b/kernel/cobalt/arch/sh/include/asm/xenomai/uapi/features.h
index c38c403..5d1500f 100644
--- a/kernel/cobalt/arch/sh/include/asm/xenomai/uapi/features.h
+++ b/kernel/cobalt/arch/sh/include/asm/xenomai/uapi/features.h
@@ -21,7 +21,7 @@
 #include 
 
 /* The ABI revision level we use on this arch. */
-#define XENOMAI_ABI_REV   6UL
+#define XENOMAI_ABI_REV   7UL
 
 #define XENOMAI_FEAT_DEP  __xn_feat_generic_mask
 
diff --git a/kernel/cobalt/arch/x86/include/asm/xenomai/uapi/features.h 
b/kernel/cobalt/arch/x86/include/asm/xenomai/uapi/features.h
index 5e96f85..dba7921 100644
--- a/kernel/cobalt/arch/x86/include/asm/xenomai/uapi/features.h
+++ b/kernel/cobalt/arch/x86/include/asm/xenomai/uapi/features.h
@@ -19,7 +19,7 @@
 #define _COBALT_X86_ASM_UAPI_FEATURES_H
 
 /* The ABI revision level we use on this arch. */
-#define XENOMAI_ABI_REV   9UL
+#define XENOMAI_ABI_REV   10UL
 
 #define XENOMAI_FEAT_DEP  __xn_feat_generic_mask
 


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


[Xenomai-git] Philippe Gerum : lib/cobalt/sem: fix error status upon allocation failure

2014-09-21 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: 20686366e23ccc954eb40d6c6b56f94995bcbd2b
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=20686366e23ccc954eb40d6c6b56f94995bcbd2b

Author: Philippe Gerum 
Date:   Thu Sep 11 16:37:48 2014 +0200

lib/cobalt/sem: fix error status upon allocation failure

---

 lib/cobalt/semaphore.c |7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/lib/cobalt/semaphore.c b/lib/cobalt/semaphore.c
index f97b85e..87cea44 100644
--- a/lib/cobalt/semaphore.c
+++ b/lib/cobalt/semaphore.c
@@ -459,8 +459,9 @@ COBALT_IMPL(int, sem_getvalue, (sem_t *sem, int *sval))
  *   named semaphore already exists;
  * - ENOENT, the bit @a O_CREAT is not set in @a oflags and the named semaphore
  *   does not exist;
- * - ENOSPC, insufficient memory exists in the system heap to create the
- *   semaphore, increase CONFIG_XENO_OPT_SYS_HEAPSZ;
+ * - ENOMEM, not enough memory to create the semaphore. A usual
+ *   suspect is a shortage in the Cobalt system heap, which may be
+ *   fixed by increasing CONFIG_XENO_OPT_SYS_HEAPSZ;
  * - EINVAL, the @a value argument exceeds @a SEM_VALUE_MAX.
  *
  * @see
@@ -484,7 +485,7 @@ COBALT_IMPL(sem_t *, sem_open, (const char *name, int 
oflags, ...))
 
rsem = sem = malloc(sizeof(*sem));
if (rsem == NULL) {
-   err = -ENOSPC;
+   err = -ENOMEM;
goto error;
}
 


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


[Xenomai-git] Philippe Gerum : cobalt/syscall: fix in/out value types

2014-09-21 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: 2378a7399d162a243e2bf51b96a569a10be36bb4
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=2378a7399d162a243e2bf51b96a569a10be36bb4

Author: Philippe Gerum 
Date:   Wed Sep 10 11:41:26 2014 +0200

cobalt/syscall: fix in/out value types

---

 kernel/cobalt/posix/syscall.c  |8 +---
 kernel/cobalt/trace/cobalt-posix.h |   20 ++--
 2 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/kernel/cobalt/posix/syscall.c b/kernel/cobalt/posix/syscall.c
index 7e8db89..384c13a 100644
--- a/kernel/cobalt/posix/syscall.c
+++ b/kernel/cobalt/posix/syscall.c
@@ -107,10 +107,11 @@ static void prepare_for_signal(struct task_struct *p,
 static int handle_head_syscall(struct ipipe_domain *ipd, struct pt_regs *regs)
 {
struct cobalt_process *process;
-   int nr, switched, ret, sigs;
+   int switched, ret, sigs;
struct xnthread *thread;
cobalt_syshand handler;
struct task_struct *p;
+   unsigned int nr;
int sysflags;
 
if (!__xn_syscall_p(regs))
@@ -121,7 +122,7 @@ static int handle_head_syscall(struct ipipe_domain *ipd, 
struct pt_regs *regs)
 
trace_cobalt_head_sysentry(thread, nr);
 
-   if (nr < 0 || nr >= __NR_COBALT_SYSCALLS)
+   if (nr >= __NR_COBALT_SYSCALLS)
goto bad_syscall;
 
process = cobalt_current_process();
@@ -285,10 +286,11 @@ bad_syscall:
 
 static int handle_root_syscall(struct ipipe_domain *ipd, struct pt_regs *regs)
 {
-   int nr, sysflags, switched, ret, sigs;
+   int sysflags, switched, ret, sigs;
struct xnthread *thread;
cobalt_syshand handler;
struct task_struct *p;
+   unsigned int nr;
 
/*
 * Catch cancellation requests pending for user shadows
diff --git a/kernel/cobalt/trace/cobalt-posix.h 
b/kernel/cobalt/trace/cobalt-posix.h
index f0d4e3e..a143e97 100644
--- a/kernel/cobalt/trace/cobalt-posix.h
+++ b/kernel/cobalt/trace/cobalt-posix.h
@@ -23,13 +23,13 @@
__entry->tv_sec_##__name, __entry->tv_nsec_##__name
 
 DECLARE_EVENT_CLASS(syscall_entry,
-   TP_PROTO(struct xnthread *thread, int nr),
+   TP_PROTO(struct xnthread *thread, unsigned int nr),
TP_ARGS(thread, nr),
 
TP_STRUCT__entry(
__field(struct xnthread *, thread)
__string(name, thread ? thread->name : "(anon)")
-   __field(int, nr)
+   __field(unsigned int, nr)
),
 
TP_fast_assign(
@@ -38,17 +38,17 @@ DECLARE_EVENT_CLASS(syscall_entry,
__entry->nr = nr;
),
 
-   TP_printk("thread=%p(%s) syscall=%d",
+   TP_printk("thread=%p(%s) syscall=%u",
  __entry->thread, __get_str(name), __entry->nr)
 );
 
 DECLARE_EVENT_CLASS(syscall_exit,
-   TP_PROTO(struct xnthread *thread, int result),
+   TP_PROTO(struct xnthread *thread, long result),
TP_ARGS(thread, result),
 
TP_STRUCT__entry(
__field(struct xnthread *, thread)
-   __field(int, result)
+   __field(long, result)
),
 
TP_fast_assign(
@@ -56,7 +56,7 @@ DECLARE_EVENT_CLASS(syscall_exit,
__entry->result = result;
),
 
-   TP_printk("thread=%p result=%d",
+   TP_printk("thread=%p result=%ld",
  __entry->thread, __entry->result)
 );
 
@@ -150,22 +150,22 @@ DECLARE_EVENT_CLASS(cobalt_void,
 );
 
 DEFINE_EVENT(syscall_entry, cobalt_head_sysentry,
-   TP_PROTO(struct xnthread *thread, int nr),
+   TP_PROTO(struct xnthread *thread, unsigned int nr),
TP_ARGS(thread, nr)
 );
 
 DEFINE_EVENT(syscall_exit, cobalt_head_sysexit,
-   TP_PROTO(struct xnthread *thread, int result),
+   TP_PROTO(struct xnthread *thread, long result),
TP_ARGS(thread, result)
 );
 
 DEFINE_EVENT(syscall_entry, cobalt_root_sysentry,
-   TP_PROTO(struct xnthread *thread, int nr),
+   TP_PROTO(struct xnthread *thread, unsigned int nr),
TP_ARGS(thread, nr)
 );
 
 DEFINE_EVENT(syscall_exit, cobalt_root_sysexit,
-   TP_PROTO(struct xnthread *thread, int result),
+   TP_PROTO(struct xnthread *thread, long result),
TP_ARGS(thread, result)
 );
 


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


[Xenomai-git] Philippe Gerum : cobalt/thread, cobalt/sched: cosmetic fix to kthread names

2014-09-21 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: 636f971c627f4bfc25f65a8e009cf39f8922c5f9
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=636f971c627f4bfc25f65a8e009cf39f8922c5f9

Author: Philippe Gerum 
Date:   Fri Sep 19 15:51:55 2014 +0200

cobalt/thread, cobalt/sched: cosmetic fix to kthread names

---

 kernel/cobalt/sched.c  |   13 +
 kernel/cobalt/thread.c |5 ++---
 2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/kernel/cobalt/sched.c b/kernel/cobalt/sched.c
index 465fe52..2f8d277 100644
--- a/kernel/cobalt/sched.c
+++ b/kernel/cobalt/sched.c
@@ -1008,7 +1008,7 @@ static int vfile_schedlist_show(struct 
xnvfile_snapshot_iterator *it,
xnthread_format_status(p->state, sbuf, sizeof(sbuf));
 
xnvfile_printf(it,
-  "%3u  %-6d %-5s  %-8s  %-5s %-8s  %-10s %s\n",
+  "%3u  %-6d %-5s  %-8s  %-5s %-8s  %-10s 
%s%s%s\n",
   p->cpu,
   p->pid,
   p->sched_class,
@@ -1016,7 +1016,9 @@ static int vfile_schedlist_show(struct 
xnvfile_snapshot_iterator *it,
   pbuf,
   tbuf,
   sbuf,
-  p->name);
+  (p->state & XNUSER) ? "" : "[",
+  p->name,
+  (p->state & XNUSER) ? "" : "]");
}
 
return 0;
@@ -1210,9 +1212,12 @@ static int vfile_schedstat_show(struct 
xnvfile_snapshot_iterator *it,
}
xnvfile_printf(it,
   "%3u  %-6d %-10lu %-10lu %-10lu %-4lu  %.8x  
%3u.%u"
-  "  %s\n",
+  "  %s%s%s\n",
   p->cpu, p->pid, p->ssw, p->csw, p->xsc, p->pf, 
p->state,
-  usage / 10, usage % 10, p->name);
+  usage / 10, usage % 10,
+  (p->state & XNUSER) ? "" : "[",
+  p->name,
+  (p->state & XNUSER) ? "" : "]");
}
 
return 0;
diff --git a/kernel/cobalt/thread.c b/kernel/cobalt/thread.c
index 7c2405a..f44bfe0 100644
--- a/kernel/cobalt/thread.c
+++ b/kernel/cobalt/thread.c
@@ -162,11 +162,10 @@ int __xnthread_init(struct xnthread *thread,
 
if (attr->name)
ksformat(thread->name,
-sizeof(thread->name), flags & XNUSER ?
-"%s" : "[%s]", attr->name);
+sizeof(thread->name), "%s", attr->name);
else
ksformat(thread->name,
-sizeof(thread->name), "[%p]", thread);
+sizeof(thread->name), "@%p", thread);
 
thread->personality = attr->personality;
cpus_and(thread->affinity, attr->affinity, nkaffinity);


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


[Xenomai-git] Philippe Gerum : lib/smokey: cosmetic fix in help strings

2014-09-21 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: 0d7fb07a954fd4fe903bcf65f3ce45a0f8745c6e
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=0d7fb07a954fd4fe903bcf65f3ce45a0f8745c6e

Author: Philippe Gerum 
Date:   Thu Sep 11 16:35:42 2014 +0200

lib/smokey: cosmetic fix in help strings

---

 lib/smokey/init.c |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/smokey/init.c b/lib/smokey/init.c
index a77d420..3241d45 100644
--- a/lib/smokey/init.c
+++ b/lib/smokey/init.c
@@ -278,10 +278,10 @@ static const struct option smokey_options[] = {
 
 static void smokey_help(void)
 {
-fprintf(stderr, "--keep-going   don't stop upon test 
error\n");
-fprintf(stderr, "--quietrequire tests to tame down 
verbosity\n");
-   fprintf(stderr, "--list list all tests\n");
-   fprintf(stderr, "--run[=]]  run [portion of] test 
list\n");
+fprintf(stderr, "--keep-going  don't stop upon test 
error\n");
+fprintf(stderr, "--quiet   require tests to tame 
down verbosity\n");
+   fprintf(stderr, "--list list all tests\n");
+   fprintf(stderr, "--run[=]]  run [portion of] test 
list\n");
 }
 
 static inline void pick_test_range(int start, int end)


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


[Xenomai-git] Philippe Gerum : cobalt/rtdm: export device information through sysfs

2014-09-21 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: 1860f7f61d7a065d7fbc823b8745312b2bac1d84
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=1860f7f61d7a065d7fbc823b8745312b2bac1d84

Author: Philippe Gerum 
Date:   Thu Sep 18 17:09:31 2014 +0200

cobalt/rtdm: export device information through sysfs

/sys/class/ enumerates the registered RTDM devices
which belong to this class. Device class and subclass ids, flags and
reference count are readable as sysfs attributes.

---

 include/cobalt/kernel/rtdm/driver.h |4 +-
 kernel/cobalt/rtdm/device.c |  125 ---
 2 files changed, 103 insertions(+), 26 deletions(-)

diff --git a/include/cobalt/kernel/rtdm/driver.h 
b/include/cobalt/kernel/rtdm/driver.h
index 0b4a70c..2896e3d 100644
--- a/include/cobalt/kernel/rtdm/driver.h
+++ b/include/cobalt/kernel/rtdm/driver.h
@@ -255,10 +255,10 @@ struct rtdm_device_class {
union {
struct {
struct cdev cdev;
-   struct class *kclass;
int major;
} named;
};
+   struct class *kclass;
atomic_t refcount;
};
 };
@@ -344,6 +344,8 @@ struct rtdm_device {
struct xnid id;
} proto;
};
+   dev_t rdev;
+   struct device *kdev;
atomic_t refcount;
struct rtdm_dev_context *exclusive_context;
struct rtdm_fd_ops ops;
diff --git a/kernel/cobalt/rtdm/device.c b/kernel/cobalt/rtdm/device.c
index 9825b93..131c9f1 100644
--- a/kernel/cobalt/rtdm/device.c
+++ b/kernel/cobalt/rtdm/device.c
@@ -121,6 +121,67 @@ static char *rtdm_devnode(struct device *dev, umode_t 
*mode)
return kasprintf(GFP_KERNEL, "rtdm/%s", dev_name(dev));
 }
 
+static ssize_t class_id_show(struct device *dev,
+struct device_attribute *attr, char *buf)
+{
+   struct rtdm_device *device = dev_get_drvdata(dev);
+
+   return sprintf(buf, "%d/%d\n",
+  device->class->profile_info.class_id,
+  device->class->profile_info.subclass_id);
+}
+static DEVICE_ATTR_RO(class_id);
+
+static ssize_t refcount_show(struct device *dev,
+struct device_attribute *attr, char *buf)
+{
+   struct rtdm_device *device = dev_get_drvdata(dev);
+
+   return sprintf(buf, "%d\n", atomic_read(&device->refcount));
+}
+static DEVICE_ATTR_RO(refcount);
+
+#define cat_count(__buf, __str)\
+   ({  \
+   int __ret = sizeof(__str) - 1;  \
+   strcat(__buf, __str);   \
+   __ret;  \
+   })
+
+static ssize_t flags_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+   struct rtdm_device *device = dev_get_drvdata(dev);
+   struct rtdm_device_class *class = device->class;
+   int ret;
+
+   ret = sprintf(buf, "%#x (", class->device_flags);
+   if (class->device_flags & RTDM_NAMED_DEVICE)
+   ret += cat_count(buf, "named");
+   else
+   ret += cat_count(buf, "protocol");
+
+   if (class->device_flags & RTDM_EXCLUSIVE)
+   ret += cat_count(buf, ", exclusive");
+   
+   if (class->device_flags & RTDM_SECURE_DEVICE)
+   ret += cat_count(buf, ", secure");
+   
+   ret += cat_count(buf, ")\n");
+
+   return ret;
+
+}
+static DEVICE_ATTR_RO(flags);
+
+static struct attribute *rtdm_attrs[] = {
+   &dev_attr_class_id.attr,
+   &dev_attr_refcount.attr,
+   &dev_attr_flags.attr,
+   NULL,
+};
+ATTRIBUTE_GROUPS(rtdm);
+
 static int register_device_class(struct rtdm_device_class *class)
 {
struct class *kclass;
@@ -146,15 +207,26 @@ static int register_device_class(struct rtdm_device_class 
*class)
if (class->device_count <= 0)
return -EINVAL;
 
+   kclass = class_create(THIS_MODULE, class->profile_info.name);
+   if (IS_ERR(kclass)) {
+   printk(XENO_WARN "cannot create device class %s\n",
+  class->profile_info.name);
+   return PTR_ERR(kclass);
+   }
+   kclass->dev_groups = rtdm_groups;
+   class->kclass = kclass;
+
if ((class->device_flags & RTDM_NAMED_DEVICE) == 0)
goto done;
 
+   kclass->devnode = rtdm_devnode;
+
ret = alloc_chrdev_region(&rdev, 0, class->device_count,
  class->profile_info.name);
if (ret) {
printk(XENO_WARN "cannot allocate chrdev region %s[0..%d]\n",
   class->profile_info.name, class->device_count - 1);
-   return ret;
+   goto fail_chrdev;
}
 
cdev_

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

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

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 501cdec..b35dfd4 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] Philippe Gerum : doc: fixups

2014-09-21 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: 35953fb343d58a6ad04f4cf08231bebb8730394d
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=35953fb343d58a6ad04f4cf08231bebb8730394d

Author: Philippe Gerum 
Date:   Sun Sep 21 15:04:34 2014 +0200

doc: fixups

---

 doc/asciidoc/MIGRATION.adoc |  589 ---
 doc/doxygen/xeno3prm-common.conf.in |   12 +-
 include/cobalt/kernel/rtdm/driver.h |6 +-
 include/cobalt/kernel/thread.h  |8 +-
 include/rtdm/can.h  |8 +-
 include/rtdm/serial.h   |   13 +-
 include/rtdm/testing.h  |   14 +-
 include/rtdm/uapi/ipc.h |8 +-
 kernel/cobalt/heap.c|4 +-
 kernel/cobalt/rtdm/device.c |4 +-
 kernel/drivers/can/README   |2 +-
 lib/psos/README |5 +-
 lib/trank/native.c  |2 +-
 lib/vxworks/README  |7 +-
 14 files changed, 533 insertions(+), 149 deletions(-)

diff --git a/doc/asciidoc/MIGRATION.adoc b/doc/asciidoc/MIGRATION.adoc
index f87fffb..0790e9f 100644
--- a/doc/asciidoc/MIGRATION.adoc
+++ b/doc/asciidoc/MIGRATION.adoc
@@ -361,13 +361,307 @@ rtdm/rtipc.h -> rtdm/ipc.h
 
 === Driver API ===
 
-- Changes in the +rtdm_device+ descriptor
+ New device description model 
+
+Several changes have taken place in the device description passed to
++rtdm_dev_register()+ (i.e. +struct rtdm_device+). Aside of fixing
+consistency issues, the bulk of changes is aimed at narrowing the gap
+between the regular Linux device driver model and RTDM.
+
+To this end, RTDM in Xenomai 3 shares the Linux namespace for named
+devices, which are now backed by common character device objects from
+the regular Linux device model. As a consequence of this, file
+descriptors obtained on named RTDM devices are regular file
+descriptors, visible from the +/proc//fd+ interface.
+
+= Named device description =
+
+The major change required for supporting this closer integration of
+RTDM into the regular Linux driver model involved splitting the device
+driver properties from the device instance definitions, which used to
+be combined in Xenomai 2.x into the +rtdm_device+ descriptor.
+
+.Xenomai 2.x named device description
+-
+static struct rtdm_device foo_device0 = {
+   .struct_version =   RTDM_DEVICE_STRUCT_VER,
+   .device_flags   =   RTDM_NAMED_DEVICE|RTDM_EXCLUSIVE,
+   .device_id  =   0
+   .context_size   =   sizeof(struct foo_context),
+   .ops = {
+   .open   =   foo_open,
+   .ioctl_rt   =   foo_ioctl_rt,
+   .ioctl_nrt  =   foo_ioctl_nrt,
+   .close  =   foo_close,
+   },
+   .device_class   =   RTDM_CLASS_EXPERIMENTAL,
+   .device_sub_class   =   RTDM_SUBCLASS_FOO,
+   .profile_version=   42,
+   .device_name=   "foo0",
+   .driver_name=   "foo driver",
+   .driver_version =   RTDM_DRIVER_VER(1, 0, 0),
+   .peripheral_name=   "Ultra-void IV board driver",
+   .proc_name  =   device.device_name,
+   .provider_name  =   "Whoever",
+};
+
+static struct rtdm_device foo_device1 = {
+   .struct_version =   RTDM_DEVICE_STRUCT_VER,
+   .device_flags   =   RTDM_NAMED_DEVICE|RTDM_EXCLUSIVE,
+   .device_id  =   1
+   .context_size   =   sizeof(struct foo_context),
+   .ops = {
+   .open   =   foo_open,
+   .ioctl_rt   =   foo_ioctl_rt,
+   .ioctl_nrt  =   foo_ioctl_nrt,
+   .close  =   foo_close,
+   },
+   .device_class   =   RTDM_CLASS_EXPERIMENTAL,
+   .device_sub_class   =   RTDM_SUBCLASS_FOO,
+   .profile_version=   42,
+   .device_name=   "foo1",
+   .device_data=   NULL,
+   .driver_name=   "foo driver",
+   .driver_version =   RTDM_DRIVER_VER(1, 0, 0),
+   .peripheral_name=   "Ultra-void IV board driver",
+   .proc_name  =   device.device_name,
+   .provider_name  =   "Whoever",
+};
+
+foo0.device_data = &some_driver_data0;
+ret = rtdm_dev_register(&foo0);
+...
+foo1.device_data = &some_driver_data1;
+ret = rtdm_dev_register(&foo1);
+
+-
+
+The legacy description above would only create "virtual" device
+entries, private to the RTDM device namespace, with no visible
+counterparts into the Linux device namespace.
+
+.Xenomai 3.x named device description
+-
+
+static struct rtdm_driver foo_driver = {

[Xenomai-git] Philippe Gerum : cobalt/posix/process: fix access to stale memory

2014-09-21 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: 48fc79b57d4a40fffdd474325a24c3122913737b
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=48fc79b57d4a40fffdd474325a24c3122913737b

Author: Philippe Gerum 
Date:   Sun Sep 21 12:51:08 2014 +0200

cobalt/posix/process: fix access to stale memory

---

 kernel/cobalt/posix/process.c |   44 -
 1 file changed, 13 insertions(+), 31 deletions(-)

diff --git a/kernel/cobalt/posix/process.c b/kernel/cobalt/posix/process.c
index c79c8d7..3c72db8 100644
--- a/kernel/cobalt/posix/process.c
+++ b/kernel/cobalt/posix/process.c
@@ -172,28 +172,6 @@ static void *lookup_context(int xid)
return priv;
 }
 
-static int enter_personality(struct cobalt_process *process,
-struct xnthread_personality *personality)
-{
-   if (personality->module && !try_module_get(personality->module))
-   return -EAGAIN;
-
-   __set_bit(personality->xid, &process->permap);
-   atomic_inc(&personality->refcnt);
-
-   return 0;
-}
-
-static void leave_personality(struct cobalt_process *process,
- struct xnthread_personality *personality)
-{
-   __clear_bit(personality->xid, &process->permap);
-   atomic_dec(&personality->refcnt);
-   XENO_ASSERT(COBALT, atomic_read(&personality->refcnt) >= 0);
-   if (personality->module)
-   module_put(personality->module);
-}
-
 static void remove_process(struct cobalt_process *process)
 {
struct xnthread_personality *personality;
@@ -207,16 +185,20 @@ static void remove_process(struct cobalt_process *process)
continue;
personality = cobalt_personalities[xid];
priv = process->priv[xid];
+   if (priv == NULL)
+   continue;
/*
 * CAUTION: process potentially refers to stale memory
 * upon return from detach_process() for the Cobalt
 * personality, so don't dereference it afterwards.
 */
-   if (priv) {
-   process->priv[xid] = NULL;
-   personality->ops.detach_process(priv);
-   leave_personality(process, personality);
-   }
+   process->priv[xid] = NULL;
+   __clear_bit(personality->xid, &process->permap);
+   personality->ops.detach_process(priv);
+   atomic_dec(&personality->refcnt);
+   XENO_ASSERT(COBALT, atomic_read(&personality->refcnt) >= 0);
+   if (personality->module)
+   module_put(personality->module);
}
 
cobalt_set_process(NULL);
@@ -295,7 +277,6 @@ static int bind_personality(struct xnthread_personality 
*personality)
 {
struct cobalt_process *process;
void *priv;
-   int ret;
 
/*
 * We also check capabilities for stacking a Cobalt extension,
@@ -323,12 +304,13 @@ static int bind_personality(struct xnthread_personality 
*personality)
 * safely bump the module refcount after the attach handler
 * has returned.
 */
-   ret = enter_personality(process, personality);
-   if (ret) {
+   if (personality->module && !try_module_get(personality->module)) {
personality->ops.detach_process(priv);
-   return ret;
+   return -EAGAIN;
}
 
+   __set_bit(personality->xid, &process->permap);
+   atomic_inc(&personality->refcnt);
process->priv[personality->xid] = priv;
 
raise_cap(CAP_SYS_NICE);


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


[Xenomai-git] Philippe Gerum : cobalt: rename CONFIG_XENO_HW to CONFIG_XENO_ARCH

2014-09-21 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: 1b04207c6aa4b8ffbae27e64b46753695631d635
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=1b04207c6aa4b8ffbae27e64b46753695631d635

Author: Philippe Gerum 
Date:   Sun Sep 21 10:54:22 2014 +0200

cobalt: rename CONFIG_XENO_HW to CONFIG_XENO_ARCH

This option class is for machine/platform-specific tunables,
"hardware" has always been too generic.

---

 include/cobalt/kernel/lock.h   |2 +-
 include/cobalt/kernel/ppd.h|4 ++--
 include/cobalt/kernel/rtdm/fd.h|8 +++
 include/cobalt/kernel/sched.h  |   10 -
 include/cobalt/kernel/thread.h |4 ++--
 kernel/cobalt/Kconfig  |4 ++--
 kernel/cobalt/arch/arm/Kconfig |   14 ++---
 .../cobalt/arch/arm/include/asm/xenomai/thread.h   |   12 +--
 kernel/cobalt/arch/arm/switch.S|2 +-
 kernel/cobalt/arch/arm/thread.c|4 ++--
 kernel/cobalt/arch/blackfin/Kconfig|2 +-
 kernel/cobalt/arch/nios2/Kconfig   |2 +-
 kernel/cobalt/arch/powerpc/Kconfig |   16 +++---
 kernel/cobalt/arch/powerpc/Makefile|2 +-
 .../arch/powerpc/include/asm/xenomai/fptest.h  |4 ++--
 .../arch/powerpc/include/asm/xenomai/thread.h  |8 +++
 kernel/cobalt/arch/powerpc/thread.c|4 ++--
 kernel/cobalt/arch/sh/Kconfig  |8 +++
 kernel/cobalt/arch/sh/include/asm/xenomai/thread.h |8 +++
 kernel/cobalt/arch/sh/thread.c |4 ++--
 kernel/cobalt/arch/x86/Kconfig |6 +++---
 .../cobalt/arch/x86/include/asm/xenomai/thread.h   |6 +++---
 kernel/cobalt/arch/x86/thread.c|4 ++--
 kernel/cobalt/debug.c  |2 +-
 kernel/cobalt/include/asm-generic/xenomai/thread.h |4 ++--
 kernel/cobalt/init.c   |2 +-
 kernel/cobalt/lock.c   |2 +-
 kernel/cobalt/posix/cond.c |2 +-
 kernel/cobalt/posix/mutex.c|2 +-
 kernel/cobalt/posix/process.c  |   16 +++---
 kernel/cobalt/posix/process.h  |4 ++--
 kernel/cobalt/posix/sem.c  |2 +-
 kernel/cobalt/rtdm/fd.c|   16 +++---
 kernel/cobalt/sched.c  |   22 ++--
 kernel/cobalt/thread.c |   18 
 35 files changed, 115 insertions(+), 115 deletions(-)

diff --git a/include/cobalt/kernel/lock.h b/include/cobalt/kernel/lock.h
index d576c0a..b0c34bf 100644
--- a/include/cobalt/kernel/lock.h
+++ b/include/cobalt/kernel/lock.h
@@ -208,7 +208,7 @@ static inline void xnlock_put(struct xnlock *lock /*, 
*/ XNLOCK_DBG_CONTEXT_
atomic_set(&lock->owner, ~0);
 }
 
-#ifndef CONFIG_XENO_HW_OUTOFLINE_XNLOCK
+#ifndef CONFIG_XENO_ARCH_OUTOFLINE_XNLOCK
 #define ___xnlock_get xnlock_get
 #define ___xnlock_put xnlock_put
 #else /* out of line xnlock */
diff --git a/include/cobalt/kernel/ppd.h b/include/cobalt/kernel/ppd.h
index e76350c..4d42427 100644
--- a/include/cobalt/kernel/ppd.h
+++ b/include/cobalt/kernel/ppd.h
@@ -30,7 +30,7 @@ struct cobalt_umm {
void (*release)(struct cobalt_umm *umm);
 };
 
-struct xnsys_ppd {
+struct cobalt_ppd {
struct cobalt_umm umm;
unsigned long mayday_addr;
atomic_t refcnt;
@@ -38,6 +38,6 @@ struct xnsys_ppd {
struct rb_root fds;
 };
 
-extern struct xnsys_ppd __xnsys_global_ppd;
+extern struct cobalt_ppd __xnsys_global_ppd;
 
 #endif /* _COBALT_KERNEL_PPD_H */
diff --git a/include/cobalt/kernel/rtdm/fd.h b/include/cobalt/kernel/rtdm/fd.h
index 920b276..ec327b3 100644
--- a/include/cobalt/kernel/rtdm/fd.h
+++ b/include/cobalt/kernel/rtdm/fd.h
@@ -29,7 +29,7 @@ struct vm_area_struct;
 struct rtdm_fd;
 struct _rtdm_mmap_request;
 struct xnselector;
-struct xnsys_ppd;
+struct cobalt_ppd;
 
 /**
  * @file
@@ -295,7 +295,7 @@ struct rtdm_fd_ops {
 struct rtdm_fd {
unsigned int magic;
struct rtdm_fd_ops *ops;
-   struct xnsys_ppd *owner;
+   struct cobalt_ppd *owner;
unsigned int refs;
int minor;
struct list_head cleanup;
@@ -307,7 +307,7 @@ int __rtdm_anon_getfd(const char *name, int flags);
 
 void __rtdm_anon_putfd(int ufd);
 
-static inline struct xnsys_ppd *rtdm_fd_owner(struct rtdm_fd *fd)
+static inline struct cobalt_ppd *rtdm_fd_owner(struct rtdm_fd *fd)
 {
return fd->owner;
 }
@@ -349,7 +349,7 @@ int rtdm_fd_valid_p(int ufd);
 int rtdm_fd_select(int ufd, struct xnselector *selector,
   unsigned int type);
 
-void rtdm_fd_cleanup(struct xnsys_ppd *p);
+void rtdm_fd_cleanup(struct co

[Xenomai-git] Philippe Gerum : cobalt/rtdm/core: enable legacy pathnames for named devices

2014-09-21 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: c04e569927f783e946ed66c9569e9df0441c00b1
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=c04e569927f783e946ed66c9569e9df0441c00b1

Author: Philippe Gerum 
Date:   Sun Sep 21 10:16:43 2014 +0200

cobalt/rtdm/core: enable legacy pathnames for named devices

---

 kernel/cobalt/rtdm/core.c |   48 -
 kernel/drivers/Kconfig|   21 
 2 files changed, 68 insertions(+), 1 deletion(-)

diff --git a/kernel/cobalt/rtdm/core.c b/kernel/cobalt/rtdm/core.c
index 896f139..076af73 100644
--- a/kernel/cobalt/rtdm/core.c
+++ b/kernel/cobalt/rtdm/core.c
@@ -96,6 +96,40 @@ static int create_instance(int ufd, struct rtdm_device *dev,
return rtdm_fd_enter(&context->fd, ufd, RTDM_FD_MAGIC, &dev->ops);
 }
 
+#ifdef CONFIG_XENO_OPT_RTDM_COMPAT_DEVNODE
+
+static inline struct file *
+open_devnode(struct rtdm_device *dev, const char *path, int oflag)
+{
+   struct file *filp;
+   char *filename;
+
+#ifdef CONFIG_XENO_OPT_DEBUG_USER
+   if (strncmp(path, "/dev/rtdm/", 10))
+   printk(XENO_WARN
+  "%s[%d] opens obsolete device path: %s",
+  current->comm, current->pid, path);
+#endif
+   filename = kasprintf(GFP_KERNEL, "/dev/rtdm/%s", dev->name);
+   if (filename == NULL)
+   return ERR_PTR(-ENOMEM);
+
+   filp = filp_open(filename, oflag, 0);
+   kfree(filename);
+
+   return filp;
+}
+
+#else /* !CONFIG_XENO_OPT_RTDM_COMPAT_DEVNODE */
+
+static inline struct file *
+open_devnode(struct rtdm_device *dev, const char *path, int oflag)
+{
+   return filp_open(path, oflag, 0);
+}
+
+#endif /* !CONFIG_XENO_OPT_RTDM_COMPAT_DEVNODE */
+
 int __rtdm_dev_open(const char *path, int oflag)
 {
struct rtdm_dev_context *context;
@@ -105,6 +139,18 @@ int __rtdm_dev_open(const char *path, int oflag)
 
secondary_mode_only();
 
+   /*
+* CAUTION: we do want a lookup into the registry to happen
+* before any attempt is made to open the devnode, so that we
+* don't inadvertently open a regular (i.e. non-RTDM) device.
+* Reason is that opening, then closing a device - because we
+* don't manage it - may incur side-effects we don't want,
+* e.g. opening then closing one end of a pipe would cause the
+* other side to read the EOF condition.  This is basically
+* why we keep a RTDM registry for named devices, so that we
+* can figure out whether an open() request is going to be
+* valid, without having to open the devnode yet.
+*/
dev = __rtdm_get_namedev(path);
if (dev == NULL)
return -ENODEV;
@@ -115,7 +161,7 @@ int __rtdm_dev_open(const char *path, int oflag)
goto fail_fd;
}
 
-   filp = filp_open(path, oflag, 0);
+   filp = open_devnode(dev, path, oflag);
if (IS_ERR(filp)) {
ret = PTR_ERR(filp);
goto fail_fopen;
diff --git a/kernel/drivers/Kconfig b/kernel/drivers/Kconfig
index 5496f30..a01eb8c 100644
--- a/kernel/drivers/Kconfig
+++ b/kernel/drivers/Kconfig
@@ -1,5 +1,26 @@
 menu "Drivers"
 
+config XENO_OPT_RTDM_COMPAT_DEVNODE
+bool "Enable legacy pathnames for named RTDM devices"
+   default y
+   help
+
+   This compatibility option allows applications to open named
+   RTDM devices using the legacy naming scheme, i.e.
+
+   fd = open("devname", ...);
+  or
+   fd = open("/dev/devname", ...);
+
+   When such a request is received by RTDM, a warning message is
+   issued to the kernel log whenever XENO_OPT_DEBUG_USER is
+   also enabled in the kernel configuration.
+
+   Applications should open named devices via their actual device
+   nodes instead, i.e.
+
+   fd = open("/dev/rtdm/devname", ...);
+
 source "drivers/xenomai/autotune/Kconfig"
 source "drivers/xenomai/serial/Kconfig"
 source "drivers/xenomai/testing/Kconfig"


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