]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - keystone-rtos/fvid2.git/blobdiff - src/trace.c
PDK-3279: FVID2 Trace should use user defined callback function to print
[keystone-rtos/fvid2.git] / src / trace.c
index f77600d0dc6a78dc976af4c53660106995c551f1..9097882c154d017892c0de317b0578dcb45fb299 100644 (file)
@@ -47,9 +47,6 @@
 /* ========================================================================== */
 
 #include <stdint.h>
-/* This is needed for vsnprintf */
-#include <stdio.h>
-#include <stdarg.h>
 
 #include <ti/csl/tistdtypes.h>
 #include <ti/drv/fvid2/fvid2.h>
 /*                           Macros & Typedefs                                */
 /* ========================================================================== */
 
-#define REMOTE_DEBUG_SERVER_PRINT_BUF_LEN        (uint32_t) (1024U * 2U)
-
-//TODO: Move this to OSAL
-#define Osal_printf     printf
+/* None */
 
 /* ========================================================================== */
 /*                         Structure Declarations                             */
 /* ========================================================================== */
 
-typedef struct
-{
-    uint32_t coreId;
-    char   printBuf[REMOTE_DEBUG_SERVER_PRINT_BUF_LEN];
-} RemoteDebug_ServerObj;
+/* None */
 
 /* ========================================================================== */
 /*                          Function Declarations                             */
@@ -83,56 +73,13 @@ typedef struct
 /*                            Global Variables                                */
 /* ========================================================================== */
 
-static RemoteDebug_ServerObj gRemoteDebug_serverObj = {0};
-
-/** \brief Global trace flag. */
-int32_t curTrace = 0;
+/* None */
 
 /* ========================================================================== */
 /*                          Function Definitions                              */
 /* ========================================================================== */
 
-void Fvid2_printf(const char *format, ...)
-{
-    va_list     vaArgPtr;
-    uintptr_t   cookie;
-    char       *buf = NULL;
-
-    cookie = HwiP_disable();
-
-    buf = &gRemoteDebug_serverObj.printBuf[0];
-    va_start(vaArgPtr, format);
-    vsnprintf(buf, REMOTE_DEBUG_SERVER_PRINT_BUF_LEN,
-              (const char *) format, vaArgPtr);
-    va_end(vaArgPtr);
-
-    HwiP_restore(cookie);
-
-    Osal_printf(buf);
-
-    return;
-}
-
-void Fvid2_rprintf(const char *format, ...)
-{
-    uintptr_t   cookie;
-    char       *buf = NULL;
-    va_list     vaArgPtr;
-
-    cookie = HwiP_disable();
-
-    buf = &gRemoteDebug_serverObj.printBuf[0];
-
-    va_start(vaArgPtr, format);
-    vsnprintf(buf, REMOTE_DEBUG_SERVER_PRINT_BUF_LEN,
-              (const char *) format, vaArgPtr);
-    va_end(vaArgPtr);
-
-    HwiP_restore(cookie);
-
-    return;
-}
-
+#if defined (FVID2_CFG_TRACE_ENABLE)
 /**
  *  \brief      Function to log the trace with zero parameters and just
  *              information string.
@@ -145,37 +92,27 @@ void Fvid2_rprintf(const char *format, ...)
  *  \param      The debug string.
  */
 void
