]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - arch/mips/lib/strnlen_user.S
MIPS: Update ip27_defconfig for SCSI_DH change
[mirror_ubuntu-artful-kernel.git] / arch / mips / lib / strnlen_user.S
CommitLineData
1da177e4
LT
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 *
6 * Copyright (c) 1996, 1998, 1999, 2004 by Ralf Baechle
7 * Copyright (c) 1999 Silicon Graphics, Inc.
8 */
9#include <asm/asm.h>
048eb582 10#include <asm/asm-offsets.h>
d6cb6715 11#include <asm/export.h>
1da177e4
LT
12#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/*
25985edc 21 * Return the size of a string including the ending NUL character up to a
1da177e4
LT
22 * maximum of a1 or 0 in case of error.
23 *
24 * Note: for performance reasons we deliberately accept that a user may
70342287
RB
25 * make strlen_user and strnlen_user access the first few KSEG0
26 * bytes. There's nothing secret there. On 64-bit accessing beyond
27 * the maximum is a tad hairier ...
1da177e4 28 */
c48be43e
MC
29 .macro __BUILD_STRNLEN_ASM func
30LEAF(__strnlen_\func\()_asm)
d6cb6715 31EXPORT_SYMBOL(__strnlen_\func\()_asm)
1da177e4
LT
32 LONG_L v0, TI_ADDR_LIMIT($28) # pointer ok?
33 and v0, a0
c48be43e 34 bnez v0, .Lfault\@
1da177e4 35
c48be43e 36FEXPORT(__strnlen_\func\()_nocheck_asm)
d6cb6715 37EXPORT_SYMBOL(__strnlen_\func\()_nocheck_asm)
1da177e4
LT
38 move v0, a0
39 PTR_ADDU a1, a0 # stop pointer
c4fca4fd
MR
401:
41#ifdef CONFIG_CPU_DADDI_WORKAROUNDS
42 .set noat
43 li AT, 1
44#endif
45 beq v0, a1, 1f # limit reached?
4968db4b 46.ifeqs "\func", "kernel"
c48be43e 47 EX(lb, t0, (v0), .Lfault\@)
4968db4b
MC
48.else
49 EX(lbe, t0, (v0), .Lfault\@)
50.endif
00977610 51 .set noreorder
1da177e4 52 bnez t0, 1b
c4fca4fd
MR
531:
54#ifndef CONFIG_CPU_DADDI_WORKAROUNDS
55 PTR_ADDIU v0, 1
56#else
57 PTR_ADDU v0, AT
58 .set at
59#endif
00977610
RB
60 .set reorder
61 PTR_SUBU v0, a0
1da177e4 62 jr ra
c48be43e 63 END(__strnlen_\func\()_asm)
1da177e4 64
c48be43e 65.Lfault\@:
c5ec1983 66 move v0, zero
1da177e4 67 jr ra
c48be43e
MC
68 .endm
69
4968db4b
MC
70#ifndef CONFIG_EVA
71 /* Set aliases */
72 .global __strnlen_user_asm
73 .global __strnlen_user_nocheck_asm
74 .set __strnlen_user_asm, __strnlen_kernel_asm
75 .set __strnlen_user_nocheck_asm, __strnlen_kernel_nocheck_asm
76#endif
77
78__BUILD_STRNLEN_ASM kernel
79
80#ifdef CONFIG_EVA
81
82 .set push
83 .set eva
c48be43e 84__BUILD_STRNLEN_ASM user
4968db4b
MC
85 .set pop
86#endif