1 /*
2 * Copyright (c) Texas Instruments Incorporated 2018
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the
14 * distribution.
15 *
16 * Neither the name of Texas Instruments Incorporated nor the names of
17 * its contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
33 /**
34 * \file trace.h
35 *
36 * \brief Kernel Trace enabling/disabling/application interface.
37 *
38 * This will have the definitions for kernel side traces
39 * statements and also details of variable traces
40 * supported in existing implementation.
41 */
43 #ifndef FVID2TRACE_H_
44 #define FVID2TRACE_H_
46 #include <ti/csl/tistdtypes.h>
48 #ifdef __cplusplus
49 extern "C" {
50 #endif
52 /*!
53 * @def GT_TRACESTATE_MASK
54 * @brief Trace state mask
55 */
56 #define GT_TRACESTATE_MASK (0x0000000FU)
57 /*!
58 * @def GT_TRACESTATE_SHIFT
59 * @brief Bit shift for trace state
60 */
61 #define GT_TRACESTATE_SHIFT (0U)
62 /*!
63 * @def GT_TRACECLASS_MASK
64 * @brief GT class mask
65 */
66 #define GT_TRACECLASS_MASK (0x000F0000U)
67 /*!
68 * @def GT_TRACECLASS_SHIFT
69 * @brief Bit shift for GT class mask
70 */
71 #define GT_TRACECLASS_SHIFT (16U)
73 /*!
74 * @brief Default Mask to use with GT_assert
75 */
76 #define GT_DEFAULT_MASK (GT_ERR | GT_TraceState_Enable)
78 /*!
79 * @brief Enumerates the types of states of trace (enable/disable)
80 */
81 typedef enum {
82 GT_TraceState_Disable = 0x00000000U,
83 /*!< Disable trace */
84 GT_TraceState_Enable = 0x00000001U,
85 /*!< Enable trace */
86 GT_TraceState_EndValue = 0x00000002U
87 /*!< End delimiter indicating start of invalid
88 *values for this enum */
89 } GT_TraceState;
91 /*!
92 * @brief Enumerates the types of trace classes
93 */
94 typedef enum {
95 GT_ERR = 0x00010000U,
96 /*!< Class 1 trace: Used for errors/warnings */
97 GT_CRIT = 0x00020000U,
98 /*!< Class 2 trace: Used for critical information */
99 GT_INFO = 0x00030000U,
100 /*!< Class 3 trace: Used for additional information */
101 GT_INFO1 = 0x00040000U,
102 /*!< Class 4 trace: Used for additional information (sub level 1) */
103 GT_DEBUG = 0x00050000U,
104 /*!< Class 5 trace: Used for block level information */
105 GT_ENTER = 0x00060000U,
106 /*!< Indicates a function entry class of trace */
107 GT_LEAVE = 0x00070000U
108 /*!< Indicates a function leave class of trace */
109 } GT_TraceClass;
111 /** \brief Log enable for FVID2 Utils. */
112 #define Fvid2Trace (GT_DEFAULT_MASK)
114 /**
115 * \brief Prints to Shared memory and CCS console
116 *
117 * This function prints the provided formatted string to shared memory and CCS
118 * console
119 *
120 * \param format [IN] Formatted string followed by variable arguments
121 *
122 */
123 void Fvid2_printf(const char *format, ...);
125 #if defined (FVID2_CFG_ASSERT_ENABLE)
127 /** \brief assert function. */
128 void GT_assertLocal(uint32_t enableMask,
129 uint32_t condition,
130 const char *str,
131 const char *fileName,
132 int32_t lineNum);
134 /** \brief GT_assert */
135 #define GT_assert(x, y) \
136 (GT_assertLocal((uint32_t) (x), (uint32_t) (y), (const char *) # y, \
137 (const char *) __FILE__, (int32_t) __LINE__))
139 #else
141 #define GT_assert(x, y)
143 #endif
145 /**
146 * \brief Log the trace with zero parameters and information string.
147 *
148 * \param maskType [IN] Trace mask
149 * \param classType [IN] Trace class type
150 * \param fileName [IN] File Name
151 * \param lineNum [IN] Line Number
152 * \param infoString [IN] Print string
153 *
154 */
155 void GT_trace0(uint32_t maskType,
156 GT_TraceClass classType,
157 const char *fileName,
158 int32_t lineNum,
159 const char *infoString);
160 /**
161 * \brief Function to log the trace with one additional parameter.
162 *
163 * \param maskType [IN] Trace mask
164 * \param classType [IN] Trace class type
165 * \param fileName [IN] File Name
166 * \param lineNum [IN] Line Number
167 * \param infoString [IN] Print string
168 * \param param0 [IN] Parameter 0
169 *
170 */
171 void GT_trace1(uint32_t maskType,
172 GT_TraceClass classType,
173 const char *fileName,
174 int32_t lineNum,
175 const char *infoString,
176 uintptr_t param0);
178 /**
179 * \brief Function to log the trace with two additional parameters.
180 *
181 * \param maskType [IN] Trace mask
182 * \param classType [IN] Trace class type
183 * \param fileName [IN] File Name
184 * \param lineNum [IN] Line Number
185 * \param infoString [IN] Print string
186 * \param param0 [IN] Parameter 0
187 * \param param1 [IN] Parameter 1
188 *
189 */
190 void GT_trace2(uint32_t maskType,
191 GT_TraceClass classType,
192 const char *fileName,
193 int32_t lineNum,
194 const char *infoString,
195 uintptr_t param0,
196 uintptr_t param1);
198 /**
199 * \brief Function to log the trace with three additional parameters.
200 *
201 * \param maskType [IN] Trace mask
202 * \param classType [IN] Trace class type
203 * \param fileName [IN] File Name
204 * \param lineNum [IN] Line Number
205 * \param infoString [IN] Print string
206 * \param param0 [IN] Parameter 0
207 * \param param1 [IN] Parameter 1
208 * \param param2 [IN] Parameter 2
209 *
210 */
211 void GT_trace3(uint32_t maskType,
212 GT_TraceClass classType,
213 const char *fileName,
214 int32_t lineNum,
215 const char *infoString,
216 uintptr_t param0,
217 uintptr_t param1,
218 uintptr_t param2);
220 /**
221 * \brief Function to log the trace with four additional parameters.
222 *
223 * \param maskType [IN] Trace mask
224 * \param classType [IN] Trace class type
225 * \param fileName [IN] File Name
226 * \param lineNum [IN] Line Number
227 * \param infoString [IN] Print string
228 * \param param0 [IN] Parameter 0
229 * \param param1 [IN] Parameter 1
230 * \param param2 [IN] Parameter 2
231 * \param param3 [IN] Parameter 3
232 *
233 */
234 void GT_trace4(uint32_t maskType,
235 GT_TraceClass classType,
236 const char *fileName,
237 int32_t lineNum,
238 const char *infoString,
239 uintptr_t param0,
240 uintptr_t param1,
241 uintptr_t param2,
242 uintptr_t param3);
244 /**
245 * \brief Function to log the trace with five additional parameters.
246 *
247 * \param maskType [IN] Trace mask
248 * \param classType [IN] Trace class type
249 * \param fileName [IN] File Name
250 * \param lineNum [IN] Line Number
251 * \param infoString [IN] Print string
252 * \param param0 [IN] Parameter 0
253 * \param param1 [IN] Parameter 1
254 * \param param2 [IN] Parameter 2
255 * \param param3 [IN] Parameter 3
256 * \param param4 [IN] Parameter 4
257 *
258 */
259 void GT_trace5(uint32_t maskType,
260 GT_TraceClass classType,
261 const char *fileName,
262 int32_t lineNum,
263 const char *infoString,
264 uintptr_t param0,
265 uintptr_t param1,
266 uintptr_t param2,
267 uintptr_t param3,
268 uintptr_t param4);
270 /**
271 * \brief Function to log the trace with six additional parameters.
272 *
273 * \param maskType [IN] Trace mask
274 * \param classType [IN] Trace class type
275 * \param fileName [IN] File Name
276 * \param lineNum [IN] Line Number
277 * \param infoString [IN] Print string
278 * \param param0 [IN] Parameter 0
279 * \param param1 [IN] Parameter 1
280 * \param param2 [IN] Parameter 2
281 * \param param3 [IN] Parameter 3
282 * \param param4 [IN] Parameter 4
283 * \param param5 [IN] Parameter 5
284 *
285 */
286 void GT_trace6(uint32_t maskType,
287 GT_TraceClass classType,
288 const char *fileName,
289 int32_t lineNum,
290 const char *infoString,
291 uintptr_t param0,
292 uintptr_t param1,
293 uintptr_t param2,
294 uintptr_t param3,
295 uintptr_t param4,
296 uintptr_t param5);
298 /**
299 * \brief Function to log the trace with seven additional parameters.
300 *
301 * \param maskType [IN] Trace mask
302 * \param classType [IN] Trace class type
303 * \param fileName [IN] File Name
304 * \param lineNum [IN] Line Number
305 * \param infoString [IN] Print string
306 * \param param0 [IN] Parameter 0
307 * \param param1 [IN] Parameter 1
308 * \param param2 [IN] Parameter 2
309 * \param param3 [IN] Parameter 3
310 * \param param4 [IN] Parameter 4
311 * \param param5 [IN] Parameter 5
312 * \param param6 [IN] Parameter 6
313 *
314 */
315 void GT_trace7(uint32_t maskType,
316 GT_TraceClass classType,
317 const char *fileName,
318 int32_t lineNum,
319 const char *infoString,
320 uintptr_t param0,
321 uintptr_t param1,
322 uintptr_t param2,
323 uintptr_t param3,
324 uintptr_t param4,
325 uintptr_t param5,
326 uintptr_t param6);
328 #if defined (FVID2_CFG_TRACE_ENABLE)
329 /** \brief Log the trace with zero parameters and information string. */
330 #define GT_0trace(maskType, classType, infoString) \
331 (GT_trace0((maskType), (classType), \
332 (const char *) __FILE__, (int32_t) __LINE__, \
333 (const char *) (infoString)))
335 /** \brief Function to log the trace with one additional parameters. */
336 #define GT_1trace(maskType, classType, infoString, param0) \
337 (GT_trace1((maskType), (classType), \
338 (const char *) __FILE__, (int32_t) __LINE__, \
339 (const char *) (infoString), (uintptr_t) (param0)))
341 /** \brief Function to log the trace with two additional parameters. */
342 #define GT_2trace(maskType, classType, infoString, param0, param1) \
343 (GT_trace2((maskType), (classType), \
344 (const char *) __FILE__, (int32_t) __LINE__, \
345 (const char *) (infoString), (uintptr_t) (param0), (uintptr_t) (param1)))
347 /** \brief Function to log the trace with three additional parameters. */
348 #define GT_3trace(maskType, classType, infoString, param0, param1, param2) \
349 (GT_trace3((maskType), (classType), \
350 (const char *) __FILE__, (int32_t) __LINE__, \
351 (const char *) (infoString), \
352 (uintptr_t) (param0), \
353 (uintptr_t) (param1), \
354 (uintptr_t) (param2)))
356 /** \brief Function to log the trace with four additional parameters. */
357 #define GT_4trace(maskType, classType, infoString, \
358 param0, param1, param2, param3) \
359 (GT_trace4((maskType), (classType), \
360 (const char *) __FILE__, (int32_t) __LINE__, \
361 (const char *) (infoString), \
362 (uintptr_t) (param0), \
363 (uintptr_t) (param1), \
364 (uintptr_t) (param2), \
365 (uintptr_t) (param3)))
367 /** \brief Function to log the trace with five additional parameters. */
368 #define GT_5trace(maskType, classType, infoString, \
369 param0, param1, param2, param3, param4) \
370 (GT_trace5((maskType), (classType), \
371 (const char *) __FILE__, (int32_t) __LINE__, \
372 (const char *) (infoString), \
373 (uintptr_t) (param0), \
374 (uintptr_t) (param1), \
375 (uintptr_t) (param2), \
376 (uintptr_t) (param3), \
377 (uintptr_t) (param4)))
379 /** \brief Function to log the trace with six additional parameters. */
380 #define GT_6trace(maskType, classType, infoString, \
381 param0, param1, param2, param3, param4, param5) \
382 (GT_trace6((maskType), (classType), \
383 (const char *) __FILE__, (int32_t) __LINE__, \
384 (const char *) (infoString), \
385 (uintptr_t) (param0), \
386 (uintptr_t) (param1), \
387 (uintptr_t) (param2), \
388 (uintptr_t) (param3), \
389 (uintptr_t) (param4), \
390 (uintptr_t) (param5)))
392 /** \brief Function to log the trace with seven additional parameters. */
393 #define GT_7trace(maskType, classType, infoString, \
394 param0, param1, param2, param3, param4, param5, param6) \
395 (GT_trace7((maskType), (classType), \
396 (const char *) __FILE__, (int32_t) __LINE__, \
397 (const char *) (infoString), \
398 (uintptr_t) (param0), \
399 (uintptr_t) (param1), \
400 (uintptr_t) (param2), \
401 (uintptr_t) (param3), \
402 (uintptr_t) (param4), \
403 (uintptr_t) (param5), \
404 (uintptr_t) (param6)))
406 #else /* if defined (FVID2_CFG_TRACE_ENABLE) */
408 /** \brief Log the trace with zero parameters and information string. */
409 #define GT_0trace(maskType, classType, infoString)
410 /** \brief Function to log the trace with one additional parameter. */
411 #define GT_1trace(maskType, classType, infoString, param0)
412 /** \brief Function to log the trace with two additional parameters. */
413 #define GT_2trace(maskType, classType, infoString, param0, param1)
414 /** \brief Function to log the trace with three additional parameters. */
415 #define GT_3trace(maskType, classType, infoString, param0, param1, param2)
416 /** \brief Function to log the trace with four additional parameters. */
417 #define GT_4trace(maskType, classType, infoString, param0, param1, param2, \
418 param3)
419 /** \brief Function to log the trace with five additional parameters. */
420 #define GT_5trace(maskType, classType, infoString, param0, param1, param2, \
421 param3, param4)
422 /** \brief Function to log the trace with six additional parameters. */
423 #define GT_6trace(maskType, classType, infoString, param0, param1, param2, \
424 param3, param4, param5)
425 /** \brief Function to log the trace with seven additional parameters. */
426 #define GT_7trace(maskType, classType, infoString, param0, param1, param2, \
427 param3, param4, param5, param6)
429 #endif /* if defined (FVID2_CFG_TRACE_ENABLE) */
431 #ifdef __cplusplus
432 }
433 #endif
435 #endif /* ifndef FVID2TRACE_H_ */