copy_page.S 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. /* clear_page.S: UltraSparc optimized copy page.
  2. *
  3. * Copyright (C) 1996, 1998, 1999, 2000, 2004 David S. Miller (davem@redhat.com)
  4. * Copyright (C) 1997 Jakub Jelinek (jakub@redhat.com)
  5. */
  6. #include <asm/visasm.h>
  7. #include <asm/thread_info.h>
  8. #include <asm/page.h>
  9. #include <asm/pgtable.h>
  10. #include <asm/spitfire.h>
  11. #include <asm/head.h>
  12. /* What we used to do was lock a TLB entry into a specific
  13. * TLB slot, clear the page with interrupts disabled, then
  14. * restore the original TLB entry. This was great for
  15. * disturbing the TLB as little as possible, but it meant
  16. * we had to keep interrupts disabled for a long time.
  17. *
  18. * Now, we simply use the normal TLB loading mechanism,
  19. * and this makes the cpu choose a slot all by itself.
  20. * Then we do a normal TLB flush on exit. We need only
  21. * disable preemption during the clear.
  22. */
  23. #define DCACHE_SIZE (PAGE_SIZE * 2)
  24. #if (PAGE_SHIFT == 13)
  25. #define PAGE_SIZE_REM 0x80
  26. #elif (PAGE_SHIFT == 16)
  27. #define PAGE_SIZE_REM 0x100
  28. #else
  29. #error Wrong PAGE_SHIFT specified
  30. #endif
  31. #define TOUCH(reg0, reg1, reg2, reg3, reg4, reg5, reg6, reg7) \
  32. fsrc2 %reg0, %f48; fsrc2 %reg1, %f50; \
  33. fsrc2 %reg2, %f52; fsrc2 %reg3, %f54; \
  34. fsrc2 %reg4, %f56; fsrc2 %reg5, %f58; \
  35. fsrc2 %reg6, %f60; fsrc2 %reg7, %f62;
  36. .text
  37. .align 32
  38. .globl copy_user_page
  39. .type copy_user_page,#function
  40. copy_user_page: /* %o0=dest, %o1=src, %o2=vaddr */
  41. lduw [%g6 + TI_PRE_COUNT], %o4
  42. sethi %hi(PAGE_OFFSET), %g2
  43. sethi %hi(PAGE_SIZE), %o3
  44. ldx [%g2 + %lo(PAGE_OFFSET)], %g2
  45. sethi %hi(PAGE_KERNEL_LOCKED), %g3
  46. ldx [%g3 + %lo(PAGE_KERNEL_LOCKED)], %g3
  47. sub %o0, %g2, %g1 ! dest paddr
  48. sub %o1, %g2, %g2 ! src paddr
  49. and %o2, %o3, %o0 ! vaddr D-cache alias bit
  50. or %g1, %g3, %g1 ! dest TTE data
  51. or %g2, %g3, %g2 ! src TTE data
  52. sethi %hi(TLBTEMP_BASE), %o3
  53. sethi %hi(DCACHE_SIZE), %o1
  54. add %o0, %o3, %o0 ! dest TTE vaddr
  55. add %o4, 1, %o2
  56. add %o0, %o1, %o1 ! src TTE vaddr
  57. /* Disable preemption. */
  58. mov TLB_TAG_ACCESS, %g3
  59. stw %o2, [%g6 + TI_PRE_COUNT]
  60. /* Load TLB entries. */
  61. rdpr %pstate, %o2
  62. wrpr %o2, PSTATE_IE, %pstate
  63. stxa %o0, [%g3] ASI_DMMU
  64. stxa %g1, [%g0] ASI_DTLB_DATA_IN
  65. membar #Sync
  66. stxa %o1, [%g3] ASI_DMMU
  67. stxa %g2, [%g0] ASI_DTLB_DATA_IN
  68. membar #Sync
  69. wrpr %o2, 0x0, %pstate
  70. cheetah_copy_page_insn:
  71. ba,pt %xcc, 9f
  72. nop
  73. 1:
  74. VISEntryHalf
  75. membar #StoreLoad | #StoreStore | #LoadStore
  76. sethi %hi((PAGE_SIZE/64)-2), %o2
  77. mov %o0, %g1
  78. prefetch [%o1 + 0x000], #one_read
  79. or %o2, %lo((PAGE_SIZE/64)-2), %o2
  80. prefetch [%o1 + 0x040], #one_read
  81. prefetch [%o1 + 0x080], #one_read
  82. prefetch [%o1 + 0x0c0], #one_read
  83. ldd [%o1 + 0x000], %f0
  84. prefetch [%o1 + 0x100], #one_read
  85. ldd [%o1 + 0x008], %f2
  86. prefetch [%o1 + 0x140], #one_read
  87. ldd [%o1 + 0x010], %f4
  88. prefetch [%o1 + 0x180], #one_read
  89. fsrc2 %f0, %f16
  90. ldd [%o1 + 0x018], %f6
  91. fsrc2 %f2, %f18
  92. ldd [%o1 + 0x020], %f8
  93. fsrc2 %f4, %f20
  94. ldd [%o1 + 0x028], %f10
  95. fsrc2 %f6, %f22
  96. ldd [%o1 + 0x030], %f12
  97. fsrc2 %f8, %f24
  98. ldd [%o1 + 0x038], %f14
  99. fsrc2 %f10, %f26
  100. ldd [%o1 + 0x040], %f0
  101. 1: ldd [%o1 + 0x048], %f2
  102. fsrc2 %f12, %f28
  103. ldd [%o1 + 0x050], %f4
  104. fsrc2 %f14, %f30
  105. stda %f16, [%o0] ASI_BLK_P
  106. ldd [%o1 + 0x058], %f6
  107. fsrc2 %f0, %f16
  108. ldd [%o1 + 0x060], %f8
  109. fsrc2 %f2, %f18
  110. ldd [%o1 + 0x068], %f10
  111. fsrc2 %f4, %f20
  112. ldd [%o1 + 0x070], %f12
  113. fsrc2 %f6, %f22
  114. ldd [%o1 + 0x078], %f14
  115. fsrc2 %f8, %f24
  116. ldd [%o1 + 0x080], %f0
  117. prefetch [%o1 + 0x180], #one_read
  118. fsrc2 %f10, %f26
  119. subcc %o2, 1, %o2
  120. add %o0, 0x40, %o0
  121. bne,pt %xcc, 1b
  122. add %o1, 0x40, %o1
  123. ldd [%o1 + 0x048], %f2
  124. fsrc2 %f12, %f28
  125. ldd [%o1 + 0x050], %f4
  126. fsrc2 %f14, %f30
  127. stda %f16, [%o0] ASI_BLK_P
  128. ldd [%o1 + 0x058], %f6
  129. fsrc2 %f0, %f16
  130. ldd [%o1 + 0x060], %f8
  131. fsrc2 %f2, %f18
  132. ldd [%o1 + 0x068], %f10
  133. fsrc2 %f4, %f20
  134. ldd [%o1 + 0x070], %f12
  135. fsrc2 %f6, %f22
  136. add %o0, 0x40, %o0
  137. ldd [%o1 + 0x078], %f14
  138. fsrc2 %f8, %f24
  139. fsrc2 %f10, %f26
  140. fsrc2 %f12, %f28
  141. fsrc2 %f14, %f30
  142. stda %f16, [%o0] ASI_BLK_P
  143. membar #Sync
  144. VISExitHalf
  145. ba,pt %xcc, 5f
  146. nop
  147. 9:
  148. VISEntry
  149. ldub [%g6 + TI_FAULT_CODE], %g3
  150. mov %o0, %g1
  151. cmp %g3, 0
  152. rd %asi, %g3
  153. be,a,pt %icc, 1f
  154. wr %g0, ASI_BLK_P, %asi
  155. wr %g0, ASI_BLK_COMMIT_P, %asi
  156. 1: ldda [%o1] ASI_BLK_P, %f0
  157. add %o1, 0x40, %o1
  158. ldda [%o1] ASI_BLK_P, %f16
  159. add %o1, 0x40, %o1
  160. sethi %hi(PAGE_SIZE), %o2
  161. 1: TOUCH(f0, f2, f4, f6, f8, f10, f12, f14)
  162. ldda [%o1] ASI_BLK_P, %f32
  163. stda %f48, [%o0] %asi
  164. add %o1, 0x40, %o1
  165. sub %o2, 0x40, %o2
  166. add %o0, 0x40, %o0
  167. TOUCH(f16, f18, f20, f22, f24, f26, f28, f30)
  168. ldda [%o1] ASI_BLK_P, %f0
  169. stda %f48, [%o0] %asi
  170. add %o1, 0x40, %o1
  171. sub %o2, 0x40, %o2
  172. add %o0, 0x40, %o0
  173. TOUCH(f32, f34, f36, f38, f40, f42, f44, f46)
  174. ldda [%o1] ASI_BLK_P, %f16
  175. stda %f48, [%o0] %asi
  176. sub %o2, 0x40, %o2
  177. add %o1, 0x40, %o1
  178. cmp %o2, PAGE_SIZE_REM
  179. bne,pt %xcc, 1b
  180. add %o0, 0x40, %o0
  181. #if (PAGE_SHIFT == 16)
  182. TOUCH(f0, f2, f4, f6, f8, f10, f12, f14)
  183. ldda [%o1] ASI_BLK_P, %f32
  184. stda %f48, [%o0] %asi
  185. add %o1, 0x40, %o1
  186. sub %o2, 0x40, %o2
  187. add %o0, 0x40, %o0
  188. TOUCH(f16, f18, f20, f22, f24, f26, f28, f30)
  189. ldda [%o1] ASI_BLK_P, %f0
  190. stda %f48, [%o0] %asi
  191. add %o1, 0x40, %o1
  192. sub %o2, 0x40, %o2
  193. add %o0, 0x40, %o0
  194. membar #Sync
  195. stda %f32, [%o0] %asi
  196. add %o0, 0x40, %o0
  197. stda %f0, [%o0] %asi
  198. #else
  199. membar #Sync
  200. stda %f0, [%o0] %asi
  201. add %o0, 0x40, %o0
  202. stda %f16, [%o0] %asi
  203. #endif
  204. membar #Sync
  205. wr %g3, 0x0, %asi
  206. VISExit
  207. 5:
  208. stxa %g0, [%g1] ASI_DMMU_DEMAP
  209. membar #Sync
  210. sethi %hi(DCACHE_SIZE), %g2
  211. stxa %g0, [%g1 + %g2] ASI_DMMU_DEMAP
  212. membar #Sync
  213. retl
  214. stw %o4, [%g6 + TI_PRE_COUNT]
  215. .size copy_user_page, .-copy_user_page
  216. .globl cheetah_patch_copy_page
  217. cheetah_patch_copy_page:
  218. sethi %hi(0x01000000), %o1 ! NOP
  219. sethi %hi(cheetah_copy_page_insn), %o0
  220. or %o0, %lo(cheetah_copy_page_insn), %o0
  221. stw %o1, [%o0]
  222. membar #StoreStore
  223. flush %o0
  224. retl
  225. nop