1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef __ASM_SH_CACHEFLUSH_H 3 #define __ASM_SH_CACHEFLUSH_H 4 5 #ifdef __KERNEL__ 6 7 #include <linux/mm.h> 8 9 /* 10 * Cache flushing: 11 * 12 * - flush_cache_all() flushes entire cache 13 * - flush_cache_mm(mm) flushes the specified mm context's cache lines 14 * - flush_cache_dup mm(mm) handles cache flushing when forking 15 * - flush_cache_page(mm, vmaddr, pfn) flushes a single page 16 * - flush_cache_range(vma, start, end) flushes a range of pages 17 * 18 * - flush_dcache_page(pg) flushes(wback&invalidates) a page for dcache 19 * - flush_icache_range(start, end) flushes(invalidates) a range for icache 20 * - flush_icache_page(vma, pg) flushes(invalidates) a page for icache 21 * - flush_cache_sigtramp(vaddr) flushes the signal trampoline 22 */ 23 extern void (*local_flush_cache_all)(void *args); 24 extern void (*local_flush_cache_mm)(void *args); 25 extern void (*local_flush_cache_dup_mm)(void *args); 26 extern void (*local_flush_cache_page)(void *args); 27 extern void (*local_flush_cache_range)(void *args); 28 extern void (*local_flush_dcache_page)(void *args); 29 extern void (*local_flush_icache_range)(void *args); 30 extern void (*local_flush_icache_page)(void *args); 31 extern void (*local_flush_cache_sigtramp)(void *args); 32 33 static inline void cache_noop(void *args) { } 34 35 extern void (*__flush_wback_region)(void *start, int size); 36 extern void (*__flush_purge_region)(void *start, int size); 37 extern void (*__flush_invalidate_region)(void *start, int size); 38 39 extern void flush_cache_all(void); 40 extern void flush_cache_mm(struct mm_struct *mm); 41 extern void flush_cache_dup_mm(struct mm_struct *mm); 42 extern void flush_cache_page(struct vm_area_struct *vma, 43 unsigned long addr, unsigned long pfn); 44 extern void flush_cache_range(struct vm_area_struct *vma, 45 unsigned long start, unsigned long end); 46 #define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 1 47 extern void flush_dcache_page(struct page *page); 48 extern void flush_icache_range(unsigned long start, unsigned long end); 49 #define flush_icache_user_range flush_icache_range 50 extern void flush_icache_page(struct vm_area_struct *vma, 51 struct page *page); 52 extern void flush_cache_sigtramp(unsigned long address); 53 54 struct flusher_data { 55 struct vm_area_struct *vma; 56 unsigned long addr1, addr2; 57 }; 58 59 #define ARCH_HAS_FLUSH_ANON_PAGE 60 extern void __flush_anon_page(struct page *page, unsigned long); 61 62 static inline void flush_anon_page(struct vm_area_struct *vma, 63 struct page *page, unsigned long vmaddr) 64 { 65 if (boot_cpu_data.dcache.n_aliases && PageAnon(page)) 66 __flush_anon_page(page, vmaddr); 67 } 68 static inline void flush_kernel_vmap_range(void *addr, int size) 69 { 70 __flush_wback_region(addr, size); 71 } 72 static inline void invalidate_kernel_vmap_range(void *addr, int size) 73 { 74 __flush_invalidate_region(addr, size); 75 } 76 77 #define ARCH_HAS_FLUSH_KERNEL_DCACHE_PAGE 78 static inline void flush_kernel_dcache_page(struct page *page) 79 { 80 flush_dcache_page(page); 81 } 82 83 extern void copy_to_user_page(struct vm_area_struct *vma, 84 struct page *page, unsigned long vaddr, void *dst, const void *src, 85 unsigned long len); 86 87 extern void copy_from_user_page(struct vm_area_struct *vma, 88 struct page *page, unsigned long vaddr, void *dst, const void *src, 89 unsigned long len); 90 91 #define flush_cache_vmap(start, end) local_flush_cache_all(NULL) 92 #define flush_cache_vunmap(start, end) local_flush_cache_all(NULL) 93 94 #define flush_dcache_mmap_lock(mapping) do { } while (0) 95 #define flush_dcache_mmap_unlock(mapping) do { } while (0) 96 97 void kmap_coherent_init(void); 98 void *kmap_coherent(struct page *page, unsigned long addr); 99 void kunmap_coherent(void *kvaddr); 100 101 #define PG_dcache_clean PG_arch_1 102 103 void cpu_cache_init(void); 104 105 static inline void *sh_cacheop_vaddr(void *vaddr) 106 { 107 if (__in_29bit_mode()) 108 vaddr = (void *)CAC_ADDR((unsigned long)vaddr); 109 return vaddr; 110 } 111 112 #endif /* __KERNEL__ */ 113 #endif /* __ASM_SH_CACHEFLUSH_H */ 114