cacheflush.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. #ifndef _PARISC_CACHEFLUSH_H
  2. #define _PARISC_CACHEFLUSH_H
  3. #include <linux/mm.h>
  4. #include <linux/uaccess.h>
  5. #include <asm/tlbflush.h>
  6. /* The usual comment is "Caches aren't brain-dead on the <architecture>".
  7. * Unfortunately, that doesn't apply to PA-RISC. */
  8. /* Internal implementation */
  9. void flush_data_cache_local(void *); /* flushes local data-cache only */
  10. void flush_instruction_cache_local(void *); /* flushes local code-cache only */
  11. #ifdef CONFIG_SMP
  12. void flush_data_cache(void); /* flushes data-cache only (all processors) */
  13. void flush_instruction_cache(void); /* flushes i-cache only (all processors) */
  14. #else
  15. #define flush_data_cache() flush_data_cache_local(NULL)
  16. #define flush_instruction_cache() flush_instruction_cache_local(NULL)
  17. #endif
  18. #define flush_cache_dup_mm(mm) flush_cache_mm(mm)
  19. void flush_user_icache_range_asm(unsigned long, unsigned long);
  20. void flush_kernel_icache_range_asm(unsigned long, unsigned long);
  21. void flush_user_dcache_range_asm(unsigned long, unsigned long);
  22. void flush_kernel_dcache_range_asm(unsigned long, unsigned long);
  23. void purge_kernel_dcache_range_asm(unsigned long, unsigned long);
  24. void flush_kernel_dcache_page_asm(void *);
  25. void flush_kernel_icache_page(void *);
  26. void flush_user_dcache_range(unsigned long, unsigned long);
  27. void flush_user_icache_range(unsigned long, unsigned long);
  28. /* Cache flush operations */
  29. void flush_cache_all_local(void);
  30. void flush_cache_all(void);
  31. void flush_cache_mm(struct mm_struct *mm);
  32. #define ARCH_HAS_FLUSH_KERNEL_DCACHE_PAGE
  33. void flush_kernel_dcache_page_addr(void *addr);
  34. static inline void flush_kernel_dcache_page(struct page *page)
  35. {
  36. flush_kernel_dcache_page_addr(page_address(page));
  37. }
  38. #define flush_kernel_dcache_range(start,size) \
  39. flush_kernel_dcache_range_asm((start), (start)+(size));
  40. void flush_kernel_vmap_range(void *vaddr, int size);
  41. void invalidate_kernel_vmap_range(void *vaddr, int size);
  42. #define flush_cache_vmap(start, end) flush_cache_all()
  43. #define flush_cache_vunmap(start, end) flush_cache_all()
  44. #define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 1
  45. extern void flush_dcache_page(struct page *page);
  46. #define flush_dcache_mmap_lock(mapping) \
  47. spin_lock_irq(&(mapping)->tree_lock)
  48. #define flush_dcache_mmap_unlock(mapping) \
  49. spin_unlock_irq(&(mapping)->tree_lock)
  50. #define flush_icache_page(vma,page) do { \
  51. flush_kernel_dcache_page(page); \
  52. flush_kernel_icache_page(page_address(page)); \
  53. } while (0)
  54. #define flush_icache_range(s,e) do { \
  55. flush_kernel_dcache_range_asm(s,e); \
  56. flush_kernel_icache_range_asm(s,e); \
  57. } while (0)
  58. #define copy_to_user_page(vma, page, vaddr, dst, src, len) \
  59. do { \
  60. flush_cache_page(vma, vaddr, page_to_pfn(page)); \
  61. memcpy(dst, src, len); \
  62. flush_kernel_dcache_range_asm((unsigned long)dst, (unsigned long)dst + len); \
  63. } while (0)
  64. #define copy_from_user_page(vma, page, vaddr, dst, src, len) \
  65. do { \
  66. flush_cache_page(vma, vaddr, page_to_pfn(page)); \
  67. memcpy(dst, src, len); \
  68. } while (0)
  69. void flush_cache_page(struct vm_area_struct *vma, unsigned long vmaddr, unsigned long pfn);
  70. void flush_cache_range(struct vm_area_struct *vma,
  71. unsigned long start, unsigned long end);
  72. /* defined in pacache.S exported in cache.c used by flush_anon_page */
  73. void flush_dcache_page_asm(unsigned long phys_addr, unsigned long vaddr);
  74. #define ARCH_HAS_FLUSH_ANON_PAGE
  75. static inline void
  76. flush_anon_page(struct vm_area_struct *vma, struct page *page, unsigned long vmaddr)
  77. {
  78. if (PageAnon(page)) {
  79. flush_tlb_page(vma, vmaddr);
  80. preempt_disable();
  81. flush_dcache_page_asm(page_to_phys(page), vmaddr);
  82. preempt_enable();
  83. }
  84. }
  85. #include <asm/kmap_types.h>
  86. #define ARCH_HAS_KMAP
  87. static inline void *kmap(struct page *page)
  88. {
  89. might_sleep();
  90. return page_address(page);
  91. }
  92. static inline void kunmap(struct page *page)
  93. {
  94. flush_kernel_dcache_page_addr(page_address(page));
  95. }
  96. static inline void *kmap_atomic(struct page *page)
  97. {
  98. preempt_disable();
  99. pagefault_disable();
  100. return page_address(page);
  101. }
  102. static inline void __kunmap_atomic(void *addr)
  103. {
  104. flush_kernel_dcache_page_addr(addr);
  105. pagefault_enable();
  106. preempt_enable();
  107. }
  108. #define kmap_atomic_prot(page, prot) kmap_atomic(page)
  109. #define kmap_atomic_pfn(pfn) kmap_atomic(pfn_to_page(pfn))
  110. #endif /* _PARISC_CACHEFLUSH_H */