diff options
author | Ralf Baechle <ralf@linux-mips.org> | 1999-12-04 03:58:56 +0000 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 1999-12-04 03:58:56 +0000 |
commit | 1d67e90f19a7acfd9a05dc59678e7d0c5090bd0d (patch) | |
tree | 357efc7b93f8f5102110d20d293f41360ec212fc /arch/mips/lib | |
parent | aea27b2e18d69af87e673972246e66657b4fa274 (diff) |
Merge with Linux 2.3.21.
Diffstat (limited to 'arch/mips/lib')
-rw-r--r-- | arch/mips/lib/Makefile | 5 | ||||
-rw-r--r-- | arch/mips/lib/strlen_user.S | 33 | ||||
-rw-r--r-- | arch/mips/lib/strncpy_user.S | 47 | ||||
-rw-r--r-- | arch/mips/lib/strnlen_user.S | 54 |
4 files changed, 96 insertions, 43 deletions
diff --git a/arch/mips/lib/Makefile b/arch/mips/lib/Makefile index 59c711647..604847280 100644 --- a/arch/mips/lib/Makefile +++ b/arch/mips/lib/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.10 1999/10/12 17:33:49 harald Exp $ +# $Id: Makefile,v 1.11 1999/10/17 19:55:22 harald Exp $ # # Makefile for MIPS-specific library files.. # @@ -11,7 +11,8 @@ L_TARGET = lib.a L_OBJS = csum_partial.o csum_partial_copy.o floppy-std.o \ floppy-no.o ide-std.o ide-no.o kbd-std.o kbd-no.o rtc-std.o \ - rtc-no.o memset.o memcpy.o strlen_user.o strncpy_user.o watch.o + rtc-no.o memcpy.o memset.o strlen_user.o strncpy_user.o \ + strnlen_user.o watch.o ifdef CONFIG_CPU_R3000 L_OBJS += r3k_dump_tlb.o diff --git a/arch/mips/lib/strlen_user.S b/arch/mips/lib/strlen_user.S index a19e89d3c..0902817c0 100644 --- a/arch/mips/lib/strlen_user.S +++ b/arch/mips/lib/strlen_user.S @@ -1,4 +1,4 @@ -/* $Id: strlen_user.S,v 1.2 1998/05/04 09:12:54 ralf Exp $ +/* $Id: strlen_user.S,v 1.3 1999/08/21 22:19:11 ralf Exp $ * * This file is subject to the terms and conditions of the GNU General Public * License. See the file "COPYING" in the main directory of this archive @@ -23,24 +23,23 @@ * * Return 0 for error */ -LEAF(__strlen_user_nocheck_asm) - LONG_L v0, THREAD_CURDS($28) # pointer ok? - LONG_SUBU v0, zero, v0 - and v0, a0 - not v0 - beqz v0, fault -EXPORT(__strlen_user_asm) - move v0, a0 +LEAF(__strlen_user_asm) + lw v0, THREAD_CURDS($28) # pointer ok? + and v0, a0 + bltz v0, fault + +EXPORT(__strlen_user_nocheck_asm) + move v0, a0 1: EX(lb, t0, (v0), fault) - LONG_ADDIU v0, 1 - bnez t0, 1b - LONG_SUBU v0, a0 - jr ra + addiu v0, 1 + bnez t0, 1b + subu v0, a0 + jr ra END(__strlen_user_nocheck_asm) - .section __ex_table,"a" - PTR 1b, fault + .section __ex_table,"a" + PTR 1b, fault .previous -fault: move v0, zero - jr ra +fault: move v0, zero + jr ra diff --git a/arch/mips/lib/strncpy_user.S b/arch/mips/lib/strncpy_user.S index 231ff8c9d..9c8e0ab85 100644 --- a/arch/mips/lib/strncpy_user.S +++ b/arch/mips/lib/strncpy_user.S @@ -1,4 +1,4 @@ -/* $Id: strncpy_user.S,v 1.2 1998/05/04 09:12:54 ralf Exp $ +/* $Id: strncpy_user.S,v 1.3 1999/08/21 22:19:11 ralf Exp $ * * This file is subject to the terms and conditions of the GNU General Public * License. See the file "COPYING" in the main directory of this archive @@ -29,32 +29,31 @@ */ LEAF(__strncpy_from_user_asm) - LONG_L v0, THREAD_CURDS($28) # pointer ok? - LONG_SUBU v0, zero, v0 - and v0, a1 - not v0 - beqz v0, fault + lw v0, THREAD_CURDS($28) # pointer ok? + and v0, a1 + bltz v0, fault + EXPORT(__strncpy_from_user_nocheck_asm) - move v0,zero - move v1,a1 - .set noreorder + move v0, zero + move v1, a1 + .set noreorder 1: EX(lbu, t0, (v1), fault) - LONG_ADDIU v1,1 - beqz t0,2f - sb t0,(a0) - LONG_ADDIU v0,1 - bne v0,a2,1b - LONG_ADDIU a0,1 - .set reorder -2: LONG_ADDU t0,a1,v0 - xor t0,a1 - bltz t0,fault - jr ra # return n + addiu v1, v1, 1 + beqz t0, 2f + sb t0, (a0) + addiu v0, 1 + bne v0, a2, 1b + addiu a0, 1 + .set reorder +2: addu t0, a1, v0 + xor t0, a1 + bltz t0, fault + jr ra # return n END(__strncpy_from_user_asm) -fault: li v0, -EFAULT - jr ra +fault: li v0, -EFAULT + jr ra - .section __ex_table,"a" - PTR 1b, fault + .section __ex_table,"a" + PTR 1b, fault .previous diff --git a/arch/mips/lib/strnlen_user.S b/arch/mips/lib/strnlen_user.S new file mode 100644 index 000000000..0ae411834 --- /dev/null +++ b/arch/mips/lib/strnlen_user.S @@ -0,0 +1,54 @@ +/* $Id: strnlen_user.S,v 1.2 1999/11/19 20:35:21 ralf Exp $ + * + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file "COPYING" in the main directory of this archive + * for more details. + * + * Copyright (c) 1996, 1998, 1999 by Ralf Baechle + * Copyright (c) 1999 Silicon Graphics, Inc. + */ +#include <asm/asm.h> +#include <asm/offset.h> +#include <asm/regdef.h> +#include <asm/sgidefs.h> + +#define EX(insn,reg,addr,handler) \ +9: insn reg, addr; \ + .section __ex_table,"a"; \ + PTR 9b, handler; \ + .previous + +/* + * Return the size of a string (including the ending 0) + * + * Return 0 for error, len of string but at max a1 otherwise + * + * Note: for performance reasons we deliberately accept that a user may + * make strlen_user and strnlen_user access the first few KSEG0 + * bytes. There's nothing secret there ... + */ +LEAF(__strnlen_user_asm) + lw v0, THREAD_CURDS($28) # pointer ok? + and v0, a0 + bltz v0, fault + +EXPORT(__strnlen_user_nocheck_asm) + .type __strnlen_user_nocheck_asm,@function + move v0, a0 + addu a1, a0 # stop pointer + .set noreorder +1: beq v0, a1, 1f # limit reached? + addiu v0, 1 + .set reorder + EX(lb, t0, -1(v0), fault) + bnez t0, 1b +1: subu v0, a0 + jr ra + END(__strnlen_user_asm) + + .section __ex_table,"a" + PTR 1b, fault + .previous + +fault: move v0, zero + jr ra |