copy_user_template.S 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. /*
  2. * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 and
  6. * only version 2 as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program; if not, write to the Free Software
  15. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  16. * 02110-1301, USA.
  17. */
  18. /* Numerology:
  19. * WXYZ
  20. * W: width in bytes
  21. * X: Load=0, Store=1
  22. * Y: Location 0=preamble,8=loop,9=epilog
  23. * Z: Location=0,handler=9
  24. */
  25. .text
  26. .global FUNCNAME
  27. .type FUNCNAME, @function
  28. .p2align 5
  29. FUNCNAME:
  30. {
  31. p0 = cmp.gtu(bytes,#0)
  32. if (!p0.new) jump:nt .Ldone
  33. r3 = or(dst,src)
  34. r4 = xor(dst,src)
  35. }
  36. {
  37. p1 = cmp.gtu(bytes,#15)
  38. p0 = bitsclr(r3,#7)
  39. if (!p0.new) jump:nt .Loop_not_aligned_8
  40. src_dst_sav = combine(src,dst)
  41. }
  42. {
  43. loopcount = lsr(bytes,#3)
  44. if (!p1) jump .Lsmall
  45. }
  46. p3=sp1loop0(.Loop8,loopcount)
  47. .Loop8:
  48. 8080:
  49. 8180:
  50. {
  51. if (p3) memd(dst++#8) = d_dbuf
  52. d_dbuf = memd(src++#8)
  53. }:endloop0
  54. 8190:
  55. {
  56. memd(dst++#8) = d_dbuf
  57. bytes -= asl(loopcount,#3)
  58. jump .Lsmall
  59. }
  60. .Loop_not_aligned_8:
  61. {
  62. p0 = bitsclr(r4,#7)
  63. if (p0.new) jump:nt .Lalign
  64. }
  65. {
  66. p0 = bitsclr(r3,#3)
  67. if (!p0.new) jump:nt .Loop_not_aligned_4
  68. p1 = cmp.gtu(bytes,#7)
  69. }
  70. {
  71. if (!p1) jump .Lsmall
  72. loopcount = lsr(bytes,#2)
  73. }
  74. p3=sp1loop0(.Loop4,loopcount)
  75. .Loop4:
  76. 4080:
  77. 4180:
  78. {
  79. if (p3) memw(dst++#4) = w_dbuf
  80. w_dbuf = memw(src++#4)
  81. }:endloop0
  82. 4190:
  83. {
  84. memw(dst++#4) = w_dbuf
  85. bytes -= asl(loopcount,#2)
  86. jump .Lsmall
  87. }
  88. .Loop_not_aligned_4:
  89. {
  90. p0 = bitsclr(r3,#1)
  91. if (!p0.new) jump:nt .Loop_not_aligned
  92. p1 = cmp.gtu(bytes,#3)
  93. }
  94. {
  95. if (!p1) jump .Lsmall
  96. loopcount = lsr(bytes,#1)
  97. }
  98. p3=sp1loop0(.Loop2,loopcount)
  99. .Loop2:
  100. 2080:
  101. 2180:
  102. {
  103. if (p3) memh(dst++#2) = w_dbuf
  104. w_dbuf = memuh(src++#2)
  105. }:endloop0
  106. 2190:
  107. {
  108. memh(dst++#2) = w_dbuf
  109. bytes -= asl(loopcount,#1)
  110. jump .Lsmall
  111. }
  112. .Loop_not_aligned: /* Works for as small as one byte */
  113. p3=sp1loop0(.Loop1,bytes)
  114. .Loop1:
  115. 1080:
  116. 1180:
  117. {
  118. if (p3) memb(dst++#1) = w_dbuf
  119. w_dbuf = memub(src++#1)
  120. }:endloop0
  121. /* Done */
  122. 1190:
  123. {
  124. memb(dst) = w_dbuf
  125. jumpr r31
  126. r0 = #0
  127. }
  128. .Lsmall:
  129. {
  130. p0 = cmp.gtu(bytes,#0)
  131. if (p0.new) jump:nt .Loop_not_aligned
  132. }
  133. .Ldone:
  134. {
  135. r0 = #0
  136. jumpr r31
  137. }
  138. .falign
  139. .Lalign:
  140. 1000:
  141. {
  142. if (p0.new) w_dbuf = memub(src)
  143. p0 = tstbit(src,#0)
  144. if (!p1) jump .Lsmall
  145. }
  146. 1100:
  147. {
  148. if (p0) memb(dst++#1) = w_dbuf
  149. if (p0) bytes = add(bytes,#-1)
  150. if (p0) src = add(src,#1)
  151. }
  152. 2000:
  153. {
  154. if (p0.new) w_dbuf = memuh(src)
  155. p0 = tstbit(src,#1)
  156. if (!p1) jump .Lsmall
  157. }
  158. 2100:
  159. {
  160. if (p0) memh(dst++#2) = w_dbuf
  161. if (p0) bytes = add(bytes,#-2)
  162. if (p0) src = add(src,#2)
  163. }
  164. 4000:
  165. {
  166. if (p0.new) w_dbuf = memw(src)
  167. p0 = tstbit(src,#2)
  168. if (!p1) jump .Lsmall
  169. }
  170. 4100:
  171. {
  172. if (p0) memw(dst++#4) = w_dbuf
  173. if (p0) bytes = add(bytes,#-4)
  174. if (p0) src = add(src,#4)
  175. jump FUNCNAME
  176. }
  177. .size FUNCNAME,.-FUNCNAME