Back to home page

LXR

 
 

    


0001 /*
0002  * This file is subject to the terms and conditions of the GNU General Public
0003  * License.  See the file "COPYING" in the main directory of this archive
0004  * for more details.
0005  *
0006  * Copyright (C) 1996, 1998, 1999, 2004 by Ralf Baechle
0007  * Copyright (C) 1999 Silicon Graphics, Inc.
0008  * Copyright (C) 2011 MIPS Technologies, Inc.
0009  */
0010 #include <asm/asm.h>
0011 #include <asm/asm-offsets.h>
0012 #include <asm/regdef.h>
0013 
0014 #define EX(insn,reg,addr,handler)           \
0015 9:  insn    reg, addr;              \
0016     .section __ex_table,"a";            \
0017     PTR 9b, handler;                \
0018     .previous
0019 
0020 /*
0021  * Return the size of a string (including the ending 0)
0022  *
0023  * Return 0 for error
0024  */
0025     .macro __BUILD_STRLEN_ASM func
0026 LEAF(__strlen_\func\()_asm)
0027     LONG_L      v0, TI_ADDR_LIMIT($28)  # pointer ok?
0028     and     v0, a0
0029     bnez        v0, .Lfault\@
0030 
0031     move        v0, a0
0032 .ifeqs "\func", "kernel"
0033 1:  EX(lbu, v1, (v0), .Lfault\@)
0034 .else
0035 1:  EX(lbue, v1, (v0), .Lfault\@)
0036 .endif
0037     PTR_ADDIU   v0, 1
0038     bnez        v1, 1b
0039     PTR_SUBU    v0, a0
0040     jr      ra
0041     END(__strlen_\func\()_asm)
0042 
0043 .Lfault\@:  move        v0, zero
0044     jr      ra
0045     .endm
0046 
0047 #ifndef CONFIG_EVA
0048     /* Set aliases */
0049     .global __strlen_user_asm
0050     .set __strlen_user_asm, __strlen_kernel_asm
0051 #endif
0052 
0053 __BUILD_STRLEN_ASM kernel
0054 
0055 #ifdef CONFIG_EVA
0056 
0057     .set push
0058     .set eva
0059 __BUILD_STRLEN_ASM user
0060     .set pop
0061 #endif