/*******************************************************************************\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
-/******************************************************************************* \r
- * Tracealyzer v2.7.0 Recorder Library\r
+/*******************************************************************************\r
+ * Tracealyzer v2.7.7 Recorder Library\r
* Percepio AB, www.percepio.com\r
*\r
- * trcHardwarePort.c\r
+ * trcBase.c\r
*\r
- * Contains together with trcHardwarePort.h all hardware portability issues of \r
- * the trace recorder library.\r
+ * Core functionality of the trace recorder library.\r
*\r
* Terms of Use\r
* This software is copyright Percepio AB. The recorder library is free for\r
* use together with Percepio products. You may distribute the recorder library\r
- * in its original form, including modifications in trcPort.c and trcPort.h\r
+ * in its original form, including modifications in trcHardwarePort.c/.h\r
* given that these modification are clearly marked as your own modifications\r
- * and documented in the initial comment section of these source files. \r
- * This software is the intellectual property of Percepio AB and may not be \r
- * sold or in other ways commercially redistributed without explicit written \r
+ * and documented in the initial comment section of these source files.\r
+ * This software is the intellectual property of Percepio AB and may not be\r
+ * sold or in other ways commercially redistributed without explicit written\r
* permission by Percepio AB.\r
*\r
- * Disclaimer \r
- * The trace tool and recorder library is being delivered to you AS IS and \r
- * Percepio AB makes no warranty as to its use or performance. Percepio AB does \r
- * not and cannot warrant the performance or results you may obtain by using the \r
- * software or documentation. Percepio AB make no warranties, express or \r
- * implied, as to noninfringement of third party rights, merchantability, or \r
- * fitness for any particular purpose. In no event will Percepio AB, its \r
- * technology partners, or distributors be liable to you for any consequential, \r
- * incidental or special damages, including any lost profits or lost savings, \r
- * even if a representative of Percepio AB has been advised of the possibility \r
- * of such damages, or for any claim by any third party. Some jurisdictions do \r
- * not allow the exclusion or limitation of incidental, consequential or special \r
- * damages, or the exclusion of implied warranties or limitations on how long an \r
+ * Disclaimer\r
+ * The trace tool and recorder library is being delivered to you AS IS and\r
+ * Percepio AB makes no warranty as to its use or performance. Percepio AB does\r
+ * not and cannot warrant the performance or results you may obtain by using the\r
+ * software or documentation. Percepio AB make no warranties, express or\r
+ * implied, as to noninfringement of third party rights, merchantability, or\r
+ * fitness for any particular purpose. In no event will Percepio AB, its\r
+ * technology partners, or distributors be liable to you for any consequential,\r
+ * incidental or special damages, including any lost profits or lost savings,\r
+ * even if a representative of Percepio AB has been advised of the possibility\r
+ * of such damages, or for any claim by any third party. Some jurisdictions do\r
+ * not allow the exclusion or limitation of incidental, consequential or special\r
+ * damages, or the exclusion of implied warranties or limitations on how long an\r
* implied warranty may last, so the above limitations may not apply to you.\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
/*******************************************************************************\r
* uiTraceTickCount\r
*\r
- * This variable is should be updated by the Kernel tick interrupt. This does \r
- * not need to be modified when developing a new timer port. It is preferred to \r
- * keep any timer port changes in the HWTC macro definitions, which typically \r
+ * This variable is should be updated by the Kernel tick interrupt. This does\r
+ * not need to be modified when developing a new timer port. It is preferred to\r
+ * keep any timer port changes in the HWTC macro definitions, which typically\r
* give sufficient flexibility.\r
******************************************************************************/\r
uint32_t uiTraceTickCount = 0;\r
vTraceError("DWT_CYCCNT not supported by this chip!");\r
break;\r
}\r
- \r
+\r
/* Reset the cycle counter */\r
REG_DWT_CYCCNT = 0;\r
\r
REG_DWT_CTRL |= DWT_CTRL_CYCCNTENA;\r
\r
}while(0); /* breaks above jump here */\r
- \r
+\r
if (RecorderDataPtr->frequency == 0)\r
- { \r
+ {\r
RecorderDataPtr->frequency = TRACE_CPU_CLOCK_HZ / HWTC_DIVISOR;\r
}\r
}\r
static uint32_t last_hwtc_count = 0;\r
uint32_t traceTickCount = 0;\r
uint32_t hwtc_count = 0;\r
- \r
+\r
if (trace_disable_timestamp == 1)\r
{\r
if (pTimestamp)\r
*pTimestamp = last_timestamp;\r
return;\r
}\r
- \r
+\r
/* Retrieve HWTC_COUNT only once since the same value should be used all throughout this function. */\r
#if (HWTC_COUNT_DIRECTION == DIRECTION_INCREMENTING)\r
hwtc_count = HWTC_COUNT;\r
#endif\r
\r
#if (SELECTED_PORT == PORT_Win32)\r
- /* The Win32 port uses ulGetRunTimeCounterValue for timestamping, which in turn \r
- uses QueryPerformanceCounter. That function is not always reliable when used over \r
+ /* The Win32 port uses ulGetRunTimeCounterValue for timestamping, which in turn\r
+ uses QueryPerformanceCounter. That function is not always reliable when used over\r
multiple threads. We must therefore handle rare cases where the timestamp is less\r
- than the previous. In practice, the Win32 should "never" roll over since the \r
+ than the previous. In practice, the Win32 should "never" roll over since the\r
performance counter is 64 bit wide. */\r
- \r
+\r
if (last_hwtc_count > hwtc_count)\r
{\r
hwtc_count = last_hwtc_count;\r
traceTickCount = uiTraceTickCount;\r
}\r
\r
- /* Check for overflow. May occur if the update of uiTraceTickCount has been \r
+ /* Check for overflow. May occur if the update of uiTraceTickCount has been\r
delayed due to disabled interrupts. */\r
if (traceTickCount == last_traceTickCount && hwtc_count < last_hwtc_count)\r
{\r
/* A trace tick has occurred but not been executed by the kernel, so we compensate manually. */\r
traceTickCount++;\r
}\r
- \r
+\r
/* Check if the return address is OK, then we perform the calculation. */\r
if (pTimestamp)\r
{\r
*pTimestamp = traceTickCount * (HWTC_PERIOD / HWTC_DIVISOR);\r
/* Increase timestamp by (hwtc_count + "lost hardware ticks from scaling down period") / HWTC_DIVISOR. */\r
*pTimestamp += (hwtc_count + traceTickCount * (HWTC_PERIOD % HWTC_DIVISOR)) / HWTC_DIVISOR;\r
- \r
+\r
last_timestamp = *pTimestamp;\r
}\r
- \r
+\r
/* Store the previous values. */\r
last_traceTickCount = traceTickCount;\r
last_hwtc_count = hwtc_count;\r