copy_page.S 5.8 KB

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