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 26#include <linux/linkage.h> 27#include <asm-generic/errno.h> 28 29 .text 30 .align 2 31ENTRY(__strncpy_from_user) 32 cmpi.c r6, 0 33 mv r9, r6 34 ble .L2 350: lbu r7, [r5] 36 ldi r8, 0 371: sb r7, [r4] 382: lb r6, [r5] 39 cmp.c r6, r8 40 beq .L2 41 42.L5: 43 addi r8, 1 44 cmp.c r8, r9 45 beq .L7 463: lbu r6, [r5, 1]+ 474: sb r6, [r4, 1]+ 485: lb r7, [r5] 49 cmpi.c r7, 0 50 bne .L5 51.L7: 52 mv r4, r8 53 br r3 54.L2: 55 ldi r8, 0 56 mv r4, r8 57 br r3 58 .section .fixup, "ax" 5999: 60 ldi r4, -EFAULT 61 br r3 62 .previous 63 .section __ex_table, "a" 64 .align 2 65 .word 0b ,99b 66 .word 1b ,99b 67 .word 2b ,99b 68 .word 3b ,99b 69 .word 4b ,99b 70 .word 5b ,99b 71 .previous 72 73 .align 2 74ENTRY(__strnlen_user) 75 cmpi.c r5, 0 76 ble .L11 770: lb r6, [r4] 78 ldi r7, 0 79 cmp.c r6, r7 80 beq .L11 81.L15: 82 addi r7, 1 83 cmp.c r7, r5 84 beq .L23 851: lb r6, [r4,1]+ 86 cmpi.c r6, 0 87 bne .L15 88.L23: 89 addri r4, r7, 1 90 br r3 91 92.L11: 93 ldi r4, 1 94 br r3 95 .section .fixup, "ax" 9699: 97 ldi r4, 0 98 br r3 99 100 .section __ex_table,"a" 101 .align 2 102 .word 0b, 99b 103 .word 1b, 99b 104 .previous 105 106 .align 2 107ENTRY(__strlen_user) 1080: lb r6, [r4] 109 mv r7, r4 110 extsb r6, r6 111 cmpi.c r6, 0 112 mv r4, r6 113 beq .L27 114.L28: 1151: lb r6, [r7, 1]+ 116 addi r6, 1 117 cmpi.c r6, 0 118 bne .L28 119.L27: 120 br r3 121 .section .fixup, "ax" 122 ldi r4, 0x0 123 br r3 12499: 125 ldi r4, 0 126 br r3 127 .previous 128 .section __ex_table, "a" 129 .align 2 130 .word 0b ,99b 131 .word 1b ,99b 132 .previous 133 134 .align 2 135ENTRY(__copy_tofrom_user) 136 cmpi.c r6, 0 137 mv r10,r6 138 beq .L32 139 ldi r9, 0 140.L34: 141 add r6, r5, r9 1420: lbu r8, [r6] 143 add r7, r4, r9 1441: sb r8, [r7] 145 addi r9, 1 146 cmp.c r9, r10 147 bne .L34 148.L32: 149 ldi r4, 0 150 br r3 151 .section .fixup, "ax" 15299: 153 sub r4, r10, r9 154 br r3 155 .previous 156 .section __ex_table, "a" 157 .align 2 158 .word 0b, 99b 159 .word 1b, 99b 160 .previous 161 162 .align 2 163ENTRY(__clear_user) 164 cmpi.c r5, 0 165 beq .L38 166 ldi r6, 0 167 mv r7, r6 168.L40: 169 addi r6, 1 1700: sb r7, [r4]+, 1 171 cmp.c r6, r5 172 bne .L40 173.L38: 174 ldi r4, 0 175 br r3 176 177 .section .fixup, "ax" 17899: 179 br r3 180 .previous 181 .section __ex_table, "a" 182 .align 2 183 .word 0b, 99b 184 .previous 185