Module: xenomai-2.6 Branch: master Commit: 2e80e0331f891cec4834ab520aabce4f0e63fc5d URL: http://git.xenomai.org/?p=xenomai-2.6.git;a=commit;h=2e80e0331f891cec4834ab520aabce4f0e63fc5d
Author: Gilles Chanteperdrix <gilles.chanteperd...@xenomai.org> Date: Mon May 28 13:36:45 2012 +0200 hal/x86 adapt to newer kernels where TS_USEDFPU was replaced --- include/asm-x86/bits/pod_64.h | 18 +++++++++--------- include/asm-x86/wrappers_32.h | 13 ++++++++++++- include/asm-x86/wrappers_64.h | 23 +++++++++++++++++++++++ 3 files changed, 44 insertions(+), 10 deletions(-) diff --git a/include/asm-x86/bits/pod_64.h b/include/asm-x86/bits/pod_64.h index 46bd380..772e009 100644 --- a/include/asm-x86/bits/pod_64.h +++ b/include/asm-x86/bits/pod_64.h @@ -47,7 +47,7 @@ static inline void xnarch_leave_root(xnarchtcb_t *rootcb) rootcb->user_task = rootcb->active_task = current; rootcb->rspp = ¤t->thread.x86reg_sp; rootcb->ripp = ¤t->thread.rip; - rootcb->ts_usedfpu = !!(task_thread_info(current)->status & TS_USEDFPU); + rootcb->ts_usedfpu = !!wrap_test_fpu_used(current); rootcb->cr0_ts = (read_cr0() & 8) != 0; /* So that xnarch_save_fpu() will operate on the right FPU area. */ if (rootcb->cr0_ts || rootcb->ts_usedfpu) @@ -70,7 +70,7 @@ static inline void xnarch_switch_to(xnarchtcb_t *out_tcb, xnarchtcb_t *in_tcb) struct task_struct *next = in_tcb->user_task; if (likely(next != NULL)) { - if (task_thread_info(prev)->status & TS_USEDFPU) + if (wrap_test_fpu_used(prev)) /* * __switch_to will try and use __unlazy_fpu, * so we need to clear the ts bit. @@ -171,7 +171,7 @@ static inline void xnarch_init_fpu(xnarchtcb_t * tcb) fpu usage bit is necessary for xnarch_save_fpu to save the FPU state at next switch. */ xnarch_set_fpu_init(task); - task_thread_info(task)->status |= TS_USEDFPU; + wrap_set_fpu_used(task); } } @@ -202,19 +202,19 @@ static inline void xnarch_save_fpu(xnarchtcb_t *tcb) if (!tcb->is_root) { if (task) { /* fpu not used or already saved by __switch_to. */ - if (!(task_thread_info(task)->status & TS_USEDFPU)) + if (wrap_test_fpu_used(task) == 0) return; /* Tell Linux that we already saved the state * of the FPU hardware of this task. */ - task_thread_info(task)->status &= ~TS_USEDFPU; + wrap_clear_fpu_used(task); } } else { if (tcb->cr0_ts || - (tcb->ts_usedfpu && !(task_thread_info(task)->status & TS_USEDFPU))) + (tcb->ts_usedfpu && wrap_test_fpu_used(task) == 0)) return; - task_thread_info(task)->status &= ~TS_USEDFPU; + wrap_clear_fpu_used(task); } clts(); @@ -255,7 +255,7 @@ static inline void xnarch_restore_fpu(xnarchtcb_t * tcb) /* Tell Linux that this task has altered the state of * the FPU hardware. */ - task_thread_info(task)->status |= TS_USEDFPU; + wrap_set_fpu_used(task); } } else { /* Restore state of FPU only if TS bit in cr0 was clear. */ @@ -265,7 +265,7 @@ static inline void xnarch_restore_fpu(xnarchtcb_t * tcb) } if (tcb->ts_usedfpu - && !(task_thread_info(task)->status & TS_USEDFPU)) { + && wrap_test_fpu_used(task) == 0) { /* __switch_to saved the fpu context, no need to restore it since we are switching to root, where fpu can be in lazy state. */ diff --git a/include/asm-x86/wrappers_32.h b/include/asm-x86/wrappers_32.h index b1ebaff..76a8189 100644 --- a/include/asm-x86/wrappers_32.h +++ b/include/asm-x86/wrappers_32.h @@ -93,6 +93,7 @@ typedef phys_addr_t resource_size_t; :"1" (addr),"g" ((int)(size)),"g" (task_thread_info(task)->addr_limit.seg)); \ flag == 0; }) +#ifdef TS_USEDFPU #define wrap_test_fpu_used(task) \ (task_thread_info(task)->status & TS_USEDFPU) #define wrap_set_fpu_used(task) \ @@ -103,7 +104,17 @@ do { \ do { \ task_thread_info(task)->status &= ~TS_USEDFPU; \ } while(0) - +#else /* !defined(TS_USEDFPU) */ +#define wrap_test_fpu_used(task) ((task)->thread.has_fpu) +#define wrap_set_fpu_used(task) \ + do { \ + (task)->thread.has_fpu = 1; \ + } while(0) +#define wrap_clear_fpu_used(task) \ + do { \ + (task)->thread.has_fpu = 0; \ + } while(0) +#endif /* !defined(TS_USEDFPU) */ #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22) #define wrap_iobitmap_base(tss) (tss)->io_bitmap_base diff --git a/include/asm-x86/wrappers_64.h b/include/asm-x86/wrappers_64.h index f1ef185..1a06ecd 100644 --- a/include/asm-x86/wrappers_64.h +++ b/include/asm-x86/wrappers_64.h @@ -81,6 +81,29 @@ typedef union thread_xstate x86_fpustate; #define x86_fpustate_ptr(t) ((t)->fpu.state) #endif +#ifdef TS_USEDFPU +#define wrap_test_fpu_used(task) \ + (task_thread_info(task)->status & TS_USEDFPU) +#define wrap_set_fpu_used(task) \ +do { \ + task_thread_info(task)->status |= TS_USEDFPU; \ +} while(0) +#define wrap_clear_fpu_used(task) \ +do { \ + task_thread_info(task)->status &= ~TS_USEDFPU; \ +} while(0) +#else /* !defined(TS_USEDFPU) */ +#define wrap_test_fpu_used(task) ((task)->thread.has_fpu) +#define wrap_set_fpu_used(task) \ + do { \ + (task)->thread.has_fpu = 1; \ + } while(0) +#define wrap_clear_fpu_used(task) \ + do { \ + (task)->thread.has_fpu = 0; \ + } while(0) +#endif /* !defined(TS_USEDFPU) */ + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34) #define per_cpu_var(var) (var) #endif /* Linux >= 2.6.34 */ _______________________________________________ Xenomai-git mailing list Xenomai-git@xenomai.org http://www.xenomai.org/mailman/listinfo/xenomai-git