]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - android-sdk/device-ti-proprietary-open.git/blob - jacinto6/sgx_src/eurasia_km/include4/pvr_debug.h
7e056665f2e09877267fd08e63e3e60ffef0c13e
[android-sdk/device-ti-proprietary-open.git] / jacinto6 / sgx_src / eurasia_km / include4 / pvr_debug.h
1 /*************************************************************************/ /*!
2 @Title          PVR Debug Declarations
3 @Copyright      Copyright (c) Imagination Technologies Ltd. All Rights Reserved
4 @Description    Provides debug functionality
5 @License        Dual MIT/GPLv2
7 The contents of this file are subject to the MIT license as set out below.
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
19 Alternatively, the contents of this file may be used under the terms of
20 the GNU General Public License Version 2 ("GPL") in which case the provisions
21 of GPL are applicable instead of those above.
23 If you wish to allow use of your version of this file only under the terms of
24 GPL, and not to allow others to use your version of this file under the terms
25 of the MIT license, indicate your decision by deleting the provisions above
26 and replace them with the notice and other provisions required by GPL as set
27 out in the file called "GPL-COPYING" included in this distribution. If you do
28 not delete the provisions above, a recipient may use your version of this file
29 under the terms of either the MIT license or GPL.
31 This License is also included in this distribution in the file called
32 "MIT-COPYING".
34 EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
35 PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
36 BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
37 PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
38 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
39 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
40 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
41 */ /**************************************************************************/
42 #ifndef __PVR_DEBUG_H__
43 #define __PVR_DEBUG_H__
46 #include "img_types.h"
49 #if defined (__cplusplus)
50 extern "C" {
51 #endif
53 #define PVR_MAX_DEBUG_MESSAGE_LEN       (512)
55 /* These are privately used by pvr_debug, use the PVR_DBG_ defines instead */
56 #define DBGPRIV_FATAL                   0x01UL
57 #define DBGPRIV_ERROR                   0x02UL
58 #define DBGPRIV_WARNING                 0x04UL
59 #define DBGPRIV_MESSAGE                 0x08UL
60 #define DBGPRIV_VERBOSE                 0x10UL
61 #define DBGPRIV_CALLTRACE               0x20UL
62 #define DBGPRIV_ALLOC                   0x40UL
63 #define DBGPRIV_DBGDRV_MESSAGE  0x80UL
65 #define DBGPRIV_DBGLEVEL_COUNT  8
67 #if !defined(PVRSRV_NEED_PVR_ASSERT) && defined(DEBUG)
68 #define PVRSRV_NEED_PVR_ASSERT
69 #endif
71 #if defined(PVRSRV_NEED_PVR_ASSERT) && !defined(PVRSRV_NEED_PVR_DPF)
72 #define PVRSRV_NEED_PVR_DPF
73 #endif
75 #if !defined(PVRSRV_NEED_PVR_TRACE) && (defined(DEBUG) || defined(TIMING))
76 #define PVRSRV_NEED_PVR_TRACE
77 #endif
79 /* PVR_ASSERT() and PVR_DBG_BREAK handling */
81 #if defined(PVRSRV_NEED_PVR_ASSERT)
83 #if defined(LINUX) && defined(__KERNEL__)
84 /* In Linux kernel mode, use BUG() directly. This produces the correct
85    filename and line number in the panic message. */
86 #define PVR_ASSERT(EXPR) do                                                                                     \
87         {                                                                                                                               \
88                 if (!(EXPR))                                                                                            \
89                 {                                                                                                                       \
90                         PVRSRVDebugPrintf(DBGPRIV_FATAL, __FILE__, __LINE__,    \
91                                                           "Debug assertion failed!");                   \
92                         BUG();                                                                                                  \
93                 }                                                                                                                       \
94         } while (0)
96 #else /* defined(LINUX) && defined(__KERNEL__) */
98 IMG_IMPORT IMG_VOID IMG_CALLCONV PVRSRVDebugAssertFail(const IMG_CHAR *pszFile,
99                                                                                                            IMG_UINT32 ui32Line);
101 #if defined(LINUX)
102         #define PVR_ASSERT(EXPR) do                                                             \
103                 {                                                                                                       \
104                         if (!(EXPR))                                                                    \
105                                 PVRSRVDebugAssertFail(__FILE__, __LINE__);      \
106                 } while (0)
107 #else
108     #if defined (__QNXNTO__)
109             #define PVR_ASSERT(EXPR) if (!(EXPR)) PVRSRVDebugAssertFail(__FILE__, __LINE__);
110     #else
111             #define PVR_ASSERT(EXPR) if (!(EXPR)) PVRSRVDebugAssertFail(__FILE__, __LINE__)
112     #endif
113 #endif
115 #endif /* defined(LINUX) && defined(__KERNEL__) */
118                         #if defined(LINUX) && defined(__KERNEL__)
119                                 #define PVR_DBG_BREAK BUG()
120                         #else
121                                 #define PVR_DBG_BREAK PVRSRVDebugAssertFail(__FILE__, __LINE__)
122                         #endif
124 #else  /* defined(PVRSRV_NEED_PVR_ASSERT) */
126         #define PVR_ASSERT(EXPR)
127         #define PVR_DBG_BREAK
129 #endif /* defined(PVRSRV_NEED_PVR_ASSERT) */
132 /* PVR_DPF() handling */
134 #if defined(PVRSRV_NEED_PVR_DPF)
136 #if defined(PVRSRV_NEW_PVR_DPF)
138         /* New logging mechanism */
139         #define PVR_DBG_FATAL           DBGPRIV_FATAL
140         #define PVR_DBG_ERROR           DBGPRIV_ERROR
141         #define PVR_DBG_WARNING         DBGPRIV_WARNING
142         #define PVR_DBG_MESSAGE         DBGPRIV_MESSAGE
143         #define PVR_DBG_VERBOSE         DBGPRIV_VERBOSE
144         #define PVR_DBG_CALLTRACE       DBGPRIV_CALLTRACE
145         #define PVR_DBG_ALLOC           DBGPRIV_ALLOC
146         #define PVR_DBGDRIV_MESSAGE     DBGPRIV_DBGDRV_MESSAGE
148         /* These levels are always on with PVRSRV_NEED_PVR_DPF */
149         #define __PVR_DPF_0x01UL(x...) PVRSRVDebugPrintf(DBGPRIV_FATAL, x)
150         #define __PVR_DPF_0x02UL(x...) PVRSRVDebugPrintf(DBGPRIV_ERROR, x)
152         /* Some are compiled out completely in release builds */
153 #if defined(DEBUG)
154         #define __PVR_DPF_0x04UL(x...) PVRSRVDebugPrintf(DBGPRIV_WARNING, x)
155         #define __PVR_DPF_0x08UL(x...) PVRSRVDebugPrintf(DBGPRIV_MESSAGE, x)
156         #define __PVR_DPF_0x10UL(x...) PVRSRVDebugPrintf(DBGPRIV_VERBOSE, x)
157         #define __PVR_DPF_0x20UL(x...) PVRSRVDebugPrintf(DBGPRIV_CALLTRACE, x)
158         #define __PVR_DPF_0x40UL(x...) PVRSRVDebugPrintf(DBGPRIV_ALLOC, x)
159         #define __PVR_DPF_0x80UL(x...) PVRSRVDebugPrintf(DBGPRIV_DBGDRV_MESSAGE, x)
160 #else
161         #define __PVR_DPF_0x04UL(x...)
162         #define __PVR_DPF_0x08UL(x...)
163         #define __PVR_DPF_0x10UL(x...)
164         #define __PVR_DPF_0x20UL(x...)
165         #define __PVR_DPF_0x40UL(x...)
166         #define __PVR_DPF_0x80UL(x...)
167 #endif
169         /* Translate the different log levels to separate macros
170          * so they can each be compiled out.
171          */
172 #if defined(DEBUG)
173         #define __PVR_DPF(lvl, x...) __PVR_DPF_ ## lvl (__FILE__, __LINE__, x)
174 #else
175         #define __PVR_DPF(lvl, x...) __PVR_DPF_ ## lvl ("", 0, x)
176 #endif
178         /* Get rid of the double bracketing */
179         #define PVR_DPF(x) __PVR_DPF x
181 #else /* defined(PVRSRV_NEW_PVR_DPF) */
183         /* Old logging mechanism */
184         #define PVR_DBG_FATAL           DBGPRIV_FATAL,__FILE__, __LINE__
185         #define PVR_DBG_ERROR           DBGPRIV_ERROR,__FILE__, __LINE__
186         #define PVR_DBG_WARNING         DBGPRIV_WARNING,__FILE__, __LINE__
187         #define PVR_DBG_MESSAGE         DBGPRIV_MESSAGE,__FILE__, __LINE__
188         #define PVR_DBG_VERBOSE         DBGPRIV_VERBOSE,__FILE__, __LINE__
189         #define PVR_DBG_CALLTRACE       DBGPRIV_CALLTRACE,__FILE__, __LINE__
190         #define PVR_DBG_ALLOC           DBGPRIV_ALLOC,__FILE__, __LINE__
191         #define PVR_DBGDRIV_MESSAGE     DBGPRIV_DBGDRV_MESSAGE, "", 0
193         #define PVR_DPF(X)                      PVRSRVDebugPrintf X
195 #endif /* defined(PVRSRV_NEW_PVR_DPF) */
197 IMG_IMPORT IMG_VOID IMG_CALLCONV PVRSRVDebugPrintf(IMG_UINT32 ui32DebugLevel,
198                                                                                                    const IMG_CHAR *pszFileName,
199                                                                                                    IMG_UINT32 ui32Line,
200                                                                                                    const IMG_CHAR *pszFormat,
201                                                                                                    ...) IMG_FORMAT_PRINTF(4, 5);
203 #else  /* defined(PVRSRV_NEED_PVR_DPF) */
205         #define PVR_DPF(X)
207 #endif /* defined(PVRSRV_NEED_PVR_DPF) */
210 /* PVR_TRACE() handling */
212 #if defined(PVRSRV_NEED_PVR_TRACE)
214         #define PVR_TRACE(X)    PVRSRVTrace X
216 IMG_IMPORT IMG_VOID IMG_CALLCONV PVRSRVTrace(const IMG_CHAR* pszFormat, ... )
217         IMG_FORMAT_PRINTF(1, 2);
219 #else /* defined(PVRSRV_NEED_PVR_TRACE) */
221         #define PVR_TRACE(X)
223 #endif /* defined(PVRSRV_NEED_PVR_TRACE) */
226 #if defined (__cplusplus)
228 #endif
230 #endif  /* __PVR_DEBUG_H__ */
232 /******************************************************************************
233  End of file (pvr_debug.h)
234 ******************************************************************************/