blob: 2f1e1b05440a50cf1de278e03c7b698cf09851bb [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef _PARISC_CACHEFLUSH_H
2#define _PARISC_CACHEFLUSH_H
3
Linus Torvalds1da177e2005-04-16 15:20:36 -07004#include <linux/mm.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07005
6/* The usual comment is "Caches aren't brain-dead on the <architecture>".
7 * Unfortunately, that doesn't apply to PA-RISC. */
8
Randolph Chungd6ce8622006-12-12 05:51:54 -08009/* Internal implementation */
10void flush_data_cache_local(void *); /* flushes local data-cache only */
11void flush_instruction_cache_local(void *); /* flushes local code-cache only */
Linus Torvalds1da177e2005-04-16 15:20:36 -070012#ifdef CONFIG_SMP
Randolph Chungd6ce8622006-12-12 05:51:54 -080013void flush_data_cache(void); /* flushes data-cache only (all processors) */
14void flush_instruction_cache(void); /* flushes i-cache only (all processors) */
Linus Torvalds1da177e2005-04-16 15:20:36 -070015#else
Randolph Chungd6ce8622006-12-12 05:51:54 -080016#define flush_data_cache() flush_data_cache_local(NULL)
17#define flush_instruction_cache() flush_instruction_cache_local(NULL)
Linus Torvalds1da177e2005-04-16 15:20:36 -070018#endif
19
Ralf Baechleec8c0442006-12-12 17:14:57 +000020#define flush_cache_dup_mm(mm) flush_cache_mm(mm)
21
Randolph Chungd6ce8622006-12-12 05:51:54 -080022void flush_user_icache_range_asm(unsigned long, unsigned long);
23void flush_kernel_icache_range_asm(unsigned long, unsigned long);
24void flush_user_dcache_range_asm(unsigned long, unsigned long);
25void flush_kernel_dcache_range_asm(unsigned long, unsigned long);
26void flush_kernel_dcache_page_asm(void *);
27void flush_kernel_icache_page(void *);
28void flush_user_dcache_page(unsigned long);
29void flush_user_icache_page(unsigned long);
Matthew Wilcox37353132006-12-15 09:29:39 -070030void flush_user_dcache_range(unsigned long, unsigned long);
31void flush_user_icache_range(unsigned long, unsigned long);
Randolph Chungd6ce8622006-12-12 05:51:54 -080032
33/* Cache flush operations */
34
35void flush_cache_all_local(void);
36void flush_cache_all(void);
37void flush_cache_mm(struct mm_struct *mm);
38
Linus Torvalds1da177e2005-04-16 15:20:36 -070039#define flush_kernel_dcache_range(start,size) \
40 flush_kernel_dcache_range_asm((start), (start)+(size));
41
Linus Torvalds1da177e2005-04-16 15:20:36 -070042#define flush_cache_vmap(start, end) flush_cache_all()
43#define flush_cache_vunmap(start, end) flush_cache_all()
44
Linus Torvalds1da177e2005-04-16 15:20:36 -070045extern void flush_dcache_page(struct page *page);
46
47#define flush_dcache_mmap_lock(mapping) \
48 write_lock_irq(&(mapping)->tree_lock)
49#define flush_dcache_mmap_unlock(mapping) \
50 write_unlock_irq(&(mapping)->tree_lock)
51
Randolph Chungd6ce8622006-12-12 05:51:54 -080052#define flush_icache_page(vma,page) do { \
53 flush_kernel_dcache_page(page); \
54 flush_kernel_icache_page(page_address(page)); \
55} while (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070056
Randolph Chungd6ce8622006-12-12 05:51:54 -080057#define flush_icache_range(s,e) do { \
58 flush_kernel_dcache_range_asm(s,e); \
59 flush_kernel_icache_range_asm(s,e); \
60} while (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070061
62#define copy_to_user_page(vma, page, vaddr, dst, src, len) \
63do { \
64 flush_cache_page(vma, vaddr, page_to_pfn(page)); \
65 memcpy(dst, src, len); \
66 flush_kernel_dcache_range_asm((unsigned long)dst, (unsigned long)dst + len); \
67} while (0)
68
69#define copy_from_user_page(vma, page, vaddr, dst, src, len) \
70do { \
71 flush_cache_page(vma, vaddr, page_to_pfn(page)); \
72 memcpy(dst, src, len); \
73} while (0)
74
Randolph Chungd6ce8622006-12-12 05:51:54 -080075void flush_cache_page(struct vm_area_struct *vma, unsigned long vmaddr, unsigned long pfn);
76void flush_cache_range(struct vm_area_struct *vma,
77 unsigned long start, unsigned long end);
Linus Torvalds1da177e2005-04-16 15:20:36 -070078
Randolph Chungd6ce8622006-12-12 05:51:54 -080079#define ARCH_HAS_FLUSH_ANON_PAGE
James Bottomleyab432272006-03-22 08:28:59 -070080static inline void
Russell Kinga6f36be2006-12-30 22:24:19 +000081flush_anon_page(struct vm_area_struct *vma, struct page *page, unsigned long vmaddr)
James Bottomleyab432272006-03-22 08:28:59 -070082{
83 if (PageAnon(page))
84 flush_user_dcache_page(vmaddr);
85}
James Bottomleyab432272006-03-22 08:28:59 -070086
James Bottomleyba575832006-03-22 09:42:04 -070087#define ARCH_HAS_FLUSH_KERNEL_DCACHE_PAGE
James Bottomley20f4d3c2006-08-23 09:00:04 -070088void flush_kernel_dcache_page_addr(void *addr);
89static inline void flush_kernel_dcache_page(struct page *page)
90{
91 flush_kernel_dcache_page_addr(page_address(page));
92}
James Bottomleyba575832006-03-22 09:42:04 -070093
Helge Deller1bcdd852006-01-13 13:21:06 -070094#ifdef CONFIG_DEBUG_RODATA
95void mark_rodata_ro(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -070096#endif
Helge Deller1bcdd852006-01-13 13:21:06 -070097
James Bottomley20f4d3c2006-08-23 09:00:04 -070098#ifdef CONFIG_PA8X00
99/* Only pa8800, pa8900 needs this */
100#define ARCH_HAS_KMAP
101
102void kunmap_parisc(void *addr);
103
104static inline void *kmap(struct page *page)
105{
106 might_sleep();
107 return page_address(page);
108}
109
110#define kunmap(page) kunmap_parisc(page_address(page))
111
112#define kmap_atomic(page, idx) page_address(page)
113
114#define kunmap_atomic(addr, idx) kunmap_parisc(addr)
115
116#define kmap_atomic_pfn(pfn, idx) page_address(pfn_to_page(pfn))
117#define kmap_atomic_to_page(ptr) virt_to_page(ptr)
118#endif
119
Helge Deller1bcdd852006-01-13 13:21:06 -0700120#endif /* _PARISC_CACHEFLUSH_H */
121