cacheflush.h 3.7 KB

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