cacheflush.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*
  2. * File: include/asm-blackfin/cacheflush.h
  3. * Based on: include/asm-m68knommu/cacheflush.h
  4. * Author: LG Soft India
  5. * Copyright (C) 2004 Analog Devices Inc.
  6. * Created: Tue Sep 21 2004
  7. * Description: Blackfin low-level cache routines adapted from the i386
  8. * and PPC versions by Greg Ungerer (gerg@snapgear.com)
  9. *
  10. * Modified:
  11. *
  12. * Bugs: Enter bugs at http://blackfin.uclinux.org/
  13. *
  14. * This program is free software; you can redistribute it and/or modify
  15. * it under the terms of the GNU General Public License as published by
  16. * the Free Software Foundation; either version 2, or (at your option)
  17. * any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU General Public License
  25. * along with this program; see the file COPYING.
  26. * If not, write to the Free Software Foundation,
  27. * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  28. */
  29. #ifndef _BLACKFIN_CACHEFLUSH_H
  30. #define _BLACKFIN_CACHEFLUSH_H
  31. extern void blackfin_icache_dcache_flush_range(unsigned long start_address, unsigned long end_address);
  32. extern void blackfin_icache_flush_range(unsigned long start_address, unsigned long end_address);
  33. extern void blackfin_dcache_flush_range(unsigned long start_address, unsigned long end_address);
  34. extern void blackfin_dcache_invalidate_range(unsigned long start_address, unsigned long end_address);
  35. extern void blackfin_dflush_page(void *page);
  36. extern void blackfin_invalidate_entire_dcache(void);
  37. #define flush_dcache_mmap_lock(mapping) do { } while (0)
  38. #define flush_dcache_mmap_unlock(mapping) do { } while (0)
  39. #define flush_cache_mm(mm) do { } while (0)
  40. #define flush_cache_range(vma, start, end) do { } while (0)
  41. #define flush_cache_page(vma, vmaddr) do { } while (0)
  42. #define flush_cache_vmap(start, end) do { } while (0)
  43. #define flush_cache_vunmap(start, end) do { } while (0)
  44. #ifdef CONFIG_SMP
  45. #define flush_icache_range_others(start, end) \
  46. smp_icache_flush_range_others((start), (end))
  47. #else
  48. #define flush_icache_range_others(start, end) do { } while (0)
  49. #endif
  50. static inline void flush_icache_range(unsigned start, unsigned end)
  51. {
  52. #if defined(CONFIG_BFIN_DCACHE) && defined(CONFIG_BFIN_ICACHE)
  53. # if defined(CONFIG_BFIN_WT)
  54. blackfin_icache_flush_range((start), (end));
  55. flush_icache_range_others(start, end);
  56. # else
  57. blackfin_icache_dcache_flush_range((start), (end));
  58. # endif
  59. #else
  60. # if defined(CONFIG_BFIN_ICACHE)
  61. blackfin_icache_flush_range((start), (end));
  62. flush_icache_range_others(start, end);
  63. # endif
  64. # if defined(CONFIG_BFIN_DCACHE)
  65. blackfin_dcache_flush_range((start), (end));
  66. # endif
  67. #endif
  68. }
  69. #define copy_to_user_page(vma, page, vaddr, dst, src, len) \
  70. do { memcpy(dst, src, len); \
  71. flush_icache_range((unsigned) (dst), (unsigned) (dst) + (len)); \
  72. flush_icache_range_others((unsigned long) (dst), (unsigned long) (dst) + (len));\
  73. } while (0)
  74. #define copy_from_user_page(vma, page, vaddr, dst, src, len) memcpy(dst, src, len)
  75. #if defined(CONFIG_BFIN_DCACHE)
  76. # define invalidate_dcache_range(start,end) blackfin_dcache_invalidate_range((start), (end))
  77. #else
  78. # define invalidate_dcache_range(start,end) do { } while (0)
  79. #endif
  80. #if defined(CONFIG_BFIN_DCACHE) && defined(CONFIG_BFIN_WB)
  81. # define flush_dcache_range(start,end) blackfin_dcache_flush_range((start), (end))
  82. # define flush_dcache_page(page) blackfin_dflush_page(page_address(page))
  83. #else
  84. # define flush_dcache_range(start,end) do { } while (0)
  85. # define flush_dcache_page(page) do { } while (0)
  86. #endif
  87. extern unsigned long reserved_mem_dcache_on;
  88. extern unsigned long reserved_mem_icache_on;
  89. static inline int bfin_addr_dcachable(unsigned long addr)
  90. {
  91. #ifdef CONFIG_BFIN_DCACHE
  92. if (addr < (_ramend - DMA_UNCACHED_REGION))
  93. return 1;
  94. #endif
  95. if (reserved_mem_dcache_on &&
  96. addr >= _ramend && addr < physical_mem_end)
  97. return 1;
  98. return 0;
  99. }
  100. #endif /* _BLACKFIN_ICACHEFLUSH_H */