blob: f388a85bba113c7c6f050202e494ad0d71731a43 [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>
John David Anglin210501a2010-04-11 16:36:14 +00005#include <linux/uaccess.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07006
7/* The usual comment is "Caches aren't brain-dead on the <architecture>".
8 * Unfortunately, that doesn't apply to PA-RISC. */
9
Randolph Chungd6ce8622006-12-12 05:51:54 -080010/* Internal implementation */
11void flush_data_cache_local(void *); /* flushes local data-cache only */
12void flush_instruction_cache_local(void *); /* flushes local code-cache only */
Linus Torvalds1da177e2005-04-16 15:20:36 -070013#ifdef CONFIG_SMP
Randolph Chungd6ce8622006-12-12 05:51:54 -080014void flush_data_cache(void); /* flushes data-cache only (all processors) */
15void flush_instruction_cache(void); /* flushes i-cache only (all processors) */
Linus Torvalds1da177e2005-04-16 15:20:36 -070016#else
Randolph Chungd6ce8622006-12-12 05:51:54 -080017#define flush_data_cache() flush_data_cache_local(NULL)
18#define flush_instruction_cache() flush_instruction_cache_local(NULL)
Linus Torvalds1da177e2005-04-16 15:20:36 -070019#endif
20
Ralf Baechleec8c0442006-12-12 17:14:57 +000021#define flush_cache_dup_mm(mm) flush_cache_mm(mm)
22
Randolph Chungd6ce8622006-12-12 05:51:54 -080023void flush_user_icache_range_asm(unsigned long, unsigned long);
24void flush_kernel_icache_range_asm(unsigned long, unsigned long);
25void flush_user_dcache_range_asm(unsigned long, unsigned long);
26void flush_kernel_dcache_range_asm(unsigned long, unsigned long);
27void flush_kernel_dcache_page_asm(void *);
28void flush_kernel_icache_page(void *);
29void flush_user_dcache_page(unsigned long);
30void flush_user_icache_page(unsigned long);
Matthew Wilcox37353132006-12-15 09:29:39 -070031void flush_user_dcache_range(unsigned long, unsigned long);
32void flush_user_icache_range(unsigned long, unsigned long);
Randolph Chungd6ce8622006-12-12 05:51:54 -080033
34/* Cache flush operations */
35
36void flush_cache_all_local(void);
37void flush_cache_all(void);
38void flush_cache_mm(struct mm_struct *mm);
39
Linus Torvalds1da177e2005-04-16 15:20:36 -070040#define flush_kernel_dcache_range(start,size) \
41 flush_kernel_dcache_range_asm((start), (start)+(size));
James Bottomleyef7cc352010-01-25 11:42:21 -060042/* vmap range flushes and invalidates. Architecturally, we don't need
43 * the invalidate, because the CPU should refuse to speculate once an
44 * area has been flushed, so invalidate is left empty */
45static inline void flush_kernel_vmap_range(void *vaddr, int size)
46{
47 unsigned long start = (unsigned long)vaddr;
48
49 flush_kernel_dcache_range_asm(start, start + size);
50}
51static inline void invalidate_kernel_vmap_range(void *vaddr, int size)
52{
53}
Linus Torvalds1da177e2005-04-16 15:20:36 -070054
Linus Torvalds1da177e2005-04-16 15:20:36 -070055#define flush_cache_vmap(start, end) flush_cache_all()
56#define flush_cache_vunmap(start, end) flush_cache_all()
57
Ilya Loginov2d4dc892009-11-26 09:16:19 +010058#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 1
Linus Torvalds1da177e2005-04-16 15:20:36 -070059extern void flush_dcache_page(struct page *page);
60
61#define flush_dcache_mmap_lock(mapping) \
Nick Piggin19fd6232008-07-25 19:45:32 -070062 spin_lock_irq(&(mapping)->tree_lock)
Linus Torvalds1da177e2005-04-16 15:20:36 -070063#define flush_dcache_mmap_unlock(mapping) \
Nick Piggin19fd6232008-07-25 19:45:32 -070064 spin_unlock_irq(&(mapping)->tree_lock)
Linus Torvalds1da177e2005-04-16 15:20:36 -070065
Randolph Chungd6ce8622006-12-12 05:51:54 -080066#define flush_icache_page(vma,page) do { \
67 flush_kernel_dcache_page(page); \
68 flush_kernel_icache_page(page_address(page)); \
69} while (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070070
Randolph Chungd6ce8622006-12-12 05:51:54 -080071#define flush_icache_range(s,e) do { \
72 flush_kernel_dcache_range_asm(s,e); \
73 flush_kernel_icache_range_asm(s,e); \
74} while (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070075
76#define copy_to_user_page(vma, page, vaddr, dst, src, len) \
77do { \
78 flush_cache_page(vma, vaddr, page_to_pfn(page)); \
79 memcpy(dst, src, len); \
80 flush_kernel_dcache_range_asm((unsigned long)dst, (unsigned long)dst + len); \
81} while (0)
82
83#define copy_from_user_page(vma, page, vaddr, dst, src, len) \
84do { \
85 flush_cache_page(vma, vaddr, page_to_pfn(page)); \
86 memcpy(dst, src, len); \
87} while (0)
88
Randolph Chungd6ce8622006-12-12 05:51:54 -080089void flush_cache_page(struct vm_area_struct *vma, unsigned long vmaddr, unsigned long pfn);
90void flush_cache_range(struct vm_area_struct *vma,
91 unsigned long start, unsigned long end);
Linus Torvalds1da177e2005-04-16 15:20:36 -070092
Randolph Chungd6ce8622006-12-12 05:51:54 -080093#define ARCH_HAS_FLUSH_ANON_PAGE
James Bottomleyab432272006-03-22 08:28:59 -070094static inline void
Russell Kinga6f36be2006-12-30 22:24:19 +000095flush_anon_page(struct vm_area_struct *vma, struct page *page, unsigned long vmaddr)
James Bottomleyab432272006-03-22 08:28:59 -070096{
97 if (PageAnon(page))
98 flush_user_dcache_page(vmaddr);
99}
James Bottomleyab432272006-03-22 08:28:59 -0700100
James Bottomleyba575832006-03-22 09:42:04 -0700101#define ARCH_HAS_FLUSH_KERNEL_DCACHE_PAGE
James Bottomley20f4d3c2006-08-23 09:00:04 -0700102void flush_kernel_dcache_page_addr(void *addr);
103static inline void flush_kernel_dcache_page(struct page *page)
104{
105 flush_kernel_dcache_page_addr(page_address(page));
106}
James Bottomleyba575832006-03-22 09:42:04 -0700107
Helge Deller1bcdd852006-01-13 13:21:06 -0700108#ifdef CONFIG_DEBUG_RODATA
109void mark_rodata_ro(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110#endif
Helge Deller1bcdd852006-01-13 13:21:06 -0700111
James Bottomley20f4d3c2006-08-23 09:00:04 -0700112#ifdef CONFIG_PA8X00
113/* Only pa8800, pa8900 needs this */
Kyle McMartinbb735012009-04-02 02:40:41 +0000114
115#include <asm/kmap_types.h>
116
James Bottomley20f4d3c2006-08-23 09:00:04 -0700117#define ARCH_HAS_KMAP
118
119void kunmap_parisc(void *addr);
120
121static inline void *kmap(struct page *page)
122{
123 might_sleep();
124 return page_address(page);
125}
126
127#define kunmap(page) kunmap_parisc(page_address(page))
128
James Bottomley765aaaf2010-10-28 10:14:41 -0500129static inline void *__kmap_atomic(struct page *page)
John David Anglin210501a2010-04-11 16:36:14 +0000130{
131 pagefault_disable();
132 return page_address(page);
133}
James Bottomley20f4d3c2006-08-23 09:00:04 -0700134
James Bottomley765aaaf2010-10-28 10:14:41 -0500135static inline void __kunmap_atomic(void *addr)
John David Anglin210501a2010-04-11 16:36:14 +0000136{
137 kunmap_parisc(addr);
138 pagefault_enable();
139}
James Bottomley20f4d3c2006-08-23 09:00:04 -0700140
James Bottomley765aaaf2010-10-28 10:14:41 -0500141#define kmap_atomic_prot(page, prot) kmap_atomic(page)
142#define kmap_atomic_pfn(pfn) kmap_atomic(pfn_to_page(pfn))
James Bottomley20f4d3c2006-08-23 09:00:04 -0700143#define kmap_atomic_to_page(ptr) virt_to_page(ptr)
144#endif
145
Helge Deller1bcdd852006-01-13 13:21:06 -0700146#endif /* _PARISC_CACHEFLUSH_H */
147