[Xenomai-git] Philippe Gerum : cobalt/corectl: move implementation to separate file

2015-12-28 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: d90722e2b7102fb9f340cb181a080629e1fe3aeb
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=d90722e2b7102fb9f340cb181a080629e1fe3aeb

Author: Philippe Gerum 
Date:   Sun Dec 27 16:20:41 2015 +0100

cobalt/corectl: move implementation to separate file

---

 kernel/cobalt/posix/Makefile  |1 +
 kernel/cobalt/posix/corectl.c |  189 +
 kernel/cobalt/posix/corectl.h |   27 ++
 kernel/cobalt/posix/syscall.c |  163 +--
 4 files changed, 218 insertions(+), 162 deletions(-)

diff --git a/kernel/cobalt/posix/Makefile b/kernel/cobalt/posix/Makefile
index 2da764a..f194bff 100644
--- a/kernel/cobalt/posix/Makefile
+++ b/kernel/cobalt/posix/Makefile
@@ -6,6 +6,7 @@ obj-$(CONFIG_XENOMAI) += xenomai.o
 xenomai-y :=   \
clock.o \
cond.o  \
+   corectl.o   \
event.o \
io.o\
memory.o\
diff --git a/kernel/cobalt/posix/corectl.c b/kernel/cobalt/posix/corectl.c
new file mode 100644
index 000..f5af386
--- /dev/null
+++ b/kernel/cobalt/posix/corectl.c
@@ -0,0 +1,189 @@
+/*
+ * Copyright (C) 2016 Philippe Gerum .
+ *
+ * This program 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.
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "corectl.h"
+
+static int get_conf_option(int option, void __user *u_buf, size_t u_bufsz)
+{
+   int ret, val = 0;
+
+   if (u_bufsz < sizeof(val))
+   return -EINVAL;
+
+   switch (option) {
+   case _CC_COBALT_GET_VERSION:
+   val = XENO_VERSION_CODE;
+   break;
+   case _CC_COBALT_GET_NR_PIPES:
+#ifdef CONFIG_XENO_OPT_PIPE
+   val = CONFIG_XENO_OPT_PIPE_NRDEV;
+#endif
+   break;
+   case _CC_COBALT_GET_NR_TIMERS:
+   val = CONFIG_XENO_OPT_NRTIMERS;
+   break;
+   case _CC_COBALT_GET_POLICIES:
+   val = _CC_COBALT_SCHED_FIFO|_CC_COBALT_SCHED_RR;
+   if (IS_ENABLED(CONFIG_XENO_OPT_SCHED_WEAK))
+   val |= _CC_COBALT_SCHED_WEAK;
+   if (IS_ENABLED(CONFIG_XENO_OPT_SCHED_SPORADIC))
+   val |= _CC_COBALT_SCHED_SPORADIC;
+   if (IS_ENABLED(CONFIG_XENO_OPT_SCHED_QUOTA))
+   val |= _CC_COBALT_SCHED_QUOTA;
+   if (IS_ENABLED(CONFIG_XENO_OPT_SCHED_TP))
+   val |= _CC_COBALT_SCHED_TP;
+   break;
+   case _CC_COBALT_GET_DEBUG:
+   if (IS_ENABLED(CONFIG_XENO_OPT_DEBUG_COBALT))
+   val |= _CC_COBALT_DEBUG_ASSERT;
+   if (IS_ENABLED(CONFIG_XENO_OPT_DEBUG_CONTEXT))
+   val |= _CC_COBALT_DEBUG_CONTEXT;
+   if (IS_ENABLED(CONFIG_XENO_OPT_DEBUG_LOCKING))
+   val |= _CC_COBALT_DEBUG_LOCKING;
+   if (IS_ENABLED(CONFIG_XENO_OPT_DEBUG_USER))
+   val |= _CC_COBALT_DEBUG_USER;
+   if (IS_ENABLED(CONFIG_XENO_OPT_DEBUG_MUTEX_RELAXED))
+   val |= _CC_COBALT_DEBUG_MUTEX_RELAXED;
+   if (IS_ENABLED(CONFIG_XENO_OPT_DEBUG_MUTEX_SLEEP))
+   val |= _CC_COBALT_DEBUG_MUTEX_SLEEP;
+   if (IS_ENABLED(CONFIG_XENO_OPT_DEBUG_POSIX_SYNCHRO))
+   val |= _CC_COBALT_DEBUG_POSIX_SYNCHRO;
+   if (IS_ENABLED(CONFIG_XENO_OPT_DEBUG_LEGACY))
+   val |= _CC_COBALT_DEBUG_LEGACY;
+   if (IS_ENABLED(CONFIG_XENO_OPT_DEBUG_TRACE_RELAX))
+   val |= _CC_COBALT_DEBUG_TRACE_RELAX;
+   break;
+   case _CC_COBALT_GET_WATCHDOG:
+#ifdef CONFIG_XENO_OPT_WATCHDOG
+   val = CONFIG_XENO_OPT_WATCHDOG_TIMEOUT;
+#endif
+   break;
+   case _CC_COBALT_GET_CORE_STATUS:
+   val = realtime_core_state();
+   break;
+   default:
+   return -EINVAL;
+   }
+
+   ret = cobalt_copy_to_user(u_buf, , sizeof(val));
+
+   return ret ? -EFAULT : 0;
+}
+
+static int stop_services(const void __user *u_buf, size_t u_bufsz)
+{
+   const int final_grace_period = 3; 

[Xenomai-git] Philippe Gerum : cobalt/corectl: move implementation to separate file

2015-12-28 Thread git repository hosting
Module: xenomai-3
Branch: stable-3.0.x
Commit: 9b546e52c06a39f8c7232224b07e66062dab25fc
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=9b546e52c06a39f8c7232224b07e66062dab25fc

Author: Philippe Gerum 
Date:   Sun Dec 27 16:20:41 2015 +0100

cobalt/corectl: move implementation to separate file

---

 kernel/cobalt/posix/Makefile  |1 +
 kernel/cobalt/posix/corectl.c |  189 +
 kernel/cobalt/posix/corectl.h |   27 ++
 kernel/cobalt/posix/syscall.c |  163 +--
 4 files changed, 218 insertions(+), 162 deletions(-)

diff --git a/kernel/cobalt/posix/Makefile b/kernel/cobalt/posix/Makefile
index 2da764a..f194bff 100644
--- a/kernel/cobalt/posix/Makefile
+++ b/kernel/cobalt/posix/Makefile
@@ -6,6 +6,7 @@ obj-$(CONFIG_XENOMAI) += xenomai.o
 xenomai-y :=   \
clock.o \
cond.o  \
+   corectl.o   \
event.o \
io.o\
memory.o\
diff --git a/kernel/cobalt/posix/corectl.c b/kernel/cobalt/posix/corectl.c
new file mode 100644
index 000..f5af386
--- /dev/null
+++ b/kernel/cobalt/posix/corectl.c
@@ -0,0 +1,189 @@
+/*
+ * Copyright (C) 2016 Philippe Gerum .
+ *
+ * This program 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.
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "corectl.h"
+
+static int get_conf_option(int option, void __user *u_buf, size_t u_bufsz)
+{
+   int ret, val = 0;
+
+   if (u_bufsz < sizeof(val))
+   return -EINVAL;
+
+   switch (option) {
+   case _CC_COBALT_GET_VERSION:
+   val = XENO_VERSION_CODE;
+   break;
+   case _CC_COBALT_GET_NR_PIPES:
+#ifdef CONFIG_XENO_OPT_PIPE
+   val = CONFIG_XENO_OPT_PIPE_NRDEV;
+#endif
+   break;
+   case _CC_COBALT_GET_NR_TIMERS:
+   val = CONFIG_XENO_OPT_NRTIMERS;
+   break;
+   case _CC_COBALT_GET_POLICIES:
+   val = _CC_COBALT_SCHED_FIFO|_CC_COBALT_SCHED_RR;
+   if (IS_ENABLED(CONFIG_XENO_OPT_SCHED_WEAK))
+   val |= _CC_COBALT_SCHED_WEAK;
+   if (IS_ENABLED(CONFIG_XENO_OPT_SCHED_SPORADIC))
+   val |= _CC_COBALT_SCHED_SPORADIC;
+   if (IS_ENABLED(CONFIG_XENO_OPT_SCHED_QUOTA))
+   val |= _CC_COBALT_SCHED_QUOTA;
+   if (IS_ENABLED(CONFIG_XENO_OPT_SCHED_TP))
+   val |= _CC_COBALT_SCHED_TP;
+   break;
+   case _CC_COBALT_GET_DEBUG:
+   if (IS_ENABLED(CONFIG_XENO_OPT_DEBUG_COBALT))
+   val |= _CC_COBALT_DEBUG_ASSERT;
+   if (IS_ENABLED(CONFIG_XENO_OPT_DEBUG_CONTEXT))
+   val |= _CC_COBALT_DEBUG_CONTEXT;
+   if (IS_ENABLED(CONFIG_XENO_OPT_DEBUG_LOCKING))
+   val |= _CC_COBALT_DEBUG_LOCKING;
+   if (IS_ENABLED(CONFIG_XENO_OPT_DEBUG_USER))
+   val |= _CC_COBALT_DEBUG_USER;
+   if (IS_ENABLED(CONFIG_XENO_OPT_DEBUG_MUTEX_RELAXED))
+   val |= _CC_COBALT_DEBUG_MUTEX_RELAXED;
+   if (IS_ENABLED(CONFIG_XENO_OPT_DEBUG_MUTEX_SLEEP))
+   val |= _CC_COBALT_DEBUG_MUTEX_SLEEP;
+   if (IS_ENABLED(CONFIG_XENO_OPT_DEBUG_POSIX_SYNCHRO))
+   val |= _CC_COBALT_DEBUG_POSIX_SYNCHRO;
+   if (IS_ENABLED(CONFIG_XENO_OPT_DEBUG_LEGACY))
+   val |= _CC_COBALT_DEBUG_LEGACY;
+   if (IS_ENABLED(CONFIG_XENO_OPT_DEBUG_TRACE_RELAX))
+   val |= _CC_COBALT_DEBUG_TRACE_RELAX;
+   break;
+   case _CC_COBALT_GET_WATCHDOG:
+#ifdef CONFIG_XENO_OPT_WATCHDOG
+   val = CONFIG_XENO_OPT_WATCHDOG_TIMEOUT;
+#endif
+   break;
+   case _CC_COBALT_GET_CORE_STATUS:
+   val = realtime_core_state();
+   break;
+   default:
+   return -EINVAL;
+   }
+
+   ret = cobalt_copy_to_user(u_buf, , sizeof(val));
+
+   return ret ? -EFAULT : 0;
+}
+
+static int stop_services(const void __user *u_buf, size_t u_bufsz)
+{
+   const int