1 /****************************************************************************
3 * Copyright (C) 2005 - 2014 by Vivante Corp.
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.
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.
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.
19 *****************************************************************************/
22 #ifndef __gc_hal_kernel_debug_h_
23 #define __gc_hal_kernel_debug_h_
25 #include <gc_hal_kernel_linux.h>
26 #include <linux/spinlock.h>
27 #include <linux/time.h>
34 /******************************************************************************\
35 ****************************** OS-dependent Macros *****************************
36 \******************************************************************************/
38 typedef va_list gctARGUMENTS;
40 #define gcmkARGUMENTS_START(Arguments, Pointer) \
41 va_start(Arguments, Pointer)
43 #define gcmkARGUMENTS_END(Arguments) \
46 #define gcmkARGUMENTS_ARG(Arguments, Type) \
47 va_arg(Arguments, Type)
49 #define gcmkDECLARE_LOCK(__spinLock__) \
50 static DEFINE_SPINLOCK(__spinLock__); \
51 unsigned long __spinLock__##flags = 0;
53 #define gcmkLOCKSECTION(__spinLock__) \
54 spin_lock_irqsave(&__spinLock__, __spinLock__##flags)
56 #define gcmkUNLOCKSECTION(__spinLock__) \
57 spin_unlock_irqrestore(&__spinLock__, __spinLock__##flags)
59 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
60 # define gcmkGETPROCESSID() \
61 task_tgid_vnr(current)
63 # define gcmkGETPROCESSID() \
67 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
68 # define gcmkGETTHREADID() \
71 # define gcmkGETTHREADID() \
75 #define gcmkOUTPUT_STRING(String) \
76 if(gckDEBUGFS_IsEnabled()) {\
77 while(-ERESTARTSYS == gckDEBUGFS_Print(String));\
81 touch_softlockup_watchdog()
84 #define gcmkSPRINTF(Destination, Size, Message, Value) \
85 snprintf(Destination, Size, Message, Value)
87 #define gcmkSPRINTF2(Destination, Size, Message, Value1, Value2) \
88 snprintf(Destination, Size, Message, Value1, Value2)
90 #define gcmkSPRINTF3(Destination, Size, Message, Value1, Value2, Value3) \
91 snprintf(Destination, Size, Message, Value1, Value2, Value3)
93 #define gcmkVSPRINTF(Destination, Size, Message, Arguments) \
94 vsnprintf(Destination, Size, Message, *((va_list*)Arguments))
96 #define gcmkSTRCAT(Destination, Size, String) \
97 strncat(Destination, String, Size)
99 #define gcmkMEMCPY(Destination, Source, Size) \
100 memcpy(Destination, Source, Size)
102 #define gcmkSTRLEN(String) \
105 /* If not zero, forces data alignment in the variable argument list
106 by its individual size. */
107 #define gcdALIGNBYSIZE 1
113 #endif /* __gc_hal_kernel_debug_h_ */