[Xenomai-git] Philippe Gerum : cobalt: introduce internal extension interface

2013-07-17 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: 4e09e1bf51803b042a0505cb8d5e3e2c73d4b451
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=4e09e1bf51803b042a0505cb8d5e3e2c73d4b451

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.

Cobalt extension drivers should include rtdm/cobalt.h, which will
read in the appropriate kernel headers, useful for implementing the
add-on features, and interposing on the existing Cobalt services via
the internal interface. Since these headers a not part of the public
kernel API, drivers should mention -Ikernel in the ccflags-y
variable from their Kbuild Makefile frag.

---

 include/cobalt/kernel/thread.h   |3 --
 include/rtdm/Makefile.am |   13 ---
 include/rtdm/Makefile.in |   11 +++---
 include/rtdm/cobalt.h|   31 +
 kernel/cobalt/Kconfig|3 ++
 kernel/cobalt/posix/clock.h  |   67 +
 kernel/cobalt/posix/cond.c   |4 ++-
 kernel/cobalt/posix/cond.h   |   11 --
 kernel/cobalt/posix/cond_attr.c  |3 +-
 kernel/cobalt/posix/event.c  |4 +-
 kernel/cobalt/posix/init.c   |4 +--
 kernel/cobalt/posix/internal.h   |   68 --
 kernel/cobalt/posix/monitor.c|4 +-
 kernel/cobalt/posix/mqueue.c |   12 +++---
 kernel/cobalt/posix/mutex.c  |4 ++-
 kernel/cobalt/posix/mutex_attr.c |3 +-
 kernel/cobalt/posix/registry.c   |6 ++--
 kernel/cobalt/posix/sem.c|   44 ++--
 kernel/cobalt/posix/sem.h|   13 ++-
 kernel/cobalt/posix/signal.c |2 +
 kernel/cobalt/posix/syscall.c|7 +++-
 kernel/cobalt/posix/thread.c |   28 +++
 kernel/cobalt/posix/thread.h |   25 ++---
 kernel/cobalt/posix/timer.c  |3 ++
 kernel/cobalt/posix/timer.h  |1 +
 kernel/cobalt/thread.c   |1 -
 26 files changed, 226 insertions(+), 149 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 \
- 

[Xenomai-git] Philippe Gerum : cobalt: introduce internal extension interface

2013-07-16 Thread git repository hosting
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 000..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