Path: blob/master/arch/unicore32/lib/strncpy_from_user.S
10817 views
/*1* linux/arch/unicore32/lib/strncpy_from_user.S2*3* Code specific to PKUnity SoC and UniCore ISA4*5* Copyright (C) 2001-2010 GUAN Xue-tao6*7* This program is free software; you can redistribute it and/or modify8* it under the terms of the GNU General Public License version 2 as9* published by the Free Software Foundation.10*/11#include <linux/linkage.h>12#include <asm/assembler.h>13#include <asm/errno.h>1415.text16.align 51718/*19* Copy a string from user space to kernel space.20* r0 = dst, r1 = src, r2 = byte length21* returns the number of characters copied (strlen of copied string),22* -EFAULT on exception, or "len" if we fill the whole buffer23*/24ENTRY(__strncpy_from_user)25mov ip, r1261: sub.a r2, r2, #127ldrusr r3, r1, 1, ns28bfs 2f29stb.w r3, [r0]+, #130cxor.a r3, #031bne 1b32sub r1, r1, #1 @ take NUL character out of count332: sub r0, r1, ip34mov pc, lr35ENDPROC(__strncpy_from_user)3637.pushsection .fixup,"ax"38.align 0399001: mov r3, #040stb r3, [r0+], #0 @ null terminate41mov r0, #-EFAULT42mov pc, lr43.popsection44454647