viking.S 6.1 KB

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