cacheflush.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /* cacheflush.h: FRV cache flushing routines
  2. *
  3. * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
  4. * Written by David Howells (dhowells@redhat.com)
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version
  9. * 2 of the License, or (at your option) any later version.
  10. */
  11. #ifndef _ASM_CACHEFLUSH_H
  12. #define _ASM_CACHEFLUSH_H
  13. /* Keep includes the same across arches. */
  14. #include <linux/mm.h>
  15. /*
  16. * virtually-indexed cache management (our cache is physically indexed)
  17. */
  18. #define flush_cache_all() do {} while(0)
  19. #define flush_cache_mm(mm) do {} while(0)
  20. #define flush_cache_dup_mm(mm) do {} while(0)
  21. #define flush_cache_range(mm, start, end) do {} while(0)
  22. #define flush_cache_page(vma, vmaddr, pfn) do {} while(0)
  23. #define flush_cache_vmap(start, end) do {} while(0)
  24. #define flush_cache_vunmap(start, end) do {} while(0)
  25. #define flush_dcache_mmap_lock(mapping) do {} while(0)
  26. #define flush_dcache_mmap_unlock(mapping) do {} while(0)
  27. /*
  28. * physically-indexed cache management
  29. * - see arch/frv/lib/cache.S
  30. */
  31. extern void frv_dcache_writeback(unsigned long start, unsigned long size);
  32. extern void frv_cache_invalidate(unsigned long start, unsigned long size);
  33. extern void frv_icache_invalidate(unsigned long start, unsigned long size);
  34. extern void frv_cache_wback_inv(unsigned long start, unsigned long size);
  35. static inline void __flush_cache_all(void)
  36. {
  37. asm volatile(" dcef @(gr0,gr0),#1 \n"
  38. " icei @(gr0,gr0),#1 \n"
  39. " membar \n"
  40. : : : "memory"
  41. );
  42. }
  43. /* dcache/icache coherency... */
  44. #define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 1
  45. #ifdef CONFIG_MMU
  46. extern void flush_dcache_page(struct page *page);
  47. #else
  48. static inline void flush_dcache_page(struct page *page)
  49. {
  50. unsigned long addr = page_to_phys(page);
  51. frv_dcache_writeback(addr, addr + PAGE_SIZE);
  52. }
  53. #endif
  54. static inline void flush_page_to_ram(struct page *page)
  55. {
  56. flush_dcache_page(page);
  57. }
  58. static inline void flush_icache(void)
  59. {
  60. __flush_cache_all();
  61. }
  62. static inline void flush_icache_range(unsigned long start, unsigned long end)
  63. {
  64. frv_cache_wback_inv(start, end);
  65. }
  66. #ifdef CONFIG_MMU
  67. extern void flush_icache_user_range(struct vm_area_struct *vma, struct page *page,
  68. unsigned long start, unsigned long len);
  69. #else
  70. static inline void flush_icache_user_range(struct vm_area_struct *vma, struct page *page,
  71. unsigned long start, unsigned long len)
  72. {
  73. frv_cache_wback_inv(start, start + len);
  74. }
  75. #endif
  76. static inline void flush_icache_page(struct vm_area_struct *vma, struct page *page)
  77. {
  78. flush_icache_user_range(vma, page, page_to_phys(page), PAGE_SIZE);
  79. }
  80. /*
  81. * permit ptrace to access another process's address space through the icache
  82. * and the dcache
  83. */
  84. #define copy_to_user_page(vma, page, vaddr, dst, src, len) \
  85. do { \
  86. memcpy((dst), (src), (len)); \
  87. flush_icache_user_range((vma), (page), (vaddr), (len)); \
  88. } while(0)
  89. #define copy_from_user_page(vma, page, vaddr, dst, src, len) \
  90. memcpy((dst), (src), (len))
  91. #endif /* _ASM_CACHEFLUSH_H */