cache-v4wt.S 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  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 pc, lr
  119. /*
  120. * flush_kern_dcache_area(void *addr, size_t size)
  121. *
  122. * Ensure no D cache aliasing occurs, either with itself or
  123. * the I cache
  124. *
  125. * - addr - kernel address
  126. * - size - region size
  127. */
  128. ENTRY(v4wt_flush_kern_dcache_area)
  129. mov r2, #0
  130. mcr p15, 0, r2, c7, c5, 0 @ invalidate I cache
  131. add r1, r0, r1
  132. /* fallthrough */
  133. /*
  134. * dma_inv_range(start, end)
  135. *
  136. * Invalidate (discard) the specified virtual address range.
  137. * May not write back any entries. If 'start' or 'end'
  138. * are not cache line aligned, those lines must be written
  139. * back.
  140. *
  141. * - start - virtual start address
  142. * - end - virtual end address
  143. */
  144. v4wt_dma_inv_range:
  145. bic r0, r0, #CACHE_DLINESIZE - 1
  146. 1: mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
  147. add r0, r0, #CACHE_DLINESIZE
  148. cmp r0, r1
  149. blo 1b
  150. mov pc, lr
  151. /*
  152. * dma_flush_range(start, end)
  153. *
  154. * Clean and invalidate the specified virtual address range.
  155. *
  156. * - start - virtual start address
  157. * - end - virtual end address
  158. */
  159. .globl v4wt_dma_flush_range
  160. .equ v4wt_dma_flush_range, v4wt_dma_inv_range
  161. /*
  162. * dma_unmap_area(start, size, dir)
  163. * - start - kernel virtual start address
  164. * - size - size of region
  165. * - dir - DMA direction
  166. */
  167. ENTRY(v4wt_dma_unmap_area)
  168. add r1, r1, r0
  169. teq r2, #DMA_TO_DEVICE
  170. bne v4wt_dma_inv_range
  171. /* FALLTHROUGH */
  172. /*
  173. * dma_map_area(start, size, dir)
  174. * - start - kernel virtual start address
  175. * - size - size of region
  176. * - dir - DMA direction
  177. */
  178. ENTRY(v4wt_dma_map_area)
  179. mov pc, lr
  180. ENDPROC(v4wt_dma_unmap_area)
  181. ENDPROC(v4wt_dma_map_area)
  182. .globl v4wt_flush_kern_cache_louis
  183. .equ v4wt_flush_kern_cache_louis, v4wt_flush_kern_cache_all
  184. __INITDATA
  185. @ define struct cpu_cache_fns (see <asm/cacheflush.h> and proc-macros.S)
  186. define_cache_functions v4wt