mmu_context.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. #ifndef __ASM_POWERPC_MMU_CONTEXT_H
  2. #define __ASM_POWERPC_MMU_CONTEXT_H
  3. #ifdef __KERNEL__
  4. #include <linux/kernel.h>
  5. #include <linux/mm.h>
  6. #include <linux/sched.h>
  7. #include <linux/spinlock.h>
  8. #include <asm/mmu.h>
  9. #include <asm/cputable.h>
  10. #include <asm-generic/mm_hooks.h>
  11. #include <asm/cputhreads.h>
  12. /*
  13. * Most if the context management is out of line
  14. */
  15. extern int init_new_context(struct task_struct *tsk, struct mm_struct *mm);
  16. extern void destroy_context(struct mm_struct *mm);
  17. extern void switch_mmu_context(struct mm_struct *prev, struct mm_struct *next);
  18. extern void switch_stab(struct task_struct *tsk, struct mm_struct *mm);
  19. extern void switch_slb(struct task_struct *tsk, struct mm_struct *mm);
  20. extern void set_context(unsigned long id, pgd_t *pgd);
  21. #ifdef CONFIG_PPC_BOOK3S_64
  22. extern int __init_new_context(void);
  23. extern void __destroy_context(int context_id);
  24. static inline void mmu_context_init(void) { }
  25. #else
  26. extern unsigned long __init_new_context(void);
  27. extern void __destroy_context(unsigned long context_id);
  28. extern void mmu_context_init(void);
  29. #endif
  30. extern void switch_cop(struct mm_struct *next);
  31. extern int use_cop(unsigned long acop, struct mm_struct *mm);
  32. extern void drop_cop(unsigned long acop, struct mm_struct *mm);
  33. /*
  34. * switch_mm is the entry point called from the architecture independent
  35. * code in kernel/sched.c
  36. */
  37. static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
  38. struct task_struct *tsk)
  39. {
  40. /* Mark this context has been used on the new CPU */
  41. cpumask_set_cpu(smp_processor_id(), mm_cpumask(next));
  42. /* 32-bit keeps track of the current PGDIR in the thread struct */
  43. #ifdef CONFIG_PPC32
  44. tsk->thread.pgdir = next->pgd;
  45. #endif /* CONFIG_PPC32 */
  46. /* 64-bit Book3E keeps track of current PGD in the PACA */
  47. #ifdef CONFIG_PPC_BOOK3E_64
  48. get_paca()->pgd = next->pgd;
  49. #endif
  50. /* Nothing else to do if we aren't actually switching */
  51. if (prev == next)
  52. return;
  53. #ifdef CONFIG_PPC_ICSWX
  54. /* Switch coprocessor context only if prev or next uses a coprocessor */
  55. if (prev->context.acop || next->context.acop)
  56. switch_cop(next);
  57. #endif /* CONFIG_PPC_ICSWX */
  58. /* We must stop all altivec streams before changing the HW
  59. * context
  60. */
  61. #ifdef CONFIG_ALTIVEC
  62. if (cpu_has_feature(CPU_FTR_ALTIVEC))
  63. asm volatile ("dssall");
  64. #endif /* CONFIG_ALTIVEC */
  65. /* The actual HW switching method differs between the various
  66. * sub architectures.
  67. */
  68. #ifdef CONFIG_PPC_STD_MMU_64
  69. if (mmu_has_feature(MMU_FTR_SLB))
  70. switch_slb(tsk, next);
  71. else
  72. switch_stab(tsk, next);
  73. #else
  74. /* Out of line for now */
  75. switch_mmu_context(prev, next);
  76. #endif
  77. }
  78. #define deactivate_mm(tsk,mm) do { } while (0)
  79. /*
  80. * After we have set current->mm to a new value, this activates
  81. * the context for the new mm so we see the new mappings.
  82. */
  83. static inline void activate_mm(struct mm_struct *prev, struct mm_struct *next)
  84. {
  85. unsigned long flags;
  86. local_irq_save(flags);
  87. switch_mm(prev, next, current);
  88. local_irq_restore(flags);
  89. }
  90. /* We don't currently use enter_lazy_tlb() for anything */
  91. static inline void enter_lazy_tlb(struct mm_struct *mm,
  92. struct task_struct *tsk)
  93. {
  94. /* 64-bit Book3E keeps track of current PGD in the PACA */
  95. #ifdef CONFIG_PPC_BOOK3E_64
  96. get_paca()->pgd = NULL;
  97. #endif
  98. }
  99. #endif /* __KERNEL__ */
  100. #endif /* __ASM_POWERPC_MMU_CONTEXT_H */