Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef _PARISC_CACHEFLUSH_H |
| 2 | #define _PARISC_CACHEFLUSH_H |
| 3 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | #include <linux/mm.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 | |
| 6 | /* The usual comment is "Caches aren't brain-dead on the <architecture>". |
| 7 | * Unfortunately, that doesn't apply to PA-RISC. */ |
| 8 | |
Randolph Chung | d6ce862 | 2006-12-12 05:51:54 -0800 | [diff] [blame] | 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 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | #ifdef CONFIG_SMP |
Randolph Chung | d6ce862 | 2006-12-12 05:51:54 -0800 | [diff] [blame] | 13 | void flush_data_cache(void); /* flushes data-cache only (all processors) */ |
| 14 | void flush_instruction_cache(void); /* flushes i-cache only (all processors) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | #else |
Randolph Chung | d6ce862 | 2006-12-12 05:51:54 -0800 | [diff] [blame] | 16 | #define flush_data_cache() flush_data_cache_local(NULL) |
| 17 | #define flush_instruction_cache() flush_instruction_cache_local(NULL) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | #endif |
| 19 | |
Ralf Baechle | ec8c044 | 2006-12-12 17:14:57 +0000 | [diff] [blame] | 20 | #define flush_cache_dup_mm(mm) flush_cache_mm(mm) |
| 21 | |
Randolph Chung | d6ce862 | 2006-12-12 05:51:54 -0800 | [diff] [blame] | 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); |
Matthew Wilcox | 3735313 | 2006-12-15 09:29:39 -0700 | [diff] [blame] | 30 | void flush_user_dcache_range(unsigned long, unsigned long); |
| 31 | void flush_user_icache_range(unsigned long, unsigned long); |
Randolph Chung | d6ce862 | 2006-12-12 05:51:54 -0800 | [diff] [blame] | 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 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | #define flush_kernel_dcache_range(start,size) \ |
| 40 | flush_kernel_dcache_range_asm((start), (start)+(size)); |
| 41 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | #define flush_cache_vmap(start, end) flush_cache_all() |
| 43 | #define flush_cache_vunmap(start, end) flush_cache_all() |
| 44 | |
Ilya Loginov | 2d4dc89 | 2009-11-26 09:16:19 +0100 | [diff] [blame^] | 45 | #define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 1 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | extern void flush_dcache_page(struct page *page); |
| 47 | |
| 48 | #define flush_dcache_mmap_lock(mapping) \ |
Nick Piggin | 19fd623 | 2008-07-25 19:45:32 -0700 | [diff] [blame] | 49 | spin_lock_irq(&(mapping)->tree_lock) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | #define flush_dcache_mmap_unlock(mapping) \ |
Nick Piggin | 19fd623 | 2008-07-25 19:45:32 -0700 | [diff] [blame] | 51 | spin_unlock_irq(&(mapping)->tree_lock) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | |
Randolph Chung | d6ce862 | 2006-12-12 05:51:54 -0800 | [diff] [blame] | 53 | #define flush_icache_page(vma,page) do { \ |
| 54 | flush_kernel_dcache_page(page); \ |
| 55 | flush_kernel_icache_page(page_address(page)); \ |
| 56 | } while (0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | |
Randolph Chung | d6ce862 | 2006-12-12 05:51:54 -0800 | [diff] [blame] | 58 | #define flush_icache_range(s,e) do { \ |
| 59 | flush_kernel_dcache_range_asm(s,e); \ |
| 60 | flush_kernel_icache_range_asm(s,e); \ |
| 61 | } while (0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | |
| 63 | #define copy_to_user_page(vma, page, vaddr, dst, src, len) \ |
| 64 | do { \ |
| 65 | flush_cache_page(vma, vaddr, page_to_pfn(page)); \ |
| 66 | memcpy(dst, src, len); \ |
| 67 | flush_kernel_dcache_range_asm((unsigned long)dst, (unsigned long)dst + len); \ |
| 68 | } while (0) |
| 69 | |
| 70 | #define copy_from_user_page(vma, page, vaddr, dst, src, len) \ |
| 71 | do { \ |
| 72 | flush_cache_page(vma, vaddr, page_to_pfn(page)); \ |
| 73 | memcpy(dst, src, len); \ |
| 74 | } while (0) |
| 75 | |
Randolph Chung | d6ce862 | 2006-12-12 05:51:54 -0800 | [diff] [blame] | 76 | void flush_cache_page(struct vm_area_struct *vma, unsigned long vmaddr, unsigned long pfn); |
| 77 | void flush_cache_range(struct vm_area_struct *vma, |
| 78 | unsigned long start, unsigned long end); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | |
Randolph Chung | d6ce862 | 2006-12-12 05:51:54 -0800 | [diff] [blame] | 80 | #define ARCH_HAS_FLUSH_ANON_PAGE |
James Bottomley | ab43227 | 2006-03-22 08:28:59 -0700 | [diff] [blame] | 81 | static inline void |
Russell King | a6f36be | 2006-12-30 22:24:19 +0000 | [diff] [blame] | 82 | flush_anon_page(struct vm_area_struct *vma, struct page *page, unsigned long vmaddr) |
James Bottomley | ab43227 | 2006-03-22 08:28:59 -0700 | [diff] [blame] | 83 | { |
| 84 | if (PageAnon(page)) |
| 85 | flush_user_dcache_page(vmaddr); |
| 86 | } |
James Bottomley | ab43227 | 2006-03-22 08:28:59 -0700 | [diff] [blame] | 87 | |
James Bottomley | ba57583 | 2006-03-22 09:42:04 -0700 | [diff] [blame] | 88 | #define ARCH_HAS_FLUSH_KERNEL_DCACHE_PAGE |
James Bottomley | 20f4d3c | 2006-08-23 09:00:04 -0700 | [diff] [blame] | 89 | void flush_kernel_dcache_page_addr(void *addr); |
| 90 | static inline void flush_kernel_dcache_page(struct page *page) |
| 91 | { |
| 92 | flush_kernel_dcache_page_addr(page_address(page)); |
| 93 | } |
James Bottomley | ba57583 | 2006-03-22 09:42:04 -0700 | [diff] [blame] | 94 | |
Helge Deller | 1bcdd85 | 2006-01-13 13:21:06 -0700 | [diff] [blame] | 95 | #ifdef CONFIG_DEBUG_RODATA |
| 96 | void mark_rodata_ro(void); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | #endif |
Helge Deller | 1bcdd85 | 2006-01-13 13:21:06 -0700 | [diff] [blame] | 98 | |
James Bottomley | 20f4d3c | 2006-08-23 09:00:04 -0700 | [diff] [blame] | 99 | #ifdef CONFIG_PA8X00 |
| 100 | /* Only pa8800, pa8900 needs this */ |
Kyle McMartin | bb73501 | 2009-04-02 02:40:41 +0000 | [diff] [blame] | 101 | |
| 102 | #include <asm/kmap_types.h> |
| 103 | |
James Bottomley | 20f4d3c | 2006-08-23 09:00:04 -0700 | [diff] [blame] | 104 | #define ARCH_HAS_KMAP |
| 105 | |
| 106 | void kunmap_parisc(void *addr); |
| 107 | |
| 108 | static inline void *kmap(struct page *page) |
| 109 | { |
| 110 | might_sleep(); |
| 111 | return page_address(page); |
| 112 | } |
| 113 | |
| 114 | #define kunmap(page) kunmap_parisc(page_address(page)) |
| 115 | |
| 116 | #define kmap_atomic(page, idx) page_address(page) |
| 117 | |
| 118 | #define kunmap_atomic(addr, idx) kunmap_parisc(addr) |
| 119 | |
| 120 | #define kmap_atomic_pfn(pfn, idx) page_address(pfn_to_page(pfn)) |
| 121 | #define kmap_atomic_to_page(ptr) virt_to_page(ptr) |
| 122 | #endif |
| 123 | |
Helge Deller | 1bcdd85 | 2006-01-13 13:21:06 -0700 | [diff] [blame] | 124 | #endif /* _PARISC_CACHEFLUSH_H */ |
| 125 | |