Module: xenomai-forge
Branch: master
Commit: 2cc8900f6217dfb1d8c0b4934cc89129dfcff5b1
URL:    
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=2cc8900f6217dfb1d8c0b4934cc89129dfcff5b1

Author: Philippe Gerum <r...@xenomai.org>
Date:   Wed Aug  7 16:40:26 2013 +0200

cobalt/kernel: drop "sys" features file

This file used to be a kitchen sink although its contents could be
dispatched to better feature-specific places. Move them there instead,
and plug that sink.

---

 include/cobalt/kernel/Makefile.am   |    1 -
 include/cobalt/kernel/Makefile.in   |    1 -
 include/cobalt/kernel/sched.h       |   25 ++++
 include/cobalt/kernel/shadow.h      |   19 +++-
 include/cobalt/kernel/sys.h         |   83 -----------
 kernel/cobalt/Makefile              |    1 -
 kernel/cobalt/init.c                |  177 +++++++++++++++++++++++-
 kernel/cobalt/intr.c                |    2 +-
 kernel/cobalt/rtdm/internal.h       |    6 +-
 kernel/cobalt/sched.c               |    6 +-
 kernel/cobalt/shadow.c              |    8 +-
 kernel/cobalt/sys.c                 |  259 -----------------------------------
 kernel/cobalt/thread.c              |    1 -
 kernel/drivers/testing/switchtest.c |    1 -
 14 files changed, 230 insertions(+), 360 deletions(-)

diff --git a/include/cobalt/kernel/Makefile.am 
b/include/cobalt/kernel/Makefile.am
index 65824ba..e1653da 100644
--- a/include/cobalt/kernel/Makefile.am
+++ b/include/cobalt/kernel/Makefile.am
@@ -26,7 +26,6 @@ noinst_HEADERS =      \
        shadow.h        \
        stat.h          \
        synch.h         \
-       sys.h           \
        thread.h        \
        timer.h         \
        trace.h         \
diff --git a/include/cobalt/kernel/Makefile.in 
b/include/cobalt/kernel/Makefile.in
index e9d3ed0..e0ed379 100644
--- a/include/cobalt/kernel/Makefile.in
+++ b/include/cobalt/kernel/Makefile.in
@@ -272,7 +272,6 @@ noinst_HEADERS = \
        shadow.h        \
        stat.h          \
        synch.h         \
-       sys.h           \
        thread.h        \
        timer.h         \
        trace.h         \
diff --git a/include/cobalt/kernel/sched.h b/include/cobalt/kernel/sched.h
index e6751c4..2606b6c 100644
--- a/include/cobalt/kernel/sched.h
+++ b/include/cobalt/kernel/sched.h
@@ -36,6 +36,7 @@
 #include <cobalt/kernel/sched-sporadic.h>
 #include <cobalt/kernel/vfile.h>
 #include <cobalt/kernel/assert.h>
+#include <asm/xenomai/machine.h>
 
 /* Sched status flags */
 #define XNRESCHED      0x10000000      /* Needs rescheduling */
@@ -112,6 +113,8 @@ struct xnsched {
 
 DECLARE_PER_CPU(struct xnsched, nksched);
 
+extern cpumask_t nkaffinity;
+
 extern struct list_head nkthreadq;
 
 extern int nknrthreads;
@@ -200,6 +203,7 @@ static inline void xnsched_set_self_resched(struct xnsched 
*sched)
 
 /* Set resched flag for the given scheduler. */
 #ifdef CONFIG_SMP
+
 static inline void xnsched_set_resched(struct xnsched *sched)
 {
        struct xnsched *current_sched = xnsched_current();
@@ -212,13 +216,34 @@ static inline void xnsched_set_resched(struct xnsched 
*sched)
                current_sched->status |= XNRESCHED;
        }
 }
+
+#define xnsched_cpus xnarch_machdata.supported_cpus
+
+static inline int xnsched_supported_cpu(int cpu)
+{
+       return cpu_isset(cpu, xnsched_cpus);
+}
+
 #else /* !CONFIG_SMP */
+
 static inline void xnsched_set_resched(struct xnsched *sched)
 {
        xnsched_set_self_resched(sched);
 }
+
+#define xnsched_cpus CPU_MASK_ALL
+
+static inline int xnsched_supported_cpu(int cpu)
+{
+       return 1;
+}
+
 #endif /* !CONFIG_SMP */
 
+#define for_each_realtime_cpu(cpu)             \
+       for_each_online_cpu(cpu)                \
+               if (xnsched_supported_cpu(cpu)) \
+
 void __xnsched_run(struct xnsched *sched);
 
 void __xnsched_run_handler(void);
diff --git a/include/cobalt/kernel/shadow.h b/include/cobalt/kernel/shadow.h
index 6d3a90f..8f5b4cb 100644
--- a/include/cobalt/kernel/shadow.h
+++ b/include/cobalt/kernel/shadow.h
@@ -20,7 +20,6 @@
 #ifndef _COBALT_KERNEL_SHADOW_H
 #define _COBALT_KERNEL_SHADOW_H
 
-#include <cobalt/kernel/sys.h>
 #include <asm/xenomai/syscall.h>
 
 struct xnthread;
@@ -32,6 +31,22 @@ struct completion;
 struct module;
 struct xnshadow_ppd;
 
+struct xnpersonality {
+       const char *name;
+       unsigned int magic;
+       int nrcalls;
+       struct xnsyscall *syscalls;
+       atomic_t refcnt;
+       struct {
+               struct xnshadow_ppd *(*attach_process)(void);
+               void (*detach_process)(struct xnshadow_ppd *ppd);
+               struct xnpersonality *(*map_thread)(struct xnthread *thread);
+               struct xnpersonality *(*exit_thread)(struct xnthread *thread);
+               struct xnpersonality *(*finalize_thread)(struct xnthread 
*thread);
+       } ops;
+       struct module *module;
+};
+
 static inline struct xnthread *xnshadow_current(void)
 {
        return ipipe_current_threadinfo()->thread;
@@ -107,4 +122,6 @@ xnshadow_push_personality(struct xnthread *thread,
 void xnshadow_pop_personality(struct xnthread *thread,
                              struct xnpersonality *prev);
 
+extern struct xnpersonality xenomai_personality;
+
 #endif /* !_COBALT_KERNEL_SHADOW_H */
diff --git a/include/cobalt/kernel/sys.h b/include/cobalt/kernel/sys.h
deleted file mode 100644
index c95f9d9..0000000
--- a/include/cobalt/kernel/sys.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/**
- * Copyright (C) 2001-2013 Philippe Gerum <r...@xenomai.org>.
- * Copyright (C) 2001-2013 The Xenomai project <http://www.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.
- *
- * 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.
- *
- * @addtogroup nucleus
- * @{
- */
-#ifndef _COBALT_KERNEL_SYS_H
-#define _COBALT_KERNEL_SYS_H
-
-#include <asm/xenomai/machine.h>
-
-struct module;
-struct xnshadow_ppd;
-struct xnsyscall;
-struct xnthread;
-
-struct xnpersonality {
-       const char *name;
-       unsigned int magic;
-       int nrcalls;
-       struct xnsyscall *syscalls;
-       atomic_t refcnt;
-       struct {
-               struct xnshadow_ppd *(*attach_process)(void);
-               void (*detach_process)(struct xnshadow_ppd *ppd);
-               struct xnpersonality *(*map_thread)(struct xnthread *thread);
-               struct xnpersonality *(*exit_thread)(struct xnthread *thread);
-               struct xnpersonality *(*finalize_thread)(struct xnthread 
*thread);
-       } ops;
-       struct module *module;
-};
-
-#ifdef CONFIG_SMP
-
-#define xnsys_cpus xnarch_machdata.supported_cpus
-
-static inline int xnsys_supported_cpu(int cpu)
-{
-       return cpu_isset(cpu, xnsys_cpus);
-}
-
-#else  /* !CONFIG_SMP */
-
-#define xnsys_cpus CPU_MASK_ALL
-
-static inline int xnsys_supported_cpu(int cpu)
-{
-       return 1;
-}
-
-#endif /* !CONFIG_SMP */
-
-#define for_each_realtime_cpu(cpu)             \
-       for_each_online_cpu(cpu)                \
-               if (xnsys_supported_cpu(cpu))   \
-
-extern cpumask_t nkaffinity;
-
-extern struct xnpersonality xenomai_personality;
-
-int xnsys_init(void);
-
-void xnsys_shutdown(void);
-
-/* @} */
-
-#endif /* !_COBALT_KERNEL_SYS_H */
diff --git a/kernel/cobalt/Makefile b/kernel/cobalt/Makefile
index dc053ee..fd8acb0 100644
--- a/kernel/cobalt/Makefile
+++ b/kernel/cobalt/Makefile
@@ -16,7 +16,6 @@ xenomai-y :=  apc.o           \
                select.o        \
                shadow.o        \
                synch.o         \
-               sys.o           \
                thread.o        \
                timer.o
 
diff --git a/kernel/cobalt/init.c b/kernel/cobalt/init.c
index 5606bbc..da9276c 100644
--- a/kernel/cobalt/init.c
+++ b/kernel/cobalt/init.c
@@ -72,6 +72,65 @@ EXPORT_SYMBOL_GPL(__xnsys_global_ppd);
 #define boot_notice ""
 #endif
 
+static void disable_timesource(void)
+{
+       int cpu;
+
+       trace_mark(xn_nucleus, disable_timesource, MARK_NOARGS);
+
+       /*
+        * We must not hold the nklock while stopping the hardware
+        * timer, since this could cause deadlock situations to arise
+        * on SMP systems.
+        */
+       for_each_realtime_cpu(cpu)
+               xntimer_release_hardware(cpu);
+
+#ifdef CONFIG_XENO_OPT_STATS
+       xnintr_destroy(&nktimer);
+#endif /* CONFIG_XENO_OPT_STATS */
+}
+
+static void flush_heap(struct xnheap *heap,
+                      void *extaddr, unsigned long extsize, void *cookie)
+{
+       free_pages_exact(extaddr, extsize);
+}
+
+static void sys_shutdown(void)
+{
+       struct xnthread *thread, *tmp;
+       struct xnsched *sched;
+       int cpu;
+       spl_t s;
+
+       disable_timesource();
+       xnshadow_release_events();
+#ifdef CONFIG_SMP
+       ipipe_free_irq(&xnarch_machdata.domain, IPIPE_RESCHEDULE_IPI);
+#endif
+
+       xnlock_get_irqsave(&nklock, s);
+
+       /* NOTE: &nkthreadq can't be empty (root thread(s)). */
+       list_for_each_entry_safe(thread, tmp, &nkthreadq, glink) {
+               if (!xnthread_test_state(thread, XNROOT))
+                       xnthread_cancel(thread);
+       }
+
+       xnsched_run();
+
+       for_each_realtime_cpu(cpu) {
+               sched = xnsched_struct(cpu);
+               xnsched_destroy(sched);
+       }
+
+       xnlock_put_irqrestore(&nklock, s);
+
+       xnregistry_cleanup();
+       xnheap_destroy(&kheap, flush_heap, NULL);
+}
+
 static int __init mach_setup(void)
 {
        int ret, virq, __maybe_unused cpu;
@@ -85,7 +144,7 @@ static int __init mach_setup(void)
        }
 #endif /* CONFIG_SMP */
 
-       ret = ipipe_select_timers(&xnsys_cpus);
+       ret = ipipe_select_timers(&xnsched_cpus);
        if (ret < 0)
                return ret;
 
@@ -169,6 +228,116 @@ static __init void mach_cleanup(void)
        xnclock_cleanup();
 }
 
+static __init int enable_timesource(void)
+{
+       struct xnsched *sched;
+       int htickval, cpu;
+       spl_t s;
+
+       trace_mark(xn_nucleus, enable_timesource, MARK_NOARGS);
+
+#ifdef CONFIG_XENO_OPT_STATS
+       /*
+        * Only for statistical purpose, the timer interrupt is
+        * attached by xntimer_grab_hardware().
+        */
+       xnintr_init(&nktimer, "[timer]",
+                   per_cpu(ipipe_percpu.hrtimer_irq, 0), NULL, NULL, 0);
+#endif /* CONFIG_XENO_OPT_STATS */
+
+       nkclock.wallclock_offset =
+               xnclock_get_host_time() - xnclock_read_monotonic(&nkclock);
+       nkvdso->wallclock_offset = nkclock.wallclock_offset;
+
+       for_each_realtime_cpu(cpu) {
+               htickval = xntimer_grab_hardware(cpu);
+               if (htickval < 0) {
+                       while (--cpu >= 0)
+                               xntimer_release_hardware(cpu);
+
+                       return htickval;
+               }
+
+               xnlock_get_irqsave(&nklock, s);
+
+               /* If the current tick device for the target CPU is
+                * periodic, we won't be called back for host tick
+                * emulation. Therefore, we need to start a periodic
+                * nucleus timer which will emulate the ticking for
+                * that CPU, since we are going to hijack the hw clock
+                * chip for managing our own system timer.
+                *
+                * CAUTION:
+                *
+                * - nucleus timers may be started only _after_ the hw
+                * timer has been set up for the target CPU through a
+                * call to xntimer_grab_hardware().
+                *
+                * - we don't compensate for the elapsed portion of
+                * the current host tick, since we cannot get this
+                * information easily for all CPUs except the current
+                * one, and also because of the declining relevance of
+                * the jiffies clocksource anyway.
+                *
+                * - we must not hold the nklock across calls to
+                * xntimer_grab_hardware().
+                */
+
+               sched = xnsched_struct(cpu);
+               if (htickval > 1)
+                       xntimer_start(&sched->htimer, htickval, htickval, 
XN_RELATIVE);
+               else if (htickval == 1)
+                       xntimer_start(&sched->htimer, 0, 0, XN_RELATIVE);
+
+#if defined(CONFIG_XENO_OPT_WATCHDOG)
+               xntimer_start(&sched->wdtimer, 1000000000UL, 1000000000UL, 
XN_RELATIVE);
+               xnsched_reset_watchdog(sched);
+#endif /* CONFIG_XENO_OPT_WATCHDOG */
+               xnlock_put_irqrestore(&nklock, s);
+       }
+
+       return 0;
+}
+
+static __init int sys_init(void)
+{
+       struct xnsched *sched;
+       void *heapaddr;
+       int ret, cpu;
+
+       heapaddr = alloc_pages_exact(CONFIG_XENO_OPT_SYS_HEAPSZ * 1024, 
GFP_KERNEL);
+       if (heapaddr == NULL ||
+           xnheap_init(&kheap, heapaddr, CONFIG_XENO_OPT_SYS_HEAPSZ * 1024,
+                       XNHEAP_PAGE_SIZE) != 0) {
+               return -ENOMEM;
+       }
+       xnheap_set_label(&kheap, "main heap");
+
+       for_each_realtime_cpu(cpu) {
+               sched = &per_cpu(nksched, cpu);
+               xnsched_init(sched, cpu);
+       }
+
+#ifdef CONFIG_SMP
+       ipipe_request_irq(&xnarch_machdata.domain,
+                         IPIPE_RESCHEDULE_IPI,
+                         (ipipe_irq_handler_t)__xnsched_run_handler,
+                         NULL, NULL);
+#endif
+
+       xnregistry_init();
+
+       nkpanic = __xnsys_fatal;
+       smp_wmb();
+       xnshadow_grab_events();
+
+       ret = enable_timesource();
+       if (ret)
+               sys_shutdown();
+
+       return ret;
+}
+
 static int __init xenomai_init(void)
 {
        int ret;
@@ -206,7 +375,7 @@ static int __init xenomai_init(void)
        if (ret)
                goto cleanup_select;
 
-       ret = xnsys_init();
+       ret = sys_init();
        if (ret)
                goto cleanup_shadow;
 
@@ -218,7 +387,7 @@ static int __init xenomai_init(void)
        if (ret)
                goto cleanup_rtdm;
 
-       cpus_and(nkaffinity, nkaffinity, xnsys_cpus);
+       cpus_and(nkaffinity, nkaffinity, xnsched_cpus);
 
        printk(XENO_INFO "Cobalt v%s enabled%s\n",
               XENO_VERSION_STRING, boot_notice);
@@ -228,7 +397,7 @@ static int __init xenomai_init(void)
 cleanup_rtdm:
        rtdm_cleanup();
 cleanup_sys:
-       xnsys_shutdown();
+       sys_shutdown();
 cleanup_shadow:
        xnshadow_cleanup();
 cleanup_select:
diff --git a/kernel/cobalt/intr.c b/kernel/cobalt/intr.c
index d315b25..fecd190 100644
--- a/kernel/cobalt/intr.c
+++ b/kernel/cobalt/intr.c
@@ -1107,7 +1107,7 @@ static ssize_t affinity_vfile_store(struct xnvfile_input 
*input)
                if (val & 1)
                        cpu_set(cpu, new_affinity);
 
-       cpus_and(nkaffinity, new_affinity, xnsys_cpus);
+       cpus_and(nkaffinity, new_affinity, xnsched_cpus);
 
        return ret;
 }
diff --git a/kernel/cobalt/rtdm/internal.h b/kernel/cobalt/rtdm/internal.h
index f953c55..ead3e8d 100644
--- a/kernel/cobalt/rtdm/internal.h
+++ b/kernel/cobalt/rtdm/internal.h
@@ -20,12 +20,10 @@
 #ifndef _RTDM_INTERNAL_H
 #define _RTDM_INTERNAL_H
 
-#include <cobalt/kernel/sys.h>
-#include <cobalt/kernel/ppd.h>
-#include <rtdm/rtdm_driver.h>
-
 #include <linux/list.h>
 #include <linux/sem.h>
+#include <cobalt/kernel/ppd.h>
+#include <rtdm/rtdm_driver.h>
 
 #define RTDM_FD_MAX                    CONFIG_XENO_OPT_RTDM_FILDES
 
diff --git a/kernel/cobalt/sched.c b/kernel/cobalt/sched.c
index d46ff36..f3c9b65 100644
--- a/kernel/cobalt/sched.c
+++ b/kernel/cobalt/sched.c
@@ -25,12 +25,14 @@
 #include <cobalt/kernel/heap.h>
 #include <cobalt/kernel/shadow.h>
 #include <cobalt/kernel/arith.h>
-#include <cobalt/kernel/sys.h>
 #include <asm/xenomai/thread.h>
 
 DEFINE_PER_CPU(struct xnsched, nksched);
 EXPORT_PER_CPU_SYMBOL_GPL(nksched);
 
+cpumask_t nkaffinity = CPU_MASK_ALL;
+EXPORT_SYMBOL_GPL(nkaffinity);
+
 LIST_HEAD(nkthreadq);
 
 int nknrthreads;
@@ -1074,7 +1076,7 @@ scan_irqs:
                return VFILE_SEQ_SKIP;
        }
 
