Ok. I didn't make 2.4.0 in 2000. Tough. I tried, but we had some
[davej-history.git] / arch / mips / lib / strncpy_user.S
blob9c8e0ab85405388e0a9af37ef1411e3123662e2d
1 /* $Id: strncpy_user.S,v 1.3 1999/08/21 22:19:11 ralf Exp $
2  *
3  * This file is subject to the terms and conditions of the GNU General Public
4  * License.  See the file "COPYING" in the main directory of this archive
5  * for more details.
6  *
7  * Copyright (c) 1996, 1999 by Ralf Baechle
8  */
9 #include <linux/errno.h>
10 #include <asm/asm.h>
11 #include <asm/offset.h>
12 #include <asm/regdef.h>
14 #define EX(insn,reg,addr,handler)                       \
15 9:      insn    reg, addr;                              \
16         .section __ex_table,"a";                        \
17         PTR     9b, handler;                            \
18         .previous
21  * Returns: -EFAULT if exception before terminator, N if the entire
22  * buffer filled, else strlen.
23  */
26  * Ugly special case have to check: we might get passed a user space
27  * pointer which wraps into the kernel space.  We don't deal with that.  If
28  * it happens at most some bytes of the exceptions handlers will be copied.
29  */
31 LEAF(__strncpy_from_user_asm)
32         lw      v0, THREAD_CURDS($28)   # pointer ok?
33         and     v0, a1
34         bltz    v0, fault
36 EXPORT(__strncpy_from_user_nocheck_asm)
37         move    v0, zero
38         move    v1, a1
39         .set    noreorder
40 1:      EX(lbu,  t0, (v1), fault)
41         addiu   v1, v1, 1
42         beqz    t0, 2f
43          sb     t0, (a0)
44         addiu   v0, 1
45         bne     v0, a2, 1b
46          addiu  a0, 1
47         .set    reorder
48 2:      addu    t0, a1, v0
49         xor     t0, a1
50         bltz    t0, fault
51         jr      ra                              # return n
52         END(__strncpy_from_user_asm)
54 fault:  li      v0, -EFAULT
55         jr      ra
57         .section __ex_table,"a"
58         PTR     1b, fault
59         .previous