mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-08-20 01:58:32 -04:00
Update trace recorder code to the latest.
Some minor changes to enable the configREMOVE_STATIC_QUALIFIER constant to be used by those debuggers that cannot cope with statics being used.
This commit is contained in:
parent
21a8ff35dd
commit
be9c0730c3
25 changed files with 370 additions and 270 deletions
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Trace Recorder Library for Tracealyzer v4.1.1
|
||||
* Trace Recorder Library for Tracealyzer v4.1.5
|
||||
* Percepio AB, www.percepio.com
|
||||
*
|
||||
* trcSnapshotRecorder.c
|
||||
|
@ -7,7 +7,7 @@
|
|||
* The generic core of the trace recorder's snapshot mode.
|
||||
*
|
||||
* Terms of Use
|
||||
* This file is part of the trace recorder library (RECORDER), which is the
|
||||
* This file is part of the trace recorder library (RECORDER), which is the
|
||||
* intellectual property of Percepio AB (PERCEPIO) and provided under a
|
||||
* license as follows.
|
||||
* The RECORDER may be used free of charge for the purpose of recording data
|
||||
|
@ -16,14 +16,14 @@
|
|||
* You may distribute the RECORDER in its original source code form, assuming
|
||||
* this text (terms of use, disclaimer, copyright notice) is unchanged. You are
|
||||
* allowed to distribute the RECORDER with minor modifications intended for
|
||||
* configuration or porting of the RECORDER, e.g., to allow using it on a
|
||||
* configuration or porting of the RECORDER, e.g., to allow using it on a
|
||||
* specific processor, processor family or with a specific communication
|
||||
* interface. Any such modifications should be documented directly below
|
||||
* this comment block.
|
||||
* this comment block.
|
||||
*
|
||||
* Disclaimer
|
||||
* The RECORDER is being delivered to you AS IS and PERCEPIO makes no warranty
|
||||
* as to its use or performance. PERCEPIO does not and cannot warrant the
|
||||
* as to its use or performance. PERCEPIO does not and cannot warrant the
|
||||
* performance or results you may obtain by using the RECORDER or documentation.
|
||||
* PERCEPIO make no warranties, express or implied, as to noninfringement of
|
||||
* third party rights, merchantability, or fitness for any particular purpose.
|
||||
|
@ -107,9 +107,9 @@ extern traceHandle handle_of_last_logged_task;
|
|||
|
||||
/*************** Private Functions *******************************************/
|
||||
static void prvStrncpy(char* dst, const char* src, uint32_t maxLength);
|
||||
static uint8_t prvTraceGetObjectState(uint8_t objectclass, traceHandle id);
|
||||
static void prvTraceGetChecksum(const char *pname, uint8_t* pcrc, uint8_t* plength);
|
||||
static void* prvTraceNextFreeEventBufferSlot(void);
|
||||
static uint8_t prvTraceGetObjectState(uint8_t objectclass, traceHandle id);
|
||||
static void prvTraceGetChecksum(const char *pname, uint8_t* pcrc, uint8_t* plength);
|
||||
static void* prvTraceNextFreeEventBufferSlot(void);
|
||||
static uint16_t prvTraceGetDTS(uint16_t param_maxDTS);
|
||||
static traceString prvTraceOpenSymbol(const char* name, traceString userEventChannel);
|
||||
static void prvTraceUpdateCounters(void);
|
||||
|
@ -136,7 +136,7 @@ static traceString prvTraceLookupSymbolTableEntry(const char* name,
|
|||
void prvTraceIncreaseISRActive(void);
|
||||
void prvTraceDecreaseISRActive(void);
|
||||
#endif /*(TRC_CFG_INCLUDE_ISR_TRACING == 0)*/
|
||||
|
||||
|
||||
#if (TRC_CFG_USE_16BIT_OBJECT_HANDLES == 1)
|
||||
static uint8_t prvTraceGet8BitHandle(traceHandle handle);
|
||||
#else
|
||||
|
@ -204,19 +204,19 @@ void prvTraceError(const char* msg);
|
|||
* Initializes and optionally starts the trace, depending on the start option.
|
||||
* To use the trace recorder, the startup must call vTraceEnable before any RTOS
|
||||
* calls are made (including "create" calls). Three start options are provided:
|
||||
*
|
||||
* TRC_START: Starts the tracing directly. In snapshot mode this allows for
|
||||
*
|
||||
* TRC_START: Starts the tracing directly. In snapshot mode this allows for
|
||||
* starting the trace at any point in your code, assuming vTraceEnable(TRC_INIT)
|
||||
* has been called in the startup.
|
||||
* Can also be used for streaming without Tracealyzer control, e.g. to a local
|
||||
* flash file system (assuming such a "stream port", see trcStreamingPort.h).
|
||||
*
|
||||
*
|
||||
* TRC_INIT: Initializes the trace recorder, but does not start the tracing.
|
||||
* In snapshot mode, this must be followed by a vTraceEnable(TRC_START) sometime
|
||||
* later.
|
||||
*
|
||||
* Usage examples, in snapshot mode:
|
||||
*
|
||||
*
|
||||
* Snapshot trace, from startup:
|
||||
* <board init>
|
||||
* vTraceEnable(TRC_START);
|
||||
|
@ -228,14 +228,14 @@ void prvTraceError(const char* msg);
|
|||
* <RTOS init>
|
||||
* ...
|
||||
* vTraceEnable(TRC_START); // e.g., in task context, at some relevant event
|
||||
*
|
||||
*
|
||||
*
|
||||
* Note: See other implementation of vTraceEnable in trcStreamingRecorder.c
|
||||
******************************************************************************/
|
||||
void vTraceEnable(int startOption)
|
||||
{
|
||||
prvTraceInitTraceData();
|
||||
|
||||
|
||||
if (startOption == TRC_START)
|
||||
{
|
||||
vTraceStart();
|
||||
|
@ -247,7 +247,7 @@ void vTraceEnable(int startOption)
|
|||
else if (startOption != TRC_INIT)
|
||||
{
|
||||
prvTraceError("Unexpected argument to vTraceEnable (snapshot mode)");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
|
@ -325,7 +325,7 @@ uint32_t uiTraceStart(void)
|
|||
TRACE_ASSERT(RecorderDataPtr != NULL, "Recorder not initialized. Use vTraceEnable() instead!", 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
if (RecorderDataPtr->recorderActive == 1)
|
||||
return 1; /* Already running */
|
||||
|
||||
|
@ -553,7 +553,7 @@ void vTraceInstanceFinishedNow(void)
|
|||
* xTraceSetISRProperties
|
||||
*
|
||||
* Stores a name and priority level for an Interrupt Service Routine, to allow
|
||||
* for better visualization. Returns a traceHandle used by vTraceStoreISRBegin.
|
||||
* for better visualization. Returns a traceHandle used by vTraceStoreISRBegin.
|
||||
*
|
||||
* Example:
|
||||
* #define PRIO_ISR_TIMER1 3 // the hardware priority of the interrupt
|
||||
|
@ -569,7 +569,7 @@ void vTraceInstanceFinishedNow(void)
|
|||
******************************************************************************/
|
||||
traceHandle xTraceSetISRProperties(const char* name, uint8_t priority)
|
||||
{
|
||||
static traceHandle handle = 0;
|
||||
static traceHandle handle = 0;
|
||||
TRACE_ASSERT(RecorderDataPtr != NULL, "Recorder not initialized, call vTraceEnable() first!", (traceHandle)0);
|
||||
TRACE_ASSERT(handle <= RecorderDataPtr->ObjectPropertyTable.NumberOfObjectsPerClass[TRACE_CLASS_ISR], "xTraceSetISRProperties: Invalid value for handle", 0);
|
||||
TRACE_ASSERT(name != NULL, "xTraceSetISRProperties: name == NULL", 0);
|
||||
|
@ -578,7 +578,7 @@ void vTraceInstanceFinishedNow(void)
|
|||
|
||||
prvTraceSetObjectName(TRACE_CLASS_ISR, handle, name);
|
||||
prvTraceSetPriorityProperty(TRACE_CLASS_ISR, handle, priority);
|
||||
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
|
@ -608,7 +608,7 @@ void vTraceStoreISRBegin(traceHandle handle)
|
|||
{
|
||||
/*************************************************************************
|
||||
* This occurs if an ISR calls a trace function, preempting a previous
|
||||
* trace call that is being processed in a different ISR or task.
|
||||
* trace call that is being processed in a different ISR or task.
|
||||
* If this occurs, there is probably a problem in the definition of the
|
||||
* recorder's internal critical sections (TRACE_ENTER_CRITICAL_SECTION and
|
||||
* TRACE_EXIT_CRITICAL_SECTION). They must disable the RTOS tick interrupt
|
||||
|
@ -620,14 +620,14 @@ void vTraceStoreISRBegin(traceHandle handle)
|
|||
return;
|
||||
}
|
||||
trcCRITICAL_SECTION_BEGIN();
|
||||
|
||||
|
||||
if (RecorderDataPtr->recorderActive && handle_of_last_logged_task)
|
||||
{
|
||||
uint16_t dts4;
|
||||
|
||||
TRACE_ASSERT(handle != 0, "vTraceStoreISRBegin: Invalid ISR handle (NULL)", TRC_UNUSED);
|
||||
|
||||
TRACE_ASSERT(handle != 0, "vTraceStoreISRBegin: Invalid ISR handle (NULL)", TRC_UNUSED);
|
||||
TRACE_ASSERT(handle <= RecorderDataPtr->ObjectPropertyTable.NumberOfObjectsPerClass[TRACE_CLASS_ISR], "vTraceStoreISRBegin: Invalid ISR handle (> NISR)", TRC_UNUSED);
|
||||
|
||||
|
||||
dts4 = (uint16_t)prvTraceGetDTS(0xFFFF);
|
||||
|
||||
if (RecorderDataPtr->recorderActive) /* Need to repeat this check! */
|
||||
|
@ -663,7 +663,7 @@ void vTraceStoreISRBegin(traceHandle handle)
|
|||
* Registers the end of an Interrupt Service Routine.
|
||||
*
|
||||
* The parameter pendingISR indicates if the interrupt has requested a
|
||||
* task-switch (= 1), e.g., by signaling a semaphore. Otherwise (= 0) the
|
||||
* task-switch (= 1), e.g., by signaling a semaphore. Otherwise (= 0) the
|
||||
* interrupt is assumed to return to the previous context.
|
||||
*
|
||||
* Example:
|
||||
|
@ -684,7 +684,7 @@ void vTraceStoreISREnd(int pendingISR)
|
|||
TSEvent* ts;
|
||||
uint16_t dts5;
|
||||
uint8_t hnd8 = 0, type = 0;
|
||||
|
||||
|
||||
TRACE_ALLOC_CRITICAL_SECTION();
|
||||
|
||||
if (! RecorderDataPtr->recorderActive || ! handle_of_last_logged_task)
|
||||
|
@ -696,7 +696,7 @@ void vTraceStoreISREnd(int pendingISR)
|
|||
{
|
||||
/*************************************************************************
|
||||
* This occurs if an ISR calls a trace function, preempting a previous
|
||||
* trace call that is being processed in a different ISR or task.
|
||||
* trace call that is being processed in a different ISR or task.
|
||||
* If this occurs, there is probably a problem in the definition of the
|
||||
* recorder's internal critical sections (TRACE_ENTER_CRITICAL_SECTION and
|
||||
* TRACE_EXIT_CRITICAL_SECTION). They must disable the RTOS tick interrupt
|
||||
|
@ -707,7 +707,7 @@ void vTraceStoreISREnd(int pendingISR)
|
|||
prvTraceError("vTraceStoreISREnd - recorder busy! See code comment.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (nISRactive == 0)
|
||||
{
|
||||
prvTraceError("Unmatched call to vTraceStoreISREnd (nISRactive == 0, expected > 0)");
|
||||
|
@ -723,7 +723,7 @@ void vTraceStoreISREnd(int pendingISR)
|
|||
type = TS_ISR_RESUME;
|
||||
hnd8 = prvTraceGet8BitHandle(isrstack[nISRactive - 1]); /* isrstack[nISRactive] is the handle of the ISR we're currently exiting. isrstack[nISRactive - 1] is the handle of the ISR that was executing previously. */
|
||||
}
|
||||
else if ((isPendingContextSwitch == 0) || (prvTraceIsSchedulerSuspended()))
|
||||
else if ((isPendingContextSwitch == 0) || (prvTraceIsSchedulerSuspended()))
|
||||
{
|
||||
/* Return to interrupted task, if no context switch will occur in between. */
|
||||
type = TS_TASK_RESUME;
|
||||
|
@ -1081,7 +1081,7 @@ static void prvTraceClearChannelBuffer(uint32_t count)
|
|||
static void prvTraceCopyToDataBuffer(uint32_t* data, uint32_t count)
|
||||
{
|
||||
uint32_t slots;
|
||||
|
||||
|
||||
TRACE_ASSERT(data != NULL,
|
||||
"prvTraceCopyToDataBuffer: data == NULL.", TRC_UNUSED);
|
||||
TRACE_ASSERT(count <= (TRC_CFG_SEPARATE_USER_EVENT_BUFFER_SIZE),
|
||||
|
@ -1137,7 +1137,7 @@ static void prvTraceUBHelper2(traceUBChannel channel, uint32_t* data, uint32_t n
|
|||
{
|
||||
static uint32_t old_timestamp = 0;
|
||||
uint32_t old_nextSlotToWrite = 0;
|
||||
|
||||
|
||||
TRACE_ALLOC_CRITICAL_SECTION();
|
||||
|
||||
TRACE_ASSERT((TRC_CFG_SEPARATE_USER_EVENT_BUFFER_SIZE) >= noOfSlots, "prvTraceUBHelper2: TRC_CFG_SEPARATE_USER_EVENT_BUFFER_SIZE is too small to handle this event.", TRC_UNUSED);
|
||||
|
@ -1189,7 +1189,7 @@ traceUBChannel xTraceRegisterUBChannel(traceString channel, traceString formatSt
|
|||
{
|
||||
uint8_t i;
|
||||
traceUBChannel retVal = 0;
|
||||
|
||||
|
||||
TRACE_ALLOC_CRITICAL_SECTION();
|
||||
|
||||
TRACE_ASSERT(formatStr != 0, "xTraceRegisterChannelFormat: formatStr == 0", (traceUBChannel)0);
|
||||
|
@ -1231,7 +1231,7 @@ traceUBChannel xTraceRegisterUBChannel(traceString channel, traceString formatSt
|
|||
void vTraceUBData(traceUBChannel channelPair, ...)
|
||||
{
|
||||
va_list vl;
|
||||
|
||||
|
||||
TRACE_ASSERT(channelPair != 0, "vTraceUBData: Not a valid traceUBChannel!", TRC_UNUSED);
|
||||
|
||||
va_start(vl, channelPair);
|
||||
|
@ -1531,7 +1531,7 @@ traceString xTraceRegisterString(const char* label)
|
|||
|
||||
#if ((!defined TRC_CFG_INCLUDE_READY_EVENTS) || (TRC_CFG_INCLUDE_READY_EVENTS == 1))
|
||||
|
||||
void prvTraceSetReadyEventsEnabled(int status)
|
||||
void prvTraceSetReadyEventsEnabled(int status)
|
||||
{
|
||||
readyEventsEnabled = status;
|
||||
}
|
||||
|
@ -1541,7 +1541,7 @@ void prvTraceSetReadyEventsEnabled(int status)
|
|||
*
|
||||
* This function stores a ready state for the task handle sent in as parameter.
|
||||
******************************************************************************/
|
||||
void prvTraceStoreTaskReady(traceHandle handle)
|
||||
void prvTraceStoreTaskReady(traceHandle handle)
|
||||
{
|
||||
uint16_t dts3;
|
||||
TREvent* tr;
|
||||
|
@ -1555,11 +1555,11 @@ void prvTraceStoreTaskReady(traceHandle handle)
|
|||
placement of the trace macro. In that case, the events are ignored. */
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (! readyEventsEnabled)
|
||||
{
|
||||
/* When creating tasks, ready events are also created. If creating
|
||||
a "hidden" (not traced) task, we must therefore disable recording
|
||||
/* When creating tasks, ready events are also created. If creating
|
||||
a "hidden" (not traced) task, we must therefore disable recording
|
||||
of ready events to avoid an undesired ready event... */
|
||||
return;
|
||||
}
|
||||
|
@ -1570,7 +1570,7 @@ void prvTraceStoreTaskReady(traceHandle handle)
|
|||
{
|
||||
/*************************************************************************
|
||||
* This occurs if an ISR calls a trace function, preempting a previous
|
||||
* trace call that is being processed in a different ISR or task.
|
||||
* trace call that is being processed in a different ISR or task.
|
||||
* If this occurs, there is probably a problem in the definition of the
|
||||
* recorder's internal critical sections (TRACE_ENTER_CRITICAL_SECTION and
|
||||
* TRACE_EXIT_CRITICAL_SECTION). They must disable the RTOS tick interrupt
|
||||
|
@ -1605,7 +1605,7 @@ void prvTraceStoreTaskReady(traceHandle handle)
|
|||
*
|
||||
* This function stores a low power state.
|
||||
******************************************************************************/
|
||||
void prvTraceStoreLowPower(uint32_t flag)
|
||||
void prvTraceStoreLowPower(uint32_t flag)
|
||||
{
|
||||
uint16_t dts;
|
||||
LPEvent* lp;
|
||||
|
@ -1617,7 +1617,7 @@ void prvTraceStoreLowPower(uint32_t flag)
|
|||
{
|
||||
/*************************************************************************
|
||||
* This occurs if an ISR calls a trace function, preempting a previous
|
||||
* trace call that is being processed in a different ISR or task.
|
||||
* trace call that is being processed in a different ISR or task.
|
||||
* If this occurs, there is probably a problem in the definition of the
|
||||
* recorder's internal critical sections (TRACE_ENTER_CRITICAL_SECTION and
|
||||
* TRACE_EXIT_CRITICAL_SECTION). They must disable the RTOS tick interrupt
|
||||
|
@ -1671,16 +1671,16 @@ void vTraceStoreMemMangEvent(uint32_t ecode, uint32_t address, int32_t signed_si
|
|||
/* Occurs in vTraceInitTraceData, if using dynamic allocation. */
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (signed_size < 0)
|
||||
size = (uint32_t)(- signed_size);
|
||||
else
|
||||
size = (uint32_t)(signed_size);
|
||||
|
||||
trcCRITICAL_SECTION_BEGIN();
|
||||
|
||||
|
||||
heapMemUsage = heapMemUsage + (uint32_t)signed_size;
|
||||
|
||||
|
||||
if (RecorderDataPtr->recorderActive)
|
||||
{
|
||||
dts1 = (uint8_t)prvTraceGetDTS(0xFF);
|
||||
|
@ -1699,7 +1699,7 @@ void vTraceStoreMemMangEvent(uint32_t ecode, uint32_t address, int32_t signed_si
|
|||
/* If the heap address range is within 16 MB, i.e., the upper 8 bits
|
||||
of addresses are constant, this optimization avoids storing an extra
|
||||
event record by ignoring the upper 8 bit of the address */
|
||||
addr_low = address & 0xFFFF;
|
||||
addr_low = address & 0xFFFF;
|
||||
addr_high = (address >> 16) & 0xFF;
|
||||
#else
|
||||
/* The whole 32 bit address is stored using a second event record
|
||||
|
@ -1715,7 +1715,7 @@ void vTraceStoreMemMangEvent(uint32_t ecode, uint32_t address, int32_t signed_si
|
|||
ma->addr_high = addr_high;
|
||||
ma->type = (uint8_t) (ecode + 1); /* Note this! */
|
||||
ms->type = (uint8_t) ecode;
|
||||
prvTraceUpdateCounters();
|
||||
prvTraceUpdateCounters();
|
||||
RecorderDataPtr->heapMemUsage = heapMemUsage;
|
||||
}
|
||||
}
|
||||
|
@ -1747,7 +1747,7 @@ void prvTraceStoreKernelCall(uint32_t ecode, traceObjectClass objectClass, uint3
|
|||
{
|
||||
/*************************************************************************
|
||||
* This occurs if an ISR calls a trace function, preempting a previous
|
||||
* trace call that is being processed in a different ISR or task.
|
||||
* trace call that is being processed in a different ISR or task.
|
||||
* If this occurs, there is probably a problem in the definition of the
|
||||
* recorder's internal critical sections (TRACE_ENTER_CRITICAL_SECTION and
|
||||
* TRACE_EXIT_CRITICAL_SECTION). They must disable the RTOS tick interrupt
|
||||
|
@ -1809,7 +1809,7 @@ void prvTraceStoreKernelCallWithParam(uint32_t evtcode,
|
|||
{
|
||||
/*************************************************************************
|
||||
* This occurs if an ISR calls a trace function, preempting a previous
|
||||
* trace call that is being processed in a different ISR or task.
|
||||
* trace call that is being processed in a different ISR or task.
|
||||
* If this occurs, there is probably a problem in the definition of the
|
||||
* recorder's internal critical sections (TRACE_ENTER_CRITICAL_SECTION and
|
||||
* TRACE_EXIT_CRITICAL_SECTION). They must disable the RTOS tick interrupt
|
||||
|
@ -1899,7 +1899,7 @@ void prvTraceStoreKernelCallWithNumericParamOnly(uint32_t evtcode, uint32_t para
|
|||
{
|
||||
/*************************************************************************
|
||||
* This occurs if an ISR calls a trace function, preempting a previous
|
||||
* trace call that is being processed in a different ISR or task.
|
||||
* trace call that is being processed in a different ISR or task.
|
||||
* If this occurs, there is probably a problem in the definition of the
|
||||
* recorder's internal critical sections (TRACE_ENTER_CRITICAL_SECTION and
|
||||
* TRACE_EXIT_CRITICAL_SECTION). They must disable the RTOS tick interrupt
|
||||
|
@ -2109,13 +2109,13 @@ void prvTraceSetTaskInstanceFinished(traceHandle handle)
|
|||
******************************************************************************/
|
||||
|
||||
/* A set of stacks that keeps track of available object handles for each class.
|
||||
The stacks are empty initially, meaning that allocation of new handles will be
|
||||
The stacks are empty initially, meaning that allocation of new handles will be
|
||||
based on a counter (for each object class). Any delete operation will
|
||||
return the handle to the corresponding stack, for reuse on the next allocate.*/
|
||||
objectHandleStackType objectHandleStacks = { { 0 }, { 0 }, { 0 }, { 0 }, { 0 } };
|
||||
|
||||
/* Initial TRC_HWTC_COUNT value, for detecting if the time-stamping source is
|
||||
enabled. If using the OS periodic timer for time-stamping, this might not
|
||||
/* Initial TRC_HWTC_COUNT value, for detecting if the time-stamping source is
|
||||
enabled. If using the OS periodic timer for time-stamping, this might not
|
||||
have been configured on the earliest events during the startup. */
|
||||
uint32_t init_hwtc_count;
|
||||
|
||||
|
@ -2134,14 +2134,14 @@ RecorderDataType RecorderData;
|
|||
/*******************************************************************************
|
||||
* RecorderDataPtr
|
||||
*
|
||||
* Pointer to the main data structure, when in snapshot mode.
|
||||
* Pointer to the main data structure, when in snapshot mode.
|
||||
******************************************************************************/
|
||||
RecorderDataType* RecorderDataPtr = NULL;
|
||||
|
||||
/* This version of the function dynamically allocates the trace data */
|
||||
void prvTraceInitTraceData()
|
||||
{
|
||||
|
||||
{
|
||||
|
||||
if (RecorderDataPtr == NULL)
|
||||
{
|
||||
#if (TRC_CFG_RECORDER_BUFFER_ALLOCATION == TRC_RECORDER_BUFFER_ALLOCATION_STATIC)
|
||||
|
@ -2169,11 +2169,11 @@ void prvTraceInitTraceData()
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
init_hwtc_count = TRC_HWTC_COUNT;
|
||||
|
||||
|
||||
(void)memset(RecorderDataPtr, 0, sizeof(RecorderDataType));
|
||||
|
||||
|
||||
RecorderDataPtr->version = TRACE_KERNEL_VERSION;
|
||||
RecorderDataPtr->minor_version = TRACE_MINOR_VERSION;
|
||||
RecorderDataPtr->irq_priority_order = TRC_IRQ_PRIORITY_ORDER;
|
||||
|
@ -2218,20 +2218,20 @@ void prvTraceInitTraceData()
|
|||
/* Kernel specific initialization of the objectHandleStacks variable */
|
||||
vTraceInitObjectHandleStack();
|
||||
|
||||
|
||||
/* Finally, the 12-byte "start markers" are initialized, allowing for
|
||||
Tracealyzer to find the trace data in a larger RAM dump.
|
||||
|
||||
|
||||
/* Finally, the 12-byte "start markers" are initialized, allowing for
|
||||
Tracealyzer to find the trace data in a larger RAM dump.
|
||||
|
||||
The start and end markers must be unique, but without proper precautions there
|
||||
might be a risk of accidental duplicates of the start/end markers, e.g., due to
|
||||
compiler optimizations.
|
||||
|
||||
The below initialization of the start marker is therefore made in reverse order
|
||||
and the fields are volatile to ensure this assignment order. This to avoid any
|
||||
|
||||
The below initialization of the start marker is therefore made in reverse order
|
||||
and the fields are volatile to ensure this assignment order. This to avoid any
|
||||
chance of accidental duplicates of this elsewhere in memory.
|
||||
|
||||
|
||||
Moreover, the fields are set byte-by-byte to avoid endian issues.*/
|
||||
|
||||
|
||||
RecorderDataPtr->startmarker11 = 0xF4;
|
||||
RecorderDataPtr->startmarker10 = 0xF3;
|
||||
RecorderDataPtr->startmarker9 = 0xF2;
|
||||
|
@ -2242,8 +2242,8 @@ void prvTraceInitTraceData()
|
|||
RecorderDataPtr->startmarker4 = 0x71;
|
||||
RecorderDataPtr->startmarker3 = 0x04;
|
||||
RecorderDataPtr->startmarker2 = 0x03;
|
||||
RecorderDataPtr->startmarker1 = 0x02;
|
||||
RecorderDataPtr->startmarker0 = 0x01;
|
||||
RecorderDataPtr->startmarker1 = 0x02;
|
||||
RecorderDataPtr->startmarker0 = 0x01;
|
||||
|
||||
if (traceErrorMessage != NULL)
|
||||
{
|
||||
|
@ -2254,7 +2254,7 @@ void prvTraceInitTraceData()
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef TRC_PORT_SPECIFIC_INIT
|
||||
TRC_PORT_SPECIFIC_INIT();
|
||||
#endif
|
||||
|
@ -2280,15 +2280,15 @@ void* prvTraceNextFreeEventBufferSlot(void)
|
|||
|
||||
uint16_t uiIndexOfObject(traceHandle objecthandle, uint8_t objectclass)
|
||||
{
|
||||
TRACE_ASSERT(objectclass < TRACE_NCLASSES,
|
||||
TRACE_ASSERT(objectclass < TRACE_NCLASSES,
|
||||
"uiIndexOfObject: Invalid value for objectclass", 0);
|
||||
TRACE_ASSERT(objecthandle > 0 && objecthandle <= RecorderDataPtr->ObjectPropertyTable.NumberOfObjectsPerClass[objectclass],
|
||||
TRACE_ASSERT(objecthandle > 0 && objecthandle <= RecorderDataPtr->ObjectPropertyTable.NumberOfObjectsPerClass[objectclass],
|
||||
"uiIndexOfObject: Invalid value for objecthandle", 0);
|
||||
|
||||
if ((objectclass < TRACE_NCLASSES) && (objecthandle > 0) &&
|
||||
if ((objectclass < TRACE_NCLASSES) && (objecthandle > 0) &&
|
||||
(objecthandle <= RecorderDataPtr->ObjectPropertyTable.NumberOfObjectsPerClass[objectclass]))
|
||||
{
|
||||
return (uint16_t)(RecorderDataPtr->ObjectPropertyTable.StartIndexOfClass[objectclass] +
|
||||
return (uint16_t)(RecorderDataPtr->ObjectPropertyTable.StartIndexOfClass[objectclass] +
|
||||
(RecorderDataPtr->ObjectPropertyTable.TotalPropertyBytesPerClass[objectclass] * (objecthandle-1)));
|
||||
}
|
||||
|
||||
|
@ -2304,8 +2304,8 @@ traceHandle prvTraceGetObjectHandle(traceObjectClass objectclass)
|
|||
TRACE_ALLOC_CRITICAL_SECTION();
|
||||
|
||||
TRACE_ASSERT(RecorderDataPtr != NULL, "Recorder not initialized, call vTraceEnable() first!", (traceHandle)0);
|
||||
|
||||
TRACE_ASSERT(objectclass < TRACE_NCLASSES,
|
||||
|
||||
TRACE_ASSERT(objectclass < TRACE_NCLASSES,
|
||||
"prvTraceGetObjectHandle: Invalid value for objectclass", (traceHandle)0);
|
||||
|
||||
trcCRITICAL_SECTION_BEGIN();
|
||||
|
@ -2352,9 +2352,9 @@ void prvTraceFreeObjectHandle(traceObjectClass objectclass, traceHandle handle)
|
|||
{
|
||||
int indexOfHandle;
|
||||
|
||||
TRACE_ASSERT(objectclass < TRACE_NCLASSES,
|
||||
TRACE_ASSERT(objectclass < TRACE_NCLASSES,
|
||||
"prvTraceFreeObjectHandle: Invalid value for objectclass", TRC_UNUSED);
|
||||
TRACE_ASSERT(handle > 0 && handle <= RecorderDataPtr->ObjectPropertyTable.NumberOfObjectsPerClass[objectclass],
|
||||
TRACE_ASSERT(handle > 0 && handle <= RecorderDataPtr->ObjectPropertyTable.NumberOfObjectsPerClass[objectclass],
|
||||
"prvTraceFreeObjectHandle: Invalid value for handle", TRC_UNUSED);
|
||||
|
||||
/* Check that there is room to push the handle on the stack */
|
||||
|
@ -2451,10 +2451,10 @@ traceString prvTraceOpenSymbol(const char* name, traceString userEventChannel)
|
|||
uint8_t len;
|
||||
uint8_t crc;
|
||||
TRACE_ALLOC_CRITICAL_SECTION();
|
||||
|
||||
|
||||
len = 0;
|
||||
crc = 0;
|
||||
|
||||
|
||||
TRACE_ASSERT(name != NULL, "prvTraceOpenSymbol: name == NULL", (traceString)0);
|
||||
|
||||
prvTraceGetChecksum(name, &crc, &len);
|
||||
|
@ -2557,7 +2557,7 @@ void prvCheckDataToBeOverwrittenForMultiEntryEvents(uint8_t nofEntriesToCheck)
|
|||
unsigned int i = 0;
|
||||
unsigned int e = 0;
|
||||
|
||||
TRACE_ASSERT(nofEntriesToCheck != 0,
|
||||
TRACE_ASSERT(nofEntriesToCheck != 0,
|
||||
"prvCheckDataToBeOverwrittenForMultiEntryEvents: nofEntriesToCheck == 0", TRC_UNUSED);
|
||||
|
||||
while (i < nofEntriesToCheck)
|
||||
|
@ -2597,12 +2597,12 @@ void prvCheckDataToBeOverwrittenForMultiEntryEvents(uint8_t nofEntriesToCheck)
|
|||
* Updates the index of the event buffer.
|
||||
******************************************************************************/
|
||||
void prvTraceUpdateCounters(void)
|
||||
{
|
||||
{
|
||||
if (RecorderDataPtr->recorderActive == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
RecorderDataPtr->numEvents++;
|
||||
|
||||
RecorderDataPtr->nextFreeIndex++;
|
||||
|
@ -2641,34 +2641,34 @@ uint16_t prvTraceGetDTS(uint16_t param_maxDTS)
|
|||
|
||||
TRACE_ASSERT(param_maxDTS == 0xFF || param_maxDTS == 0xFFFF, "prvTraceGetDTS: Invalid value for param_maxDTS", 0);
|
||||
|
||||
|
||||
|
||||
if (RecorderDataPtr->frequency == 0)
|
||||
{
|
||||
{
|
||||
if (timestampFrequency != 0)
|
||||
{
|
||||
/* If to override default TRC_HWTC_FREQ_HZ value with value set by vTraceSetFrequency */
|
||||
RecorderDataPtr->frequency = timestampFrequency / (TRC_HWTC_DIVISOR);
|
||||
}
|
||||
}
|
||||
else if (init_hwtc_count != (TRC_HWTC_COUNT))
|
||||
{
|
||||
/* If using default value and timer has been started.
|
||||
/* If using default value and timer has been started.
|
||||
Note: If the default frequency value set here would be incorrect, e.g.,
|
||||
if the timer has actually not been configured yet, override this
|
||||
if the timer has actually not been configured yet, override this
|
||||
with vTraceSetFrequency.
|
||||
*/
|
||||
RecorderDataPtr->frequency = (TRC_HWTC_FREQ_HZ) / (TRC_HWTC_DIVISOR);
|
||||
RecorderDataPtr->frequency = (TRC_HWTC_FREQ_HZ) / (TRC_HWTC_DIVISOR);
|
||||
}
|
||||
/* If no override (vTraceSetFrequency) and timer inactive -> no action */
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
* The below statements read the timestamp from the timer port module.
|
||||
* If necessary, whole seconds are extracted using division while the rest
|
||||
* comes from the modulo operation.
|
||||
**************************************************************************/
|
||||
|
||||
prvTracePortGetTimeStamp(×tamp);
|
||||
|
||||
|
||||
prvTracePortGetTimeStamp(×tamp);
|
||||
|
||||
/***************************************************************************
|
||||
* Since dts is unsigned the result will be correct even if timestamp has
|
||||
* wrapped around.
|
||||
|
@ -2878,14 +2878,14 @@ void prvTraceGetChecksum(const char *pname, uint8_t* pcrc, uint8_t* plength)
|
|||
|
||||
#if (TRC_CFG_USE_16BIT_OBJECT_HANDLES == 1)
|
||||
|
||||
static void prvTraceStoreXID(traceHandle handle);
|
||||
static void prvTraceStoreXID(traceHandle handle);
|
||||
|
||||
/******************************************************************************
|
||||
* prvTraceStoreXID
|
||||
*
|
||||
* Stores an XID (eXtended IDentifier) event.
|
||||
* This is used if an object/task handle is larger than 255.
|
||||
* The parameter "handle" is the full (16 bit) handle, assumed to be 256 or
|
||||
* The parameter "handle" is the full (16 bit) handle, assumed to be 256 or
|
||||
* larger. Handles below 256 should not use this function.
|
||||
*
|
||||
* NOTE: this function MUST be called from within a critical section.
|
||||
|
@ -2903,7 +2903,7 @@ static void prvTraceStoreXID(traceHandle handle)
|
|||
xid->type = XID;
|
||||
|
||||
/* This function is (only) used when traceHandle is 16 bit... */
|
||||
xid->xps_16 = handle;
|
||||
xid->xps_16 = handle;
|
||||
|
||||
prvTraceUpdateCounters();
|
||||
}
|
||||
|
@ -2912,11 +2912,11 @@ static void prvTraceStoreXID(traceHandle handle)
|
|||
static uint8_t prvTraceGet8BitHandle(traceHandle handle)
|
||||
{
|
||||
if (handle > 255)
|
||||
{
|
||||
{
|
||||
prvTraceStoreXID(handle);
|
||||
/* The full handle (16 bit) is stored in the XID event.
|
||||
/* The full handle (16 bit) is stored in the XID event.
|
||||
This code (255) is used instead of zero (which is an error code).*/
|
||||
return 255;
|
||||
return 255;
|
||||
}
|
||||
return (uint8_t)(handle & 0xFF);
|
||||
}
|
||||
|
@ -2939,15 +2939,15 @@ void prvTraceInitCortexM()
|
|||
if (TRC_REG_DEMCR == 0)
|
||||
{
|
||||
/* This function is called on Cortex-M3, M4 and M7 devices to initialize
|
||||
the DWT unit, assumed present. The DWT cycle counter is used for timestamping.
|
||||
|
||||
the DWT unit, assumed present. The DWT cycle counter is used for timestamping.
|
||||
|
||||
If the below error is produced, the DWT unit does not seem to be available.
|
||||
|
||||
|
||||
In that case, define the macro TRC_CFG_ARM_CM_USE_SYSTICK in your build
|
||||
to use SysTick timestamping instead, or define your own timestamping by
|
||||
to use SysTick timestamping instead, or define your own timestamping by
|
||||
setting TRC_CFG_HARDWARE_PORT to TRC_HARDWARE_PORT_APPLICATION_DEFINED
|
||||
and make the necessary definitions, as explained in trcHardwarePort.h.*/
|
||||
|
||||
|
||||
prvTraceError("DWT unit not available, see code comment.");
|
||||
break;
|
||||
}
|
||||
|
@ -2956,12 +2956,12 @@ void prvTraceInitCortexM()
|
|||
if (TRC_REG_DWT_CTRL & TRC_DWT_CTRL_NOCYCCNT)
|
||||
{
|
||||
/* This function is called on Cortex-M3, M4 and M7 devices to initialize
|
||||
the DWT unit, assumed present. The DWT cycle counter is used for timestamping.
|
||||
|
||||
the DWT unit, assumed present. The DWT cycle counter is used for timestamping.
|
||||
|
||||
If the below error is produced, the cycle counter does not seem to be available.
|
||||
|
||||
|
||||
In that case, define the macro TRC_CFG_ARM_CM_USE_SYSTICK in your build
|
||||
to use SysTick timestamping instead, or define your own timestamping by
|
||||
to use SysTick timestamping instead, or define your own timestamping by
|
||||
setting TRC_CFG_HARDWARE_PORT to TRC_HARDWARE_PORT_APPLICATION_DEFINED
|
||||
and make the necessary definitions, as explained in trcHardwarePort.h.*/
|
||||
|
||||
|
@ -3071,20 +3071,20 @@ void prvTracePortGetTimeStamp(uint32_t *pTimestamp)
|
|||
}
|
||||
/* Store the previous value */
|
||||
last_traceTickCount = traceTickCount;
|
||||
|
||||
|
||||
#else /*(TRC_HWTC_TYPE == TRC_OS_TIMER_INCR || TRC_HWTC_TYPE == TRC_OS_TIMER_DECR)*/
|
||||
|
||||
|
||||
/* Timestamping is based on a free running timer */
|
||||
/* This part handles free running clocks that can be scaled down to avoid too large DTS values.
|
||||
Without this, the scaled timestamp will incorrectly wrap at (2^32 / TRC_HWTC_DIVISOR) ticks.
|
||||
The scaled timestamp returned from this function is supposed to go from 0 -> 2^32, which in real time would represent (0 -> 2^32 * TRC_HWTC_DIVISOR) ticks. */
|
||||
|
||||
|
||||
/* First we see how long time has passed since the last timestamp call, and we also add the ticks that was lost when we scaled down the last time. */
|
||||
diff = (hwtc_count - last_hwtc_count) + last_hwtc_rest;
|
||||
|
||||
|
||||
/* Scale down the diff */
|
||||
diff_scaled = diff / (TRC_HWTC_DIVISOR);
|
||||
|
||||
|
||||
/* Find out how many ticks were lost when scaling down, so we can add them the next time */
|
||||
last_hwtc_rest = diff % (TRC_HWTC_DIVISOR);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue