]> git.karo-electronics.de Git - karo-tx-linux.git/blob - drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_debug.h
339dff462780de861cac5a34dc08a023e0bedbed
[karo-tx-linux.git] / drivers / mxc / gpu-viv / hal / os / linux / kernel / gc_hal_kernel_debug.h
1 /****************************************************************************
2 *
3 *    Copyright (C) 2005 - 2013 by Vivante Corp.
4 *
5 *    This program is free software; you can redistribute it and/or modify
6 *    it under the terms of the GNU General Public License as published by
7 *    the Free Software Foundation; either version 2 of the license, or
8 *    (at your option) any later version.
9 *
10 *    This program is distributed in the hope that it will be useful,
11 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
12 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 *    GNU General Public License for more details.
14 *
15 *    You should have received a copy of the GNU General Public License
16 *    along with this program; if not write to the Free Software
17 *    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 *
19 *****************************************************************************/
20
21
22 #ifndef __gc_hal_kernel_debug_h_
23 #define __gc_hal_kernel_debug_h_
24
25 #include <gc_hal_kernel_linux.h>
26 #include <linux/spinlock.h>
27 #include <linux/time.h>
28 #include <stdarg.h>
29
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33
34 /******************************************************************************\
35 ****************************** OS-dependent Macros *****************************
36 \******************************************************************************/
37
38 typedef va_list gctARGUMENTS;
39
40 #define gcmkARGUMENTS_START(Arguments, Pointer) \
41     va_start(Arguments, Pointer)
42
43 #define gcmkARGUMENTS_END(Arguments) \
44     va_end(Arguments)
45
46 #define gcmkDECLARE_LOCK(__spinLock__) \
47     static DEFINE_SPINLOCK(__spinLock__);
48
49 #define gcmkLOCKSECTION(__spinLock__) \
50     spin_lock(&__spinLock__)
51
52 #define gcmkUNLOCKSECTION(__spinLock__) \
53     spin_unlock(&__spinLock__)
54
55 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
56 #   define gcmkGETPROCESSID() \
57         task_tgid_vnr(current)
58 #else
59 #   define gcmkGETPROCESSID() \
60         current->tgid
61 #endif
62
63 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
64 #   define gcmkGETTHREADID() \
65         task_pid_vnr(current)
66 #else
67 #   define gcmkGETTHREADID() \
68         current->pid
69 #endif
70
71 #define gcmkOUTPUT_STRING(String) \
72    if(gckDebugFileSystemIsEnabled()) \
73         gckDebugFileSystemPrint(String);\
74    else\
75         printk(String); \
76     touch_softlockup_watchdog()
77
78
79 #define gcmkSPRINTF(Destination, Size, Message, Value) \
80     snprintf(Destination, Size, Message, Value)
81
82 #define gcmkSPRINTF2(Destination, Size, Message, Value1, Value2) \
83     snprintf(Destination, Size, Message, Value1, Value2)
84
85 #define gcmkSPRINTF3(Destination, Size, Message, Value1, Value2, Value3) \
86     snprintf(Destination, Size, Message, Value1, Value2, Value3)
87
88 #define gcmkVSPRINTF(Destination, Size, Message, Arguments) \
89     vsnprintf(Destination, Size, Message, *(va_list *) &Arguments)
90
91 #define gcmkSTRCAT(Destination, Size, String) \
92     strncat(Destination, String, Size)
93
94 /* If not zero, forces data alignment in the variable argument list
95    by its individual size. */
96 #define gcdALIGNBYSIZE      1
97
98 #ifdef __cplusplus
99 }
100 #endif
101
102 #endif /* __gc_hal_kernel_debug_h_ */