-       if (!xnsys_supported_cpu(priv->intr_it.cpu))
+       if (!xnsched_supported_cpu(priv->intr_it.cpu))
                return VFILE_SEQ_SKIP;
 
        p->cpu = priv->intr_it.cpu;
diff --git a/kernel/cobalt/shadow.c b/kernel/cobalt/shadow.c
index 8f0d93d..b8c63d9 100644
--- a/kernel/cobalt/shadow.c
+++ b/kernel/cobalt/shadow.c
@@ -57,7 +57,6 @@
 #include <cobalt/kernel/stat.h>
 #include <cobalt/kernel/ppd.h>
 #include <cobalt/kernel/vdso.h>
-#include <cobalt/kernel/sys.h>
 #include <asm/xenomai/features.h>
 #include <asm/xenomai/syscall.h>
 #include <asm/xenomai/thread.h>
@@ -2543,4 +2542,11 @@ void xnshadow_cleanup(void)
        xndebug_cleanup();
 }
 
+/* Xenomai's generic personality. */
+struct xnpersonality xenomai_personality = {
+       .name = "xenomai",
+       /* .magic = 0 */
+};
+EXPORT_SYMBOL_GPL(xenomai_personality);
+
 /*@}*/
diff --git a/kernel/cobalt/sys.c b/kernel/cobalt/sys.c
deleted file mode 100644
index 4003ac0..0000000
--- a/kernel/cobalt/sys.c
+++ /dev/null
@@ -1,259 +0,0 @@
-/**
- * Copyright (C) 2001-2013 Philippe Gerum <r...@xenomai.org>.
- * Copyright (C) 2001-2013 The Xenomai project <http://www.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.
- *
- * 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.
- *
- * @defgroup nucleus Xenomai core services.
- * @{
- */
-#include <cobalt/kernel/sched.h>
-#include <cobalt/kernel/timer.h>
-#include <cobalt/kernel/intr.h>
-#include <cobalt/kernel/heap.h>
-#include <cobalt/kernel/clock.h>
-#include <cobalt/kernel/trace.h>
-#include <cobalt/kernel/assert.h>
-#include <cobalt/kernel/select.h>
-#include <cobalt/kernel/shadow.h>
-#include <cobalt/kernel/lock.h>
-#include <cobalt/kernel/vdso.h>
-#include <cobalt/kernel/sys.h>
-
-cpumask_t nkaffinity = CPU_MASK_ALL;
-
-static int enable_timesource(void)
-{
-       struct xnsched *sched;
-       int htickval, cpu;
-       spl_t s;
-
-       trace_mark(xn_nucleus, enable_timesource, MARK_NOARGS);
-
-#ifdef CONFIG_XENO_OPT_STATS
-       /*
-        * Only for statistical purpose, the timer interrupt is
-        * attached by xntimer_grab_hardware().
-        */
-       xnintr_init(&nktimer, "[timer]",
-                   per_cpu(ipipe_percpu.hrtimer_irq, 0), NULL, NULL, 0);
-#endif /* CONFIG_XENO_OPT_STATS */
-
-       nkclock.wallclock_offset =
-               xnclock_get_host_time() - xnclock_read_monotonic(&nkclock);
-       nkvdso->wallclock_offset = nkclock.wallclock_offset;
-
-       for_each_realtime_cpu(cpu) {
-               htickval = xntimer_grab_hardware(cpu);
-               if (htickval < 0) {
-                       while (--cpu >= 0)
-                               xntimer_release_hardware(cpu);
-
-                       return htickval;
-               }
-
-               xnlock_get_irqsave(&nklock, s);
-
-               /* If the current tick device for the target CPU is
-                * periodic, we won't be called back for host tick
-                * emulation. Therefore, we need to start a periodic
-                * nucleus timer which will emulate the ticking for
-                * that CPU, since we are going to hijack the hw clock
-                * chip for managing our own system timer.
-                *
-                * CAUTION:
-                *
-                * - nucleus timers may be started only _after_ the hw
-                * timer has been set up for the target CPU through a
-                * call to xntimer_grab_hardware().
-                *
-                * - we don't compensate for the elapsed portion of
-                * the current host tick, since we cannot get this
-                * information easily for all CPUs except the current
-                * one, and also because of the declining relevance of
-                * the jiffies clocksource anyway.
-                *
-                * - we must not hold the nklock across calls to
-                * xntimer_grab_hardware().
-                */
-
-               sched = xnsched_struct(cpu);
-               if (htickval > 1)
-                       xntimer_start(&sched->htimer, htickval, htickval, 
XN_RELATIVE);
-               else if (htickval == 1)
-                       xntimer_start(&sched->htimer, 0, 0, XN_RELATIVE);
-
-#if defined(CONFIG_XENO_OPT_WATCHDOG)
-               xntimer_start(&sched->wdtimer, 1000000000UL, 1000000000UL, 
XN_RELATIVE);
-               xnsched_reset_watchdog(sched);
-#endif /* CONFIG_XENO_OPT_WATCHDOG */
-               xnlock_put_irqrestore(&nklock, s);
-       }
-
-       return 0;
-}
-
-/**
- * @fn int xnsys_init(void)
- * @brief Bootstrap the Xenomai core system.
- *
- * This call runs once in the kernel's lifetime at bootup. Basically,
- * the main heap is allocated early, the scheduler is initialized and the
- * core clock event source is enabled.
- *
- * @return 0 is returned on success. Otherwise:
- *
- * - -ENOMEM is returned if the memory manager fails to initialize.
- *
- * - -ENODEV is returned if a failure occurred while configuring the
- * hardware timer.
- *
- * Environments:
- *
- * This service can be called from:
- *
- * - Kernel module initialization code
- *
- * @note On every architecture, Xenomai directly manages a hardware
- * timer clocked in one-shot mode, to support any number of software
- * timers internally. Timings are always specified as a count of
- * nanoseconds.
- *
- * enable_timesource() configures the hardware timer chip. Because
- * Xenomai often interposes on the system timer used by the Linux
- * kernel, a software timer may be started to relay ticks to the host
- * kernel if needed.
- */
-int xnsys_init(void)
-{
-       struct xnsched *sched;
-       void *heapaddr;
-       int ret, cpu;
-
-       heapaddr = alloc_pages_exact(CONFIG_XENO_OPT_SYS_HEAPSZ * 1024, 
GFP_KERNEL);
-       if (heapaddr == NULL ||
-           xnheap_init(&kheap, heapaddr, CONFIG_XENO_OPT_SYS_HEAPSZ * 1024,
-                       XNHEAP_PAGE_SIZE) != 0) {
-               return -ENOMEM;
-       }
-       xnheap_set_label(&kheap, "main heap");
-
-       for_each_realtime_cpu(cpu) {
-               sched = &per_cpu(nksched, cpu);
-               xnsched_init(sched, cpu);
-       }
-
-#ifdef CONFIG_SMP
-       ipipe_request_irq(&xnarch_machdata.domain,
-                         IPIPE_RESCHEDULE_IPI,
-                         (ipipe_irq_handler_t)__xnsched_run_handler,
-                         NULL, NULL);
-#endif
-
-       xnregistry_init();
-
-       nkpanic = __xnsys_fatal;
-       smp_wmb();
-       xnshadow_grab_events();
-
-       ret = enable_timesource();
-       if (ret)
-               xnsys_shutdown();
-
-       return ret;
-}
-
-static void disable_timesource(void)
-{
-       int cpu;
-
-       trace_mark(xn_nucleus, disable_timesource, MARK_NOARGS);
-
-       /*
-        * We must not hold the nklock while stopping the hardware
-        * timer, since this could cause deadlock situations to arise
-        * on SMP systems.
-        */
-       for_each_realtime_cpu(cpu)
-               xntimer_release_hardware(cpu);
-
-#ifdef CONFIG_XENO_OPT_STATS
-       xnintr_destroy(&nktimer);
-#endif /* CONFIG_XENO_OPT_STATS */
-}
-
-static void flush_heap(struct xnheap *heap,
-                      void *extaddr, unsigned long extsize, void *cookie)
-{
-       free_pages_exact(extaddr, extsize);
-}
-
-/**
- * @fn void xnsys_shutdown(void)
- * @brief Shutdown the Xenomai system.
- *
- * Forcibly shutdowns the system. All existing threads (but the root
- * one) are terminated.
- *
- * Environments:
- *
- * This service can be called from:
- *
- * - Kernel module initialization/cleanup code
- */
-void xnsys_shutdown(void)
-{
-       struct xnthread *thread, *tmp;
-       struct xnsched *sched;
-       int cpu;
-       spl_t s;
-
-       disable_timesource();
-       xnshadow_release_events();
-#ifdef CONFIG_SMP
-       ipipe_free_irq(&xnarch_machdata.domain, IPIPE_RESCHEDULE_IPI);
-#endif
-
-       xnlock_get_irqsave(&nklock, s);
-
-       /* NOTE: &nkthreadq can't be empty (root thread(s)). */
-       list_for_each_entry_safe(thread, tmp, &nkthreadq, glink) {
-               if (!xnthread_test_state(thread, XNROOT))
-                       xnthread_cancel(thread);
-       }
-
-       xnsched_run();
-
-       for_each_realtime_cpu(cpu) {
-               sched = xnsched_struct(cpu);
-               xnsched_destroy(sched);
-       }
-
-       xnlock_put_irqrestore(&nklock, s);
-
-       xnregistry_cleanup();
-       xnheap_destroy(&kheap, flush_heap, NULL);
-}
-EXPORT_SYMBOL_GPL(xnsys_shutdown);
-
-/* Xenomai's generic personality. */
-struct xnpersonality xenomai_personality = {
-       .name = "xenomai",
-       /* .magic = 0 */
-};
-EXPORT_SYMBOL_GPL(xenomai_personality);
-
-/* @} */
diff --git a/kernel/cobalt/thread.c b/kernel/cobalt/thread.c
index d41da62..976f1e1 100644
--- a/kernel/cobalt/thread.c
+++ b/kernel/cobalt/thread.c
@@ -35,7 +35,6 @@
 #include <cobalt/kernel/select.h>
 #include <cobalt/kernel/shadow.h>
 #include <cobalt/kernel/lock.h>
-#include <cobalt/kernel/sys.h>
 #include <cobalt/kernel/thread.h>
 #include <asm/xenomai/thread.h>
 
diff --git a/kernel/drivers/testing/switchtest.c 
b/kernel/drivers/testing/switchtest.c
index 48c318c..235c0e5 100644
--- a/kernel/drivers/testing/switchtest.c
+++ b/kernel/drivers/testing/switchtest.c
@@ -1,6 +1,5 @@
 #include <linux/vmalloc.h>
 #include <linux/semaphore.h>
-#include <cobalt/kernel/sys.h>
 #include <cobalt/kernel/sched.h>
 #include <cobalt/kernel/synch.h>
 #include <cobalt/kernel/thread.h>


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

Reply via email to