1 /* MN10300 FPU definitions
3 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 * Derived from include/asm-i386/i387.h: Copyright (C) 1994 Linus Torvalds
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public Licence
9 * as published by the Free Software Foundation; either version
10 * 2 of the Licence, or (at your option) any later version.
17 #include <linux/sched.h>
18 #include <asm/exceptions.h>
19 #include <asm/sigcontext.h>
23 extern asmlinkage
void fpu_disabled(void);
27 #ifdef CONFIG_LAZY_SAVE_FPU
28 /* the task that currently owns the FPU state */
29 extern struct task_struct
*fpu_state_owner
;
32 #if (THREAD_USING_FPU & ~0xff)
33 #error THREAD_USING_FPU must be smaller than 0x100.
36 static inline void set_using_fpu(struct task_struct
*tsk
)
41 : "i"(THREAD_USING_FPU
), "a"(&tsk
->thread
.fpu_flags
)
45 static inline void clear_using_fpu(struct task_struct
*tsk
)
50 : "i"(THREAD_USING_FPU
), "a"(&tsk
->thread
.fpu_flags
)
54 #define is_using_fpu(tsk) ((tsk)->thread.fpu_flags & THREAD_USING_FPU)
56 extern asmlinkage
void fpu_kill_state(struct task_struct
*);
57 extern asmlinkage
void fpu_exception(struct pt_regs
*, enum exception_code
);
58 extern asmlinkage
void fpu_invalid_op(struct pt_regs
*, enum exception_code
);
59 extern asmlinkage
void fpu_init_state(void);
60 extern asmlinkage
void fpu_save(struct fpu_state_struct
*);
61 extern int fpu_setup_sigcontext(struct fpucontext
*buf
);
62 extern int fpu_restore_sigcontext(struct fpucontext
*buf
);
64 static inline void unlazy_fpu(struct task_struct
*tsk
)
67 #ifndef CONFIG_LAZY_SAVE_FPU
68 if (tsk
->thread
.fpu_flags
& THREAD_HAS_FPU
) {
69 fpu_save(&tsk
->thread
.fpu_state
);
70 tsk
->thread
.fpu_flags
&= ~THREAD_HAS_FPU
;
71 tsk
->thread
.uregs
->epsw
&= ~EPSW_FE
;
74 if (fpu_state_owner
== tsk
)
75 fpu_save(&tsk
->thread
.fpu_state
);
80 static inline void exit_fpu(void)
82 #ifdef CONFIG_LAZY_SAVE_FPU
83 struct task_struct
*tsk
= current
;
86 if (fpu_state_owner
== tsk
)
87 fpu_state_owner
= NULL
;
92 static inline void flush_fpu(void)
94 struct task_struct
*tsk
= current
;
97 #ifndef CONFIG_LAZY_SAVE_FPU
98 if (tsk
->thread
.fpu_flags
& THREAD_HAS_FPU
) {
99 tsk
->thread
.fpu_flags
&= ~THREAD_HAS_FPU
;
100 tsk
->thread
.uregs
->epsw
&= ~EPSW_FE
;
103 if (fpu_state_owner
== tsk
) {
104 fpu_state_owner
= NULL
;
105 tsk
->thread
.uregs
->epsw
&= ~EPSW_FE
;
109 clear_using_fpu(tsk
);
112 #else /* CONFIG_FPU */
115 void unexpected_fpu_exception(struct pt_regs
*, enum exception_code
);
116 #define fpu_invalid_op unexpected_fpu_exception
117 #define fpu_exception unexpected_fpu_exception
120 struct fpu_state_struct
;
121 static inline bool is_using_fpu(struct task_struct
*tsk
) { return false; }
122 static inline void set_using_fpu(struct task_struct
*tsk
) {}
123 static inline void clear_using_fpu(struct task_struct
*tsk
) {}
124 static inline void fpu_init_state(void) {}
125 static inline void fpu_save(struct fpu_state_struct
*s
) {}
126 static inline void fpu_kill_state(struct task_struct
*tsk
) {}
127 static inline void unlazy_fpu(struct task_struct
*tsk
) {}
128 static inline void exit_fpu(void) {}
129 static inline void flush_fpu(void) {}
130 static inline int fpu_setup_sigcontext(struct fpucontext
*buf
) { return 0; }
131 static inline int fpu_restore_sigcontext(struct fpucontext
*buf
) { return 0; }
132 #endif /* CONFIG_FPU */
134 #endif /* __KERNEL__ */
135 #endif /* !__ASSEMBLY__ */
136 #endif /* _ASM_FPU_H */
This page took 0.041953 seconds and 5 git commands to generate.