cache-v6.S 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. /*
  2. * linux/arch/arm/mm/cache-v6.S
  3. *
  4. * Copyright (C) 2001 Deep Blue Solutions Ltd.
  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. * This is the "shell" of the ARMv6 processor support.
  11. */
  12. #include <linux/linkage.h>
  13. #include <linux/init.h>
  14. #include <asm/assembler.h>
  15. #include "proc-macros.S"
  16. #define HARVARD_CACHE
  17. #define CACHE_LINE_SIZE 32
  18. #define D_CACHE_LINE_SIZE 32
  19. /*
  20. * v6_flush_cache_all()
  21. *
  22. * Flush the entire cache.
  23. *
  24. * It is assumed that:
  25. */
  26. ENTRY(v6_flush_kern_cache_all)
  27. mov r0, #0
  28. #ifdef HARVARD_CACHE
  29. mcr p15, 0, r0, c7, c14, 0 @ D cache clean+invalidate
  30. mcr p15, 0, r0, c7, c5, 0 @ I+BTB cache invalidate
  31. #else
  32. mcr p15, 0, r0, c7, c15, 0 @ Cache clean+invalidate
  33. #endif
  34. mov pc, lr
  35. /*
  36. * v6_flush_cache_all()
  37. *
  38. * Flush all TLB entries in a particular address space
  39. *
  40. * - mm - mm_struct describing address space
  41. */
  42. ENTRY(v6_flush_user_cache_all)
  43. /*FALLTHROUGH*/
  44. /*
  45. * v6_flush_cache_range(start, end, flags)
  46. *
  47. * Flush a range of TLB entries in the specified address space.
  48. *
  49. * - start - start address (may not be aligned)
  50. * - end - end address (exclusive, may not be aligned)
  51. * - flags - vm_area_struct flags describing address space
  52. *
  53. * It is assumed that:
  54. * - we have a VIPT cache.
  55. */
  56. ENTRY(v6_flush_user_cache_range)
  57. mov pc, lr
  58. /*
  59. * v6_coherent_kern_range(start,end)
  60. *
  61. * Ensure that the I and D caches are coherent within specified
  62. * region. This is typically used when code has been written to
  63. * a memory region, and will be executed.
  64. *
  65. * - start - virtual start address of region
  66. * - end - virtual end address of region
  67. *
  68. * It is assumed that:
  69. * - the Icache does not read data from the write buffer
  70. */
  71. ENTRY(v6_coherent_kern_range)
  72. /* FALLTHROUGH */
  73. /*
  74. * v6_coherent_user_range(start,end)
  75. *
  76. * Ensure that the I and D caches are coherent within specified
  77. * region. This is typically used when code has been written to
  78. * a memory region, and will be executed.
  79. *
  80. * - start - virtual start address of region
  81. * - end - virtual end address of region
  82. *
  83. * It is assumed that:
  84. * - the Icache does not read data from the write buffer
  85. */
  86. ENTRY(v6_coherent_user_range)
  87. bic r0, r0, #CACHE_LINE_SIZE - 1
  88. 1:
  89. #ifdef HARVARD_CACHE
  90. mcr p15, 0, r0, c7, c10, 1 @ clean D line
  91. mcr p15, 0, r0, c7, c5, 1 @ invalidate I line
  92. #endif
  93. mcr p15, 0, r0, c7, c5, 7 @ invalidate BTB entry
  94. add r0, r0, #CACHE_LINE_SIZE
  95. cmp r0, r1
  96. blo 1b
  97. #ifdef HARVARD_CACHE
  98. mov r0, #0
  99. mcr p15, 0, r0, c7, c10, 4 @ drain write buffer
  100. #endif
  101. mov pc, lr
  102. /*
  103. * v6_flush_kern_dcache_page(kaddr)
  104. *
  105. * Ensure that the data held in the page kaddr is written back
  106. * to the page in question.
  107. *
  108. * - kaddr - kernel address (guaranteed to be page aligned)
  109. */
  110. ENTRY(v6_flush_kern_dcache_page)
  111. add r1, r0, #PAGE_SZ
  112. 1:
  113. #ifdef HARVARD_CACHE
  114. mcr p15, 0, r0, c7, c14, 1 @ clean & invalidate D line
  115. #else
  116. mcr p15, 0, r0, c7, c15, 1 @ clean & invalidate unified line
  117. #endif
  118. add r0, r0, #D_CACHE_LINE_SIZE
  119. cmp r0, r1
  120. blo 1b
  121. #ifdef HARVARD_CACHE
  122. mov r0, #0
  123. mcr p15, 0, r0, c7, c10, 4
  124. #endif
  125. mov pc, lr
  126. /*
  127. * v6_dma_inv_range(start,end)
  128. *
  129. * Invalidate the data cache within the specified region; we will
  130. * be performing a DMA operation in this region and we want to
  131. * purge old data in the cache.
  132. *
  133. * - start - virtual start address of region
  134. * - end - virtual end address of region
  135. */
  136. ENTRY(v6_dma_inv_range)
  137. tst r0, #D_CACHE_LINE_SIZE - 1
  138. bic r0, r0, #D_CACHE_LINE_SIZE - 1
  139. #ifdef HARVARD_CACHE
  140. mcrne p15, 0, r0, c7, c10, 1 @ clean D line
  141. #else
  142. mcrne p15, 0, r0, c7, c11, 1 @ clean unified line
  143. #endif
  144. tst r1, #D_CACHE_LINE_SIZE - 1
  145. bic r1, r1, #D_CACHE_LINE_SIZE - 1
  146. #ifdef HARVARD_CACHE
  147. mcrne p15, 0, r1, c7, c14, 1 @ clean & invalidate D line
  148. #else
  149. mcrne p15, 0, r1, c7, c15, 1 @ clean & invalidate unified line
  150. #endif
  151. 1:
  152. #ifdef HARVARD_CACHE
  153. mcr p15, 0, r0, c7, c6, 1 @ invalidate D line
  154. #else
  155. mcr p15, 0, r0, c7, c7, 1 @ invalidate unified line
  156. #endif
  157. add r0, r0, #D_CACHE_LINE_SIZE
  158. cmp r0, r1
  159. blo 1b
  160. mov r0, #0
  161. mcr p15, 0, r0, c7, c10, 4 @ drain write buffer
  162. mov pc, lr
  163. /*
  164. * v6_dma_clean_range(start,end)
  165. * - start - virtual start address of region
  166. * - end - virtual end address of region
  167. */
  168. ENTRY(v6_dma_clean_range)
  169. bic r0, r0, #D_CACHE_LINE_SIZE - 1
  170. 1:
  171. #ifdef HARVARD_CACHE
  172. mcr p15, 0, r0, c7, c10, 1 @ clean D line
  173. #else
  174. mcr p15, 0, r0, c7, c11, 1 @ clean unified line
  175. #endif
  176. add r0, r0, #D_CACHE_LINE_SIZE
  177. cmp r0, r1
  178. blo 1b
  179. mov r0, #0
  180. mcr p15, 0, r0, c7, c10, 4 @ drain write buffer
  181. mov pc, lr
  182. /*
  183. * v6_dma_flush_range(start,end)
  184. * - start - virtual start address of region
  185. * - end - virtual end address of region
  186. */
  187. ENTRY(v6_dma_flush_range)
  188. bic r0, r0, #D_CACHE_LINE_SIZE - 1
  189. 1:
  190. #ifdef HARVARD_CACHE
  191. mcr p15, 0, r0, c7, c14, 1 @ clean & invalidate D line
  192. #else
  193. mcr p15, 0, r0, c7, c15, 1 @ clean & invalidate line
  194. #endif
  195. add r0, r0, #D_CACHE_LINE_SIZE
  196. cmp r0, r1
  197. blo 1b
  198. mov r0, #0
  199. mcr p15, 0, r0, c7, c10, 4 @ drain write buffer
  200. mov pc, lr
  201. __INITDATA
  202. .type v6_cache_fns, #object
  203. ENTRY(v6_cache_fns)
  204. .long v6_flush_kern_cache_all
  205. .long v6_flush_user_cache_all
  206. .long v6_flush_user_cache_range
  207. .long v6_coherent_kern_range
  208. .long v6_coherent_user_range
  209. .long v6_flush_kern_dcache_page
  210. .long v6_dma_inv_range
  211. .long v6_dma_clean_range
  212. .long v6_dma_flush_range
  213. .size v6_cache_fns, . - v6_cache_fns