1 #ifndef _PARISC_CACHEFLUSH_H 2 #define _PARISC_CACHEFLUSH_H 3 4 #include <linux/mm.h> 5 6 /* The usual comment is "Caches aren't brain-dead on the <architecture>". 7 * Unfortunately, that doesn't apply to PA-RISC. */ 8 9 /* Internal implementation */ 10 void flush_data_cache_local(void *); /* flushes local data-cache only */ 11 void flush_instruction_cache_local(void *); /* flushes local code-cache only */ 12 #ifdef CONFIG_SMP 13 void flush_data_cache(void); /* flushes data-cache only (all processors) */ 14 void flush_instruction_cache(void); /* flushes i-cache only (all processors) */ 15 #else 16 #define flush_data_cache() flush_data_cache_local(NULL) 17 #define flush_instruction_cache() flush_instruction_cache_local(NULL) 18 #endif 19 20 #define flush_cache_dup_mm(mm) flush_cache_mm(mm) 21 22 void flush_user_icache_range_asm(unsigned long, unsigned long); 23 void flush_kernel_icache_range_asm(unsigned long, unsigned long); 24 void flush_user_dcache_range_asm(unsigned long, unsigned long); 25 void flush_kernel_dcache_range_asm(unsigned long, unsigned long); 26 void flush_kernel_dcache_page_asm(void *); 27 void flush_kernel_icache_page(void *); 28 void flush_user_dcache_page(unsigned long); 29 void flush_user_icache_page(unsigned long); 30 void flush_user_dcache_range(unsigned long, unsigned long); 31 void flush_user_icache_range(unsigned long, unsigned long); 32 33 /* Cache flush operations */ 34 35 void flush_cache_all_local(void); 36 void flush_cache_all(void); 37 void flush_cache_mm(struct mm_struct *mm); 38 39 #define flush_kernel_dcache_range(start,size) \ 40 flush_kernel_dcache_range_asm((start), (start)+(size)); 41 /* vmap range flushes and invalidates. Architecturally, we don't need 42 * the invalidate, because the CPU should refuse to speculate once an 43 * area has been flushed, so invalidate is left empty */ 44 static inline void flush_kernel_vmap_range(void *vaddr, int size) 45 { 46 unsigned long start = (unsigned long)vaddr; 47 48 flush_kernel_dcache_range_asm(start, start + size); 49 } 50 static inline void invalidate_kernel_vmap_range(void *vaddr, int size) 51 { 52 } 53 54 #define flush_cache_vmap(start, end) flush_cache_all() 55 #define flush_cache_vunmap(start, end) flush_cache_all() 56 57 #define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 1 58 extern void flush_dcache_page(struct page *page); 59 60 #define flush_dcache_mmap_lock(mapping) \ 61 spin_lock_irq(&(mapping)->tree_lock) 62 #define flush_dcache_mmap_unlock(mapping) \ 63 spin_unlock_irq(&(mapping)->tree_lock) 64 65 #define flush_icache_page(vma,page) do { \ 66 flush_kernel_dcache_page(page); \ 67 flush_kernel_icache_page(page_address(page)); \ 68 } while (0) 69 70 #define flush_icache_range(s,e) do { \ 71 flush_kernel_dcache_range_asm(s,e); \ 72 flush_kernel_icache_range_asm(s,e); \ 73 } while (0) 74 75 #define copy_to_user_page(vma, page, vaddr, dst, src, len) \ 76 do { \ 77 flush_cache_page(vma, vaddr, page_to_pfn(page)); \ 78 memcpy(dst, src, len); \ 79 flush_kernel_dcache_range_asm((unsigned long)dst, (unsigned long)dst + len); \ 80 } while (0) 81 82 #define copy_from_user_page(vma, page, vaddr, dst, src, len) \ 83 do { \ 84 flush_cache_page(vma, vaddr, page_to_pfn(page)); \ 85 memcpy(dst, src, len); \ 86 } while (0) 87 88 void flush_cache_page(struct vm_area_struct *vma, unsigned long vmaddr, unsigned long pfn); 89 void flush_cache_range(struct vm_area_struct *vma, 90 unsigned long start, unsigned long end); 91 92 #define ARCH_HAS_FLUSH_ANON_PAGE 93 static inline void 94 flush_anon_page(struct vm_area_struct *vma, struct page *page, unsigned long vmaddr) 95 { 96 if (PageAnon(page)) 97 flush_user_dcache_page(vmaddr); 98 } 99 100 #define ARCH_HAS_FLUSH_KERNEL_DCACHE_PAGE 101 void flush_kernel_dcache_page_addr(void *addr); 102 static inline void flush_kernel_dcache_page(struct page *page) 103 { 104 flush_kernel_dcache_page_addr(page_address(page)); 105 } 106 107 #ifdef CONFIG_DEBUG_RODATA 108 void mark_rodata_ro(void); 109 #endif 110 111 #ifdef CONFIG_PA8X00 112 /* Only pa8800, pa8900 needs this */ 113 114 #include <asm/kmap_types.h> 115 116 #define ARCH_HAS_KMAP 117 118 void kunmap_parisc(void *addr); 119 120 static inline void *kmap(struct page *page) 121 { 122 might_sleep(); 123 return page_address(page); 124 } 125 126 #define kunmap(page) kunmap_parisc(page_address(page)) 127 128 #define kmap_atomic(page, idx) page_address(page) 129 130 #define kunmap_atomic(addr, idx) kunmap_parisc(addr) 131 132 #define kmap_atomic_pfn(pfn, idx) page_address(pfn_to_page(pfn)) 133 #define kmap_atomic_to_page(ptr) virt_to_page(ptr) 134 #endif 135 136 #endif /* _PARISC_CACHEFLUSH_H */ 137 138