tizen 2.4 release
[kernel/linux-3.0.git] / drivers / gpu / arm / mali400 / mali / linux / mali_ukk_gp.c
1 /*
2  * Copyright (C) 2011-2012 ARM Limited. All rights reserved.
3  *
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.
6  *
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.
9  */
10 #include <linux/fs.h>       /* file system operations */
11 #include <asm/uaccess.h>    /* user space access */
12
13 #include "mali_ukk.h"
14 #include "mali_osk.h"
15 #include "mali_kernel_common.h"
16 #include "mali_session.h"
17 #include "mali_ukk_wrappers.h"
18
19 int gp_start_job_wrapper(struct mali_session_data *session_data, _mali_uk_gp_start_job_s __user *uargs)
20 {
21         _mali_osk_errcode_t err;
22
23         MALI_CHECK_NON_NULL(uargs, -EINVAL);
24         MALI_CHECK_NON_NULL(session_data, -EINVAL);
25
26         err = _mali_ukk_gp_start_job(session_data, uargs);
27         if (_MALI_OSK_ERR_OK != err) return map_errcode(err);
28
29         return 0;
30 }
31
32 int gp_get_core_version_wrapper(struct mali_session_data *session_data, _mali_uk_get_gp_core_version_s __user *uargs)
33 {
34     _mali_uk_get_gp_core_version_s kargs;
35     _mali_osk_errcode_t err;
36
37     MALI_CHECK_NON_NULL(uargs, -EINVAL);
38     MALI_CHECK_NON_NULL(session_data, -EINVAL);
39
40     kargs.ctx = session_data;
41     err =  _mali_ukk_get_gp_core_version(&kargs);
42     if (_MALI_OSK_ERR_OK != err) return map_errcode(err);
43
44         /* no known transactions to roll-back */
45
46     if (0 != put_user(kargs.version, &uargs->version)) return -EFAULT;
47
48     return 0;
49 }
50
51 int gp_suspend_response_wrapper(struct mali_session_data *session_data, _mali_uk_gp_suspend_response_s __user *uargs)
52 {
53     _mali_uk_gp_suspend_response_s kargs;
54     _mali_osk_errcode_t err;
55
56     MALI_CHECK_NON_NULL(uargs, -EINVAL);
57     MALI_CHECK_NON_NULL(session_data, -EINVAL);
58
59     if (0 != copy_from_user(&kargs, uargs, sizeof(_mali_uk_gp_suspend_response_s))) return -EFAULT;
60
61     kargs.ctx = session_data;
62     err = _mali_ukk_gp_suspend_response(&kargs);
63     if (_MALI_OSK_ERR_OK != err) return map_errcode(err);
64
65     if (0 != put_user(kargs.cookie, &uargs->cookie)) return -EFAULT;
66
67     /* no known transactions to roll-back */
68     return 0;
69 }
70
71 int gp_get_number_of_cores_wrapper(struct mali_session_data *session_data, _mali_uk_get_gp_number_of_cores_s __user *uargs)
72 {
73     _mali_uk_get_gp_number_of_cores_s kargs;
74     _mali_osk_errcode_t err;
75
76     MALI_CHECK_NON_NULL(uargs, -EINVAL);
77     MALI_CHECK_NON_NULL(session_data, -EINVAL);
78
79     kargs.ctx = session_data;
80     err = _mali_ukk_get_gp_number_of_cores(&kargs);
81     if (_MALI_OSK_ERR_OK != err) return map_errcode(err);
82
83         /* no known transactions to roll-back */
84
85     if (0 != put_user(kargs.number_of_cores, &uargs->number_of_cores)) return -EFAULT;
86
87     return 0;
88 }