switch_to.h 2.3 KB

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