tizen 2.4 release
[kernel/linux-3.0.git] / drivers / gpu / arm / mali400 / r4p0_rel0 / linux / mali_osk_misc.c
1 /*
2  * Copyright (C) 2010-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
11 /**
12  * @file mali_osk_misc.c
13  * Implementation of the OS abstraction layer for the kernel device driver
14  */
15 #include <linux/kernel.h>
16 #include <asm/uaccess.h>
17 #include <asm/cacheflush.h>
18 #include <linux/sched.h>
19 #include <linux/module.h>
20 #include "mali_osk.h"
21
22 void _mali_osk_dbgmsg( const char *fmt, ... )
23 {
24         va_list args;
25         va_start(args, fmt);
26         vprintk(fmt, args);
27         va_end(args);
28 }
29
30 u32 _mali_osk_snprintf( char *buf, u32 size, const char *fmt, ... )
31 {
32         int res;
33         va_list args;
34         va_start(args, fmt);
35
36         res = vscnprintf(buf, (size_t)size, fmt, args);
37
38         va_end(args);
39         return res;
40 }
41
42 void _mali_osk_abort(void)
43 {
44         /* make a simple fault by dereferencing a NULL pointer */
45         dump_stack();
46         *(int *)0 = 0;
47 }
48
49 void _mali_osk_break(void)
50 {
51         _mali_osk_abort();
52 }
53
54 u32 _mali_osk_get_pid(void)
55 {
56         /* Thread group ID is the process ID on Linux */
57         return (u32)current->tgid;
58 }
59
60 u32 _mali_osk_get_tid(void)
61 {
62         /* pid is actually identifying the thread on Linux */
63         u32 tid = current->pid;
64
65         /* If the pid is 0 the core was idle.  Instead of returning 0 we return a special number
66          * identifying which core we are on. */
67         if (0 == tid) {
68                 tid = -(1 + raw_smp_processor_id());
69         }
70
71         return tid;
72 }