1 #ifndef _ASM_SCORE_MMU_CONTEXT_H
2 #define _ASM_SCORE_MMU_CONTEXT_H
4 #include <linux/errno.h>
5 #include <linux/sched.h>
6 #include <linux/slab.h>
7 #include <asm-generic/mm_hooks.h>
9 #include <asm/cacheflush.h>
10 #include <asm/tlbflush.h>
11 #include <asm/scoreregs.h>
14 * For the fast tlb miss handlers, we keep a per cpu array of pointers
15 * to the current pgd for each processor. Also, the proc. id is stuffed
16 * into the context register.
18 extern unsigned long asid_cache
;
19 extern unsigned long pgd_current
;
21 #define TLBMISS_HANDLER_SETUP_PGD(pgd) (pgd_current = (unsigned long)(pgd))
23 #define TLBMISS_HANDLER_SETUP() \
25 write_c0_context(0); \
26 TLBMISS_HANDLER_SETUP_PGD(swapper_pg_dir) \
30 * All unused by hardware upper bits will be considered
31 * as a software asid extension.
33 #define ASID_VERSION_MASK 0xfffff000
34 #define ASID_FIRST_VERSION 0x1000
36 /* PEVN --------- VPN ---------- --ASID--- -NA- */
37 /* binary: 0000 0000 0000 0000 0000 0000 0001 0000 */
38 /* binary: 0000 0000 0000 0000 0000 1111 1111 0000 */
40 #define ASID_MASK 0xff0
42 static inline void enter_lazy_tlb(struct mm_struct
*mm
,
43 struct task_struct
*tsk
)
47 get_new_mmu_context(struct mm_struct
*mm
)
49 unsigned long asid
= asid_cache
+ ASID_INC
;
51 if (!(asid
& ASID_MASK
)) {
52 local_flush_tlb_all(); /* start new asid cycle */
53 if (!asid
) /* fix version if needed */
54 asid
= ASID_FIRST_VERSION
;
62 * Initialize the context related info for a new mm_struct
66 init_new_context(struct task_struct
*tsk
, struct mm_struct
*mm
)
72 static inline void switch_mm(struct mm_struct
*prev
, struct mm_struct
*next
,
73 struct task_struct
*tsk
)
77 local_irq_save(flags
);
78 if ((next
->context
^ asid_cache
) & ASID_VERSION_MASK
)
79 get_new_mmu_context(next
);
81 pevn_set(next
->context
);
82 TLBMISS_HANDLER_SETUP_PGD(next
->pgd
);
83 local_irq_restore(flags
);
87 * Destroy context related info for an mm_struct that is about
90 static inline void destroy_context(struct mm_struct
*mm
)
94 deactivate_mm(struct task_struct
*task
, struct mm_struct
*mm
)
98 * After we have set current->mm to a new value, this activates
99 * the context for the new mm so we see the new mappings.
102 activate_mm(struct mm_struct
*prev
, struct mm_struct
*next
)
106 local_irq_save(flags
);
107 get_new_mmu_context(next
);
108 pevn_set(next
->context
);
109 TLBMISS_HANDLER_SETUP_PGD(next
->pgd
);
110 local_irq_restore(flags
);
113 #endif /* _ASM_SCORE_MMU_CONTEXT_H */