mmu_context.h 1.6 KB

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