]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/trcBase.c
Final commit before tagging - cosmetic changes only.
[freertos] / FreeRTOS-Plus / Source / FreeRTOS-Plus-Trace / trcBase.c
index 57afa6483f92ec6990a1a15980a828d37e20931a..b772478fd1c7efd7c73a2b0f431fe3a7b8ddbafe 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************\r
 /*******************************************************************************\r
- * Tracealyzer v2.7.0 Recorder Library\r
+ * Tracealyzer v2.7.7 Recorder Library\r
  * Percepio AB, www.percepio.com\r
  *\r
  * trcBase.c\r
  * Percepio AB, www.percepio.com\r
  *\r
  * trcBase.c\r
  *\r
  * Tabs are used for indent in this file (1 tab = 4 spaces)\r
  *\r
  *\r
  * Tabs are used for indent in this file (1 tab = 4 spaces)\r
  *\r
- * Copyright Percepio AB, 2014.\r
+ * Copyright Percepio AB, 2012-2015.\r
  * www.percepio.com\r
  ******************************************************************************/\r
 \r
  * www.percepio.com\r
  ******************************************************************************/\r
 \r
-#include "trcBase.h"\r
+ #include "trcBase.h"\r
 \r
 #if (USE_TRACEALYZER_RECORDER == 1)\r
 \r
 \r
 #if (USE_TRACEALYZER_RECORDER == 1)\r
 \r
@@ -48,7 +48,7 @@
  ******************************************************************************/\r
 \r
 /* Tasks and kernel objects can be explicitly excluded from the trace to reduce\r
  ******************************************************************************/\r
 \r
 /* Tasks and kernel objects can be explicitly excluded from the trace to reduce\r
-buffer usage. This structure handles the exclude flags for all objects and tasks. \r
+buffer usage. This structure handles the exclude flags for all objects and tasks.\r
 Note that slot 0 is not used, since not a valid handle. */\r
 uint8_t excludedObjects[(TRACE_KERNEL_OBJECT_COUNT + TRACE_NCLASSES) / 8 + 1] = { 0 };\r
 \r
 Note that slot 0 is not used, since not a valid handle. */\r
 uint8_t excludedObjects[(TRACE_KERNEL_OBJECT_COUNT + TRACE_NCLASSES) / 8 + 1] = { 0 };\r
 \r
@@ -58,43 +58,43 @@ This structure handle the exclude flags for all event codes */
 uint8_t excludedEventCodes[NEventCodes / 8 + 1] = { 0 };\r
 \r
 /* A set of stacks that keeps track of available object handles for each class.\r
 uint8_t excludedEventCodes[NEventCodes / 8 + 1] = { 0 };\r
 \r
 /* A set of stacks that keeps track of available object handles for each class.\r
-The stacks are empty initially, meaning that allocation of new handles will be \r
+The stacks are empty initially, meaning that allocation of new handles will be\r
 based on a counter (for each object class). Any delete operation will\r
 return the handle to the corresponding stack, for reuse on the next allocate.*/\r
 objectHandleStackType objectHandleStacks = { { 0 }, { 0 }, { 0 }, { 0 }, { 0 } };\r
 \r
 based on a counter (for each object class). Any delete operation will\r
 return the handle to the corresponding stack, for reuse on the next allocate.*/\r
 objectHandleStackType objectHandleStacks = { { 0 }, { 0 }, { 0 }, { 0 }, { 0 } };\r
 \r
