blob: 9c05836239a2c97b1ccf52ed73059b36d598e3f6 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef __PARISC_MMU_CONTEXT_H
2#define __PARISC_MMU_CONTEXT_H
3
4#include <linux/mm.h>
5#include <asm/atomic.h>
6#include <asm/pgalloc.h>
7#include <asm/pgtable.h>
8
9static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
10{
11}
12
13/* on PA-RISC, we actually have enough contexts to justify an allocator
14 * for them. prumpf */
15
16extern unsigned long alloc_sid(void);
17extern void free_sid(unsigned long);
18
19static inline int
20init_new_context(struct task_struct *tsk, struct mm_struct *mm)
21{
22 BUG_ON(atomic_read(&mm->mm_users) != 1);
23
24 mm->context = alloc_sid();
25 return 0;
26}
27
28static inline void
29destroy_context(struct mm_struct *mm)
30{
31 free_sid(mm->context);
32 mm->context = 0;
33}
34
35static inline void load_context(mm_context_t context)
36{
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
43}
44
45static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next, struct task_struct *tsk)
46{
47
48 if (prev != next) {
49 mtctl(__pa(next->pgd), 25);
50 load_context(next->context);
51 }
52}
53
54#define deactivate_mm(tsk,mm) do { } while (0)
55
56static inline void activate_mm(struct mm_struct *prev, struct mm_struct *next)
57{
58 /*
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.
64 */
65
66 BUG_ON(next == &init_mm); /* Should never happen */
67
68 if (next->context == 0)
69 next->context = alloc_sid();
70
71 switch_mm(prev,next,current);
72}
73#endif