2 * Copyright (C) 2010, 2012-2014, 2016 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 <asm/uaccess.h> /* user space access */
15 #include "mali_kernel_common.h"
16 #include "mali_session.h"
17 #include "mali_ukk_wrappers.h"
19 int pp_start_job_wrapper(struct mali_session_data *session_data, _mali_uk_pp_start_job_s __user *uargs)
21 _mali_osk_errcode_t err;
23 /* If the job was started successfully, 0 is returned. If there was an error, but the job
24 * was started, we return -ENOENT. For anything else returned, the job was not started. */
26 MALI_CHECK_NON_NULL(uargs, -EINVAL);
27 MALI_CHECK_NON_NULL(session_data, -EINVAL);
29 err = _mali_ukk_pp_start_job(session_data, uargs);
30 if (_MALI_OSK_ERR_OK != err) return map_errcode(err);
35 int pp_and_gp_start_job_wrapper(struct mali_session_data *session_data, _mali_uk_pp_and_gp_start_job_s __user *uargs)
37 _mali_osk_errcode_t err;
39 /* If the jobs were started successfully, 0 is returned. If there was an error, but the
40 * jobs were started, we return -ENOENT. For anything else returned, the jobs were not
43 MALI_CHECK_NON_NULL(uargs, -EINVAL);
44 MALI_CHECK_NON_NULL(session_data, -EINVAL);
46 err = _mali_ukk_pp_and_gp_start_job(session_data, uargs);
47 if (_MALI_OSK_ERR_OK != err) return map_errcode(err);
52 int pp_get_number_of_cores_wrapper(struct mali_session_data *session_data, _mali_uk_get_pp_number_of_cores_s __user *uargs)
54 _mali_uk_get_pp_number_of_cores_s kargs;
55 _mali_osk_errcode_t err;
57 MALI_CHECK_NON_NULL(uargs, -EINVAL);
58 MALI_CHECK_NON_NULL(session_data, -EINVAL);
60 kargs.ctx = (uintptr_t)session_data;
62 err = _mali_ukk_get_pp_number_of_cores(&kargs);
63 if (_MALI_OSK_ERR_OK != err) {
64 return map_errcode(err);
67 kargs.ctx = (uintptr_t)NULL; /* prevent kernel address to be returned to user space */
68 if (0 != copy_to_user(uargs, &kargs, sizeof(_mali_uk_get_pp_number_of_cores_s))) {
75 int pp_get_core_version_wrapper(struct mali_session_data *session_data, _mali_uk_get_pp_core_version_s __user *uargs)
77 _mali_uk_get_pp_core_version_s kargs;
78 _mali_osk_errcode_t err;
80 MALI_CHECK_NON_NULL(uargs, -EINVAL);
81 MALI_CHECK_NON_NULL(session_data, -EINVAL);
83 kargs.ctx = (uintptr_t)session_data;
84 err = _mali_ukk_get_pp_core_version(&kargs);
85 if (_MALI_OSK_ERR_OK != err) return map_errcode(err);
87 if (0 != put_user(kargs.version, &uargs->version)) return -EFAULT;
92 int pp_disable_wb_wrapper(struct mali_session_data *session_data, _mali_uk_pp_disable_wb_s __user *uargs)
94 _mali_uk_pp_disable_wb_s kargs;
96 MALI_CHECK_NON_NULL(uargs, -EINVAL);
97 MALI_CHECK_NON_NULL(session_data, -EINVAL);
99 if (0 != copy_from_user(&kargs, uargs, sizeof(_mali_uk_pp_disable_wb_s))) return -EFAULT;
101 kargs.ctx = (uintptr_t)session_data;
102 _mali_ukk_pp_job_disable_wb(&kargs);