blob: e362dcdc69d1617486ee5627f055ffc3075b5548 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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. Hillb1bac372013-03-25 13:41:47 -05006 * Copyright (C) 1996, 1998, 1999, 2004 by Ralf Baechle
7 * Copyright (C) 1999 Silicon Graphics, Inc.
8 * Copyright (C) 2011 MIPS Technologies, Inc.
Linus Torvalds1da177e2005-04-16 15:20:36 -07009 */
10#include <asm/asm.h>
Sam Ravnborg048eb582005-09-09 22:32:31 +020011#include <asm/asm-offsets.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070012#include <asm/regdef.h>
13
14#define EX(insn,reg,addr,handler) \
159: 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 */
25LEAF(__strlen_user_asm)
26 LONG_L v0, TI_ADDR_LIMIT($28) # pointer ok?
27 and v0, a0
Ralf Baechlec5ec1982008-01-29 10:14:59 +000028 bnez v0, .Lfault
Linus Torvalds1da177e2005-04-16 15:20:36 -070029
30FEXPORT(__strlen_user_nocheck_asm)
31 move v0, a0
Steven J. Hillb1bac372013-03-25 13:41:47 -0500321: EX(lbu, v1, (v0), .Lfault)
Linus Torvalds1da177e2005-04-16 15:20:36 -070033 PTR_ADDIU v0, 1
Steven J. Hillb1bac372013-03-25 13:41:47 -050034 bnez v1, 1b
Linus Torvalds1da177e2005-04-16 15:20:36 -070035 PTR_SUBU v0, a0
36 jr ra
37 END(__strlen_user_asm)
38
Ralf Baechlec5ec1982008-01-29 10:14:59 +000039.Lfault: move v0, zero
Linus Torvalds1da177e2005-04-16 15:20:36 -070040 jr ra