Main Page | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

Trace.h

Go to the documentation of this file.
00001 /** 
00002  *  @file   Trace.h
00003  *
00004  *  @brief      Kernel Trace enabling/disabling/application interface.
00005  *
00006  *              This will have the definitions for kernel side traces
00007  *              statements and also details of variable traces
00008  *              supported in existing implementation.
00009  *
00010  *
00011  *  @ver        02.00.00.68_beta1
00012  *  
00013  *  ============================================================================
00014  *  
00015  *  Copyright (c) 2008-2009, Texas Instruments Incorporated
00016  *
00017  *  Redistribution and use in source and binary forms, with or without
00018  *  modification, are permitted provided that the following conditions
00019  *  are met:
00020  *  
00021  *  *  Redistributions of source code must retain the above copyright
00022  *     notice, this list of conditions and the following disclaimer.
00023  *  
00024  *  *  Redistributions in binary form must reproduce the above copyright
00025  *     notice, this list of conditions and the following disclaimer in the
00026  *     documentation and/or other materials provided with the distribution.
00027  *  
00028  *  *  Neither the name of Texas Instruments Incorporated nor the names of
00029  *     its contributors may be used to endorse or promote products derived
00030  *     from this software without specific prior written permission.
00031  *  
00032  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00033  *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
00034  *  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00035  *  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
00036  *  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00037  *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00038  *  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
00039  *  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
00040  *  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
00041  *  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
00042  *  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00043  *  Contact information for paper mail:
00044  *  Texas Instruments
00045  *  Post Office Box 655303
00046  *  Dallas, Texas 75265
00047  *  Contact information: 
00048  *  http://www-k.ext.ti.com/sc/technical-support/product-information-centers.htm?
00049  *  DCMP=TIHomeTracking&HQS=Other+OT+home_d_contact
00050  *  ============================================================================
00051  *  
00052  */
00053 
00054 #ifndef OSALTRACE_H_0xDA50
00055 #define OSALTRACE_H_0xDA50
00056 
00057 
00058 /* OSAL and utils headers */
00059 #include <ti/syslink/utils/OsalPrint.h>
00060 
00061 
00062 #if defined (__cplusplus)
00063 extern "C" {
00064 #endif
00065 
00066 
00067 /*!
00068  *  @def    OSALTRACE_MODULEID
00069  *  @brief  Module ID for OsalTrace OSAL module.
00070  */
00071 #define OSALTRACE_MODULEID                 (UInt16) 0xDA50
00072 
00073 
00074 /*!
00075  *  @def    GT_TRACESTATE_MASK
00076  *  @brief  Trace state mask
00077  */
00078 #define GT_TRACESTATE_MASK                 0x0000000F
00079 
00080 /*!
00081  *  @def    GT_TRACESTATE_SHIFT
00082  *  @brief  Bit shift for trace state
00083  */
00084 #define GT_TRACESTATE_SHIFT                0u
00085 
00086 /*!
00087  *  @def    GT_TRACEENTER_MASK
00088  *  @brief  Trace enter mask
00089  */
00090 #define GT_TRACEENTER_MASK                 0x000000F0
00091 
00092 /*!
00093  *  @def    GT_TRACEENTER_SHIFT
00094  *  @brief  Bit shift for trace enter
00095  */
00096 #define GT_TRACEENTER_SHIFT                4u
00097 
00098 /*!
00099  *  @def    GT_TRACESETFAILURE_MASK
00100  *  @brief  Trace Set Failure Reason mask
00101  */
00102 #define GT_TRACESETFAILURE_MASK            0x00000F00
00103 
00104 /*!
00105  *  @def    GT_TRACESETFAILURE_SHIFT
00106  *  @brief  Bit shift for trace Set Failure Reason
00107  */
00108 #define GT_TRACESETFAILURE_SHIFT           8u
00109 
00110 /*!
00111  *  @def    GT_TRACECLASS_MASK
00112  *  @brief  GT class mask
00113  */
00114 #define GT_TRACECLASS_MASK                 0x000F0000
00115 
00116 /*!
00117  *  @def    GT_TRACECLASS_SHIFT
00118  *  @brief  Bit shift for GT class mask
00119  */
00120 #define GT_TRACECLASS_SHIFT                16u
00121 
00122 /*!
00123  *  @brief   Enumerates the types of states of trace (enable/disable)
00124  */
00125 typedef enum {
00126     GT_TraceState_Disable       = 0x00000000,
00127     /*!< Disable trace */
00128     GT_TraceState_Enable        = 0x00000001,
00129     /*!< Enable trace */
00130     GT_TraceState_EndValue      = 0x00000002
00131     /*!< End delimiter indicating start of invalid values for this enum */
00132 } GT_TraceState;
00133 
00134 /*!
00135  *  @brief   Enumerates the states of enter/leave trace (enable/disable)
00136  */
00137 typedef enum {
00138     GT_TraceEnter_Disable       = 0x00000000,
00139     /*!< Disable GT_ENTER trace prints */
00140     GT_TraceEnter_Enable        = 0x00000010,
00141     /*!< Enable GT_ENTER trace prints */
00142     GT_TraceEnter_EndValue      = 0x00000020
00143     /*!< End delimiter indicating start of invalid values for this enum */
00144 } GT_TraceEnter;
00145 
00146 /*!
00147  *  @brief   Enumerates the states of SetFailureReason trace (enable/disable)
00148  */
00149 typedef enum {
00150     GT_TraceSetFailure_Disable       = 0x00000000,
00151     /*!< Disable Set Failure trace prints */
00152     GT_TraceSetFailure_Enable        = 0x00000100,
00153     /*!< Enable Set Failure trace prints */
00154     GT_TraceSetFailure_EndValue      = 0x00000200
00155     /*!< End delimiter indicating start of invalid values for this enum */
00156 } GT_TraceSetFailure;
00157 
00158 /*!
00159  *  @brief   Enumerates the types of trace classes
00160  */
00161 typedef enum {
00162     GT_1CLASS                   = 0x00010000,
00163     /*!< Class 1 trace: Used for block level information */
00164     GT_2CLASS                   = 0x00020000,
00165     /*!< Class 2 trace: Used for critical information */
00166     GT_3CLASS                   = 0x00030000,
00167     /*!< Class 3 trace: Used for additional information */
00168     GT_4CLASS                   = 0x00040000,
00169     /*!< Class 4 trace: Used for errors/warnings */
00170     GT_ENTER                    = 0x00050000,
00171     /*!< Indicates a function entry class of trace */
00172     GT_LEAVE                    = 0x00060000
00173     /*!< Indicates a function leave class of trace */
00174 } GT_TraceClass;
00175 
00176 /*!
00177  *  @brief   Enumerates the types of trace
00178  */
00179 typedef enum {
00180     GT_TraceType_User       = 0x00000000,
00181     /*!< Disable trace */
00182     GT_TraceType_Kernel     = 0x00000001,
00183     /*!< Enable trace */
00184     GT_TraceType_EndValue   = 0x00000002
00185     /*!< End delimiter indicating start of invalid values for this enum */
00186 } GT_TraceType;
00187 
00188 
00189 #if defined(SYSLINK_BUILD_DEBUG) && defined(SYSLINK_BUILD_HLOS)
00190 #define GT_assert(x, y)                                                 \
00191 do {                                                                    \
00192     if (!(y)) {                                                         \
00193         Osal_printf ("Assertion at Line no: %d in %s: %s : failed\n",   \
00194                      __LINE__, __FILE__, #y);                           \
00195     }                                                                   \
00196 } while (0)
00197 #endif /*#if defined(SYSLINK_BUILD_DEBUG) && defined(SYSLINK_BUILD_HLOS) */
00198 
00199 
00200 #if defined(SYSLINK_BUILD_DEBUG) && defined(SYSLINK_BUILD_RTOS)
00201 #define GT_assert(x, y)                                                 \
00202 do {                                                                    \
00203     if (!(y)) {                                                         \
00204         System_printf ("Assertion at %s : failed\n", #y);               \
00205     }                                                                   \
00206 } while (0)
00207 /* Assert on RTOS side should hang */
00208 while(1);
00209 #endif /* #if defined(SYSLINK_BUILD_DEBUG) && defined(SYSLINK_BUILD_RTOS) */
00210 
00211 
00212 #if !defined(GT_assert)
00213 #define GT_assert(x, y)
00214 #endif
00215 
00216 #if defined (SYSLINK_TRACE_ENABLE)
00217 /* The global trace variable containing current trace configuration. */
00218 extern Int curTrace;
00219 
00220 UInt32 _GT_setTrace (UInt32 mask, GT_TraceType type);
00221 #define GT_setTrace(mask,type) _GT_setTrace(mask, type)
00222 
00223 /* Function to report the syslink failure and log the trace. */
00224 Void _GT_setFailureReason (Int enableMask,
00225                            Char * func,
00226                            Char * fileName,
00227                            UInt32 lineNo,
00228                            UInt32 status,
00229                            Char * msg);
00230 #define GT_setFailureReason(mask, classId, func, status, msg)           \
00231        _GT_setFailureReason(mask, func,                                 \
00232                             __FILE__, __LINE__, status, (Char*) (msg"\n"))
00233 
00234 
00235 /* Log the trace with zero parameters and information string. */
00236 Void _GT_0trace (UInt32 maskType, GT_TraceClass classtype, Char* infoString);
00237 #define GT_0trace(mask, classId, format) \
00238 do {                                                            \
00239     if (classId == GT_ENTER) {                                  \
00240        _GT_0trace(mask, classId,                                \
00241                   "Entered "format"\n");                        \
00242     }                                                           \
00243     else if (classId == GT_LEAVE) {                             \
00244        _GT_0trace(mask, classId,                                \
00245                   "Leaving "format"\n");                        \
00246     }                                                           \
00247     else {                                                      \
00248        _GT_0trace(mask, classId,                                \
00249                   format"\n");                                  \
00250     }                                                           \
00251 } while (0)
00252 
00253 
00254 /* Function to log the trace with one additional parameter */
00255 Void _GT_1trace (UInt32         maskType,
00256                  GT_TraceClass  classtype,
00257                  Char *         infoString,
00258                  UInt32         param);
00259 #define GT_1trace(mask, classId, format, a)                     \
00260 do {                                                            \
00261     if (classId == GT_ENTER) {                                  \
00262        _GT_1trace(mask, classId,                                \
00263                   "Entered "format"\n\t"#a"\t[0x%x]\n",         \
00264                   (UInt32) (a));                                \
00265     }                                                           \
00266     else if (classId == GT_LEAVE) {                             \
00267        _GT_1trace(mask, classId,                                \
00268                   "Leaving "format"\n\t"#a"\t[0x%x]\n",         \
00269                   (UInt32) (a));                                \
00270     }                                                           \
00271     else {                                                      \
00272        _GT_1trace(mask, classId,                                \
00273                   format"\n",                                   \
00274                   (UInt32) (a));                                \
00275     }                                                           \
00276 } while (0)
00277 
00278 
00279 /* Function to log the trace with two additional parameters */
00280 Void _GT_2trace (UInt32         maskType,
00281                  GT_TraceClass  classtype,
00282                  Char *         infoString,
00283                  UInt32         param0,
00284                  UInt32         param1);
00285 #define GT_2trace(mask, classId, format, a, b)                  \
00286 do {                                                            \
00287     if (classId == GT_ENTER) {                                  \
00288        _GT_2trace(mask, classId,                                \
00289                   "Entered "format"\n\t"#a"\t[0x%x]\n"          \
00290                   "\t"#b"\t[0x%x]\n",                           \
00291                   (UInt32) (a),                                 \
00292                   (UInt32) (b));                                \
00293     }                                                           \
00294     else if (classId == GT_LEAVE) {                             \
00295        _GT_2trace(mask, classId,                                \
00296                   "Leaving "format"\n\t"#a"\t[0x%x]\n"          \
00297                   "\t"#b"\t[0x%x]\n",                           \
00298                   (UInt32) (a),                                 \
00299                   (UInt32) (b));                                \
00300     }                                                           \
00301     else {                                                      \
00302        _GT_2trace(mask, classId,                                \
00303                   format"\n",                                   \
00304                   (UInt32) (a),                                 \
00305                   (UInt32) (b));                                \
00306     }                                                           \
00307 } while (0)
00308 
00309 
00310 /* Function to log the trace with three parameters. */
00311 Void _GT_3trace (UInt32         maskType,
00312                  GT_TraceClass  classtype,
00313                  Char*          infoString,
00314                  UInt32         param0,
00315                  UInt32         param1,
00316                  UInt32         param2);
00317 #define GT_3trace(mask, classId, format, a, b, c)               \
00318 do {                                                            \
00319     if (classId == GT_ENTER) {                                  \
00320        _GT_3trace(mask, classId,                                \
00321                   "Entered "format"\n\t"#a"\t[0x%x]\n"          \
00322                   "\t"#b"\t[0x%x]\n"                            \
00323                   "\t"#c"\t[0x%x]\n",                           \
00324                   (UInt32) (a),                                 \
00325                   (UInt32) (b),                                 \
00326                   (UInt32) (c));                                \
00327     }                                                           \
00328     else if (classId == GT_LEAVE) {                             \
00329        _GT_3trace(mask, classId,                                \
00330                   "Leaving "format"\n\t"#a"\t[0x%x]\n"          \
00331                   "\t"#b"\t[0x%x]\n"                            \
00332                   "\t"#c"\t[0x%x]\n",                           \
00333                   (UInt32) (a),                                 \
00334                   (UInt32) (b),                                 \
00335                   (UInt32) (c));                                \
00336     }                                                           \
00337     else {                                                      \
00338        _GT_3trace(mask, classId,                                \
00339                   format"\n",                                   \
00340                   (UInt32) (a),                                 \
00341                   (UInt32) (b),                                 \
00342                   (UInt32) (c));                                \
00343     }                                                           \
00344 } while (0)
00345 
00346 
00347 /* Function to log the trace with four parameters. */
00348 Void _GT_4trace (UInt32         maskType,
00349                  GT_TraceClass  classtype,
00350                  Char*          infoString,
00351                  UInt32         param0,
00352                  UInt32         param1,
00353                  UInt32         param2,
00354                  UInt32         param3);
00355 #define GT_4trace(mask, classId, format, a, b, c, d) \
00356 do {                                                            \
00357     if (classId == GT_ENTER) {                                  \
00358        _GT_4trace(mask, classId,                                \
00359                   "Entered "format"\n\t"#a"\t[0x%x]\n"          \
00360                   "\t"#b"\t[0x%x]\n"                            \
00361                   "\t"#c"\t[0x%x]\n"                            \
00362                   "\t"#d"\t[0x%x]\n",                           \
00363                   (UInt32) (a),                                 \
00364                   (UInt32) (b),                                 \
00365                   (UInt32) (c),                                 \
00366                   (UInt32) (d));                                \
00367     }                                                           \
00368     else if (classId == GT_LEAVE) {                             \
00369        _GT_4trace(mask, classId,                                \
00370                   "Leaving "format"\n\t"#a"\t[0x%x]\n"          \
00371                   "\t"#b"\t[0x%x]\n"                            \
00372                   "\t"#c"\t[0x%x]\n"                            \
00373                   "\t"#d"\t[0x%x]\n",                           \
00374                   (UInt32) (a),                                 \
00375                   (UInt32) (b),                                 \
00376                   (UInt32) (c),                                 \
00377                   (UInt32) (d));                                \
00378     }                                                           \
00379     else {                                                      \
00380        _GT_4trace(mask, classId,                                \
00381                   format"\n",                                   \
00382                   (UInt32) (a),                                 \
00383                   (UInt32) (b),                                 \
00384                   (UInt32) (c),                                 \
00385                   (UInt32) (d));                                \
00386     }                                                           \
00387 } while (0)
00388 
00389 
00390 /* Function to log the trace with five parameters. */
00391 Void _GT_5trace (UInt32         maskType,
00392                  GT_TraceClass  classtype,
00393                  Char*          infoString,
00394                  UInt32         param0,
00395                  UInt32         param1,
00396                  UInt32         param2,
00397                  UInt32         param3,
00398                  UInt32         param4);
00399 #define GT_5trace(mask, classId, format, a, b, c, d, e) \
00400 do {                                                            \
00401     if (classId == GT_ENTER) {                                  \
00402        _GT_5trace(mask, classId,                                \
00403                   "Entered "format"\n\t"#a"\t[0x%x]\n"          \
00404                   "\t"#b"\t[0x%x]\n"                            \
00405                   "\t"#c"\t[0x%x]\n"                            \
00406                   "\t"#d"\t[0x%x]\n"                            \
00407                   "\t"#e"\t[0x%x]\n",                           \
00408                   (UInt32) (a),                                 \
00409                   (UInt32) (b),                                 \
00410                   (UInt32) (c),                                 \
00411                   (UInt32) (d),                                 \
00412                   (UInt32) (e));                                \
00413     }                                                           \
00414     else if (classId == GT_LEAVE) {                             \
00415        _GT_5trace(mask, classId,                                \
00416                   "Leaving "format"\n\t"#a"\t[0x%x]\n"          \
00417                   "\t"#b"\t[0x%x]\n"                            \
00418                   "\t"#c"\t[0x%x]\n"                            \
00419                   "\t"#d"\t[0x%x]\n"                            \
00420                   "\t"#e"\t[0x%x]\n",                           \
00421                   (UInt32) (a),                                 \
00422                   (UInt32) (b),                                 \
00423                   (UInt32) (c),                                 \
00424                   (UInt32) (d),                                 \
00425                   (UInt32) (e));                                \
00426     }                                                           \
00427     else {                                                      \
00428        _GT_5trace(mask, classId,                                \
00429                   format"\n",                                   \
00430                   (UInt32) (a),                                 \
00431                   (UInt32) (b),                                 \
00432                   (UInt32) (c),                                 \
00433                   (UInt32) (d),                                 \
00434                   (UInt32) (e));                                \
00435     }                                                           \
00436 } while (0)
00437 
00438 #else /* if defined (SYSLINK_TRACE_ENABLE) */
00439 
00440 #define GT_setFailureReason(mask, classId, func, status, msg)
00441 #define GT_0trace(mask, classId, format)
00442 #define GT_1trace(mask, classId, format, arg1)
00443 #define GT_2trace(mask, classId, format, arg1, arg2)
00444 #define GT_3trace(mask, classId, format, arg1, arg2, arg3)
00445 #define GT_4trace(mask, classId, format, arg1, arg2, arg3, arg4)
00446 #define GT_5trace(mask, classId, format, arg1, arg2, arg3, arg4, arg5)
00447 #define GT_setTrace(mask, type) 0
00448 
00449 #endif /* if defined (SYSLINK_TRACE_ENABLE) */
00450 
00451 
00452 #if defined (__cplusplus)
00453 }
00454 #endif /* defined (__cplusplus) */
00455 
00456 #endif /* ifndef OSALTRACE_H_0xDA50 */

Generated on Mon Mar 14 11:59:45 2011 for Syslink by  doxygen 1.4.4