Module: xenomai-gch
Branch: for-forge
Commit: 9e3bf070dc64e2359797260904b64a8a20317e07
URL:    
http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=9e3bf070dc64e2359797260904b64a8a20317e07

Author: Gilles Chanteperdrix <gilles.chanteperd...@xenomai.org>
Date:   Sat Oct 26 13:59:16 2013 +0200

cobalt/fpu: prepare for dynamic XNFPU

Architecture which want to implement dynamic XNFPU have to disable XNFPU
in xnarch_init_shadow_tcb, and enable it upon first FPU fault. As a consequence,
fpuholoder has to be updated when the FPU fault handler returned 1.

---

 kernel/cobalt/arch/arm/include/asm/xenomai/thread.h |    7 +------
 kernel/cobalt/arch/arm/thread.c                     |    7 +++++++
 kernel/cobalt/arch/sh/include/asm/xenomai/thread.h  |    6 +-----
 kernel/cobalt/arch/sh/thread.c                      |    6 ++++++
 kernel/cobalt/shadow.c                              |   18 +++++++++---------
 5 files changed, 24 insertions(+), 20 deletions(-)

diff --git a/kernel/cobalt/arch/arm/include/asm/xenomai/thread.h 
b/kernel/cobalt/arch/arm/include/asm/xenomai/thread.h
index 346e329..8b54b97 100644
--- a/kernel/cobalt/arch/arm/include/asm/xenomai/thread.h
+++ b/kernel/cobalt/arch/arm/include/asm/xenomai/thread.h
@@ -99,12 +99,7 @@ static inline void xnarch_init_root_tcb(struct xnthread 
*thread)
        tcb->fpup = NULL;
 }
 
-static inline void xnarch_init_shadow_tcb(struct xnthread *thread)
-{
-       struct xnarchtcb *tcb = xnthread_archtcb(thread);
-       tcb->fpup = (struct arm_fpustate *)
-               &task_thread_info(tcb->core.host_task)->used_cp[0];
-}
+void xnarch_init_shadow_tcb(struct xnthread *thread);
 
 int xnarch_fault_fpu_p(struct ipipe_trap_data *d);
 
diff --git a/kernel/cobalt/arch/arm/thread.c b/kernel/cobalt/arch/arm/thread.c
index 29a58fe..7c68095 100644
--- a/kernel/cobalt/arch/arm/thread.c
+++ b/kernel/cobalt/arch/arm/thread.c
@@ -402,3 +402,10 @@ int xnarch_escalate(void)
 
        return 0;
 }
+
+void xnarch_init_shadow_tcb(struct xnthread *thread)
+{
+       struct xnarchtcb *tcb = xnthread_archtcb(thread);
+       tcb->fpup = (struct arm_fpustate *)
+               &task_thread_info(tcb->core.host_task)->used_cp[0];
+}
diff --git a/kernel/cobalt/arch/sh/include/asm/xenomai/thread.h 
b/kernel/cobalt/arch/sh/include/asm/xenomai/thread.h
index 6bf7329..2c7fe88 100644
--- a/kernel/cobalt/arch/sh/include/asm/xenomai/thread.h
+++ b/kernel/cobalt/arch/sh/include/asm/xenomai/thread.h
@@ -60,11 +60,7 @@ static inline void xnarch_init_root_tcb(struct xnthread 
*thread)
        tcb->fpup = NULL;
 }
 
-static inline void xnarch_init_shadow_tcb(struct xnthread *thread)
-{
-       struct xnarchtcb *tcb = xnthread_archtcb(thread);
-       tcb->fpup = &tcb->core.host_task->thread;
-}
+void xnarch_init_shadow_tcb(struct xnthread *thread);
 
 #else /* !CONFIG_XENO_HW_FPU */
 
diff --git a/kernel/cobalt/arch/sh/thread.c b/kernel/cobalt/arch/sh/thread.c
index 4c8b532..78feb97 100644
--- a/kernel/cobalt/arch/sh/thread.c
+++ b/kernel/cobalt/arch/sh/thread.c
@@ -292,3 +292,9 @@ int xnarch_escalate(void)
 
        return 0;
 }
+
+void xnarch_init_shadow_tcb(struct xnthread *thread)
+{
+       struct xnarchtcb *tcb = xnthread_archtcb(thread);
+       tcb->fpup = &tcb->core.host_task->thread;
+}
diff --git a/kernel/cobalt/shadow.c b/kernel/cobalt/shadow.c
index 99ccee0..c858777 100644
--- a/kernel/cobalt/shadow.c
+++ b/kernel/cobalt/shadow.c
@@ -2591,12 +2591,14 @@ int ipipe_kevent_hook(int kevent, void *data)
 
 static inline int handle_exception(struct ipipe_trap_data *d)
 {
+       struct xnsched *sched;
        struct xnthread *thread;
 
-       if (xnsched_root_p())
-               return 0;
+       sched = xnsched_current();
+       thread = sched->curr;
 
-       thread = xnsched_current_thread();
+       if (xnthread_test_state(thread, XNROOT))
+               return 0;
 
        trace_mark(xn_nucleus, thread_fault,
                   "thread %p thread_name %s ip %p type 0x%x",
@@ -2605,17 +2607,15 @@ static inline int handle_exception(struct 
ipipe_trap_data *d)
                   xnarch_fault_trap(d));
 
        if (xnarch_fault_fpu_p(d)) {
-               if (!xnthread_test_state(thread, XNROOT)) {
-                       /* FPU exception received in primary mode. */
-                       if (xnarch_handle_fpu_fault(thread))
-                               return 1;
+               /* FPU exception received in primary mode. */
+               if (xnarch_handle_fpu_fault(thread)) {
+                       sched->fpuholder = thread;
+                       return 1;
                }
                print_symbol("invalid use of FPU in Xenomai context at %s\n",
                             xnarch_fault_pc(d));
        }
 
-       if (xnthread_test_state(thread, XNROOT))
-               return 0;
        /*
         * If we experienced a trap on behalf of a shadow thread
         * running in primary mode, move it to the Linux domain,


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

Reply via email to