swift.S 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. /*
  2. * swift.S: MicroSparc-II mmu/cache operations.
  3. *
  4. * Copyright (C) 1999 David S. Miller (davem@redhat.com)
  5. */
  6. #include <asm/psr.h>
  7. #include <asm/asi.h>
  8. #include <asm/page.h>
  9. #include <asm/pgtsrmmu.h>
  10. #include <asm/asm-offsets.h>
  11. .text
  12. .align 4
  13. #if 1 /* XXX screw this, I can't get the VAC flushes working
  14. * XXX reliably... -DaveM
  15. */
  16. .globl swift_flush_cache_all, swift_flush_cache_mm
  17. .globl swift_flush_cache_range, swift_flush_cache_page
  18. .globl swift_flush_page_for_dma
  19. .globl swift_flush_page_to_ram
  20. swift_flush_cache_all:
  21. swift_flush_cache_mm:
  22. swift_flush_cache_range:
  23. swift_flush_cache_page:
  24. swift_flush_page_for_dma:
  25. swift_flush_page_to_ram:
  26. sethi %hi(0x2000), %o0
  27. 1: subcc %o0, 0x10, %o0
  28. add %o0, %o0, %o1
  29. sta %g0, [%o0] ASI_M_DATAC_TAG
  30. bne 1b
  31. sta %g0, [%o1] ASI_M_TXTC_TAG
  32. retl
  33. nop
  34. #else
  35. .globl swift_flush_cache_all
  36. swift_flush_cache_all:
  37. WINDOW_FLUSH(%g4, %g5)
  38. /* Just clear out all the tags. */
  39. sethi %hi(16 * 1024), %o0
  40. 1: subcc %o0, 16, %o0
  41. sta %g0, [%o0] ASI_M_TXTC_TAG
  42. bne 1b
  43. sta %g0, [%o0] ASI_M_DATAC_TAG
  44. retl
  45. nop
  46. .globl swift_flush_cache_mm
  47. swift_flush_cache_mm:
  48. ld [%o0 + AOFF_mm_context], %g2
  49. cmp %g2, -1
  50. be swift_flush_cache_mm_out
  51. WINDOW_FLUSH(%g4, %g5)
  52. rd %psr, %g1
  53. andn %g1, PSR_ET, %g3
  54. wr %g3, 0x0, %psr
  55. nop
  56. nop
  57. mov SRMMU_CTX_REG, %g7
  58. lda [%g7] ASI_M_MMUREGS, %g5
  59. sta %g2, [%g7] ASI_M_MMUREGS
  60. #if 1
  61. sethi %hi(0x2000), %o0
  62. 1: subcc %o0, 0x10, %o0
  63. sta %g0, [%o0] ASI_M_FLUSH_CTX
  64. bne 1b
  65. nop
  66. #else
  67. clr %o0
  68. or %g0, 2048, %g7
  69. or %g0, 2048, %o1
  70. add %o1, 2048, %o2
  71. add %o2, 2048, %o3
  72. mov 16, %o4
  73. add %o4, 2048, %o5
  74. add %o5, 2048, %g2
  75. add %g2, 2048, %g3
  76. 1: sta %g0, [%o0 ] ASI_M_FLUSH_CTX
  77. sta %g0, [%o0 + %o1] ASI_M_FLUSH_CTX
  78. sta %g0, [%o0 + %o2] ASI_M_FLUSH_CTX
  79. sta %g0, [%o0 + %o3] ASI_M_FLUSH_CTX
  80. sta %g0, [%o0 + %o4] ASI_M_FLUSH_CTX
  81. sta %g0, [%o0 + %o5] ASI_M_FLUSH_CTX
  82. sta %g0, [%o0 + %g2] ASI_M_FLUSH_CTX
  83. sta %g0, [%o0 + %g3] ASI_M_FLUSH_CTX
  84. subcc %g7, 32, %g7
  85. bne 1b
  86. add %o0, 32, %o0
  87. #endif
  88. mov SRMMU_CTX_REG, %g7
  89. sta %g5, [%g7] ASI_M_MMUREGS
  90. wr %g1, 0x0, %psr
  91. nop
  92. nop
  93. swift_flush_cache_mm_out:
  94. retl
  95. nop
  96. .globl swift_flush_cache_range
  97. swift_flush_cache_range:
  98. ld [%o0 + VMA_VM_MM], %o0
  99. sub %o2, %o1, %o2
  100. sethi %hi(4096), %o3
  101. cmp %o2, %o3
  102. bgu swift_flush_cache_mm
  103. nop
  104. b 70f
  105. nop
  106. .globl swift_flush_cache_page
  107. swift_flush_cache_page:
  108. ld [%o0 + VMA_VM_MM], %o0
  109. 70:
  110. ld [%o0 + AOFF_mm_context], %g2
  111. cmp %g2, -1
  112. be swift_flush_cache_page_out
  113. WINDOW_FLUSH(%g4, %g5)
  114. rd %psr, %g1
  115. andn %g1, PSR_ET, %g3
  116. wr %g3, 0x0, %psr
  117. nop
  118. nop
  119. mov SRMMU_CTX_REG, %g7
  120. lda [%g7] ASI_M_MMUREGS, %g5
  121. sta %g2, [%g7] ASI_M_MMUREGS
  122. andn %o1, (PAGE_SIZE - 1), %o1
  123. #if 1
  124. sethi %hi(0x1000), %o0
  125. 1: subcc %o0, 0x10, %o0
  126. sta %g0, [%o1 + %o0] ASI_M_FLUSH_PAGE
  127. bne 1b
  128. nop
  129. #else
  130. or %g0, 512, %g7
  131. or %g0, 512, %o0
  132. add %o0, 512, %o2
  133. add %o2, 512, %o3
  134. add %o3, 512, %o4
  135. add %o4, 512, %o5
  136. add %o5, 512, %g3
  137. add %g3, 512, %g4
  138. 1: sta %g0, [%o1 ] ASI_M_FLUSH_PAGE
  139. sta %g0, [%o1 + %o0] ASI_M_FLUSH_PAGE
  140. sta %g0, [%o1 + %o2] ASI_M_FLUSH_PAGE
  141. sta %g0, [%o1 + %o3] ASI_M_FLUSH_PAGE
  142. sta %g0, [%o1 + %o4] ASI_M_FLUSH_PAGE
  143. sta %g0, [%o1 + %o5] ASI_M_FLUSH_PAGE
  144. sta %g0, [%o1 + %g3] ASI_M_FLUSH_PAGE
  145. sta %g0, [%o1 + %g4] ASI_M_FLUSH_PAGE
  146. subcc %g7, 16, %g7
  147. bne 1b
  148. add %o1, 16, %o1
  149. #endif
  150. mov SRMMU_CTX_REG, %g7
  151. sta %g5, [%g7] ASI_M_MMUREGS
  152. wr %g1, 0x0, %psr
  153. nop
  154. nop
  155. swift_flush_cache_page_out:
  156. retl
  157. nop
  158. /* Swift is write-thru, however it is not
  159. * I/O nor TLB-walk coherent. Also it has
  160. * caches which are virtually indexed and tagged.
  161. */
  162. .globl swift_flush_page_for_dma
  163. .globl swift_flush_page_to_ram
  164. swift_flush_page_for_dma:
  165. swift_flush_page_to_ram:
  166. andn %o0, (PAGE_SIZE - 1), %o1
  167. #if 1
  168. sethi %hi(0x1000), %o0
  169. 1: subcc %o0, 0x10, %o0
  170. sta %g0, [%o1 + %o0] ASI_M_FLUSH_PAGE
  171. bne 1b
  172. nop
  173. #else
  174. or %g0, 512, %g7
  175. or %g0, 512, %o0
  176. add %o0, 512, %o2
  177. add %o2, 512, %o3
  178. add %o3, 512, %o4
  179. add %o4, 512, %o5
  180. add %o5, 512, %g3
  181. add %g3, 512, %g4
  182. 1: sta %g0, [%o1 ] ASI_M_FLUSH_PAGE
  183. sta %g0, [%o1 + %o0] ASI_M_FLUSH_PAGE
  184. sta %g0, [%o1 + %o2] ASI_M_FLUSH_PAGE
  185. sta %g0, [%o1 + %o3] ASI_M_FLUSH_PAGE
  186. sta %g0, [%o1 + %o4] ASI_M_FLUSH_PAGE
  187. sta %g0, [%o1 + %o5] ASI_M_FLUSH_PAGE
  188. sta %g0, [%o1 + %g3] ASI_M_FLUSH_PAGE
  189. sta %g0, [%o1 + %g4] ASI_M_FLUSH_PAGE
  190. subcc %g7, 16, %g7
  191. bne 1b
  192. add %o1, 16, %o1
  193. #endif
  194. retl
  195. nop
  196. #endif
  197. .globl swift_flush_sig_insns
  198. swift_flush_sig_insns:
  199. flush %o1
  200. retl
  201. flush %o1 + 4
  202. .globl swift_flush_tlb_mm
  203. .globl swift_flush_tlb_range
  204. .globl swift_flush_tlb_all
  205. swift_flush_tlb_range:
  206. ld [%o0 + VMA_VM_MM], %o0
  207. swift_flush_tlb_mm:
  208. ld [%o0 + AOFF_mm_context], %g2
  209. cmp %g2, -1
  210. be swift_flush_tlb_all_out
  211. swift_flush_tlb_all:
  212. mov 0x400, %o1
  213. sta %g0, [%o1] ASI_M_FLUSH_PROBE
  214. swift_flush_tlb_all_out:
  215. retl
  216. nop
  217. .globl swift_flush_tlb_page
  218. swift_flush_tlb_page:
  219. ld [%o0 + VMA_VM_MM], %o0
  220. mov SRMMU_CTX_REG, %g1
  221. ld [%o0 + AOFF_mm_context], %o3
  222. andn %o1, (PAGE_SIZE - 1), %o1
  223. cmp %o3, -1
  224. be swift_flush_tlb_page_out
  225. nop
  226. #if 1
  227. mov 0x400, %o1
  228. sta %g0, [%o1] ASI_M_FLUSH_PROBE
  229. #else
  230. lda [%g1] ASI_M_MMUREGS, %g5
  231. sta %o3, [%g1] ASI_M_MMUREGS
  232. sta %g0, [%o1] ASI_M_FLUSH_PAGE /* rem. virt. cache. prot. */
  233. sta %g0, [%o1] ASI_M_FLUSH_PROBE
  234. sta %g5, [%g1] ASI_M_MMUREGS
  235. #endif
  236. swift_flush_tlb_page_out:
  237. retl
  238. nop