Module: xenomai-gch
Branch: fpu-tracer
Commit: 9f9a8a505623c7769582bb03ba7e41e5629a31ef
URL:    
http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=9f9a8a505623c7769582bb03ba7e41e5629a31ef

Author: Gilles Chanteperdrix <gilles.chanteperd...@xenomai.org>
Date:   Tue Aug 11 23:50:02 2009 +0200

fpu-tracer for powerpc now working

---

 include/asm-powerpc/bits/pod.h |   50 ++++++++++++++++++++++++++++++++-------
 ksrc/arch/powerpc/Config.in    |    3 ++
 ksrc/arch/powerpc/fpu.S        |   18 ++++++++++++++
 ksrc/nucleus/pod.c             |    2 +
 ksrc/nucleus/shadow.c          |    2 -
 5 files changed, 64 insertions(+), 11 deletions(-)

diff --git a/include/asm-powerpc/bits/pod.h b/include/asm-powerpc/bits/pod.h
index 8f52f7b..0d47a22 100644
--- a/include/asm-powerpc/bits/pod.h
+++ b/include/asm-powerpc/bits/pod.h
@@ -24,6 +24,7 @@
 #define _XENO_ASM_POWERPC_BITS_POD_H
 
 #include <asm-generic/xenomai/bits/pod.h>
+#include <nucleus/fpu_trace.h>
 
 void xnpod_welcome_thread(struct xnthread *, int);
 
@@ -55,6 +56,7 @@ static inline void xnarch_leave_root(xnarchtcb_t * rootcb)
        /* So that xnarch_save_fpu() will operate on the right FPU area. */
        rootcb->fpup = rootcb->user_fpu_owner ?
                &rootcb->user_fpu_owner->thread : NULL;
+       fp_trace_xeno_leave_root(rootcb->user_fpu_owner == current ? 1 : 2);
 #endif /* CONFIG_XENO_HW_FPU */
 }
 
@@ -199,6 +201,7 @@ static void xnarch_init_fpu(xnarchtcb_t * tcb)
         * in tcb.
         */
        rthal_init_fpu(&tcb->ts);
+       fp_trace_xeno_init(1, tcb);
 #endif /* CONFIG_XENO_HW_FPU */
 }
 
@@ -206,11 +209,14 @@ static inline void xnarch_enable_fpu(xnarchtcb_t *tcb)
 {
 #ifdef CONFIG_XENO_HW_FPU
        struct task_struct *task = tcb->user_task;
-
-        if (task && task != tcb->user_fpu_owner)
+ 
+       if (task && task != tcb->user_fpu_owner) {
                rthal_disable_fpu();
-       else
+               fp_trace_xeno_enable(1, 0, tcb);
+       } else {
                rthal_enable_fpu();
+               fp_trace_xeno_enable(2, 0, tcb);
+       }
 #endif /* CONFIG_XENO_HW_FPU */
 }
 
@@ -221,9 +227,13 @@ static void xnarch_save_fpu(xnarchtcb_t * tcb)
                rthal_save_fpu(tcb->fpup);
 
                if (tcb->user_fpu_owner &&
-                   tcb->user_fpu_owner->thread.regs)
+                   tcb->user_fpu_owner->thread.regs) {
                        tcb->user_fpu_owner->thread.regs->msr &= 
~(MSR_FP|MSR_FE0|MSR_FE1);
-       }
+                       fp_trace_xeno_save(1, 1, tcb);
+               } else
+                       fp_trace_xeno_save(2, 1, tcb);
+       } else
+               fp_trace_xeno_save(3, 1, tcb);
 #endif /* CONFIG_XENO_HW_FPU */
 }
 
@@ -232,6 +242,7 @@ static void xnarch_restore_fpu(xnarchtcb_t * tcb)
 #ifdef CONFIG_XENO_HW_FPU
        struct thread_struct *ts;
        struct pt_regs *regs;
+       unsigned branch;
 
        if (tcb->fpup) {
                rthal_restore_fpu(tcb->fpup);
@@ -245,16 +256,37 @@ static void xnarch_restore_fpu(xnarchtcb_t * tcb)
                        if (regs) {
                                regs->msr &= ~(MSR_FE0|MSR_FE1);
                                regs->msr |= (MSR_FP|ts->fpexc_mode);
-                       }
-               }
-       }
+                               branch = 1;
+                       } else
+                               branch = 2;
+               } else
+                       branch = 3;
+       } else
+               branch = 4;
        /*
         * FIXME: We restore FPU "as it was" when Xenomai preempted Linux,
         * whereas we could be much lazier.
         */
