viking.S 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. /*
  2. * viking.S: High speed Viking cache/mmu operations
  3. *
  4. * Copyright (C) 1997 Eddie C. Dost (ecd@skynet.be)
  5. * Copyright (C) 1997,1998,1999 Jakub Jelinek (jj@ultra.linux.cz)
  6. * Copyright (C) 1999 Pavel Semerad (semerad@ss1000.ms.mff.cuni.cz)
  7. */
  8. #include <asm/ptrace.h>
  9. #include <asm/psr.h>
  10. #include <asm/asm-offsets.h>
  11. #include <asm/asi.h>
  12. #include <asm/mxcc.h>
  13. #include <asm/page.h>
  14. #include <asm/pgtsrmmu.h>
  15. #include <asm/viking.h>
  16. #ifdef CONFIG_SMP
  17. .data
  18. .align 4
  19. sun4dsmp_flush_tlb_spin:
  20. .word 0
  21. #endif
  22. .text
  23. .align 4
  24. .globl viking_flush_cache_all, viking_flush_cache_mm
  25. .globl viking_flush_cache_range, viking_flush_cache_page
  26. .globl viking_flush_page, viking_mxcc_flush_page
  27. .globl viking_flush_page_for_dma, viking_flush_page_to_ram
  28. .globl viking_flush_sig_insns
  29. .globl viking_flush_tlb_all, viking_flush_tlb_mm
  30. .globl viking_flush_tlb_range, viking_flush_tlb_page
  31. viking_flush_page:
  32. sethi %hi(PAGE_OFFSET), %g2
  33. sub %o0, %g2, %g3
  34. srl %g3, 12, %g1 ! ppage >> 12
  35. clr %o1 ! set counter, 0 - 127
  36. sethi %hi(PAGE_OFFSET + PAGE_SIZE - 0x80000000), %o3
  37. sethi %hi(0x80000000), %o4
  38. sethi %hi(VIKING_PTAG_VALID), %o5
  39. sethi %hi(2*PAGE_SIZE), %o0
  40. sethi %hi(PAGE_SIZE), %g7
  41. clr %o2 ! block counter, 0 - 3
  42. 5:
  43. sll %o1, 5, %g4
  44. or %g4, %o4, %g4 ! 0x80000000 | (set << 5)
  45. sll %o2, 26, %g5 ! block << 26
  46. 6:
  47. or %g5, %g4, %g5
  48. ldda [%g5] ASI_M_DATAC_TAG, %g2
  49. cmp %g3, %g1 ! ptag == ppage?
  50. bne 7f
  51. inc %o2
  52. andcc %g2, %o5, %g0 ! ptag VALID?
  53. be 7f
  54. add %g4, %o3, %g2 ! (PAGE_OFFSET + PAGE_SIZE) | (set << 5)
  55. ld [%g2], %g3
  56. ld [%g2 + %g7], %g3
  57. add %g2, %o0, %g2
  58. ld [%g2], %g3
  59. ld [%g2 + %g7], %g3
  60. add %g2, %o0, %g2
  61. ld [%g2], %g3
  62. ld [%g2 + %g7], %g3
  63. add %g2, %o0, %g2
  64. ld [%g2], %g3
  65. b 8f
  66. ld [%g2 + %g7], %g3
  67. 7:
  68. cmp %o2, 3
  69. ble 6b
  70. sll %o2, 26, %g5 ! block << 26
  71. 8: inc %o1
  72. cmp %o1, 0x7f
  73. ble 5b
  74. clr %o2
  75. 9: retl
  76. nop
  77. viking_mxcc_flush_page:
  78. sethi %hi(PAGE_OFFSET), %g2
  79. sub %o0, %g2, %g3
  80. sub %g3, -PAGE_SIZE, %g3 ! ppage + PAGE_SIZE
  81. sethi %hi(MXCC_SRCSTREAM), %o3 ! assume %hi(MXCC_SRCSTREAM) == %hi(MXCC_DESTSTREAM)
  82. mov 0x10, %g2 ! set cacheable bit
  83. or %o3, %lo(MXCC_SRCSTREAM), %o2
  84. or %o3, %lo(MXCC_DESSTREAM), %o3
  85. sub %g3, MXCC_STREAM_SIZE, %g3
  86. 6:
  87. stda %g2, [%o2] ASI_M_MXCC
  88. stda %g2, [%o3] ASI_M_MXCC
  89. andncc %g3, PAGE_MASK, %g0
  90. bne 6b
  91. sub %g3, MXCC_STREAM_SIZE, %g3
  92. 9: retl
  93. nop
  94. viking_flush_cache_page:
  95. viking_flush_cache_range:
  96. #ifndef CONFIG_SMP
  97. ld [%o0 + VMA_VM_MM], %o0
  98. #endif
  99. viking_flush_cache_mm:
  100. #ifndef CONFIG_SMP
  101. ld [%o0 + AOFF_mm_context], %g1
  102. cmp %g1, -1
  103. bne viking_flush_cache_all
  104. nop
  105. b,a viking_flush_cache_out
  106. #endif
  107. viking_flush_cache_all:
  108. WINDOW_FLUSH(%g4, %g5)
  109. viking_flush_cache_out:
  110. retl
  111. nop
  112. viking_flush_tlb_all:
  113. mov 0x400, %g1
  114. retl
  115. sta %g0, [%g1] ASI_M_FLUSH_PROBE
  116. viking_flush_tlb_mm:
  117. mov SRMMU_CTX_REG, %g1
  118. ld [%o0 + AOFF_mm_context], %o1
  119. lda [%g1] ASI_M_MMUREGS, %g5
  120. #ifndef CONFIG_SMP
  121. cmp %o1, -1
  122. be 1f
  123. #endif
  124. mov 0x300, %g2
  125. sta %o1, [%g1] ASI_M_MMUREGS
  126. sta %g0, [%g2] ASI_M_FLUSH_PROBE
  127. retl
  128. sta %g5, [%g1] ASI_M_MMUREGS
  129. #ifndef CONFIG_SMP
  130. 1: retl
  131. nop
  132. #endif
  133. viking_flush_tlb_range:
  134. ld [%o0 + VMA_VM_MM], %o0
  135. mov SRMMU_CTX_REG, %g1
  136. ld [%o0 + AOFF_mm_context], %o3
  137. lda [%g1] ASI_M_MMUREGS, %g5
  138. #ifndef CONFIG_SMP
  139. cmp %o3, -1
  140. be 2f
  141. #endif
  142. sethi %hi(~((1 << SRMMU_PGDIR_SHIFT) - 1)), %o4
  143. sta %o3, [%g1] ASI_M_MMUREGS
  144. and %o1, %o4, %o1
  145. add %o1, 0x200, %o1
  146. sta %g0, [%o1] ASI_M_FLUSH_PROBE
  147. 1: sub %o1, %o4, %o1
  148. cmp %o1, %o2
  149. blu,a 1b
  150. sta %g0, [%o1] ASI_M_FLUSH_PROBE
  151. retl
  152. sta %g5, [%g1] ASI_M_MMUREGS
  153. #ifndef CONFIG_SMP
  154. 2: retl
  155. nop
  156. #endif
  157. viking_flush_tlb_page:
  158. ld [%o0 + VMA_VM_MM], %o0
  159. mov SRMMU_CTX_REG, %g1
  160. ld [%o0 + AOFF_mm_context], %o3
  161. lda [%g1] ASI_M_MMUREGS, %g5
  162. #ifndef CONFIG_SMP
  163. cmp %o3, -1
  164. be 1f
  165. #endif
  166. and %o1, PAGE_MASK, %o1
  167. sta %o3, [%g1] ASI_M_MMUREGS
  168. sta %g0, [%o1] ASI_M_FLUSH_PROBE
  169. retl
  170. sta %g5, [%g1] ASI_M_MMUREGS
  171. #ifndef CONFIG_SMP
  172. 1: retl
  173. nop
  174. #endif
  175. viking_flush_page_to_ram:
  176. viking_flush_page_for_dma:
  177. viking_flush_sig_insns:
  178. retl
  179. nop
  180. #ifdef CONFIG_SMP
  181. .globl sun4dsmp_flush_tlb_all, sun4dsmp_flush_tlb_mm
  182. .globl sun4dsmp_flush_tlb_range, sun4dsmp_flush_tlb_page
  183. sun4dsmp_flush_tlb_all:
  184. sethi %hi(sun4dsmp_flush_tlb_spin), %g3
  185. 1: ldstub [%g3 + %lo(sun4dsmp_flush_tlb_spin)], %g5
  186. tst %g5
  187. bne 2f
  188. mov 0x400, %g1
  189. sta %g0, [%g1] ASI_M_FLUSH_PROBE
  190. retl
  191. stb %g0, [%g3 + %lo(sun4dsmp_flush_tlb_spin)]
  192. 2: tst %g5
  193. bne,a 2b
  194. ldub [%g3 + %lo(sun4dsmp_flush_tlb_spin)], %g5
  195. b,a 1b
  196. sun4dsmp_flush_tlb_mm:
  197. sethi %hi(sun4dsmp_flush_tlb_spin), %g3
  198. 1: ldstub [%g3 + %lo(sun4dsmp_flush_tlb_spin)], %g5
  199. tst %g5
  200. bne 2f
  201. mov SRMMU_CTX_REG, %g1
  202. ld [%o0 + AOFF_mm_context], %o1
  203. lda [%g1] ASI_M_MMUREGS, %g5
  204. mov 0x300, %g2
  205. sta %o1, [%g1] ASI_M_MMUREGS
  206. sta %g0, [%g2] ASI_M_FLUSH_PROBE
  207. sta %g5, [%g1] ASI_M_MMUREGS
  208. retl
  209. stb %g0, [%g3 + %lo(sun4dsmp_flush_tlb_spin)]
  210. 2: tst %g5
  211. bne,a 2b
  212. ldub [%g3 + %lo(sun4dsmp_flush_tlb_spin)], %g5
  213. b,a 1b
  214. sun4dsmp_flush_tlb_range:
  215. sethi %hi(sun4dsmp_flush_tlb_spin), %g3
  216. 1: ldstub [%g3 + %lo(sun4dsmp_flush_tlb_spin)], %g5
  217. tst %g5
  218. bne 3f
  219. mov SRMMU_CTX_REG, %g1
  220. ld [%o0 + VMA_VM_MM], %o0
  221. ld [%o0 + AOFF_mm_context], %o3
  222. lda [%g1] ASI_M_MMUREGS, %g5
  223. sethi %hi(~((1 << SRMMU_PGDIR_SHIFT) - 1)), %o4
  224. sta %o3, [%g1] ASI_M_MMUREGS
  225. and %o1, %o4, %o1
  226. add %o1, 0x200, %o1
  227. sta %g0, [%o1] ASI_M_FLUSH_PROBE
  228. 2: sub %o1, %o4, %o1
  229. cmp %o1, %o2
  230. blu,a 2b
  231. sta %g0, [%o1] ASI_M_FLUSH_PROBE
  232. sta %g5, [%g1] ASI_M_MMUREGS
  233. retl
  234. stb %g0, [%g3 + %lo(sun4dsmp_flush_tlb_spin)]
  235. 3: tst %g5
  236. bne,a 3b
  237. ldub [%g3 + %lo(sun4dsmp_flush_tlb_spin)], %g5
  238. b,a 1b
  239. sun4dsmp_flush_tlb_page:
  240. sethi %hi(sun4dsmp_flush_tlb_spin), %g3
  241. 1: ldstub [%g3 + %lo(sun4dsmp_flush_tlb_spin)], %g5
  242. tst %g5
  243. bne 2f
  244. mov SRMMU_CTX_REG, %g1
  245. ld [%o0 + VMA_VM_MM], %o0
  246. ld [%o0 + AOFF_mm_context], %o3
  247. lda [%g1] ASI_M_MMUREGS, %g5
  248. and %o1, PAGE_MASK, %o1
  249. sta %o3, [%g1] ASI_M_MMUREGS
  250. sta %g0, [%o1] ASI_M_FLUSH_PROBE
  251. sta %g5, [%g1] ASI_M_MMUREGS
  252. retl
  253. stb %g0, [%g3 + %lo(sun4dsmp_flush_tlb_spin)]
  254. 2: tst %g5
  255. bne,a 2b
  256. ldub [%g3 + %lo(sun4dsmp_flush_tlb_spin)], %g5
  257. b,a 1b
  258. nop
  259. #endif