fpu.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef __ASM_SH_FPU_H
  3. #define __ASM_SH_FPU_H
  4. #ifndef __ASSEMBLY__
  5. #include <asm/ptrace.h>
  6. struct task_struct;
  7. #ifdef CONFIG_SH_FPU
  8. static inline void release_fpu(struct pt_regs *regs)
  9. {
  10. regs->sr |= SR_FD;
  11. }
  12. static inline void grab_fpu(struct pt_regs *regs)
  13. {
  14. regs->sr &= ~SR_FD;
  15. }
  16. extern void save_fpu(struct task_struct *__tsk);
  17. extern void restore_fpu(struct task_struct *__tsk);
  18. extern void fpu_state_restore(struct pt_regs *regs);
  19. extern void __fpu_state_restore(void);
  20. #else
  21. #define save_fpu(tsk) do { } while (0)
  22. #define restore_fpu(tsk) do { } while (0)
  23. #define release_fpu(regs) do { } while (0)
  24. #define grab_fpu(regs) do { } while (0)
  25. #define fpu_state_restore(regs) do { } while (0)
  26. #define __fpu_state_restore(regs) do { } while (0)
  27. #endif
  28. struct user_regset;
  29. extern int do_fpu_inst(unsigned short, struct pt_regs *);
  30. extern int init_fpu(struct task_struct *);
  31. extern int fpregs_get(struct task_struct *target,
  32. const struct user_regset *regset,
  33. unsigned int pos, unsigned int count,
  34. void *kbuf, void __user *ubuf);
  35. static inline void __unlazy_fpu(struct task_struct *tsk, struct pt_regs *regs)
  36. {
  37. if (task_thread_info(tsk)->status & TS_USEDFPU) {
  38. task_thread_info(tsk)->status &= ~TS_USEDFPU;
  39. save_fpu(tsk);
  40. release_fpu(regs);
  41. } else
  42. tsk->thread.fpu_counter = 0;
  43. }
  44. static inline void unlazy_fpu(struct task_struct *tsk, struct pt_regs *regs)
  45. {
  46. preempt_disable();
  47. __unlazy_fpu(tsk, regs);
  48. preempt_enable();
  49. }
  50. static inline void clear_fpu(struct task_struct *tsk, struct pt_regs *regs)
  51. {
  52. preempt_disable();
  53. if (task_thread_info(tsk)->status & TS_USEDFPU) {
  54. task_thread_info(tsk)->status &= ~TS_USEDFPU;
  55. release_fpu(regs);
  56. }
  57. preempt_enable();
  58. }
  59. #endif /* __ASSEMBLY__ */
  60. #endif /* __ASM_SH_FPU_H */