Module: xenomai-forge
Branch: next
Commit: 34859da66580315c35de5eeff55681625db4954a
URL:    
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=34859da66580315c35de5eeff55681625db4954a

Author: Philippe Gerum <r...@xenomai.org>
Date:   Tue Jul 16 15:42:58 2013 +0200

cobalt: introduce internal extension interface

Drivers from the RTDM_COBALT class are specifically designed for
extending the Cobalt/POSIX services. We need a way to expose
extension-specific handlers in the latter, so that the former may
change the default behavior at well-defined locations.

This extension mechanism should not cause any overhead when disabled,
which is the most common situation. For this reason, the extension
mechanism is compiled out when CONFIG_XENO_OPT_COBALT_EXTENSION is
disabled.

This patch introduces the cobalt_extension abstraction, aimed at
exposing a series of extension handlers as described previously, on
a per-thread basis.  Extension drivers should invoke the
cobalt_thread_extend() and cobalt_thread_restrict() services to
respectively enable and disable the handlers.

At this chance, the private data field moved from the core thread
object (xnthread) to the cobalt_thread structure, since this facility
is intended for use by Cobalt extension code.

---

 include/cobalt/kernel/thread.h |    3 ---
 include/rtdm/Makefile.am       |   13 +++++++------
 include/rtdm/Makefile.in       |   11 ++++++-----
 include/rtdm/cobalt.h          |   40 ++++++++++++++++++++++++++++++++++++++++
 kernel/cobalt/Kconfig          |    3 +++
 kernel/cobalt/posix/internal.h |    3 ---
 kernel/cobalt/posix/thread.c   |   26 ++++++++++++++++++++++++++
 kernel/cobalt/posix/thread.h   |    6 +++++-
 kernel/cobalt/posix/timer.c    |    1 +
 kernel/cobalt/thread.c         |    1 -
 10 files changed, 88 insertions(+), 19 deletions(-)

diff --git a/include/cobalt/kernel/thread.h b/include/cobalt/kernel/thread.h
index 4f5f5f5..a9c8d8d 100644
--- a/include/cobalt/kernel/thread.h
+++ b/include/cobalt/kernel/thread.h
@@ -165,8 +165,6 @@ typedef struct xnthread {
        struct pt_regs *regs;           /* Current register frame */
        struct xnthread_user_window *u_window;  /* Data visible from userland. 
*/
 
-       void *privdata;                         /* Private data for extension */
-
        struct xnpersonality *personality; /* Originating interface/personality 
*/
 
 #ifdef CONFIG_XENO_OPT_DEBUG
@@ -232,7 +230,6 @@ static inline void xnthread_clear_info(struct xnthread 
*thread, int bits)
 #define xnthread_inc_rescnt(thread)        ({ (thread)->hrescnt++; })
 #define xnthread_dec_rescnt(thread)        ({ --(thread)->hrescnt; })
 #define xnthread_get_rescnt(thread)        ((thread)->hrescnt)
-#define xnthread_private(thread)           ((thread)->privdata)
 #define xnthread_personality(thread)       ((thread)->personality)
 
 #define xnthread_for_each_claimed(__pos, __thread)             \
diff --git a/include/rtdm/Makefile.am b/include/rtdm/Makefile.am
index 4e48be8..b271df9 100644
--- a/include/rtdm/Makefile.am
+++ b/include/rtdm/Makefile.am
@@ -1,9 +1,10 @@
 includesubdir = $(includedir)/rtdm
 
-includesub_HEADERS = \
-       rtdm.h \
-       rtdm_driver.h \
-       rtserial.h \
-       rttesting.h \
-       rtcan.h \
+includesub_HEADERS =   \
+       cobalt.h        \
+       rtdm.h          \
+       rtdm_driver.h   \
+       rtserial.h      \
+       rttesting.h     \
+       rtcan.h         \
        rtipc.h
diff --git a/include/rtdm/Makefile.in b/include/rtdm/Makefile.in
index e4c3742..3e2eca4 100644
--- a/include/rtdm/Makefile.in
+++ b/include/rtdm/Makefile.in
@@ -275,11 +275,12 @@ top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 includesubdir = $(includedir)/rtdm
 includesub_HEADERS = \
-       rtdm.h \
-       rtdm_driver.h \
-       rtserial.h \
-       rttesting.h \
-       rtcan.h \
+       cobalt.h        \
+       rtdm.h          \
+       rtdm_driver.h   \
+       rtserial.h      \
+       rttesting.h     \
+       rtcan.h         \
        rtipc.h
 
 all: all-am
diff --git a/include/rtdm/cobalt.h b/include/rtdm/cobalt.h
new file mode 100644
index 0000000..489b7cd
--- /dev/null
+++ b/include/rtdm/cobalt.h
@@ -0,0 +1,40 @@
+/**
+ * @file
+ * This file is part of the Xenomai project.
+ *
+ * @note Copyright (C) 2013 Philippe Gerum <r...@xenomai.org>
+ *
+ * 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.
+ *
+ * This program 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+#ifndef _RTDM_COBALT_H
+#define _RTDM_COBALT_H
+
+#include <cobalt/kernel/shadow.h>
+
+struct cobalt_thread;
+
+struct cobalt_extension {
+       struct xnpersonality core;
+       struct {
+       } ops;
+};
+
+void cobalt_thread_extend(struct cobalt_thread *thread,
+                         struct cobalt_extension *ext,
+                         void *priv);
+
+void cobalt_thread_restrict(struct cobalt_thread *thread);
+
+#endif /* !_RTDM_COBALT_H */
diff --git a/kernel/cobalt/Kconfig b/kernel/cobalt/Kconfig
index 241216a..d6764f1 100644
--- a/kernel/cobalt/Kconfig
+++ b/kernel/cobalt/Kconfig
@@ -208,6 +208,9 @@ config XENO_OPT_PIPE
 config XENO_OPT_MAP
        bool
 
+config XENO_OPT_COBALT_EXTENSION
+       bool
+
 config XENO_OPT_VFILE
        bool
        depends on PROC_FS
diff --git a/kernel/cobalt/posix/internal.h b/kernel/cobalt/posix/internal.h
index 4e536fb..9122af1 100644
--- a/kernel/cobalt/posix/internal.h
+++ b/kernel/cobalt/posix/internal.h
@@ -161,9 +161,6 @@ static inline int clock_flag(int flag, clockid_t clock_id)
        return -EINVAL;
 }
 
