1 #ifndef _M68K_CACHEFLUSH_H
2 #define _M68K_CACHEFLUSH_H
7 #define FLUSH_I_AND_D (0x00000808)
8 #define FLUSH_I (0x00000008)
11 * Cache handling functions
14 static inline void flush_icache(void)
16 if (CPU_IS_040_OR_060
)
17 asm volatile ( "nop\n"
23 asm volatile ( "movec %%cacr,%0\n"
32 * invalidate the cache for the specified memory range.
33 * It starts at the physical address specified for
34 * the given number of bytes.
36 extern void cache_clear(unsigned long paddr
, int len
);
38 * push any dirty cache in the specified memory range.
39 * It starts at the physical address specified for
40 * the given number of bytes.
42 extern void cache_push(unsigned long paddr
, int len
);
45 * push and invalidate pages in the specified user virtual
48 extern void cache_push_v(unsigned long vaddr
, int len
);
50 /* This is needed whenever the virtual mapping of the current
52 #define __flush_cache_all() \
54 if (CPU_IS_040_OR_060) \
55 __asm__ __volatile__("nop\n\t" \
61 __asm__ __volatile__("movec %%cacr,%0\n\t" \
65 : "di" (FLUSH_I_AND_D)); \
69 #define __flush_cache_030() \
71 if (CPU_IS_020_OR_030) { \
73 __asm__ __volatile__("movec %%cacr,%0\n\t" \
77 : "di" (FLUSH_I_AND_D)); \
81 #define flush_cache_all() __flush_cache_all()
83 #define flush_cache_vmap(start, end) flush_cache_all()
84 #define flush_cache_vunmap(start, end) flush_cache_all()
86 static inline void flush_cache_mm(struct mm_struct
*mm
)
88 if (mm
== current
->mm
)
92 #define flush_cache_dup_mm(mm) flush_cache_mm(mm)
94 /* flush_cache_range/flush_cache_page must be macros to avoid
95 a dependency on linux/mm.h, which includes this file... */
96 static inline void flush_cache_range(struct vm_area_struct
*vma
,
100 if (vma
->vm_mm
== current
->mm
)
104 static inline void flush_cache_page(struct vm_area_struct
*vma
, unsigned long vmaddr
, unsigned long pfn
)
106 if (vma
->vm_mm
== current
->mm
)
111 /* Push the page at kernel virtual address and clear the icache */
112 /* RZ: use cpush %bc instead of cpush %dc, cinv %ic */
113 static inline void __flush_page_to_ram(void *vaddr
)
115 if (CPU_IS_040_OR_060
) {
116 __asm__
__volatile__("nop\n\t"
118 "cpushp %%bc,(%0)\n\t"
120 : : "a" (__pa(vaddr
)));
123 __asm__
__volatile__("movec %%cacr,%0\n\t"
131 #define flush_dcache_page(page) __flush_page_to_ram(page_address(page))
132 #define flush_dcache_mmap_lock(mapping) do { } while (0)
133 #define flush_dcache_mmap_unlock(mapping) do { } while (0)
134 #define flush_icache_page(vma, page) __flush_page_to_ram(page_address(page))
136 extern void flush_icache_user_range(struct vm_area_struct
*vma
, struct page
*page
,
137 unsigned long addr
, int len
);
138 extern void flush_icache_range(unsigned long address
, unsigned long endaddr
);
140 static inline void copy_to_user_page(struct vm_area_struct
*vma
,
141 struct page
*page
, unsigned long vaddr
,
142 void *dst
, void *src
, int len
)
144 flush_cache_page(vma
, vaddr
, page_to_pfn(page
));
145 memcpy(dst
, src
, len
);
146 flush_icache_user_range(vma
, page
, vaddr
, len
);
148 static inline void copy_from_user_page(struct vm_area_struct
*vma
,
149 struct page
*page
, unsigned long vaddr
,
150 void *dst
, void *src
, int len
)
152 flush_cache_page(vma
, vaddr
, page_to_pfn(page
));
153 memcpy(dst
, src
, len
);
156 #endif /* _M68K_CACHEFLUSH_H */