mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-08-11 13:54:16 -04:00
Add FreeRTOS-Plus directory with new directory structure so it matches the FreeRTOS directory.
This commit is contained in:
parent
80f7e8cdd4
commit
64a3ab321a
528 changed files with 228252 additions and 0 deletions
524
FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcBase.h
Normal file
524
FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcBase.h
Normal file
|
@ -0,0 +1,524 @@
|
|||
/*******************************************************************************
|
||||
* FreeRTOS+Trace v2.3.0 Recorder Library
|
||||
* Percepio AB, www.percepio.com
|
||||
*
|
||||
* trcBase.h
|
||||
*
|
||||
* Core functionallity of the FreeRTOS+Trace recorder library.
|
||||
*
|
||||
* Terms of Use
|
||||
* This software is copyright Percepio AB. The recorder library is free for
|
||||
* use together with Percepio products. You may distribute the recorder library
|
||||
* in its original form, including modifications in trcPort.c and trcPort.h
|
||||
* given that these modification are clearly marked as your own modifications
|
||||
* and documented in the initial comment section of these source files.
|
||||
* This software is the intellectual property of Percepio AB and may not be
|
||||
* sold or in other ways commercially redistributed without explicit written
|
||||
* permission by Percepio AB.
|
||||
*
|
||||
* Disclaimer
|
||||
* The trace tool and recorder library is being delivered to you AS IS and
|
||||
* Percepio AB makes no warranty as to its use or performance. Percepio AB does
|
||||
* not and cannot warrant the performance or results you may obtain by using the
|
||||
* software or documentation. Percepio AB make no warranties, express or
|
||||
* implied, as to noninfringement of third party rights, merchantability, or
|
||||
* fitness for any particular purpose. In no event will Percepio AB, its
|
||||
* technology partners, or distributors be liable to you for any consequential,
|
||||
* incidental or special damages, including any lost profits or lost savings,
|
||||
* even if a representative of Percepio AB has been advised of the possibility
|
||||
* of such damages, or for any claim by any third party. Some jurisdictions do
|
||||
* not allow the exclusion or limitation of incidental, consequential or special
|
||||
* damages, or the exclusion of implied warranties or limitations on how long an
|
||||
* implied warranty may last, so the above limitations may not apply to you.
|
||||
*
|
||||
* FreeRTOS+Trace is available as Free Edition and in two premium editions.
|
||||
* You may use the premium features during 30 days for evaluation.
|
||||
* Download FreeRTOS+Trace at http://www.percepio.com/products/downloads/
|
||||
*
|
||||
* Copyright Percepio AB, 2012.
|
||||
* www.percepio.com
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef TRCBASE_H
|
||||
#define TRCBASE_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "FreeRTOS.h"
|
||||
#include "trcConfig.h"
|
||||
#include "trcTypes.h"
|
||||
#include "trcPort.h"
|
||||
|
||||
extern volatile int recorder_busy;
|
||||
|
||||
#define trcCRITICAL_SECTION_BEGIN() {taskENTER_CRITICAL(); recorder_busy++;}
|
||||
#define trcCRITICAL_SECTION_END() {recorder_busy--; taskEXIT_CRITICAL();}
|
||||
|
||||
#define NCLASSES 5
|
||||
#define VERSION 0x1AA1
|
||||
#define MINOR_VERSION 1
|
||||
#define STORE_MODE_STOP_WHEN_FULL 1
|
||||
#define STORE_MODE_RING_BUFFER 2
|
||||
#define TRACE_DATA_ALLOCATION_STATIC 1
|
||||
#define TRACE_DATA_ALLOCATION_DYNAMIC 2
|
||||
|
||||
/******************************************************************************
|
||||
* Object Property Table
|
||||
* The Object Table contains name and other properties of the objects (tasks,
|
||||
* queues, mutexes, etc). The below data structures defines the properties of
|
||||
* each object class and are used to cast the byte buffer into a cleaner format.
|
||||
*
|
||||
* The values in the object table are continously overwritten and always
|
||||
* represent the current state. If a property is changed during runtime, the OLD
|
||||
* value should be stored in the trace buffer, not the new value (since the new
|
||||
* value is found in the Object Property Table).
|
||||
* For close events this mechanism is the old names are stored in the symbol
|
||||
* table), for "priority set" (the old priority is stored in the event data)
|
||||
* and for "isActive", where the value decides is the taskswitch event type
|
||||
* should be "new" or "resume".
|
||||
******************************************************************************/
|
||||
|
||||
/* The size of the Object Property Table entries, in bytes, per object */
|
||||
|
||||
/* Queue properties (except name): current number of message in queue */
|
||||
#define PropertyTableSizeQueue (NameLenQueue + 1)
|
||||
|
||||
/* Semaphore properties (except name): state (signaled = 1, cleared = 0) */
|
||||
#define PropertyTableSizeSemaphore (NameLenSemaphore + 1)
|
||||
|
||||
/* Mutex properties (except name): owner (task handle, 0 = free) */
|
||||
#define PropertyTableSizeMutex (NameLenMutex + 1)
|
||||
|
||||
/* Task properties (except name): Byte 0: Current priority
|
||||
Byte 1: state (if already active)
|
||||
Byte 2: InstanceFinishEvent_ServiceCode
|
||||
Byte 3: InstanceFinishEvent_ObjHandle */
|
||||
#define PropertyTableSizeTask (NameLenTask + 4)
|
||||
|
||||
/* ISR properties: Byte 0: priority
|
||||
Byte 1: state (if already active) */
|
||||
#define PropertyTableSizeISR (NameLenISR + 2)
|
||||
|
||||
/* The layout of the byte array representing the Object Property Table */
|
||||
#define StartIndexQueue 0
|
||||
#define StartIndexSemaphore StartIndexQueue + NQueue * PropertyTableSizeQueue
|
||||
#define StartIndexMutex StartIndexSemaphore + NSemaphore * PropertyTableSizeSemaphore
|
||||
#define StartIndexTask StartIndexMutex + NMutex * PropertyTableSizeMutex
|
||||
#define StartIndexISR StartIndexTask + NTask * PropertyTableSizeTask
|
||||
#define DynObjTableSize StartIndexISR + NISR * PropertyTableSizeISR
|
||||
|
||||
typedef struct
|
||||
{
|
||||
/* = NCLASSES */
|
||||
uint32_t NumberOfObjectClasses;
|
||||
|
||||
uint32_t ObjectPropertyTableSizeInBytes;
|
||||
|
||||
/* This is used to calculate the index in the dynamic object table
|
||||
(handle - 1 - nofStaticObjects = index)*/
|
||||
uint8_t NumberOfObjectsPerClass[ 4*((NCLASSES+3)/4)];
|
||||
|
||||
/* Allocation size rounded up to the closest multiple of 4 */
|
||||
uint8_t NameLengthPerClass[ 4*((NCLASSES+3)/4) ];
|
||||
|
||||
uint8_t TotalPropertyBytesPerClass[ 4*((NCLASSES+3)/4) ];
|
||||
|
||||
/* Allocation size rounded up to the closest multiple of 2 */
|
||||
uint16_t StartIndexOfClass[ 2*((NCLASSES+1)/2) ];
|
||||
|
||||
/* The actual handles issued, should be Initiated to all zeros */
|
||||
uint8_t objbytes[ 4*((DynObjTableSize+3)/4) ];
|
||||
} ObjectPropertyTableType;
|
||||
|
||||
/* Symbol table data structure */
|
||||
typedef struct
|
||||
{
|
||||
/* = SYMBOL_HISTORY_TABLE_SIZE_IN_BYTES */
|
||||
uint32_t symTableSize;
|
||||
|
||||
/* Entry 0 is reserved. Any reference to entry 0 implies NULL*/
|
||||
uint32_t nextFreeSymbolIndex;
|
||||
|
||||
/* Size rounded up to closest multiple of 4, to avoid alignment issues*/
|
||||
uint8_t symbytes[4*((SYMBOL_TABLE_SIZE+3)/4)];
|
||||
|
||||
/* Used for lookups - Up to 64 linked lists within the symbol table
|
||||
connecting all entries with the same 6 bit checksum.
|
||||
This field holds the current list heads. Should be initiated to zeros */
|
||||
uint16_t latestEntryOfChecksum[64];
|
||||
} symbolTableType;
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* The data structures of the different events, all 4 bytes long
|
||||
******************************************************************************/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t type;
|
||||
objectHandleType objHandle;
|
||||
uint16_t dts; /* differential timestamp - time since last event */
|
||||
} TSEvent, TREvent;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t type;
|
||||
uint8_t objHandle;
|
||||
uint16_t dts;
|
||||
} KernelCall;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t type;
|
||||
objectHandleType objHandle;
|
||||
uint8_t param;
|
||||
uint8_t dts;
|
||||
} KernelCallWithParamAndHandle;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t type;
|
||||
uint8_t dts;
|
||||
uint16_t param;
|
||||
} KernelCallWithParam16;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t type;
|
||||
objectHandleType objHandle; /* the handle of the closed object */
|
||||
uint16_t symbolIndex; /* the name of the closed object */
|
||||
} ObjCloseNameEvent;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t type;
|
||||
uint8_t arg1;
|
||||
uint8_t arg2;
|
||||
uint8_t arg3;
|
||||
} ObjClosePropEvent;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t type;
|
||||
uint8_t dts;
|
||||
uint16_t payload; /* the name of the user event */
|
||||
} UserEvent;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t type;
|
||||
|
||||
/* 8 bits extra for storing DTS, if it does not fit in ordinary event
|
||||
(this one is always MSB if used) */
|
||||
uint8_t xts_8;
|
||||
|
||||
/* 16 bits extra for storing DTS, if it does not fit in ordinary event. */
|
||||
uint16_t xts_16;
|
||||
} XTSEvent;
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* The main datastructure, read by FreeRTOS+Trace from the RAM dump
|
||||
******************************************************************************/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t startmarker0;
|
||||
uint8_t startmarker1;
|
||||
uint8_t startmarker2;
|
||||
uint8_t startmarker3;
|
||||
uint8_t startmarker4;
|
||||
uint8_t startmarker5;
|
||||
uint8_t startmarker6;
|
||||
uint8_t startmarker7;
|
||||
uint8_t startmarker8;
|
||||
uint8_t startmarker9;
|
||||
uint8_t startmarker10;
|
||||
uint8_t startmarker11;
|
||||
|
||||
/* For FreeRTOS: 0x1AA1 */
|
||||
uint16_t version;
|
||||
|
||||
/* Currently 1 for v2.2.2 (0 earlier)*/
|
||||
uint8_t minor_version;
|
||||
|
||||
/* This should be 0 if lower irq priority values implies higher priority
|
||||
levels, such as on ARM Cortex M. If the opposite scheme is used, i.e.,
|
||||
if higher irq priority values means higher priority, this should be 1. */
|
||||
uint8_t irq_priority_order;
|
||||
|
||||
/* sizeof(RecorderDataType) - just for control */
|
||||
uint32_t filesize;
|
||||
|
||||
/* Current number of events recorded */
|
||||
uint32_t numEvents;
|
||||
|
||||
/* The buffer size, in number of event records */
|
||||
uint32_t maxEvents;
|
||||
|
||||
/* The event buffer index, where to write the next event */
|
||||
uint32_t nextFreeIndex;
|
||||
|
||||
/* 1 if the buffer is full, 0 otherwise */
|
||||
uint32_t bufferIsFull;
|
||||
|
||||
/* The frequency of the clock/timer/counter used as time base */
|
||||
uint32_t frequency;
|
||||
|
||||
/* The absolute timestamp of the last stored event, in the native
|
||||
timebase, modulo frequency! */
|
||||
uint32_t absTimeLastEvent;
|
||||
|
||||
/* The number of seconds in total - lasts for 136 years */
|
||||
uint32_t absTimeLastEventSecond;
|
||||
|
||||
/* 1 if the recorder has been started, 0 if not yet started or stopped.
|
||||
This is a 32 bit variable due to alignment issues. */
|
||||
uint32_t recorderActive;
|
||||
|
||||
/* For storing a Team License key */
|
||||
uint8_t teamLicenceKey[32];
|
||||
|
||||
/* 0xF0F0F0F0 - for control only */
|
||||
int32_t debugMarker0;
|
||||
|
||||
/* The Object Property Table holds information about currently active
|
||||
tasks, queues, and other recorded objects. This is updated on each
|
||||
create call and includes object name and other properties. */
|
||||
ObjectPropertyTableType ObjectPropertyTable;
|
||||
|
||||
/* 0xF1F1F1F1 - for control only */
|
||||
int32_t debugMarker1;
|
||||
|
||||
/* The Symbol Table stores strings for User Events and is also used to
|
||||
store names of deleted objects, which still may be in the trace but no
|
||||
longer are available. */
|
||||
symbolTableType SymbolTable;
|
||||
|
||||
/* For includsion of float support, and for endian detection of floats.
|
||||
The value should be (float)1 or (uint32_t)0 */
|
||||
#if (INCLUDE_FLOAT_SUPPORT == 1)
|
||||
float exampleFloatEncoding;
|
||||
#else
|
||||
uint32_t exampleFloatEncoding;
|
||||
#endif
|
||||
/* This is non-zero if an internal error occured in the recorder, e.g., if
|
||||
one of the Nxxx constants was too small. The systemInfo string will then
|
||||
contain an error message that is displayed when attempting to view the
|
||||
trace file. */
|
||||
uint32_t internalErrorOccured;
|
||||
|
||||
/* 0xF2F2F2F2 - for control only */
|
||||
int32_t debugMarker2;
|
||||
|
||||
/* Generic system information string, presented in the tool. Note that this
|
||||
is also used for storing any internal error messages from the recorder, so
|
||||
do not make TRACE_DESCRIPTION_MAX_LENGTH too small. 80 is recommended. */
|
||||
char systemInfo[TRACE_DESCRIPTION_MAX_LENGTH];
|
||||
|
||||
/* 0xF3F3F3F3 - for control only */
|
||||
int32_t debugMarker3;
|
||||
|
||||
/* The event data, in 4-byte records */
|
||||
uint8_t eventData[ EVENT_BUFFER_SIZE * 4 ];
|
||||
|
||||
uint8_t endmarker0;
|
||||
uint8_t endmarker1;
|
||||
uint8_t endmarker2;
|
||||
uint8_t endmarker3;
|
||||
uint8_t endmarker4;
|
||||
uint8_t endmarker5;
|
||||
uint8_t endmarker6;
|
||||
uint8_t endmarker7;
|
||||
uint8_t endmarker8;
|
||||
uint8_t endmarker9;
|
||||
uint8_t endmarker10;
|
||||
uint8_t endmarker11;
|
||||
|
||||
} RecorderDataType;
|
||||
|
||||
extern RecorderDataType* RecorderDataPtr;
|
||||
|
||||
/******************************************************************************
|
||||
* ObjectHandleStack
|
||||
* This data-structure is used to provide a mechanism for 1-byte trace object
|
||||
* handles. This way, only 1 byte is necessary instead of 4 bytes (a pointer)
|
||||
* when storing a reference to an object. This allows for up to 255 objects of
|
||||
* each object class - Task, ISR, Semaphore, CountingSemaphore, Mutex and Queue,
|
||||
* active at any given moment. There can be more "historic" objects, that have
|
||||
* been deleted - that number is only limited by the size of the symbol table.
|
||||
* Note that handle zero (0) is not used, it is a code for an invalid handle.
|
||||
*
|
||||
* This data structure keeps track of the FREE handles, not the handles in use.
|
||||
* This datastructure contains one stack per object class. When a handle is
|
||||
* allocated to an object, the next free handle is popped from the stack. When
|
||||
* a handle is released (on object delete), it is pushed back on the stack.
|
||||
* Note that there is no initialization code that pushed the free handles
|
||||
* initially, that is not necessary due to the following optimization:
|
||||
*
|
||||
* The stack of handles (objectHandles) is initially all zeros. Since zero
|
||||
* is not a valid handle, that is a signal of additional handles needed.
|
||||
* If a zero is received when popping a new handle, it is replaced by the
|
||||
* index of the popped handle instead.
|
||||
*
|
||||
*****************************************************************************/
|
||||
typedef struct
|
||||
{
|
||||
/* For each object class, the index of the next handle to allocate */
|
||||
int16_t indexOfNextAvailableHandle[ NCLASSES ];
|
||||
|
||||
/* The lowest index of this class (constant) */
|
||||
int16_t lowestIndexOfClass[ NCLASSES ];
|
||||
|
||||
/* The highest index of this class (constant) */
|
||||
int16_t highestIndexOfClass[ NCLASSES ];
|
||||
|
||||
/* The highest use count for this class (for statistics) */
|
||||
int16_t handleCountWaterMarksOfClass[ NCLASSES ];
|
||||
|
||||
/* The free object handles - a set of stacks within this array */
|
||||
objectHandleType objectHandles[ NTask+NISR+NSemaphore+NMutex+NQueue ];
|
||||
|
||||
} objectHandleStackType;
|
||||
|
||||
/* Internal data */
|
||||
|
||||
extern objectHandleStackType objectHandleStacks;
|
||||
|
||||
/* Structures to handle the exclude flags for all objects, tasks and event codes */
|
||||
#define NEventCodes 0x100
|
||||
extern uint8_t excludedFlags[(NEventCodes+NQueue+NSemaphore+NMutex+NTask) / 8 + 1];
|
||||
extern uint8_t ifeFlags[NTask / 8 + 1];
|
||||
|
||||
/* Internal functions */
|
||||
|
||||
uint16_t prvTraceGetDTS(uint16_t param_maxDTS);
|
||||
|
||||
void prvTraceGetChecksum(const char *pname, uint8_t* pcrc, uint8_t* plength);
|
||||
|
||||
traceLabel prvTraceCreateSymbolTableEntry(const char* name,
|
||||
uint8_t crc6,
|
||||
uint8_t len,
|
||||
traceLabel channel);
|
||||
|
||||
traceLabel prvTraceLookupSymbolTableEntry(const char* name,
|
||||
uint8_t crc6,
|
||||
uint8_t len,
|
||||
traceLabel channel);
|
||||
|
||||
traceLabel prvTraceOpenSymbol(const char* name, traceLabel userEventChannel);
|
||||
|
||||
void prvTraceUpdateCounters(void);
|
||||
|
||||
void prvCheckDataToBeOverwrittenForMultiEntryUserEvents(uint8_t nEntries);
|
||||
|
||||
objectHandleType xTraceGetObjectHandle(traceObjectClass objectclass);
|
||||
|
||||
void vTraceFreeObjectHandle(traceObjectClass objectclass,
|
||||
objectHandleType handle);
|
||||
|
||||
void vTraceSetObjectName(traceObjectClass objectclass,
|
||||
objectHandleType handle,
|
||||
const char* name);
|
||||
|
||||
void* xTraceNextFreeEventBufferSlot(void);
|
||||
|
||||
uint16_t uiIndexOfObject(objectHandleType objecthandle,
|
||||
uint8_t objectclass);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* vTraceError
|
||||
*
|
||||
* Called by various parts in the recorder. Stops the recorder and stores a
|
||||
* pointer to an error message, which is printed by the monitor task.
|
||||
******************************************************************************/
|
||||
void vTraceError(const char* msg);
|
||||
|
||||
/*******************************************************************************
|
||||
* xTraceGetLastError
|
||||
*
|
||||
* Gives the last error message, if any. NULL if no error message is stored.
|
||||
* The message is cleared on read.
|
||||
******************************************************************************/
|
||||
char* xTraceGetLastError(void);
|
||||
|
||||
/*******************************************************************************
|
||||
* xTraceInitTraceData
|
||||
*
|
||||
* Allocates and initializes the recorder datastructure, based on the constants
|
||||
* in trcConfig.h. This allows for allocating the data on the heap, instead of
|
||||
* using a static declaration.
|
||||
******************************************************************************/
|
||||
RecorderDataType* xTraceInitTraceData(void);
|
||||
|
||||
/* Internal macros */
|
||||
|
||||
#define PROPERTY_NAME_GET(objectclass, objecthandle) \
|
||||
(const char*)(& RecorderDataPtr->ObjectPropertyTable.objbytes \
|
||||
[uiIndexOfObject(objecthandle, objectclass)])
|
||||
|
||||
#define PROPERTY_OBJECT_STATE(objectclass, handle) \
|
||||
RecorderDataPtr->ObjectPropertyTable.objbytes[uiIndexOfObject(handle, objectclass) \
|
||||
+ RecorderDataPtr->ObjectPropertyTable.NameLengthPerClass[objectclass]]
|
||||
|
||||
#define PROPERTY_ACTOR_PRIORITY(objectclass, handle) \
|
||||
RecorderDataPtr->ObjectPropertyTable.objbytes[uiIndexOfObject(handle, objectclass) \
|
||||
+ RecorderDataPtr->ObjectPropertyTable.NameLengthPerClass[objectclass] + 1]
|
||||
|
||||
#define PROPERTY_TASK_IFE_SERVICECODE(handle) \
|
||||
RecorderDataPtr->ObjectPropertyTable.objbytes \
|
||||
[uiIndexOfObject(handle, TRACE_CLASS_TASK) \
|
||||
+ RecorderDataPtr->ObjectPropertyTable.NameLengthPerClass[TRACE_CLASS_TASK]+2]
|
||||
|
||||
#define PROPERTY_TASK_IFE_OBJHANDLE(handle) \
|
||||
RecorderDataPtr->ObjectPropertyTable.objbytes \
|
||||
[uiIndexOfObject(handle, TRACE_CLASS_TASK) \
|
||||
+ RecorderDataPtr->ObjectPropertyTable.NameLengthPerClass[TRACE_CLASS_TASK]+3]
|
||||
|
||||
#define SET_FLAG_ISEXCLUDED(bitIndex) excludedFlags[(bitIndex) >> 3] |= (1 << ((bitIndex) & 7))
|
||||
#define CLEAR_FLAG_ISEXCLUDED(bitIndex) excludedFlags[(bitIndex) >> 3] &= ~(1 << ((bitIndex) & 7))
|
||||
#define GET_FLAG_ISEXCLUDED(bitIndex) (excludedFlags[(bitIndex) >> 3] & (1 << ((bitIndex) & 7)))
|
||||
|
||||
#define SET_FLAG_MARKIFE(bitIndex) ifeFlags[(bitIndex) >> 3] |= (1 << ((bitIndex) & 7))
|
||||
#define CLEAR_FLAG_MARKIFE(bitIndex) ifeFlags[(bitIndex) >> 3] &= ~(1 << ((bitIndex) & 7))
|
||||
#define GET_FLAG_MARKIFE(bitIndex) (ifeFlags[(bitIndex) >> 3] & (1 << ((bitIndex) & 7)))
|
||||
|
||||
#define SET_EVENT_CODE_FLAG_ISEXCLUDED(eventCode) SET_FLAG_ISEXCLUDED(eventCode)
|
||||
#define CLEAR_EVENT_CODE_FLAG_ISEXCLUDED(eventCode) CLEAR_FLAG_ISEXCLUDED(eventCode)
|
||||
#define GET_EVENT_CODE_FLAG_ISEXCLUDED(eventCode) GET_FLAG_ISEXCLUDED(eventCode)
|
||||
|
||||
#define SET_QUEUE_FLAG_ISEXCLUDED(queueHandle) SET_FLAG_ISEXCLUDED(NEventCodes+queueHandle-1)
|
||||
#define CLEAR_QUEUE_FLAG_ISEXCLUDED(queueHandle) CLEAR_FLAG_ISEXCLUDED(NEventCodes+queueHandle-1)
|
||||
#define GET_QUEUE_FLAG_ISEXCLUDED(queueHandle) GET_FLAG_ISEXCLUDED(NEventCodes+queueHandle-1)
|
||||
|
||||
#define SET_SEMAPHORE_FLAG_ISEXCLUDED(semaphoreHandle) SET_FLAG_ISEXCLUDED(NEventCodes+NQueue+semaphoreHandle-1)
|
||||
#define CLEAR_SEMAPHORE_FLAG_ISEXCLUDED(semaphoreHandle) CLEAR_FLAG_ISEXCLUDED(NEventCodes+NQueue+semaphoreHandle-1)
|
||||
#define GET_SEMAPHORE_FLAG_ISEXCLUDED(semaphoreHandle) GET_FLAG_ISEXCLUDED(NEventCodes+NQueue+semaphoreHandle-1)
|
||||
|
||||
#define SET_MUTEX_FLAG_ISEXCLUDED(mutexHandle) SET_FLAG_ISEXCLUDED(NEventCodes+NQueue+NSemaphore+mutexHandle-1)
|
||||
#define CLEAR_MUTEX_FLAG_ISEXCLUDED(mutexHandle) CLEAR_FLAG_ISEXCLUDED(NEventCodes+NQueue+NSemaphore+mutexHandle-1)
|
||||
#define GET_MUTEX_FLAG_ISEXCLUDED(mutexHandle) GET_FLAG_ISEXCLUDED(NEventCodes+NQueue+NSemaphore+mutexHandle-1)
|
||||
|
||||
#define SET_TASK_FLAG_ISEXCLUDED(taskHandle) SET_FLAG_ISEXCLUDED(NEventCodes+NQueue+NSemaphore+NMutex+taskHandle-1)
|
||||
#define CLEAR_TASK_FLAG_ISEXCLUDED(taskHandle) CLEAR_FLAG_ISEXCLUDED(NEventCodes+NQueue+NSemaphore+NMutex+taskHandle-1)
|
||||
#define GET_TASK_FLAG_ISEXCLUDED(taskHandle) GET_FLAG_ISEXCLUDED(NEventCodes+NQueue+NSemaphore+NMutex+taskHandle-1)
|
||||
|
||||
#define SET_TASK_FLAG_MARKIFE(bitIndex) SET_FLAG_MARKIFE(bitIndex-1)
|
||||
#define CLEAR_TASK_FLAG_MARKIFE(bitIndex) CLEAR_FLAG_MARKIFE(bitIndex-1)
|
||||
#define GET_TASK_FLAG_MARKIFE(bitIndex) GET_FLAG_MARKIFE(bitIndex-1)
|
||||
|
||||
/* For debug printouts - the names of the object classes */
|
||||
extern char OBJECTCLASSNAME[NCLASSES][10];
|
||||
/*=
|
||||
{
|
||||
"QUEUE"
|
||||
"SEMAPHORE",
|
||||
"MUTEX",
|
||||
"TASK",
|
||||
"ISR"
|
||||
};*/
|
||||
|
||||
#endif
|
||||
|
308
FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcHooks.h
Normal file
308
FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcHooks.h
Normal file
|
@ -0,0 +1,308 @@
|
|||
/*******************************************************************************
|
||||
* FreeRTOS+Trace v2.3.0 Recorder Library
|
||||
* Percepio AB, www.percepio.com
|
||||
*
|
||||
* trcHooks.h
|
||||
*
|
||||
* The kernel integration hooks for FreeRTOS (v7.1.0 or later). This file should
|
||||
* be included in the end of FreeRTOSConfig.h, together with:
|
||||
*
|
||||
* #define configUSE_TRACE_FACILITY 1
|
||||
*
|
||||
* NOTE:
|
||||
* For IAR Embedded Workbench for ARM, you need to have a preprocessor condition
|
||||
* on the include, to except it from the assembler step which otherwise give
|
||||
* compile-time errors.
|
||||
*
|
||||
* #ifdef __ICCARM__
|
||||
* #include "percepio/Include/trcHooks.h"
|
||||
* #endif
|
||||
*
|
||||
* Terms of Use
|
||||
* This software is copyright Percepio AB. The recorder library is free for
|
||||
* use together with Percepio products. You may distribute the recorder library
|
||||
* in its original form, including modifications in trcPort.c and trcPort.h
|
||||
* given that these modification are clearly marked as your own modifications
|
||||
* and documented in the initial comment section of these source files.
|
||||
* This software is the intellectual property of Percepio AB and may not be
|
||||
* sold or in other ways commercially redistributed without explicit written
|
||||
* permission by Percepio AB.
|
||||
*
|
||||
* Disclaimer
|
||||
* The trace tool and recorder library is being delivered to you AS IS and
|
||||
* Percepio AB makes no warranty as to its use or performance. Percepio AB does
|
||||
* not and cannot warrant the performance or results you may obtain by using the
|
||||
* software or documentation. Percepio AB make no warranties, express or
|
||||
* implied, as to noninfringement of third party rights, merchantability, or
|
||||
* fitness for any particular purpose. In no event will Percepio AB, its
|
||||
* technology partners, or distributors be liable to you for any consequential,
|
||||
* incidental or special damages, including any lost profits or lost savings,
|
||||
* even if a representative of Percepio AB has been advised of the possibility
|
||||
* of such damages, or for any claim by any third party. Some jurisdictions do
|
||||
* not allow the exclusion or limitation of incidental, consequential or special
|
||||
* damages, or the exclusion of implied warranties or limitations on how long an
|
||||
* implied warranty may last, so the above limitations may not apply to you.
|
||||
*
|
||||
* FreeRTOS+Trace is available as Free Edition and in two premium editions.
|
||||
* You may use the premium features during 30 days for evaluation.
|
||||
* Download FreeRTOS+Trace at http://www.percepio.com/products/downloads/
|
||||
*
|
||||
* Copyright Percepio AB, 2012.
|
||||
* www.percepio.com
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef TRCHOOKS_H
|
||||
#define TRCHOOKS_H
|
||||
|
||||
#if (configUSE_TRACE_FACILITY == 1)
|
||||
|
||||
#include "trcUser.h"
|
||||
|
||||
#undef INCLUDE_xTaskGetSchedulerState
|
||||
#define INCLUDE_xTaskGetSchedulerState 1
|
||||
|
||||
#undef INCLUDE_xTaskGetCurrentTaskHandle
|
||||
#define INCLUDE_xTaskGetCurrentTaskHandle 1
|
||||
|
||||
#if !defined INCLUDE_READY_EVENTS || INCLUDE_READY_EVENTS == 1
|
||||
/* Called for each task that becomes ready */
|
||||
#undef traceMOVED_TASK_TO_READY_STATE
|
||||
#define traceMOVED_TASK_TO_READY_STATE( pxTCB ) \
|
||||
vTraceStoreTaskReady((unsigned char)pxTCB->uxTaskNumber);
|
||||
#endif
|
||||
|
||||
/* Called on each OS tick. Will call uiPortGetTimestamp to make sure it is called at least once every OS tick. */
|
||||
#undef traceTASK_INCREMENT_TICK
|
||||
#define traceTASK_INCREMENT_TICK( xTickCount ) \
|
||||
if (uxSchedulerSuspended == ( unsigned portBASE_TYPE ) pdTRUE || uxMissedTicks == 0) {extern uint32_t uiTraceTickCount; uiTraceTickCount++; uiTracePortGetTimeStamp(0);}
|
||||
|
||||
/* Called on each task-switch */
|
||||
#undef traceTASK_SWITCHED_IN
|
||||
#define traceTASK_SWITCHED_IN() \
|
||||
vTraceStoreTaskswitch();
|
||||
|
||||
/* Called on vTaskSuspend */
|
||||
#undef traceTASK_SUSPEND
|
||||
#define traceTASK_SUSPEND( pxTaskToSuspend ) \
|
||||
vTraceStoreKernelCall(TASK_SUSPEND, TRACE_CLASS_TASK, pxTaskToSuspend->uxTaskNumber); \
|
||||
vTraceSetTaskInstanceFinished((uint8_t)pxTaskToSuspend->uxTaskNumber);
|
||||
|
||||
/* Called on vTaskDelay - note the use of FreeRTOS variable xTicksToDelay */
|
||||
#undef traceTASK_DELAY
|
||||
#define traceTASK_DELAY() \
|
||||
portENTER_CRITICAL(); \
|
||||
vTraceStoreKernelCallWithNumericParamOnly(TASK_DELAY, (uint16_t)xTicksToDelay);\
|
||||
vTraceSetTaskInstanceFinished((uint8_t)pxCurrentTCB->uxTaskNumber);\
|
||||
portEXIT_CRITICAL();
|
||||
|
||||
/* Called on vTaskDelayUntil - note the use of FreeRTOS variable xTimeToWake */
|
||||
#undef traceTASK_DELAY_UNTIL
|
||||
#define traceTASK_DELAY_UNTIL() \
|
||||
portENTER_CRITICAL(); \
|
||||
vTraceStoreKernelCallWithNumericParamOnly(TASK_DELAY_UNTIL, (uint16_t)xTimeToWake); \
|
||||
vTraceSetTaskInstanceFinished((uint8_t)pxCurrentTCB->uxTaskNumber); \
|
||||
portEXIT_CRITICAL();
|
||||
|
||||
#ifndef INCLUDE_OBJECT_DELETE
|
||||
#define INCLUDE_OBJECT_DELETE 1
|
||||
#endif
|
||||
|
||||
#if (INCLUDE_OBJECT_DELETE == 1)
|
||||
/* Called on vTaskDelete */
|
||||
#undef traceTASK_DELETE
|
||||
#define traceTASK_DELETE( pxTaskToDelete ) \
|
||||
trcCRITICAL_SECTION_BEGIN(); \
|
||||
vTraceStoreKernelCall(EVENTGROUP_DELETE + TRACE_CLASS_TASK, TRACE_CLASS_TASK, pxTaskToDelete->uxTaskNumber); \
|
||||
vTraceStoreObjectNameOnCloseEvent((objectHandleType)pxTaskToDelete->uxTaskNumber, TRACE_CLASS_TASK); \
|
||||
vTraceStoreObjectPropertiesOnCloseEvent((objectHandleType)pxTaskToDelete->uxTaskNumber, TRACE_CLASS_TASK); \
|
||||
vTraceSetPriorityProperty(TRACE_CLASS_TASK, (objectHandleType)pxTaskToDelete->uxTaskNumber, (uint8_t)pxTaskToDelete->uxPriority); \
|
||||
vTraceSetObjectState(TRACE_CLASS_TASK, (objectHandleType)pxTaskToDelete->uxTaskNumber, TASK_STATE_INSTANCE_NOT_ACTIVE); \
|
||||
vTraceFreeObjectHandle(TRACE_CLASS_TASK, (objectHandleType)pxTaskToDelete->uxTaskNumber); \
|
||||
trcCRITICAL_SECTION_END();
|
||||
#endif
|
||||
|
||||
/* Called on vTaskCreate */
|
||||
#undef traceTASK_CREATE
|
||||
#define traceTASK_CREATE( pxNewTCB ) \
|
||||
if (pxNewTCB != NULL){ \
|
||||
pxNewTCB->uxTaskNumber = xTraceGetObjectHandle(TRACE_CLASS_TASK); \
|
||||
vTraceSetObjectName(TRACE_CLASS_TASK, (objectHandleType)pxNewTCB->uxTaskNumber, (char*)pxNewTCB->pcTaskName); \
|
||||
vTraceSetPriorityProperty(TRACE_CLASS_TASK, (objectHandleType)pxNewTCB->uxTaskNumber, (uint8_t)pxNewTCB->uxPriority); \
|
||||
vTraceStoreKernelCall(EVENTGROUP_CREATE + TRACE_CLASS_TASK, TRACE_CLASS_TASK, pxNewTCB->uxTaskNumber);\
|
||||
}
|
||||
|
||||
/* Called in vTaskCreate, if it fails (typically if the stack can not be allocated) */
|
||||
#undef traceTASK_CREATE_FAILED
|
||||
#define traceTASK_CREATE_FAILED() \
|
||||
portENTER_CRITICAL();\
|
||||
vTraceStoreKernelCall(EVENTGROUP_FAILED_CREATE + TRACE_CLASS_TASK, TRACE_CLASS_TASK, 0); \
|
||||
portEXIT_CRITICAL();
|
||||
|
||||
/* Called in xQueueCreate, and thereby for all other object based on queues, such as semaphores. */
|
||||
#undef traceQUEUE_CREATE
|
||||
#define traceQUEUE_CREATE( pxNewQueue )\
|
||||
portENTER_CRITICAL(); \
|
||||
pxNewQueue->ucQueueNumber = xTraceGetObjectHandle(TraceObjectClassTable[pxNewQueue->ucQueueType]);\
|
||||
vTraceStoreKernelCall(EVENTGROUP_CREATE + TraceObjectClassTable[pxNewQueue->ucQueueType], TraceObjectClassTable[pxNewQueue->ucQueueType], pxNewQueue->ucQueueNumber); \
|
||||
vTraceSetObjectState(TraceObjectClassTable[pxNewQueue->ucQueueType], pxNewQueue->ucQueueNumber, 0); \
|
||||
portEXIT_CRITICAL();
|
||||
|
||||
/* Called in xQueueCreate, if the queue creation fails */
|
||||
#undef traceQUEUE_CREATE_FAILED
|
||||
#define traceQUEUE_CREATE_FAILED( queueType ) \
|
||||
portENTER_CRITICAL();\
|
||||
vTraceStoreKernelCall((uint8_t)(EVENTGROUP_FAILED_CREATE + TraceObjectClassTable[queueType]), TraceObjectClassTable[queueType], 0); \
|
||||
portEXIT_CRITICAL();
|
||||
|
||||
/* Called in xQueueCreateMutex, and thereby also from xSemaphoreCreateMutex and xSemaphoreCreateRecursiveMutex */
|
||||
#undef traceCREATE_MUTEX
|
||||
#define traceCREATE_MUTEX( pxNewQueue ) \
|
||||
portENTER_CRITICAL();\
|
||||
pxNewQueue->ucQueueNumber = xTraceGetObjectHandle(TRACE_CLASS_MUTEX); \
|
||||
vTraceStoreKernelCall(EVENTGROUP_CREATE + TraceObjectClassTable[pxNewQueue->ucQueueType], TraceObjectClassTable[pxNewQueue->ucQueueType], pxNewQueue->ucQueueNumber); \
|
||||
vTraceSetObjectState(TraceObjectClassTable[pxNewQueue->ucQueueType], pxNewQueue->ucQueueNumber, 0); \
|
||||
portEXIT_CRITICAL();
|
||||
|
||||
/* Called in xQueueCreateMutex when the operation fails (when memory allocation fails) */
|
||||
#undef traceCREATE_MUTEX_FAILED
|
||||
#define traceCREATE_MUTEX_FAILED() \
|
||||
portENTER_CRITICAL();\
|
||||
vTraceStoreKernelCall(EVENTGROUP_FAILED_CREATE + TRACE_CLASS_MUTEX, TRACE_CLASS_MUTEX, 0);\
|
||||
portEXIT_CRITICAL();
|
||||
|
||||
/* Called when the Mutex can not be given, since not holder */
|
||||
#undef traceGIVE_MUTEX_RECURSIVE_FAILED
|
||||
#define traceGIVE_MUTEX_RECURSIVE_FAILED( pxMutex ) \
|
||||
portENTER_CRITICAL();\
|
||||
vTraceStoreKernelCall(EVENTGROUP_FAILED_SEND + TRACE_CLASS_MUTEX, TRACE_CLASS_MUTEX, pxMutex->ucQueueNumber); \
|
||||
portEXIT_CRITICAL();
|
||||
|
||||
/* Called when a message is sent to a queue */
|
||||
#undef traceQUEUE_SEND
|
||||
#define traceQUEUE_SEND( pxQueue ) \
|
||||
vTraceStoreKernelCall(EVENTGROUP_SEND + TraceObjectClassTable[pxQueue->ucQueueType], TraceObjectClassTable[pxQueue->ucQueueType], pxQueue->ucQueueNumber); \
|
||||
if (TraceObjectClassTable[pxQueue->ucQueueType] == TRACE_CLASS_MUTEX){\
|
||||
vTraceSetObjectState(TraceObjectClassTable[pxQueue->ucQueueType], (uint8_t)pxQueue->ucQueueNumber, (uint8_t)0); \
|
||||
}else{\
|
||||
vTraceSetObjectState(TraceObjectClassTable[pxQueue->ucQueueType], (uint8_t)pxQueue->ucQueueNumber, (uint8_t)(pxQueue->uxMessagesWaiting + 1)); \
|
||||
}
|
||||
|
||||
/* Called when a message failed to be sent to a queue (timeout) */
|
||||
#undef traceQUEUE_SEND_FAILED
|
||||
#define traceQUEUE_SEND_FAILED( pxQueue ) \
|
||||
portENTER_CRITICAL();\
|
||||
vTraceStoreKernelCall(EVENTGROUP_FAILED_SEND + TraceObjectClassTable[pxQueue->ucQueueType], TraceObjectClassTable[pxQueue->ucQueueType], pxQueue->ucQueueNumber); \
|
||||
portEXIT_CRITICAL();
|
||||
|
||||
/* Called when the task is blocked due to a send operation on a full queue */
|
||||
#undef traceBLOCKING_ON_QUEUE_SEND
|
||||
#define traceBLOCKING_ON_QUEUE_SEND( pxQueue ) \
|
||||
portENTER_CRITICAL();\
|
||||
vTraceStoreKernelCall(EVENTGROUP_BLOCK_ON_SEND + TraceObjectClassTable[pxQueue->ucQueueType], TraceObjectClassTable[pxQueue->ucQueueType], pxQueue->ucQueueNumber); \
|
||||
portEXIT_CRITICAL();
|
||||
|
||||
/* Called when a message is received from a queue */
|
||||
#undef traceQUEUE_RECEIVE
|
||||
#define traceQUEUE_RECEIVE( pxQueue ) \
|
||||
vTraceStoreKernelCall(EVENTGROUP_RECEIVE + TraceObjectClassTable[pxQueue->ucQueueType], TraceObjectClassTable[pxQueue->ucQueueType], pxQueue->ucQueueNumber); \
|
||||
if (TraceObjectClassTable[pxQueue->ucQueueType] == TRACE_CLASS_MUTEX){\
|
||||
extern volatile void * volatile pxCurrentTCB; \
|
||||
vTraceSetObjectState(TraceObjectClassTable[pxQueue->ucQueueType], (objectHandleType)pxQueue->ucQueueNumber, (objectHandleType)uxTaskGetTaskNumber((xTaskHandle)pxCurrentTCB)); /*For mutex, store the new owner rather than queue length */ \
|
||||
}else{\
|
||||
vTraceSetObjectState(TraceObjectClassTable[pxQueue->ucQueueType], (objectHandleType)pxQueue->ucQueueNumber, (uint8_t)(pxQueue->uxMessagesWaiting - 1)); \
|
||||
}
|
||||
|
||||
/* Called when the task is blocked due to a receive operation on an empty queue */
|
||||
#undef traceBLOCKING_ON_QUEUE_RECEIVE
|
||||
#define traceBLOCKING_ON_QUEUE_RECEIVE( pxQueue ) \
|
||||
portENTER_CRITICAL(); \
|
||||
vTraceStoreKernelCall(EVENTGROUP_BLOCK_ON_RECEIVE + TraceObjectClassTable[pxQueue->ucQueueType], TraceObjectClassTable[pxQueue->ucQueueType], pxQueue->ucQueueNumber); \
|
||||
if (TraceObjectClassTable[pxQueue->ucQueueType] != TRACE_CLASS_MUTEX){\
|
||||
extern volatile void * volatile pxCurrentTCB; \
|
||||
vTraceSetTaskInstanceFinished((objectHandleType)uxTaskGetTaskNumber((xTaskHandle)pxCurrentTCB)); \
|
||||
}\
|
||||
portEXIT_CRITICAL();
|
||||
|
||||
/* Called on xQueuePeek */
|
||||
#undef traceQUEUE_PEEK
|
||||
#define traceQUEUE_PEEK( pxQueue ) \
|
||||
vTraceStoreKernelCall(EVENTGROUP_PEEK + TraceObjectClassTable[pxQueue->ucQueueType], TraceObjectClassTable[pxQueue->ucQueueType], pxQueue->ucQueueNumber);
|
||||
|
||||
/* Called when a receive operation on a queue fails (timeout) */
|
||||
#undef traceQUEUE_RECEIVE_FAILED
|
||||
#define traceQUEUE_RECEIVE_FAILED( pxQueue ) \
|
||||
portENTER_CRITICAL(); \
|
||||
vTraceStoreKernelCall(EVENTGROUP_FAILED_RECEIVE + TraceObjectClassTable[pxQueue->ucQueueType], TraceObjectClassTable[pxQueue->ucQueueType], pxQueue->ucQueueNumber); \
|
||||
portEXIT_CRITICAL();
|
||||
|
||||
/* Called when a message is sent from interrupt context, e.g., using xQueueSendFromISR */
|
||||
#undef traceQUEUE_SEND_FROM_ISR
|
||||
#define traceQUEUE_SEND_FROM_ISR( pxQueue ) \
|
||||
vTraceStoreKernelCall(EVENTGROUP_SEND_FROM_ISR + TraceObjectClassTable[pxQueue->ucQueueType], TraceObjectClassTable[pxQueue->ucQueueType], pxQueue->ucQueueNumber); \
|
||||
vTraceSetObjectState(TraceObjectClassTable[pxQueue->ucQueueType], (objectHandleType)pxQueue->ucQueueNumber, (uint8_t)(pxQueue->uxMessagesWaiting + 1));
|
||||
|
||||
/* Called when a message send from interrupt context fails (since the queue was full) */
|
||||
#undef traceQUEUE_SEND_FROM_ISR_FAILED
|
||||
#define traceQUEUE_SEND_FROM_ISR_FAILED( pxQueue ) \
|
||||
vTraceStoreKernelCall(EVENTGROUP_FAILED_SEND_FROM_ISR + TraceObjectClassTable[pxQueue->ucQueueType], TraceObjectClassTable[pxQueue->ucQueueType], pxQueue->ucQueueNumber);
|
||||
|
||||
/* Called when a message is received in interrupt context, e.g., using xQueueReceiveFromISR */
|
||||
#undef traceQUEUE_RECEIVE_FROM_ISR
|
||||
#define traceQUEUE_RECEIVE_FROM_ISR( pxQueue ) \
|
||||
vTraceStoreKernelCall(EVENTGROUP_RECEIVE_FROM_ISR + TraceObjectClassTable[pxQueue->ucQueueType], TraceObjectClassTable[pxQueue->ucQueueType], pxQueue->ucQueueNumber); \
|
||||
vTraceSetObjectState(TraceObjectClassTable[pxQueue->ucQueueType], (objectHandleType)pxQueue->ucQueueNumber, (uint8_t)(pxQueue->uxMessagesWaiting - 1));
|
||||
|
||||
/* Called when a message receive from interrupt context fails (since the queue was empty) */
|
||||
#undef traceQUEUE_RECEIVE_FROM_ISR_FAILED
|
||||
#define traceQUEUE_RECEIVE_FROM_ISR_FAILED( pxQueue ) \
|
||||
vTraceStoreKernelCall(EVENTGROUP_FAILED_RECEIVE_FROM_ISR + TraceObjectClassTable[pxQueue->ucQueueType], TraceObjectClassTable[pxQueue->ucQueueType], pxQueue->ucQueueNumber);
|
||||
|
||||
#if (INCLUDE_OBJECT_DELETE == 1)
|
||||
/* Called on vQueueDelete */
|
||||
#undef traceQUEUE_DELETE
|
||||
#define traceQUEUE_DELETE( pxQueue ) \
|
||||
{ \
|
||||
portENTER_CRITICAL();\
|
||||
vTraceStoreKernelCall(EVENTGROUP_DELETE + TraceObjectClassTable[pxQueue->ucQueueType], TraceObjectClassTable[pxQueue->ucQueueType], pxQueue->ucQueueNumber); \
|
||||
vTraceStoreObjectNameOnCloseEvent((objectHandleType)pxQueue->ucQueueNumber, TraceObjectClassTable[pxQueue->ucQueueType]); \
|
||||
vTraceStoreObjectPropertiesOnCloseEvent((objectHandleType)pxQueue->ucQueueNumber, TraceObjectClassTable[pxQueue->ucQueueType]); \
|
||||
if (TraceObjectClassTable[pxQueue->ucQueueType] == TRACE_CLASS_MUTEX){ \
|
||||
vTraceSetObjectState(TraceObjectClassTable[pxQueue->ucQueueType], (objectHandleType)pxQueue->ucQueueNumber, (objectHandleType)uxTaskGetTaskNumber((xTaskHandle)pxQueue->pxMutexHolder)); \
|
||||
}else{ \
|
||||
vTraceSetObjectState(TraceObjectClassTable[pxQueue->ucQueueType], (objectHandleType)pxQueue->ucQueueNumber, (uint8_t)uxQueueMessagesWaiting(pxQueue)); \
|
||||
} \
|
||||
vTraceFreeObjectHandle(TraceObjectClassTable[pxQueue->ucQueueType], (objectHandleType)pxQueue->ucQueueNumber); \
|
||||
portEXIT_CRITICAL();\
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Called in vTaskPrioritySet */
|
||||
#undef traceTASK_PRIORITY_SET
|
||||
#define traceTASK_PRIORITY_SET( pxTask, uxNewPriority ) \
|
||||
vTraceStoreKernelCallWithParam(TASK_PRIORITY_SET, TRACE_CLASS_TASK, pxTask->uxTaskNumber, uiTraceGetPriorityProperty(TRACE_CLASS_TASK, (uint8_t)pxTask->uxTaskNumber));\
|
||||
vTraceSetPriorityProperty( TRACE_CLASS_TASK, (uint8_t)pxTask->uxTaskNumber, (uint8_t)uxNewPriority);
|
||||
|
||||
/* Called in vTaskPriorityInherit, which is called by Mutex operations */
|
||||
#undef traceTASK_PRIORITY_INHERIT
|
||||
#define traceTASK_PRIORITY_INHERIT( pxTask, uxNewPriority ) \
|
||||
vTraceStoreKernelCallWithParam(TASK_PRIORITY_INHERIT, TRACE_CLASS_TASK, pxTask->uxTaskNumber, uiTraceGetPriorityProperty(TRACE_CLASS_TASK, (uint8_t)pxTask->uxTaskNumber));\
|
||||
vTraceSetPriorityProperty( TRACE_CLASS_TASK, (uint8_t)pxTask->uxTaskNumber, (uint8_t)uxNewPriority );
|
||||
|
||||
/* Called in vTaskPriorityDisinherit, which is called by Mutex operations */
|
||||
#undef traceTASK_PRIORITY_DISINHERIT
|
||||
#define traceTASK_PRIORITY_DISINHERIT( pxTask, uxNewPriority ) \
|
||||
vTraceStoreKernelCallWithParam(TASK_PRIORITY_DISINHERIT, TRACE_CLASS_TASK, pxTask->uxTaskNumber, uiTraceGetPriorityProperty(TRACE_CLASS_TASK, (uint8_t)pxTask->uxTaskNumber));\
|
||||
vTraceSetPriorityProperty( TRACE_CLASS_TASK, (uint8_t)pxTask->uxTaskNumber, (uint8_t)uxNewPriority );
|
||||
|
||||
/* Called in vTaskResume */
|
||||
#undef traceTASK_RESUME
|
||||
#define traceTASK_RESUME( pxTaskToResume ) \
|
||||
vTraceStoreKernelCall(TASK_RESUME, TRACE_CLASS_TASK, pxTaskToResume->uxTaskNumber);
|
||||
|
||||
/* Called in vTaskResumeFromISR */
|
||||
#undef traceTASK_RESUME_FROM_ISR
|
||||
#define traceTASK_RESUME_FROM_ISR( pxTaskToResume )\
|
||||
vTraceStoreKernelCall(TASK_RESUME_FROM_ISR, TRACE_CLASS_TASK, pxTaskToResume->uxTaskNumber);
|
||||
|
||||
#endif
|
||||
#endif
|
274
FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcKernel.h
Normal file
274
FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcKernel.h
Normal file
|
@ -0,0 +1,274 @@
|
|||
/*******************************************************************************
|
||||
* FreeRTOS+Trace v2.3.0 Recorder Library
|
||||
* Percepio AB, www.percepio.com
|
||||
*
|
||||
* trcKernel.h
|
||||
*
|
||||
* Functions used by trcHooks.h, for the FreeRTOS kernel integration.
|
||||
*
|
||||
* Terms of Use
|
||||
* This software is copyright Percepio AB. The recorder library is free for
|
||||
* use together with Percepio products. You may distribute the recorder library
|
||||
* in its original form, including modifications in trcPort.c and trcPort.h
|
||||
* given that these modification are clearly marked as your own modifications
|
||||
* and documented in the initial comment section of these source files.
|
||||
* This software is the intellectual property of Percepio AB and may not be
|
||||
* sold or in other ways commercially redistributed without explicit written
|
||||
* permission by Percepio AB.
|
||||
*
|
||||
* Disclaimer
|
||||
* The trace tool and recorder library is being delivered to you AS IS and
|
||||
* Percepio AB makes no warranty as to its use or performance. Percepio AB does
|
||||
* not and cannot warrant the performance or results you may obtain by using the
|
||||
* software or documentation. Percepio AB make no warranties, express or
|
||||
* implied, as to noninfringement of third party rights, merchantability, or
|
||||
* fitness for any particular purpose. In no event will Percepio AB, its
|
||||
* technology partners, or distributors be liable to you for any consequential,
|
||||
* incidental or special damages, including any lost profits or lost savings,
|
||||
* even if a representative of Percepio AB has been advised of the possibility
|
||||
* of such damages, or for any claim by any third party. Some jurisdictions do
|
||||
* not allow the exclusion or limitation of incidental, consequential or special
|
||||
* damages, or the exclusion of implied warranties or limitations on how long an
|
||||
* implied warranty may last, so the above limitations may not apply to you.
|
||||
*
|
||||
* FreeRTOS+Trace is available as Free Edition and in two premium editions.
|
||||
* You may use the premium features during 30 days for evaluation.
|
||||
* Download FreeRTOS+Trace at http://www.percepio.com/products/downloads/
|
||||
*
|
||||
* Copyright Percepio AB, 2012.
|
||||
* www.percepio.com
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef TRCKERNEL_H
|
||||
#define TRCKERNEL_H
|
||||
|
||||
#include "trcBase.h"
|
||||
|
||||
/* Internal functions */
|
||||
|
||||
|
||||
#if !defined INCLUDE_READY_EVENTS || INCLUDE_READY_EVENTS == 1
|
||||
void vTraceStoreTaskReady(objectHandleType handle);
|
||||
#endif
|
||||
|
||||
void vTraceStoreTaskswitch(void);
|
||||
|
||||
void vTraceStoreKernelCall(uint32_t eventcode, traceObjectClass objectClass, uint32_t byteParam);
|
||||
|
||||
void vTraceStoreKernelCallWithNumericParamOnly(uint32_t evtcode,
|
||||
uint16_t param);
|
||||
|
||||
void vTraceStoreKernelCallWithParam(uint32_t evtcode, traceObjectClass objectClass,
|
||||
uint32_t objectNumber, uint8_t param);
|
||||
|
||||
void vTraceSetTaskInstanceFinished(objectHandleType handle);
|
||||
|
||||
void vTraceSetPriorityProperty(uint8_t objectclass, uint8_t id, uint8_t value);
|
||||
|
||||
uint8_t uiTraceGetPriorityProperty(uint8_t objectclass, uint8_t id);
|
||||
|
||||
void vTraceSetObjectState(uint8_t objectclass, uint8_t id, uint8_t value);
|
||||
|
||||
uint8_t uiTraceGetObjectState(uint8_t objectclass, uint8_t id);
|
||||
|
||||
#if (INCLUDE_OBJECT_DELETE == 1)
|
||||
|
||||
void vTraceStoreObjectNameOnCloseEvent(objectHandleType handle,
|
||||
traceObjectClass objectclass);
|
||||
|
||||
void vTraceStoreObjectPropertiesOnCloseEvent(objectHandleType handle,
|
||||
traceObjectClass objectclass);
|
||||
#endif
|
||||
|
||||
/* Internal constants for task state */
|
||||
#define TASK_STATE_INSTANCE_NOT_ACTIVE 0
|
||||
#define TASK_STATE_INSTANCE_ACTIVE 1
|
||||
#define TASK_STATE_INSTANCE_MARKED_FINISHED 2
|
||||
|
||||
extern objectHandleType handle_of_running_task;
|
||||
|
||||
/* This defines the mapping between FreeRTOS queue types and our internal
|
||||
class IDs */
|
||||
extern traceObjectClass TraceObjectClassTable[5];
|
||||
|
||||
/*******************************************************************************
|
||||
* The event codes - should match the offline config file.
|
||||
*
|
||||
* Some sections below are encoded to allow for constructions like:
|
||||
*
|
||||
* vTraceStoreKernelCall(EVENTGROUP_CREATE + objectclass, ...
|
||||
*
|
||||
* The object class ID is given by the three LSB bits, in such cases. Since each
|
||||
* object class has a separate object property table, the class ID is needed to
|
||||
* know what section in the object table to use for getting an object name from
|
||||
* an object handle.
|
||||
******************************************************************************/
|
||||
|
||||
#define NULL_EVENT (0x00) /* Ignored in the analysis*/
|
||||
|
||||
/*******************************************************************************
|
||||
* EVENTGROUP_RE
|
||||
*
|
||||
* Events that indicate that something is ready to execute.
|
||||
******************************************************************************/
|
||||
#define EVENTGROUP_RE (NULL_EVENT + 2) /*0x02*/
|
||||
#define TR_TASK_READY (EVENTGROUP_RE + 0) /*0x02*/
|
||||
|
||||
/*******************************************************************************
|
||||
* EVENTGROUP_TS
|
||||
*
|
||||
* Events for storing task-switches and interrupts. The RESUME events are
|
||||
* generated if the task/interrupt is already marked active.
|
||||
******************************************************************************/
|
||||
#define EVENTGROUP_TS (EVENTGROUP_RE + 2) /*0x04*/
|
||||
#define TS_ISR_BEGIN (EVENTGROUP_TS + 0) /*0x04*/
|
||||
#define TS_ISR_RESUME (EVENTGROUP_TS + 1) /*0x05*/
|
||||
#define TS_TASK_BEGIN (EVENTGROUP_TS + 2) /*0x06*/
|
||||
#define TS_TASK_RESUME (EVENTGROUP_TS + 3) /*0x07*/
|
||||
|
||||
/*******************************************************************************
|
||||
* EVENTGROUP_OBJCLOSE_NAME
|
||||
*
|
||||
* About Close Events
|
||||
* When an object is evicted from the object property table (object close), two
|
||||
* internal events are stored (EVENTGROUP_OBJCLOSE_NAME and
|
||||
* EVENTGROUP_OBJCLOSE_PROP), containg the handle-name mapping and object
|
||||
* properties valid up to this point.
|
||||
******************************************************************************/
|
||||
#define EVENTGROUP_OBJCLOSE_NAME (EVENTGROUP_TS + 4) /*0x08*/
|
||||
|
||||
/*******************************************************************************
|
||||
* EVENTGROUP_OBJCLOSE_PROP
|
||||
*
|
||||
* The internal event carrying properties of deleted objects
|
||||
* The handle and object class of the closed object is not stored in this event,
|
||||
* but is assumed to be the same as in the preceeding CLOSE event. Thus, these
|
||||
* two events must be generated from within a critical section.
|
||||
* When queues are closed, arg1 is the "state" property (i.e., number of
|
||||
* buffered messages/signals).
|
||||
* When actors are closed, arg1 is priority, arg2 is handle of the "instance
|
||||
* finish" event, and arg3 is event code of the "instance finish" event.
|
||||
* In this case, the lower three bits is the object class of the instance finish
|
||||
* handle. The lower three bits are not used (always zero) when queues are
|
||||
* closed since the queue type is given in the previous OBJCLOSE_NAME event.
|
||||
******************************************************************************/
|
||||
#define EVENTGROUP_OBJCLOSE_PROP (EVENTGROUP_OBJCLOSE_NAME + 8) /*0x10*/
|
||||
|
||||
/*******************************************************************************
|
||||
* EVENTGROUP_CREATE
|
||||
*
|
||||
* The events in this group are used to log Kernel object creations.
|
||||
* The lower three bits in the event code gives the object class, i.e., type of
|
||||
* create operation (task, queue, semaphore, etc).
|
||||
******************************************************************************/
|
||||
#define EVENTGROUP_CREATE (EVENTGROUP_OBJCLOSE_PROP + 8) /*0x18*/
|
||||
|
||||
/*******************************************************************************
|
||||
* EVENTGROUP_SEND
|
||||
*
|
||||
* The events in this group are used to log Send/Give events on queues,
|
||||
* semaphores and mutexeds The lower three bits in the event code gives the
|
||||
* object class, i.e., what type of object that is operated on (queue, semaphore
|
||||
* or mutex).
|
||||
******************************************************************************/
|
||||
#define EVENTGROUP_SEND (EVENTGROUP_CREATE + 8) /*0x20*/
|
||||
|
||||
/*******************************************************************************
|
||||
* EVENTGROUP_RECEIVE
|
||||
*
|
||||
* The events in this group are used to log Receive/Take events on queues,
|
||||
* semaphores and mutexes. The lower three bits in the event code gives the
|
||||
* object class, i.e., what type of object that is operated on (queue, semaphore
|
||||
* or mutex).
|
||||
******************************************************************************/
|
||||
#define EVENTGROUP_RECEIVE (EVENTGROUP_SEND + 8) /*0x28*/
|
||||
|
||||
/* Send/Give operations, from ISR */
|
||||
#define EVENTGROUP_SEND_FROM_ISR (EVENTGROUP_RECEIVE + 8) /*0x30*/
|
||||
|
||||
/* Receive/Take operations, from ISR */
|
||||
#define EVENTGROUP_RECEIVE_FROM_ISR (EVENTGROUP_SEND_FROM_ISR + 8) /*0x38*/
|
||||
|
||||
/* "Failed" event type versions of above (timeout, failed allocation, etc) */
|
||||
#define EVENTGROUP_FAILED_KSE (EVENTGROUP_RECEIVE_FROM_ISR + 8) /*0x40*/
|
||||
|
||||
/* Failed create calls - memory allocation failed */
|
||||
#define EVENTGROUP_FAILED_CREATE (EVENTGROUP_FAILED_KSE) /*0x40*/
|
||||
|
||||
/* Failed send/give - timeout! */
|
||||
#define EVENTGROUP_FAILED_SEND (EVENTGROUP_FAILED_CREATE + 8) /*0x48*/
|
||||
|
||||
/* Failed receive/take - timeout! */
|
||||
#define EVENTGROUP_FAILED_RECEIVE (EVENTGROUP_FAILED_SEND + 8) /*0x50*/
|
||||
|
||||
/* Failed non-blocking send/give - queue full */
|
||||
#define EVENTGROUP_FAILED_SEND_FROM_ISR (EVENTGROUP_FAILED_RECEIVE + 8) /*0x58*/
|
||||
|
||||
/* Failed non-blocking receive/take - queue empty */
|
||||
#define EVENTGROUP_FAILED_RECEIVE_FROM_ISR \
|
||||
(EVENTGROUP_FAILED_SEND_FROM_ISR + 8) /*0x60*/
|
||||
|
||||
/* Events when blocking on receive/take */
|
||||
#define EVENTGROUP_BLOCK_ON_RECEIVE \
|
||||
(EVENTGROUP_FAILED_RECEIVE_FROM_ISR + 8) /*0x68*/
|
||||
|
||||
/* Events when blocking on send/give */
|
||||
#define EVENTGROUP_BLOCK_ON_SEND (EVENTGROUP_BLOCK_ON_RECEIVE + 8) /*0x70*/
|
||||
|
||||
/* Events on queue peek (receive) */
|
||||
#define EVENTGROUP_PEEK (EVENTGROUP_BLOCK_ON_SEND + 8) /*0x78*/
|
||||
|
||||
/* Events on object delete (vTaskDelete or vQueueDelete) */
|
||||
#define EVENTGROUP_DELETE (EVENTGROUP_PEEK + 8) /*0x80*/
|
||||
|
||||
/* Other events - object class is implied: TASK */
|
||||
#define EVENTGROUP_OTHERS (EVENTGROUP_DELETE + 8) /*0x88*/
|
||||
#define TASK_DELAY_UNTIL (EVENTGROUP_OTHERS + 0) /*0x88*/
|
||||
#define TASK_DELAY (EVENTGROUP_OTHERS + 1) /*0x89*/
|
||||
#define TASK_SUSPEND (EVENTGROUP_OTHERS + 2) /*0x8A*/
|
||||
#define TASK_RESUME (EVENTGROUP_OTHERS + 3) /*0x8B*/
|
||||
#define TASK_RESUME_FROM_ISR (EVENTGROUP_OTHERS + 4) /*0x8C*/
|
||||
#define TASK_PRIORITY_SET (EVENTGROUP_OTHERS + 5) /*0x8D*/
|
||||
#define TASK_PRIORITY_INHERIT (EVENTGROUP_OTHERS + 6) /*0x8E*/
|
||||
#define TASK_PRIORITY_DISINHERIT (EVENTGROUP_OTHERS + 7) /*0x8F*/
|
||||
|
||||
/* Not yet used */
|
||||
#define EVENTGROUP_FTRACE_PLACEHOLDER (EVENTGROUP_OTHERS + 8) /*0x90*/
|
||||
|
||||
/* User events */
|
||||
#define EVENTGROUP_USEREVENT (EVENTGROUP_FTRACE_PLACEHOLDER + 8) /*0x98*/
|
||||
#define USER_EVENT (EVENTGROUP_USEREVENT + 0)
|
||||
|
||||
/* Allow for 0-15 arguments (the number of args is added to event code) */
|
||||
#define USER_EVENT_LAST (EVENTGROUP_USEREVENT + 15) /*0xA7*/
|
||||
|
||||
/*******************************************************************************
|
||||
* XTS Event - eXtended TimeStamp events
|
||||
* The timestamps used in the recorder are "differential timestamps" (DTS), i.e.
|
||||
* the time since the last stored event. The DTS fields are either 1 or 2 bytes
|
||||
* in the other events, depending on the bytes available in the event struct.
|
||||
* If the time since the last event (the DTS) is larger than allowed for by
|
||||
* the DTS field of the current event, an XTS event is inserted immidiatly
|
||||
* before the original event. The XTS event contains up to 3 additional bytes
|
||||
* of the DTS value - the higher bytes of the true DTS value. The lower 1-2
|
||||
* bytes are stored in the normal DTS field.
|
||||
* There are two types of XTS events, XTS8 and XTS16. An XTS8 event is stored
|
||||
* when there is only room for 1 byte (8 bit) DTS data in the original event,
|
||||
* which means a limit of 0xFF (255). The XTS16 is used when the original event
|
||||
* has a 16 bit DTS field and thereby can handle values up to 0xFFFF (65535).
|
||||
*
|
||||
* Using a very high frequency time base can result in many XTS events.
|
||||
* Preferably, the time between two OS ticks should fit in 16 bits, i.e.,
|
||||
* at most 65535. If your time base has a higher frequency, you can define
|
||||
* the TRACE
|
||||
******************************************************************************/
|
||||
|
||||
#define EVENTGROUP_SYS (EVENTGROUP_USEREVENT + 16) /*0xA8*/
|
||||
#define XTS8 (EVENTGROUP_SYS + 0) /*0xA8*/
|
||||
#define XTS16 (EVENTGROUP_SYS + 1) /*0xA9*/
|
||||
|
||||
#define EVENT_BEING_WRITTEN (EVENTGROUP_SYS + 2) /*0xAA*/
|
||||
|
||||
#define RESERVED_DUMMY_CODE (EVENTGROUP_SYS + 3) /*0xAB*/
|
||||
|
||||
#endif
|
81
FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcTypes.h
Normal file
81
FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcTypes.h
Normal file
|
@ -0,0 +1,81 @@
|
|||
/*******************************************************************************
|
||||
* FreeRTOS+Trace v2.3.0 Recorder Library
|
||||
* Percepio AB, www.percepio.com
|
||||
*
|
||||
* trcTypes.h
|
||||
*
|
||||
* Data types used by the trace recorder library.
|
||||
*
|
||||
* Terms of Use
|
||||
* This software is copyright Percepio AB. The recorder library is free for
|
||||
* use together with Percepio products. You may distribute the recorder library
|
||||
* in its original form, including modifications in trcPort.c and trcPort.h
|
||||
* given that these modification are clearly marked as your own modifications
|
||||
* and documented in the initial comment section of these source files.
|
||||
* This software is the intellectual property of Percepio AB and may not be
|
||||
* sold or in other ways commercially redistributed without explicit written
|
||||
* permission by Percepio AB.
|
||||
*
|
||||
* Disclaimer
|
||||
* The trace tool and recorder library is being delivered to you AS IS and
|
||||
* Percepio AB makes no warranty as to its use or performance. Percepio AB does
|
||||
* not and cannot warrant the performance or results you may obtain by using the
|
||||
* software or documentation. Percepio AB make no warranties, express or
|
||||
* implied, as to noninfringement of third party rights, merchantability, or
|
||||
* fitness for any particular purpose. In no event will Percepio AB, its
|
||||
* technology partners, or distributors be liable to you for any consequential,
|
||||
* incidental or special damages, including any lost profits or lost savings,
|
||||
* even if a representative of Percepio AB has been advised of the possibility
|
||||
* of such damages, or for any claim by any third party. Some jurisdictions do
|
||||
* not allow the exclusion or limitation of incidental, consequential or special
|
||||
* damages, or the exclusion of implied warranties or limitations on how long an
|
||||
* implied warranty may last, so the above limitations may not apply to you.
|
||||
*
|
||||
* FreeRTOS+Trace is available as Free Edition and in two premium editions.
|
||||
* You may use the premium features during 30 days for evaluation.
|
||||
* Download FreeRTOS+Trace at http://www.percepio.com/products/downloads/
|
||||
*
|
||||
* Copyright Percepio AB, 2012.
|
||||
* www.percepio.com
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef TRCTYPES_H
|
||||
#define TRCTYPES_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef uint16_t traceLabel;
|
||||
|
||||
typedef uint8_t objectHandleType;
|
||||
|
||||
typedef uint8_t traceObjectClass;
|
||||
|
||||
#define TRACE_CLASS_QUEUE ((traceObjectClass)0)
|
||||
#define TRACE_CLASS_SEMAPHORE ((traceObjectClass)1)
|
||||
#define TRACE_CLASS_MUTEX ((traceObjectClass)2)
|
||||
#define TRACE_CLASS_TASK ((traceObjectClass)3)
|
||||
#define TRACE_CLASS_ISR ((traceObjectClass)4)
|
||||
|
||||
typedef uint8_t traceKernelService;
|
||||
|
||||
#define TRACE_KERNEL_SERVICE_TASK_CREATE ((traceKernelService)0)
|
||||
#define TRACE_KERNEL_SERVICE_TASK_DELETE ((traceKernelService)1)
|
||||
#define TRACE_KERNEL_SERVICE_TASK_DELAY ((traceKernelService)2)
|
||||
#define TRACE_KERNEL_SERVICE_PRIORITY_SET ((traceKernelService)3)
|
||||
#define TRACE_KERNEL_SERVICE_TASK_SUSPEND ((traceKernelService)4)
|
||||
#define TRACE_KERNEL_SERVICE_TASK_RESUME ((traceKernelService)5)
|
||||
#define TRACE_KERNEL_SERVICE_QUEUE_CREATE ((traceKernelService)6)
|
||||
#define TRACE_KERNEL_SERVICE_QUEUE_DELETE ((traceKernelService)7)
|
||||
#define TRACE_KERNEL_SERVICE_QUEUE_SEND ((traceKernelService)8)
|
||||
#define TRACE_KERNEL_SERVICE_QUEUE_RECEIVE ((traceKernelService)9)
|
||||
#define TRACE_KERNEL_SERVICE_QUEUE_PEEK ((traceKernelService)10)
|
||||
#define TRACE_KERNEL_SERVICE_MUTEX_CREATE ((traceKernelService)11)
|
||||
#define TRACE_KERNEL_SERVICE_MUTEX_DELETE ((traceKernelService)12)
|
||||
#define TRACE_KERNEL_SERVICE_MUTEX_GIVE ((traceKernelService)13)
|
||||
#define TRACE_KERNEL_SERVICE_MUTEX_TAKE ((traceKernelService)14)
|
||||
#define TRACE_KERNEL_SERVICE_SEMAPHORE_CREATE ((traceKernelService)15)
|
||||
#define TRACE_KERNEL_SERVICE_SEMAPHORE_DELETE ((traceKernelService)16)
|
||||
#define TRACE_KERNEL_SERVICE_SEMAPHORE_GIVE ((traceKernelService)17)
|
||||
#define TRACE_KERNEL_SERVICE_SEMAPHORE_TAKE ((traceKernelService)18)
|
||||
|
||||
#endif
|
444
FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcUser.h
Normal file
444
FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcUser.h
Normal file
|
@ -0,0 +1,444 @@
|
|||
/*******************************************************************************
|
||||
* FreeRTOS+Trace v2.3.0 Recorder Library
|
||||
* Percepio AB, www.percepio.com
|
||||
*
|
||||
* trcUser.h
|
||||
* The public API of the trace recorder library.
|
||||
*
|
||||
* Terms of Use
|
||||
* This software is copyright Percepio AB. The recorder library is free for
|
||||
* use together with Percepio products. You may distribute the recorder library
|
||||
* in its original form, including modifications in trcPort.c and trcPort.h
|
||||
* given that these modification are clearly marked as your own modifications
|
||||
* and documented in the initial comment section of these source files.
|
||||
* This software is the intellectual property of Percepio AB and may not be
|
||||
* sold or in other ways commercially redistributed without explicit written
|
||||
* permission by Percepio AB.
|
||||
*
|
||||
* Disclaimer
|
||||
* The trace tool and recorder library is being delivered to you AS IS and
|
||||
* Percepio AB makes no warranty as to its use or performance. Percepio AB does
|
||||
* not and cannot warrant the performance or results you may obtain by using the
|
||||
* software or documentation. Percepio AB make no warranties, express or
|
||||
* implied, as to noninfringement of third party rights, merchantability, or
|
||||
* fitness for any particular purpose. In no event will Percepio AB, its
|
||||
* technology partners, or distributors be liable to you for any consequential,
|
||||
* incidental or special damages, including any lost profits or lost savings,
|
||||
* even if a representative of Percepio AB has been advised of the possibility
|
||||
* of such damages, or for any claim by any third party. Some jurisdictions do
|
||||
* not allow the exclusion or limitation of incidental, consequential or special
|
||||
* damages, or the exclusion of implied warranties or limitations on how long an
|
||||
* implied warranty may last, so the above limitations may not apply to you.
|
||||
*
|
||||
* FreeRTOS+Trace is available as Free Edition and in two premium editions.
|
||||
* You may use the premium features during 30 days for evaluation.
|
||||
* Download FreeRTOS+Trace at http://www.percepio.com/products/downloads/
|
||||
*
|
||||
* Copyright Percepio AB, 2012.
|
||||
* www.percepio.com
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef TRCUSER_H
|
||||
#define TRCUSER_H
|
||||
|
||||
#include "FreeRTOS.h"
|
||||
|
||||
#include "trcKernel.h"
|
||||
|
||||
#if (configUSE_TRACE_FACILITY == 1)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
* uiTraceStart
|
||||
*
|
||||
* Starts the recorder. The recorder will not be started if an error has been
|
||||
* indicated using vTraceError, e.g. if any of the Nx constants in trcConfig.h
|
||||
* has a too small value (NTASK, NQUEUE, etc).
|
||||
*
|
||||
* Returns 1 if the recorder was started successfully.
|
||||
* Returns 0 if the recorder start was prevented due to a previous internal
|
||||
* error. In that case, check vTraceGetLastError to get the error message.
|
||||
* Any error message is also presented when opening a trace file in
|
||||
* FreeRTOS+Trace v2.2.2 or later.
|
||||
******************************************************************************/
|
||||
uint32_t uiTraceStart(void);
|
||||
|
||||
/*******************************************************************************
|
||||
* vTraceStart
|
||||
*
|
||||
* Starts the recorder. The recorder will not be started if an error has been
|
||||
* indicated using vTraceError, e.g. if any of the Nx constants in trcConfig.h
|
||||
* has a too small value (NTASK, NQUEUE, etc).
|
||||
*
|
||||
* This function is obsolete, but has been saved for backwards compatibility.
|
||||
* We recommend using uiTraceStart instead.
|
||||
******************************************************************************/
|
||||
void vTraceStart(void);
|
||||
|
||||
/*******************************************************************************
|
||||
* vTraceStartStatusMonitor
|
||||
*
|
||||
* This starts a task to monitor the status of the recorder module.
|
||||
* This task periodically prints a line to the console window, which shows the
|
||||
* recorder status, the number of events recorded and the latest timestamp.
|
||||
* This task calls vTracePortEnd (trcPort.c) when it detects that the recorder
|
||||
* has been stopped. This allows for adding custom actions, e.g., to store the
|
||||
* trace to a file in case a file system is available on the device.
|
||||
******************************************************************************/
|
||||
void vTraceStartStatusMonitor(void);
|
||||
|
||||
/*******************************************************************************
|
||||
* vTraceStop
|
||||
*
|
||||
* Stops the recorder. The recording can be resumed by calling vTraceStart.
|
||||
* This does not reset the recorder. Use vTraceClear is that is desired.
|
||||
******************************************************************************/
|
||||
void vTraceStop(void);
|
||||
|
||||
/*******************************************************************************
|
||||
* vTraceClear
|
||||
*
|
||||
* Resets the recorder. Only necessary if a restart is desired - this is not
|
||||
* needed in the startup initialization.
|
||||
******************************************************************************/
|
||||
void vTraceClear(void);
|
||||
|
||||
/*******************************************************************************
|
||||
* vTraceSetQueueName
|
||||
*
|
||||
* Assigns a name to a FreeRTOS Queue, Semaphore or Mutex. This function should
|
||||
* be called right after creation of the queue/mutex/semaphore. If not using
|
||||
* this function, the queues/mutexes/semaphores will be presented by their
|
||||
* numeric handle only.
|
||||
*
|
||||
* Example:
|
||||
* actuatorQ = xQueueCreate(3, sizeof(QueueMessage));
|
||||
* vTraceSetQueueName(actuatorQ, "ActuatorQueue");
|
||||
******************************************************************************/
|
||||
void vTraceSetQueueName(void* queue, const char* name);
|
||||
|
||||
#if (INCLUDE_ISR_TRACING == 1)
|
||||
|
||||
/*******************************************************************************
|
||||
* vTraceSetISRProperties
|
||||
*
|
||||
* Registers an Interrupt Service Routine in the recorder library, This must be
|
||||
* called before using vTraceStoreISRBegin to store ISR events. This is
|
||||
* typically called in the startup of the system, before the scheduler is
|
||||
* started.
|
||||
*
|
||||
* Example:
|
||||
* #define ID_ISR_TIMER1 1 // lowest valid ID is 1
|
||||
* #define PRIO_OF_ISR_TIMER1 3 // the hardware priority of the interrupt
|
||||
* ...
|
||||
* vTraceSetISRProperties(ID_ISR_TIMER1, "ISRTimer1", PRIO_OF_ISR_TIMER1);
|
||||
* ...
|
||||
* void ISR_handler()
|
||||
* {
|
||||
* portENTER_CRITICAL(); // Required if nested ISRs are allowed
|
||||
* vTraceStoreISRBegin(ID_OF_ISR_TIMER1);
|
||||
* portEXIT_CRITICAL();
|
||||
* ...
|
||||
* portENTER_CRITICAL(); // Required if nested ISRs are allowed
|
||||
* vTraceStoreISREnd();
|
||||
* portEXIT_CRITICAL();
|
||||
* }
|
||||
******************************************************************************/
|
||||
void vTraceSetISRProperties(objectHandleType handle, const char* name, char priority);
|
||||
|
||||
/*******************************************************************************
|
||||
* vTraceStoreISRBegin
|
||||
*
|
||||
* Registers the beginning of an Interrupt Service Routine.
|
||||
*
|
||||
* Note! This may only be used for interrupts affected by portENTER_CRITICAL.
|
||||
* In some FreeRTOS ports, such as ARM Cortex M3, this does not disable all
|
||||
* interrupts. Interrupts above configMAX_SYSCALL_INTERRUPT_PRIORITY are still
|
||||
* enabled, but may not call the FreeRTOS API. Such may not call the recorder
|
||||
* API, including this function.
|
||||
*
|
||||
* See http://www.freertos.org/a00110.html
|
||||
*
|
||||
* If allowing nested ISRs, this must be called with interrupts disabled.
|
||||
*
|
||||
* Example:
|
||||
* #define ID_ISR_TIMER1 1 // lowest valid ID is 1
|
||||
* #define PRIO_OF_ISR_TIMER1 3 // the hardware priority of the interrupt
|
||||
* ...
|
||||
* vTraceSetISRProperties(ID_ISR_TIMER1, "ISRTimer1", PRIO_OF_ISR_TIMER1);
|
||||
* ...
|
||||
* void ISR_handler()
|
||||
* {
|
||||
* portENTER_CRITICAL(); // Required if nested ISRs are allowed
|
||||
* vTraceStoreISRBegin(ID_OF_ISR_TIMER1);
|
||||
* portEXIT_CRITICAL();
|
||||
* ...
|
||||
* portENTER_CRITICAL(); // Required if nested ISRs are allowed
|
||||
* vTraceStoreISREnd();
|
||||
* portEXIT_CRITICAL();
|
||||
* }
|
||||
******************************************************************************/
|
||||
void vTraceStoreISRBegin(objectHandleType id);
|
||||
|
||||
/*******************************************************************************
|
||||
* vTraceStoreISREnd
|
||||
*
|
||||
* Registers the end of an Interrupt Service Routine.
|
||||
*
|
||||
* Note! This may only be used for interrupts affected by portENTER_CRITICAL.
|
||||
* In some FreeRTOS ports, such as ARM Cortex M3, this does not disable all
|
||||
* interrupts. Interrupts above configMAX_SYSCALL_INTERRUPT_PRIORITY are still
|
||||
* enabled, but may not call the FreeRTOS API. Such may not call the recorder
|
||||
* API, including this function.
|
||||
*
|
||||
* See http://www.freertos.org/a00110.html
|
||||
*
|
||||
* If allowing nested ISRs, this must be called with interrupts disabled.
|
||||
*
|
||||
* Example:
|
||||
* #define ID_ISR_TIMER1 1 // lowest valid ID is 1
|
||||
* #define PRIO_OF_ISR_TIMER1 3 // the hardware priority of the interrupt
|
||||
* ...
|
||||
* vTraceSetISRProperties(ID_ISR_TIMER1, "ISRTimer1", PRIO_OF_ISR_TIMER1);
|
||||
* ...
|
||||
* void ISR_handler()
|
||||
* {
|
||||
* portENTER_CRITICAL(); // Required if nested ISRs are allowed
|
||||
* vTraceStoreISRBegin(ID_OF_ISR_TIMER1);
|
||||
* portEXIT_CRITICAL();
|
||||
* ...
|
||||
* portENTER_CRITICAL(); // Required if nested ISRs are allowed
|
||||
* vTraceStoreISREnd();
|
||||
* portEXIT_CRITICAL();
|
||||
* }
|
||||
******************************************************************************/
|
||||
void vTraceStoreISREnd(void);
|
||||
|
||||
#else
|
||||
/* If not including the ISR recording */
|
||||
|
||||
void vTraceIncreaseISRActive(void);
|
||||
|
||||
void vTraceDecreaseISRActive(void);
|
||||
|
||||
#define vTraceSetISRProperties(handle, name, priority)
|
||||
#define vTraceStoreISRBegin(id) vTraceIncreaseISRActive()
|
||||
#define vTraceStoreISREnd() vTraceDecreaseISRActive()
|
||||
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
* vvTraceTaskSkipDefaultInstanceFinishedEvents
|
||||
*
|
||||
* This is useful if there are implicit Instance Finish Events, such as
|
||||
* vTaskDelayUntil or xQueueReceive, in a task where an explicit Instance Finish
|
||||
* Event has been defined. This function tells the recorder that only the
|
||||
* explicitly defined functions (using vTraceTaskInstanceIsFinished) should be
|
||||
* treated as Instance Finish Events for this task. The implicit Instance Finish
|
||||
* Events are thus disregarded for this task.
|
||||
******************************************************************************/
|
||||
void vTraceTaskSkipDefaultInstanceFinishedEvents(void);
|
||||
|
||||
/*******************************************************************************
|
||||
* vTraceTaskInstanceIsFinished
|
||||
*
|
||||
* This defines an explicit Instance Finish Event for the current task. It tells
|
||||
* the recorder that the current instance of this task is finished at the next
|
||||
* kernel call of the task, e.g., a taskDelay or a queue receive. This function
|
||||
* should be called right before the api function call considered to be the end
|
||||
* of the task instamce, i.e., the Instance Finish Event.
|
||||
******************************************************************************/
|
||||
void vTraceTaskInstanceIsFinished(void);
|
||||
|
||||
/*******************************************************************************
|
||||
* vTraceGetTraceBuffer
|
||||
*
|
||||
* Returns a pointer to the recorder data structure. Use this together with
|
||||
* uiTraceGetTraceBufferSize if you wish to implement an own store/upload
|
||||
* solution, e.g., in case a debugger connection is not available for uploading
|
||||
* the data.
|
||||
******************************************************************************/
|
||||
void* vTraceGetTraceBuffer(void);
|
||||
|
||||
/*******************************************************************************
|
||||
* uiTraceGetTraceBufferSize
|
||||
*
|
||||
* Gets the size of the recorder data structure. For use together with
|
||||
* vTraceGetTraceBuffer if you wish to implement an own store/upload solution,
|
||||
* e.g., in case a debugger connection is not available for uploading the data.
|
||||
******************************************************************************/
|
||||
uint32_t uiTraceGetTraceBufferSize(void);
|
||||
|
||||
#if (INCLUDE_USER_EVENTS == 1)
|
||||
|
||||
/*******************************************************************************
|
||||
* xTraceOpenLabel
|
||||
*
|
||||
* Creates user event labels for user event channels or for individual events.
|
||||
* User events can be used to log application events and data for display in
|
||||
* the visualization tool. A user event is identified by a label, i.e., a string,
|
||||
* which is stored in the recorder's symbol table.
|
||||
* When logging a user event, a numeric handle (reference) to this string is
|
||||
* used to identify the event. This is obtained by calling
|
||||
*
|
||||
* xTraceOpenLabel()
|
||||
*
|
||||
* whihc adds the string to the symbol table (if not already present)
|
||||
* and returns the corresponding handle.
|
||||
*
|
||||
* This can be used in two ways:
|
||||
*
|
||||
* 1. The handle is looked up every time, when storing the user event.
|
||||
*
|
||||
* Example:
|
||||
* vTraceUserEvent(xTraceOpenLabel("MyUserEvent"));
|
||||
*
|
||||
* 2. The label is registered just once, with the handle stored in an
|
||||
* application variable - much like using a file handle.
|
||||
*
|
||||
* Example:
|
||||
* myEventHandle = xTraceOpenLabel("MyUserEvent");
|
||||
* ...
|
||||
* vTraceUserEvent(myEventHandle);
|
||||
*
|
||||
* The second option is faster since no lookup is required on each event, and
|
||||
* therefore recommended for user events that are frequently
|
||||
* executed and/or located in time-critical code. The lookup operation is
|
||||
* however fairly fast due to the design of the symbol table.
|
||||
******************************************************************************/
|
||||
traceLabel xTraceOpenLabel(const char* label);
|
||||
|
||||
/******************************************************************************
|
||||
* vTraceUserEvent
|
||||
*
|
||||
* Basic user event (Standard and Professional Edition only)
|
||||
*
|
||||
* Generates a User Event with a text label. The label is created/looked up
|
||||
* in the symbol table using xTraceOpenLabel.
|
||||
******************************************************************************/
|
||||
void vTraceUserEvent(traceLabel eventLabel);
|
||||
|
||||
/******************************************************************************
|
||||
* vTracePrintF
|
||||
*
|
||||
* Advanced user events (Professional Edition only)
|
||||
*
|
||||
* Generates User Event with formatted text and data, similar to a "printf".
|
||||
* It is very fast compared to a normal "printf" since this function only
|
||||
* stores the arguments. The actual formatting is done
|
||||
* on the host PC when the trace is displayed in the viewer tool.
|
||||
*
|
||||
* User Event labels are created using xTraceOpenLabel.
|
||||
* Example:
|
||||
*
|
||||
* traceLabel adc_uechannel = xTraceOpenLabel("ADC User Events");
|
||||
* ...
|
||||
* vTracePrint(adc_uechannel,
|
||||
* "ADC channel %d: %lf volts",
|
||||
* ch, (double)adc_reading/(double)scale);
|
||||
*
|
||||
* This can be combined into one line, if desired, but this is slower:
|
||||
*
|
||||
* vTracePrint(xTraceOpenLabel("ADC User Events"),
|
||||
* "ADC channel %d: %lf volts",
|
||||
* ch, (double)adc_reading/(double)scale);
|
||||
*
|
||||
* Calling xTraceOpenLabel multiple times will not create duplicate entries, but
|
||||
* it is of course faster to just do it once, and then keep the handle for later
|
||||
* use. If you don´t have any data arguments, only a text label/string, it is
|
||||
* better to use vTraceUserEvent - it is faster.
|
||||
*
|
||||
* Format specifiers supported:
|
||||
* %d - 32 bit signed integer
|
||||
* %u - 32 bit unsigned integer
|
||||
* %f - 32 bit float
|
||||
* %s - string (is copied to the recorder symbol table)
|
||||
* %hd - 16 bit signed integer
|
||||
* %hu - 16 bit unsigned integer
|
||||
* %bd - 8 bit signed integer
|
||||
* %bu - 8 bit unsigned integer
|
||||
* %lf - double-precision float (Note! See below...)
|
||||
*
|
||||
* Up to 15 data arguments are allowed, with a total size of maximum 32 byte.
|
||||
* In case this is exceeded, the user event is changed into an error message.
|
||||
*
|
||||
* The data is stored in trace buffer, and is packed to allow storing multiple
|
||||
* smaller data entries in the same 4-byte record, e.g., four 8-bit values.
|
||||
* A string requires two bytes, as the symbol table is limited to 64K. Storing
|
||||
* a double (%lf) uses two records, so this is quite costly. Use float (%f)
|
||||
* unless the higher precision is really necessary.
|
||||
*
|
||||
* Note that the double-precision float (%lf) assumes a 64 bit double
|
||||
* representation. This does not seem to be the case on e.g. PIC24F.
|
||||
* Before using a %lf argument on a 16-bit MCU, please verify that
|
||||
* "sizeof(double)" actually gives 8 as expected. If not, use %f instead.
|
||||
******************************************************************************/
|
||||
void vTracePrintF(traceLabel eventLabel, const char* formatStr, ...);
|
||||
|
||||
#else
|
||||
|
||||
#define vTracePrintF(eventLabel, formatStr, ...);
|
||||
#define xTraceOpenLabel(label) 0
|
||||
#define vTraceUserEvent(eventLabel)
|
||||
|
||||
#endif
|
||||
|
||||
/******************************************************************************
|
||||
* vTraceExclude______FromTrace
|
||||
*
|
||||
* Excludes a task or object from the trace.
|
||||
* This can be useful if some irrelevant task is very frequent and is "eating
|
||||
* up the buffer". This should be called after the task has been created, but
|
||||
* before starting the FreeRTOS scheduler.
|
||||
*****************************************************************************/
|
||||
void vTraceExcludeQueueFromTrace(void* handle);
|
||||
void vTraceExcludeSemaphoreFromTrace(void* handle);
|
||||
void vTraceExcludeMutexFromTrace(void* handle);
|
||||
void vTraceExcludeTaskFromTrace(void* handle);
|
||||
void vTraceExcludeKernelServiceFromTrace(traceKernelService kernelService);
|
||||
|
||||
/******************************************************************************
|
||||
* vTraceInclude______InTrace
|
||||
*
|
||||
* Includes a task, object or kernel service in the trace. This is only
|
||||
* necessary if the task or object has been previously exluded.
|
||||
*****************************************************************************/
|
||||
void vTraceIncludeQueueInTrace(void* handle);
|
||||
void vTraceIncludeSemaphoreInTrace(void* handle);
|
||||
void vTraceIncludeMutexInTrace(void* handle);
|
||||
void vTraceIncludeTaskInTrace(void* handle);
|
||||
void vTraceIncludeKernelServiceInTrace(traceKernelService kernelService);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#include "trcPort.h"
|
||||
|
||||
#define vTraceInit()
|
||||
#define uiTraceStart() (1)
|
||||
#define vTraceStart()
|
||||
#define vTraceStop()
|
||||
#define vTraceClear()
|
||||
#define vTraceStartStatusMonitor()
|
||||
#define vTracePortSetOutFile(f)
|
||||
#define vTraceGetTraceBuffer() ((void*)0)
|
||||
#define uiTraceGetTraceBufferSize() 0
|
||||
#define xTraceOpenLabel(label) 0
|
||||
#define vTraceUserEvent(eventLabel)
|
||||
#define vTracePrintF(eventLabel,formatStr,...)
|
||||
#define vTraceExcludeTaskFromSchedulingTrace(name)
|
||||
#define vTraceSetQueueName(queue, name)
|
||||
|
||||
#define vTraceTaskSkipDefaultInstanceFinishedEvents()
|
||||
#define vTraceSetISRProperties(handle, name, priority)
|
||||
#define vTraceStoreISRBegin(id)
|
||||
#define vTraceStoreISREnd()
|
||||
#endif
|
||||
#endif
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue