cacheflush.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. * Copyright (C) 2007-2009 Michal Simek <monstr@monstr.eu>
  3. * Copyright (C) 2007-2009 PetaLogix
  4. * Copyright (C) 2007 John Williams <john.williams@petalogix.com>
  5. * based on v850 version which was
  6. * Copyright (C) 2001,02,03 NEC Electronics Corporation
  7. * Copyright (C) 2001,02,03 Miles Bader <miles@gnu.org>
  8. *
  9. * This file is subject to the terms and conditions of the GNU General
  10. * Public License. See the file COPYING in the main directory of this
  11. * archive for more details.
  12. *
  13. */
  14. #ifndef _ASM_MICROBLAZE_CACHEFLUSH_H
  15. #define _ASM_MICROBLAZE_CACHEFLUSH_H
  16. /* Somebody depends on this; sigh... */
  17. #include <linux/mm.h>
  18. /* Look at Documentation/cachetlb.txt */
  19. /*
  20. * Cache handling functions.
  21. * Microblaze has a write-through data cache, meaning that the data cache
  22. * never needs to be flushed. The only flushing operations that are
  23. * implemented are to invalidate the instruction cache. These are called
  24. * after loading a user application into memory, we must invalidate the
  25. * instruction cache to make sure we don't fetch old, bad code.
  26. */
  27. /* struct cache, d=dcache, i=icache, fl = flush, iv = invalidate,
  28. * suffix r = range */
  29. struct scache {
  30. /* icache */
  31. void (*ie)(void); /* enable */
  32. void (*id)(void); /* disable */
  33. void (*ifl)(void); /* flush */
  34. void (*iflr)(unsigned long a, unsigned long b);
  35. void (*iin)(void); /* invalidate */
  36. void (*iinr)(unsigned long a, unsigned long b);
  37. /* dcache */
  38. void (*de)(void); /* enable */
  39. void (*dd)(void); /* disable */
  40. void (*dfl)(void); /* flush */
  41. void (*dflr)(unsigned long a, unsigned long b);
  42. void (*din)(void); /* invalidate */
  43. void (*dinr)(unsigned long a, unsigned long b);
  44. };
  45. /* microblaze cache */
  46. extern struct scache *mbc;
  47. void microblaze_cache_init(void);
  48. #define enable_icache() mbc->ie();
  49. #define disable_icache() mbc->id();
  50. #define flush_icache() mbc->ifl();
  51. #define flush_icache_range(start, end) mbc->iflr(start, end);
  52. #define invalidate_icache() mbc->iin();
  53. #define invalidate_icache_range(start, end) mbc->iinr(start, end);
  54. #define flush_icache_user_range(vma, pg, adr, len) flush_icache();
  55. #define flush_icache_page(vma, pg) do { } while (0)
  56. #define enable_dcache() mbc->de();
  57. #define disable_dcache() mbc->dd();
  58. /* FIXME for LL-temac driver */
  59. #define invalidate_dcache() mbc->din();
  60. #define invalidate_dcache_range(start, end) mbc->dinr(start, end);
  61. #define flush_dcache() mbc->dfl();
  62. #define flush_dcache_range(start, end) mbc->dflr(start, end);
  63. #define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 0
  64. /* D-cache aliasing problem can't happen - cache is between MMU and ram */
  65. #define flush_dcache_page(page) do { } while (0)
  66. #define flush_dcache_mmap_lock(mapping) do { } while (0)
  67. #define flush_dcache_mmap_unlock(mapping) do { } while (0)
  68. #define flush_cache_dup_mm(mm) do { } while (0)
  69. #define flush_cache_vmap(start, end) do { } while (0)
  70. #define flush_cache_vunmap(start, end) do { } while (0)
  71. #define flush_cache_mm(mm) do { } while (0)
  72. #define flush_cache_page(vma, vmaddr, pfn) do { } while (0)
  73. /* MS: kgdb code use this macro, wrong len with FLASH */
  74. #if 0
  75. #define flush_cache_range(vma, start, len) { \
  76. flush_icache_range((unsigned) (start), (unsigned) (start) + (len)); \
  77. flush_dcache_range((unsigned) (start), (unsigned) (start) + (len)); \
  78. }
  79. #endif
  80. #define flush_cache_range(vma, start, len) do { } while (0)
  81. #define copy_to_user_page(vma, page, vaddr, dst, src, len) \
  82. do { \
  83. memcpy((dst), (src), (len)); \
  84. flush_icache_range((unsigned) (dst), (unsigned) (dst) + (len)); \
  85. } while (0)
  86. #define copy_from_user_page(vma, page, vaddr, dst, src, len) \
  87. do { \
  88. memcpy((dst), (src), (len)); \
  89. } while (0)
  90. #endif /* _ASM_MICROBLAZE_CACHEFLUSH_H */