1 /* 2 * Copyright (C) 2012 Regents of the University of California 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation, version 2. 7 * 8 * This program is distributed in the hope that it will be useful, 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * GNU General Public License for more details. 12 */ 13 14 #ifndef _ASM_RISCV_MMU_CONTEXT_H 15 #define _ASM_RISCV_MMU_CONTEXT_H 16 17 #include <asm-generic/mm_hooks.h> 18 19 #include <linux/mm.h> 20 #include <linux/sched.h> 21 #include <asm/tlbflush.h> 22 23 static inline void enter_lazy_tlb(struct mm_struct *mm, 24 struct task_struct *task) 25 { 26 } 27 28 /* Initialize context-related info for a new mm_struct */ 29 static inline int init_new_context(struct task_struct *task, 30 struct mm_struct *mm) 31 { 32 return 0; 33 } 34 35 static inline void destroy_context(struct mm_struct *mm) 36 { 37 } 38 39 static inline pgd_t *current_pgdir(void) 40 { 41 return pfn_to_virt(csr_read(sptbr) & SPTBR_PPN); 42 } 43 44 static inline void set_pgdir(pgd_t *pgd) 45 { 46 csr_write(sptbr, virt_to_pfn(pgd) | SPTBR_MODE); 47 } 48 49 static inline void switch_mm(struct mm_struct *prev, 50 struct mm_struct *next, struct task_struct *task) 51 { 52 if (likely(prev != next)) { 53 set_pgdir(next->pgd); 54 local_flush_tlb_all(); 55 } 56 } 57 58 static inline void activate_mm(struct mm_struct *prev, 59 struct mm_struct *next) 60 { 61 switch_mm(prev, next, NULL); 62 } 63 64 static inline void deactivate_mm(struct task_struct *task, 65 struct mm_struct *mm) 66 { 67 } 68 69 #endif /* _ASM_RISCV_MMU_CONTEXT_H */ 70