switch_to.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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 load_up_fpu(void);
  25. extern void enable_kernel_fp(void);
  26. extern void enable_kernel_altivec(void);
  27. extern void load_up_altivec(struct task_struct *);
  28. extern int emulate_altivec(struct pt_regs *);
  29. extern void __giveup_vsx(struct task_struct *);
  30. extern void giveup_vsx(struct task_struct *);
  31. extern void enable_kernel_spe(void);
  32. extern void giveup_spe(struct task_struct *);
  33. extern void load_up_spe(struct task_struct *);
  34. #ifndef CONFIG_SMP
  35. extern void discard_lazy_cpu_state(void);
  36. #else
  37. static inline void discard_lazy_cpu_state(void)
  38. {
  39. }
  40. #endif
  41. #ifdef CONFIG_PPC_FPU
  42. extern void flush_fp_to_thread(struct task_struct *);
  43. extern void giveup_fpu(struct task_struct *);
  44. #else
  45. static inline void flush_fp_to_thread(struct task_struct *t) { }
  46. static inline void giveup_fpu(struct task_struct *t) { }
  47. #endif
  48. #ifdef CONFIG_ALTIVEC
  49. extern void flush_altivec_to_thread(struct task_struct *);
  50. extern void giveup_altivec(struct task_struct *);
  51. extern void giveup_altivec_notask(void);
  52. #else
  53. static inline void flush_altivec_to_thread(struct task_struct *t)
  54. {
  55. }
  56. static inline void giveup_altivec(struct task_struct *t)
  57. {
  58. }
  59. #endif
  60. #ifdef CONFIG_VSX
  61. extern void flush_vsx_to_thread(struct task_struct *);
  62. #else
  63. static inline void flush_vsx_to_thread(struct task_struct *t)
  64. {
  65. }
  66. #endif
  67. #ifdef CONFIG_SPE
  68. extern void flush_spe_to_thread(struct task_struct *);
  69. #else
  70. static inline void flush_spe_to_thread(struct task_struct *t)
  71. {
  72. }
  73. #endif
  74. static inline void clear_task_ebb(struct task_struct *t)
  75. {
  76. #ifdef CONFIG_PPC_BOOK3S_64
  77. /* EBB perf events are not inherited, so clear all EBB state. */
  78. t->thread.bescr = 0;
  79. t->thread.mmcr2 = 0;
  80. t->thread.mmcr0 = 0;
  81. t->thread.siar = 0;
  82. t->thread.sdar = 0;
  83. t->thread.sier = 0;
  84. t->thread.used_ebb = 0;
  85. #endif
  86. }
  87. #endif /* _ASM_POWERPC_SWITCH_TO_H */