/*******************************************************************************\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
*\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
-#include "trcBase.h"\r
+ #include "trcBase.h"\r
\r
#if (USE_TRACEALYZER_RECORDER == 1)\r
\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
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
-/* 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
- * 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
- * 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
- * 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
- * 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
- * \r
+ *\r
* Remember to replace "name" with the correct section name.\r
******************************************************************************/\r
\r
\r
/* This version of the function dynamically allocates the trace data */\r
void prvTraceInitTraceData()\r
-{ \r
+{\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
vTraceError("No recorder data structure allocated!");\r
return;\r
}\r
- \r
+\r
(void)memset(RecorderDataPtr, 0, sizeof(RecorderDataType));\r
\r
RecorderDataPtr->startmarker0 = 0x00;\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
\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
- 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
- if ((objectclass < TRACE_NCLASSES) && (objecthandle > 0) && \r
+ if ((objectclass < TRACE_NCLASSES) && (objecthandle > 0) &&\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
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
{\r
int indexOfHandle;\r
\r
- TRACE_ASSERT(objectclass < TRACE_NCLASSES, \r
+ TRACE_ASSERT(objectclass < TRACE_NCLASSES,\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
uint8_t len;\r
uint8_t crc;\r
TRACE_SR_ALLOC_CRITICAL_SECTION();\r
- \r
+\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
{\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
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
* Updates the index of the event buffer.\r
******************************************************************************/\r
void prvTraceUpdateCounters(void)\r
-{ \r
+{\r
if (RecorderDataPtr->recorderActive == 0)\r
{\r
return;\r
}\r
- \r
+\r
RecorderDataPtr->numEvents++;\r
\r
RecorderDataPtr->nextFreeIndex++;\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
- 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
* If necessary, whole seconds are extracted using division while the rest\r
* comes from the modulo operation.\r
**************************************************************************/\r
- \r
- vTracePortGetTimeStamp(×tamp); \r
- \r
+\r
+ vTracePortGetTimeStamp(×tamp);\r
+\r
/***************************************************************************\r
* Since dts is unsigned the result will be correct even if timestamp has\r
* wrapped around.\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
- * 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
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
unsigned char prvTraceGet8BitHandle(objectHandleType handle)\r
{\r
if (handle > 255)\r
- { \r
+ {\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
- return 255; \r
+ return 255;\r
}\r
return (unsigned char)(handle & 0xFF);\r
}\r