Path: blob/master/arch/score/include/asm/mmu_context.h
10819 views
#ifndef _ASM_SCORE_MMU_CONTEXT_H1#define _ASM_SCORE_MMU_CONTEXT_H23#include <linux/errno.h>4#include <linux/sched.h>5#include <linux/slab.h>6#include <asm-generic/mm_hooks.h>78#include <asm/cacheflush.h>9#include <asm/tlbflush.h>10#include <asm/scoreregs.h>1112/*13* For the fast tlb miss handlers, we keep a per cpu array of pointers14* to the current pgd for each processor. Also, the proc. id is stuffed15* into the context register.16*/17extern unsigned long asid_cache;18extern unsigned long pgd_current;1920#define TLBMISS_HANDLER_SETUP_PGD(pgd) (pgd_current = (unsigned long)(pgd))2122#define TLBMISS_HANDLER_SETUP() \23do { \24write_c0_context(0); \25TLBMISS_HANDLER_SETUP_PGD(swapper_pg_dir) \26} while (0)2728/*29* All unused by hardware upper bits will be considered30* as a software asid extension.31*/32#define ASID_VERSION_MASK 0xfffff00033#define ASID_FIRST_VERSION 0x10003435/* PEVN --------- VPN ---------- --ASID--- -NA- */36/* binary: 0000 0000 0000 0000 0000 0000 0001 0000 */37/* binary: 0000 0000 0000 0000 0000 1111 1111 0000 */38#define ASID_INC 0x1039#define ASID_MASK 0xff04041static inline void enter_lazy_tlb(struct mm_struct *mm,42struct task_struct *tsk)43{}4445static inline void46get_new_mmu_context(struct mm_struct *mm)47{48unsigned long asid = asid_cache + ASID_INC;4950if (!(asid & ASID_MASK)) {51local_flush_tlb_all(); /* start new asid cycle */52if (!asid) /* fix version if needed */53asid = ASID_FIRST_VERSION;54}5556mm->context = asid;57asid_cache = asid;58}5960/*61* Initialize the context related info for a new mm_struct62* instance.63*/64static inline int65init_new_context(struct task_struct *tsk, struct mm_struct *mm)66{67mm->context = 0;68return 0;69}7071static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,72struct task_struct *tsk)73{74unsigned long flags;7576local_irq_save(flags);77if ((next->context ^ asid_cache) & ASID_VERSION_MASK)78get_new_mmu_context(next);7980pevn_set(next->context);81TLBMISS_HANDLER_SETUP_PGD(next->pgd);82local_irq_restore(flags);83}8485/*86* Destroy context related info for an mm_struct that is about87* to be put to rest.88*/89static inline void destroy_context(struct mm_struct *mm)90{}9192static inline void93deactivate_mm(struct task_struct *task, struct mm_struct *mm)94{}9596/*97* After we have set current->mm to a new value, this activates98* the context for the new mm so we see the new mappings.99*/100static inline void101activate_mm(struct mm_struct *prev, struct mm_struct *next)102{103unsigned long flags;104105local_irq_save(flags);106get_new_mmu_context(next);107pevn_set(next->context);108TLBMISS_HANDLER_SETUP_PGD(next->pgd);109local_irq_restore(flags);110}111112#endif /* _ASM_SCORE_MMU_CONTEXT_H */113114115