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