mmu_context.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #ifndef __ASM_POWERPC_MMU_CONTEXT_H
  2. #define __ASM_POWERPC_MMU_CONTEXT_H
  3. #ifndef CONFIG_PPC64
  4. #include <asm-ppc/mmu_context.h>
  5. #else
  6. #include <linux/kernel.h>
  7. #include <linux/mm.h>
  8. #include <asm/mmu.h>
  9. #include <asm/cputable.h>
  10. /*
  11. * Copyright (C) 2001 PPC 64 Team, IBM Corp
  12. *
  13. * This program is free software; you can redistribute it and/or
  14. * modify it under the terms of the GNU General Public License
  15. * as published by the Free Software Foundation; either version
  16. * 2 of the License, or (at your option) any later version.
  17. */
  18. /*
  19. * Getting into a kernel thread, there is no valid user segment, mark
  20. * paca->pgdir NULL so that SLB miss on user addresses will fault
  21. */
  22. static inline void enter_lazy_tlb(struct mm_struct *mm,
  23. struct task_struct *tsk)
  24. {
  25. #ifdef CONFIG_PPC_64K_PAGES
  26. get_paca()->pgdir = NULL;
  27. #endif /* CONFIG_PPC_64K_PAGES */
  28. }
  29. #define NO_CONTEXT 0
  30. #define MAX_CONTEXT (0x100000-1)
  31. extern int init_new_context(struct task_struct *tsk, struct mm_struct *mm);
  32. extern void destroy_context(struct mm_struct *mm);
  33. extern void switch_stab(struct task_struct *tsk, struct mm_struct *mm);
  34. extern void switch_slb(struct task_struct *tsk, struct mm_struct *mm);
  35. /*
  36. * switch_mm is the entry point called from the architecture independent
  37. * code in kernel/sched.c
  38. */
  39. static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
  40. struct task_struct *tsk)
  41. {
  42. if (!cpu_isset(smp_processor_id(), next->cpu_vm_mask))
  43. cpu_set(smp_processor_id(), next->cpu_vm_mask);
  44. /* No need to flush userspace segments if the mm doesnt change */
  45. #ifdef CONFIG_PPC_64K_PAGES
  46. if (prev == next && get_paca()->pgdir == next->pgd)
  47. return;
  48. #else
  49. if (prev == next)
  50. return;
  51. #endif /* CONFIG_PPC_64K_PAGES */
  52. #ifdef CONFIG_ALTIVEC
  53. if (cpu_has_feature(CPU_FTR_ALTIVEC))
  54. asm volatile ("dssall");
  55. #endif /* CONFIG_ALTIVEC */
  56. if (cpu_has_feature(CPU_FTR_SLB))
  57. switch_slb(tsk, next);
  58. else
  59. switch_stab(tsk, next);
  60. }
  61. #define deactivate_mm(tsk,mm) do { } while (0)
  62. /*
  63. * After we have set current->mm to a new value, this activates
  64. * the context for the new mm so we see the new mappings.
  65. */
  66. static inline void activate_mm(struct mm_struct *prev, struct mm_struct *next)
  67. {
  68. unsigned long flags;
  69. local_irq_save(flags);
  70. switch_mm(prev, next, current);
  71. local_irq_restore(flags);
  72. }
  73. #endif /* CONFIG_PPC64 */
  74. #endif /* __ASM_POWERPC_MMU_CONTEXT_H */