Path: blob/master/arch/unicore32/include/asm/tlbflush.h
10818 views
/*1* linux/arch/unicore32/include/asm/tlbflush.h2*3* Code specific to PKUnity SoC and UniCore ISA4*5* Copyright (C) 2001-2010 GUAN Xue-tao6*7* This program is free software; you can redistribute it and/or modify8* it under the terms of the GNU General Public License version 2 as9* published by the Free Software Foundation.10*/11#ifndef __UNICORE_TLBFLUSH_H__12#define __UNICORE_TLBFLUSH_H__1314#ifndef __ASSEMBLY__1516#include <linux/sched.h>1718extern void __cpu_flush_user_tlb_range(unsigned long, unsigned long,19struct vm_area_struct *);20extern void __cpu_flush_kern_tlb_range(unsigned long, unsigned long);2122/*23* TLB Management24* ==============25*26* The arch/unicore/mm/tlb-*.S files implement these methods.27*28* The TLB specific code is expected to perform whatever tests it29* needs to determine if it should invalidate the TLB for each30* call. Start addresses are inclusive and end addresses are31* exclusive; it is safe to round these addresses down.32*33* flush_tlb_all()34*35* Invalidate the entire TLB.36*37* flush_tlb_mm(mm)38*39* Invalidate all TLB entries in a particular address40* space.41* - mm - mm_struct describing address space42*43* flush_tlb_range(mm,start,end)44*45* Invalidate a range of TLB entries in the specified46* address space.47* - mm - mm_struct describing address space48* - start - start address (may not be aligned)49* - end - end address (exclusive, may not be aligned)50*51* flush_tlb_page(vaddr,vma)52*53* Invalidate the specified page in the specified address range.54* - vaddr - virtual address (may not be aligned)55* - vma - vma_struct describing address range56*57* flush_kern_tlb_page(kaddr)58*59* Invalidate the TLB entry for the specified page. The address60* will be in the kernels virtual memory space. Current uses61* only require the D-TLB to be invalidated.62* - kaddr - Kernel virtual memory address63*/6465static inline void local_flush_tlb_all(void)66{67const int zero = 0;6869/* TLB invalidate all */70asm("movc p0.c6, %0, #6; nop; nop; nop; nop; nop; nop; nop; nop"71: : "r" (zero) : "cc");72}7374static inline void local_flush_tlb_mm(struct mm_struct *mm)75{76const int zero = 0;7778if (cpumask_test_cpu(get_cpu(), mm_cpumask(mm))) {79/* TLB invalidate all */80asm("movc p0.c6, %0, #6; nop; nop; nop; nop; nop; nop; nop; nop"81: : "r" (zero) : "cc");82}83put_cpu();84}8586static inline void87local_flush_tlb_page(struct vm_area_struct *vma, unsigned long uaddr)88{89if (cpumask_test_cpu(smp_processor_id(), mm_cpumask(vma->vm_mm))) {90#ifndef CONFIG_CPU_TLB_SINGLE_ENTRY_DISABLE91/* iTLB invalidate page */92asm("movc p0.c6, %0, #5; nop; nop; nop; nop; nop; nop; nop; nop"93: : "r" (uaddr & PAGE_MASK) : "cc");94/* dTLB invalidate page */95asm("movc p0.c6, %0, #3; nop; nop; nop; nop; nop; nop; nop; nop"96: : "r" (uaddr & PAGE_MASK) : "cc");97#else98/* TLB invalidate all */99asm("movc p0.c6, %0, #6; nop; nop; nop; nop; nop; nop; nop; nop"100: : "r" (uaddr & PAGE_MASK) : "cc");101#endif102}103}104105static inline void local_flush_tlb_kernel_page(unsigned long kaddr)106{107#ifndef CONFIG_CPU_TLB_SINGLE_ENTRY_DISABLE108/* iTLB invalidate page */109asm("movc p0.c6, %0, #5; nop; nop; nop; nop; nop; nop; nop; nop"110: : "r" (kaddr & PAGE_MASK) : "cc");111/* dTLB invalidate page */112asm("movc p0.c6, %0, #3; nop; nop; nop; nop; nop; nop; nop; nop"113: : "r" (kaddr & PAGE_MASK) : "cc");114#else115/* TLB invalidate all */116asm("movc p0.c6, %0, #6; nop; nop; nop; nop; nop; nop; nop; nop"117: : "r" (kaddr & PAGE_MASK) : "cc");118#endif119}120121/*122* flush_pmd_entry123*124* Flush a PMD entry (word aligned, or double-word aligned) to125* RAM if the TLB for the CPU we are running on requires this.126* This is typically used when we are creating PMD entries.127*128* clean_pmd_entry129*130* Clean (but don't drain the write buffer) if the CPU requires131* these operations. This is typically used when we are removing132* PMD entries.133*/134static inline void flush_pmd_entry(pmd_t *pmd)135{136#ifndef CONFIG_CPU_DCACHE_LINE_DISABLE137/* flush dcache line, see dcacheline_flush in proc-macros.S */138asm("mov r1, %0 << #20\n"139"ldw r2, =_stext\n"140"add r2, r2, r1 >> #20\n"141"ldw r1, [r2+], #0x0000\n"142"ldw r1, [r2+], #0x1000\n"143"ldw r1, [r2+], #0x2000\n"144"ldw r1, [r2+], #0x3000\n"145: : "r" (pmd) : "r1", "r2");146#else147/* flush dcache all */148asm("movc p0.c5, %0, #14; nop; nop; nop; nop; nop; nop; nop; nop"149: : "r" (pmd) : "cc");150#endif151}152153static inline void clean_pmd_entry(pmd_t *pmd)154{155#ifndef CONFIG_CPU_DCACHE_LINE_DISABLE156/* clean dcache line */157asm("movc p0.c5, %0, #11; nop; nop; nop; nop; nop; nop; nop; nop"158: : "r" (__pa(pmd) & ~(L1_CACHE_BYTES - 1)) : "cc");159#else160/* clean dcache all */161asm("movc p0.c5, %0, #10; nop; nop; nop; nop; nop; nop; nop; nop"162: : "r" (pmd) : "cc");163#endif164}165166/*167* Convert calls to our calling convention.168*/169#define local_flush_tlb_range(vma, start, end) \170__cpu_flush_user_tlb_range(start, end, vma)171#define local_flush_tlb_kernel_range(s, e) \172__cpu_flush_kern_tlb_range(s, e)173174#define flush_tlb_all local_flush_tlb_all175#define flush_tlb_mm local_flush_tlb_mm176#define flush_tlb_page local_flush_tlb_page177#define flush_tlb_kernel_page local_flush_tlb_kernel_page178#define flush_tlb_range local_flush_tlb_range179#define flush_tlb_kernel_range local_flush_tlb_kernel_range180181/*182* if PG_dcache_clean is not set for the page, we need to ensure that any183* cache entries for the kernels virtual memory range are written184* back to the page.185*/186extern void update_mmu_cache(struct vm_area_struct *vma,187unsigned long addr, pte_t *ptep);188189extern void do_bad_area(unsigned long addr, unsigned int fsr,190struct pt_regs *regs);191192#endif193194#endif195196197