xref: /openbmc/linux/arch/microblaze/include/asm/cacheflush.h (revision 46fb9be93b15bd8315622ad2f85f9516c064a785)
18beb8503SMichal Simek /*
2*46fb9be9SMichal Simek  * Copyright (C) 2007-2009 Michal Simek <monstr@monstr.eu>
3*46fb9be9SMichal Simek  * Copyright (C) 2007-2009 PetaLogix
48beb8503SMichal Simek  * Copyright (C) 2007 John Williams <john.williams@petalogix.com>
58beb8503SMichal Simek  * based on v850 version which was
68beb8503SMichal Simek  * Copyright (C) 2001,02,03 NEC Electronics Corporation
78beb8503SMichal Simek  * Copyright (C) 2001,02,03 Miles Bader <miles@gnu.org>
88beb8503SMichal Simek  *
98beb8503SMichal Simek  * This file is subject to the terms and conditions of the GNU General
108beb8503SMichal Simek  * Public License. See the file COPYING in the main directory of this
118beb8503SMichal Simek  * archive for more details.
128beb8503SMichal Simek  *
138beb8503SMichal Simek  */
148beb8503SMichal Simek 
158beb8503SMichal Simek #ifndef _ASM_MICROBLAZE_CACHEFLUSH_H
168beb8503SMichal Simek #define _ASM_MICROBLAZE_CACHEFLUSH_H
178beb8503SMichal Simek 
188beb8503SMichal Simek /* Somebody depends on this; sigh... */
198beb8503SMichal Simek #include <linux/mm.h>
208beb8503SMichal Simek 
218beb8503SMichal Simek /*
228beb8503SMichal Simek  * Cache handling functions.
238beb8503SMichal Simek  * Microblaze has a write-through data cache, meaning that the data cache
248beb8503SMichal Simek  * never needs to be flushed.  The only flushing operations that are
258beb8503SMichal Simek  * implemented are to invalidate the instruction cache.  These are called
268beb8503SMichal Simek  * after loading a user application into memory, we must invalidate the
278beb8503SMichal Simek  * instruction cache to make sure we don't fetch old, bad code.
288beb8503SMichal Simek  */
298beb8503SMichal Simek 
308beb8503SMichal Simek /* FIXME for LL-temac driver */
318beb8503SMichal Simek #define invalidate_dcache_range(start, end) \
328beb8503SMichal Simek 			__invalidate_dcache_range(start, end)
338beb8503SMichal Simek 
348beb8503SMichal Simek #define flush_cache_all()			__invalidate_cache_all()
358beb8503SMichal Simek #define flush_cache_mm(mm)			do { } while (0)
368beb8503SMichal Simek #define flush_cache_range(vma, start, end)	__invalidate_cache_all()
378beb8503SMichal Simek #define flush_cache_page(vma, vmaddr, pfn)	do { } while (0)
388beb8503SMichal Simek 
398beb8503SMichal Simek #define flush_dcache_range(start, end)	__invalidate_dcache_range(start, end)
408beb8503SMichal Simek #define flush_dcache_page(page)			do { } while (0)
418beb8503SMichal Simek #define flush_dcache_mmap_lock(mapping)		do { } while (0)
428beb8503SMichal Simek #define flush_dcache_mmap_unlock(mapping)	do { } while (0)
438beb8503SMichal Simek 
448beb8503SMichal Simek #define flush_icache_range(start, len)	__invalidate_icache_range(start, len)
458beb8503SMichal Simek #define flush_icache_page(vma, pg)		do { } while (0)
468beb8503SMichal Simek 
47*46fb9be9SMichal Simek #ifndef CONFIG_MMU
48*46fb9be9SMichal Simek # define flush_icache_user_range(start, len)	do { } while (0)
49*46fb9be9SMichal Simek #else
50*46fb9be9SMichal Simek # define flush_icache_user_range(vma, pg, adr, len) __invalidate_icache_all()
51*46fb9be9SMichal Simek 
52*46fb9be9SMichal Simek # define flush_page_to_ram(page)		do { } while (0)
53*46fb9be9SMichal Simek 
54*46fb9be9SMichal Simek # define flush_icache()			__invalidate_icache_all()
55*46fb9be9SMichal Simek # define flush_cache_sigtramp(vaddr) \
56*46fb9be9SMichal Simek 			__invalidate_icache_range(vaddr, vaddr + 8)
57*46fb9be9SMichal Simek 
58*46fb9be9SMichal Simek # define flush_dcache_mmap_lock(mapping)	do { } while (0)
59*46fb9be9SMichal Simek # define flush_dcache_mmap_unlock(mapping)	do { } while (0)
60*46fb9be9SMichal Simek 
61*46fb9be9SMichal Simek # define flush_cache_dup_mm(mm)			do { } while (0)
62*46fb9be9SMichal Simek #endif
63*46fb9be9SMichal Simek 
648beb8503SMichal Simek #define flush_cache_vmap(start, end)		do { } while (0)
658beb8503SMichal Simek #define flush_cache_vunmap(start, end)		do { } while (0)
668beb8503SMichal Simek 
678beb8503SMichal Simek struct page;
688beb8503SMichal Simek struct mm_struct;
698beb8503SMichal Simek struct vm_area_struct;
708beb8503SMichal Simek 
718beb8503SMichal Simek /* see arch/microblaze/kernel/cache.c */
728beb8503SMichal Simek extern void __invalidate_icache_all(void);
738beb8503SMichal Simek extern void __invalidate_icache_range(unsigned long start, unsigned long end);
748beb8503SMichal Simek extern void __invalidate_icache_page(struct vm_area_struct *vma,
758beb8503SMichal Simek 				struct page *page);
768beb8503SMichal Simek extern void __invalidate_icache_user_range(struct vm_area_struct *vma,
778beb8503SMichal Simek 				struct page *page,
788beb8503SMichal Simek 				unsigned long adr, int len);
798beb8503SMichal Simek extern void __invalidate_cache_sigtramp(unsigned long addr);
808beb8503SMichal Simek 
818beb8503SMichal Simek extern void __invalidate_dcache_all(void);
828beb8503SMichal Simek extern void __invalidate_dcache_range(unsigned long start, unsigned long end);
838beb8503SMichal Simek extern void __invalidate_dcache_page(struct vm_area_struct *vma,
848beb8503SMichal Simek 				struct page *page);
858beb8503SMichal Simek extern void __invalidate_dcache_user_range(struct vm_area_struct *vma,
868beb8503SMichal Simek 				struct page *page,
878beb8503SMichal Simek 				unsigned long adr, int len);
888beb8503SMichal Simek 
898beb8503SMichal Simek extern inline void __invalidate_cache_all(void)
908beb8503SMichal Simek {
918beb8503SMichal Simek 	__invalidate_icache_all();
928beb8503SMichal Simek 	__invalidate_dcache_all();
938beb8503SMichal Simek }
948beb8503SMichal Simek 
958beb8503SMichal Simek #define copy_to_user_page(vma, page, vaddr, dst, src, len) \
968beb8503SMichal Simek do { memcpy((dst), (src), (len)); \
978beb8503SMichal Simek 	flush_icache_range((unsigned) (dst), (unsigned) (dst) + (len)); \
988beb8503SMichal Simek } while (0)
998beb8503SMichal Simek 
1008beb8503SMichal Simek #define copy_from_user_page(vma, page, vaddr, dst, src, len) \
1018beb8503SMichal Simek 	memcpy((dst), (src), (len))
1028beb8503SMichal Simek 
1038beb8503SMichal Simek #endif /* _ASM_MICROBLAZE_CACHEFLUSH_H */
104