Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
[cris-mirror.git] / arch / parisc / lib / memcpy.c
blob865a7f796c7fbf8ae817786451a4d78a48c8cb46
1 /*
2 * Optimized memory copy routines.
4 * Copyright (C) 2004 Randolph Chung <tausq@debian.org>
5 * Copyright (C) 2013-2017 Helge Deller <deller@gmx.de>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
10 * any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 * Portions derived from the GNU C Library
22 * Copyright (C) 1991, 1997, 2003 Free Software Foundation, Inc.
26 #include <linux/module.h>
27 #include <linux/compiler.h>
28 #include <linux/uaccess.h>
30 #define get_user_space() (uaccess_kernel() ? 0 : mfsp(3))
31 #define get_kernel_space() (0)
33 /* Returns 0 for success, otherwise, returns number of bytes not transferred. */
34 extern unsigned long pa_memcpy(void *dst, const void *src,
35 unsigned long len);
37 unsigned long raw_copy_to_user(void __user *dst, const void *src,
38 unsigned long len)
40 mtsp(get_kernel_space(), 1);
41 mtsp(get_user_space(), 2);
42 return pa_memcpy((void __force *)dst, src, len);
44 EXPORT_SYMBOL(raw_copy_to_user);
46 unsigned long raw_copy_from_user(void *dst, const void __user *src,
47 unsigned long len)
49 mtsp(get_user_space(), 1);
50 mtsp(get_kernel_space(), 2);
51 return pa_memcpy(dst, (void __force *)src, len);
53 EXPORT_SYMBOL(raw_copy_from_user);
55 unsigned long raw_copy_in_user(void __user *dst, const void __user *src, unsigned long len)
57 mtsp(get_user_space(), 1);
58 mtsp(get_user_space(), 2);
59 return pa_memcpy((void __force *)dst, (void __force *)src, len);
63 void * memcpy(void * dst,const void *src, size_t count)
65 mtsp(get_kernel_space(), 1);
66 mtsp(get_kernel_space(), 2);
67 pa_memcpy(dst, src, count);
68 return dst;
71 EXPORT_SYMBOL(raw_copy_in_user);
72 EXPORT_SYMBOL(memcpy);
74 long probe_kernel_read(void *dst, const void *src, size_t size)
76 unsigned long addr = (unsigned long)src;
78 if (addr < PAGE_SIZE)
79 return -EFAULT;
81 /* check for I/O space F_EXTEND(0xfff00000) access as well? */
83 return __probe_kernel_read(dst, src, size);