Back to home page

OSCL-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  */
0009 #include <asm/asm.h>
0010 #include <asm/asm-offsets.h>
0011 #include <asm/export.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_WD  9b, handler;                \
0018     .previous
0019 
0020 /*
0021  * Return the size of a string including the ending NUL character up to a
0022  * maximum of a1 or 0 in case of error.
0023  *
0024  * Note: for performance reasons we deliberately accept that a user may
0025  *   make strlen_user and strnlen_user access the first few KSEG0
0026  *   bytes.  There's nothing secret there.  On 64-bit accessing beyond
0027  *   the maximum is a tad hairier ...
0028  */
0029 LEAF(__strnlen_user_asm)
0030     move        v0, a0
0031     PTR_ADDU    a1, a0          # stop pointer
0032 1:
0033 #ifdef CONFIG_CPU_DADDI_WORKAROUNDS
0034     .set        noat
0035     li      AT, 1
0036 #endif
0037     beq     v0, a1, 1f      # limit reached?
0038 #ifdef CONFIG_EVA
0039     .set push
0040     .set eva
0041     EX(lbe, t0, (v0), .Lfault)
0042     .set pop
0043 #else
0044     EX(lb, t0, (v0), .Lfault)
0045 #endif
0046     .set        noreorder
0047     bnez        t0, 1b
0048 1:
0049 #ifndef CONFIG_CPU_DADDI_WORKAROUNDS
0050      PTR_ADDIU  v0, 1
0051 #else
0052      PTR_ADDU   v0, AT
0053     .set        at
0054 #endif
0055     .set        reorder
0056     PTR_SUBU    v0, a0
0057     jr      ra
0058     END(__strnlen_user_asm)
0059 
0060 .Lfault:
0061     move        v0, zero
0062     jr      ra
0063 
0064     EXPORT_SYMBOL(__strnlen_user_asm)