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