[PATCH] fix semaphore handling in __unregister_chrdev_region
[linux/fpc-iii.git] / include / asm-parisc / mmu_context.h
blob9c05836239a2c97b1ccf52ed73059b36d598e3f6
1 #ifndef __PARISC_MMU_CONTEXT_H
2 #define __PARISC_MMU_CONTEXT_H
4 #include <linux/mm.h>
5 #include <asm/atomic.h>
6 #include <asm/pgalloc.h>
7 #include <asm/pgtable.h>
9 static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
13 /* on PA-RISC, we actually have enough contexts to justify an allocator
14 * for them. prumpf */
16 extern unsigned long alloc_sid(void);
17 extern void free_sid(unsigned long);
19 static inline int
20 init_new_context(struct task_struct *tsk, struct mm_struct *mm)
22 BUG_ON(atomic_read(&mm->mm_users) != 1);
24 mm->context = alloc_sid();
25 return 0;
28 static inline void
29 destroy_context(struct mm_struct *mm)
31 free_sid(mm->context);
32 mm->context = 0;
35 static inline void load_context(mm_context_t context)
37 mtsp(context, 3);
38 #if SPACEID_SHIFT == 0
39 mtctl(context << 1,8);
40 #else
41 mtctl(context >> (SPACEID_SHIFT - 1),8);
42 #endif
45 static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next, struct task_struct *tsk)
48 if (prev != next) {
49 mtctl(__pa(next->pgd), 25);
50 load_context(next->context);
54 #define deactivate_mm(tsk,mm) do { } while (0)
56 static inline void activate_mm(struct mm_struct *prev, struct mm_struct *next)
59 * Activate_mm is our one chance to allocate a space id
60 * for a new mm created in the exec path. There's also
61 * some lazy tlb stuff, which is currently dead code, but
62 * we only allocate a space id if one hasn't been allocated
63 * already, so we should be OK.
66 BUG_ON(next == &init_mm); /* Should never happen */
68 if (next->context == 0)
69 next->context = alloc_sid();
71 switch_mm(prev,next,current);
73 #endif