cache-v4wt.S 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. /*
  2. * linux/arch/arm/mm/cache-v4wt.S
  3. *
  4. * Copyright (C) 1997-2002 Russell king
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. *
  10. * ARMv4 write through cache operations support.
  11. *
  12. * We assume that the write buffer is not enabled.
  13. */
  14. #include <linux/linkage.h>
  15. #include <linux/init.h>
  16. #include <asm/page.h>
  17. #include "proc-macros.S"
  18. /*
  19. * The size of one data cache line.
  20. */
  21. #define CACHE_DLINESIZE 32
  22. /*
  23. * The number of data cache segments.
  24. */
  25. #define CACHE_DSEGMENTS 8
  26. /*
  27. * The number of lines in a cache segment.
  28. */
  29. #define CACHE_DENTRIES 64
  30. /*
  31. * This is the size at which it becomes more efficient to
  32. * clean the whole cache, rather than using the individual
  33. * cache line maintenance instructions.
  34. *
  35. * *** This needs benchmarking
  36. */
  37. #define CACHE_DLIMIT 16384
  38. /*
  39. * flush_icache_all()
  40. *
  41. * Unconditionally clean and invalidate the entire icache.
  42. */
  43. ENTRY(v4wt_flush_icache_all)
  44. mov r0, #0
  45. mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache
  46. mov pc, lr
  47. ENDPROC(v4wt_flush_icache_all)
  48. /*
  49. * flush_user_cache_all()
  50. *
  51. * Invalidate all cache entries in a particular address
  52. * space.
  53. */
  54. ENTRY(v4wt_flush_user_cache_all)
  55. /* FALLTHROUGH */
  56. /*
  57. * flush_kern_cache_all()
  58. *
  59. * Clean and invalidate the entire cache.
  60. */
  61. ENTRY(v4wt_flush_kern_cache_all)
  62. mov r2, #VM_EXEC
  63. mov ip, #0
  64. __flush_whole_cache:
  65. tst r2, #VM_EXEC
  66. mcrne p15, 0, ip, c7, c5, 0 @ invalidate I cache
  67. mcr p15, 0, ip, c7, c6, 0 @ invalidate D cache
  68. mov pc, lr
  69. /*
  70. * flush_user_cache_range(start, end, flags)
  71. *
  72. * Clean and invalidate a range of cache entries in the specified
  73. * address space.
  74. *
  75. * - start - start address (inclusive, page aligned)
  76. * - end - end address (exclusive, page aligned)
  77. * - flags - vma_area_struct flags describing address space
  78. */
  79. ENTRY(v4wt_flush_user_cache_range)
  80. sub r3, r1, r0 @ calculate total size
  81. cmp r3, #CACHE_DLIMIT
  82. bhs __flush_whole_cache
  83. 1: mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
  84. tst r2, #VM_EXEC
  85. mcrne p15, 0, r0, c7, c5, 1 @ invalidate I entry
  86. add r0, r0, #CACHE_DLINESIZE
  87. cmp r0, r1
  88. blo 1b
  89. mov pc, lr
  90. /*
  91. * coherent_kern_range(start, end)
  92. *
  93. * Ensure coherency between the Icache and the Dcache in the
  94. * region described by start. If you have non-snooping
  95. * Harvard caches, you need to implement this function.
  96. *
  97. * - start - virtual start address
  98. * - end - virtual end address
  99. */
  100. ENTRY(v4wt_coherent_kern_range)
  101. /* FALLTRHOUGH */
  102. /*
  103. * coherent_user_range(start, end)
  104. *
  105. * Ensure coherency between the Icache and the Dcache in the
  106. * region described by start. If you have non-snooping
  107. * Harvard caches, you need to implement this function.
  108. *
  109. * - start - virtual start address
  110. * - end - virtual end address
  111. */
  112. ENTRY(v4wt_coherent_user_range)
  113. bic r0, r0, #CACHE_DLINESIZE - 1
  114. 1: mcr p15, 0, r0, c7, c5, 1 @ invalidate I entry
  115. add r0, r0, #CACHE_DLINESIZE
  116. cmp r0, r1
  117. blo 1b
  118. mov r0, #0
  119. mov pc, lr
  120. /*
  121. * flush_kern_dcache_area(void *addr, size_t size)
  122. *
  123. * Ensure no D cache aliasing occurs, either with itself or
  124. * the I cache
  125. *
  126. * - addr - kernel address
  127. * - size - region size
  128. */
  129. ENTRY(v4wt_flush_kern_dcache_area)
  130. mov r2, #0
  131. mcr p15, 0, r2, c7, c5, 0 @ invalidate I cache
  132. add r1, r0, r1
  133. /* fallthrough */
  134. /*
  135. * dma_inv_range(start, end)
  136. *
  137. * Invalidate (discard) the specified virtual address range.
  138. * May not write back any entries. If 'start' or 'end'
  139. * are not cache line aligned, those lines must be written
  140. * back.
  141. *
  142. * - start - virtual start address
  143. * - end - virtual end address
  144. */
  145. v4wt_dma_inv_range:
  146. bic r0, r0, #CACHE_DLINESIZE - 1
  147. 1: mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
  148. add r0, r0, #CACHE_DLINESIZE
  149. cmp r0, r1
  150. blo 1b
  151. mov pc, lr
  152. /*
  153. * dma_flush_range(start, end)
  154. *
  155. * Clean and invalidate the specified virtual address range.
  156. *
  157. * - start - virtual start address
  158. * - end - virtual end address
  159. */
  160. .globl v4wt_dma_flush_range
  161. .equ v4wt_dma_flush_range, v4wt_dma_inv_range
  162. /*
  163. * dma_unmap_area(start, size, dir)
  164. * - start - kernel virtual start address
  165. * - size - size of region
  166. * - dir - DMA direction
  167. */
  168. ENTRY(v4wt_dma_unmap_area)
  169. add r1, r1, r0
  170. teq r2, #DMA_TO_DEVICE
  171. bne v4wt_dma_inv_range
  172. /* FALLTHROUGH */
  173. /*
  174. * dma_map_area(start, size, dir)
  175. * - start - kernel virtual start address
  176. * - size - size of region
  177. * - dir - DMA direction
  178. */
  179. ENTRY(v4wt_dma_map_area)
  180. mov pc, lr
  181. ENDPROC(v4wt_dma_unmap_area)
  182. ENDPROC(v4wt_dma_map_area)
  183. __INITDATA
  184. @ define struct cpu_cache_fns (see <asm/cacheflush.h> and proc-macros.S)
  185. define_cache_functions v4wt