-/* Initial HWTC_COUNT value, for detecting if the time-stamping source is \r
-enabled. If using the OS periodic timer for time-stamping, this might not \r
+/* Initial HWTC_COUNT value, for detecting if the time-stamping source is\r
+enabled. If using the OS periodic timer for time-stamping, this might not\r
 have been configured on the earliest events during the startup. */\r
 uint32_t init_hwtc_count;\r
 \r
 /*******************************************************************************\r
  * RecorderData\r
  *\r
 have been configured on the earliest events during the startup. */\r
 uint32_t init_hwtc_count;\r
 \r
 /*******************************************************************************\r
  * RecorderData\r
  *\r
- * The main data structure. This is the data read by the Tracealyzer tools, \r
- * typically through a debugger RAM dump. The recorder uses the pointer \r
+ * The main data structure. This is the data read by the Tracealyzer tools,\r
+ * typically through a debugger RAM dump. The recorder uses the pointer\r
  * RecorderDataPtr for accessing this, to allow for dynamic allocation.\r
  *\r
  * On the NXP LPC17xx you may use the secondary RAM bank (AHB RAM) for this\r
  * purpose. For instance, the LPC1766 has 32 KB AHB RAM which allows for\r
  * allocating a buffer size of at least 7500 events without affecting the main\r
  * RecorderDataPtr for accessing this, to allow for dynamic allocation.\r
  *\r
  * On the NXP LPC17xx you may use the secondary RAM bank (AHB RAM) for this\r
  * purpose. For instance, the LPC1766 has 32 KB AHB RAM which allows for\r
  * allocating a buffer size of at least 7500 events without affecting the main\r
- * RAM. To place RecorderData in this RAM bank using IAR Embedded Workbench \r
+ * RAM. To place RecorderData in this RAM bank using IAR Embedded Workbench\r
  * for ARM, use this pragma right before the declaration:\r
  *\r
  *      #pragma location="AHB_RAM_MEMORY"\r
  *\r
  * This of course works for other hardware architectures with additional RAM\r
  * for ARM, use this pragma right before the declaration:\r
  *\r
  *      #pragma location="AHB_RAM_MEMORY"\r
  *\r
  * This of course works for other hardware architectures with additional RAM\r
- * banks as well, just replace "AHB_RAM_MEMORY" with the section name from the \r
+ * banks as well, just replace "AHB_RAM_MEMORY" with the section name from the\r
  * linker .map file, or simply the desired address.\r
  *\r
  * linker .map file, or simply the desired address.\r
  *\r
- * For portability reasons, we don't add the pragma directly in trcBase.c, but \r
+ * For portability reasons, we don't add the pragma directly in trcBase.c, but\r
  * in a header file included below. To include this header, you need to enable\r
  * USE_LINKER_PRAGMA, defined in trcConfig.h.\r
  *\r
  * If using GCC, you need to modify the declaration as follows:\r
  *\r
  *      RecorderDataType RecorderData __attribute__ ((section ("name"))) = ...\r
  * in a header file included below. To include this header, you need to enable\r
  * USE_LINKER_PRAGMA, defined in trcConfig.h.\r
  *\r
  * If using GCC, you need to modify the declaration as follows:\r
  *\r
  *      RecorderDataType RecorderData __attribute__ ((section ("name"))) = ...\r
- * \r
+ *\r
  * Remember to replace "name" with the correct section name.\r
  ******************************************************************************/\r
 \r
  * Remember to replace "name" with the correct section name.\r
  ******************************************************************************/\r
 \r
@@ -113,9 +113,9 @@ RecorderDataType* RecorderDataPtr = NULL;
 \r
 /* This version of the function dynamically allocates the trace data */\r
 void prvTraceInitTraceData()\r
 \r
 /* This version of the function dynamically allocates the trace data */\r
 void prvTraceInitTraceData()\r
-{              \r
+{\r
        init_hwtc_count = HWTC_COUNT;\r
        init_hwtc_count = HWTC_COUNT;\r
-       \r
+\r
 #if TRACE_DATA_ALLOCATION == TRACE_DATA_ALLOCATION_STATIC\r
        RecorderDataPtr = &RecorderData;\r
 #elif TRACE_DATA_ALLOCATION == TRACE_DATA_ALLOCATION_DYNAMIC\r
 #if TRACE_DATA_ALLOCATION == TRACE_DATA_ALLOCATION_STATIC\r
        RecorderDataPtr = &RecorderData;\r
 #elif TRACE_DATA_ALLOCATION == TRACE_DATA_ALLOCATION_DYNAMIC\r
@@ -132,7 +132,7 @@ void prvTraceInitTraceData()
                vTraceError("No recorder data structure allocated!");\r
                return;\r
        }\r
                vTraceError("No recorder data structure allocated!");\r
                return;\r
        }\r
-               \r
+\r
        (void)memset(RecorderDataPtr, 0, sizeof(RecorderDataType));\r
 \r
        RecorderDataPtr->startmarker0 = 0x00;\r
        (void)memset(RecorderDataPtr, 0, sizeof(RecorderDataType));\r
 \r
        RecorderDataPtr->startmarker0 = 0x00;\r
