string.S 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. /*
  2. * arch/score/lib/string.S
  3. *
  4. * Score Processor version.
  5. *
  6. * Copyright (C) 2009 Sunplus Core Technology Co., Ltd.
  7. * Chen Liqin <liqin.chen@sunplusct.com>
  8. * Lennox Wu <lennox.wu@sunplusct.com>
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 2 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, see the file COPYING, or write
  22. * to the Free Software Foundation, Inc.,
  23. * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  24. */
  25. #include <linux/linkage.h>
  26. #include <asm-generic/errno.h>
  27. .text
  28. .align 2
  29. ENTRY(__strncpy_from_user)
  30. cmpi.c r6, 0
  31. mv r9, r6
  32. ble .L2
  33. 0: lbu r7, [r5]
  34. ldi r8, 0
  35. 1: sb r7, [r4]
  36. 2: lb r6, [r5]
  37. cmp.c r6, r8
  38. beq .L2
  39. .L5:
  40. addi r8, 1
  41. cmp.c r8, r9
  42. beq .L7
  43. 3: lbu r6, [r5, 1]+
  44. 4: sb r6, [r4, 1]+
  45. 5: lb r7, [r5]
  46. cmpi.c r7, 0
  47. bne .L5
  48. .L7:
  49. mv r4, r8
  50. br r3
  51. .L2:
  52. ldi r8, 0
  53. mv r4, r8
  54. br r3
  55. .section .fixup, "ax"
  56. 99:
  57. ldi r4, -EFAULT
  58. br r3
  59. .previous
  60. .section __ex_table, "a"
  61. .align 2
  62. .word 0b ,99b
  63. .word 1b ,99b
  64. .word 2b ,99b
  65. .word 3b ,99b
  66. .word 4b ,99b
  67. .word 5b ,99b
  68. .previous
  69. .align 2
  70. ENTRY(__strnlen_user)
  71. cmpi.c r5, 0
  72. ble .L11
  73. 0: lb r6, [r4]
  74. ldi r7, 0
  75. cmp.c r6, r7
  76. beq .L11
  77. .L15:
  78. addi r7, 1
  79. cmp.c r7, r5
  80. beq .L23
  81. 1: lb r6, [r4,1]+
  82. cmpi.c r6, 0
  83. bne .L15
  84. .L23:
  85. addri r4, r7, 1
  86. br r3
  87. .L11:
  88. ldi r4, 1
  89. br r3
  90. .section .fixup, "ax"
  91. 99:
  92. ldi r4, 0
  93. br r3
  94. .section __ex_table,"a"
  95. .align 2
  96. .word 0b, 99b
  97. .word 1b, 99b
  98. .previous
  99. .align 2
  100. ENTRY(__strlen_user)
  101. 0: lb r6, [r4]
  102. mv r7, r4
  103. extsb r6, r6
  104. cmpi.c r6, 0
  105. mv r4, r6
  106. beq .L27
  107. .L28:
  108. 1: lb r6, [r7, 1]+
  109. addi r6, 1
  110. cmpi.c r6, 0
  111. bne .L28
  112. .L27:
  113. br r3
  114. .section .fixup, "ax"
  115. ldi r4, 0x0
  116. br r3
  117. 99:
  118. ldi r4, 0
  119. br r3
  120. .previous
  121. .section __ex_table, "a"
  122. .align 2
  123. .word 0b ,99b
  124. .word 1b ,99b
  125. .previous
  126. .align 2
  127. ENTRY(__copy_tofrom_user)
  128. cmpi.c r6, 0
  129. mv r10,r6
  130. beq .L32
  131. ldi r9, 0
  132. .L34:
  133. add r6, r5, r9
  134. 0: lbu r8, [r6]
  135. add r7, r4, r9
  136. 1: sb r8, [r7]
  137. addi r9, 1
  138. cmp.c r9, r10
  139. bne .L34
  140. .L32:
  141. ldi r4, 0
  142. br r3
  143. .section .fixup, "ax"
  144. 99:
  145. sub r4, r10, r9
  146. br r3
  147. .previous
  148. .section __ex_table, "a"
  149. .align 2
  150. .word 0b, 99b
  151. .word 1b, 99b
  152. .previous
  153. .align 2
  154. ENTRY(__clear_user)
  155. cmpi.c r5, 0
  156. beq .L38
  157. ldi r6, 0
  158. mv r7, r6
  159. .L40:
  160. addi r6, 1
  161. 0: sb r7, [r4]+, 1
  162. cmp.c r6, r5
  163. bne .L40
  164. .L38:
  165. ldi r4, 0
  166. br r3
  167. .section .fixup, "ax"
  168. 99:
  169. br r3
  170. .previous
  171. .section __ex_table, "a"
  172. .align 2
  173. .word 0b, 99b
  174. .previous