[Xenomai-git] Gilles Chanteperdrix : cobalt/fpu: change fpu handling interface

2013-11-05 Thread git repository hosting
Module: xenomai-gch
Branch: for-forge
Commit: 0b9db0ef2e640d1f23ce55e1b6444c776202f317
URL:
http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=0b9db0ef2e640d1f23ce55e1b6444c776202f317

Author: Gilles Chanteperdrix gilles.chanteperd...@xenomai.org
Date:   Fri Oct 25 20:42:48 2013 +0200

cobalt/fpu: change fpu handling interface

For different reasons on x86 and ARM, implementing FPU switching in terms
of xnarch_enable_fpu/xnarch_save_fpu/xnarch_restore_fpu no longer really
makes sense. So, keep xnarch_save_fpu for migration, but replace
xnarch_enable_fpu and xnarch_restore_fpu with xnarch_switch_fpu(from, to).

A default implementation for xnarch_switch_fpu is provided which switches
fpu in terms of xnarch_save_fpu/xnarch_restore_fpu/xnarch_enable_fpu on
architectures where it still makes sense.

---

 kernel/cobalt/arch/arm/include/asm/xenomai/thread.h |4 +---
 kernel/cobalt/arch/arm/thread.c |   15 +++
 .../arch/blackfin/include/asm/xenomai/thread.h  |7 +--
 .../cobalt/arch/nios2/include/asm/xenomai/thread.h  |7 +--
 .../arch/powerpc/include/asm/xenomai/thread.h   |4 +---
 kernel/cobalt/arch/powerpc/thread.c |   19 +--
 kernel/cobalt/arch/sh/thread.c  |   19 +--
 kernel/cobalt/arch/x86/include/asm/xenomai/thread.h |   10 ++
 kernel/cobalt/arch/x86/thread.c |7 +--
 kernel/cobalt/thread.c  |   16 ++--
 10 files changed, 70 insertions(+), 38 deletions(-)

diff --git a/kernel/cobalt/arch/arm/include/asm/xenomai/thread.h 
b/kernel/cobalt/arch/arm/include/asm/xenomai/thread.h
index 8c42775..dd582d7 100644
--- a/kernel/cobalt/arch/arm/include/asm/xenomai/thread.h
+++ b/kernel/cobalt/arch/arm/include/asm/xenomai/thread.h
@@ -79,11 +79,9 @@ struct xnarchtcb {
 
 #define xnarch_fault_notify(d) (!xnarch_fault_bp_p(d))
 
-void xnarch_enable_fpu(struct xnthread *current_thread);
-
 void xnarch_save_fpu(struct xnthread *thread);
 
-void xnarch_restore_fpu(struct xnthread *thread);
+void xnarch_switch_fpu(struct xnthread *from, struct xnthread *thread);
 
 void xnarch_switch_to(struct xnthread *out, struct xnthread *in);
 
diff --git a/kernel/cobalt/arch/arm/thread.c b/kernel/cobalt/arch/arm/thread.c
index 4915d75..d8cc813 100644
--- a/kernel/cobalt/arch/arm/thread.c
+++ b/kernel/cobalt/arch/arm/thread.c
@@ -388,6 +388,21 @@ void xnarch_restore_fpu(struct xnthread *thread)
 #endif /* CONFIG_XENO_HW_FPU */
 }
 
