cacheflush.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. /*
  19. * Cache handling functions.
  20. * Microblaze has a write-through data cache, meaning that the data cache
  21. * never needs to be flushed. The only flushing operations that are
  22. * implemented are to invalidate the instruction cache. These are called
  23. * after loading a user application into memory, we must invalidate the
  24. * instruction cache to make sure we don't fetch old, bad code.
  25. */
  26. /* FIXME for LL-temac driver */
  27. #define invalidate_dcache_range(start, end) \
  28. __invalidate_dcache_range(start, end)
  29. #define flush_cache_all() __invalidate_cache_all()
  30. #define flush_cache_mm(mm) do { } while (0)
  31. #define flush_cache_range(vma, start, end) __invalidate_cache_all()
  32. #define flush_cache_page(vma, vmaddr, pfn) do { } while (0)
  33. #define flush_dcache_range(start, end) __invalidate_dcache_range(start, end)
  34. #define flush_dcache_page(page) do { } while (0)
  35. #define flush_dcache_mmap_lock(mapping) do { } while (0)
  36. #define flush_dcache_mmap_unlock(mapping) do { } while (0)
  37. #define flush_icache_range(start, len) __invalidate_icache_range(start, len)
  38. #define flush_icache_page(vma, pg) do { } while (0)
  39. #ifndef CONFIG_MMU
  40. # define flush_icache_user_range(start, len) do { } while (0)
  41. #else
  42. # define flush_icache_user_range(vma, pg, adr, len) __invalidate_icache_all()
  43. # define flush_page_to_ram(page) do { } while (0)
  44. # define flush_icache() __invalidate_icache_all()
  45. # define flush_cache_sigtramp(vaddr) \
  46. __invalidate_icache_range(vaddr, vaddr + 8)
  47. # define flush_dcache_mmap_lock(mapping) do { } while (0)
  48. # define flush_dcache_mmap_unlock(mapping) do { } while (0)
  49. # define flush_cache_dup_mm(mm) do { } while (0)
  50. #endif
  51. #define flush_cache_vmap(start, end) do { } while (0)
  52. #define flush_cache_vunmap(start, end) do { } while (0)
  53. struct page;
  54. struct mm_struct;
  55. struct vm_area_struct;
  56. /* see arch/microblaze/kernel/cache.c */
  57. extern void __invalidate_icache_all(void);
  58. extern void __invalidate_icache_range(unsigned long start, unsigned long end);
  59. extern void __invalidate_icache_page(struct vm_area_struct *vma,
  60. struct page *page);
  61. extern void __invalidate_icache_user_range(struct vm_area_struct *vma,
  62. struct page *page,
  63. unsigned long adr, int len);
  64. extern void __invalidate_cache_sigtramp(unsigned long addr);
  65. extern void __invalidate_dcache_all(void);
  66. extern void __invalidate_dcache_range(unsigned long start, unsigned long end);
  67. extern void __invalidate_dcache_page(struct vm_area_struct *vma,
  68. struct page *page);
  69. extern void __invalidate_dcache_user_range(struct vm_area_struct *vma,
  70. struct page *page,
  71. unsigned long adr, int len);
  72. extern inline void __invalidate_cache_all(void)
  73. {
  74. __invalidate_icache_all();
  75. __invalidate_dcache_all();
  76. }
  77. #define copy_to_user_page(vma, page, vaddr, dst, src, len) \
  78. do { memcpy((dst), (src), (len)); \
  79. flush_icache_range((unsigned) (dst), (unsigned) (dst) + (len)); \
  80. } while (0)
  81. #define copy_from_user_page(vma, page, vaddr, dst, src, len) \
  82. memcpy((dst), (src), (len))
  83. #endif /* _ASM_MICROBLAZE_CACHEFLUSH_H */