-        if (tcb->user_task && tcb->user_task != tcb->user_fpu_owner)
+        if (tcb->user_task && tcb->user_task != tcb->user_fpu_owner) {
+               fp_trace_xeno_restore(branch, 1, tcb);
                rthal_disable_fpu();
+       } else
+               fp_trace_xeno_restore(branch + 10, 1, tcb);
+#endif /* CONFIG_XENO_HW_FPU */
+}
 
+static inline void xnarch_enable_fpu(xnarchtcb_t *tcb)
+{
+#ifdef CONFIG_XENO_HW_FPU
+       struct task_struct *task = tcb->user_task;
+
+        if (task && task != tcb->user_fpu_owner) {
+               rthal_disable_fpu();
+               fp_trace_xeno_enable(1, 0, tcb);
+       } else {
+               rthal_enable_fpu();
+               fp_trace_xeno_enable(2, 0, tcb);
+       }
 #endif /* CONFIG_XENO_HW_FPU */
 }
 
diff --git a/ksrc/arch/powerpc/Config.in b/ksrc/arch/powerpc/Config.in
index d0b26db..a24fd0f 100644
--- a/ksrc/arch/powerpc/Config.in
+++ b/ksrc/arch/powerpc/Config.in
@@ -14,6 +14,9 @@ else
        mainmenu_option next_comment
        comment 'Machine'
        bool 'Enable FPU support' CONFIG_XENO_HW_FPU
+        if [ "$CONFIG_XENO_HW_FPU" = "y" ]; then
+               bool 'Enable FPU tracer' CONFIG_XENO_HW_FPU_TRACER
+       fi
        endmenu
     fi
 fi
diff --git a/ksrc/arch/powerpc/fpu.S b/ksrc/arch/powerpc/fpu.S
index e0adf90..ff9b5d7 100644
--- a/ksrc/arch/powerpc/fpu.S
+++ b/ksrc/arch/powerpc/fpu.S
@@ -72,6 +72,24 @@ _GLOBAL(rthal_save_fpu)
        SAVE_32FPRS(0,r3)
        mffs    fr0
        stfd    fr0,__FPSCR(r3)
+       lfd     fr0,THREAD_FPR0(r3)     
+       blr
+
+/* r3 = &fpenv */
+_GLOBAL(rthal_save_fpu_trace)
+       mfmsr   r5
+       ori     r6,r5,MSR_FP
+       SYNC
+       MTMSRD(r6)
+       isync
+       addi    r3,r3,-THREAD_FPR0
+       SAVE_32FPRS(0,r3)
+       mffs    fr0
+       stfd    fr0,__FPSCR(r3)
+       lfd     fr0,THREAD_FPR0(r3)     
+       SYNC
+       MTMSRD(r5)
+       isync
        blr
 
 /* r3 = &thread_struct */
diff --git a/ksrc/nucleus/pod.c b/ksrc/nucleus/pod.c
index 76e1fe1..d891960 100644
--- a/ksrc/nucleus/pod.c
+++ b/ksrc/nucleus/pod.c
@@ -2044,6 +2044,8 @@ static inline void xnpod_switch_to(xnsched_t *sched,
        xnlock_clear_irqon(&nklock);
 #endif /* !CONFIG_XENO_HW_UNLOCKED_SWITCH */
 
+       fp_trace_xeno_switch(threadout, threadin);
+
        xnarch_switch_to(xnthread_archtcb(prev),
                         xnthread_archtcb(next));
 }
diff --git a/ksrc/nucleus/shadow.c b/ksrc/nucleus/shadow.c
index 2b51c99..d1ae1a8 100644
--- a/ksrc/nucleus/shadow.c
+++ b/ksrc/nucleus/shadow.c
@@ -50,9 +50,7 @@
 #include <nucleus/trace.h>
 #include <nucleus/stat.h>
 #include <nucleus/sys_ppd.h>
-
 #include <nucleus/fpu_trace.h>
-
 #include <asm/xenomai/features.h>
 #include <asm/xenomai/syscall.h>
 #include <asm/xenomai/bits/shadow.h>


_______________________________________________
Xenomai-git mailing list
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git

Reply via email to