fpu.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #ifndef __ASM_SH_FPU_H
  2. #define __ASM_SH_FPU_H
  3. #ifndef __ASSEMBLY__
  4. #include <linux/preempt.h>
  5. #include <asm/ptrace.h>
  6. #ifdef CONFIG_SH_FPU
  7. static inline void release_fpu(struct pt_regs *regs)
  8. {
  9. regs->sr |= SR_FD;
  10. }
  11. static inline void grab_fpu(struct pt_regs *regs)
  12. {
  13. regs->sr &= ~SR_FD;
  14. }
  15. struct task_struct;
  16. extern void save_fpu(struct task_struct *__tsk, struct pt_regs *regs);
  17. #else
  18. #define release_fpu(regs) do { } while (0)
  19. #define grab_fpu(regs) do { } while (0)
  20. static inline void save_fpu(struct task_struct *tsk, struct pt_regs *regs)
  21. {
  22. clear_tsk_thread_flag(tsk, TIF_USEDFPU);
  23. }
  24. #endif
  25. struct user_regset;
  26. extern int do_fpu_inst(unsigned short, struct pt_regs *);
  27. extern int fpregs_get(struct task_struct *target,
  28. const struct user_regset *regset,
  29. unsigned int pos, unsigned int count,
  30. void *kbuf, void __user *ubuf);
  31. static inline void unlazy_fpu(struct task_struct *tsk, struct pt_regs *regs)
  32. {
  33. preempt_disable();
  34. if (test_tsk_thread_flag(tsk, TIF_USEDFPU))
  35. save_fpu(tsk, regs);
  36. preempt_enable();
  37. }
  38. static inline void clear_fpu(struct task_struct *tsk, struct pt_regs *regs)
  39. {
  40. preempt_disable();
  41. if (test_tsk_thread_flag(tsk, TIF_USEDFPU)) {
  42. clear_tsk_thread_flag(tsk, TIF_USEDFPU);
  43. release_fpu(regs);
  44. }
  45. preempt_enable();
  46. }
  47. static inline int init_fpu(struct task_struct *tsk)
  48. {
  49. if (tsk_used_math(tsk)) {
  50. if ((boot_cpu_data.flags & CPU_HAS_FPU) && tsk == current)
  51. unlazy_fpu(tsk, task_pt_regs(tsk));
  52. return 0;
  53. }
  54. set_stopped_child_used_math(tsk);
  55. return 0;
  56. }
  57. #endif /* __ASSEMBLY__ */
  58. #endif /* __ASM_SH_FPU_H */