Merge git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
[wrt350n-kernel.git] / include / asm-xtensa / cacheflush.h
blob003108271d62735d2a716c7d947d628349c56520
1 /*
2 * include/asm-xtensa/cacheflush.h
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
8 * (C) 2001 - 2007 Tensilica Inc.
9 */
11 #ifndef _XTENSA_CACHEFLUSH_H
12 #define _XTENSA_CACHEFLUSH_H
14 #ifdef __KERNEL__
16 #include <linux/mm.h>
17 #include <asm/processor.h>
18 #include <asm/page.h>
21 * Lo-level routines for cache flushing.
23 * invalidate data or instruction cache:
25 * __invalidate_icache_all()
26 * __invalidate_icache_page(adr)
27 * __invalidate_dcache_page(adr)
28 * __invalidate_icache_range(from,size)
29 * __invalidate_dcache_range(from,size)
31 * flush data cache:
33 * __flush_dcache_page(adr)
35 * flush and invalidate data cache:
37 * __flush_invalidate_dcache_all()
38 * __flush_invalidate_dcache_page(adr)
39 * __flush_invalidate_dcache_range(from,size)
41 * specials for cache aliasing:
43 * __flush_invalidate_dcache_page_alias(vaddr,paddr)
44 * __invalidate_icache_page_alias(vaddr,paddr)
47 extern void __invalidate_dcache_all(void);
48 extern void __invalidate_icache_all(void);
49 extern void __invalidate_dcache_page(unsigned long);
50 extern void __invalidate_icache_page(unsigned long);
51 extern void __invalidate_icache_range(unsigned long, unsigned long);
52 extern void __invalidate_dcache_range(unsigned long, unsigned long);
55 #if XCHAL_DCACHE_IS_WRITEBACK
56 extern void __flush_invalidate_dcache_all(void);
57 extern void __flush_dcache_page(unsigned long);
58 extern void __flush_dcache_range(unsigned long, unsigned long);
59 extern void __flush_invalidate_dcache_page(unsigned long);
60 extern void __flush_invalidate_dcache_range(unsigned long, unsigned long);
61 #else
62 # define __flush_dcache_range(p,s) do { } while(0)
63 # define __flush_dcache_page(p) do { } while(0)
64 # define __flush_invalidate_dcache_page(p) __invalidate_dcache_page(p)
65 # define __flush_invalidate_dcache_range(p,s) __invalidate_dcache_range(p,s)
66 #endif
68 #if (DCACHE_WAY_SIZE > PAGE_SIZE)
69 extern void __flush_invalidate_dcache_page_alias(unsigned long, unsigned long);
70 #endif
71 #if (ICACHE_WAY_SIZE > PAGE_SIZE)
72 extern void __invalidate_icache_page_alias(unsigned long, unsigned long);
73 <<<<<<< HEAD:include/asm-xtensa/cacheflush.h
74 =======
75 #else
76 # define __invalidate_icache_page_alias(v,p) do { } while(0)
77 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:include/asm-xtensa/cacheflush.h
78 #endif
81 * We have physically tagged caches - nothing to do here -
82 * unless we have cache aliasing.
84 * Pages can get remapped. Because this might change the 'color' of that page,
85 * we have to flush the cache before the PTE is changed.
86 * (see also Documentation/cachetlb.txt)
89 #if (DCACHE_WAY_SIZE > PAGE_SIZE)
91 #define flush_cache_all() \
92 do { \
93 __flush_invalidate_dcache_all(); \
94 __invalidate_icache_all(); \
95 } while (0)
97 #define flush_cache_mm(mm) flush_cache_all()
98 #define flush_cache_dup_mm(mm) flush_cache_mm(mm)
100 #define flush_cache_vmap(start,end) flush_cache_all()
101 #define flush_cache_vunmap(start,end) flush_cache_all()
103 extern void flush_dcache_page(struct page*);
104 extern void flush_cache_range(struct vm_area_struct*, ulong, ulong);
105 extern void flush_cache_page(struct vm_area_struct*, unsigned long, unsigned long);
107 #else
109 #define flush_cache_all() do { } while (0)
110 #define flush_cache_mm(mm) do { } while (0)
111 #define flush_cache_dup_mm(mm) do { } while (0)
113 #define flush_cache_vmap(start,end) do { } while (0)
114 #define flush_cache_vunmap(start,end) do { } while (0)
116 #define flush_dcache_page(page) do { } while (0)
118 #define flush_cache_page(vma,addr,pfn) do { } while (0)
119 #define flush_cache_range(vma,start,end) do { } while (0)
121 #endif
123 /* Ensure consistency between data and instruction cache. */
124 #define flush_icache_range(start,end) \
125 do { \
126 __flush_dcache_range(start, (end) - (start)); \
127 __invalidate_icache_range(start,(end) - (start)); \
128 } while (0)
130 /* This is not required, see Documentation/cachetlb.txt */
131 #define flush_icache_page(vma,page) do { } while (0)
133 #define flush_dcache_mmap_lock(mapping) do { } while (0)
134 #define flush_dcache_mmap_unlock(mapping) do { } while (0)
136 #if (DCACHE_WAY_SIZE > PAGE_SIZE)
138 extern void copy_to_user_page(struct vm_area_struct*, struct page*,
139 unsigned long, void*, const void*, unsigned long);
140 extern void copy_from_user_page(struct vm_area_struct*, struct page*,
141 unsigned long, void*, const void*, unsigned long);
143 #else
145 #define copy_to_user_page(vma, page, vaddr, dst, src, len) \
146 do { \
147 memcpy(dst, src, len); \
148 __flush_dcache_range((unsigned long) dst, len); \
149 __invalidate_icache_range((unsigned long) dst, len); \
150 } while (0)
152 #define copy_from_user_page(vma, page, vaddr, dst, src, len) \
153 memcpy(dst, src, len)
155 #endif
157 #endif /* __KERNEL__ */
158 #endif /* _XTENSA_CACHEFLUSH_H */