hypersparc.S 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412
  1. /*
  2. * hypersparc.S: High speed Hypersparc mmu/cache operations.
  3. *
  4. * Copyright (C) 1997 David S. Miller (davem@caip.rutgers.edu)
  5. */
  6. #include <asm/ptrace.h>
  7. #include <asm/psr.h>
  8. #include <asm/asm-offsets.h>
  9. #include <asm/asi.h>
  10. #include <asm/page.h>
  11. #include <asm/pgtsrmmu.h>
  12. #include <linux/init.h>
  13. .text
  14. .align 4
  15. .globl hypersparc_flush_cache_all, hypersparc_flush_cache_mm
  16. .globl hypersparc_flush_cache_range, hypersparc_flush_cache_page
  17. .globl hypersparc_flush_page_to_ram
  18. .globl hypersparc_flush_page_for_dma, hypersparc_flush_sig_insns
  19. .globl hypersparc_flush_tlb_all, hypersparc_flush_tlb_mm
  20. .globl hypersparc_flush_tlb_range, hypersparc_flush_tlb_page
  21. hypersparc_flush_cache_all:
  22. WINDOW_FLUSH(%g4, %g5)
  23. sethi %hi(vac_cache_size), %g4
  24. ld [%g4 + %lo(vac_cache_size)], %g5
  25. sethi %hi(vac_line_size), %g1
  26. ld [%g1 + %lo(vac_line_size)], %g2
  27. 1:
  28. subcc %g5, %g2, %g5 ! hyper_flush_unconditional_combined
  29. bne 1b
  30. sta %g0, [%g5] ASI_M_FLUSH_CTX
  31. retl
  32. sta %g0, [%g0] ASI_M_FLUSH_IWHOLE ! hyper_flush_whole_icache
  33. /* We expand the window flush to get maximum performance. */
  34. hypersparc_flush_cache_mm:
  35. #ifndef CONFIG_SMP
  36. ld [%o0 + AOFF_mm_context], %g1
  37. cmp %g1, -1
  38. be hypersparc_flush_cache_mm_out
  39. #endif
  40. WINDOW_FLUSH(%g4, %g5)
  41. sethi %hi(vac_line_size), %g1
  42. ld [%g1 + %lo(vac_line_size)], %o1
  43. sethi %hi(vac_cache_size), %g2
  44. ld [%g2 + %lo(vac_cache_size)], %o0
  45. add %o1, %o1, %g1
  46. add %o1, %g1, %g2
  47. add %o1, %g2, %g3
  48. add %o1, %g3, %g4
  49. add %o1, %g4, %g5
  50. add %o1, %g5, %o4
  51. add %o1, %o4, %o5
  52. /* BLAMMO! */
  53. 1:
  54. subcc %o0, %o5, %o0 ! hyper_flush_cache_user
  55. sta %g0, [%o0 + %g0] ASI_M_FLUSH_USER
  56. sta %g0, [%o0 + %o1] ASI_M_FLUSH_USER
  57. sta %g0, [%o0 + %g1] ASI_M_FLUSH_USER
  58. sta %g0, [%o0 + %g2] ASI_M_FLUSH_USER
  59. sta %g0, [%o0 + %g3] ASI_M_FLUSH_USER
  60. sta %g0, [%o0 + %g4] ASI_M_FLUSH_USER
  61. sta %g0, [%o0 + %g5] ASI_M_FLUSH_USER
  62. bne 1b
  63. sta %g0, [%o0 + %o4] ASI_M_FLUSH_USER
  64. hypersparc_flush_cache_mm_out:
  65. retl
  66. nop
  67. /* The things we do for performance... */
  68. hypersparc_flush_cache_range:
  69. ld [%o0 + VMA_VM_MM], %o0
  70. #ifndef CONFIG_SMP
  71. ld [%o0 + AOFF_mm_context], %g1
  72. cmp %g1, -1
  73. be hypersparc_flush_cache_range_out
  74. #endif
  75. WINDOW_FLUSH(%g4, %g5)
  76. sethi %hi(vac_line_size), %g1
  77. ld [%g1 + %lo(vac_line_size)], %o4
  78. sethi %hi(vac_cache_size), %g2
  79. ld [%g2 + %lo(vac_cache_size)], %o3
  80. /* Here comes the fun part... */
  81. add %o2, (PAGE_SIZE - 1), %o2
  82. andn %o1, (PAGE_SIZE - 1), %o1
  83. add %o4, %o4, %o5
  84. andn %o2, (PAGE_SIZE - 1), %o2
  85. add %o4, %o5, %g1
  86. sub %o2, %o1, %g4
  87. add %o4, %g1, %g2
  88. sll %o3, 2, %g5
  89. add %o4, %g2, %g3
  90. cmp %g4, %g5
  91. add %o4, %g3, %g4
  92. blu 0f
  93. add %o4, %g4, %g5
  94. add %o4, %g5, %g7
  95. /* Flush entire user space, believe it or not this is quicker
  96. * than page at a time flushings for range > (cache_size<<2).
  97. */
  98. 1:
  99. subcc %o3, %g7, %o3
  100. sta %g0, [%o3 + %g0] ASI_M_FLUSH_USER
  101. sta %g0, [%o3 + %o4] ASI_M_FLUSH_USER
  102. sta %g0, [%o3 + %o5] ASI_M_FLUSH_USER
  103. sta %g0, [%o3 + %g1] ASI_M_FLUSH_USER
  104. sta %g0, [%o3 + %g2] ASI_M_FLUSH_USER
  105. sta %g0, [%o3 + %g3] ASI_M_FLUSH_USER
  106. sta %g0, [%o3 + %g4] ASI_M_FLUSH_USER
  107. bne 1b
  108. sta %g0, [%o3 + %g5] ASI_M_FLUSH_USER
  109. retl
  110. nop
  111. /* Below our threshold, flush one page at a time. */
  112. 0:
  113. ld [%o0 + AOFF_mm_context], %o0
  114. mov SRMMU_CTX_REG, %g7
  115. lda [%g7] ASI_M_MMUREGS, %o3
  116. sta %o0, [%g7] ASI_M_MMUREGS
  117. add %o2, -PAGE_SIZE, %o0
  118. 1:
  119. or %o0, 0x400, %g7
  120. lda [%g7] ASI_M_FLUSH_PROBE, %g7
  121. orcc %g7, 0, %g0
  122. be,a 3f
  123. mov %o0, %o2
  124. add %o4, %g5, %g7
  125. 2:
  126. sub %o2, %g7, %o2
  127. sta %g0, [%o2 + %g0] ASI_M_FLUSH_PAGE
  128. sta %g0, [%o2 + %o4] ASI_M_FLUSH_PAGE
  129. sta %g0, [%o2 + %o5] ASI_M_FLUSH_PAGE
  130. sta %g0, [%o2 + %g1] ASI_M_FLUSH_PAGE
  131. sta %g0, [%o2 + %g2] ASI_M_FLUSH_PAGE
  132. sta %g0, [%o2 + %g3] ASI_M_FLUSH_PAGE
  133. andcc %o2, 0xffc, %g0
  134. sta %g0, [%o2 + %g4] ASI_M_FLUSH_PAGE
  135. bne 2b
  136. sta %g0, [%o2 + %g5] ASI_M_FLUSH_PAGE
  137. 3:
  138. cmp %o2, %o1
  139. bne 1b
  140. add %o2, -PAGE_SIZE, %o0
  141. mov SRMMU_FAULT_STATUS, %g5
  142. lda [%g5] ASI_M_MMUREGS, %g0
  143. mov SRMMU_CTX_REG, %g7
  144. sta %o3, [%g7] ASI_M_MMUREGS
  145. hypersparc_flush_cache_range_out:
  146. retl
  147. nop
  148. /* HyperSparc requires a valid mapping where we are about to flush
  149. * in order to check for a physical tag match during the flush.
  150. */
  151. /* Verified, my ass... */
  152. hypersparc_flush_cache_page:
  153. ld [%o0 + VMA_VM_MM], %o0
  154. ld [%o0 + AOFF_mm_context], %g2
  155. #ifndef CONFIG_SMP
  156. cmp %g2, -1
  157. be hypersparc_flush_cache_page_out
  158. #endif
  159. WINDOW_FLUSH(%g4, %g5)
  160. sethi %hi(vac_line_size), %g1
  161. ld [%g1 + %lo(vac_line_size)], %o4
  162. mov SRMMU_CTX_REG, %o3
  163. andn %o1, (PAGE_SIZE - 1), %o1
  164. lda [%o3] ASI_M_MMUREGS, %o2
  165. sta %g2, [%o3] ASI_M_MMUREGS
  166. or %o1, 0x400, %o5
  167. lda [%o5] ASI_M_FLUSH_PROBE, %g1
  168. orcc %g0, %g1, %g0
  169. be 2f
  170. add %o4, %o4, %o5
  171. sub %o1, -PAGE_SIZE, %o1
  172. add %o4, %o5, %g1
  173. add %o4, %g1, %g2
  174. add %o4, %g2, %g3
  175. add %o4, %g3, %g4
  176. add %o4, %g4, %g5
  177. add %o4, %g5, %g7
  178. /* BLAMMO! */
  179. 1:
  180. sub %o1, %g7, %o1
  181. sta %g0, [%o1 + %g0] ASI_M_FLUSH_PAGE
  182. sta %g0, [%o1 + %o4] ASI_M_FLUSH_PAGE
  183. sta %g0, [%o1 + %o5] ASI_M_FLUSH_PAGE
  184. sta %g0, [%o1 + %g1] ASI_M_FLUSH_PAGE
  185. sta %g0, [%o1 + %g2] ASI_M_FLUSH_PAGE
  186. sta %g0, [%o1 + %g3] ASI_M_FLUSH_PAGE
  187. andcc %o1, 0xffc, %g0
  188. sta %g0, [%o1 + %g4] ASI_M_FLUSH_PAGE
  189. bne 1b
  190. sta %g0, [%o1 + %g5] ASI_M_FLUSH_PAGE
  191. 2:
  192. mov SRMMU_FAULT_STATUS, %g7
  193. mov SRMMU_CTX_REG, %g4
  194. lda [%g7] ASI_M_MMUREGS, %g0
  195. sta %o2, [%g4] ASI_M_MMUREGS
  196. hypersparc_flush_cache_page_out:
  197. retl
  198. nop
  199. hypersparc_flush_sig_insns:
  200. flush %o1
  201. retl
  202. flush %o1 + 4
  203. /* HyperSparc is copy-back. */
  204. hypersparc_flush_page_to_ram:
  205. sethi %hi(vac_line_size), %g1
  206. ld [%g1 + %lo(vac_line_size)], %o4
  207. andn %o0, (PAGE_SIZE - 1), %o0
  208. add %o4, %o4, %o5
  209. or %o0, 0x400, %g7
  210. lda [%g7] ASI_M_FLUSH_PROBE, %g5
  211. add %o4, %o5, %g1
  212. orcc %g5, 0, %g0
  213. be 2f
  214. add %o4, %g1, %g2
  215. add %o4, %g2, %g3
  216. sub %o0, -PAGE_SIZE, %o0
  217. add %o4, %g3, %g4
  218. add %o4, %g4, %g5
  219. add %o4, %g5, %g7
  220. /* BLAMMO! */
  221. 1:
  222. sub %o0, %g7, %o0
  223. sta %g0, [%o0 + %g0] ASI_M_FLUSH_PAGE
  224. sta %g0, [%o0 + %o4] ASI_M_FLUSH_PAGE
  225. sta %g0, [%o0 + %o5] ASI_M_FLUSH_PAGE
  226. sta %g0, [%o0 + %g1] ASI_M_FLUSH_PAGE
  227. sta %g0, [%o0 + %g2] ASI_M_FLUSH_PAGE
  228. sta %g0, [%o0 + %g3] ASI_M_FLUSH_PAGE
  229. andcc %o0, 0xffc, %g0
  230. sta %g0, [%o0 + %g4] ASI_M_FLUSH_PAGE
  231. bne 1b
  232. sta %g0, [%o0 + %g5] ASI_M_FLUSH_PAGE
  233. 2:
  234. mov SRMMU_FAULT_STATUS, %g1
  235. retl
  236. lda [%g1] ASI_M_MMUREGS, %g0
  237. /* HyperSparc is IO cache coherent. */
  238. hypersparc_flush_page_for_dma:
  239. retl
  240. nop
  241. /* It was noted that at boot time a TLB flush all in a delay slot
  242. * can deliver an illegal instruction to the processor if the timing
  243. * is just right...
  244. */
  245. hypersparc_flush_tlb_all:
  246. mov 0x400, %g1
  247. sta %g0, [%g1] ASI_M_FLUSH_PROBE
  248. retl
  249. nop
  250. hypersparc_flush_tlb_mm:
  251. mov SRMMU_CTX_REG, %g1
  252. ld [%o0 + AOFF_mm_context], %o1
  253. lda [%g1] ASI_M_MMUREGS, %g5
  254. #ifndef CONFIG_SMP
  255. cmp %o1, -1
  256. be hypersparc_flush_tlb_mm_out
  257. #endif
  258. mov 0x300, %g2
  259. sta %o1, [%g1] ASI_M_MMUREGS
  260. sta %g0, [%g2] ASI_M_FLUSH_PROBE
  261. hypersparc_flush_tlb_mm_out:
  262. retl
  263. sta %g5, [%g1] ASI_M_MMUREGS
  264. hypersparc_flush_tlb_range:
  265. ld [%o0 + VMA_VM_MM], %o0
  266. mov SRMMU_CTX_REG, %g1
  267. ld [%o0 + AOFF_mm_context], %o3
  268. lda [%g1] ASI_M_MMUREGS, %g5
  269. #ifndef CONFIG_SMP
  270. cmp %o3, -1
  271. be hypersparc_flush_tlb_range_out
  272. #endif
  273. sethi %hi(~((1 << SRMMU_PGDIR_SHIFT) - 1)), %o4
  274. sta %o3, [%g1] ASI_M_MMUREGS
  275. and %o1, %o4, %o1
  276. add %o1, 0x200, %o1
  277. sta %g0, [%o1] ASI_M_FLUSH_PROBE
  278. 1:
  279. sub %o1, %o4, %o1
  280. cmp %o1, %o2
  281. blu,a 1b
  282. sta %g0, [%o1] ASI_M_FLUSH_PROBE
  283. hypersparc_flush_tlb_range_out:
  284. retl
  285. sta %g5, [%g1] ASI_M_MMUREGS
  286. hypersparc_flush_tlb_page:
  287. ld [%o0 + VMA_VM_MM], %o0
  288. mov SRMMU_CTX_REG, %g1
  289. ld [%o0 + AOFF_mm_context], %o3
  290. andn %o1, (PAGE_SIZE - 1), %o1
  291. #ifndef CONFIG_SMP
  292. cmp %o3, -1
  293. be hypersparc_flush_tlb_page_out
  294. #endif
  295. lda [%g1] ASI_M_MMUREGS, %g5
  296. sta %o3, [%g1] ASI_M_MMUREGS
  297. sta %g0, [%o1] ASI_M_FLUSH_PROBE
  298. hypersparc_flush_tlb_page_out:
  299. retl
  300. sta %g5, [%g1] ASI_M_MMUREGS
  301. __INIT
  302. /* High speed page clear/copy. */
  303. hypersparc_bzero_1page:
  304. /* NOTE: This routine has to be shorter than 40insns --jj */
  305. clr %g1
  306. mov 32, %g2
  307. mov 64, %g3
  308. mov 96, %g4
  309. mov 128, %g5
  310. mov 160, %g7
  311. mov 192, %o2
  312. mov 224, %o3
  313. mov 16, %o1
  314. 1:
  315. stda %g0, [%o0 + %g0] ASI_M_BFILL
  316. stda %g0, [%o0 + %g2] ASI_M_BFILL
  317. stda %g0, [%o0 + %g3] ASI_M_BFILL
  318. stda %g0, [%o0 + %g4] ASI_M_BFILL
  319. stda %g0, [%o0 + %g5] ASI_M_BFILL
  320. stda %g0, [%o0 + %g7] ASI_M_BFILL
  321. stda %g0, [%o0 + %o2] ASI_M_BFILL
  322. stda %g0, [%o0 + %o3] ASI_M_BFILL
  323. subcc %o1, 1, %o1
  324. bne 1b
  325. add %o0, 256, %o0
  326. retl
  327. nop
  328. hypersparc_copy_1page:
  329. /* NOTE: This routine has to be shorter than 70insns --jj */
  330. sub %o1, %o0, %o2 ! difference
  331. mov 16, %g1
  332. 1:
  333. sta %o0, [%o0 + %o2] ASI_M_BCOPY
  334. add %o0, 32, %o0
  335. sta %o0, [%o0 + %o2] ASI_M_BCOPY
  336. add %o0, 32, %o0
  337. sta %o0, [%o0 + %o2] ASI_M_BCOPY
  338. add %o0, 32, %o0
  339. sta %o0, [%o0 + %o2] ASI_M_BCOPY
  340. add %o0, 32, %o0
  341. sta %o0, [%o0 + %o2] ASI_M_BCOPY
  342. add %o0, 32, %o0
  343. sta %o0, [%o0 + %o2] ASI_M_BCOPY
  344. add %o0, 32, %o0
  345. sta %o0, [%o0 + %o2] ASI_M_BCOPY
  346. add %o0, 32, %o0
  347. sta %o0, [%o0 + %o2] ASI_M_BCOPY
  348. subcc %g1, 1, %g1
  349. bne 1b
  350. add %o0, 32, %o0
  351. retl
  352. nop
  353. .globl hypersparc_setup_blockops
  354. hypersparc_setup_blockops:
  355. sethi %hi(bzero_1page), %o0
  356. or %o0, %lo(bzero_1page), %o0
  357. sethi %hi(hypersparc_bzero_1page), %o1
  358. or %o1, %lo(hypersparc_bzero_1page), %o1
  359. sethi %hi(hypersparc_copy_1page), %o2
  360. or %o2, %lo(hypersparc_copy_1page), %o2
  361. ld [%o1], %o4
  362. 1:
  363. add %o1, 4, %o1
  364. st %o4, [%o0]
  365. add %o0, 4, %o0
  366. cmp %o1, %o2
  367. bne 1b
  368. ld [%o1], %o4
  369. sethi %hi(__copy_1page), %o0
  370. or %o0, %lo(__copy_1page), %o0
  371. sethi %hi(hypersparc_setup_blockops), %o2
  372. or %o2, %lo(hypersparc_setup_blockops), %o2
  373. ld [%o1], %o4
  374. 1:
  375. add %o1, 4, %o1
  376. st %o4, [%o0]
  377. add %o0, 4, %o0
  378. cmp %o1, %o2
  379. bne 1b
  380. ld [%o1], %o4
  381. sta %g0, [%g0] ASI_M_FLUSH_IWHOLE
  382. retl
  383. nop