-int cobalt_mq_elect_bind(mqd_t fd, struct xnselector *selector,
-                        unsigned type, unsigned index);
-
 int cobalt_init(void);
 
 void cobalt_cleanup(void);
diff --git a/kernel/cobalt/posix/thread.c b/kernel/cobalt/posix/thread.c
index 1b84181..1355e0d 100644
--- a/kernel/cobalt/posix/thread.c
+++ b/kernel/cobalt/posix/thread.c
@@ -33,6 +33,7 @@
 #include <linux/jhash.h>
 #include <linux/signal.h>
 #include <cobalt/uapi/signal.h>
+#include <rtdm/cobalt.h>
 #include "thread.h"
 #include "timer.h"
 
@@ -1196,6 +1197,31 @@ int cobalt_thread_getschedparam_ex(unsigned long pth,
        return __xn_safe_copy_to_user(u_param, &param, sizeof(param));
 }
 
+#ifdef CONFIG_XENO_OPT_COBALT_EXTENSION
+
+void cobalt_thread_extend(struct cobalt_thread *thread,
+                         struct cobalt_extension *ext,
+                         void *priv)
+{
+       struct xnpersonality *prev;
+
+       prev = xnshadow_push_personality(&thread->threadbase, &ext->core);
+       thread->extension = ext;
+       thread->private = priv;
+       XENO_BUGON(NUCLEUS, prev != &cobalt_personality);
+}
+EXPORT_SYMBOL_GPL(cobalt_thread_extend);
+
+void cobalt_thread_restrict(struct cobalt_thread *thread)
+{
+       xnshadow_pop_personality(&thread->threadbase, &cobalt_personality);
+       thread->extension = NULL;
+       thread->private = NULL;
+}
+EXPORT_SYMBOL_GPL(cobalt_thread_restrict);
+
+#endif /* !CONFIG_XENO_OPT_COBALT_EXTENSION */
+
 int cobalt_sched_min_prio(int policy)
 {
        switch (policy) {
diff --git a/kernel/cobalt/posix/thread.h b/kernel/cobalt/posix/thread.h
index d431b6c..4d647fd 100644
--- a/kernel/cobalt/posix/thread.h
+++ b/kernel/cobalt/posix/thread.h
@@ -43,6 +43,7 @@
 
 struct cobalt_thread;
 struct cobalt_threadstat;
+struct cobalt_extension;
 
 typedef struct cobalt_condattr pthread_condattr_t;
 
@@ -102,6 +103,10 @@ struct cobalt_local_hkey {
 struct cobalt_thread {
        unsigned int magic;
        struct xnthread threadbase;
+#ifdef CONFIG_XENO_OPT_COBALT_EXTENSION
+       struct cobalt_extension *extension;
+       void *private;
+#endif
 
        /** cobalt_threadq */
        struct list_head link;
@@ -195,7 +200,6 @@ struct xnpersonality *cobalt_thread_exit(struct xnthread 
*curr);
 
 struct xnpersonality *cobalt_thread_unmap(struct xnthread *zombie);
 
-/* round-robin period. */
 extern xnticks_t cobalt_time_slice;
 
 extern struct xnpersonality cobalt_personality;
diff --git a/kernel/cobalt/posix/timer.c b/kernel/cobalt/posix/timer.c
index 7e79b50..c826c56 100644
--- a/kernel/cobalt/posix/timer.c
+++ b/kernel/cobalt/posix/timer.c
@@ -34,6 +34,7 @@ struct cobalt_timer {
        siginfo_t si;
        clockid_t clockid;
        pid_t target;
+       struct sigevent ev;
        struct cobalt_thread *owner;
        struct cobalt_kqueues *owningq;
 };
diff --git a/kernel/cobalt/thread.c b/kernel/cobalt/thread.c
index 2c5573d..0d43a8b 100644
--- a/kernel/cobalt/thread.c
+++ b/kernel/cobalt/thread.c
@@ -177,7 +177,6 @@ int xnthread_init(struct xnthread *thread,
        thread->selector = NULL;
        INIT_LIST_HEAD(&thread->claimq);
 
-       thread->privdata = NULL;
        thread->personality = attr->personality;
 
        thread->sched = sched;


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

Reply via email to