Path: blob/master/arch/unicore32/include/asm/cacheflush.h
10818 views
/*1* linux/arch/unicore32/include/asm/cacheflush.h2*3* Code specific to PKUnity SoC and UniCore ISA4*5* Copyright (C) 2001-2010 GUAN Xue-tao6*7* This program is free software; you can redistribute it and/or modify8* it under the terms of the GNU General Public License version 2 as9* published by the Free Software Foundation.10*/11#ifndef __UNICORE_CACHEFLUSH_H__12#define __UNICORE_CACHEFLUSH_H__1314#include <linux/mm.h>1516#include <asm/shmparam.h>1718#define CACHE_COLOUR(vaddr) ((vaddr & (SHMLBA - 1)) >> PAGE_SHIFT)1920/*21* This flag is used to indicate that the page pointed to by a pte is clean22* and does not require cleaning before returning it to the user.23*/24#define PG_dcache_clean PG_arch_12526/*27* MM Cache Management28* ===================29*30* The arch/unicore32/mm/cache.S files implement these methods.31*32* Start addresses are inclusive and end addresses are exclusive;33* start addresses should be rounded down, end addresses up.34*35* See Documentation/cachetlb.txt for more information.36* Please note that the implementation of these, and the required37* effects are cache-type (VIVT/VIPT/PIPT) specific.38*39* flush_icache_all()40*41* Unconditionally clean and invalidate the entire icache.42* Currently only needed for cache-v6.S and cache-v7.S, see43* __flush_icache_all for the generic implementation.44*45* flush_kern_all()46*47* Unconditionally clean and invalidate the entire cache.48*49* flush_user_all()50*51* Clean and invalidate all user space cache entries52* before a change of page tables.53*54* flush_user_range(start, end, flags)55*56* Clean and invalidate a range of cache entries in the57* specified address space before a change of page tables.58* - start - user start address (inclusive, page aligned)59* - end - user end address (exclusive, page aligned)60* - flags - vma->vm_flags field61*62* coherent_kern_range(start, end)63*64* Ensure coherency between the Icache and the Dcache in the65* region described by start, end. If you have non-snooping66* Harvard caches, you need to implement this function.67* - start - virtual start address68* - end - virtual end address69*70* coherent_user_range(start, end)71*72* Ensure coherency between the Icache and the Dcache in the73* region described by start, end. If you have non-snooping74* Harvard caches, you need to implement this function.75* - start - virtual start address76* - end - virtual end address77*78* flush_kern_dcache_area(kaddr, size)79*80* Ensure that the data held in page is written back.81* - kaddr - page address82* - size - region size83*84* DMA Cache Coherency85* ===================86*87* dma_flush_range(start, end)88*89* Clean and invalidate the specified virtual address range.90* - start - virtual start address91* - end - virtual end address92*/9394extern void __cpuc_flush_icache_all(void);95extern void __cpuc_flush_kern_all(void);96extern void __cpuc_flush_user_all(void);97extern void __cpuc_flush_user_range(unsigned long, unsigned long, unsigned int);98extern void __cpuc_coherent_kern_range(unsigned long, unsigned long);99extern void __cpuc_coherent_user_range(unsigned long, unsigned long);100extern void __cpuc_flush_dcache_area(void *, size_t);101extern void __cpuc_flush_kern_dcache_area(void *addr, size_t size);102103/*104* These are private to the dma-mapping API. Do not use directly.105* Their sole purpose is to ensure that data held in the cache106* is visible to DMA, or data written by DMA to system memory is107* visible to the CPU.108*/109extern void __cpuc_dma_clean_range(unsigned long, unsigned long);110extern void __cpuc_dma_flush_range(unsigned long, unsigned long);111112/*113* Copy user data from/to a page which is mapped into a different114* processes address space. Really, we want to allow our "user115* space" model to handle this.116*/117extern void copy_to_user_page(struct vm_area_struct *, struct page *,118unsigned long, void *, const void *, unsigned long);119#define copy_from_user_page(vma, page, vaddr, dst, src, len) \120do { \121memcpy(dst, src, len); \122} while (0)123124/*125* Convert calls to our calling convention.126*/127/* Invalidate I-cache */128static inline void __flush_icache_all(void)129{130asm("movc p0.c5, %0, #20;\n"131"nop; nop; nop; nop; nop; nop; nop; nop\n"132:133: "r" (0));134}135136#define flush_cache_all() __cpuc_flush_kern_all()137138extern void flush_cache_mm(struct mm_struct *mm);139extern void flush_cache_range(struct vm_area_struct *vma,140unsigned long start, unsigned long end);141extern void flush_cache_page(struct vm_area_struct *vma,142unsigned long user_addr, unsigned long pfn);143144#define flush_cache_dup_mm(mm) flush_cache_mm(mm)145146/*147* flush_cache_user_range is used when we want to ensure that the148* Harvard caches are synchronised for the user space address range.149* This is used for the UniCore private sys_cacheflush system call.150*/151#define flush_cache_user_range(vma, start, end) \152__cpuc_coherent_user_range((start) & PAGE_MASK, PAGE_ALIGN(end))153154/*155* Perform necessary cache operations to ensure that data previously156* stored within this range of addresses can be executed by the CPU.157*/158#define flush_icache_range(s, e) __cpuc_coherent_kern_range(s, e)159160/*161* Perform necessary cache operations to ensure that the TLB will162* see data written in the specified area.163*/164#define clean_dcache_area(start, size) cpu_dcache_clean_area(start, size)165166/*167* flush_dcache_page is used when the kernel has written to the page168* cache page at virtual address page->virtual.169*170* If this page isn't mapped (ie, page_mapping == NULL), or it might171* have userspace mappings, then we _must_ always clean + invalidate172* the dcache entries associated with the kernel mapping.173*174* Otherwise we can defer the operation, and clean the cache when we are175* about to change to user space. This is the same method as used on SPARC64.176* See update_mmu_cache for the user space part.177*/178#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 1179extern void flush_dcache_page(struct page *);180181#define flush_dcache_mmap_lock(mapping) \182spin_lock_irq(&(mapping)->tree_lock)183#define flush_dcache_mmap_unlock(mapping) \184spin_unlock_irq(&(mapping)->tree_lock)185186#define flush_icache_user_range(vma, page, addr, len) \187flush_dcache_page(page)188189/*190* We don't appear to need to do anything here. In fact, if we did, we'd191* duplicate cache flushing elsewhere performed by flush_dcache_page().192*/193#define flush_icache_page(vma, page) do { } while (0)194195/*196* flush_cache_vmap() is used when creating mappings (eg, via vmap,197* vmalloc, ioremap etc) in kernel space for pages. On non-VIPT198* caches, since the direct-mappings of these pages may contain cached199* data, we need to do a full cache flush to ensure that writebacks200* don't corrupt data placed into these pages via the new mappings.201*/202static inline void flush_cache_vmap(unsigned long start, unsigned long end)203{204}205206static inline void flush_cache_vunmap(unsigned long start, unsigned long end)207{208}209210#endif211212213