2 * Copyright (C) 2010-2012 ARM Limited. All rights reserved.
4 * This program is free software and is provided to you under the terms of the GNU General Public License version 2
5 * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
7 * A copy of the licence is included with the program, and can also be obtained from Free Software
8 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
10 #include <linux/fs.h> /* file system operations */
11 #include <linux/slab.h> /* memort allocation functions */
12 #include <asm/uaccess.h> /* user space access */
16 #include "mali_kernel_common.h"
17 #include "mali_session.h"
18 #include "mali_ukk_wrappers.h"
20 int get_api_version_wrapper(struct mali_session_data *session_data, _mali_uk_get_api_version_s __user *uargs)
22 _mali_uk_get_api_version_s kargs;
23 _mali_osk_errcode_t err;
25 MALI_CHECK_NON_NULL(uargs, -EINVAL);
27 if (0 != get_user(kargs.version, &uargs->version)) return -EFAULT;
29 kargs.ctx = session_data;
30 err = _mali_ukk_get_api_version(&kargs);
31 if (_MALI_OSK_ERR_OK != err) return map_errcode(err);
33 if (0 != put_user(kargs.version, &uargs->version)) return -EFAULT;
34 if (0 != put_user(kargs.compatible, &uargs->compatible)) return -EFAULT;
39 int wait_for_notification_wrapper(struct mali_session_data *session_data, _mali_uk_wait_for_notification_s __user *uargs)
41 _mali_uk_wait_for_notification_s kargs;
42 _mali_osk_errcode_t err;
44 MALI_CHECK_NON_NULL(uargs, -EINVAL);
46 kargs.ctx = session_data;
47 err = _mali_ukk_wait_for_notification(&kargs);
48 if (_MALI_OSK_ERR_OK != err) return map_errcode(err);
50 if(_MALI_NOTIFICATION_CORE_SHUTDOWN_IN_PROGRESS != kargs.type) {
51 kargs.ctx = NULL; /* prevent kernel address to be returned to user space */
52 if (0 != copy_to_user(uargs, &kargs, sizeof(_mali_uk_wait_for_notification_s))) return -EFAULT;
54 if (0 != put_user(kargs.type, &uargs->type)) return -EFAULT;
60 int post_notification_wrapper(struct mali_session_data *session_data, _mali_uk_post_notification_s __user *uargs)
62 _mali_uk_post_notification_s kargs;
63 _mali_osk_errcode_t err;
65 MALI_CHECK_NON_NULL(uargs, -EINVAL);
67 kargs.ctx = session_data;
69 if (0 != get_user(kargs.type, &uargs->type)) {
73 err = _mali_ukk_post_notification(&kargs);
74 if (_MALI_OSK_ERR_OK != err) {
75 return map_errcode(err);
81 int get_user_settings_wrapper(struct mali_session_data *session_data, _mali_uk_get_user_settings_s __user *uargs)
83 _mali_uk_get_user_settings_s kargs;
84 _mali_osk_errcode_t err;
86 MALI_CHECK_NON_NULL(uargs, -EINVAL);
88 kargs.ctx = session_data;
89 err = _mali_ukk_get_user_settings(&kargs);
90 if (_MALI_OSK_ERR_OK != err) {
91 return map_errcode(err);
94 kargs.ctx = NULL; /* prevent kernel address to be returned to user space */
95 if (0 != copy_to_user(uargs, &kargs, sizeof(_mali_uk_get_user_settings_s))) return -EFAULT;
100 int request_high_priority_wrapper(struct mali_session_data *session_data, _mali_uk_request_high_priority_s __user *uargs)
102 _mali_uk_request_high_priority_s kargs;
103 _mali_osk_errcode_t err;
105 MALI_CHECK_NON_NULL(uargs, -EINVAL);
107 kargs.ctx = session_data;
108 err = _mali_ukk_request_high_priority(&kargs);
112 return map_errcode(err);