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 "dsp_common.h"
30 #define HAVE_ASM_COPY_FROM_USER_DSP_2B
32 #ifdef HAVE_ASM_COPY_FROM_USER_DSP_2B
33 extern unsigned long __copy_from_user_dsp_2b(void *to,
34 const void __user *from);
35 extern unsigned long __copy_to_user_dsp_2b(void __user *to,
39 #ifndef HAVE_ASM_COPY_FROM_USER_DSP_2B
40 static __inline__ unsigned long copy_from_user_dsp_2b(void *to,
45 if (__copy_from_user(&tmp, from, 2))
47 /* expecting compiler to generate "strh" instruction */
48 *((unsigned short *)to) = tmp;
54 * @n must be multiple of 2
56 static __inline__ unsigned long copy_from_user_dsp(void *to, const void *from,
59 if (access_ok(VERIFY_READ, from, n)) {
60 if ((is_dsp_internal_mem(to)) &&
61 (((unsigned long)to & 2) || (n & 2))) {
63 * DARAM/SARAM with odd word alignment
68 /* dest not aligned -- copy 2 bytes */
69 if (((unsigned long)to & 2) && (n >= 2)) {
70 #ifdef HAVE_ASM_COPY_FROM_USER_DSP_2B
71 if (__copy_from_user_dsp_2b(to, from))
73 if (copy_from_user_dsp_2b(to, from))
80 /* middle 4*n bytes */
83 if ((n = __copy_from_user(to, from, n4)) != 0)
89 #ifdef HAVE_ASM_COPY_FROM_USER_DSP_2B
90 if (__copy_from_user_dsp_2b(to, from))
92 if (copy_from_user_dsp_2b(to, from))
99 * DARAM/SARAM with 4-byte alignment or
102 n = __copy_from_user(to, from, n);
105 else /* security hole - plug it */
110 #ifndef HAVE_ASM_COPY_FROM_USER_DSP_2B
111 static __inline__ unsigned long copy_to_user_dsp_2b(void *to, const void *from)
113 /* expecting compiler to generate "strh" instruction */
114 unsigned short tmp = *(unsigned short *)from;
116 return __copy_to_user(to, &tmp, 2);
121 * @n must be multiple of 2
123 static __inline__ unsigned long copy_to_user_dsp(void *to, const void *from,
126 if (access_ok(VERIFY_WRITE, to, n)) {
127 if ((is_dsp_internal_mem(from)) &&
128 (((unsigned long)to & 2) || (n & 2))) {
130 * DARAM/SARAM with odd word alignment
133 unsigned long last_n;
135 /* dest not aligned -- copy 2 bytes */
136 if (((unsigned long)to & 2) && (n >= 2)) {
137 #ifdef HAVE_ASM_COPY_FROM_USER_DSP_2B
138 if (__copy_to_user_dsp_2b(to, from))
140 if (copy_to_user_dsp_2b(to, from))
147 /* middle 4*n bytes */
150 if ((n = __copy_to_user(to, from, n4)) != 0)
156 #ifdef HAVE_ASM_COPY_FROM_USER_DSP_2B
157 if (__copy_to_user_dsp_2b(to, from))
159 if (copy_to_user_dsp_2b(to, from))
166 * DARAM/SARAM with 4-byte alignment or
169 n = __copy_to_user(to, from, n);
175 #endif /* _OMAP_DSP_UACCESS_DSP_H */