3 * (C) COPYRIGHT 2010-2011 ARM Limited. All rights reserved.
5 * This program is free software and is provided to you under the terms of the GNU General Public License version 2
6 * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
8 * A copy of the licence is included with the program, and can also be obtained from Free Software
9 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15 #include <osk/mali_osk.h>
16 #include <uk/mali_ukk.h>
17 #include <plat/mali_ukk_os.h>
19 /* following OS specific includes can be removed when osk functions are implemented */
21 #include <linux/module.h> /* Kernel module definitions */
22 #include <linux/kernel.h> /* Needed for KERN_INFO */
25 mali_error ukk_start(void)
27 return MALI_ERROR_NONE;
34 void ukk_call_prepare(ukk_call_context * const ukk_ctx, ukk_session * const session, void * const thread_ctx)
36 OSK_ASSERT(NULL != ukk_ctx);
37 OSK_ASSERT(NULL != session);
38 /* NULL thread_ctx parameter is allowed */
40 ukk_ctx->ukk_session = session;
41 ukk_ctx->thread_ctx = thread_ctx;
45 void *ukk_session_get(ukk_call_context * const ukk_ctx)
47 OSK_ASSERT(NULL != ukk_ctx);
48 return ukk_ctx->ukk_session;
51 void ukk_call_data_set(ukk_call_context * const ukk_ctx, uintptr_t data)
53 OSK_ASSERT(NULL != ukk_ctx);
57 uintptr_t ukk_call_data_get(ukk_call_context * const ukk_ctx)
59 OSK_ASSERT(NULL != ukk_ctx);
63 void *ukk_thread_ctx_get(ukk_call_context * const ukk_ctx)
65 OSK_ASSERT(NULL != ukk_ctx);
66 return ukk_ctx->thread_ctx;
69 static mali_error ukkp_dispatch_call(ukk_call_context *ukk_ctx, void *args, u32 args_size)
71 uk_header *header = (uk_header *)args;
72 mali_error ret = MALI_ERROR_NONE;
74 if(UKP_FUNC_ID_CHECK_VERSION == header->id)
76 if (args_size == sizeof(uku_version_check_args))
78 ukk_session *ukk_session = ukk_session_get(ukk_ctx);
79 uku_version_check_args *version_check = (uku_version_check_args *)args;
81 version_check->major = ukk_session->version_major;
82 version_check->minor = ukk_session->version_minor;
83 header->ret = MALI_ERROR_NONE;
87 header->ret = MALI_ERROR_FUNCTION_FAILED;
92 ret = MALI_ERROR_FUNCTION_FAILED; /* not handled */
97 mali_error ukk_dispatch(ukk_call_context * const ukk_ctx, void * const args, u32 args_size)
100 uk_header *header = (uk_header *)args;
102 OSK_ASSERT(NULL != ukk_ctx);
103 OSK_ASSERT(NULL != args);
105 /* Verify args_size both in debug and release builds */
106 OSK_ASSERT(args_size >= sizeof(uk_header));
107 if (args_size < sizeof(uk_header)) return MALI_ERROR_FUNCTION_FAILED;
109 if (header->id >= UK_FUNC_ID)
111 ret = ukk_ctx->ukk_session->dispatch(ukk_ctx, args, args_size);
115 ret = ukkp_dispatch_call(ukk_ctx, args, args_size);