1 #ifndef __PARISC_MMU_CONTEXT_H
2 #define __PARISC_MMU_CONTEXT_H
5 #include <linux/sched.h>
6 #include <linux/atomic.h>
7 #include <asm/pgalloc.h>
8 #include <asm/pgtable.h>
9 #include <asm-generic/mm_hooks.h>
11 static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
15 /* on PA-RISC, we actually have enough contexts to justify an allocator
18 extern unsigned long alloc_sid(void);
19 extern void free_sid(unsigned long);
22 init_new_context(struct task_struct *tsk, struct mm_struct *mm)
24 BUG_ON(atomic_read(&mm->mm_users) != 1);
26 mm->context = alloc_sid();
31 destroy_context(struct mm_struct *mm)
33 free_sid(mm->context);
37 static inline unsigned long __space_to_prot(mm_context_t context)
39 #if SPACEID_SHIFT == 0
42 return context >> (SPACEID_SHIFT - 1);
46 static inline void load_context(mm_context_t context)
49 mtctl(__space_to_prot(context), 8);
52 static inline void switch_mm_irqs_off(struct mm_struct *prev,
53 struct mm_struct *next, struct task_struct *tsk)
56 mtctl(__pa(next->pgd), 25);
57 load_context(next->context);
61 static inline void switch_mm(struct mm_struct *prev,
62 struct mm_struct *next, struct task_struct *tsk)
66 local_irq_save(flags);
67 switch_mm_irqs_off(prev, next, tsk);
68 local_irq_restore(flags);
70 #define switch_mm_irqs_off switch_mm_irqs_off
72 #define deactivate_mm(tsk,mm) do { } while (0)
74 static inline void activate_mm(struct mm_struct *prev, struct mm_struct *next)
77 * Activate_mm is our one chance to allocate a space id
78 * for a new mm created in the exec path. There's also
79 * some lazy tlb stuff, which is currently dead code, but
80 * we only allocate a space id if one hasn't been allocated
81 * already, so we should be OK.
84 BUG_ON(next == &init_mm); /* Should never happen */
86 if (next->context == 0)
87 next->context = alloc_sid();
89 switch_mm(prev,next,current);