/*1* This file is subject to the terms and conditions of the GNU General Public2* License. See the file "COPYING" in the main directory of this archive3* for more details.4*5* Copyright (c) 1996, 1998, 1999, 2004 by Ralf Baechle6* Copyright (c) 1999 Silicon Graphics, Inc.7*/8#include <asm/asm.h>9#include <asm/asm-offsets.h>10#include <asm/regdef.h>1112#define EX(insn,reg,addr,handler) \139: insn reg, addr; \14.section __ex_table,"a"; \15PTR 9b, handler; \16.previous1718/*19* Return the size of a string including the ending NUL character up to a20* maximum of a1 or 0 in case of error.21*22* Note: for performance reasons we deliberately accept that a user may23* make strlen_user and strnlen_user access the first few KSEG024* bytes. There's nothing secret there. On 64-bit accessing beyond25* the maximum is a tad hairier ...26*/27LEAF(__strnlen_user_asm)28LONG_L v0, TI_ADDR_LIMIT($28) # pointer ok?29and v0, a030bnez v0, .Lfault3132FEXPORT(__strnlen_user_nocheck_asm)33move v0, a034PTR_ADDU a1, a0 # stop pointer351: beq v0, a1, 1f # limit reached?36EX(lb, t0, (v0), .Lfault)37PTR_ADDU v0, 138bnez t0, 1b391: PTR_SUBU v0, a040jr ra41END(__strnlen_user_asm)4243.Lfault:44move v0, zero45jr ra464748