1 #ifndef _SPARC64_CACHEFLUSH_H
2 #define _SPARC64_CACHEFLUSH_H
3 
4 #include <asm/page.h>
5 
6 #ifndef __ASSEMBLY__
7 
8 #include <linux/mm.h>
9 
10 /* Cache flush operations. */
11 
12 
13 #define flushi(addr)	__asm__ __volatile__ ("flush %0" : : "r" (addr) : "memory")
14 #define flushw_all()	__asm__ __volatile__("flushw")
15 
16 extern void __flushw_user(void);
17 #define flushw_user() __flushw_user()
18 
19 #define flush_user_windows flushw_user
20 #define flush_register_windows flushw_all
21 
22 /* These are the same regardless of whether this is an SMP kernel or not. */
23 #define flush_cache_mm(__mm) \
24 	do { if ((__mm) == current->mm) flushw_user(); } while(0)
25 #define flush_cache_dup_mm(mm) flush_cache_mm(mm)
26 #define flush_cache_range(vma, start, end) \
27 	flush_cache_mm((vma)->vm_mm)
28 #define flush_cache_page(vma, page, pfn) \
29 	flush_cache_mm((vma)->vm_mm)
30 
31 /*
32  * On spitfire, the icache doesn't snoop local stores and we don't
33  * use block commit stores (which invalidate icache lines) during
34  * module load, so we need this.
35  */
36 extern void flush_icache_range(unsigned long start, unsigned long end);
37 extern void __flush_icache_page(unsigned long);
38 
39 extern void __flush_dcache_page(void *addr, int flush_icache);
40 extern void flush_dcache_page_impl(struct page *page);
41 #ifdef CONFIG_SMP
42 extern void smp_flush_dcache_page_impl(struct page *page, int cpu);
43 extern void flush_dcache_page_all(struct mm_struct *mm, struct page *page);
44 #else
45 #define smp_flush_dcache_page_impl(page,cpu) flush_dcache_page_impl(page)
46 #define flush_dcache_page_all(mm,page) flush_dcache_page_impl(page)
47 #endif
48 
49 extern void __flush_dcache_range(unsigned long start, unsigned long end);
50 #define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 1
51 extern void flush_dcache_page(struct page *page);
52 
53 #define flush_icache_page(vma, pg)	do { } while(0)
54 #define flush_icache_user_range(vma,pg,adr,len)	do { } while (0)
55 
56 extern void flush_ptrace_access(struct vm_area_struct *, struct page *,
57 				unsigned long uaddr, void *kaddr,
58 				unsigned long len, int write);
59 
60 #define copy_to_user_page(vma, page, vaddr, dst, src, len)		\
61 	do {								\
62 		flush_cache_page(vma, vaddr, page_to_pfn(page));	\
63 		memcpy(dst, src, len);					\
64 		flush_ptrace_access(vma, page, vaddr, src, len, 0);	\
65 	} while (0)
66 
67 #define copy_from_user_page(vma, page, vaddr, dst, src, len) 		\
68 	do {								\
69 		flush_cache_page(vma, vaddr, page_to_pfn(page));	\
70 		memcpy(dst, src, len);					\
71 		flush_ptrace_access(vma, page, vaddr, dst, len, 1);	\
72 	} while (0)
73 
74 #define flush_dcache_mmap_lock(mapping)		do { } while (0)
75 #define flush_dcache_mmap_unlock(mapping)	do { } while (0)
76 
77 #define flush_cache_vmap(start, end)		do { } while (0)
78 #define flush_cache_vunmap(start, end)		do { } while (0)
79 
80 #ifdef CONFIG_DEBUG_PAGEALLOC
81 /* internal debugging function */
82 void kernel_map_pages(struct page *page, int numpages, int enable);
83 #endif
84 
85 #endif /* !__ASSEMBLY__ */
86 
87 #endif /* _SPARC64_CACHEFLUSH_H */
88