[Xenomai-git] Philippe Gerum : copperplate/threadobj: mercury: fix stat call (CPU number )

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

Author: Philippe Gerum 
Date:   Mon Dec 28 12:08:32 2015 +0100

copperplate/threadobj: mercury: fix stat call (CPU number)

---

 lib/copperplate/threadobj.c |   27 ---
 1 file changed, 24 insertions(+), 3 deletions(-)

diff --git a/lib/copperplate/threadobj.c b/lib/copperplate/threadobj.c
index 44266f4..2d37d46 100644
--- a/lib/copperplate/threadobj.c
+++ b/lib/copperplate/threadobj.c
@@ -22,6 +22,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -851,14 +853,33 @@ static void disable_rr_corespec(struct threadobj *thobj) 
/* thobj->lock held */
 int threadobj_stat(struct threadobj *thobj,
   struct threadobj_stat *stat) /* thobj->lock held */
 {
+   char procstat[64], buf[BUFSIZ], *p;
struct timespec now, delta;
+   FILE *fp;
+   int n;
 
__threadobj_check_locked(thobj);
 
-   stat->cpu = sched_getcpu();
-   if (stat->cpu < 0)
-   stat->cpu = 0;  /* assume uniprocessor on ENOSYS */
+   snprintf(procstat, sizeof(procstat), "/proc/%d/stat", thobj->pid);
+   fp = fopen(procstat, "r");
+   if (fp == NULL)
+   return -EINVAL;
+
+   p = fgets(buf, sizeof(buf), fp);
+   fclose(fp);
+
+   if (p == NULL)
+   return -EIO;
+
+   p += strlen(buf);
+   for (n = 0; n < 14; n++) {
+   while (*--p != ' ') {
+   if (p <= buf)
+   return -EINVAL;
+   }
+   }
 
+   stat->cpu = atoi(++p);
stat->status = threadobj_get_status(thobj);
 
if (thobj->run_state & (__THREAD_S_TIMEDWAIT|__THREAD_S_DELAYED)) {


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


[Xenomai-git] Philippe Gerum : copperplate/registry: handle bad stat reading in system/ threads

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

Author: Philippe Gerum 
Date:   Mon Dec 28 12:09:28 2015 +0100

copperplate/registry: handle bad stat reading in system/threads

---

 lib/copperplate/regd/fs-common.c |   25 +
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/lib/copperplate/regd/fs-common.c b/lib/copperplate/regd/fs-common.c
index 99a2120..ef2e6da 100644
--- a/lib/copperplate/regd/fs-common.c
+++ b/lib/copperplate/regd/fs-common.c
@@ -119,12 +119,16 @@ int open_threads(struct fsobj *fsobj, void *priv)
p->pid = thobj->pid;
p->priority = threadobj_get_priority(thobj);
p->policy = threadobj_get_policy(thobj);
-   threadobj_stat(thobj, );
+   ret = threadobj_stat(thobj, );
threadobj_unlock(thobj);
-   p->status = statbuf.status;
-   p->cpu = statbuf.cpu;
-   p->timeout = statbuf.timeout;
-   p->schedlock = statbuf.schedlock;
+   if (ret)
+   p->cpu = -1;
+   else {
+   p->status = statbuf.status;
+   p->cpu = statbuf.cpu;
+   p->timeout = statbuf.timeout;
+   p->schedlock = statbuf.schedlock;
+   }
p++;
}
 
@@ -142,8 +146,13 @@ int open_threads(struct fsobj *fsobj, void *priv)
if (kill(p->pid, 0))
continue;
snprintf(pbuf, sizeof(pbuf), "%3d", p->priority);
-   format_time(p->timeout, tbuf, sizeof(tbuf));
-   format_thread_status(p, sbuf, sizeof(sbuf));
+   if (p->cpu < 0) {
+   strcpy(tbuf, "");
+   strcpy(sbuf, "??");
+   } else {
+   format_time(p->timeout, tbuf, sizeof(tbuf));
+   format_thread_status(p, sbuf, sizeof(sbuf));
+   }
switch (p->policy) {
case SCHED_FIFO:
sched_class = "fifo";
@@ -176,7 +185,7 @@ int open_threads(struct fsobj *fsobj, void *priv)
break;
}
len += fsobstack_grow_format(o,
-"%3u  %-6d %-5s  %-8s %-8s  %-10s 
%s\n",
+"%3d  %-6d %-5s  %-8s %-8s  %-10s 
%s\n",
 p->cpu, p->pid, sched_class, pbuf,
 tbuf, sbuf, p->name);
p++;


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


[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 : copperplate/threadobj: mercury: fix stat call (CPU number )

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

Author: Philippe Gerum 
Date:   Mon Dec 28 12:08:32 2015 +0100

copperplate/threadobj: mercury: fix stat call (CPU number)

---

 lib/copperplate/threadobj.c |   27 ---
 1 file changed, 24 insertions(+), 3 deletions(-)

diff --git a/lib/copperplate/threadobj.c b/lib/copperplate/threadobj.c
index 44266f4..2d37d46 100644
--- a/lib/copperplate/threadobj.c
+++ b/lib/copperplate/threadobj.c
@@ -22,6 +22,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -851,14 +853,33 @@ static void disable_rr_corespec(struct threadobj *thobj) 
/* thobj->lock held */
 int threadobj_stat(struct threadobj *thobj,
   struct threadobj_stat *stat) /* thobj->lock held */
 {
+   char procstat[64], buf[BUFSIZ], *p;
struct timespec now, delta;
+   FILE *fp;
+   int n;
 
__threadobj_check_locked(thobj);
 
-   stat->cpu = sched_getcpu();
-   if (stat->cpu < 0)
-   stat->cpu = 0;  /* assume uniprocessor on ENOSYS */
+   snprintf(procstat, sizeof(procstat), "/proc/%d/stat", thobj->pid);
+   fp = fopen(procstat, "r");
+   if (fp == NULL)
+   return -EINVAL;
+
+   p = fgets(buf, sizeof(buf), fp);
+   fclose(fp);
+
+   if (p == NULL)
+   return -EIO;
+
+   p += strlen(buf);
+   for (n = 0; n < 14; n++) {
+   while (*--p != ' ') {
+   if (p <= buf)
+   return -EINVAL;
+   }
+   }
 
+   stat->cpu = atoi(++p);
stat->status = threadobj_get_status(thobj);
 
if (thobj->run_state & (__THREAD_S_TIMEDWAIT|__THREAD_S_DELAYED)) {


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


[Xenomai-git] Philippe Gerum : cobalt/corectl: chain config requests to external subsystems

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

Author: Philippe Gerum 
Date:   Sun Dec 27 18:02:01 2015 +0100

cobalt/corectl: chain config requests to external subsystems

External subsystems (e.g. RTNet, Analogy) may attach to the generic
corectl() configuration service by registering to the config_notifier
list, using the cobalt_add_config_chain() routine.

Upon a call to corectl(), a configuration request left unprocessed by
the core is posted to the registered handlers in turn, until NOTIFY_OK
or any error is raised.  If a request remains unprocessed, corectl()
eventually returns -EINVAL.

Unlike core configuration requests which may be handled in primary
mode if applicable, the current context is always switched to
secondary mode before subsystem handlers are called.

---

 include/cobalt/kernel/init.h|6 +++---
 include/cobalt/kernel/rtdm/cobalt.h |1 +
 kernel/cobalt/init.c|   12 ++--
 kernel/cobalt/posix/corectl.c   |   36 +--
 kernel/cobalt/posix/corectl.h   |   11 +++
 kernel/cobalt/rtdm/device.c |4 ++--
 6 files changed, 53 insertions(+), 17 deletions(-)

diff --git a/include/cobalt/kernel/init.h b/include/cobalt/kernel/init.h
index bdb2bb6..41dd531 100644
--- a/include/cobalt/kernel/init.h
+++ b/include/cobalt/kernel/init.h
@@ -45,10 +45,10 @@ static inline void set_realtime_core_state(enum 
cobalt_run_states state)
atomic_set(_runstate, state);
 }
 
-void cobalt_add_notifier_chain(struct notifier_block *nb);
+void cobalt_add_state_chain(struct notifier_block *nb);
 
-void cobalt_remove_notifier_chain(struct notifier_block *nb);
+void cobalt_remove_state_chain(struct notifier_block *nb);
 
-void cobalt_call_notifier_chain(enum cobalt_run_states newstate);
+void cobalt_call_state_chain(enum cobalt_run_states newstate);
 
 #endif /* !_COBALT_KERNEL_INIT_H_ */
diff --git a/include/cobalt/kernel/rtdm/cobalt.h 
b/include/cobalt/kernel/rtdm/cobalt.h
index a2b268d..d60cfc5 100644
--- a/include/cobalt/kernel/rtdm/cobalt.h
+++ b/include/cobalt/kernel/rtdm/cobalt.h
@@ -28,5 +28,6 @@
 #include 
 #include 
 #include 
+#include 
 
 #endif /* !_COBALT_RTDM_COBALT_H */
diff --git a/kernel/cobalt/init.c b/kernel/cobalt/init.c
index cc77b37..0eab3be 100644
--- a/kernel/cobalt/init.c
+++ b/kernel/cobalt/init.c
@@ -104,23 +104,23 @@ EXPORT_SYMBOL_GPL(cobalt_kernel_ppd);
"[STOPPED]" : "";   \
})
 
-void cobalt_add_notifier_chain(struct notifier_block *nb)
+void cobalt_add_state_chain(struct notifier_block *nb)
 {
blocking_notifier_chain_register(_notifier_list, nb);
 }
-EXPORT_SYMBOL_GPL(cobalt_add_notifier_chain);
+EXPORT_SYMBOL_GPL(cobalt_add_state_chain);
 
-void cobalt_remove_notifier_chain(struct notifier_block *nb)
+void cobalt_remove_state_chain(struct notifier_block *nb)
 {
blocking_notifier_chain_unregister(_notifier_list, nb);
 }
-EXPORT_SYMBOL_GPL(cobalt_remove_notifier_chain);
+EXPORT_SYMBOL_GPL(cobalt_remove_state_chain);
 
-void cobalt_call_notifier_chain(enum cobalt_run_states newstate)
+void cobalt_call_state_chain(enum cobalt_run_states newstate)
 {
blocking_notifier_call_chain(_notifier_list, newstate, NULL);
 }
-EXPORT_SYMBOL_GPL(cobalt_call_notifier_chain);
+EXPORT_SYMBOL_GPL(cobalt_call_state_chain);
 
 static void sys_shutdown(void)
 {
diff --git a/kernel/cobalt/posix/corectl.c b/kernel/cobalt/posix/corectl.c
index f5af386..de8fa5b 100644
--- a/kernel/cobalt/posix/corectl.c
+++ b/kernel/cobalt/posix/corectl.c
@@ -27,11 +27,14 @@
 #include 
 #include "corectl.h"
 
-static int get_conf_option(int option, void __user *u_buf, size_t u_bufsz)
+static BLOCKING_NOTIFIER_HEAD(config_notifier_list);
+
+static int do_conf_option(int option, void __user *u_buf, size_t u_bufsz)
 {
+   struct cobalt_config_vector vec;
int ret, val = 0;
 
-   if (u_bufsz < sizeof(val))
+   if (option <= _CC_COBALT_GET_CORE_STATUS && u_bufsz < sizeof(val))
return -EINVAL;
 
switch (option) {
@@ -86,7 +89,16 @@ static int get_conf_option(int option, void __user *u_buf, 
size_t u_bufsz)
val = realtime_core_state();
break;
default:
-   return -EINVAL;
+   if (!ipipe_root_p)
+   /* Switch to secondary mode first. */
+   return -ENOSYS;
+   vec.u_buf = u_buf;
+   vec.u_bufsz = u_bufsz;
+   ret = blocking_notifier_call_chain(_notifier_list,
+  option, );
+   if (ret == NOTIFY_DONE)
+   return -EINVAL; /* Nobody cared. */
+   return notifier_to_errno(ret);
}
 
ret = cobalt_copy_to_user(u_buf, , 

[Xenomai-git] Philippe Gerum : copperplate/threadobj: fixup run state upon threadobj_wait_period()

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

Author: Philippe Gerum 
Date:   Mon Dec 28 10:46:22 2015 +0100

copperplate/threadobj: fixup run state upon threadobj_wait_period()

---

 lib/copperplate/threadobj.c |3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/copperplate/threadobj.c b/lib/copperplate/threadobj.c
index cc64caa..44266f4 100644
--- a/lib/copperplate/threadobj.c
+++ b/lib/copperplate/threadobj.c
@@ -1623,11 +1623,14 @@ int threadobj_set_periodic(struct threadobj *thobj,
 
 int threadobj_wait_period(unsigned long *overruns_r)
 {
+   struct threadobj *current = threadobj_current();
siginfo_t si;
int sig;
 
for (;;) {
+   current->run_state = __THREAD_S_DELAYED;
sig = __RT(sigwaitinfo(_set, ));
+   current->run_state = __THREAD_S_RUNNING;
if (sig == SIGPERIOD)
break;
if (errno == EINTR)


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


[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