cacheflush.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. * Blackfin low-level cache routines
  3. *
  4. * Copyright 2004-2009 Analog Devices Inc.
  5. *
  6. * Licensed under the GPL-2 or later.
  7. */
  8. #ifndef _BLACKFIN_CACHEFLUSH_H
  9. #define _BLACKFIN_CACHEFLUSH_H
  10. #include <asm/blackfin.h> /* for SSYNC() */
  11. extern void blackfin_icache_flush_range(unsigned long start_address, unsigned long end_address);
  12. extern void blackfin_dcache_flush_range(unsigned long start_address, unsigned long end_address);
  13. extern void blackfin_dcache_invalidate_range(unsigned long start_address, unsigned long end_address);
  14. extern void blackfin_dflush_page(void *page);
  15. extern void blackfin_invalidate_entire_dcache(void);
  16. extern void blackfin_invalidate_entire_icache(void);
  17. #define flush_dcache_mmap_lock(mapping) do { } while (0)
  18. #define flush_dcache_mmap_unlock(mapping) do { } while (0)
  19. #define flush_cache_mm(mm) do { } while (0)
  20. #define flush_cache_range(vma, start, end) do { } while (0)
  21. #define flush_cache_page(vma, vmaddr) do { } while (0)
  22. #define flush_cache_vmap(start, end) do { } while (0)
  23. #define flush_cache_vunmap(start, end) do { } while (0)
  24. #ifdef CONFIG_SMP
  25. #define flush_icache_range_others(start, end) \
  26. smp_icache_flush_range_others((start), (end))
  27. #else
  28. #define flush_icache_range_others(start, end) do { } while (0)
  29. #endif
  30. static inline void flush_icache_range(unsigned start, unsigned end)
  31. {
  32. #if defined(CONFIG_BFIN_EXTMEM_WRITEBACK) || defined(CONFIG_BFIN_L2_WRITEBACK)
  33. blackfin_dcache_flush_range(start, end);
  34. #endif
  35. /* Make sure all write buffers in the data side of the core
  36. * are flushed before trying to invalidate the icache. This
  37. * needs to be after the data flush and before the icache
  38. * flush so that the SSYNC does the right thing in preventing
  39. * the instruction prefetcher from hitting things in cached
  40. * memory at the wrong time -- it runs much further ahead than
  41. * the pipeline.
  42. */
  43. SSYNC();
  44. #if defined(CONFIG_BFIN_ICACHE)
  45. blackfin_icache_flush_range(start, end);
  46. flush_icache_range_others(start, end);
  47. #endif
  48. }
  49. #define copy_to_user_page(vma, page, vaddr, dst, src, len) \
  50. do { memcpy(dst, src, len); \
  51. flush_icache_range((unsigned) (dst), (unsigned) (dst) + (len)); \
  52. } while (0)
  53. #define copy_from_user_page(vma, page, vaddr, dst, src, len) memcpy(dst, src, len)
  54. #if defined(CONFIG_BFIN_DCACHE)
  55. # define invalidate_dcache_range(start,end) blackfin_dcache_invalidate_range((start), (end))
  56. #else
  57. # define invalidate_dcache_range(start,end) do { } while (0)
  58. #endif
  59. #if defined(CONFIG_BFIN_EXTMEM_WRITEBACK) || defined(CONFIG_BFIN_L2_WRITEBACK)
  60. # define flush_dcache_range(start,end) blackfin_dcache_flush_range((start), (end))
  61. # define flush_dcache_page(page) blackfin_dflush_page(page_address(page))
  62. #else
  63. # define flush_dcache_range(start,end) do { } while (0)
  64. # define flush_dcache_page(page) do { } while (0)
  65. #endif
  66. extern unsigned long reserved_mem_dcache_on;
  67. extern unsigned long reserved_mem_icache_on;
  68. static inline int bfin_addr_dcacheable(unsigned long addr)
  69. {
  70. #ifdef CONFIG_BFIN_EXTMEM_DCACHEABLE
  71. if (addr < (_ramend - DMA_UNCACHED_REGION))
  72. return 1;
  73. #endif
  74. if (reserved_mem_dcache_on &&
  75. addr >= _ramend && addr < physical_mem_end)
  76. return 1;
  77. #ifdef CONFIG_BFIN_L2_DCACHEABLE
  78. if (addr >= L2_START && addr < L2_START + L2_LENGTH)
  79. return 1;
  80. #endif
  81. return 0;
  82. }
  83. #endif /* _BLACKFIN_ICACHEFLUSH_H */