1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
|
/*
* Copyright (C) 2010-2014 ARM Limited. All rights reserved.
*
* This program is free software and is provided to you under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
*
* A copy of the licence is included with the program, and can also be obtained from Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/**
* @file ump_ukk_wrappers.c
* Defines the wrapper functions which turn Linux IOCTL calls into _ukk_ calls
*/
#include <asm/uaccess.h> /* user space access */
#include "ump_osk.h"
#include "ump_uk_types.h"
#include "ump_ukk.h"
#include "ump_kernel_common.h"
/*
* IOCTL operation; Negotiate version of IOCTL API
*/
int ump_get_api_version_wrapper(u32 __user *argument, struct ump_session_data *session_data)
{
_ump_uk_api_version_s version_info;
_mali_osk_errcode_t err;
/* Sanity check input parameters */
if (NULL == argument || NULL == session_data) {
MSG_ERR(("NULL parameter in ump_ioctl_get_api_version()\n"));
return -ENOTTY;
}
/* Copy the user space memory to kernel space (so we safely can read it) */
if (0 != copy_from_user(&version_info, argument, sizeof(version_info))) {
MSG_ERR(("copy_from_user() in ump_ioctl_get_api_version()\n"));
return -EFAULT;
}
version_info.ctx = (void *) session_data;
err = _ump_uku_get_api_version(&version_info);
if (_MALI_OSK_ERR_OK != err) {
MSG_ERR(("_ump_uku_get_api_version() failed in ump_ioctl_get_api_version()\n"));
return map_errcode(err);
}
version_info.ctx = NULL;
/* Copy ouput data back to user space */
if (0 != copy_to_user(argument, &version_info, sizeof(version_info))) {
MSG_ERR(("copy_to_user() failed in ump_ioctl_get_api_version()\n"));
return -EFAULT;
}
return 0; /* success */
}
/*
* IOCTL operation; Release reference to specified UMP memory.
*/
int ump_release_wrapper(u32 __user *argument, struct ump_session_data *session_data)
{
_ump_uk_release_s release_args;
_mali_osk_errcode_t err;
/* Sanity check input parameters */
if (NULL == session_data) {
MSG_ERR(("NULL parameter in ump_ioctl_release()\n"));
return -ENOTTY;
}
/* Copy the user space memory to kernel space (so we safely can read it) */
if (0 != copy_from_user(&release_args, argument, sizeof(release_args))) {
MSG_ERR(("copy_from_user() in ump_ioctl_get_api_version()\n"));
return -EFAULT;
}
release_args.ctx = (void *) session_data;
err = _ump_ukk_release(&release_args);
if (_MALI_OSK_ERR_OK != err) {
MSG_ERR(("_ump_ukk_release() failed in ump_ioctl_release()\n"));
return map_errcode(err);
}
return 0; /* success */
}
/*
* IOCTL operation; Return size for specified UMP memory.
*/
int ump_size_get_wrapper(u32 __user *argument, struct ump_session_data *session_data)
{
_ump_uk_size_get_s user_interaction;
_mali_osk_errcode_t err;
/* Sanity check input parameters */
if (NULL == argument || NULL == session_data) {
MSG_ERR(("NULL parameter in ump_ioctl_size_get()\n"));
return -ENOTTY;
}
if (0 != copy_from_user(&user_interaction, argument, sizeof(user_interaction))) {
MSG_ERR(("copy_from_user() in ump_ioctl_size_get()\n"));
return -EFAULT;
}
user_interaction.ctx = (void *) session_data;
err = _ump_ukk_size_get(&user_interaction);
if (_MALI_OSK_ERR_OK != err) {
MSG_ERR(("_ump_ukk_size_get() failed in ump_ioctl_size_get()\n"));
return map_errcode(err);
}
user_interaction.ctx = NULL;
if (0 != copy_to_user(argument, &user_interaction, sizeof(user_interaction))) {
MSG_ERR(("copy_to_user() failed in ump_ioctl_size_get()\n"));
return -EFAULT;
}
return 0; /* success */
}
/*
* IOCTL operation; Do cache maintenance on specified UMP memory.
*/
int ump_msync_wrapper(u32 __user *argument, struct ump_session_data *session_data)
{
_ump_uk_msync_s user_interaction;
/* Sanity check input parameters */
if (NULL == argument || NULL == session_data) {
MSG_ERR(("NULL parameter in ump_ioctl_size_get()\n"));
return -ENOTTY;
}
if (0 != copy_from_user(&user_interaction, argument, sizeof(user_interaction))) {
MSG_ERR(("copy_from_user() in ump_ioctl_msync()\n"));
return -EFAULT;
}
user_interaction.ctx = (void *) session_data;
_ump_ukk_msync(&user_interaction);
user_interaction.ctx = NULL;
if (0 != copy_to_user(argument, &user_interaction, sizeof(user_interaction))) {
MSG_ERR(("copy_to_user() failed in ump_ioctl_msync()\n"));
return -EFAULT;
}
return 0; /* success */
}
int ump_cache_operations_control_wrapper(u32 __user *argument, struct ump_session_data *session_data)
{
_ump_uk_cache_operations_control_s user_interaction;
/* Sanity check input parameters */
if (NULL == argument || NULL == session_data) {
MSG_ERR(("NULL parameter in ump_ioctl_size_get()\n"));
return -ENOTTY;
}
if (0 != copy_from_user(&user_interaction, argument, sizeof(user_interaction))) {
MSG_ERR(("copy_from_user() in ump_ioctl_cache_operations_control()\n"));
return -EFAULT;
}
user_interaction.ctx = (void *) session_data;
_ump_ukk_cache_operations_control((_ump_uk_cache_operations_control_s *) &user_interaction);
user_interaction.ctx = NULL;
#if 0 /* No data to copy back */
if (0 != copy_to_user(argument, &user_interaction, sizeof(user_interaction))) {
MSG_ERR(("copy_to_user() failed in ump_ioctl_cache_operations_control()\n"));
return -EFAULT;
}
#endif
return 0; /* success */
}
int ump_switch_hw_usage_wrapper(u32 __user *argument, struct ump_session_data *session_data)
{
_ump_uk_switch_hw_usage_s user_interaction;
/* Sanity check input parameters */
if (NULL == argument || NULL == session_data) {
MSG_ERR(("NULL parameter in ump_ioctl_size_get()\n"));
return -ENOTTY;
}
if (0 != copy_from_user(&user_interaction, argument, sizeof(user_interaction))) {
MSG_ERR(("copy_from_user() in ump_ioctl_switch_hw_usage()\n"));
return -EFAULT;
}
user_interaction.ctx = (void *) session_data;
_ump_ukk_switch_hw_usage(&user_interaction);
user_interaction.ctx = NULL;
#if 0 /* No data to copy back */
if (0 != copy_to_user(argument, &user_interaction, sizeof(user_interaction))) {
MSG_ERR(("copy_to_user() failed in ump_ioctl_switch_hw_usage()\n"));
return -EFAULT;
}
#endif
return 0; /* success */
}
int ump_lock_wrapper(u32 __user *argument, struct ump_session_data *session_data)
{
_ump_uk_lock_s user_interaction;
/* Sanity check input parameters */
if (NULL == argument || NULL == session_data) {
MSG_ERR(("NULL parameter in ump_ioctl_size_get()\n"));
return -ENOTTY;
}
if (0 != copy_from_user(&user_interaction, argument, sizeof(user_interaction))) {
MSG_ERR(("copy_from_user() in ump_ioctl_switch_hw_usage()\n"));
return -EFAULT;
}
user_interaction.ctx = (void *) session_data;
_ump_ukk_lock(&user_interaction);
user_interaction.ctx = NULL;
#if 0 /* No data to copy back */
if (0 != copy_to_user(argument, &user_interaction, sizeof(user_interaction))) {
MSG_ERR(("copy_to_user() failed in ump_ioctl_switch_hw_usage()\n"));
return -EFAULT;
}
#endif
return 0; /* success */
}
int ump_unlock_wrapper(u32 __user *argument, struct ump_session_data *session_data)
{
_ump_uk_unlock_s user_interaction;
/* Sanity check input parameters */
if (NULL == argument || NULL == session_data) {
MSG_ERR(("NULL parameter in ump_ioctl_size_get()\n"));
return -ENOTTY;
}
if (0 != copy_from_user(&user_interaction, argument, sizeof(user_interaction))) {
MSG_ERR(("copy_from_user() in ump_ioctl_switch_hw_usage()\n"));
return -EFAULT;
}
user_interaction.ctx = (void *) session_data;
_ump_ukk_unlock(&user_interaction);
user_interaction.ctx = NULL;
#if 0 /* No data to copy back */
if (0 != copy_to_user(argument, &user_interaction, sizeof(user_interaction))) {
MSG_ERR(("copy_to_user() failed in ump_ioctl_switch_hw_usage()\n"));
return -EFAULT;
}
#endif
return 0; /* success */
}
|