Path: blob/master/arch/microblaze/lib/uaccess_old.S
10817 views
/*1* Copyright (C) 2009 Michal Simek <[email protected]>2* Copyright (C) 2009 PetaLogix3* Copyright (C) 2007 LynuxWorks, Inc.4*5* This file is subject to the terms and conditions of the GNU General Public6* License. See the file "COPYING" in the main directory of this archive7* for more details.8*/910#include <linux/errno.h>11#include <linux/linkage.h>1213/*14* int __strncpy_user(char *to, char *from, int len);15*16* Returns:17* -EFAULT for an exception18* len if we hit the buffer limit19* bytes copied20*/2122.text23.globl __strncpy_user;24.type __strncpy_user, @function25.align 4;26__strncpy_user:2728/*29* r5 - to30* r6 - from31* r7 - len32* r3 - temp count33* r4 - temp val34*/35addik r3,r7,0 /* temp_count = len */36beqi r3,3f371:38lbu r4,r6,r039sb r4,r5,r04041addik r3,r3,-142beqi r3,2f /* break on len */4344addik r5,r5,145bneid r4,1b46addik r6,r6,1 /* delay slot */47addik r3,r3,1 /* undo "temp_count--" */482:49rsubk r3,r3,r7 /* temp_count = len - temp_count */503:51rtsd r15,852nop53.size __strncpy_user, . - __strncpy_user5455.section .fixup, "ax"56.align 2574:58brid 3b59addik r3,r0, -EFAULT6061.section __ex_table, "a"62.word 1b,4b6364/*65* int __strnlen_user(char __user *str, int maxlen);66*67* Returns:68* 0 on error69* maxlen + 1 if no NUL byte found within maxlen bytes70* size of the string (including NUL byte)71*/7273.text74.globl __strnlen_user;75.type __strnlen_user, @function76.align 4;77__strnlen_user:78addik r3,r6,079beqi r3,3f801:81lbu r4,r5,r082beqid r4,2f /* break on NUL */83addik r3,r3,-1 /* delay slot */8485bneid r3,1b86addik r5,r5,1 /* delay slot */8788addik r3,r3,-1 /* for break on len */892:90rsubk r3,r3,r6913:92rtsd r15,893nop94.size __strnlen_user, . - __strnlen_user9596.section .fixup,"ax"974:98brid 3b99addk r3,r0,r0100101.section __ex_table,"a"102.word 1b,4b103104/*105* int __copy_tofrom_user(char *to, char *from, int len)106* Return:107* 0 on success108* number of not copied bytes on error109*/110.text111.globl __copy_tofrom_user;112.type __copy_tofrom_user, @function113.align 4;114__copy_tofrom_user:115/*116* r5 - to117* r6 - from118* r7, r3 - count119* r4 - tempval120*/121beqid r7, 3f /* zero size is not likely */122andi r3, r7, 0x3 /* filter add count */123bneid r3, 4f /* if is odd value then byte copying */124or r3, r5, r6 /* find if is any to/from unaligned */125andi r3, r3, 0x3 /* mask unaligned */126bneid r3, 1f /* it is unaligned -> then jump */127or r3, r0, r0128129/* at least one 4 byte copy */1305: lw r4, r6, r31316: sw r4, r5, r3132addik r7, r7, -4133bneid r7, 5b134addik r3, r3, 4135addik r3, r7, 0136rtsd r15, 8137nop1384: or r3, r0, r01391: lbu r4,r6,r31402: sb r4,r5,r3141addik r7,r7,-1142bneid r7,1b143addik r3,r3,1 /* delay slot */1443:145addik r3,r7,0146rtsd r15,8147nop148.size __copy_tofrom_user, . - __copy_tofrom_user149150.section __ex_table,"a"151.word 1b,3b,2b,3b,5b,3b,6b,3b152153154