cache-v6.S 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  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. #define BTB_FLUSH_SIZE 8
  20. /*
  21. * v6_flush_cache_all()
  22. *
  23. * Flush the entire cache.
  24. *
  25. * It is assumed that:
  26. */
  27. ENTRY(v6_flush_kern_cache_all)
  28. mov r0, #0
  29. #ifdef HARVARD_CACHE
  30. mcr p15, 0, r0, c7, c14, 0 @ D cache clean+invalidate
  31. mcr p15, 0, r0, c7, c5, 0 @ I+BTB cache invalidate
  32. #else
  33. mcr p15, 0, r0, c7, c15, 0 @ Cache clean+invalidate
  34. #endif
  35. mov pc, lr
  36. /*
  37. * v6_flush_cache_all()
  38. *
  39. * Flush all TLB entries in a particular address space
  40. *
  41. * - mm - mm_struct describing address space
  42. */
  43. ENTRY(v6_flush_user_cache_all)
  44. /*FALLTHROUGH*/
  45. /*
  46. * v6_flush_cache_range(start, end, flags)
  47. *
  48. * Flush a range of TLB entries in the specified address space.
  49. *
  50. * - start - start address (may not be aligned)
  51. * - end - end address (exclusive, may not be aligned)
  52. * - flags - vm_area_struct flags describing address space
  53. *
  54. * It is assumed that:
  55. * - we have a VIPT cache.
  56. */
  57. ENTRY(v6_flush_user_cache_range)
  58. mov pc, lr
  59. /*
  60. * v6_coherent_kern_range(start,end)
  61. *
  62. * Ensure that the I and D caches are coherent within specified
  63. * region. This is typically used when code has been written to
  64. * a memory region, and will be executed.
  65. *
  66. * - start - virtual start address of region
  67. * - end - virtual end address of region
  68. *
  69. * It is assumed that:
  70. * - the Icache does not read data from the write buffer
  71. */
  72. ENTRY(v6_coherent_kern_range)
  73. /* FALLTHROUGH */
  74. /*
  75. * v6_coherent_user_range(start,end)
  76. *
  77. * Ensure that the I and D caches are coherent within specified
  78. * region. This is typically used when code has been written to
  79. * a memory region, and will be executed.
  80. *
  81. * - start - virtual start address of region
  82. * - end - virtual end address of region
  83. *
  84. * It is assumed that:
  85. * - the Icache does not read data from the write buffer
  86. */
  87. ENTRY(v6_coherent_user_range)
  88. #ifdef HARVARD_CACHE
  89. bic r0, r0, #CACHE_LINE_SIZE - 1
  90. 1: mcr p15, 0, r0, c7, c10, 1 @ clean D line
  91. mcr p15, 0, r0, c7, c5, 1 @ invalidate I line
  92. add r0, r0, #CACHE_LINE_SIZE
  93. cmp r0, r1
  94. blo 1b
  95. #endif
  96. mcr p15, 0, r0, c7, c5, 6 @ invalidate BTB
  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