-GT_trace0(uint32_t        maskType,
+GT_trace0(uint32_t      maskType,
           GT_TraceClass classType,
           const char   *fileName,
-          int32_t         lineNum,
+          int32_t       lineNum,
           const char   *infoString)
 {
     /* Check if trace is enabled. */
     if (((maskType & GT_TRACESTATE_MASK) >> GT_TRACESTATE_SHIFT)
         == GT_TraceState_Enable)
     {
-        if ((classType == GT_ENTER) || (classType == GT_LEAVE))
+        /* Check if specified class is enabled. */
+        if ((maskType & GT_TRACECLASS_MASK) >= classType)
         {
-            if ((maskType & GT_TRACEENTER_MASK) == GT_TraceEnter_Enable)
+            /* Print if specified class is greater than or equal to class
+             * for this specific print.
+             */
+            if (!((classType == GT_INFO) || (classType == GT_INFO1)))
             {
-                Osal_printf((const char *) infoString);
-            }
-        }
-        else
-        {
-            /* Check if specified class is enabled. */
-            if ((maskType & GT_TRACECLASS_MASK) >= classType)
-            {
-                /* Print if specified class is greater than or equal to class
-                 * for this specific print.
-                 */
-                if (!((classType == GT_INFO) || (classType == GT_INFO1)))
-                {
-                    Osal_printf("%s @ Line %d: ", fileName, lineNum);
-                }
-                Osal_printf((const char *) infoString);
+                Fvid2_printf("%s @ Line %d: ", fileName, lineNum);
             }
+            Fvid2_printf((const char *) infoString);
         }
     }
 }
@@ -192,38 +129,28 @@ GT_trace0(uint32_t        maskType,
  *  \param      param The additional parameter which needs to be logged.
  */
 void
-GT_trace1(uint32_t        maskType,
+GT_trace1(uint32_t      maskType,
           GT_TraceClass classType,
           const char   *fileName,
-          int32_t         lineNum,
+          int32_t       lineNum,
           const char   *infoString,
-          uint32_t        param0)
+          uint32_t      param0)
 {
     /* Check if trace is enabled. */
     if (((maskType & GT_TRACESTATE_MASK) >> GT_TRACESTATE_SHIFT)
         == GT_TraceState_Enable)
     {
-        if ((classType == GT_ENTER) || (classType == GT_LEAVE))
-        {
-            if ((maskType & GT_TRACEENTER_MASK) == GT_TraceEnter_Enable)
-            {
-                Osal_printf((const char *) infoString, param0);
-            }
-        }
-        else
+        /* Check if specified class is enabled. */
+        if ((maskType & GT_TRACECLASS_MASK) >= classType)
         {
-            /* Check if specified class is enabled. */
-            if ((maskType & GT_TRACECLASS_MASK) >= classType)
+            /* Print if specified class is greater than or equal to class
+             * for this specific print.
+             */
+            if (!((classType == GT_INFO) || (classType == GT_INFO1)))
             {
-                /* Print if specified class is greater than or equal to class
-                 * for this specific print.
-                 */
-                if (!((classType == GT_INFO) || (classType == GT_INFO1)))
-                {
-                    Osal_printf("%s @ Line %d: ", fileName, lineNum);
-                }
-                Osal_printf((const char *) infoString, param0);
+                Fvid2_printf("%s @ Line %d: ", fileName, lineNum);
             }
+            Fvid2_printf((const char *) infoString, param0);
         }
     }
 }
@@ -241,39 +168,29 @@ GT_trace1(uint32_t        maskType,
  *  \param      param1 The second parameter which needs to be logged.
  */
 void
-GT_trace2(uint32_t        maskType,
+GT_trace2(uint32_t      maskType,
           GT_TraceClass classType,
           const char   *fileName,
-          int32_t         lineNum,
+          int32_t       lineNum,
           const char   *infoString,
-          uint32_t        param0,
-          uint32_t        param1)
+          uint32_t      param0,
+          uint32_t      param1)
 {
     /* Check if trace is enabled. */
     if (((maskType & GT_TRACESTATE_MASK) >> GT_TRACESTATE_SHIFT)
         == GT_TraceState_Enable)
     {
-        if ((classType == GT_ENTER) || (classType == GT_LEAVE))
-        {
-            if ((maskType & GT_TRACEENTER_MASK) == GT_TraceEnter_Enable)
-            {
-                Osal_printf((const char *) infoString, param0, param1);
-            }
-        }
-        else
+        /* Check if specified class is enabled. */
+        if ((maskType & GT_TRACECLASS_MASK) >= classType)
         {
-            /* Check if specified class is enabled. */
-            if ((maskType & GT_TRACECLASS_MASK) >= classType)
+            /* Print if specified class is greater than or equal to class
+             * for this specific print.
+             */
+            if (!((classType == GT_INFO) || (classType == GT_INFO1)))
             {
-                /* Print if specified class is greater than or equal to class
-                 * for this specific print.
-                 */
-                if (!((classType == GT_INFO) || (classType == GT_INFO1)))
-                {
-                    Osal_printf("%s @ Line %d: ", fileName, lineNum);
-                }
-                Osal_printf((const char *) infoString, param0, param1);
+                Fvid2_printf("%s @ Line %d: ", fileName, lineNum);
             }
+            Fvid2_printf((const char *) infoString, param0, param1);
         }
     }
 }
@@ -292,42 +209,30 @@ GT_trace2(uint32_t        maskType,
  *  \param      param2 The third parameter which needs to be logged.
  */
 void
-GT_trace3(uint32_t        maskType,
+GT_trace3(uint32_t      maskType,
           GT_TraceClass classType,
           const char   *fileName,
-          int32_t         lineNum,
+          int32_t       lineNum,
           const char   *infoString,
-          uint32_t        param0,
-          uint32_t        param1,
-          uint32_t        param2)
+          uint32_t      param0,
+          uint32_t      param1,
+          uint32_t      param2)
 {
     /* Check if trace is enabled. */
     if (((maskType & GT_TRACESTATE_MASK) >> GT_TRACESTATE_SHIFT)
         == GT_TraceState_Enable)
     {
-        if ((classType == GT_ENTER) || (classType == GT_LEAVE))
+        /* Check if specified class is enabled. */
+        if ((maskType & GT_TRACECLASS_MASK) >= classType)
         {
-            if ((maskType & GT_TRACEENTER_MASK) == GT_TraceEnter_Enable)
+            /* Print if specified class is greater than or equal to class
+             * for this specific print.
+             */
+            if (!((classType == GT_INFO) || (classType == GT_INFO1)))
             {
-                Osal_printf((const char *) infoString, param0, param1,
-                               param2);
-            }
-        }
-        else
-        {
-            /* Check if specified class is enabled. */
-            if ((maskType & GT_TRACECLASS_MASK) >= classType)
-            {
-                /* Print if specified class is greater than or equal to class
-                 * for this specific print.
-                 */
-                if (!((classType == GT_INFO) || (classType == GT_INFO1)))
-                {
-                    Osal_printf("%s @ Line %d: ", fileName, lineNum);
-                }
-                Osal_printf((const char *) infoString, param0, param1,
-                               param2);
+                Fvid2_printf("%s @ Line %d: ", fileName, lineNum);
             }
+            Fvid2_printf((const char *) infoString, param0, param1, param2);
         }
     }
 }
@@ -347,45 +252,32 @@ GT_trace3(uint32_t        maskType,
  *  \param      param3 The fourth parameter which needs to be logged.
  */
 void
-GT_trace4(uint32_t        maskType,
+GT_trace4(uint32_t      maskType,
           GT_TraceClass classType,
           const char   *fileName,
-          int32_t         lineNum,
+          int32_t       lineNum,
           const char   *infoString,
-          uint32_t        param0,
-          uint32_t        param1,
-          uint32_t        param2,
-          uint32_t        param3)
+          uint32_t      param0,
+          uint32_t      param1,
+          uint32_t      param2,
+          uint32_t      param3)
 {
     /* Check if trace is enabled. */
     if (((maskType & GT_TRACESTATE_MASK) >> GT_TRACESTATE_SHIFT)
         == GT_TraceState_Enable)
     {
-        if ((classType == GT_ENTER) || (classType == GT_LEAVE))
+        /* Check if specified class is enabled. */
+        if ((maskType & GT_TRACECLASS_MASK) >= classType)
         {
-            if ((maskType & GT_TRACEENTER_MASK) == GT_TraceEnter_Enable)
+            /* Print if specified class is greater than or equal to class
+             * for this specific print.
+             */
+            if (!((classType == GT_INFO) || (classType == GT_INFO1)))
             {
-                Osal_printf((const char *) infoString, param0, param1,
-                               param2,
-                               param3);
-            }
-        }
-        else
-        {
-            /* Check if specified class is enabled. */
-            if ((maskType & GT_TRACECLASS_MASK) >= classType)
-            {
-                /* Print if specified class is greater than or equal to class
-                 * for this specific print.
-                 */
-                if (!((classType == GT_INFO) || (classType == GT_INFO1)))
-                {
-                    Osal_printf("%s @ Line %d: ", fileName, lineNum);
-                }
-                Osal_printf((const char *) infoString, param0, param1,
-                               param2,
-                               param3);
+                Fvid2_printf("%s @ Line %d: ", fileName, lineNum);
             }
+            Fvid2_printf(
+                (const char *) infoString, param0, param1, param2, param3);
         }
     }
 }
@@ -406,52 +298,34 @@ GT_trace4(uint32_t        maskType,
  *  \param      param4 The fifth parameter which needs to be logged.
  */
 void
-GT_trace5(uint32_t        maskType,
+GT_trace5(uint32_t      maskType,
           GT_TraceClass classType,
           const char   *fileName,
-          int32_t         lineNum,
+          int32_t       lineNum,
           const char   *infoString,
-          uint32_t        param0,
-          uint32_t        param1,
-          uint32_t        param2,
-          uint32_t        param3,
-          uint32_t        param4)
+          uint32_t      param0,
+          uint32_t      param1,
+          uint32_t      param2,
+          uint32_t      param3,
+          uint32_t      param4)
 {
     /* Check if trace is enabled. */
     if (((maskType & GT_TRACESTATE_MASK) >> GT_TRACESTATE_SHIFT)
         == GT_TraceState_Enable)
     {
-        if ((classType == GT_ENTER) || (classType == GT_LEAVE))
-        {
-            if ((maskType & GT_TRACEENTER_MASK) == GT_TraceEnter_Enable)
-            {
-                Osal_printf((const char *) infoString,
-                               param0,
-                               param1,
-                               param2,
-                               param3,
-                               param4);
-            }
-        }
-        else
+        /* Check if specified class is enabled. */
+        if ((maskType & GT_TRACECLASS_MASK) >= classType)
         {
-            /* Check if specified class is enabled. */
-            if ((maskType & GT_TRACECLASS_MASK) >= classType)
+            /* Print if specified class is greater than or equal to class
+             * for this specific print.
+             */
+            if (!((classType == GT_INFO) || (classType == GT_INFO1)))
             {
-                /* Print if specified class is greater than or equal to class
-                 * for this specific print.
-                 */
-                if (!((classType == GT_INFO) || (classType == GT_INFO1)))
-                {
-                    Osal_printf("%s @ Line %d: ", fileName, lineNum);
-                }
-                Osal_printf((const char *) infoString,
-                               param0,
-                               param1,
-                               param2,
-                               param3,
-                               param4);
+                Fvid2_printf("%s @ Line %d: ", fileName, lineNum);
             }
+            Fvid2_printf(
+                (const char *) infoString,
+                param0, param1, param2, param3, param4);
         }
     }
 }
@@ -473,55 +347,35 @@ GT_trace5(uint32_t        maskType,
  *  \param      param5 The sixth parameter which needs to be logged.
  */
 void
-GT_trace6(uint32_t        maskType,
+GT_trace6(uint32_t      maskType,
           GT_TraceClass classType,
           const char   *fileName,
-          int32_t         lineNum,
+          int32_t       lineNum,
           const char   *infoString,
-          uint32_t        param0,
-          uint32_t        param1,
-          uint32_t        param2,
-          uint32_t        param3,
-          uint32_t        param4,
-          uint32_t        param5)
+          uint32_t      param0,
+          uint32_t      param1,
+          uint32_t      param2,
+          uint32_t      param3,
+          uint32_t      param4,
+          uint32_t      param5)
 {
     /* Check if trace is enabled. */
     if (((maskType & GT_TRACESTATE_MASK) >> GT_TRACESTATE_SHIFT)
         == GT_TraceState_Enable)
     {
-        if ((classType == GT_ENTER) || (classType == GT_LEAVE))
-        {
-            if ((maskType & GT_TRACEENTER_MASK) == GT_TraceEnter_Enable)
-            {
-                Osal_printf((const char *) infoString,
-                               param0,
-                               param1,
-                               param2,
-                               param3,
-                               param4,
-                               param5);
-            }
-        }
-        else
+        /* Check if specified class is enabled. */
+        if ((maskType & GT_TRACECLASS_MASK) >= classType)
         {
-            /* Check if specified class is enabled. */
-            if ((maskType & GT_TRACECLASS_MASK) >= classType)
+            /* Print if specified class is greater than or equal to class
+             * for this specific print.
+             */
+            if (!((classType == GT_INFO) || (classType == GT_INFO1)))
             {
-                /* Print if specified class is greater than or equal to class
-                 * for this specific print.
-                 */
-                if (!((classType == GT_INFO) || (classType == GT_INFO1)))
-                {
-                    Osal_printf("%s @ Line %d: ", fileName, lineNum);
-                }
-                Osal_printf((const char *) infoString,
-                               param0,
-                               param1,
-                               param2,
-                               param3,
-                               param4,
-                               param5);
+                Fvid2_printf("%s @ Line %d: ", fileName, lineNum);
             }
+            Fvid2_printf(
+                (const char *) infoString,
+                param0, param1, param2, param3, param4, param5);
         }
     }
 }
@@ -544,92 +398,60 @@ GT_trace6(uint32_t        maskType,
  *  \param      param6 The sixth parameter which needs to be logged.
  */
 void
-GT_trace7(uint32_t        maskType,
+GT_trace7(uint32_t      maskType,
           GT_TraceClass classType,
           const char   *fileName,
-          int32_t         lineNum,
+          int32_t       lineNum,
           const char   *infoString,
-          uint32_t        param0,
-          uint32_t        param1,
-          uint32_t        param2,
-          uint32_t        param3,
-          uint32_t        param4,
-          uint32_t        param5,
-          uint32_t        param6)
+          uint32_t      param0,
+          uint32_t      param1,
+          uint32_t      param2,
+          uint32_t      param3,
+          uint32_t      param4,
+          uint32_t      param5,
+          uint32_t      param6)
 {
     /* Check if trace is enabled. */
     if (((maskType & GT_TRACESTATE_MASK) >> GT_TRACESTATE_SHIFT)
         == GT_TraceState_Enable)
     {
-        if ((classType == GT_ENTER) || (classType == GT_LEAVE))
-        {
-            if ((maskType & GT_TRACEENTER_MASK) == GT_TraceEnter_Enable)
-            {
-                Osal_printf((const char *) infoString,
-                               param0,
-                               param1,
-                               param2,
-                               param3,
-                               param4,
-                               param5,
-                               param6);
-            }
-        }
-        else
+        /* Check if specified class is enabled. */
+        if ((maskType & GT_TRACECLASS_MASK) >= classType)
         {
-            /* Check if specified class is enabled. */
-            if ((maskType & GT_TRACECLASS_MASK) >= classType)
+            /* Print if specified class is greater than or equal to class
+             * for this specific print.
+             */
+            if (!((classType == GT_INFO) || (classType == GT_INFO1)))
             {
-                /* Print if specified class is greater than or equal to class
-                 * for this specific print.
-                 */
-                if (!((classType == GT_INFO) || (classType == GT_INFO1)))
-                {
-                    Osal_printf("%s @ Line %d: ", fileName, lineNum);
-                }
-                Osal_printf((const char *) infoString,
-                               param0,
-                               param1,
-                               param2,
-                               param3,
-                               param4,
-                               param5,
-                               param6);
+                Fvid2_printf("%s @ Line %d: ", fileName, lineNum);
             }
+            Fvid2_printf(
+                (const char *) infoString,
+                param0, param1, param2, param3, param4, param5, param6);
         }
     }
 }
-
-/**
- *  \brief      Function to report the vps failure and log the trace. This
- *              is mostly the fatal error and system can not recover without
- *              module restart.
- *  \param      mask        Indicates whether SetFailure is enabled.
- *  \param      func        Name of the function where this oc.cured
- *  \param      fileName    Where the condition has occured.
- *  \param      lineNum     Line number of the current file where this failure
- *                          has occured.
- *  \param      status      What was the code we got/set for this failure
- *  \param      msg         Any additional information which can be useful for
- *                          deciphering the error condition.
- */
-void GT_failureReasonSet(int32_t  enableMask,
-                         const char  *func,
-                         const char  *fileName,
-                         int32_t  lineNum,
-                         uint32_t status,
-                         const char  *msg)
+#endif
+
+#if defined (FVID2_CFG_ASSERT_ENABLE)
+void GT_assertLocal(uint32_t    enableMask,
+                    uint32_t    condition,
+                    const char *str,
+                    const char *fileName,
+                    int32_t     lineNum)
 {
-    if ((((uint32_t) enableMask &
-          GT_TRACESETFAILURE_MASK) >> GT_TRACESETFAILURE_SHIFT)
-        == GT_TraceState_Enable)
+    if ((!(condition)) != 0)
     {
-        Osal_printf("*** %s: %s\tError [0x%x] at Line no: %d in file %s\r\n",
-                       func,
-                       msg,
-                       status,
-                       lineNum,
-                       fileName);
+        GT_3trace(
+            Fvid2Trace, GT_ERR,
+            " Assertion @ Line: %d in %s: %s : failed !!!\n",
+            lineNum, fileName, str);
+        while (TRUE)
+        {
+            ;
+        }
     }
-}
 
+    return;
+}
+#endif  /* if defined(FVID2_CFG_ASSERT_ENABLE) */