0001
0002
0003
0004
0005 #ifndef _ASM_POWERPC_SWITCH_TO_H
0006 #define _ASM_POWERPC_SWITCH_TO_H
0007
0008 #include <linux/sched.h>
0009 #include <asm/reg.h>
0010
0011 struct thread_struct;
0012 struct task_struct;
0013 struct pt_regs;
0014
0015 extern struct task_struct *__switch_to(struct task_struct *,
0016 struct task_struct *);
0017 #define switch_to(prev, next, last) ((last) = __switch_to((prev), (next)))
0018
0019 extern struct task_struct *_switch(struct thread_struct *prev,
0020 struct thread_struct *next);
0021
0022 extern void switch_booke_debug_regs(struct debug_reg *new_debug);
0023
0024 extern int emulate_altivec(struct pt_regs *);
0025
0026 #ifdef CONFIG_PPC_BOOK3S_64
0027 void restore_math(struct pt_regs *regs);
0028 #else
0029 static inline void restore_math(struct pt_regs *regs)
0030 {
0031 }
0032 #endif
0033
0034 void restore_tm_state(struct pt_regs *regs);
0035
0036 extern void flush_all_to_thread(struct task_struct *);
0037 extern void giveup_all(struct task_struct *);
0038
0039 #ifdef CONFIG_PPC_FPU
0040 extern void enable_kernel_fp(void);
0041 extern void flush_fp_to_thread(struct task_struct *);
0042 extern void giveup_fpu(struct task_struct *);
0043 extern void save_fpu(struct task_struct *);
0044 static inline void disable_kernel_fp(void)
0045 {
0046 msr_check_and_clear(MSR_FP);
0047 }
0048 #else
0049 static inline void save_fpu(struct task_struct *t) { }
0050 static inline void flush_fp_to_thread(struct task_struct *t) { }
0051 #endif
0052
0053 #ifdef CONFIG_ALTIVEC
0054 extern void enable_kernel_altivec(void);
0055 extern void flush_altivec_to_thread(struct task_struct *);
0056 extern void giveup_altivec(struct task_struct *);
0057 extern void save_altivec(struct task_struct *);
0058 static inline void disable_kernel_altivec(void)
0059 {
0060 msr_check_and_clear(MSR_VEC);
0061 }
0062 #else
0063 static inline void save_altivec(struct task_struct *t) { }
0064 static inline void __giveup_altivec(struct task_struct *t) { }
0065 static inline void enable_kernel_altivec(void)
0066 {
0067 BUILD_BUG();
0068 }
0069
0070 static inline void disable_kernel_altivec(void)
0071 {
0072 BUILD_BUG();
0073 }
0074 #endif
0075
0076 #ifdef CONFIG_VSX
0077 extern void enable_kernel_vsx(void);
0078 extern void flush_vsx_to_thread(struct task_struct *);
0079 static inline void disable_kernel_vsx(void)
0080 {
0081 msr_check_and_clear(MSR_FP|MSR_VEC|MSR_VSX);
0082 }
0083 #else
0084 static inline void enable_kernel_vsx(void)
0085 {
0086 BUILD_BUG();
0087 }
0088
0089 static inline void disable_kernel_vsx(void)
0090 {
0091 BUILD_BUG();
0092 }
0093 #endif
0094
0095 #ifdef CONFIG_SPE
0096 extern void enable_kernel_spe(void);
0097 extern void flush_spe_to_thread(struct task_struct *);
0098 extern void giveup_spe(struct task_struct *);
0099 extern void __giveup_spe(struct task_struct *);
0100 static inline void disable_kernel_spe(void)
0101 {
0102 msr_check_and_clear(MSR_SPE);
0103 }
0104 #else
0105 static inline void __giveup_spe(struct task_struct *t) { }
0106 #endif
0107
0108 static inline void clear_task_ebb(struct task_struct *t)
0109 {
0110 #ifdef CONFIG_PPC_BOOK3S_64
0111
0112 t->thread.ebbrr = 0;
0113 t->thread.ebbhr = 0;
0114 t->thread.bescr = 0;
0115 t->thread.mmcr2 = 0;
0116 t->thread.mmcr0 = 0;
0117 t->thread.siar = 0;
0118 t->thread.sdar = 0;
0119 t->thread.sier = 0;
0120 t->thread.used_ebb = 0;
0121 #endif
0122 }
0123
0124 void kvmppc_save_user_regs(void);
0125 void kvmppc_save_current_sprs(void);
0126
0127 extern int set_thread_tidr(struct task_struct *t);
0128
0129 #endif