Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * This file is subject to the terms and conditions of the GNU General Public |
| 3 | * License. See the file "COPYING" in the main directory of this archive |
| 4 | * for more details. |
| 5 | * |
Steven J. Hill | b1bac37 | 2013-03-25 13:41:47 -0500 | [diff] [blame] | 6 | * Copyright (C) 1996, 1998, 1999, 2004 by Ralf Baechle |
| 7 | * Copyright (C) 1999 Silicon Graphics, Inc. |
| 8 | * Copyright (C) 2011 MIPS Technologies, Inc. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | */ |
| 10 | #include <asm/asm.h> |
Sam Ravnborg | 048eb58 | 2005-09-09 22:32:31 +0200 | [diff] [blame] | 11 | #include <asm/asm-offsets.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | #include <asm/regdef.h> |
| 13 | |
| 14 | #define EX(insn,reg,addr,handler) \ |
| 15 | 9: insn reg, addr; \ |
| 16 | .section __ex_table,"a"; \ |
| 17 | PTR 9b, handler; \ |
| 18 | .previous |
| 19 | |
| 20 | /* |
| 21 | * Return the size of a string (including the ending 0) |
| 22 | * |
| 23 | * Return 0 for error |
| 24 | */ |
| 25 | LEAF(__strlen_user_asm) |
| 26 | LONG_L v0, TI_ADDR_LIMIT($28) # pointer ok? |
| 27 | and v0, a0 |
Ralf Baechle | c5ec198 | 2008-01-29 10:14:59 +0000 | [diff] [blame] | 28 | bnez v0, .Lfault |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | |
| 30 | FEXPORT(__strlen_user_nocheck_asm) |
| 31 | move v0, a0 |
Steven J. Hill | b1bac37 | 2013-03-25 13:41:47 -0500 | [diff] [blame] | 32 | 1: EX(lbu, v1, (v0), .Lfault) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | PTR_ADDIU v0, 1 |
Steven J. Hill | b1bac37 | 2013-03-25 13:41:47 -0500 | [diff] [blame] | 34 | bnez v1, 1b |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | PTR_SUBU v0, a0 |
| 36 | jr ra |
| 37 | END(__strlen_user_asm) |
| 38 | |
Ralf Baechle | c5ec198 | 2008-01-29 10:14:59 +0000 | [diff] [blame] | 39 | .Lfault: move v0, zero |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | jr ra |