@@ -196,7 +196,7 @@ void prvTraceInitTraceData()
 \r
        /* Fix the start markers of the trace data structure */\r
        vInitStartMarkers();\r
 \r
        /* Fix the start markers of the trace data structure */\r
        vInitStartMarkers();\r
-       \r
+\r
        #ifdef PORT_SPECIFIC_INIT\r
        PORT_SPECIFIC_INIT();\r
        #endif\r
        #ifdef PORT_SPECIFIC_INIT\r
        PORT_SPECIFIC_INIT();\r
        #endif\r
@@ -242,15 +242,15 @@ void* xTraceNextFreeEventBufferSlot(void)
 \r
 uint16_t uiIndexOfObject(objectHandleType objecthandle, uint8_t objectclass)\r
 {\r
 \r
 uint16_t uiIndexOfObject(objectHandleType objecthandle, uint8_t objectclass)\r
 {\r
-       TRACE_ASSERT(objectclass < TRACE_NCLASSES, \r
+       TRACE_ASSERT(objectclass < TRACE_NCLASSES,\r
                "uiIndexOfObject: Invalid value for objectclass", 0);\r
                "uiIndexOfObject: Invalid value for objectclass", 0);\r
-       TRACE_ASSERT(objecthandle > 0 && objecthandle <= RecorderDataPtr->ObjectPropertyTable.NumberOfObjectsPerClass[objectclass], \r
+       TRACE_ASSERT(objecthandle > 0 && objecthandle <= RecorderDataPtr->ObjectPropertyTable.NumberOfObjectsPerClass[objectclass],\r
                "uiIndexOfObject: Invalid value for objecthandle", 0);\r
 \r
                "uiIndexOfObject: Invalid value for objecthandle", 0);\r
 \r
-       if ((objectclass < TRACE_NCLASSES) && (objecthandle > 0) && \r
+       if ((objectclass < TRACE_NCLASSES) && (objecthandle > 0) &&\r
                (objecthandle <= RecorderDataPtr->ObjectPropertyTable.NumberOfObjectsPerClass[objectclass]))\r
        {\r
                (objecthandle <= RecorderDataPtr->ObjectPropertyTable.NumberOfObjectsPerClass[objectclass]))\r
        {\r
-               return (uint16_t)(RecorderDataPtr->ObjectPropertyTable.StartIndexOfClass[objectclass] + \r
+               return (uint16_t)(RecorderDataPtr->ObjectPropertyTable.StartIndexOfClass[objectclass] +\r
                        (RecorderDataPtr->ObjectPropertyTable.TotalPropertyBytesPerClass[objectclass] * (objecthandle-1)));\r
        }\r
 \r
                        (RecorderDataPtr->ObjectPropertyTable.TotalPropertyBytesPerClass[objectclass] * (objecthandle-1)));\r
        }\r
 \r
@@ -286,7 +286,7 @@ objectHandleType xTraceGetObjectHandle(traceObjectClass objectclass)
        objectHandleType handle;\r
        static int indexOfHandle;\r
 \r
        objectHandleType handle;\r
        static int indexOfHandle;\r
 \r
-       TRACE_ASSERT(objectclass < TRACE_NCLASSES, \r
+       TRACE_ASSERT(objectclass < TRACE_NCLASSES,\r
                "xTraceGetObjectHandle: Invalid value for objectclass", (objectHandleType)0);\r
 \r
        indexOfHandle = objectHandleStacks.indexOfNextAvailableHandle[objectclass];\r
                "xTraceGetObjectHandle: Invalid value for objectclass", (objectHandleType)0);\r
 \r
        indexOfHandle = objectHandleStacks.indexOfNextAvailableHandle[objectclass];\r
@@ -335,9 +335,9 @@ void vTraceFreeObjectHandle(traceObjectClass objectclass, objectHandleType handl
 {\r
        int indexOfHandle;\r
 \r
 {\r
        int indexOfHandle;\r
 \r
-       TRACE_ASSERT(objectclass < TRACE_NCLASSES, \r
+       TRACE_ASSERT(objectclass < TRACE_NCLASSES,\r
                "vTraceFreeObjectHandle: Invalid value for objectclass", );\r
                "vTraceFreeObjectHandle: Invalid value for objectclass", );\r
-       TRACE_ASSERT(handle > 0 && handle <= RecorderDataPtr->ObjectPropertyTable.NumberOfObjectsPerClass[objectclass], \r
+       TRACE_ASSERT(handle > 0 && handle <= RecorderDataPtr->ObjectPropertyTable.NumberOfObjectsPerClass[objectclass],\r
                "vTraceFreeObjectHandle: Invalid value for handle", );\r
 \r
        /* Check that there is room to push the handle on the stack */\r
                "vTraceFreeObjectHandle: Invalid value for handle", );\r
 \r
        /* Check that there is room to push the handle on the stack */\r
@@ -421,10 +421,10 @@ traceLabel prvTraceOpenSymbol(const char* name, traceLabel userEventChannel)
        uint8_t len;\r
        uint8_t crc;\r
        TRACE_SR_ALLOC_CRITICAL_SECTION();\r
        uint8_t len;\r
        uint8_t crc;\r
        TRACE_SR_ALLOC_CRITICAL_SECTION();\r
-       \r
+\r
        len = 0;\r
        crc = 0;\r
        len = 0;\r
        crc = 0;\r
-       \r
+\r
        TRACE_ASSERT(name != NULL, "prvTraceOpenSymbol: name == NULL", (traceLabel)0);\r
 \r
        prvTraceGetChecksum(name, &crc, &len);\r
        TRACE_ASSERT(name != NULL, "prvTraceOpenSymbol: name == NULL", (traceLabel)0);\r
 \r
        prvTraceGetChecksum(name, &crc, &len);\r
@@ -470,9 +470,9 @@ void vTraceError(const char* msg)
        {\r
                traceErrorMessage = (char*)msg;\r
                (void)strncpy(RecorderDataPtr->systemInfo, traceErrorMessage, 80);\r
        {\r
                traceErrorMessage = (char*)msg;\r
                (void)strncpy(RecorderDataPtr->systemInfo, traceErrorMessage, 80);\r
-               RecorderDataPtr->internalErrorOccured = 1;               \r
+               RecorderDataPtr->internalErrorOccured = 1;\r
        }\r
        }\r
-       \r
+\r
 }\r
 \r
 /******************************************************************************\r
 }\r
 \r
 /******************************************************************************\r
@@ -496,7 +496,7 @@ void prvCheckDataToBeOverwrittenForMultiEntryEvents(uint8_t nofEntriesToCheck)
        unsigned int i = 0;\r
        unsigned int e = 0;\r
 \r
        unsigned int i = 0;\r
        unsigned int e = 0;\r
 \r
-       TRACE_ASSERT(nofEntriesToCheck != 0, \r
+       TRACE_ASSERT(nofEntriesToCheck != 0,\r
                "prvCheckDataToBeOverwrittenForMultiEntryEvents: nofEntriesToCheck == 0", );\r
 \r
        while (i < nofEntriesToCheck)\r
                "prvCheckDataToBeOverwrittenForMultiEntryEvents: nofEntriesToCheck == 0", );\r
 \r
        while (i < nofEntriesToCheck)\r
@@ -535,12 +535,12 @@ void prvCheckDataToBeOverwrittenForMultiEntryEvents(uint8_t nofEntriesToCheck)
  * Updates the index of the event buffer.\r
  ******************************************************************************/\r
 void prvTraceUpdateCounters(void)\r
  * Updates the index of the event buffer.\r
  ******************************************************************************/\r
 void prvTraceUpdateCounters(void)\r
-{      \r
+{\r
        if (RecorderDataPtr->recorderActive == 0)\r
        {\r
                return;\r
        }\r
        if (RecorderDataPtr->recorderActive == 0)\r
        {\r
                return;\r
        }\r
-       \r
+\r
        RecorderDataPtr->numEvents++;\r
 \r
        RecorderDataPtr->nextFreeIndex++;\r
        RecorderDataPtr->numEvents++;\r
 \r
        RecorderDataPtr->nextFreeIndex++;\r
@@ -584,9 +584,9 @@ uint16_t prvTraceGetDTS(uint16_t param_maxDTS)
        if (RecorderDataPtr->frequency == 0 && init_hwtc_count != HWTC_COUNT)\r
        {\r
                /* If HWTC_PERIOD is mapped to the timer reload register,\r
        if (RecorderDataPtr->frequency == 0 && init_hwtc_count != HWTC_COUNT)\r
        {\r
                /* If HWTC_PERIOD is mapped to the timer reload register,\r
-               it might not be initialized     before the scheduler has been started. \r
+               it might not be initialized     before the scheduler has been started.\r
                We therefore store the frequency of the timer when the counter\r
                We therefore store the frequency of the timer when the counter\r
-               register has changed from its initial value. \r
+               register has changed from its initial value.\r
                (Note that this function is called also by vTraceStart and\r
                uiTraceStart, which might be called before the scheduler\r
                has been started.) */\r
                (Note that this function is called also by vTraceStart and\r
                uiTraceStart, which might be called before the scheduler\r
                has been started.) */\r
@@ -605,9 +605,9 @@ uint16_t prvTraceGetDTS(uint16_t param_maxDTS)
        * If necessary, whole seconds are extracted using division while the rest\r
        * comes from the modulo operation.\r
        **************************************************************************/\r
        * If necessary, whole seconds are extracted using division while the rest\r
        * comes from the modulo operation.\r
        **************************************************************************/\r
-       \r
-       vTracePortGetTimeStamp(&timestamp);     \r
-       \r
+\r
+       vTracePortGetTimeStamp(&timestamp);\r
+\r
        /***************************************************************************\r
        * Since dts is unsigned the result will be correct even if timestamp has\r
        * wrapped around.\r
        /***************************************************************************\r
        * Since dts is unsigned the result will be correct even if timestamp has\r
        * wrapped around.\r
@@ -818,14 +818,14 @@ void prvTraceGetChecksum(const char *pname, uint8_t* pcrc, uint8_t* plength)
 \r
 #if (USE_16BIT_OBJECT_HANDLES == 1)\r
 \r
 \r
 #if (USE_16BIT_OBJECT_HANDLES == 1)\r
 \r
-void prvTraceStoreXID(objectHandleType handle); \r
+void prvTraceStoreXID(objectHandleType handle);\r
 \r
 /******************************************************************************\r
  * prvTraceStoreXID\r
  *\r
  * Stores an XID (eXtended IDentifier) event.\r
  * This is used if an object/task handle is larger than 255.\r
 \r
 /******************************************************************************\r
  * prvTraceStoreXID\r
  *\r
  * Stores an XID (eXtended IDentifier) event.\r
  * This is used if an object/task handle is larger than 255.\r
- * The parameter "handle" is the full (16 bit) handle, assumed to be 256 or \r
+ * The parameter "handle" is the full (16 bit) handle, assumed to be 256 or\r
  * larger. Handles below 256 should not use this function.\r
  *\r
  * NOTE: this function MUST be called from within a critical section.\r
  * larger. Handles below 256 should not use this function.\r
  *\r
  * NOTE: this function MUST be called from within a critical section.\r
@@ -844,7 +844,7 @@ void prvTraceStoreXID(objectHandleType handle)
                xid->type = XID;\r
 \r
                /* This function is (only) used when objectHandleType is 16 bit... */\r
                xid->type = XID;\r
 \r
                /* This function is (only) used when objectHandleType is 16 bit... */\r
-               xid->xps_16 = handle; \r
+               xid->xps_16 = handle;\r
 \r
                prvTraceUpdateCounters();\r
        }\r
 \r
                prvTraceUpdateCounters();\r
        }\r
@@ -853,11 +853,11 @@ void prvTraceStoreXID(objectHandleType handle)
 unsigned char prvTraceGet8BitHandle(objectHandleType handle)\r
 {\r
        if (handle > 255)\r
 unsigned char prvTraceGet8BitHandle(objectHandleType handle)\r
 {\r
        if (handle > 255)\r
-       {               \r
+       {\r
                prvTraceStoreXID(handle);\r
                prvTraceStoreXID(handle);\r
-               /* The full handle (16 bit) is stored in the XID event. \r
+               /* The full handle (16 bit) is stored in the XID event.\r
                This code (255) is used instead of zero (which is an error code).*/\r
                This code (255) is used instead of zero (which is an error code).*/\r
-               return 255; \r
+               return 255;\r
        }\r
        return (unsigned char)(handle & 0xFF);\r
 }\r
        }\r
        return (unsigned char)(handle & 0xFF);\r
 }\r