switch_to.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. struct thread_struct;
  7. struct task_struct;
  8. struct pt_regs;
  9. extern struct task_struct *__switch_to(struct task_struct *,
  10. struct task_struct *);
  11. #define switch_to(prev, next, last) ((last) = __switch_to((prev), (next)))
  12. struct thread_struct;
  13. extern struct task_struct *_switch(struct thread_struct *prev,
  14. struct thread_struct *next);
  15. #ifdef CONFIG_PPC_BOOK3S_64
  16. static inline void save_tar(struct thread_struct *prev)
  17. {
  18. if (cpu_has_feature(CPU_FTR_ARCH_207S))
  19. prev->tar = mfspr(SPRN_TAR);
  20. }
  21. #else
  22. static inline void save_tar(struct thread_struct *prev) {}
  23. #endif
  24. extern void enable_kernel_fp(void);
  25. extern void enable_kernel_altivec(void);
  26. extern int emulate_altivec(struct pt_regs *);
  27. extern void __giveup_vsx(struct task_struct *);
  28. extern void giveup_vsx(struct task_struct *);
  29. extern void enable_kernel_spe(void);
  30. extern void giveup_spe(struct task_struct *);
  31. extern void load_up_spe(struct task_struct *);
  32. extern void switch_booke_debug_regs(struct thread_struct *new_thread);
  33. #ifndef CONFIG_SMP
  34. extern void discard_lazy_cpu_state(void);
  35. #else
  36. static inline void discard_lazy_cpu_state(void)
  37. {
  38. }
  39. #endif
  40. #ifdef CONFIG_PPC_FPU
  41. extern void flush_fp_to_thread(struct task_struct *);
  42. extern void giveup_fpu(struct task_struct *);
  43. #else
  44. static inline void flush_fp_to_thread(struct task_struct *t) { }
  45. static inline void giveup_fpu(struct task_struct *t) { }
  46. #endif
  47. #ifdef CONFIG_ALTIVEC
  48. extern void flush_altivec_to_thread(struct task_struct *);
  49. extern void giveup_altivec(struct task_struct *);
  50. extern void giveup_altivec_notask(void);
  51. #else
  52. static inline void flush_altivec_to_thread(struct task_struct *t)
  53. {
  54. }
  55. static inline void giveup_altivec(struct task_struct *t)
  56. {
  57. }
  58. #endif
  59. #ifdef CONFIG_VSX
  60. extern void flush_vsx_to_thread(struct task_struct *);
  61. #else
  62. static inline void flush_vsx_to_thread(struct task_struct *t)
  63. {
  64. }
  65. #endif
  66. #ifdef CONFIG_SPE
  67. extern void flush_spe_to_thread(struct task_struct *);
  68. #else
  69. static inline void flush_spe_to_thread(struct task_struct *t)
  70. {
  71. }
  72. #endif
  73. static inline void clear_task_ebb(struct task_struct *t)
  74. {
  75. #ifdef CONFIG_PPC_BOOK3S_64
  76. /* EBB perf events are not inherited, so clear all EBB state. */
  77. t->thread.bescr = 0;
  78. t->thread.mmcr2 = 0;
  79. t->thread.mmcr0 = 0;
  80. t->thread.siar = 0;
  81. t->thread.sdar = 0;
  82. t->thread.sier = 0;
  83. t->thread.used_ebb = 0;
  84. #endif
  85. }
  86. #endif /* _ASM_POWERPC_SWITCH_TO_H */