4 * Linux architectural port borrowing liberally from similar works of
5 * others. All original copyrights apply as per the original source
8 * Modifications for the OpenRISC architecture:
9 * Copyright (C) 2003 Matjaz Breskvar <phoenix@bsemi.com>
10 * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se>
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version
15 * 2 of the License, or (at your option) any later version.
18 #include <linux/linkage.h>
19 #include <asm/errno.h>
22 * this can be optimized by doing gcc inline assemlby with
23 * proper constraints (no need to save args registers...)
30 * int __copy_tofrom_user(void *to, const void *from, unsigned long size);
32 * NOTE: it returns number of bytes NOT copied !!!
35 .global __copy_tofrom_user
52 l.addi r11,r11,1 // r11 holds the return value
66 .section __ex_table, "a"
67 .long 8b, 99b // read fault
68 .long 9b, 99b // write fault
72 * unsigned long clear_user(void *addr, unsigned long size) ;
74 * NOTE: it returns number of bytes NOT cleared !!!
103 .section __ex_table, "a"
104 .long 9b, 99b // write fault
108 * long strncpy_from_user(char *dst, const char *src, long count)
112 .global __strncpy_from_user
134 l.sub r11,r11,r5 // r11 holds the return value
143 .section .fixup, "ax"
145 l.movhi r11,hi(-EFAULT)
146 l.ori r11,r11,lo(-EFAULT)
156 .section __ex_table, "a"
157 .long 8b, 99b // read fault
161 * extern int __strnlen_user(const char *str, long len, unsigned long top);
164 * RTRN: - length of a string including NUL termination character
168 .global __strnlen_user
181 l.sfgeu r3,r5 // are we over the top ?
192 .section .fixup, "ax"
202 .section __ex_table, "a"
203 .long 8b, 99b // read fault