switch_to.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. * Copyright (C) 1999 Cort Dougan <cort@cs.nmt.edu>
  3. */
  4. #ifndef _ASM_POWERPC_SWITCH_TO_H
  5. #define _ASM_POWERPC_SWITCH_TO_H
  6. #include <asm/reg.h>
  7. struct thread_struct;
  8. struct task_struct;
  9. struct pt_regs;
  10. extern struct task_struct *__switch_to(struct task_struct *,
  11. struct task_struct *);
  12. #define switch_to(prev, next, last) ((last) = __switch_to((prev), (next)))
  13. extern struct task_struct *_switch(struct thread_struct *prev,
  14. struct thread_struct *next);
  15. extern void switch_booke_debug_regs(struct debug_reg *new_debug);
  16. extern int emulate_altivec(struct pt_regs *);
  17. extern void flush_all_to_thread(struct task_struct *);
  18. extern void giveup_all(struct task_struct *);
  19. #ifdef CONFIG_PPC_FPU
  20. extern void enable_kernel_fp(void);
  21. extern void flush_fp_to_thread(struct task_struct *);
  22. extern void giveup_fpu(struct task_struct *);
  23. extern void save_fpu(struct task_struct *);
  24. static inline void disable_kernel_fp(void)
  25. {
  26. msr_check_and_clear(MSR_FP);
  27. }
  28. #else
  29. static inline void __giveup_fpu(struct task_struct *t) { }
  30. static inline void save_fpu(struct task_struct *t) { }
  31. static inline void flush_fp_to_thread(struct task_struct *t) { }
  32. #endif
  33. #ifdef CONFIG_ALTIVEC
  34. extern void enable_kernel_altivec(void);
  35. extern void flush_altivec_to_thread(struct task_struct *);
  36. extern void giveup_altivec(struct task_struct *);
  37. extern void save_altivec(struct task_struct *);
  38. static inline void disable_kernel_altivec(void)
  39. {
  40. msr_check_and_clear(MSR_VEC);
  41. }
  42. #else
  43. static inline void save_altivec(struct task_struct *t) { }
  44. static inline void __giveup_altivec(struct task_struct *t) { }
  45. #endif
  46. #ifdef CONFIG_VSX
  47. extern void enable_kernel_vsx(void);
  48. extern void flush_vsx_to_thread(struct task_struct *);
  49. static inline void disable_kernel_vsx(void)
  50. {
  51. msr_check_and_clear(MSR_FP|MSR_VEC|MSR_VSX);
  52. }
  53. #endif
  54. #ifdef CONFIG_SPE
  55. extern void enable_kernel_spe(void);
  56. extern void flush_spe_to_thread(struct task_struct *);
  57. extern void giveup_spe(struct task_struct *);
  58. extern void __giveup_spe(struct task_struct *);
  59. static inline void disable_kernel_spe(void)
  60. {
  61. msr_check_and_clear(MSR_SPE);
  62. }
  63. #else
  64. static inline void __giveup_spe(struct task_struct *t) { }
  65. #endif
  66. static inline void clear_task_ebb(struct task_struct *t)
  67. {
  68. #ifdef CONFIG_PPC_BOOK3S_64
  69. /* EBB perf events are not inherited, so clear all EBB state. */
  70. t->thread.ebbrr = 0;
  71. t->thread.ebbhr = 0;
  72. t->thread.bescr = 0;
  73. t->thread.mmcr2 = 0;
  74. t->thread.mmcr0 = 0;
  75. t->thread.siar = 0;
  76. t->thread.sdar = 0;
  77. t->thread.sier = 0;
  78. t->thread.used_ebb = 0;
  79. #endif
  80. }
  81. #endif /* _ASM_POWERPC_SWITCH_TO_H */