mmu_context.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #ifndef __PARISC_MMU_CONTEXT_H
  2. #define __PARISC_MMU_CONTEXT_H
  3. #include <linux/mm.h>
  4. #include <asm/atomic.h>
  5. #include <asm/pgalloc.h>
  6. #include <asm/pgtable.h>
  7. #include <asm-generic/mm_hooks.h>
  8. static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
  9. {
  10. }
  11. /* on PA-RISC, we actually have enough contexts to justify an allocator
  12. * for them. prumpf */
  13. extern unsigned long alloc_sid(void);
  14. extern void free_sid(unsigned long);
  15. static inline int
  16. init_new_context(struct task_struct *tsk, struct mm_struct *mm)
  17. {
  18. BUG_ON(atomic_read(&mm->mm_users) != 1);
  19. mm->context = alloc_sid();
  20. return 0;
  21. }
  22. static inline void
  23. destroy_context(struct mm_struct *mm)
  24. {
  25. free_sid(mm->context);
  26. mm->context = 0;
  27. }
  28. static inline void load_context(mm_context_t context)
  29. {
  30. mtsp(context, 3);
  31. #if SPACEID_SHIFT == 0
  32. mtctl(context << 1,8);
  33. #else
  34. mtctl(context >> (SPACEID_SHIFT - 1),8);
  35. #endif
  36. }
  37. static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next, struct task_struct *tsk)
  38. {
  39. if (prev != next) {
  40. mtctl(__pa(next->pgd), 25);
  41. load_context(next->context);
  42. }
  43. }
  44. #define deactivate_mm(tsk,mm) do { } while (0)
  45. static inline void activate_mm(struct mm_struct *prev, struct mm_struct *next)
  46. {
  47. /*
  48. * Activate_mm is our one chance to allocate a space id
  49. * for a new mm created in the exec path. There's also
  50. * some lazy tlb stuff, which is currently dead code, but
  51. * we only allocate a space id if one hasn't been allocated
  52. * already, so we should be OK.
  53. */
  54. BUG_ON(next == &init_mm); /* Should never happen */
  55. if (next->context == 0)
  56. next->context = alloc_sid();
  57. switch_mm(prev,next,current);
  58. }
  59. #endif