/*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, 1999 by Ralf Baechle6* Copyright (C) 2011 MIPS Technologies, Inc.7*/8#include <linux/errno.h>9#include <linux/export.h>10#include <asm/asm.h>11#include <asm/asm-offsets.h>12#include <asm/regdef.h>1314#define EX(insn,reg,addr,handler) \159: insn reg, addr; \16.section __ex_table,"a"; \17PTR_WD 9b, handler; \18.previous1920/*21* Returns: -EFAULT if exception before terminator, N if the entire22* buffer filled, else strlen.23*/2425/*26* Ugly special case have to check: we might get passed a user space27* pointer which wraps into the kernel space. We don't deal with that. If28* it happens at most some bytes of the exceptions handlers will be copied.29*/3031LEAF(__strncpy_from_user_asm)32move t0, zero33move v1, a134#ifdef CONFIG_EVA35.set push36.set eva371: EX(lbue, v0, (v1), .Lfault)38.set pop39#else401: EX(lbu, v0, (v1), .Lfault)41#endif42PTR_ADDIU v1, 143R10KCBARRIER(0(ra))44sb v0, (a0)45beqz v0, 2f46PTR_ADDIU t0, 147PTR_ADDIU a0, 148bne t0, a2, 1b492: PTR_ADDU v0, a1, t050xor v0, a151bltz v0, .Lfault52move v0, t053jr ra # return n54END(__strncpy_from_user_asm)5556.Lfault:57li v0, -EFAULT58jr ra5960.section __ex_table,"a"61PTR_WD 1b, .Lfault62.previous6364EXPORT_SYMBOL(__strncpy_from_user_asm)656667