18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci#ifndef __ASM_SH_CACHEFLUSH_H 38c2ecf20Sopenharmony_ci#define __ASM_SH_CACHEFLUSH_H 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci#include <linux/mm.h> 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ci/* 88c2ecf20Sopenharmony_ci * Cache flushing: 98c2ecf20Sopenharmony_ci * 108c2ecf20Sopenharmony_ci * - flush_cache_all() flushes entire cache 118c2ecf20Sopenharmony_ci * - flush_cache_mm(mm) flushes the specified mm context's cache lines 128c2ecf20Sopenharmony_ci * - flush_cache_dup mm(mm) handles cache flushing when forking 138c2ecf20Sopenharmony_ci * - flush_cache_page(mm, vmaddr, pfn) flushes a single page 148c2ecf20Sopenharmony_ci * - flush_cache_range(vma, start, end) flushes a range of pages 158c2ecf20Sopenharmony_ci * 168c2ecf20Sopenharmony_ci * - flush_dcache_page(pg) flushes(wback&invalidates) a page for dcache 178c2ecf20Sopenharmony_ci * - flush_icache_range(start, end) flushes(invalidates) a range for icache 188c2ecf20Sopenharmony_ci * - flush_icache_page(vma, pg) flushes(invalidates) a page for icache 198c2ecf20Sopenharmony_ci * - flush_cache_sigtramp(vaddr) flushes the signal trampoline 208c2ecf20Sopenharmony_ci */ 218c2ecf20Sopenharmony_ciextern void (*local_flush_cache_all)(void *args); 228c2ecf20Sopenharmony_ciextern void (*local_flush_cache_mm)(void *args); 238c2ecf20Sopenharmony_ciextern void (*local_flush_cache_dup_mm)(void *args); 248c2ecf20Sopenharmony_ciextern void (*local_flush_cache_page)(void *args); 258c2ecf20Sopenharmony_ciextern void (*local_flush_cache_range)(void *args); 268c2ecf20Sopenharmony_ciextern void (*local_flush_dcache_page)(void *args); 278c2ecf20Sopenharmony_ciextern void (*local_flush_icache_range)(void *args); 288c2ecf20Sopenharmony_ciextern void (*local_flush_icache_page)(void *args); 298c2ecf20Sopenharmony_ciextern void (*local_flush_cache_sigtramp)(void *args); 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_cistatic inline void cache_noop(void *args) { } 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ciextern void (*__flush_wback_region)(void *start, int size); 348c2ecf20Sopenharmony_ciextern void (*__flush_purge_region)(void *start, int size); 358c2ecf20Sopenharmony_ciextern void (*__flush_invalidate_region)(void *start, int size); 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ciextern void flush_cache_all(void); 388c2ecf20Sopenharmony_ciextern void flush_cache_mm(struct mm_struct *mm); 398c2ecf20Sopenharmony_ciextern void flush_cache_dup_mm(struct mm_struct *mm); 408c2ecf20Sopenharmony_ciextern void flush_cache_page(struct vm_area_struct *vma, 418c2ecf20Sopenharmony_ci unsigned long addr, unsigned long pfn); 428c2ecf20Sopenharmony_ciextern void flush_cache_range(struct vm_area_struct *vma, 438c2ecf20Sopenharmony_ci unsigned long start, unsigned long end); 448c2ecf20Sopenharmony_ci#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 1 458c2ecf20Sopenharmony_ciextern void flush_dcache_page(struct page *page); 468c2ecf20Sopenharmony_ciextern void flush_icache_range(unsigned long start, unsigned long end); 478c2ecf20Sopenharmony_ci#define flush_icache_user_range flush_icache_range 488c2ecf20Sopenharmony_ciextern void flush_icache_page(struct vm_area_struct *vma, 498c2ecf20Sopenharmony_ci struct page *page); 508c2ecf20Sopenharmony_ciextern void flush_cache_sigtramp(unsigned long address); 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_cistruct flusher_data { 538c2ecf20Sopenharmony_ci struct vm_area_struct *vma; 548c2ecf20Sopenharmony_ci unsigned long addr1, addr2; 558c2ecf20Sopenharmony_ci}; 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_ci#define ARCH_HAS_FLUSH_ANON_PAGE 588c2ecf20Sopenharmony_ciextern void __flush_anon_page(struct page *page, unsigned long); 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_cistatic inline void flush_anon_page(struct vm_area_struct *vma, 618c2ecf20Sopenharmony_ci struct page *page, unsigned long vmaddr) 628c2ecf20Sopenharmony_ci{ 638c2ecf20Sopenharmony_ci if (boot_cpu_data.dcache.n_aliases && PageAnon(page)) 648c2ecf20Sopenharmony_ci __flush_anon_page(page, vmaddr); 658c2ecf20Sopenharmony_ci} 668c2ecf20Sopenharmony_cistatic inline void flush_kernel_vmap_range(void *addr, int size) 678c2ecf20Sopenharmony_ci{ 688c2ecf20Sopenharmony_ci __flush_wback_region(addr, size); 698c2ecf20Sopenharmony_ci} 708c2ecf20Sopenharmony_cistatic inline void invalidate_kernel_vmap_range(void *addr, int size) 718c2ecf20Sopenharmony_ci{ 728c2ecf20Sopenharmony_ci __flush_invalidate_region(addr, size); 738c2ecf20Sopenharmony_ci} 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ci#define ARCH_HAS_FLUSH_KERNEL_DCACHE_PAGE 768c2ecf20Sopenharmony_cistatic inline void flush_kernel_dcache_page(struct page *page) 778c2ecf20Sopenharmony_ci{ 788c2ecf20Sopenharmony_ci flush_dcache_page(page); 798c2ecf20Sopenharmony_ci} 808c2ecf20Sopenharmony_ci 818c2ecf20Sopenharmony_ciextern void copy_to_user_page(struct vm_area_struct *vma, 828c2ecf20Sopenharmony_ci struct page *page, unsigned long vaddr, void *dst, const void *src, 838c2ecf20Sopenharmony_ci unsigned long len); 848c2ecf20Sopenharmony_ci 858c2ecf20Sopenharmony_ciextern void copy_from_user_page(struct vm_area_struct *vma, 868c2ecf20Sopenharmony_ci struct page *page, unsigned long vaddr, void *dst, const void *src, 878c2ecf20Sopenharmony_ci unsigned long len); 888c2ecf20Sopenharmony_ci 898c2ecf20Sopenharmony_ci#define flush_cache_vmap(start, end) local_flush_cache_all(NULL) 908c2ecf20Sopenharmony_ci#define flush_cache_vunmap(start, end) local_flush_cache_all(NULL) 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_ci#define flush_dcache_mmap_lock(mapping) do { } while (0) 938c2ecf20Sopenharmony_ci#define flush_dcache_mmap_unlock(mapping) do { } while (0) 948c2ecf20Sopenharmony_ci 958c2ecf20Sopenharmony_civoid kmap_coherent_init(void); 968c2ecf20Sopenharmony_civoid *kmap_coherent(struct page *page, unsigned long addr); 978c2ecf20Sopenharmony_civoid kunmap_coherent(void *kvaddr); 988c2ecf20Sopenharmony_ci 998c2ecf20Sopenharmony_ci#define PG_dcache_clean PG_arch_1 1008c2ecf20Sopenharmony_ci 1018c2ecf20Sopenharmony_civoid cpu_cache_init(void); 1028c2ecf20Sopenharmony_ci 1038c2ecf20Sopenharmony_cistatic inline void *sh_cacheop_vaddr(void *vaddr) 1048c2ecf20Sopenharmony_ci{ 1058c2ecf20Sopenharmony_ci if (__in_29bit_mode()) 1068c2ecf20Sopenharmony_ci vaddr = (void *)CAC_ADDR((unsigned long)vaddr); 1078c2ecf20Sopenharmony_ci return vaddr; 1088c2ecf20Sopenharmony_ci} 1098c2ecf20Sopenharmony_ci 1108c2ecf20Sopenharmony_ci#endif /* __ASM_SH_CACHEFLUSH_H */ 111