2 * This file is part of OMAP DSP driver (DSP Gateway version 3.3.1)
4 * Copyright (C) 2002-2006 Nokia Corporation. All rights reserved.
6 * Contact: Toshihiro Kobayashi <toshihiro.kobayashi@nokia.com>
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * version 2 as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * 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., 51 Franklin St, Fifth Floor, Boston, MA
24 #ifndef _OMAP_DSP_UACCESS_DSP_H
25 #define _OMAP_DSP_UACCESS_DSP_H
27 #include <asm/uaccess.h>
28 #include <asm/arch/dsp_common.h>
31 #define HAVE_ASM_COPY_FROM_USER_DSP_2B
33 #ifdef HAVE_ASM_COPY_FROM_USER_DSP_2B
34 extern unsigned long __copy_from_user_dsp_2b(void *to,
35 const void __user *from);
36 extern unsigned long __copy_to_user_dsp_2b(void __user *to,
40 #ifndef HAVE_ASM_COPY_FROM_USER_DSP_2B
41 static inline unsigned long copy_from_user_dsp_2b(void *to,
46 if (__copy_from_user(&tmp, from, 2))
48 /* expecting compiler to generate "strh" instruction */
49 *((unsigned short *)to) = tmp;
55 * @n must be multiple of 2
57 static inline unsigned long copy_from_user_dsp(void *to, const void *from,
60 if (access_ok(VERIFY_READ, from, n)) {
61 if ((is_dsp_internal_mem(to)) &&
62 (((unsigned long)to & 2) || (n & 2))) {
64 * DARAM/SARAM with odd word alignment
69 /* dest not aligned -- copy 2 bytes */
70 if (((unsigned long)to & 2) && (n >= 2)) {
71 #ifdef HAVE_ASM_COPY_FROM_USER_DSP_2B
72 if (__copy_from_user_dsp_2b(to, from))
74 if (copy_from_user_dsp_2b(to, from))
81 /* middle 4*n bytes */
84 if ((n = __copy_from_user(to, from, n4)) != 0)
90 #ifdef HAVE_ASM_COPY_FROM_USER_DSP_2B
91 if (__copy_from_user_dsp_2b(to, from))
93 if (copy_from_user_dsp_2b(to, from))
100 * DARAM/SARAM with 4-byte alignment or
103 n = __copy_from_user(to, from, n);
106 else /* security hole - plug it */
111 #ifndef HAVE_ASM_COPY_FROM_USER_DSP_2B
112 static inline unsigned long copy_to_user_dsp_2b(void *to, const void *from)
114 /* expecting compiler to generate "strh" instruction */
115 unsigned short tmp = *(unsigned short *)from;
117 return __copy_to_user(to, &tmp, 2);
122 * @n must be multiple of 2
124 static inline unsigned long copy_to_user_dsp(void *to, const void *from,
127 if (access_ok(VERIFY_WRITE, to, n)) {
128 if ((is_dsp_internal_mem(from)) &&
129 (((unsigned long)to & 2) || (n & 2))) {
131 * DARAM/SARAM with odd word alignment
134 unsigned long last_n;
136 /* dest not aligned -- copy 2 bytes */
137 if (((unsigned long)to & 2) && (n >= 2)) {
138 #ifdef HAVE_ASM_COPY_FROM_USER_DSP_2B
139 if (__copy_to_user_dsp_2b(to, from))
141 if (copy_to_user_dsp_2b(to, from))
148 /* middle 4*n bytes */
151 if ((n = __copy_to_user(to, from, n4)) != 0)
157 #ifdef HAVE_ASM_COPY_FROM_USER_DSP_2B
158 if (__copy_to_user_dsp_2b(to, from))
160 if (copy_to_user_dsp_2b(to, from))
167 * DARAM/SARAM with 4-byte alignment or
170 n = __copy_to_user(to, from, n);
176 #endif /* _OMAP_DSP_UACCESS_DSP_H */