1 /*
2 * Copyright 2001-2008 Texas Instruments - http://www.ti.com/
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17
18 /*
19 * ======== gt.h ========
20 * Purpose:
21 * There are two definitions that affect which portions of trace
22 * are acutally compiled into the client: GT_TRACE and GT_ASSERT. If
23 * GT_TRACE is set to 0 then all trace statements (except for assertions)
24 * will be compiled out of the client. If GT_ASSERT is set to 0 then
25 * assertions will be compiled out of the client. GT_ASSERT can not be
26 * set to 0 unless GT_TRACE is also set to 0 (i.e. GT_TRACE == 1 implies
27 * GT_ASSERT == 1).
28 *
29 *! Revision History
30 *! ================
31 *! 02-Feb-2000 rr: Renamed this file to gtce.h. GT CLASS and trace definitions
32 *! are WinCE Specific.
33 *! 03-Jan-1997 ge Replaced "GT_" prefix to GT_Config structure members
34 *! to eliminate preprocessor confusion with other macros.
35 */
36
37 #ifndef GT_
38 #define GT_
39
40 #ifndef GT_TRACE
41 #define GT_TRACE 0 /* 0 = "trace compiled out"; 1 = "trace active" */
42 #endif
43
44 #if !defined(GT_ASSERT) || GT_TRACE
45 #define GT_ASSERT 1
46 #endif
47
48 struct GT_Config {
49 Fxn PRINTFXN;
50 Fxn PIDFXN;
51 Fxn TIDFXN;
52 Fxn ERRORFXN;
53 };
54
55 extern struct GT_Config *GT;
56
57 struct GT_Mask {
58 String modName;
59 SmBits *flags;
60 } ;
61
62 /*
63 * New GT Class defenitions.
64 *
65 * The following are the explanations and how it could be used in the code
66 *
67 * - GT_ENTER On Entry to Functions
68 *
69 * - GT_1CLASS Display level of debugging status- Object/Automatic
70 * variables
71 * - GT_2CLASS ---- do ----
72 *
73 * - GT_3CLASS ---- do ---- + It can be used(recommended) for debug
74 status in the ISR, IST
75 * - GT_4CLASS ---- do ----
76 *
77 * - GT_5CLASS Display entry for module init/exit functions
78 *
79 * - GT_6CLASS Warn whenever SERVICES function fails
80 *
81 * - GT_7CLASS Warn failure of Critical failures
82 *
83 */
84
85 #define GT_ENTER ((SmBits)0x01)
86 #define GT_1CLASS ((SmBits)0x02)
87 #define GT_2CLASS ((SmBits)0x04)
88 #define GT_3CLASS ((SmBits)0x08)
89 #define GT_4CLASS ((SmBits)0x10)
90 #define GT_5CLASS ((SmBits)0x20)
91 #define GT_6CLASS ((SmBits)0x40)
92 #define GT_7CLASS ((SmBits)0x80)
93
94 #ifdef _LINT_
95
96 /* LINTLIBRARY */
97
98 /*
99 * ======== GT_assert ========
100 */
101 /* ARGSUSED */
102 Void
GT_assert(struct GT_Mask mask,Int expr)103 GT_assert(struct GT_Mask mask, Int expr)
104 {
105 }
106
107 /*
108 * ======== GT_config ========
109 */
110 /* ARGSUSED */
111 Void
GT_config(struct GT_Config config)112 GT_config(struct GT_Config config)
113 {
114 }
115
116 /*
117 * ======== GT_create ========
118 */
119 /* ARGSUSED */
120 Void
GT_create(struct GT_Mask * mask,String modName)121 GT_create(struct GT_Mask * mask /* OUT */ , String modName)
122 {
123 }
124
125 /*
126 * ======== GT_curLine ========
127 * Purpose:
128 * Returns the current source code line number. Is useful for performing
129 * branch testing using trace. For example,
130 *
131 * GT_1trace(curTrace, GT_1CLASS,
132 * "in module XX_mod, executing line %u\n", GT_curLine());
133 */
134 /* ARGSUSED */
135 MdUns
GT_curLine(Void)136 GT_curLine(Void)
137 {
138 return ((MdUns) NULL);
139 }
140
141 /*
142 * ======== GT_exit ========
143 */
144 /* ARGSUSED */
145 Void
GT_exit(Void)146 GT_exit(Void)
147 {
148 }
149
150 /*
151 * ======== GT_init ========
152 */
153 /* ARGSUSED */
154 Void
GT_init(Void)155 GT_init(Void)
156 {
157 }
158
159 /*
160 * ======== GT_query ========
161 */
162 /* ARGSUSED */
163 bool
GT_query(struct GT_Mask mask,SmBits class)164 GT_query(struct GT_Mask mask, SmBits class)
165 {
166 return (false);
167 }
168
169 /*
170 * ======== GT_set ========
171 * sets trace mask according to settings
172 */
173
174 /* ARGSUSED */
175 Void
GT_set(String settings)176 GT_set(String settings)
177 {
178 }
179
180 /*
181 * ======== GT_setprintf ========
182 * sets printf function
183 */
184
185 /* ARGSUSED */
186 Void
GT_setprintf(Fxn fxn)187 GT_setprintf(Fxn fxn)
188 {
189 }
190
191 /* ARGSUSED */
192 Void
GT_0trace(struct GT_Mask mask,SmBits class,String format)193 GT_0trace(struct GT_Mask mask, SmBits class, String format)
194 {
195 }
196
197 /* ARGSUSED */
198 Void
GT_1trace(struct GT_Mask mask,SmBits class,String format,...)199 GT_1trace(struct GT_Mask mask, SmBits class, String format, ...)
200 {
201 }
202
203 /* ARGSUSED */
204 Void
GT_2trace(struct GT_Mask mask,SmBits class,String format,...)205 GT_2trace(struct GT_Mask mask, SmBits class, String format, ...)
206 {
207 }
208
209 /* ARGSUSED */
210 Void
GT_3trace(struct GT_Mask mask,SmBits class,String format,...)211 GT_3trace(struct GT_Mask mask, SmBits class, String format, ...)
212 {
213 }
214
215 /* ARGSUSED */
216 Void
GT_4trace(struct GT_Mask mask,SmBits class,String format,...)217 GT_4trace(struct GT_Mask mask, SmBits class, String format, ...)
218 {
219 }
220
221 /* ARGSUSED */
222 Void
GT_5trace(struct GT_Mask mask,SmBits class,String format,...)223 GT_5trace(struct GT_Mask mask, SmBits class, String format, ...)
224 {
225 }
226
227 /* ARGSUSED */
228 Void
GT_6trace(struct GT_Mask mask,SmBits class,String format,...)229 GT_6trace(struct GT_Mask mask, SmBits class, String format, ...)
230 {
231 }
232
233 #else
234
235 #define GT_BOUND 26 /* 26 letters in alphabet */
236
237 extern Void _GT_create(struct GT_Mask * mask, String modName);
238
239 #define GT_exit()
240
241 extern Void GT_init(Void);
242 extern Void _GT_set(String str);
243 extern Int _GT_trace(struct GT_Mask * mask, String format, ...);
244
245 #if GT_ASSERT == 0
246
247 #define GT_assert( mask, expr )
248 #define GT_config( config )
249 #define GT_configInit( config )
250 #define GT_seterror( fxn )
251
252 #else
253
254 extern struct GT_Config _GT_params;
255
256 #define GT_assert( mask, expr ) \
257 (!(expr) ? \
258 (*GT->ERRORFXN)("assertion violation: %s, line %d\n", \
259 __FILE__, __LINE__), NULL : NULL)
260
261 #define GT_config( config ) (_GT_params = *(config))
262 #define GT_configInit( config ) (*(config) = _GT_params)
263 #define GT_seterror( fxn ) (_GT_params.ERRORFXN = (Fxn)(fxn))
264
265 #endif
266
267 #if GT_TRACE == 0
268
269 #define GT_curLine() ((MdUns)__LINE__)
270 #define GT_create(mask, modName)
271 #define GT_exit()
272 #define GT_init()
273 #define GT_set( settings )
274 #define GT_setprintf( fxn )
275
276 #define GT_query( mask, class ) false
277
278 #define GT_0trace( mask, class, format )
279 #define GT_1trace( mask, class, format, arg1 )
280 #define GT_2trace( mask, class, format, arg1, arg2 )
281 #define GT_3trace( mask, class, format, arg1, arg2, arg3 )
282 #define GT_4trace( mask, class, format, arg1, arg2, arg3, arg4 )
283 #define GT_5trace( mask, class, format, arg1, arg2, arg3, arg4, arg5 )
284 #define GT_6trace( mask, class, format, arg1, arg2, arg3, arg4, arg5, arg6 )
285
286 #else /* GT_TRACE == 1 */
287
288 extern String GT_format;
289 extern SmBits *GT_tMask[GT_BOUND];
290
291 #define GT_create(mask, modName) _GT_create((mask), (modName))
292 #define GT_curLine() ((MdUns)__LINE__)
293 #define GT_set( settings ) _GT_set( settings )
294 #define GT_setprintf( fxn ) (_GT_params.PRINTFXN = (Fxn)(fxn))
295
296 #define GT_query( mask, class ) ((*(mask).flags & (class)))
297
298 #define GT_0trace( mask, class, format ) \
299 ((*(mask).flags & (class)) ? \
300 _GT_trace(&(mask), (format)) : 0)
301
302 #define GT_1trace( mask, class, format, arg1 ) \
303 ((*(mask).flags & (class)) ? \
304 _GT_trace(&(mask), (format), (arg1)) : 0)
305
306 #define GT_2trace( mask, class, format, arg1, arg2 ) \
307 ((*(mask).flags & (class)) ? \
308 _GT_trace(&(mask), (format), (arg1), (arg2)) : 0)
309
310 #define GT_3trace( mask, class, format, arg1, arg2, arg3 ) \
311 ((*(mask).flags & (class)) ? \
312 _GT_trace(&(mask), (format), (arg1), (arg2), (arg3)) : 0)
313
314 #define GT_4trace( mask, class, format, arg1, arg2, arg3, arg4 ) \
315 ((*(mask).flags & (class)) ? \
316 _GT_trace(&(mask), (format), (arg1), (arg2), (arg3), (arg4)) : 0)
317
318 #define GT_5trace( mask, class, format, arg1, arg2, arg3, arg4, arg5 ) \
319 ((*(mask).flags & (class)) ? \
320 _GT_trace(&(mask), (format), (arg1), (arg2), (arg3), (arg4), (arg5)) : 0)
321
322 #define GT_6trace( mask, class, format, arg1, arg2, arg3, arg4, arg5, arg6 ) \
323 ((*(mask).flags & (class)) ? \
324 _GT_trace(&(mask), (format), (arg1), (arg2), (arg3), (arg4), (arg5), \
325 (arg6)) : 0)
326
327 #endif /* GT_TRACE */
328
329 #endif /* _LINT_ */
330
331 #endif /* GTCE_ */
332
333