Path: blob/master/arch/avr32/include/asm/cacheflush.h
10819 views
/*1* Copyright (C) 2004-2006 Atmel Corporation2*3* This program is free software; you can redistribute it and/or modify4* it under the terms of the GNU General Public License version 2 as5* published by the Free Software Foundation.6*/7#ifndef __ASM_AVR32_CACHEFLUSH_H8#define __ASM_AVR32_CACHEFLUSH_H910/* Keep includes the same across arches. */11#include <linux/mm.h>1213#define CACHE_OP_ICACHE_INVALIDATE 0x0114#define CACHE_OP_DCACHE_INVALIDATE 0x0b15#define CACHE_OP_DCACHE_CLEAN 0x0c16#define CACHE_OP_DCACHE_CLEAN_INVAL 0x0d1718/*19* Invalidate any cacheline containing virtual address vaddr without20* writing anything back to memory.21*22* Note that this function may corrupt unrelated data structures when23* applied on buffers that are not cacheline aligned in both ends.24*/25static inline void invalidate_dcache_line(void *vaddr)26{27asm volatile("cache %0[0], %1"28:29: "r"(vaddr), "n"(CACHE_OP_DCACHE_INVALIDATE)30: "memory");31}3233/*34* Make sure any cacheline containing virtual address vaddr is written35* to memory.36*/37static inline void clean_dcache_line(void *vaddr)38{39asm volatile("cache %0[0], %1"40:41: "r"(vaddr), "n"(CACHE_OP_DCACHE_CLEAN)42: "memory");43}4445/*46* Make sure any cacheline containing virtual address vaddr is written47* to memory and then invalidate it.48*/49static inline void flush_dcache_line(void *vaddr)50{51asm volatile("cache %0[0], %1"52:53: "r"(vaddr), "n"(CACHE_OP_DCACHE_CLEAN_INVAL)54: "memory");55}5657/*58* Invalidate any instruction cacheline containing virtual address59* vaddr.60*/61static inline void invalidate_icache_line(void *vaddr)62{63asm volatile("cache %0[0], %1"64:65: "r"(vaddr), "n"(CACHE_OP_ICACHE_INVALIDATE)66: "memory");67}6869/*70* Applies the above functions on all lines that are touched by the71* specified virtual address range.72*/73void invalidate_dcache_region(void *start, size_t len);74void clean_dcache_region(void *start, size_t len);75void flush_dcache_region(void *start, size_t len);76void invalidate_icache_region(void *start, size_t len);7778/*79* Make sure any pending writes are completed before continuing.80*/81#define flush_write_buffer() asm volatile("sync 0" : : : "memory")8283/*84* The following functions are called when a virtual mapping changes.85* We do not need to flush anything in this case.86*/87#define flush_cache_all() do { } while (0)88#define flush_cache_mm(mm) do { } while (0)89#define flush_cache_dup_mm(mm) do { } while (0)90#define flush_cache_range(vma, start, end) do { } while (0)91#define flush_cache_page(vma, vmaddr, pfn) do { } while (0)92#define flush_cache_vmap(start, end) do { } while (0)93#define flush_cache_vunmap(start, end) do { } while (0)9495/*96* I think we need to implement this one to be able to reliably97* execute pages from RAMDISK. However, if we implement the98* flush_dcache_*() functions, it might not be needed anymore.99*100* #define flush_icache_page(vma, page) do { } while (0)101*/102extern void flush_icache_page(struct vm_area_struct *vma, struct page *page);103104/*105* These are (I think) related to D-cache aliasing. We might need to106* do something here, but only for certain configurations. No such107* configurations exist at this time.108*/109#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 0110#define flush_dcache_page(page) do { } while (0)111#define flush_dcache_mmap_lock(page) do { } while (0)112#define flush_dcache_mmap_unlock(page) do { } while (0)113114/*115* These are for I/D cache coherency. In this case, we do need to116* flush with all configurations.117*/118extern void flush_icache_range(unsigned long start, unsigned long end);119120extern void copy_to_user_page(struct vm_area_struct *vma, struct page *page,121unsigned long vaddr, void *dst, const void *src,122unsigned long len);123124static inline void copy_from_user_page(struct vm_area_struct *vma,125struct page *page, unsigned long vaddr, void *dst,126const void *src, unsigned long len)127{128memcpy(dst, src, len);129}130131#endif /* __ASM_AVR32_CACHEFLUSH_H */132133134