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
6 * Copyright (C) 1996, 1999 by Ralf Baechle
7 * Copyright (C) 2011 MIPS Technologies, Inc.
9 #include <linux/errno.h>
11 #include <asm/asm-offsets.h>
12 #include <asm/regdef.h>
14 #define EX(insn,reg,addr,handler) \
16 .section __ex_table,"a"; \
21 * Returns: -EFAULT if exception before terminator, N if the entire
22 * buffer filled, else strlen.
26 * Ugly special case have to check: we might get passed a user space
27 * pointer which wraps into the kernel space. We don't deal with that. If
28 * it happens at most some bytes of the exceptions handlers will be copied.
31 .macro __BUILD_STRNCPY_ASM func
32 LEAF(__strncpy_from_\func\()_asm)
33 LONG_L v0, TI_ADDR_LIMIT($28) # pointer ok?
37 FEXPORT(__strncpy_from_\func\()_nocheck_asm)
40 .ifeqs "\func","kernel"
41 1: EX(lbu, v0, (v1), .Lfault\@)
43 1: EX(lbue, v0, (v1), .Lfault\@)
52 2: PTR_ADDU v0, a1, t0
57 END(__strncpy_from_\func\()_asm)
63 .section __ex_table,"a"
71 .global __strncpy_from_user_asm
72 .global __strncpy_from_user_nocheck_asm
73 .set __strncpy_from_user_asm, __strncpy_from_kernel_asm
74 .set __strncpy_from_user_nocheck_asm, __strncpy_from_kernel_nocheck_asm
77 __BUILD_STRNCPY_ASM kernel
82 __BUILD_STRNCPY_ASM user