/* SPDX-License-Identifier: GPL-2.0-or-later */1/*2* OpenRISC string.S3*4* Linux architectural port borrowing liberally from similar works of5* others. All original copyrights apply as per the original source6* declaration.7*8* Modifications for the OpenRISC architecture:9* Copyright (C) 2003 Matjaz Breskvar <[email protected]>10* Copyright (C) 2010-2011 Jonas Bonn <[email protected]>11*/1213#include <linux/linkage.h>14#include <asm/errno.h>1516/*17* this can be optimized by doing gcc inline assemlby with18* proper constraints (no need to save args registers...)19*20*/212223/*24*25* int __copy_tofrom_user(void *to, const void *from, unsigned long size);26*27* NOTE: it returns number of bytes NOT copied !!!28*29*/30.global __copy_tofrom_user31__copy_tofrom_user:32l.addi r1,r1,-1233l.sw 0(r1),r634l.sw 4(r1),r435l.sw 8(r1),r33637l.addi r11,r5,0382: l.sfeq r11,r039l.bf 1f40l.addi r11,r11,-1418: l.lbz r6,0(r4)429: l.sb 0(r3),r643l.addi r3,r3,144l.j 2b45l.addi r4,r4,1461:47l.addi r11,r11,1 // r11 holds the return value4849l.lwz r6,0(r1)50l.lwz r4,4(r1)51l.lwz r3,8(r1)52l.jr r953l.addi r1,r1,125455.section .fixup, "ax"5699:57l.j 1b58l.nop59.previous6061.section __ex_table, "a"62.long 8b, 99b // read fault63.long 9b, 99b // write fault64.previous6566/*67* unsigned long clear_user(void *addr, unsigned long size) ;68*69* NOTE: it returns number of bytes NOT cleared !!!70*/71.global __clear_user72__clear_user:73l.addi r1,r1,-874l.sw 0(r1),r475l.sw 4(r1),r376772: l.sfeq r4,r078l.bf 1f79l.addi r4,r4,-1809: l.sb 0(r3),r081l.j 2b82l.addi r3,r3,183841:85l.addi r11,r4,18687l.lwz r4,0(r1)88l.lwz r3,4(r1)89l.jr r990l.addi r1,r1,89192.section .fixup, "ax"9399:94l.j 1b95l.nop96.previous9798.section __ex_table, "a"99.long 9b, 99b // write fault100.previous101102103