cache-v4wt.S 4.7 KB

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