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