+void xnarch_switch_fpu(struct xnthread *from, struct xnthread *to)
+{
+   if (from == to || 
+   xnarch_fpu_ptr(xnthread_archtcb(from)) == 
+   xnarch_fpu_ptr(xnthread_archtcb(to))) {
+   xnarch_enable_fpu(to);
+   return;
+   }
+   
+   if (from)
+   xnarch_save_fpu(from);
+   
+   xnarch_restore_fpu(to);
+}
+
 int xnarch_escalate(void)
 {
if (ipipe_root_p) {
diff --git a/kernel/cobalt/arch/blackfin/include/asm/xenomai/thread.h 
b/kernel/cobalt/arch/blackfin/include/asm/xenomai/thread.h
index 6c630e7..0ecb0ea 100644
--- a/kernel/cobalt/arch/blackfin/include/asm/xenomai/thread.h
+++ b/kernel/cobalt/arch/blackfin/include/asm/xenomai/thread.h
@@ -58,9 +58,12 @@ static inline void xnarch_init_root_tcb(struct xnthread 
*thread) { }
 static inline void xnarch_init_shadow_tcb(struct xnthread *thread) { }
 static inline void xnarch_enter_root(struct xnthread *root) { }
 static inline void xnarch_leave_root(struct xnthread *root) { }
-static inline void xnarch_enable_fpu(struct xnthread *current_thread) { }
 static inline void xnarch_save_fpu(struct xnthread *thread) { }
-static inline void xnarch_restore_fpu(struct xnthread *thread) { }
+static inline void
+xnarch_switch_fpu(struct xnthread *from, struct xnthread *thread)
+{ 
+   return 0;
+}
 
 static inline int 
 xnarch_handle_fpu_fault(struct xnthread *from, 
diff --git a/kernel/cobalt/arch/nios2/include/asm/xenomai/thread.h 
b/kernel/cobalt/arch/nios2/include/asm/xenomai/thread.h
index 05de3c2..87f5e17 100644
--- a/kernel/cobalt/arch/nios2/include/asm/xenomai/thread.h
+++ b/kernel/cobalt/arch/nios2/include/asm/xenomai/thread.h
@@ -53,9 +53,12 @@ static inline void xnarch_init_root_tcb(struct xnthread 
*thread) { }
 static inline void xnarch_init_shadow_tcb(struct xnthread *thread) { }
 static inline void xnarch_enter_root(struct xnthread *root) { }
 static inline void xnarch_leave_root(struct xnthread *thread) { }
-static inline void xnarch_enable_fpu(struct xnthread *thread) { }
 static inline void xnarch_save_fpu(struct xnthread *thread) { }
-static inline void xnarch_restore_fpu(struct xnthread *thread) { }
+static inline void
+xnarch_switch_fpu(struct xnthread *from, struct xnthread *to) 
+{ 
+   return 0;
+}
 
 static inline int 
 xnarch_handle_fpu_fault(struct xnthread *from, 
diff --git a/kernel/cobalt/arch/powerpc/include/asm/xenomai/thread.h 

[Xenomai-git] Gilles Chanteperdrix : cobalt/fpu: change fpu handling interface

2013-11-05 Thread git repository hosting
Module: xenomai-forge
Branch: master
Commit: 0b9db0ef2e640d1f23ce55e1b6444c776202f317
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=0b9db0ef2e640d1f23ce55e1b6444c776202f317

Author: Gilles Chanteperdrix gilles.chanteperd...@xenomai.org
Date:   Fri Oct 25 20:42:48 2013 +0200

cobalt/fpu: change fpu handling interface

For different reasons on x86 and ARM, implementing FPU switching in terms
of xnarch_enable_fpu/xnarch_save_fpu/xnarch_restore_fpu no longer really
makes sense. So, keep xnarch_save_fpu for migration, but replace
xnarch_enable_fpu and xnarch_restore_fpu with xnarch_switch_fpu(from, to).

A default implementation for xnarch_switch_fpu is provided which switches
fpu in terms of xnarch_save_fpu/xnarch_restore_fpu/xnarch_enable_fpu on
architectures where it still makes sense.

---

 kernel/cobalt/arch/arm/include/asm/xenomai/thread.h |4 +---
 kernel/cobalt/arch/arm/thread.c |   15 +++
 .../arch/blackfin/include/asm/xenomai/thread.h  |7 +--
 .../cobalt/arch/nios2/include/asm/xenomai/thread.h  |7 +--
 .../arch/powerpc/include/asm/xenomai/thread.h   |4 +---
 kernel/cobalt/arch/powerpc/thread.c |   19 +--
 kernel/cobalt/arch/sh/thread.c  |   19 +--
 kernel/cobalt/arch/x86/include/asm/xenomai/thread.h |   10 ++
 kernel/cobalt/arch/x86/thread.c |7 +--
 kernel/cobalt/thread.c  |   16 ++--
 10 files changed, 70 insertions(+), 38 deletions(-)

diff --git a/kernel/cobalt/arch/arm/include/asm/xenomai/thread.h 
b/kernel/cobalt/arch/arm/include/asm/xenomai/thread.h
index 8c42775..dd582d7 100644
--- a/kernel/cobalt/arch/arm/include/asm/xenomai/thread.h
+++ b/kernel/cobalt/arch/arm/include/asm/xenomai/thread.h
@@ -79,11 +79,9 @@ struct xnarchtcb {
 
 #define xnarch_fault_notify(d) (!xnarch_fault_bp_p(d))
 
-void xnarch_enable_fpu(struct xnthread *current_thread);
-
 void xnarch_save_fpu(struct xnthread *thread);
 
-void xnarch_restore_fpu(struct xnthread *thread);
+void xnarch_switch_fpu(struct xnthread *from, struct xnthread *thread);
 
 void xnarch_switch_to(struct xnthread *out, struct xnthread *in);
 
diff --git a/kernel/cobalt/arch/arm/thread.c b/kernel/cobalt/arch/arm/thread.c
index 4915d75..d8cc813 100644
--- a/kernel/cobalt/arch/arm/thread.c
+++ b/kernel/cobalt/arch/arm/thread.c
@@ -388,6 +388,21 @@ void xnarch_restore_fpu(struct xnthread *thread)
 #endif /* CONFIG_XENO_HW_FPU */
 }
 
+void xnarch_switch_fpu(struct xnthread *from, struct xnthread *to)
+{
+   if (from == to || 
+   xnarch_fpu_ptr(xnthread_archtcb(from)) == 
+   xnarch_fpu_ptr(xnthread_archtcb(to))) {
+   xnarch_enable_fpu(to);
+   return;
+   }
+   
+   if (from)
+   xnarch_save_fpu(from);
+   
+   xnarch_restore_fpu(to);
+}
+
 int xnarch_escalate(void)
 {
if (ipipe_root_p) {
diff --git a/kernel/cobalt/arch/blackfin/include/asm/xenomai/thread.h 
b/kernel/cobalt/arch/blackfin/include/asm/xenomai/thread.h
index 6c630e7..0ecb0ea 100644
--- a/kernel/cobalt/arch/blackfin/include/asm/xenomai/thread.h
+++ b/kernel/cobalt/arch/blackfin/include/asm/xenomai/thread.h
@@ -58,9 +58,12 @@ static inline void xnarch_init_root_tcb(struct xnthread 
*thread) { }
 static inline void xnarch_init_shadow_tcb(struct xnthread *thread) { }
 static inline void xnarch_enter_root(struct xnthread *root) { }
 static inline void xnarch_leave_root(struct xnthread *root) { }
-static inline void xnarch_enable_fpu(struct xnthread *current_thread) { }
 static inline void xnarch_save_fpu(struct xnthread *thread) { }
-static inline void xnarch_restore_fpu(struct xnthread *thread) { }
+static inline void
+xnarch_switch_fpu(struct xnthread *from, struct xnthread *thread)
+{ 
+   return 0;
+}
 
 static inline int 
 xnarch_handle_fpu_fault(struct xnthread *from, 
diff --git a/kernel/cobalt/arch/nios2/include/asm/xenomai/thread.h 
b/kernel/cobalt/arch/nios2/include/asm/xenomai/thread.h
index 05de3c2..87f5e17 100644
--- a/kernel/cobalt/arch/nios2/include/asm/xenomai/thread.h
+++ b/kernel/cobalt/arch/nios2/include/asm/xenomai/thread.h
@@ -53,9 +53,12 @@ static inline void xnarch_init_root_tcb(struct xnthread 
*thread) { }
 static inline void xnarch_init_shadow_tcb(struct xnthread *thread) { }
 static inline void xnarch_enter_root(struct xnthread *root) { }
 static inline void xnarch_leave_root(struct xnthread *thread) { }
-static inline void xnarch_enable_fpu(struct xnthread *thread) { }
 static inline void xnarch_save_fpu(struct xnthread *thread) { }
-static inline void xnarch_restore_fpu(struct xnthread *thread) { }
+static inline void
+xnarch_switch_fpu(struct xnthread *from, struct xnthread *to) 
+{ 
+   return 0;
+}
 
 static inline int 
 xnarch_handle_fpu_fault(struct xnthread *from, 
diff --git a/kernel/cobalt/arch/powerpc/include/asm/xenomai/thread.h 

[Xenomai-git] Gilles Chanteperdrix : cobalt/fpu: change fpu handling interface

2013-11-05 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: 0b9db0ef2e640d1f23ce55e1b6444c776202f317
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=0b9db0ef2e640d1f23ce55e1b6444c776202f317

Author: Gilles Chanteperdrix gilles.chanteperd...@xenomai.org
Date:   Fri Oct 25 20:42:48 2013 +0200

cobalt/fpu: change fpu handling interface

For different reasons on x86 and ARM, implementing FPU switching in terms
of xnarch_enable_fpu/xnarch_save_fpu/xnarch_restore_fpu no longer really
makes sense. So, keep xnarch_save_fpu for migration, but replace
xnarch_enable_fpu and xnarch_restore_fpu with xnarch_switch_fpu(from, to).

A default implementation for xnarch_switch_fpu is provided which switches
fpu in terms of xnarch_save_fpu/xnarch_restore_fpu/xnarch_enable_fpu on
architectures where it still makes sense.

---

 kernel/cobalt/arch/arm/include/asm/xenomai/thread.h |4 +---
 kernel/cobalt/arch/arm/thread.c |   15 +++
 .../arch/blackfin/include/asm/xenomai/thread.h  |7 +--
 .../cobalt/arch/nios2/include/asm/xenomai/thread.h  |7 +--
 .../arch/powerpc/include/asm/xenomai/thread.h   |4 +---
 kernel/cobalt/arch/powerpc/thread.c |   19 +--
 kernel/cobalt/arch/sh/thread.c  |   19 +--
 kernel/cobalt/arch/x86/include/asm/xenomai/thread.h |   10 ++
 kernel/cobalt/arch/x86/thread.c |7 +--
 kernel/cobalt/thread.c  |   16 ++--
 10 files changed, 70 insertions(+), 38 deletions(-)

diff --git a/kernel/cobalt/arch/arm/include/asm/xenomai/thread.h 
b/kernel/cobalt/arch/arm/include/asm/xenomai/thread.h
index 8c42775..dd582d7 100644
--- a/kernel/cobalt/arch/arm/include/asm/xenomai/thread.h
+++ b/kernel/cobalt/arch/arm/include/asm/xenomai/thread.h
@@ -79,11 +79,9 @@ struct xnarchtcb {
 
 #define xnarch_fault_notify(d) (!xnarch_fault_bp_p(d))
 
-void xnarch_enable_fpu(struct xnthread *current_thread);
-
 void xnarch_save_fpu(struct xnthread *thread);
 
-void xnarch_restore_fpu(struct xnthread *thread);
+void xnarch_switch_fpu(struct xnthread *from, struct xnthread *thread);
 
 void xnarch_switch_to(struct xnthread *out, struct xnthread *in);
 
diff --git a/kernel/cobalt/arch/arm/thread.c b/kernel/cobalt/arch/arm/thread.c
index 4915d75..d8cc813 100644
--- a/kernel/cobalt/arch/arm/thread.c
+++ b/kernel/cobalt/arch/arm/thread.c
@@ -388,6 +388,21 @@ void xnarch_restore_fpu(struct xnthread *thread)
 #endif /* CONFIG_XENO_HW_FPU */
 }
 
+void xnarch_switch_fpu(struct xnthread *from, struct xnthread *to)
+{
+   if (from == to || 
+   xnarch_fpu_ptr(xnthread_archtcb(from)) == 
+   xnarch_fpu_ptr(xnthread_archtcb(to))) {
+   xnarch_enable_fpu(to);
+   return;
+   }
+   
+   if (from)
+   xnarch_save_fpu(from);
+   
+   xnarch_restore_fpu(to);
+}
+
 int xnarch_escalate(void)
 {
if (ipipe_root_p) {
diff --git a/kernel/cobalt/arch/blackfin/include/asm/xenomai/thread.h 
b/kernel/cobalt/arch/blackfin/include/asm/xenomai/thread.h
index 6c630e7..0ecb0ea 100644
--- a/kernel/cobalt/arch/blackfin/include/asm/xenomai/thread.h
+++ b/kernel/cobalt/arch/blackfin/include/asm/xenomai/thread.h
@@ -58,9 +58,12 @@ static inline void xnarch_init_root_tcb(struct xnthread 
*thread) { }
 static inline void xnarch_init_shadow_tcb(struct xnthread *thread) { }
 static inline void xnarch_enter_root(struct xnthread *root) { }
 static inline void xnarch_leave_root(struct xnthread *root) { }
-static inline void xnarch_enable_fpu(struct xnthread *current_thread) { }
 static inline void xnarch_save_fpu(struct xnthread *thread) { }
-static inline void xnarch_restore_fpu(struct xnthread *thread) { }
+static inline void
+xnarch_switch_fpu(struct xnthread *from, struct xnthread *thread)
+{ 
+   return 0;
+}
 
 static inline int 
 xnarch_handle_fpu_fault(struct xnthread *from, 
diff --git a/kernel/cobalt/arch/nios2/include/asm/xenomai/thread.h 
b/kernel/cobalt/arch/nios2/include/asm/xenomai/thread.h
index 05de3c2..87f5e17 100644
--- a/kernel/cobalt/arch/nios2/include/asm/xenomai/thread.h
+++ b/kernel/cobalt/arch/nios2/include/asm/xenomai/thread.h
@@ -53,9 +53,12 @@ static inline void xnarch_init_root_tcb(struct xnthread 
*thread) { }
 static inline void xnarch_init_shadow_tcb(struct xnthread *thread) { }
 static inline void xnarch_enter_root(struct xnthread *root) { }
 static inline void xnarch_leave_root(struct xnthread *thread) { }
-static inline void xnarch_enable_fpu(struct xnthread *thread) { }
 static inline void xnarch_save_fpu(struct xnthread *thread) { }
-static inline void xnarch_restore_fpu(struct xnthread *thread) { }
+static inline void
+xnarch_switch_fpu(struct xnthread *from, struct xnthread *to) 
+{ 
+   return 0;
+}
 
 static inline int 
 xnarch_handle_fpu_fault(struct xnthread *from, 
diff --git a/kernel/cobalt/arch/powerpc/include/asm/xenomai/thread.h 

[Xenomai-git] Gilles Chanteperdrix : cobalt/fpu: change fpu handling interface

2013-10-26 Thread git repository hosting
Module: xenomai-gch
Branch: for-forge
Commit: f84ca88eccce9547e45fa273094923e4bd211f4e
URL:
http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=f84ca88eccce9547e45fa273094923e4bd211f4e

Author: Gilles Chanteperdrix gilles.chanteperd...@xenomai.org
Date:   Fri Oct 25 20:42:48 2013 +0200

cobalt/fpu: change fpu handling interface

For different reasons on x86 and ARM, implementing FPU switching in terms
of xnarch_enable_fpu/xnarch_save_fpu/xnarch_restore_fpu no longer really
makes sense. So, keep xnarch_save_fpu for migration, but replace
xnarch_enable_fpu and xnarch_restore_fpu with xnarch_switch_fpu(from, to).

A default implementation for xnarch_switch_fpu is provided which switches
fpu in terms of xnarch_save_fpu/xnarch_restore_fpu/xnarch_enable_fpu on
architectures where it still makes sense.

---

 kernel/cobalt/arch/arm/include/asm/xenomai/thread.h |4 +---
 kernel/cobalt/arch/arm/thread.c |   15 +++
 .../arch/blackfin/include/asm/xenomai/thread.h  |7 +--
 .../cobalt/arch/nios2/include/asm/xenomai/thread.h  |7 +--
 .../arch/powerpc/include/asm/xenomai/thread.h   |4 +---
 kernel/cobalt/arch/powerpc/thread.c |   19 +--
 kernel/cobalt/arch/sh/thread.c  |   19 +--
 kernel/cobalt/arch/x86/include/asm/xenomai/thread.h |   10 ++
 kernel/cobalt/arch/x86/thread.c |7 +--
 kernel/cobalt/thread.c  |   16 ++--
 10 files changed, 70 insertions(+), 38 deletions(-)

diff --git a/kernel/cobalt/arch/arm/include/asm/xenomai/thread.h 
b/kernel/cobalt/arch/arm/include/asm/xenomai/thread.h
index 8c42775..dd582d7 100644
--- a/kernel/cobalt/arch/arm/include/asm/xenomai/thread.h
+++ b/kernel/cobalt/arch/arm/include/asm/xenomai/thread.h
@@ -79,11 +79,9 @@ struct xnarchtcb {
 
 #define xnarch_fault_notify(d) (!xnarch_fault_bp_p(d))
 
-void xnarch_enable_fpu(struct xnthread *current_thread);
-
 void xnarch_save_fpu(struct xnthread *thread);
 
-void xnarch_restore_fpu(struct xnthread *thread);
+void xnarch_switch_fpu(struct xnthread *from, struct xnthread *thread);
 
 void xnarch_switch_to(struct xnthread *out, struct xnthread *in);
 
diff --git a/kernel/cobalt/arch/arm/thread.c b/kernel/cobalt/arch/arm/thread.c
index 7c68095..40f088a 100644
--- a/kernel/cobalt/arch/arm/thread.c
+++ b/kernel/cobalt/arch/arm/thread.c
@@ -393,6 +393,21 @@ void xnarch_restore_fpu(struct xnthread *thread)
 #endif /* CONFIG_XENO_HW_FPU */
 }
 
+void xnarch_switch_fpu(struct xnthread *from, struct xnthread *to)
+{
+   if (from == to || 
+   xnarch_fpu_ptr(xnthread_archtcb(from)) == 
+   xnarch_fpu_ptr(xnthread_archtcb(to))) {
+   xnarch_enable_fpu(to);
+   return;
+   }
+   
+   if (from)
+   xnarch_save_fpu(from);
+   
+   xnarch_restore_fpu(to);
+}
+
 int xnarch_escalate(void)
 {
if (ipipe_root_p) {
diff --git a/kernel/cobalt/arch/blackfin/include/asm/xenomai/thread.h 
b/kernel/cobalt/arch/blackfin/include/asm/xenomai/thread.h
index 6c630e7..0ecb0ea 100644
--- a/kernel/cobalt/arch/blackfin/include/asm/xenomai/thread.h
+++ b/kernel/cobalt/arch/blackfin/include/asm/xenomai/thread.h
@@ -58,9 +58,12 @@ static inline void xnarch_init_root_tcb(struct xnthread 
*thread) { }
 static inline void xnarch_init_shadow_tcb(struct xnthread *thread) { }
 static inline void xnarch_enter_root(struct xnthread *root) { }
 static inline void xnarch_leave_root(struct xnthread *root) { }
-static inline void xnarch_enable_fpu(struct xnthread *current_thread) { }
 static inline void xnarch_save_fpu(struct xnthread *thread) { }
-static inline void xnarch_restore_fpu(struct xnthread *thread) { }
+static inline void
+xnarch_switch_fpu(struct xnthread *from, struct xnthread *thread)
+{ 
+   return 0;
+}
 
 static inline int 
 xnarch_handle_fpu_fault(struct xnthread *from, 
diff --git a/kernel/cobalt/arch/nios2/include/asm/xenomai/thread.h 
b/kernel/cobalt/arch/nios2/include/asm/xenomai/thread.h
index 05de3c2..87f5e17 100644
--- a/kernel/cobalt/arch/nios2/include/asm/xenomai/thread.h
+++ b/kernel/cobalt/arch/nios2/include/asm/xenomai/thread.h
@@ -53,9 +53,12 @@ static inline void xnarch_init_root_tcb(struct xnthread 
*thread) { }
 static inline void xnarch_init_shadow_tcb(struct xnthread *thread) { }
 static inline void xnarch_enter_root(struct xnthread *root) { }
 static inline void xnarch_leave_root(struct xnthread *thread) { }
-static inline void xnarch_enable_fpu(struct xnthread *thread) { }
 static inline void xnarch_save_fpu(struct xnthread *thread) { }
-static inline void xnarch_restore_fpu(struct xnthread *thread) { }
+static inline void
+xnarch_switch_fpu(struct xnthread *from, struct xnthread *to) 
+{ 
+   return 0;
+}
 
 static inline int 
 xnarch_handle_fpu_fault(struct xnthread *from, 
diff --git a/kernel/cobalt/arch/powerpc/include/asm/xenomai/thread.h