]> git.kernelconcepts.de Git - karo-tx-linux.git/blob - drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_debug.h
gpu: vivante: Update driver from Freescale 3.10.53-1.1-ga BSP
[karo-tx-linux.git] / drivers / mxc / gpu-viv / hal / os / linux / kernel / gc_hal_kernel_debug.h
1 /****************************************************************************
2 *
3 *    Copyright (C) 2005 - 2014 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 gcmkARGUMENTS_ARG(Arguments, Type) \
47     va_arg(Arguments, Type)
48
49 #define gcmkDECLARE_LOCK(__spinLock__) \
50     static DEFINE_SPINLOCK(__spinLock__); \
51     unsigned long __spinLock__##flags = 0;
52
53 #define gcmkLOCKSECTION(__spinLock__) \
54     spin_lock_irqsave(&__spinLock__, __spinLock__##flags)
55
56 #define gcmkUNLOCKSECTION(__spinLock__) \
57     spin_unlock_irqrestore(&__spinLock__, __spinLock__##flags)
58
59 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
60 #   define gcmkGETPROCESSID() \
61         task_tgid_vnr(current)
62 #else
63 #   define gcmkGETPROCESSID() \
64         current->tgid
65 #endif
66
67 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
68 #   define gcmkGETTHREADID() \
69         task_pid_vnr(current)
70 #else
71 #   define gcmkGETTHREADID() \
72         current->pid
73 #endif
74
75 #define gcmkOUTPUT_STRING(String) \
76     if(gckDEBUGFS_IsEnabled()) {\
77         while(-ERESTARTSYS == gckDEBUGFS_Print(String));\
78     }else{\
79         printk(String); \
80     }\
81     touch_softlockup_watchdog()
82
83
84 #define gcmkSPRINTF(Destination, Size, Message, Value) \
85     snprintf(Destination, Size, Message, Value)
86
87 #define gcmkSPRINTF2(Destination, Size, Message, Value1, Value2) \
88     snprintf(Destination, Size, Message, Value1, Value2)
89
90 #define gcmkSPRINTF3(Destination, Size, Message, Value1, Value2, Value3) \
91     snprintf(Destination, Size, Message, Value1, Value2, Value3)
92
93 #define gcmkVSPRINTF(Destination, Size, Message, Arguments) \
94     vsnprintf(Destination, Size, Message, *((va_list*)Arguments))
95
96 #define gcmkSTRCAT(Destination, Size, String) \
97     strncat(Destination, String, Size)
98
99 #define gcmkMEMCPY(Destination, Source, Size) \
100     memcpy(Destination, Source, Size)
101
102 #define gcmkSTRLEN(String) \
103     strlen(String)
104
105 /* If not zero, forces data alignment in the variable argument list
106    by its individual size. */
107 #define gcdALIGNBYSIZE      1
108
109 #ifdef __cplusplus
110 }
111 #endif
112
113 #endif /* __gc_hal_kernel_debug_h_ */