fpu.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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);
  17. void fpu_state_restore(struct pt_regs *regs);
  18. #else
  19. #define save_fpu(tsk) do { } while (0)
  20. #define release_fpu(regs) do { } while (0)
  21. #define grab_fpu(regs) do { } while (0)
  22. #define fpu_state_restore(regs) do { } while (0)
  23. #endif
  24. struct user_regset;
  25. extern int do_fpu_inst(unsigned short, struct pt_regs *);
  26. extern int fpregs_get(struct task_struct *target,
  27. const struct user_regset *regset,
  28. unsigned int pos, unsigned int count,
  29. void *kbuf, void __user *ubuf);
  30. static inline void __unlazy_fpu(struct task_struct *tsk, struct pt_regs *regs)
  31. {
  32. if (task_thread_info(tsk)->status & TS_USEDFPU) {
  33. task_thread_info(tsk)->status &= ~TS_USEDFPU;
  34. save_fpu(tsk);
  35. release_fpu(regs);
  36. } else
  37. tsk->fpu_counter = 0;
  38. }
  39. static inline void unlazy_fpu(struct task_struct *tsk, struct pt_regs *regs)
  40. {
  41. preempt_disable();
  42. __unlazy_fpu(tsk, regs);
  43. preempt_enable();
  44. }
  45. static inline void clear_fpu(struct task_struct *tsk, struct pt_regs *regs)
  46. {
  47. preempt_disable();
  48. if (task_thread_info(tsk)->status & TS_USEDFPU) {
  49. task_thread_info(tsk)->status &= ~TS_USEDFPU;
  50. release_fpu(regs);
  51. }
  52. preempt_enable();
  53. }
  54. static inline int init_fpu(struct task_struct *tsk)
  55. {
  56. if (tsk_used_math(tsk)) {
  57. if ((boot_cpu_data.flags & CPU_HAS_FPU) && tsk == current)
  58. unlazy_fpu(tsk, task_pt_regs(tsk));
  59. return 0;
  60. }
  61. set_stopped_child_used_math(tsk);
  62. return 0;
  63. }
  64. #endif /* __ASSEMBLY__ */
  65. #endif /* __ASM_SH_FPU_H */