Percepio Trace Recorder  v4.6.6
trcKernelPort.h
1 /*
2  * Trace Recorder for Tracealyzer v4.6.6
3  * Copyright 2021 Percepio AB
4  * www.percepio.com
5  *
6  * SPDX-License-Identifier: Apache-2.0
7  *
8  * FreeRTOS specific definitions needed by the trace recorder
9  */
10 
11 #ifndef TRC_KERNEL_PORT_H
12 #define TRC_KERNEL_PORT_H
13 
14 #include <trcDefines.h>
15 #include <FreeRTOS.h> /* Defines configUSE_TRACE_FACILITY */
16 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20 
21 #define TRC_USE_TRACEALYZER_RECORDER configUSE_TRACE_FACILITY
22 
23 /* FreeRTOS version codes */
24 #define FREERTOS_VERSION_NOT_SET 0
25 #define TRC_FREERTOS_VERSION_7_3_X 1 /* v7.3 is earliest supported.*/
26 #define TRC_FREERTOS_VERSION_7_4_X 2
27 #define TRC_FREERTOS_VERSION_7_5_X 3
28 #define TRC_FREERTOS_VERSION_7_6_X TRC_FREERTOS_VERSION_7_5_X
29 #define TRC_FREERTOS_VERSION_8_X_X 4
30 #define TRC_FREERTOS_VERSION_9_0_0 5
31 #define TRC_FREERTOS_VERSION_9_0_1 6
32 #define TRC_FREERTOS_VERSION_9_0_2 7
33 #define TRC_FREERTOS_VERSION_10_0_0 8
34 #define TRC_FREERTOS_VERSION_10_0_1 TRC_FREERTOS_VERSION_10_0_0
35 #define TRC_FREERTOS_VERSION_10_1_0 TRC_FREERTOS_VERSION_10_0_0
36 #define TRC_FREERTOS_VERSION_10_1_1 TRC_FREERTOS_VERSION_10_0_0
37 #define TRC_FREERTOS_VERSION_10_2_0 TRC_FREERTOS_VERSION_10_0_0
38 #define TRC_FREERTOS_VERSION_10_2_1 TRC_FREERTOS_VERSION_10_0_0
39 #define TRC_FREERTOS_VERSION_10_3_0 9
40 #define TRC_FREERTOS_VERSION_10_3_1 TRC_FREERTOS_VERSION_10_3_0
41 #define TRC_FREERTOS_VERSION_10_4_0 10
42 #define TRC_FREERTOS_VERSION_10_4_1 TRC_FREERTOS_VERSION_10_4_0
43 
44 /* Legacy FreeRTOS version codes for backwards compatibility with old trace configurations */
45 #define TRC_FREERTOS_VERSION_7_3 TRC_FREERTOS_VERSION_7_3_X
46 #define TRC_FREERTOS_VERSION_7_4 TRC_FREERTOS_VERSION_7_4_X
47 #define TRC_FREERTOS_VERSION_7_5_OR_7_6 TRC_FREERTOS_VERSION_7_5_X
48 #define TRC_FREERTOS_VERSION_8_X TRC_FREERTOS_VERSION_8_X_X
49 
50 #if (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0)
51 #define prvGetStreamBufferType(x) ((( StreamBuffer_t * )(x) )->ucFlags & sbFLAGS_IS_MESSAGE_BUFFER)
52 #else
53 #define prvGetStreamBufferType(x) 0
54 #endif
55 
56 /* Added mainly for our internal testing. This makes it easier to create test applications that
57  runs on multiple FreeRTOS versions. */
58 #if (TRC_CFG_FREERTOS_VERSION < TRC_FREERTOS_VERSION_8_X_X)
59  /* FreeRTOS v7.x */
60  #define STRING_CAST(x) ( (signed char*) x )
61  #define TickType portTickType
62  #define TaskType xTaskHandle
63 #else
64  /* FreeRTOS v8.0 and later */
65  #define STRING_CAST(x) x
66  #define TraceKernelPortTickType_t TickType_t
67  #define TraceKernelPortTaskHandle_t TaskHandle_t
68 #endif
69 
70 #if (defined(TRC_USE_TRACEALYZER_RECORDER)) && (TRC_USE_TRACEALYZER_RECORDER == 1)
71 
72 #define TRC_PLATFORM_CFG "FreeRTOS"
73 #define TRC_PLATFORM_CFG_MAJOR 1
74 #define TRC_PLATFORM_CFG_MINOR 0
75 #define TRC_PLATFORM_CFG_PATCH 0
76 
77 #if defined(TRC_CFG_ENABLE_STACK_MONITOR) && (TRC_CFG_ENABLE_STACK_MONITOR == 1) && (TRC_CFG_SCHEDULING_ONLY == 0)
78 
79 /* Required for stack monitoring */
80 #undef INCLUDE_uxTaskGetStackHighWaterMark
81 #define INCLUDE_uxTaskGetStackHighWaterMark 1
82 
83 #endif
84 
85 /* INCLUDE_xTaskGetCurrentTaskHandle must be set to 1 for tracing to work properly */
86 #undef INCLUDE_xTaskGetCurrentTaskHandle
87 #define INCLUDE_xTaskGetCurrentTaskHandle 1
88 
89 #if (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING)
90 #include <trcHeap.h>
91 
92 #define TRC_KERNEL_PORT_BUFFER_SIZE (sizeof(TraceHeapHandle_t) + sizeof(void*))
93 #elif (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_SNAPSHOT)
94 #define TRC_KERNEL_PORT_BUFFER_SIZE (sizeof(TraceUnsignedBaseType_t))
95 #endif
96 
97 #if (TRC_CFG_FREERTOS_VERSION == FREERTOS_VERSION_NOT_SET)
98 #error "Please set TRC_CFG_FREERTOS_VERSION in trcKernelPortConfig.h to the FreeRTOS version used."
99 #endif
100 
105 {
106  uint8_t buffer[TRC_KERNEL_PORT_BUFFER_SIZE];
108 
117 traceResult xTraceKernelPortInitialize(TraceKernelPortDataBuffer_t* pxBuffer);
118 
125 traceResult xTraceKernelPortEnable(void);
126 
135 traceResult xTraceKernelPortDelay(uint32_t uiTicks);
136 
143 unsigned char xTraceKernelPortIsSchedulerSuspended(void);
144 
148 #define TRC_KERNEL_PORT_ALLOC_CRITICAL_SECTION() TraceUnsignedBaseType_t TRACE_ALLOC_CRITICAL_SECTION_NAME;
149 
153 #define TRC_KERNEL_PORT_ENTER_CRITICAL_SECTION() TRACE_ALLOC_CRITICAL_SECTION_NAME = 0; portENTER_CRITICAL()
154 
158 #define TRC_KERNEL_PORT_EXIT_CRITICAL_SECTION() (void)TRACE_ALLOC_CRITICAL_SECTION_NAME; portEXIT_CRITICAL()
159 
163 #define TRC_KERNEL_PORT_SET_INTERRUPT_MASK() ((TraceBaseType_t)portSET_INTERRUPT_MASK_FROM_ISR())
164 
165 #if (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_8_X_X)
166 
170 #define TRC_KERNEL_PORT_CLEAR_INTERRUPT_MASK(xMask) portCLEAR_INTERRUPT_MASK_FROM_ISR((UBaseType_t)(xMask))
171 
172 #else
173 
177 #define TRC_KERNEL_PORT_CLEAR_INTERRUPT_MASK(xMask) portCLEAR_INTERRUPT_MASK_FROM_ISR((unsigned portBASE_TYPE)xMask)
178 #endif
179 
180 #if (TRC_CFG_SCHEDULING_ONLY == 0)
181 
188 void vTraceSetQueueName(void* pvQueue, const char* szName);
189 
196 void vTraceSetSemaphoreName(void* pvSemaphore, const char* szName);
197 
204 void vTraceSetMutexName(void* pvMutex, const char* szName);
205 
206 #if (TRC_CFG_INCLUDE_EVENT_GROUP_EVENTS == 1)
207 
214 void vTraceSetEventGroupName(void* pvEventGroup, const char* szName);
215 
216 #else
217 
221 #define vTraceSetEventGroupName(__pvEventGroup, __szName) ((void)(__pvEventGroup), (void)(__szName))
222 
223 #endif
224 
225 #if (TRC_CFG_INCLUDE_STREAM_BUFFER_EVENTS == 1)
226 
233 void vTraceSetStreamBufferName(void* pvStreamBuffer, const char* szName);
234 
241 void vTraceSetMessageBufferName(void* pvMessageBuffer, const char* szName);
242 
243 #else
244 
248 #define vTraceSetStreamBufferName(__pvStreamBuffer, __szName) ((void)(__pvStreamBuffer), (void)(__szName))
249 
253 #define vTraceSetMessageBufferName(__pvMessageBuffer, __szName) ((void)(__pvMessageBuffer), (void)(__szName))
254 
255 #endif
256 
257 #if defined(TRC_CFG_ENABLE_STACK_MONITOR) && (TRC_CFG_ENABLE_STACK_MONITOR == 1)
258 
268 traceResult xTraceKernelPortGetUnusedStack(void* pvTask, TraceUnsignedBaseType_t *puxUnusedStack);
269 
270 #endif
271 
272 #else
273 
277 #define vTraceSetQueueName(__pvQueue, __szName) ((void)(__pvQueue), (void)(__szName))
278 
282 #define vTraceSetSemaphoreName(__pvSemaphore, __szName) ((void)(__pvSemaphore), (void)(__szName))
283 
287 #define vTraceSetMutexName(__pvMutex, __szName) ((void)(__pvMutex), (void)(__szName))
288 
292 #define vTraceSetEventGroupName(__pvEventGroup, __szName) ((void)(__pvEventGroup), (void)(__szName))
293 
297 #define vTraceSetStreamBufferName(__pvStreamBuffer, __szName) ((void)(__pvStreamBuffer), (void)(__szName))
298 
302 #define vTraceSetMessageBufferName(__pvMessageBuffer, __szName) ((void)(__pvMessageBuffer), (void)(__szName))
303 
307 #define xTraceKernelPortGetUnusedStack(pvTask, puxUnusedStack) ((void)(pvTask), (void)(puxUnusedStack))
308 
309 #endif
310 
311 #if (((TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_SNAPSHOT) && (TRC_CFG_INCLUDE_ISR_TRACING == 1)) || (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING))
312 
313 /* Required for ISR tracing and Streaming */
314 #undef INCLUDE_xTaskGetSchedulerState
315 #define INCLUDE_xTaskGetSchedulerState 1
316 
317 #endif
318 
322 #define TRACE_KERNEL_VERSION 0x1AA1
323 
327 #define TRC_TICK_RATE_HZ configTICK_RATE_HZ /* Defined in "FreeRTOS.h" */
328 
332 #define TRACE_CPU_CLOCK_HZ configCPU_CLOCK_HZ /* Defined in "FreeRTOSConfig.h" */
333 
334 #if (TRC_CFG_RECORDER_BUFFER_ALLOCATION == TRC_RECORDER_BUFFER_ALLOCATION_DYNAMIC)
335 
338 #define TRC_KERNEL_PORT_HEAP_INIT(size)
339 
343 #define TRC_KERNEL_PORT_HEAP_MALLOC(size) pvPortMalloc(size)
344 #endif /* (TRC_CFG_RECORDER_BUFFER_ALLOCATION == TRC_RECORDER_BUFFER_ALLOCATION_DYNAMIC) */
345 
346 #if (defined(configUSE_TIMERS) && (configUSE_TIMERS == 1))
347 
348 #undef INCLUDE_xTimerGetTimerDaemonTaskHandle
349 #define INCLUDE_xTimerGetTimerDaemonTaskHandle 1
350 
351 #endif
352 
353 #if (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_XMOS_XCOREAI)
354 
355 #undef TRC_CFG_CORE_COUNT
356 #define TRC_CFG_CORE_COUNT configNUM_CORES
357 
358 #undef TRC_CFG_GET_CURRENT_CORE
359 #define TRC_CFG_GET_CURRENT_CORE() rtos_core_id_get()
360 
361 #endif
362 
363 #if (TRC_CFG_FREERTOS_VERSION == TRC_FREERTOS_VERSION_9_0_1)
364 
388 #define isQueueReceiveHookActuallyPeek (__LINE__ > 1674) /* Half way between the closes trace points */
389 
390 #elif (TRC_CFG_FREERTOS_VERSION <= TRC_FREERTOS_VERSION_9_0_0)
391 
395 #define isQueueReceiveHookActuallyPeek xJustPeeking
396 
397 #elif (TRC_CFG_FREERTOS_VERSION > TRC_FREERTOS_VERSION_9_0_1)
398 
402 #define isQueueReceiveHookActuallyPeek (__LINE__ < 0) /* instead of pdFALSE to fix a warning of "constant condition" */
403 
404 #endif
405 
406 /* Helpers needed to correctly expand names */
407 #define TZ__CAT2(a,b) a ## b
408 #define TZ__CAT(a,b) TZ__CAT2(a, b)
409 
410 /*
411  * The following xQueueGiveFromISR macro hacks make sure xQueueGiveFromISR also has a xCopyPosition parameter
412  */
413 
414 /* Expands name if this header is included... uxQueueType must be a macro that only exists in queue.c or whatever, and it must expand to nothing or to something that's valid in identifiers */
415 #define xQueueGiveFromISR(a,b) TZ__CAT(xQueueGiveFromISR__, uxQueueType) (a,b)
416 
417 /* If in queue.c, the "uxQueueType" macro expands to "pcHead". queueSEND_TO_BACK is the value we need to send in */
418 #define xQueueGiveFromISR__pcHead(__a, __b) MyWrapper_xQueueGiveFromISR(__a, __b, const BaseType_t xCopyPosition); \
419 BaseType_t xQueueGiveFromISR(__a, __b) { return MyWrapper_xQueueGiveFromISR(xQueue, pxHigherPriorityTaskWoken, queueSEND_TO_BACK); } \
420 BaseType_t MyWrapper_xQueueGiveFromISR(__a, __b, const BaseType_t xCopyPosition)
421 
422 /* If not in queue.c, "uxQueueType" isn't expanded */
423 #define xQueueGiveFromISR__uxQueueType(__a, __b) xQueueGiveFromISR(__a,__b)
424 
425 #if (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_SNAPSHOT)
426 
430 #define TRACE_GET_CURRENT_TASK() prvTraceGetCurrentTaskHandle()
431 
432 extern uint16_t CurrentFilterMask;
433 extern uint16_t CurrentFilterGroup;
434 
442 uint8_t prvTraceGetQueueType(void* pvQueue);
443 
451 uint16_t prvTraceGetTaskNumberLow16(void* pvTask);
452 
460 uint16_t prvTraceGetTaskNumberHigh16(void* pvTask);
461 
468 void prvTraceSetTaskNumberLow16(void* pvTask, uint16_t uiValue);
469 
476 void prvTraceSetTaskNumberHigh16(void* pvTask, uint16_t uiValue);
477 
485 uint16_t prvTraceGetQueueNumberLow16(void* pvQueue);
486 
494 uint16_t prvTraceGetQueueNumberHigh16(void* pvQueue);
495 
496 
503 void prvTraceSetQueueNumberLow16(void* pvQueue, uint16_t uiValue);
504 
505 
512 void prvTraceSetQueueNumberHigh16(void* pvQueue, uint16_t uiValue);
513 
514 #if (TRC_CFG_INCLUDE_TIMER_EVENTS == 1 && TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0)
515 
523 uint16_t prvTraceGetTimerNumberLow16(void* pvTimer);
524 
532 uint16_t prvTraceGetTimerNumberHigh16(void* pvTimer);
533 
540 void prvTraceSetTimerNumberLow16(void* pvTimer, uint16_t uiValue);
541 
548 void prvTraceSetTimerNumberHigh16(void* pvTimer, uint16_t uiValue);
549 
550 #endif
551 
552 #if (TRC_CFG_INCLUDE_EVENT_GROUP_EVENTS == 1 && TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0)
553 
561 uint16_t prvTraceGetEventGroupNumberLow16(void* pvEventGroup);
562 
570 uint16_t prvTraceGetEventGroupNumberHigh16(void* pvEventGroup);
571 
578 void prvTraceSetEventGroupNumberLow16(void* pvEventGroup, uint16_t uiValue);
579 
586 void prvTraceSetEventGroupNumberHigh16(void* handle, uint16_t value);
587 
588 #endif
589 
590 #if (TRC_CFG_INCLUDE_STREAM_BUFFER_EVENTS == 1 && TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0)
591 
599 uint16_t prvTraceGetStreamBufferNumberLow16(void* pvStreamBuffer);
600 
608 uint16_t prvTraceGetStreamBufferNumberHigh16(void* pvStreamBuffer);
609 
616 void prvTraceSetStreamBufferNumberLow16(void* pvStreamBuffer, uint16_t uiValue);
617 
624 void prvTraceSetStreamBufferNumberHigh16(void* pvStreamBuffer, uint16_t uiValue);
625 
626 #endif
627 
635 #define TRACE_GET_TASK_FILTER(pxTask) prvTraceGetTaskNumberHigh16((void*)pxTask)
636 
643 #define TRACE_SET_TASK_FILTER(pxTask, group) prvTraceSetTaskNumberHigh16((void*)pxTask, group)
644 
652 #define TRACE_GET_QUEUE_FILTER(pxQueue) prvTraceGetQueueNumberHigh16((void*)pxQueue)
653 
660 #define TRACE_SET_QUEUE_FILTER(pxQueue, group) prvTraceSetQueueNumberHigh16((void*)pxQueue, group)
661 
662 #if (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0)
663 
671 #define TRACE_GET_EVENTGROUP_FILTER(pxEventGroup) prvTraceGetEventGroupNumberHigh16((void*)pxEventGroup)
672 
679 #define TRACE_SET_EVENTGROUP_FILTER(pxEventGroup, group) prvTraceSetEventGroupNumberHigh16((void*)pxEventGroup, group)
680 
681 #else
682 
686 #define TRACE_GET_EVENTGROUP_FILTER(pxEventGroup) ((void)(pxEventGroup), 1)
687 
691 #define TRACE_SET_EVENTGROUP_FILTER(pxEventGroup, group) ((void)(pxEventGroup), (void)(group))
692 
693 #endif
694 
695 #if (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0)
696 
704 #define TRACE_GET_TIMER_FILTER(pxTimer) prvTraceGetTimerNumberHigh16((void*)pxTimer)
705 
712 #define TRACE_SET_TIMER_FILTER(pxTimer, group) prvTraceSetTimerNumberHigh16((void*)pxTimer, group)
713 
714 #else
715 
719 #define TRACE_GET_TIMER_FILTER(pxTimer) ((void)(pxTimer), 1)
720 
724 #define TRACE_SET_TIMER_FILTER(pxTimer, group) ((void)(pxTimer), (void)(group))
725 
726 #endif
727 
735 #define TRACE_GET_STREAMBUFFER_FILTER(pxStreamBuffer) prvTraceGetStreamBufferNumberHigh16((void*)pxStreamBuffer)
736 
743 #define TRACE_SET_STREAMBUFFER_FILTER(pxStreamBuffer, group) prvTraceSetStreamBufferNumberHigh16((void*)pxStreamBuffer, group)
744 
745 #if (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_8_X_X)
746 
750 #define TRACE_GET_OBJECT_FILTER(CLASS, pxObject) TRACE_GET_##CLASS##_FILTER(pxObject)
751 
755 #define TRACE_SET_OBJECT_FILTER(CLASS, pxObject, group) TRACE_SET_##CLASS##_FILTER(pxObject, group)
756 
757 #else
758 
762 #define TRACE_GET_OBJECT_FILTER(CLASS, pxObject) 0xFFFF
763 
767 #define TRACE_SET_OBJECT_FILTER(CLASS, pxObject, group)
768 
769 #endif
770 
771 /* The object classes */
772 #define TRACE_NCLASSES 9
773 #define TRACE_CLASS_QUEUE ((traceObjectClass)0)
774 #define TRACE_CLASS_SEMAPHORE ((traceObjectClass)1)
775 #define TRACE_CLASS_MUTEX ((traceObjectClass)2)
776 #define TRACE_CLASS_TASK ((traceObjectClass)3)
777 #define TRACE_CLASS_ISR ((traceObjectClass)4)
778 #define TRACE_CLASS_TIMER ((traceObjectClass)5)
779 #define TRACE_CLASS_EVENTGROUP ((traceObjectClass)6)
780 #define TRACE_CLASS_STREAMBUFFER ((traceObjectClass)7)
781 #define TRACE_CLASS_MESSAGEBUFFER ((traceObjectClass)8)
782 
783 /* Definitions for Object Table */
784 #define TRACE_KERNEL_OBJECT_COUNT ((TRC_CFG_NQUEUE) + (TRC_CFG_NSEMAPHORE) + (TRC_CFG_NMUTEX) + (TRC_CFG_NTASK) + (TRC_CFG_NISR) + (TRC_CFG_NTIMER) + (TRC_CFG_NEVENTGROUP) + (TRC_CFG_NSTREAMBUFFER) + (TRC_CFG_NMESSAGEBUFFER))
785 
786 /* Queue properties (except name): current number of message in queue */
787 #define PropertyTableSizeQueue ((TRC_CFG_NAME_LEN_QUEUE) + 1)
788 
789 /* Semaphore properties (except name): state (signaled = 1, cleared = 0) */
790 #define PropertyTableSizeSemaphore ((TRC_CFG_NAME_LEN_SEMAPHORE) + 1)
791 
792 /* Mutex properties (except name): owner (task handle, 0 = free) */
793 #define PropertyTableSizeMutex ((TRC_CFG_NAME_LEN_MUTEX) + 1)
794 
795 /* Task properties (except name): Byte 0: Current priority
796  Byte 1: state (if already active)
797  Byte 2: legacy, not used
798  Byte 3: legacy, not used */
799 #define PropertyTableSizeTask ((TRC_CFG_NAME_LEN_TASK) + 4)
800 
801 /* ISR properties: Byte 0: priority
802  Byte 1: state (if already active) */
803 #define PropertyTableSizeISR ((TRC_CFG_NAME_LEN_ISR) + 2)
804 
805 /* TRC_CFG_NTIMER properties: Byte 0: state (unused for now) */
806 #define PropertyTableSizeTimer ((TRC_CFG_NAME_LEN_TIMER) + 1)
807 
808 /* TRC_CFG_NEVENTGROUP properties: Byte 0-3: state (unused for now)*/
809 #define PropertyTableSizeEventGroup ((TRC_CFG_NAME_LEN_EVENTGROUP) + 4)
810 
811 /* TRC_CFG_NSTREAMBUFFER properties: Byte 0-3: state (unused for now)*/
812 #define PropertyTableSizeStreamBuffer ((TRC_CFG_NAME_LEN_STREAMBUFFER) + 4)
813 
814 /* TRC_CFG_NMESSAGEBUFFER properties: Byte 0-3: state (unused for now)*/
815 #define PropertyTableSizeMessageBuffer ((TRC_CFG_NAME_LEN_MESSAGEBUFFER) + 4)
816 
817 
818 /* The layout of the byte array representing the Object Property Table */
819 #define StartIndexQueue (0)
820 #define StartIndexSemaphore (StartIndexQueue + (TRC_CFG_NQUEUE) * PropertyTableSizeQueue)
821 #define StartIndexMutex (StartIndexSemaphore + (TRC_CFG_NSEMAPHORE) * PropertyTableSizeSemaphore)
822 #define StartIndexTask (StartIndexMutex + (TRC_CFG_NMUTEX) * PropertyTableSizeMutex)
823 #define StartIndexISR (StartIndexTask + (TRC_CFG_NTASK) * PropertyTableSizeTask)
824 #define StartIndexTimer (StartIndexISR + (TRC_CFG_NISR) * PropertyTableSizeISR)
825 #define StartIndexEventGroup (StartIndexTimer + (TRC_CFG_NTIMER) * PropertyTableSizeTimer)
826 #define StartIndexStreamBuffer (StartIndexEventGroup + (TRC_CFG_NEVENTGROUP) * PropertyTableSizeEventGroup)
827 #define StartIndexMessageBuffer (StartIndexStreamBuffer + (TRC_CFG_NSTREAMBUFFER) * PropertyTableSizeStreamBuffer)
828 
829 /* Number of bytes used by the object table */
830 #define TRACE_OBJECT_TABLE_SIZE (StartIndexMessageBuffer + (TRC_CFG_NMESSAGEBUFFER) * PropertyTableSizeMessageBuffer)
831 
832 /* Flag to tell the context of tracePEND_FUNC_CALL_FROM_ISR */
833 extern int uiInEventGroupSetBitsFromISR;
834 
838 traceResult xTraceKernelPortInitObjectPropertyTable(void);
839 
843 traceResult xTraceKernelPortInitObjectHandleStack(void);
844 
848 const char* pszTraceGetErrorNotEnoughHandles(traceObjectClass objectclass);
849 
853 void* prvTraceGetCurrentTaskHandle(void);
854 
855 extern traceObjectClass TraceQueueClassTable[5];
856 
857 
858 /*** Event codes for snapshot mode - must match Tracealyzer config files ******/
859 
860 #define NULL_EVENT (0x00UL)
861 
862 /*******************************************************************************
863  * EVENTGROUP_DIV
864  *
865  * Miscellaneous events.
866  ******************************************************************************/
867 #define EVENTGROUP_DIV (NULL_EVENT + 1UL) /*0x01*/
868 #define DIV_XPS (EVENTGROUP_DIV + 0UL) /*0x01*/
869 #define DIV_TASK_READY (EVENTGROUP_DIV + 1UL) /*0x02*/
870 #define DIV_NEW_TIME (EVENTGROUP_DIV + 2UL) /*0x03*/
871 
872 /*******************************************************************************
873  * EVENTGROUP_TS
874  *
875  * Events for storing task-switches and interrupts. The RESUME events are
876  * generated if the task/interrupt is already marked active.
877  ******************************************************************************/
878 #define EVENTGROUP_TS (EVENTGROUP_DIV + 3UL) /*0x04*/
879 #define TS_ISR_BEGIN (EVENTGROUP_TS + 0UL) /*0x04*/
880 #define TS_ISR_RESUME (EVENTGROUP_TS + 1UL) /*0x05*/
881 #define TS_TASK_BEGIN (EVENTGROUP_TS + 2UL) /*0x06*/
882 #define TS_TASK_RESUME (EVENTGROUP_TS + 3UL) /*0x07*/
883 
884 /*******************************************************************************
885  * EVENTGROUP_OBJCLOSE_NAME
886  *
887  * About Close Events
888  * When an object is evicted from the object property table (object close), two
889  * internal events are stored (EVENTGROUP_OBJCLOSE_NAME and
890  * EVENTGROUP_OBJCLOSE_PROP), containing the handle-name mapping and object
891  * properties valid up to this point.
892  ******************************************************************************/
893 #define EVENTGROUP_OBJCLOSE_NAME_TRCSUCCESS (EVENTGROUP_TS + 4UL) /*0x08*/
894 
895 /*******************************************************************************
896  * EVENTGROUP_OBJCLOSE_PROP
897  *
898  * The internal event carrying properties of deleted objects
899  * The handle and object class of the closed object is not stored in this event,
900  * but is assumed to be the same as in the preceding CLOSE event. Thus, these
901  * two events must be generated from within a critical section.
902  * When queues are closed, arg1 is the "state" property (i.e., number of
903  * buffered messages/signals).
904  * When actors are closed, arg1 is priority, arg2 is handle of the "instance
905  * finish" event, and arg3 is event code of the "instance finish" event.
906  * In this case, the lower three bits is the object class of the instance finish
907  * handle. The lower three bits are not used (always zero) when queues are
908  * closed since the queue type is given in the previous OBJCLOSE_NAME event.
909  ******************************************************************************/
910 #define EVENTGROUP_OBJCLOSE_PROP_TRCSUCCESS (EVENTGROUP_OBJCLOSE_NAME_TRCSUCCESS + 8UL) /*0x10*/
911 
912 /*******************************************************************************
913  * EVENTGROUP_CREATE
914  *
915  * The events in this group are used to log Kernel object creations.
916  * The lower three bits in the event code gives the object class, i.e., type of
917  * create operation (task, queue, semaphore, etc).
918  ******************************************************************************/
919 #define EVENTGROUP_CREATE_OBJ_TRCSUCCESS (EVENTGROUP_OBJCLOSE_PROP_TRCSUCCESS + 8UL) /*0x18*/
920 
921 /*******************************************************************************
922  * EVENTGROUP_SEND
923  *
924  * The events in this group are used to log Send/Give events on queues,
925  * semaphores and mutexes The lower three bits in the event code gives the
926  * object class, i.e., what type of object that is operated on (queue, semaphore
927  * or mutex).
928  ******************************************************************************/
929 #define EVENTGROUP_SEND_TRCSUCCESS (EVENTGROUP_CREATE_OBJ_TRCSUCCESS + 8UL) /*0x20*/
930 
931 /*******************************************************************************
932  * EVENTGROUP_RECEIVE
933  *
934  * The events in this group are used to log Receive/Take events on queues,
935  * semaphores and mutexes. The lower three bits in the event code gives the
936  * object class, i.e., what type of object that is operated on (queue, semaphore
937  * or mutex).
938  ******************************************************************************/
939 #define EVENTGROUP_RECEIVE_TRCSUCCESS (EVENTGROUP_SEND_TRCSUCCESS + 8UL) /*0x28*/
940 
941 /* Send/Give operations, from ISR */
942 #define EVENTGROUP_SEND_FROM_ISR_TRCSUCCESS \
943  (EVENTGROUP_RECEIVE_TRCSUCCESS + 8UL) /*0x30*/
944 
945 /* Receive/Take operations, from ISR */
946 #define EVENTGROUP_RECEIVE_FROM_ISR_TRCSUCCESS \
947  (EVENTGROUP_SEND_FROM_ISR_TRCSUCCESS + 8UL) /*0x38*/
948 
949 /* "Failed" event type versions of above (timeout, failed allocation, etc) */
950 #define EVENTGROUP_KSE_TRCFAILED \
951  (EVENTGROUP_RECEIVE_FROM_ISR_TRCSUCCESS + 8UL) /*0x40*/
952 
953 /* Failed create calls - memory allocation failed */
954 #define EVENTGROUP_CREATE_OBJ_TRCFAILED (EVENTGROUP_KSE_TRCFAILED) /*0x40*/
955 
956 /* Failed send/give - timeout! */
957 #define EVENTGROUP_SEND_TRCFAILED (EVENTGROUP_CREATE_OBJ_TRCFAILED + 8UL) /*0x48*/
958 
959 /* Failed receive/take - timeout! */
960 #define EVENTGROUP_RECEIVE_TRCFAILED (EVENTGROUP_SEND_TRCFAILED + 8UL) /*0x50*/
961 
962 /* Failed non-blocking send/give - queue full */
963 #define EVENTGROUP_SEND_FROM_ISR_TRCFAILED (EVENTGROUP_RECEIVE_TRCFAILED + 8UL) /*0x58*/
964 
965 /* Failed non-blocking receive/take - queue empty */
966 #define EVENTGROUP_RECEIVE_FROM_ISR_TRCFAILED \
967  (EVENTGROUP_SEND_FROM_ISR_TRCFAILED + 8UL) /*0x60*/
968 
969 /* Events when blocking on receive/take */
970 #define EVENTGROUP_RECEIVE_TRCBLOCK \
971  (EVENTGROUP_RECEIVE_FROM_ISR_TRCFAILED + 8UL) /*0x68*/
972 
973 /* Events when blocking on send/give */
974 #define EVENTGROUP_SEND_TRCBLOCK (EVENTGROUP_RECEIVE_TRCBLOCK + 8UL) /*0x70*/
975 
976 /* Events on queue peek (receive) */
977 #define EVENTGROUP_PEEK_TRCSUCCESS (EVENTGROUP_SEND_TRCBLOCK + 8UL) /*0x78*/
978 
979 /* Events on object delete (vTaskDelete or vQueueDelete) */
980 #define EVENTGROUP_DELETE_OBJ_TRCSUCCESS (EVENTGROUP_PEEK_TRCSUCCESS + 8UL) /*0x80*/
981 
982 /* Other events - object class is implied: TASK */
983 #define EVENTGROUP_OTHERS (EVENTGROUP_DELETE_OBJ_TRCSUCCESS + 8UL) /*0x88*/
984 #define TASK_DELAY_UNTIL (EVENTGROUP_OTHERS + 0UL) /*0x88*/
985 #define TASK_DELAY (EVENTGROUP_OTHERS + 1UL) /*0x89*/
986 #define TASK_SUSPEND (EVENTGROUP_OTHERS + 2UL) /*0x8A*/
987 #define TASK_RESUME (EVENTGROUP_OTHERS + 3UL) /*0x8B*/
988 #define TASK_RESUME_FROM_ISR (EVENTGROUP_OTHERS + 4UL) /*0x8C*/
989 #define TASK_PRIORITY_SET (EVENTGROUP_OTHERS + 5UL) /*0x8D*/
990 #define TASK_PRIORITY_INHERIT (EVENTGROUP_OTHERS + 6UL) /*0x8E*/
991 #define TASK_PRIORITY_DISINHERIT (EVENTGROUP_OTHERS + 7UL) /*0x8F*/
992 
993 #define EVENTGROUP_MISC_PLACEHOLDER (EVENTGROUP_OTHERS + 8UL) /*0x90*/
994 #define PEND_FUNC_CALL (EVENTGROUP_MISC_PLACEHOLDER+0UL) /*0x90*/
995 #define PEND_FUNC_CALL_FROM_ISR (EVENTGROUP_MISC_PLACEHOLDER+1UL) /*0x91*/
996 #define PEND_FUNC_CALL_TRCFAILED (EVENTGROUP_MISC_PLACEHOLDER+2UL) /*0x92*/
997 #define PEND_FUNC_CALL_FROM_ISR_TRCFAILED (EVENTGROUP_MISC_PLACEHOLDER+3UL) /*0x93*/
998 #define MEM_MALLOC_SIZE (EVENTGROUP_MISC_PLACEHOLDER+4UL) /*0x94*/
999 #define MEM_MALLOC_ADDR (EVENTGROUP_MISC_PLACEHOLDER+5UL) /*0x95*/
1000 #define MEM_FREE_SIZE (EVENTGROUP_MISC_PLACEHOLDER+6UL) /*0x96*/
1001 #define MEM_FREE_ADDR (EVENTGROUP_MISC_PLACEHOLDER+7UL) /*0x97*/
1002 
1003 /* User events */
1004 #define EVENTGROUP_USEREVENT (EVENTGROUP_MISC_PLACEHOLDER + 8UL) /*0x98*/
1005 #define USER_EVENT (EVENTGROUP_USEREVENT + 0UL)
1006 
1007 /* Allow for 0-15 arguments (the number of args is added to event code) */
1008 #define USER_EVENT_LAST (EVENTGROUP_USEREVENT + 15UL) /*0xA7*/
1009 
1010 /*******************************************************************************
1011  * XTS Event - eXtended TimeStamp events
1012  * The timestamps used in the recorder are "differential timestamps" (DTS), i.e.
1013  * the time since the last stored event. The DTS fields are either 1 or 2 bytes
1014  * in the other events, depending on the bytes available in the event struct.
1015  * If the time since the last event (the DTS) is larger than allowed for by
1016  * the DTS field of the current event, an XTS event is inserted immediately
1017  * before the original event. The XTS event contains up to 3 additional bytes
1018  * of the DTS value - the higher bytes of the true DTS value. The lower 1-2
1019  * bytes are stored in the normal DTS field.
1020  * There are two types of XTS events, XTS8 and XTS16. An XTS8 event is stored
1021  * when there is only room for 1 byte (8 bit) DTS data in the original event,
1022  * which means a limit of 0xFF (255UL). The XTS16 is used when the original event
1023  * has a 16 bit DTS field and thereby can handle values up to 0xFFFF (65535UL).
1024  *
1025  * Using a very high frequency time base can result in many XTS events.
1026  * Preferably, the time between two OS ticks should fit in 16 bits, i.e.,
1027  * at most 65535. If your time base has a higher frequency, you can define
1028  * the TRACE
1029  ******************************************************************************/
1030 
1031 #define EVENTGROUP_SYS (EVENTGROUP_USEREVENT + 16UL) /*0xA8*/
1032 #define XTS8 (EVENTGROUP_SYS + 0UL) /*0xA8*/
1033 #define XTS16 (EVENTGROUP_SYS + 1UL) /*0xA9*/
1034 #define EVENT_BEING_WRITTEN (EVENTGROUP_SYS + 2UL) /*0xAA*/
1035 #define RESERVED_DUMMY_CODE (EVENTGROUP_SYS + 3UL) /*0xAB*/
1036 #define LOW_POWER_BEGIN (EVENTGROUP_SYS + 4UL) /*0xAC*/
1037 #define LOW_POWER_END (EVENTGROUP_SYS + 5UL) /*0xAD*/
1038 #define XID (EVENTGROUP_SYS + 6UL) /*0xAE*/
1039 #define XTS16L (EVENTGROUP_SYS + 7UL) /*0xAF*/
1040 
1041 #define EVENTGROUP_TIMER (EVENTGROUP_SYS + 8UL) /*0xB0*/
1042 #define TIMER_CREATE (EVENTGROUP_TIMER + 0UL) /*0xB0*/
1043 #define TIMER_START (EVENTGROUP_TIMER + 1UL) /*0xB1*/
1044 #define TIMER_RST (EVENTGROUP_TIMER + 2UL) /*0xB2*/
1045 #define TIMER_STOP (EVENTGROUP_TIMER + 3UL) /*0xB3*/
1046 #define TIMER_CHANGE_PERIOD (EVENTGROUP_TIMER + 4UL) /*0xB4*/
1047 #define TIMER_DELETE_OBJ (EVENTGROUP_TIMER + 5UL) /*0xB5*/
1048 #define TIMER_START_FROM_ISR (EVENTGROUP_TIMER + 6UL) /*0xB6*/
1049 #define TIMER_RESET_FROM_ISR (EVENTGROUP_TIMER + 7UL) /*0xB7*/
1050 #define TIMER_STOP_FROM_ISR (EVENTGROUP_TIMER + 8UL) /*0xB8*/
1051 
1052 #define TIMER_CREATE_TRCFAILED (EVENTGROUP_TIMER + 9UL) /*0xB9*/
1053 #define TIMER_START_TRCFAILED (EVENTGROUP_TIMER + 10UL) /*0xBA*/
1054 #define TIMER_RESET_TRCFAILED (EVENTGROUP_TIMER + 11UL) /*0xBB*/
1055 #define TIMER_STOP_TRCFAILED (EVENTGROUP_TIMER + 12UL) /*0xBC*/
1056 #define TIMER_CHANGE_PERIOD_TRCFAILED (EVENTGROUP_TIMER + 13UL) /*0xBD*/
1057 #define TIMER_DELETE_TRCFAILED (EVENTGROUP_TIMER + 14UL) /*0xBE*/
1058 #define TIMER_START_FROM_ISR_TRCFAILED (EVENTGROUP_TIMER + 15UL) /*0xBF*/
1059 #define TIMER_RESET_FROM_ISR_TRCFAILED (EVENTGROUP_TIMER + 16UL) /*0xC0*/
1060 #define TIMER_STOP_FROM_ISR_TRCFAILED (EVENTGROUP_TIMER + 17UL) /*0xC1*/
1061 
1062 #define EVENTGROUP_EG (EVENTGROUP_TIMER + 18UL) /*0xC2*/
1063 #define EVENT_GROUP_CREATE (EVENTGROUP_EG + 0UL) /*0xC2*/
1064 #define EVENT_GROUP_CREATE_TRCFAILED (EVENTGROUP_EG + 1UL) /*0xC3*/
1065 #define EVENT_GROUP_SYNC_TRCBLOCK (EVENTGROUP_EG + 2UL) /*0xC4*/
1066 #define EVENT_GROUP_SYNC_END (EVENTGROUP_EG + 3UL) /*0xC5*/
1067 #define EVENT_GROUP_WAIT_BITS_TRCBLOCK (EVENTGROUP_EG + 4UL) /*0xC6*/
1068 #define EVENT_GROUP_WAIT_BITS_END (EVENTGROUP_EG + 5UL) /*0xC7*/
1069 #define EVENT_GROUP_CLEAR_BITS (EVENTGROUP_EG + 6UL) /*0xC8*/
1070 #define EVENT_GROUP_CLEAR_BITS_FROM_ISR (EVENTGROUP_EG + 7UL) /*0xC9*/
1071 #define EVENT_GROUP_SET_BITS (EVENTGROUP_EG + 8UL) /*0xCA*/
1072 #define EVENT_GROUP_DELETE_OBJ (EVENTGROUP_EG + 9UL) /*0xCB*/
1073 #define EVENT_GROUP_SYNC_END_TRCFAILED (EVENTGROUP_EG + 10UL) /*0xCC*/
1074 #define EVENT_GROUP_WAIT_BITS_END_TRCFAILED (EVENTGROUP_EG + 11UL) /*0xCD*/
1075 #define EVENT_GROUP_SET_BITS_FROM_ISR (EVENTGROUP_EG + 12UL) /*0xCE*/
1076 #define EVENT_GROUP_SET_BITS_FROM_ISR_TRCFAILED (EVENTGROUP_EG + 13UL) /*0xCF*/
1077 
1078 #define TASK_INSTANCE_FINISHED_NEXT_KSE (EVENTGROUP_EG + 14UL) /*0xD0*/
1079 #define TASK_INSTANCE_FINISHED_DIRECT (EVENTGROUP_EG + 15UL) /*0xD1*/
1080 
1081 #define TRACE_TASK_NOTIFY_GROUP (EVENTGROUP_EG + 16UL) /*0xD2*/
1082 #define TRACE_TASK_NOTIFY (TRACE_TASK_NOTIFY_GROUP + 0UL) /*0xD2*/
1083 #define TRACE_TASK_NOTIFY_TAKE (TRACE_TASK_NOTIFY_GROUP + 1UL) /*0xD3*/
1084 #define TRACE_TASK_NOTIFY_TAKE_TRCBLOCK (TRACE_TASK_NOTIFY_GROUP + 2UL) /*0xD4*/
1085 #define TRACE_TASK_NOTIFY_TAKE_TRCFAILED (TRACE_TASK_NOTIFY_GROUP + 3UL) /*0xD5*/
1086 #define TRACE_TASK_NOTIFY_WAIT (TRACE_TASK_NOTIFY_GROUP + 4UL) /*0xD6*/
1087 #define TRACE_TASK_NOTIFY_WAIT_TRCBLOCK (TRACE_TASK_NOTIFY_GROUP + 5UL) /*0xD7*/
1088 #define TRACE_TASK_NOTIFY_WAIT_TRCFAILED (TRACE_TASK_NOTIFY_GROUP + 6UL) /*0xD8*/
1089 #define TRACE_TASK_NOTIFY_FROM_ISR (TRACE_TASK_NOTIFY_GROUP + 7UL) /*0xD9*/
1090 #define TRACE_TASK_NOTIFY_GIVE_FROM_ISR (TRACE_TASK_NOTIFY_GROUP + 8UL) /*0xDA*/
1091 
1092 #define TIMER_EXPIRED (TRACE_TASK_NOTIFY_GROUP + 9UL) /*0xDB*/
1093 
1094  /* Events on queue peek (receive) */
1095 #define EVENTGROUP_PEEK_TRCBLOCK (TRACE_TASK_NOTIFY_GROUP + 10UL) /*0xDC*/
1096 /* peek block on queue: 0xDC */
1097 /* peek block on semaphore: 0xDD */
1098 /* peek block on mutex: 0xDE */
1099 
1100 /* Events on queue peek (receive) */
1101 #define EVENTGROUP_PEEK_TRCFAILED (EVENTGROUP_PEEK_TRCBLOCK + 3UL) /*0xDF*/
1102 /* peek failed on queue: 0xDF */
1103 /* peek failed on semaphore: 0xE0 */
1104 /* peek failed on mutex: 0xE1 */
1105 
1106 #define EVENTGROUP_STREAMBUFFER_DIV (EVENTGROUP_PEEK_TRCFAILED + 3UL) /*0xE2*/
1107 #define TRACE_STREAMBUFFER_RESET (EVENTGROUP_STREAMBUFFER_DIV + 0) /*0xE2*/
1108 #define TRACE_MESSAGEBUFFER_RESET (EVENTGROUP_STREAMBUFFER_DIV + 1UL) /*0xE3*/
1109 #define TRACE_STREAMBUFFER_OBJCLOSE_NAME_TRCSUCCESS (EVENTGROUP_STREAMBUFFER_DIV + 2UL) /*0xE4*/
1110 #define TRACE_MESSAGEBUFFER_OBJCLOSE_NAME_TRCSUCCESS (EVENTGROUP_STREAMBUFFER_DIV + 3UL) /*0xE5*/
1111 #define TRACE_STREAMBUFFER_OBJCLOSE_PROP_TRCSUCCESS (EVENTGROUP_STREAMBUFFER_DIV + 4UL) /*0xE6*/
1112 #define TRACE_MESSAGEBUFFER_OBJCLOSE_PROP_TRCSUCCESS (EVENTGROUP_STREAMBUFFER_DIV + 5UL) /*0xE7*/
1113 
1114 #define EVENTGROUP_MALLOC_FAILED (EVENTGROUP_STREAMBUFFER_DIV + 6UL) /*0xE8*/
1115 #define MEM_MALLOC_SIZE_TRCFAILED (EVENTGROUP_MALLOC_FAILED + 0UL) /*0xE8*/
1116 #define MEM_MALLOC_ADDR_TRCFAILED (EVENTGROUP_MALLOC_FAILED + 1UL) /*0xE9*/
1117 
1118 /* The following are using previously "lost" event codes */
1119 #define TRACE_STREAMBUFFER_CREATE_OBJ_TRCSUCCESS (EVENTGROUP_CREATE_OBJ_TRCSUCCESS + 4UL) /*0x1C*/
1120 #define TRACE_STREAMBUFFER_CREATE_OBJ_TRCFAILED (EVENTGROUP_CREATE_OBJ_TRCFAILED + 4UL) /*0x44*/
1121 #define TRACE_STREAMBUFFER_DELETE_OBJ_TRCSUCCESS (EVENTGROUP_DELETE_OBJ_TRCSUCCESS + 4UL) /*0x84*/
1122 #define TRACE_STREAMBUFFER_SEND_TRCSUCCESS (EVENTGROUP_SEND_TRCSUCCESS + 3UL) /*0x23*/
1123 #define TRACE_STREAMBUFFER_SEND_TRCBLOCK (EVENTGROUP_SEND_TRCBLOCK + 3UL) /*0x73*/
1124 #define TRACE_STREAMBUFFER_SEND_TRCFAILED (EVENTGROUP_SEND_TRCFAILED + 3UL) /*0x4B*/
1125 #define TRACE_STREAMBUFFER_RECEIVE_TRCSUCCESS (EVENTGROUP_RECEIVE_TRCSUCCESS + 3UL) /*0x2B*/
1126 #define TRACE_STREAMBUFFER_RECEIVE_TRCBLOCK (EVENTGROUP_RECEIVE_TRCBLOCK + 3UL) /*0x6B*/
1127 #define TRACE_STREAMBUFFER_RECEIVE_TRCFAILED (EVENTGROUP_RECEIVE_TRCFAILED + 3UL) /*0x53*/
1128 #define TRACE_STREAMBUFFER_SEND_FROM_ISR_TRCSUCCESS (EVENTGROUP_SEND_FROM_ISR_TRCSUCCESS + 3UL) /*0x33*/
1129 #define TRACE_STREAMBUFFER_SEND_FROM_ISR_TRCFAILED (EVENTGROUP_SEND_FROM_ISR_TRCFAILED + 3UL) /*0x5B*/
1130 #define TRACE_STREAMBUFFER_RECEIVE_FROM_ISR_TRCSUCCESS (EVENTGROUP_RECEIVE_FROM_ISR_TRCSUCCESS + 3UL) /*0x3B*/
1131 #define TRACE_STREAMBUFFER_RECEIVE_FROM_ISR_TRCFAILED (EVENTGROUP_RECEIVE_FROM_ISR_TRCFAILED + 3UL) /*0x63*/
1132 
1133 /* The following are using previously "lost" event codes. These macros aren't even directly referenced, instead we do (equivalent STREAMBUFFER code) + 1. */
1134 #define TRACE_MESSAGEBUFFER_CREATE_OBJ_TRCSUCCESS (EVENTGROUP_CREATE_OBJ_TRCSUCCESS + 5UL) /*0x1D*/
1135 #define TRACE_MESSAGEBUFFER_CREATE_OBJ_TRCFAILED (EVENTGROUP_CREATE_OBJ_TRCFAILED + 5UL) /*0x45*/
1136 #define TRACE_MESSAGEBUFFER_DELETE_OBJ_TRCSUCCESS (EVENTGROUP_DELETE_OBJ_TRCSUCCESS + 5UL) /*0x85*/
1137 #define TRACE_MESSAGEBUFFER_SEND_TRCSUCCESS (EVENTGROUP_SEND_TRCSUCCESS + 4UL) /*0x24*/
1138 #define TRACE_MESSAGEBUFFER_SEND_TRCBLOCK (EVENTGROUP_SEND_TRCBLOCK + 4UL) /*0x74*/
1139 #define TRACE_MESSAGEBUFFER_SEND_TRCFAILED (EVENTGROUP_SEND_TRCFAILED + 4UL) /*0x4C*/
1140 #define TRACE_MESSAGEBUFFER_RECEIVE_TRCSUCCESS (EVENTGROUP_RECEIVE_TRCSUCCESS + 4UL) /*0x2C*/
1141 #define TRACE_MESSAGEBUFFER_RECEIVE_TRCBLOCK (EVENTGROUP_RECEIVE_TRCBLOCK + 4UL) /*0x6C*/
1142 #define TRACE_MESSAGEBUFFER_RECEIVE_TRCFAILED (EVENTGROUP_RECEIVE_TRCFAILED + 4UL) /*0x54*/
1143 #define TRACE_MESSAGEBUFFER_SEND_FROM_ISR_TRCSUCCESS (EVENTGROUP_SEND_FROM_ISR_TRCSUCCESS + 4UL) /*0x34*/
1144 #define TRACE_MESSAGEBUFFER_SEND_FROM_ISR_TRCFAILED (EVENTGROUP_SEND_FROM_ISR_TRCFAILED + 4UL) /*0x5C*/
1145 #define TRACE_MESSAGEBUFFER_RECEIVE_FROM_ISR_TRCSUCCESS (EVENTGROUP_RECEIVE_FROM_ISR_TRCSUCCESS + 4UL) /*0x3C*/
1146 #define TRACE_MESSAGEBUFFER_RECEIVE_FROM_ISR_TRCFAILED (EVENTGROUP_RECEIVE_FROM_ISR_TRCFAILED + 4UL) /*0x64*/
1147 
1148 #define TRACE_QUEUE_SEND_TO_FRONT_TRCSUCCESS (EVENTGROUP_SEND_TRCSUCCESS + 5UL) /*0x25*/
1149 #define TRACE_QUEUE_SEND_TO_FRONT_TRCBLOCK (EVENTGROUP_SEND_TRCBLOCK + 5UL) /*0x75*/
1150 #define TRACE_QUEUE_SEND_TO_FRONT_TRCFAILED (EVENTGROUP_SEND_TRCFAILED + 5UL) /*0x4D*/
1151 #define TRACE_QUEUE_SEND_TO_FRONT_FROM_ISR_TRCSUCCESS (EVENTGROUP_SEND_FROM_ISR_TRCSUCCESS + 5UL) /*0x35*/
1152 #define TRACE_QUEUE_SEND_TO_FRONT_FROM_ISR_TRCFAILED (EVENTGROUP_SEND_FROM_ISR_TRCFAILED + 5UL) /*0x5D*/
1153 
1154 #define TRACE_UNUSED_STACK (EVENTGROUP_MALLOC_FAILED + 2UL) /*0xEA*/
1155 
1156 /* LAST EVENT (0xEA) */
1157 
1158 /****************************
1159 * MACROS TO GET TRACE CLASS *
1160 ****************************/
1161 #define TRACE_GET_TRACE_CLASS_FROM_TASK_CLASS(kernelClass) (TRACE_CLASS_TASK)
1162 #define TRACE_GET_TRACE_CLASS_FROM_TASK_OBJECT(pxObject) (TRACE_CLASS_TASK)
1163 
1164 #define TRACE_GET_TRACE_CLASS_FROM_QUEUE_CLASS(kernelClass) TraceQueueClassTable[kernelClass]
1165 #define TRACE_GET_TRACE_CLASS_FROM_QUEUE_OBJECT(pxObject) TRACE_GET_TRACE_CLASS_FROM_QUEUE_CLASS(prvTraceGetQueueType(pxObject))
1166 
1167 #define TRACE_GET_TRACE_CLASS_FROM_TIMER_CLASS(kernelClass) (TRACE_CLASS_TIMER)
1168 #define TRACE_GET_TRACE_CLASS_FROM_TIMER_OBJECT(pxObject) (TRACE_CLASS_TIMER)
1169 
1170 #define TRACE_GET_TRACE_CLASS_FROM_EVENTGROUP_CLASS(kernelClass) (TRACE_CLASS_EVENTGROUP)
1171 #define TRACE_GET_TRACE_CLASS_FROM_EVENTGROUP_OBJECT(pxObject) (TRACE_CLASS_EVENTGROUP)
1172 
1173 /* TRACE_GET_TRACE_CLASS_FROM_STREAMBUFFER_CLASS can only be accessed with a parameter indicating if it is a MessageBuffer */
1174 #define TRACE_GET_TRACE_CLASS_FROM_STREAMBUFFER_CLASS(xIsMessageBuffer) (xIsMessageBuffer == 1 ? TRACE_CLASS_MESSAGEBUFFER : TRACE_CLASS_STREAMBUFFER)
1175 #define TRACE_GET_TRACE_CLASS_FROM_STREAMBUFFER_OBJECT(pxObject) (prvGetStreamBufferType(pxObject) == 1 ? TRACE_CLASS_MESSAGEBUFFER : TRACE_CLASS_STREAMBUFFER)
1176 
1177 /* Generic versions */
1178 #define TRACE_GET_CLASS_TRACE_CLASS(CLASS, kernelClass) TRACE_GET_TRACE_CLASS_FROM_##CLASS##_CLASS(kernelClass)
1179 #define TRACE_GET_OBJECT_TRACE_CLASS(CLASS, pxObject) TRACE_GET_TRACE_CLASS_FROM_##CLASS##_OBJECT(pxObject)
1180 
1181 /******************************
1182 * MACROS TO GET OBJECT NUMBER *
1183 ******************************/
1184 #define TRACE_GET_TASK_NUMBER(pxTCB) (traceHandle)(prvTraceGetTaskNumberLow16(pxTCB))
1185 #define TRACE_SET_TASK_NUMBER(pxTCB) prvTraceSetTaskNumberLow16(pxTCB, prvTraceGetObjectHandle(TRACE_GET_OBJECT_TRACE_CLASS(TASK, pxTCB)));
1186 
1187 #define TRACE_GET_QUEUE_NUMBER(queue) ( ( traceHandle ) prvTraceGetQueueNumberLow16(queue) )
1188 #define TRACE_SET_QUEUE_NUMBER(queue) prvTraceSetQueueNumberLow16(queue, (uint16_t)prvTraceGetObjectHandle(TRACE_GET_OBJECT_TRACE_CLASS(QUEUE, queue)));
1189 
1190 #if (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0)
1191 #define TRACE_GET_TIMER_NUMBER(tmr) ( ( traceHandle ) prvTraceGetTimerNumberLow16(tmr) )
1192 #define TRACE_SET_TIMER_NUMBER(tmr) prvTraceSetTimerNumberLow16(tmr, (uint16_t)prvTraceGetObjectHandle(TRACE_GET_OBJECT_TRACE_CLASS(TIMER, tmr)));
1193 #else /* (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0) */
1194 #define TRACE_GET_TIMER_NUMBER(tmr) ( ( traceHandle ) ((Timer_t*)tmr)->uxTimerNumber )
1195 #define TRACE_SET_TIMER_NUMBER(tmr) ((Timer_t*)tmr)->uxTimerNumber = prvTraceGetObjectHandle(TRACE_GET_OBJECT_TRACE_CLASS(TIMER, tmr));
1196 #endif /* (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0) */
1197 
1198 #if (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0)
1199 #define TRACE_GET_EVENTGROUP_NUMBER(eg) ( ( traceHandle ) prvTraceGetEventGroupNumberLow16(eg) )
1200 #define TRACE_SET_EVENTGROUP_NUMBER(eg) prvTraceSetEventGroupNumberLow16(eg, (uint16_t)prvTraceGetObjectHandle(TRACE_GET_OBJECT_TRACE_CLASS(EVENTGROUP, eg)));
1201 #else /* (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0) */
1202 #define TRACE_GET_EVENTGROUP_NUMBER(eg) ( ( traceHandle ) uxEventGroupGetNumber(eg) )
1203 #define TRACE_SET_EVENTGROUP_NUMBER(eg) ((EventGroup_t*)eg)->uxEventGroupNumber = prvTraceGetObjectHandle(TRACE_GET_OBJECT_TRACE_CLASS(EVENTGROUP, eg));
1204 #endif /* (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0) */
1205 
1206 
1207 #define TRACE_GET_STREAMBUFFER_NUMBER(sb) ( ( traceHandle ) prvTraceGetStreamBufferNumberLow16(sb) )
1208 #define TRACE_SET_STREAMBUFFER_NUMBER(sb) prvTraceSetStreamBufferNumberLow16(sb, (uint16_t)prvTraceGetObjectHandle(TRACE_GET_OBJECT_TRACE_CLASS(STREAMBUFFER, sb)));
1209 
1210 /* Generic versions */
1211 #define TRACE_GET_OBJECT_NUMBER(CLASS, pxObject) TRACE_GET_##CLASS##_NUMBER(pxObject)
1212 #define TRACE_SET_OBJECT_NUMBER(CLASS, pxObject) TRACE_SET_##CLASS##_NUMBER(pxObject)
1213 
1214 /******************************
1215 * MACROS TO GET EVENT CODES *
1216 ******************************/
1217 #define TRACE_GET_TASK_CLASS_EVENT_CODE(SERVICE, RESULT, kernelClass) (uint8_t)(EVENTGROUP_##SERVICE##_##RESULT + TRACE_GET_CLASS_TRACE_CLASS(TASK, kernelClass))
1218 #define TRACE_GET_QUEUE_CLASS_EVENT_CODE(SERVICE, RESULT, kernelClass) (uint8_t)(EVENTGROUP_##SERVICE##_##RESULT + TRACE_GET_CLASS_TRACE_CLASS(QUEUE, kernelClass))
1219 #define TRACE_GET_TIMER_CLASS_EVENT_CODE(SERVICE, RESULT, kernelClass) -- THIS IS NOT USED --
1220 #define TRACE_GET_EVENTGROUP_CLASS_EVENT_CODE(SERVICE, RESULT, kernelClass) -- THIS IS NOT USED --
1221 #define TRACE_GET_STREAMBUFFER_CLASS_EVENT_CODE(SERVICE, RESULT, isMessageBuffer) (uint8_t)(TRACE_STREAMBUFFER_##SERVICE##_##RESULT + (uint8_t)isMessageBuffer)
1222 
1223 #define TRACE_GET_TASK_OBJECT_EVENT_CODE(SERVICE, RESULT, pxTCB) (uint8_t)(EVENTGROUP_##SERVICE##_##RESULT + TRACE_CLASS_TASK)
1224 #define TRACE_GET_QUEUE_OBJECT_EVENT_CODE(SERVICE, RESULT, pxObject) (uint8_t)(EVENTGROUP_##SERVICE##_##RESULT + TRACE_GET_OBJECT_TRACE_CLASS(QUEUE, pxObject))
1225 #define TRACE_GET_TIMER_OBJECT_EVENT_CODE(SERVICE, RESULT, UNUSED) -- THIS IS NOT USED --
1226 #define TRACE_GET_EVENTGROUP_OBJECT_EVENT_CODE(SERVICE, RESULT, UNUSED) -- THIS IS NOT USED --
1227 #define TRACE_GET_STREAMBUFFER_OBJECT_EVENT_CODE(SERVICE, RESULT, pxObject) (uint8_t)(TRACE_STREAMBUFFER_##SERVICE##_##RESULT + prvGetStreamBufferType(pxObject))
1228 
1229 /* Generic versions */
1230 #define TRACE_GET_CLASS_EVENT_CODE(SERVICE, RESULT, CLASS, kernelClass) TRACE_GET_##CLASS##_CLASS_EVENT_CODE(SERVICE, RESULT, kernelClass)
1231 #define TRACE_GET_OBJECT_EVENT_CODE(SERVICE, RESULT, CLASS, pxObject) TRACE_GET_##CLASS##_OBJECT_EVENT_CODE(SERVICE, RESULT, pxObject)
1232 
1233 /******************************
1234 * SPECIAL MACROS FOR TASKS *
1235 ******************************/
1236 #define TRACE_GET_TASK_PRIORITY(pxTCB) ((uint8_t)pxTCB->uxPriority)
1237 #define TRACE_GET_TASK_NAME(pxTCB) ((char*)pxTCB->pcTaskName)
1238 
1239 /*** The trace macros for snapshot mode **************************************/
1240 
1241 /* A macro that will update the tick count when returning from tickless idle */
1242 #undef traceINCREASE_TICK_COUNT
1243 #define traceINCREASE_TICK_COUNT( xCount )
1244 
1245 /* Called for each task that becomes ready */
1246 #undef traceMOVED_TASK_TO_READY_STATE
1247 #define traceMOVED_TASK_TO_READY_STATE( pxTCB ) \
1248  trcKERNEL_HOOKS_MOVED_TASK_TO_READY_STATE(pxTCB);
1249 
1250 /* Called on each OS tick. Will call uiPortGetTimestamp to make sure it is called at least once every OS tick. */
1251 #undef traceTASK_INCREMENT_TICK
1252 
1253 #if (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_3_0)
1254 
1255 #define traceTASK_INCREMENT_TICK( xTickCount ) \
1256  if (uxSchedulerSuspended == ( unsigned portBASE_TYPE ) pdTRUE || xPendedTicks == 0) { trcKERNEL_HOOKS_INCREMENT_TICK(); } \
1257  if (uxSchedulerSuspended == ( unsigned portBASE_TYPE ) pdFALSE) { trcKERNEL_HOOKS_NEW_TIME(DIV_NEW_TIME, xTickCount + 1); }
1258 
1259 #elif (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_7_5_X)
1260 
1261 #define traceTASK_INCREMENT_TICK( xTickCount ) \
1262  if (uxSchedulerSuspended == ( unsigned portBASE_TYPE ) pdTRUE || uxPendedTicks == 0) { trcKERNEL_HOOKS_INCREMENT_TICK(); } \
1263  if (uxSchedulerSuspended == ( unsigned portBASE_TYPE ) pdFALSE) { trcKERNEL_HOOKS_NEW_TIME(DIV_NEW_TIME, xTickCount + 1); }
1264 
1265 #else
1266 
1267 #define traceTASK_INCREMENT_TICK( xTickCount ) \
1268  if (uxSchedulerSuspended == ( unsigned portBASE_TYPE ) pdTRUE || uxMissedTicks == 0) { trcKERNEL_HOOKS_INCREMENT_TICK(); } \
1269  if (uxSchedulerSuspended == ( unsigned portBASE_TYPE ) pdFALSE) { trcKERNEL_HOOKS_NEW_TIME(DIV_NEW_TIME, xTickCount + 1); }
1270 
1271 #endif
1272 
1273 extern volatile uint32_t uiTraceSystemState;
1274 
1275 /* Called on each task-switch */
1276 #undef traceTASK_SWITCHED_IN
1277 #define traceTASK_SWITCHED_IN() \
1278  uiTraceSystemState = TRC_STATE_IN_TASKSWITCH; \
1279  trcKERNEL_HOOKS_TASK_SWITCH(TRACE_GET_CURRENT_TASK()); \
1280  uiTraceSystemState = TRC_STATE_IN_APPLICATION;
1281 
1282 /* Called on vTaskCreate */
1283 #undef traceTASK_CREATE
1284 #define traceTASK_CREATE(pxNewTCB) \
1285  if (pxNewTCB != 0) \
1286  { \
1287  trcKERNEL_HOOKS_TASK_CREATE(TRACE_GET_OBJECT_EVENT_CODE(CREATE_OBJ, TRCSUCCESS, TASK, pxNewTCB), TASK, pxNewTCB); \
1288  prvAddTaskToStackMonitor(pxNewTCB); \
1289  }
1290 
1291 /* Called in vTaskCreate, if it fails (typically if the stack can not be allocated) */
1292 #undef traceTASK_CREATE_FAILED
1293 #define traceTASK_CREATE_FAILED() \
1294  trcKERNEL_HOOKS_OBJECT_CREATE_FAILED(TRACE_GET_CLASS_EVENT_CODE(CREATE_OBJ, TRCFAILED, TASK, NOT_USED), TRACE_GET_CLASS_TRACE_CLASS(TASK, NOT_USED))
1295 
1296 /* Called on vTaskDelete */
1297 #undef traceTASK_DELETE
1298 #define traceTASK_DELETE( pxTaskToDelete ) \
1299  { TRACE_ALLOC_CRITICAL_SECTION(); \
1300  TRACE_ENTER_CRITICAL_SECTION(); \
1301  trcKERNEL_HOOKS_TASK_DELETE(TRACE_GET_OBJECT_EVENT_CODE(DELETE_OBJ, TRCSUCCESS, TASK, pxTaskToDelete), TRACE_GET_OBJECT_EVENT_CODE(OBJCLOSE_NAME, TRCSUCCESS, TASK, pxTaskToDelete), TRACE_GET_OBJECT_EVENT_CODE(OBJCLOSE_PROP, TRCSUCCESS, TASK, pxTaskToDelete), pxTaskToDelete); \
1302  prvRemoveTaskFromStackMonitor(pxTaskToDelete); \
1303  TRACE_EXIT_CRITICAL_SECTION(); }
1304 
1305 #if (TRC_CFG_SCHEDULING_ONLY == 0)
1306 
1307 #if defined(configUSE_TICKLESS_IDLE) && (configUSE_TICKLESS_IDLE != 0)
1308 
1309 #undef traceLOW_POWER_IDLE_BEGIN
1310 #define traceLOW_POWER_IDLE_BEGIN() \
1311  { \
1312  extern uint32_t trace_disable_timestamp; \
1313  prvTraceStoreLowPower(0); \
1314  trace_disable_timestamp = 1; \
1315  }
1316 
1317 #undef traceLOW_POWER_IDLE_END
1318 #define traceLOW_POWER_IDLE_END() \
1319  { \
1320  extern uint32_t trace_disable_timestamp; \
1321  trace_disable_timestamp = 0; \
1322  prvTraceStoreLowPower(1); \
1323  }
1324 
1325 #endif
1326 
1327 /* Called on vTaskSuspend */
1328 #undef traceTASK_SUSPEND
1329 #define traceTASK_SUSPEND( pxTaskToSuspend ) \
1330  trcKERNEL_HOOKS_TASK_SUSPEND(TASK_SUSPEND, pxTaskToSuspend);
1331 
1332 /* Called from special case with timer only */
1333 #undef traceTASK_DELAY_SUSPEND
1334 #define traceTASK_DELAY_SUSPEND( pxTaskToSuspend ) \
1335  trcKERNEL_HOOKS_TASK_SUSPEND(TASK_SUSPEND, pxTaskToSuspend); \
1336  trcKERNEL_HOOKS_SET_TASK_INSTANCE_FINISHED();
1337 
1338 /* Called on vTaskDelay - note the use of FreeRTOS variable xTicksToDelay */
1339 #undef traceTASK_DELAY
1340 #define traceTASK_DELAY() \
1341  trcKERNEL_HOOKS_TASK_DELAY(TASK_DELAY, pxCurrentTCB, xTicksToDelay); \
1342  trcKERNEL_HOOKS_SET_TASK_INSTANCE_FINISHED();
1343 
1344 /* Called on vTaskDelayUntil - note the use of FreeRTOS variable xTimeToWake */
1345 #undef traceTASK_DELAY_UNTIL
1346 #if (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_9_0_0)
1347 
1348 #define traceTASK_DELAY_UNTIL(xTimeToWake) \
1349  trcKERNEL_HOOKS_TASK_DELAY(TASK_DELAY_UNTIL, pxCurrentTCB, xTimeToWake); \
1350  trcKERNEL_HOOKS_SET_TASK_INSTANCE_FINISHED();
1351 #else
1352 
1353 #define traceTASK_DELAY_UNTIL() \
1354  trcKERNEL_HOOKS_TASK_DELAY(TASK_DELAY_UNTIL, pxCurrentTCB, xTimeToWake); \
1355  trcKERNEL_HOOKS_SET_TASK_INSTANCE_FINISHED();
1356 
1357 #endif
1358 
1359 /* Called in xQueueCreate, and thereby for all other object based on queues, such as semaphores. */
1360 #undef traceQUEUE_CREATE
1361 #define traceQUEUE_CREATE( pxNewQueue ) \
1362  trcKERNEL_HOOKS_OBJECT_CREATE(TRACE_GET_OBJECT_EVENT_CODE(CREATE_OBJ, TRCSUCCESS, QUEUE, pxNewQueue), QUEUE, pxNewQueue);
1363 
1364 /* Called in xQueueCreate, if the queue creation fails */
1365 #undef traceQUEUE_CREATE_FAILED
1366 #define traceQUEUE_CREATE_FAILED( queueType ) \
1367  trcKERNEL_HOOKS_OBJECT_CREATE_FAILED(TRACE_GET_CLASS_EVENT_CODE(CREATE_OBJ, TRCFAILED, QUEUE, queueType), TRACE_GET_CLASS_TRACE_CLASS(QUEUE, queueType))
1368 
1369 /* Called on vQueueDelete */
1370 #undef traceQUEUE_DELETE
1371 #define traceQUEUE_DELETE( pxQueue ) \
1372  { TRACE_ALLOC_CRITICAL_SECTION(); \
1373  TRACE_ENTER_CRITICAL_SECTION(); \
1374  trcKERNEL_HOOKS_OBJECT_DELETE(TRACE_GET_OBJECT_EVENT_CODE(DELETE_OBJ, TRCSUCCESS, QUEUE, pxQueue), TRACE_GET_OBJECT_EVENT_CODE(OBJCLOSE_NAME, TRCSUCCESS, QUEUE, pxQueue), TRACE_GET_OBJECT_EVENT_CODE(OBJCLOSE_PROP, TRCSUCCESS, QUEUE, pxQueue), QUEUE, pxQueue); \
1375  TRACE_EXIT_CRITICAL_SECTION(); }
1376 
1377 /* This macro is not necessary as of FreeRTOS v9.0.0 */
1378 #if (TRC_CFG_FREERTOS_VERSION < TRC_FREERTOS_VERSION_9_0_0)
1379 
1380 /* Called in xQueueCreateMutex, and thereby also from xSemaphoreCreateMutex and xSemaphoreCreateRecursiveMutex */
1381 #undef traceCREATE_MUTEX
1382 #define traceCREATE_MUTEX( pxNewQueue ) \
1383  trcKERNEL_HOOKS_OBJECT_CREATE(TRACE_GET_OBJECT_EVENT_CODE(CREATE_OBJ, TRCSUCCESS, QUEUE, pxNewQueue), QUEUE, pxNewQueue);
1384 
1385 /* Called in xQueueCreateMutex when the operation fails (when memory allocation fails) */
1386 #undef traceCREATE_MUTEX_FAILED
1387 #define traceCREATE_MUTEX_FAILED() \
1388  trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_NUMERIC_PARAM_ONLY(TRACE_GET_CLASS_EVENT_CODE(CREATE_OBJ, TRCFAILED, QUEUE, queueQUEUE_TYPE_MUTEX), 0);
1389 
1390 #endif
1391 
1392 /* Called when the Mutex can not be given, since not holder */
1393 #undef traceGIVE_MUTEX_RECURSIVE_FAILED
1394 #define traceGIVE_MUTEX_RECURSIVE_FAILED( pxMutex ) \
1395  trcKERNEL_HOOKS_KERNEL_SERVICE(TRACE_GET_OBJECT_EVENT_CODE(SEND, TRCFAILED, QUEUE, pxMutex), QUEUE, pxMutex);
1396 
1397 /* Called when a message is sent to a queue */ /* CS IS NEW ! */
1398 #undef traceQUEUE_SEND
1399 #define traceQUEUE_SEND( pxQueue ) \
1400  trcKERNEL_HOOKS_KERNEL_SERVICE(xCopyPosition == queueSEND_TO_BACK ? (TRACE_GET_OBJECT_EVENT_CODE(SEND, TRCSUCCESS, QUEUE, pxQueue)) : TRACE_QUEUE_SEND_TO_FRONT_TRCSUCCESS, QUEUE, pxQueue); \
1401  trcKERNEL_HOOKS_SET_OBJECT_STATE(QUEUE, pxQueue, TRACE_GET_OBJECT_TRACE_CLASS(QUEUE, pxQueue) == TRACE_CLASS_MUTEX ? (uint8_t)0 : (uint8_t)(pxQueue->uxMessagesWaiting + 1));
1402 
1403 /* Called when a message is sent to a queue set */
1404 #undef traceQUEUE_SET_SEND
1405 #define traceQUEUE_SET_SEND( pxQueue ) \
1406  trcKERNEL_HOOKS_KERNEL_SERVICE(TRACE_GET_OBJECT_EVENT_CODE(SEND, TRCSUCCESS, QUEUE, pxQueue), QUEUE, pxQueue); \
1407  trcKERNEL_HOOKS_SET_OBJECT_STATE(QUEUE, pxQueue, (uint8_t)(pxQueue->uxMessagesWaiting + 1));
1408 
1409 /* Called when a message failed to be sent to a queue (timeout) */
1410 #undef traceQUEUE_SEND_FAILED
1411 #define traceQUEUE_SEND_FAILED( pxQueue ) \
1412  trcKERNEL_HOOKS_KERNEL_SERVICE(xCopyPosition == queueSEND_TO_BACK ? (TRACE_GET_OBJECT_EVENT_CODE(SEND, TRCFAILED, QUEUE, pxQueue)) : TRACE_QUEUE_SEND_TO_FRONT_TRCFAILED, QUEUE, pxQueue);
1413 
1414 /* Called when the task is blocked due to a send operation on a full queue */
1415 #undef traceBLOCKING_ON_QUEUE_SEND
1416 #define traceBLOCKING_ON_QUEUE_SEND( pxQueue ) \
1417  trcKERNEL_HOOKS_KERNEL_SERVICE(xCopyPosition == queueSEND_TO_BACK ? (TRACE_GET_OBJECT_EVENT_CODE(SEND, TRCBLOCK, QUEUE, pxQueue)) : TRACE_QUEUE_SEND_TO_FRONT_TRCBLOCK, QUEUE, pxQueue);
1418 
1419 /* Called when a message is received from a queue */
1420 #undef traceQUEUE_RECEIVE
1421 #define traceQUEUE_RECEIVE( pxQueue ) \
1422  if (isQueueReceiveHookActuallyPeek) \
1423  { \
1424  trcKERNEL_HOOKS_KERNEL_SERVICE(TRACE_GET_OBJECT_EVENT_CODE(PEEK, TRCSUCCESS, QUEUE, pxQueue), QUEUE, pxQueue); \
1425  } \
1426  else \
1427  { \
1428  trcKERNEL_HOOKS_KERNEL_SERVICE(TRACE_GET_OBJECT_EVENT_CODE(RECEIVE, TRCSUCCESS, QUEUE, pxQueue), QUEUE, pxQueue); \
1429  } \
1430  trcKERNEL_HOOKS_SET_OBJECT_STATE(QUEUE, pxQueue, TRACE_GET_OBJECT_TRACE_CLASS(QUEUE, pxQueue) == TRACE_CLASS_MUTEX ? (uint8_t)TRACE_GET_TASK_NUMBER(TRACE_GET_CURRENT_TASK()) : (uint8_t)(pxQueue->uxMessagesWaiting - 1));
1431 
1432 /* Called when a receive operation on a queue fails (timeout) */
1433 #undef traceQUEUE_RECEIVE_FAILED
1434 #define traceQUEUE_RECEIVE_FAILED( pxQueue ) \
1435  if (isQueueReceiveHookActuallyPeek) \
1436  { \
1437  trcKERNEL_HOOKS_KERNEL_SERVICE(TRACE_GET_OBJECT_EVENT_CODE(PEEK, TRCFAILED, QUEUE, pxQueue), QUEUE, pxQueue); \
1438  } \
1439  else \
1440  { \
1441  trcKERNEL_HOOKS_KERNEL_SERVICE(TRACE_GET_OBJECT_EVENT_CODE(RECEIVE, TRCFAILED, QUEUE, pxQueue), QUEUE, pxQueue); \
1442  }
1443 
1444 /* Called when the task is blocked due to a receive operation on an empty queue */
1445 #undef traceBLOCKING_ON_QUEUE_RECEIVE
1446 #define traceBLOCKING_ON_QUEUE_RECEIVE( pxQueue ) \
1447  if (isQueueReceiveHookActuallyPeek) \
1448  { \
1449  trcKERNEL_HOOKS_KERNEL_SERVICE(TRACE_GET_OBJECT_EVENT_CODE(PEEK, TRCBLOCK, QUEUE, pxQueue), QUEUE, pxQueue); \
1450  } \
1451  else \
1452  { \
1453  trcKERNEL_HOOKS_KERNEL_SERVICE(TRACE_GET_OBJECT_EVENT_CODE(RECEIVE, TRCBLOCK, QUEUE, pxQueue), QUEUE, pxQueue); \
1454  } \
1455  if (TRACE_GET_OBJECT_TRACE_CLASS(QUEUE, pxQueue) != TRACE_CLASS_MUTEX) \
1456  { \
1457  trcKERNEL_HOOKS_SET_TASK_INSTANCE_FINISHED(); \
1458  }
1459 
1460 /* Called on xQueuePeek */
1461 #undef traceQUEUE_PEEK
1462 #define traceQUEUE_PEEK( pxQueue ) \
1463  trcKERNEL_HOOKS_KERNEL_SERVICE(TRACE_GET_OBJECT_EVENT_CODE(PEEK, TRCSUCCESS, QUEUE, pxQueue), QUEUE, pxQueue);
1464 
1465 /* Called on xQueuePeek fail/timeout (added in FreeRTOS v9.0.2) */
1466 #undef traceQUEUE_PEEK_FAILED
1467 #define traceQUEUE_PEEK_FAILED( pxQueue ) \
1468  trcKERNEL_HOOKS_KERNEL_SERVICE(TRACE_GET_OBJECT_EVENT_CODE(PEEK, TRCFAILED, QUEUE, pxQueue), QUEUE, pxQueue);
1469 
1470 /* Called on xQueuePeek blocking (added in FreeRTOS v9.0.2) */
1471 #undef traceBLOCKING_ON_QUEUE_PEEK
1472 #define traceBLOCKING_ON_QUEUE_PEEK( pxQueue ) \
1473  trcKERNEL_HOOKS_KERNEL_SERVICE(TRACE_GET_OBJECT_EVENT_CODE(PEEK, TRCBLOCK, QUEUE, pxQueue), QUEUE, pxQueue); \
1474  if (TRACE_GET_OBJECT_TRACE_CLASS(QUEUE, pxQueue) != TRACE_CLASS_MUTEX) \
1475  { \
1476  trcKERNEL_HOOKS_SET_TASK_INSTANCE_FINISHED(); \
1477  }
1478 
1479 /* Called when a message is sent from interrupt context, e.g., using xQueueSendFromISR */
1480 #undef traceQUEUE_SEND_FROM_ISR
1481 #define traceQUEUE_SEND_FROM_ISR( pxQueue ) \
1482  trcKERNEL_HOOKS_KERNEL_SERVICE_FROM_ISR(xCopyPosition == queueSEND_TO_BACK ? (TRACE_GET_OBJECT_EVENT_CODE(SEND_FROM_ISR, TRCSUCCESS, QUEUE, pxQueue)) : TRACE_QUEUE_SEND_TO_FRONT_FROM_ISR_TRCSUCCESS, QUEUE, pxQueue); \
1483  trcKERNEL_HOOKS_SET_OBJECT_STATE(QUEUE, pxQueue, (uint8_t)(pxQueue->uxMessagesWaiting + 1));
1484 
1485 /* Called when a message send from interrupt context fails (since the queue was full) */
1486 #undef traceQUEUE_SEND_FROM_ISR_FAILED
1487 #define traceQUEUE_SEND_FROM_ISR_FAILED( pxQueue ) \
1488  trcKERNEL_HOOKS_KERNEL_SERVICE_FROM_ISR(xCopyPosition == queueSEND_TO_BACK ? (TRACE_GET_OBJECT_EVENT_CODE(SEND_FROM_ISR, TRCFAILED, QUEUE, pxQueue)) : TRACE_QUEUE_SEND_TO_FRONT_FROM_ISR_TRCFAILED, QUEUE, pxQueue);
1489 
1490 /* Called when a message is received in interrupt context, e.g., using xQueueReceiveFromISR */
1491 #undef traceQUEUE_RECEIVE_FROM_ISR
1492 #define traceQUEUE_RECEIVE_FROM_ISR( pxQueue ) \
1493  trcKERNEL_HOOKS_KERNEL_SERVICE_FROM_ISR(TRACE_GET_OBJECT_EVENT_CODE(RECEIVE_FROM_ISR, TRCSUCCESS, QUEUE, pxQueue), QUEUE, pxQueue); \
1494  trcKERNEL_HOOKS_SET_OBJECT_STATE(QUEUE, pxQueue, (uint8_t)(pxQueue->uxMessagesWaiting - 1));
1495 
1496 /* Called when a message receive from interrupt context fails (since the queue was empty) */
1497 #undef traceQUEUE_RECEIVE_FROM_ISR_FAILED
1498 #define traceQUEUE_RECEIVE_FROM_ISR_FAILED( pxQueue ) \
1499  trcKERNEL_HOOKS_KERNEL_SERVICE_FROM_ISR(TRACE_GET_OBJECT_EVENT_CODE(RECEIVE_FROM_ISR, TRCFAILED, QUEUE, pxQueue), QUEUE, pxQueue);
1500 
1501 #undef traceQUEUE_REGISTRY_ADD
1502 #define traceQUEUE_REGISTRY_ADD(object, name) prvTraceSetObjectName(TRACE_GET_OBJECT_TRACE_CLASS(QUEUE, object), TRACE_GET_OBJECT_NUMBER(QUEUE, object), name);
1503 
1504 /* Called in vTaskPrioritySet */
1505 #undef traceTASK_PRIORITY_SET
1506 #define traceTASK_PRIORITY_SET( pxTask, uxNewPriority ) \
1507  trcKERNEL_HOOKS_TASK_PRIORITY_CHANGE(TASK_PRIORITY_SET, pxTask, uxNewPriority);
1508 
1509 /* Called in vTaskPriorityInherit, which is called by Mutex operations */
1510 #undef traceTASK_PRIORITY_INHERIT
1511 #define traceTASK_PRIORITY_INHERIT( pxTask, uxNewPriority ) \
1512  trcKERNEL_HOOKS_TASK_PRIORITY_CHANGE(TASK_PRIORITY_INHERIT, pxTask, uxNewPriority);
1513 
1514 /* Called in vTaskPriorityDisinherit, which is called by Mutex operations */
1515 #undef traceTASK_PRIORITY_DISINHERIT
1516 #define traceTASK_PRIORITY_DISINHERIT( pxTask, uxNewPriority ) \
1517  trcKERNEL_HOOKS_TASK_PRIORITY_CHANGE(TASK_PRIORITY_DISINHERIT, pxTask, uxNewPriority);
1518 
1519 /* Called in vTaskResume */
1520 #undef traceTASK_RESUME
1521 #define traceTASK_RESUME( pxTaskToResume ) \
1522  trcKERNEL_HOOKS_TASK_RESUME(TASK_RESUME, pxTaskToResume);
1523 
1524 /* Called in vTaskResumeFromISR */
1525 #undef traceTASK_RESUME_FROM_ISR
1526 #define traceTASK_RESUME_FROM_ISR( pxTaskToResume ) \
1527  trcKERNEL_HOOKS_TASK_RESUME_FROM_ISR(TASK_RESUME_FROM_ISR, pxTaskToResume);
1528 
1529 
1530 #if (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_8_X_X)
1531 
1532 #if (TRC_CFG_INCLUDE_MEMMANG_EVENTS == 1)
1533 
1534 extern void vTraceStoreMemMangEvent(uint32_t ecode, uint32_t address, int32_t size);
1535 
1536 /* MALLOC and FREE are always stored, no matter if they happen inside filtered task */
1537 #undef traceMALLOC
1538 #define traceMALLOC( pvAddress, uiSize ) \
1539  if (pvAddress != 0) \
1540  { \
1541  vTraceStoreMemMangEvent(MEM_MALLOC_SIZE, ( uint32_t ) pvAddress, (int32_t)uiSize); \
1542  } \
1543  else \
1544  { \
1545  vTraceStoreMemMangEvent(MEM_MALLOC_SIZE_TRCFAILED, ( uint32_t ) pvAddress, (int32_t)uiSize); \
1546  }
1547 
1548 #undef traceFREE
1549 #define traceFREE( pvAddress, uiSize ) \
1550  vTraceStoreMemMangEvent(MEM_FREE_SIZE, ( uint32_t ) pvAddress, -((int32_t)uiSize));
1551 
1552 #endif
1553 
1554 #if (TRC_CFG_INCLUDE_TIMER_EVENTS == 1)
1555 
1556 /* Called in timer.c - xTimerCreate */
1557 #undef traceTIMER_CREATE
1558 #define traceTIMER_CREATE(tmr) \
1559  trcKERNEL_HOOKS_OBJECT_CREATE(TIMER_CREATE, TIMER, tmr);
1560 
1561 #undef traceTIMER_CREATE_FAILED
1562 #define traceTIMER_CREATE_FAILED() \
1563  trcKERNEL_HOOKS_OBJECT_CREATE_FAILED(TIMER_CREATE_TRCFAILED, TRACE_GET_CLASS_TRACE_CLASS(TIMER, NOT_USED))
1564 
1565 /* Note that xCommandID can never be tmrCOMMAND_EXECUTE_CALLBACK (-1) since the trace macro is not called in that case */
1566 #undef traceTIMER_COMMAND_SEND
1567 #define traceTIMER_COMMAND_SEND(tmr, xCommandID, xOptionalValue, xReturn) \
1568  if (xCommandID > tmrCOMMAND_START_DONT_TRACE) \
1569  { \
1570  if (xCommandID == tmrCOMMAND_CHANGE_PERIOD) \
1571  { \
1572  if (xReturn == pdPASS) { \
1573  trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM(TIMER_CHANGE_PERIOD, TIMER, tmr, xOptionalValue); \
1574  } \
1575  else \
1576  { \
1577  trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM(TIMER_CHANGE_PERIOD_TRCFAILED, TIMER, tmr, xOptionalValue); \
1578  } \
1579  } \
1580  else if ((xCommandID == tmrCOMMAND_DELETE) && (xReturn == pdPASS)) \
1581  { \
1582  trcKERNEL_HOOKS_OBJECT_DELETE(TIMER_DELETE_OBJ, EVENTGROUP_OBJCLOSE_NAME_TRCSUCCESS + TRACE_GET_OBJECT_TRACE_CLASS(TIMER, tmr), EVENTGROUP_OBJCLOSE_PROP_TRCSUCCESS + TRACE_GET_OBJECT_TRACE_CLASS(TIMER, tmr), TIMER, tmr); \
1583  } \
1584  else \
1585  { \
1586  trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM(EVENTGROUP_TIMER + (uint32_t)xCommandID + ((xReturn == pdPASS) ? 0 : (TIMER_CREATE_TRCFAILED - TIMER_CREATE)), TIMER, tmr, xOptionalValue); \
1587  }\
1588  }
1589 
1590 #undef traceTIMER_EXPIRED
1591 #define traceTIMER_EXPIRED(tmr) \
1592  trcKERNEL_HOOKS_KERNEL_SERVICE(TIMER_EXPIRED, TIMER, tmr);
1593 
1594 #endif
1595 
1596 #if (TRC_CFG_INCLUDE_PEND_FUNC_CALL_EVENTS == 1)
1597 
1598 #undef tracePEND_FUNC_CALL
1599 #define tracePEND_FUNC_CALL(func, arg1, arg2, ret) \
1600  if (ret == pdPASS){ \
1601  trcKERNEL_HOOKS_KERNEL_SERVICE(PEND_FUNC_CALL, TASK, xTimerGetTimerDaemonTaskHandle() ); \
1602  } \
1603  else \
1604  { \
1605  trcKERNEL_HOOKS_KERNEL_SERVICE(PEND_FUNC_CALL_TRCFAILED, TASK, xTimerGetTimerDaemonTaskHandle() ); \
1606  }
1607 
1608 #undef tracePEND_FUNC_CALL_FROM_ISR
1609 #define tracePEND_FUNC_CALL_FROM_ISR(func, arg1, arg2, ret) \
1610  if (! uiInEventGroupSetBitsFromISR) \
1611  prvTraceStoreKernelCall(PEND_FUNC_CALL_FROM_ISR, TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(xTimerGetTimerDaemonTaskHandle()) ); \
1612  uiInEventGroupSetBitsFromISR = 0;
1613 
1614 #endif
1615 
1616 #endif
1617 
1618 #if (TRC_CFG_INCLUDE_EVENT_GROUP_EVENTS == 1)
1619 
1620 #undef traceEVENT_GROUP_CREATE
1621 #define traceEVENT_GROUP_CREATE(eg) \
1622  trcKERNEL_HOOKS_OBJECT_CREATE(EVENT_GROUP_CREATE, EVENTGROUP, eg)
1623 
1624 #undef traceEVENT_GROUP_CREATE_FAILED
1625 #define traceEVENT_GROUP_CREATE_FAILED() \
1626  trcKERNEL_HOOKS_OBJECT_CREATE_FAILED(EVENT_GROUP_CREATE_TRCFAILED, TRACE_GET_CLASS_TRACE_CLASS(EVENTGROUP, NOT_USED))
1627 
1628 #undef traceEVENT_GROUP_DELETE
1629 #define traceEVENT_GROUP_DELETE(eg) \
1630  { TRACE_ALLOC_CRITICAL_SECTION(); \
1631  TRACE_ENTER_CRITICAL_SECTION(); \
1632  trcKERNEL_HOOKS_OBJECT_DELETE(EVENT_GROUP_DELETE_OBJ, EVENTGROUP_OBJCLOSE_NAME_TRCSUCCESS + TRACE_GET_OBJECT_TRACE_CLASS(EVENTGROUP, eg), EVENTGROUP_OBJCLOSE_NAME_TRCSUCCESS + TRACE_GET_OBJECT_TRACE_CLASS(EVENTGROUP, eg), EVENTGROUP, eg); \
1633  TRACE_EXIT_CRITICAL_SECTION(); }
1634 
1635 #undef traceEVENT_GROUP_SYNC_BLOCK
1636 #define traceEVENT_GROUP_SYNC_BLOCK(eg, bitsToSet, bitsToWaitFor) \
1637  trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM(EVENT_GROUP_SYNC_TRCBLOCK, EVENTGROUP, eg, bitsToWaitFor);
1638 
1639 #undef traceEVENT_GROUP_SYNC_END
1640 #define traceEVENT_GROUP_SYNC_END(eg, bitsToSet, bitsToWaitFor, wasTimeout) \
1641  if (wasTimeout) \
1642  { \
1643  trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM(EVENT_GROUP_SYNC_END_TRCFAILED, EVENTGROUP, eg, bitsToWaitFor); \
1644  } \
1645  else \
1646  { \
1647  trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM(EVENT_GROUP_SYNC_END, EVENTGROUP, eg, bitsToWaitFor); \
1648  }
1649 
1650 #undef traceEVENT_GROUP_WAIT_BITS_BLOCK
1651 #define traceEVENT_GROUP_WAIT_BITS_BLOCK(eg, bitsToWaitFor) \
1652  trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM(EVENT_GROUP_WAIT_BITS_TRCBLOCK, EVENTGROUP, eg, bitsToWaitFor); \
1653  trcKERNEL_HOOKS_SET_TASK_INSTANCE_FINISHED();
1654 
1655 #undef traceEVENT_GROUP_WAIT_BITS_END
1656 #define traceEVENT_GROUP_WAIT_BITS_END(eg, bitsToWaitFor, wasTimeout) \
1657  if (wasTimeout) \
1658  { \
1659  trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM(EVENT_GROUP_WAIT_BITS_END_TRCFAILED, EVENTGROUP, eg, bitsToWaitFor); \
1660  } \
1661  else \
1662  { \
1663  trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM(EVENT_GROUP_WAIT_BITS_END, EVENTGROUP, eg, bitsToWaitFor); \
1664  }
1665 
1666 #undef traceEVENT_GROUP_CLEAR_BITS
1667 #define traceEVENT_GROUP_CLEAR_BITS(eg, bitsToClear) \
1668  trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM(EVENT_GROUP_CLEAR_BITS, EVENTGROUP, eg, bitsToClear);
1669 
1670 #undef traceEVENT_GROUP_CLEAR_BITS_FROM_ISR
1671 #define traceEVENT_GROUP_CLEAR_BITS_FROM_ISR(eg, bitsToClear) \
1672  trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM_FROM_ISR(EVENT_GROUP_CLEAR_BITS_FROM_ISR, EVENTGROUP, eg, bitsToClear);
1673 
1674 #undef traceEVENT_GROUP_SET_BITS
1675 #define traceEVENT_GROUP_SET_BITS(eg, bitsToSet) \
1676  trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM(EVENT_GROUP_SET_BITS, EVENTGROUP, eg, bitsToSet);
1677 
1678 #undef traceEVENT_GROUP_SET_BITS_FROM_ISR
1679 #define traceEVENT_GROUP_SET_BITS_FROM_ISR(eg, bitsToSet) \
1680  trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM_FROM_ISR(EVENT_GROUP_SET_BITS_FROM_ISR, EVENTGROUP, eg, bitsToSet); \
1681  uiInEventGroupSetBitsFromISR = 1;
1682 
1683 #endif
1684 
1685 #undef traceTASK_NOTIFY_TAKE
1686 #if (TRC_CFG_FREERTOS_VERSION < TRC_FREERTOS_VERSION_9_0_0)
1687 
1688 #define traceTASK_NOTIFY_TAKE() \
1689  if (pxCurrentTCB->eNotifyState == eNotified){ \
1690  trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM(TRACE_TASK_NOTIFY_TAKE, TASK, pxCurrentTCB, xTicksToWait); \
1691  } \
1692  else{ \
1693  trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM(TRACE_TASK_NOTIFY_TAKE_TRCFAILED, TASK, pxCurrentTCB, xTicksToWait); \
1694  }
1695 
1696 #elif (TRC_CFG_FREERTOS_VERSION < TRC_FREERTOS_VERSION_10_4_0)
1697 
1698 #define traceTASK_NOTIFY_TAKE() \
1699  if (pxCurrentTCB->ucNotifyState == taskNOTIFICATION_RECEIVED){ \
1700  trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM(TRACE_TASK_NOTIFY_TAKE, TASK, pxCurrentTCB, xTicksToWait); \
1701  }else{ \
1702  trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM(TRACE_TASK_NOTIFY_TAKE_TRCFAILED, TASK, pxCurrentTCB, xTicksToWait);}
1703 
1704 #else
1705 
1706 #define traceTASK_NOTIFY_TAKE(index) \
1707  if (pxCurrentTCB->ucNotifyState[index] == taskNOTIFICATION_RECEIVED){ \
1708  trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM(TRACE_TASK_NOTIFY_TAKE, TASK, pxCurrentTCB, xTicksToWait); \
1709  }else{ \
1710  trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM(TRACE_TASK_NOTIFY_TAKE_TRCFAILED, TASK, pxCurrentTCB, xTicksToWait);}
1711 
1712 #endif
1713 
1714 #undef traceTASK_NOTIFY_TAKE_BLOCK
1715 #if (TRC_CFG_FREERTOS_VERSION < TRC_FREERTOS_VERSION_10_4_0)
1716 
1717 #define traceTASK_NOTIFY_TAKE_BLOCK() \
1718  trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM(TRACE_TASK_NOTIFY_TAKE_TRCBLOCK, TASK, pxCurrentTCB, xTicksToWait); \
1719  trcKERNEL_HOOKS_SET_TASK_INSTANCE_FINISHED();
1720 
1721 #else
1722 
1723 #define traceTASK_NOTIFY_TAKE_BLOCK(index) \
1724  trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM(TRACE_TASK_NOTIFY_TAKE_TRCBLOCK, TASK, pxCurrentTCB, xTicksToWait); \
1725  trcKERNEL_HOOKS_SET_TASK_INSTANCE_FINISHED();
1726 
1727 #endif
1728 
1729 #undef traceTASK_NOTIFY_WAIT
1730 #if (TRC_CFG_FREERTOS_VERSION < TRC_FREERTOS_VERSION_9_0_0)
1731 
1732 #define traceTASK_NOTIFY_WAIT() \
1733  if (TRACE_GET_OBJECT_FILTER(TASK, pxCurrentTCB) & CurrentFilterMask) \
1734  { \
1735  if (pxCurrentTCB->eNotifyState == eNotified) \
1736  prvTraceStoreKernelCallWithParam(TRACE_TASK_NOTIFY_WAIT, TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxCurrentTCB), xTicksToWait); \
1737  else \
1738  prvTraceStoreKernelCallWithParam(TRACE_TASK_NOTIFY_WAIT_TRCFAILED, TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxCurrentTCB), xTicksToWait); \
1739  }
1740 
1741 #elif (TRC_CFG_FREERTOS_VERSION < TRC_FREERTOS_VERSION_10_4_0)
1742 
1743 #define traceTASK_NOTIFY_WAIT() \
1744  if (TRACE_GET_OBJECT_FILTER(TASK, pxCurrentTCB) & CurrentFilterMask) \
1745  { \
1746  if (pxCurrentTCB->ucNotifyState == taskNOTIFICATION_RECEIVED) \
1747  prvTraceStoreKernelCallWithParam(TRACE_TASK_NOTIFY_WAIT, TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxCurrentTCB), xTicksToWait); \
1748  else \
1749  prvTraceStoreKernelCallWithParam(TRACE_TASK_NOTIFY_WAIT_TRCFAILED, TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxCurrentTCB), xTicksToWait); \
1750  }
1751 
1752 #else
1753 
1754 #define traceTASK_NOTIFY_WAIT(index) \
1755  if (TRACE_GET_OBJECT_FILTER(TASK, pxCurrentTCB) & CurrentFilterMask) \
1756  { \
1757  if (pxCurrentTCB->ucNotifyState[index] == taskNOTIFICATION_RECEIVED) \
1758  prvTraceStoreKernelCallWithParam(TRACE_TASK_NOTIFY_WAIT, TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxCurrentTCB), xTicksToWait); \
1759  else \
1760  prvTraceStoreKernelCallWithParam(TRACE_TASK_NOTIFY_WAIT_TRCFAILED, TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxCurrentTCB), xTicksToWait); \
1761  }
1762 
1763 #endif
1764 
1765 #undef traceTASK_NOTIFY_WAIT_BLOCK
1766 #if (TRC_CFG_FREERTOS_VERSION < TRC_FREERTOS_VERSION_10_4_0)
1767 
1768 #define traceTASK_NOTIFY_WAIT_BLOCK() \
1769  if (TRACE_GET_OBJECT_FILTER(TASK, pxCurrentTCB) & CurrentFilterMask) \
1770  prvTraceStoreKernelCallWithParam(TRACE_TASK_NOTIFY_WAIT_TRCBLOCK, TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxCurrentTCB), xTicksToWait); \
1771  trcKERNEL_HOOKS_SET_TASK_INSTANCE_FINISHED();
1772 
1773 #else
1774 
1775 #define traceTASK_NOTIFY_WAIT_BLOCK(index) \
1776  if (TRACE_GET_OBJECT_FILTER(TASK, pxCurrentTCB) & CurrentFilterMask) \
1777  prvTraceStoreKernelCallWithParam(TRACE_TASK_NOTIFY_WAIT_TRCBLOCK, TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxCurrentTCB), xTicksToWait); \
1778  trcKERNEL_HOOKS_SET_TASK_INSTANCE_FINISHED();
1779 
1780 #endif
1781 
1782 #undef traceTASK_NOTIFY
1783 #if (TRC_CFG_FREERTOS_VERSION < TRC_FREERTOS_VERSION_10_4_0)
1784 
1785 #define traceTASK_NOTIFY() \
1786  if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \
1787  if (TRACE_GET_OBJECT_FILTER(TASK, xTaskToNotify) & CurrentFilterMask) \
1788  prvTraceStoreKernelCall(TRACE_TASK_NOTIFY, TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(xTaskToNotify));
1789 
1790 #else
1791 
1792 #define traceTASK_NOTIFY(index) \
1793  if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \
1794  if (TRACE_GET_OBJECT_FILTER(TASK, xTaskToNotify) & CurrentFilterMask) \
1795  prvTraceStoreKernelCall(TRACE_TASK_NOTIFY, TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(xTaskToNotify));
1796 
1797 #endif
1798 
1799 #undef traceTASK_NOTIFY_FROM_ISR
1800 #if (TRC_CFG_FREERTOS_VERSION < TRC_FREERTOS_VERSION_10_4_0)
1801 
1802 #define traceTASK_NOTIFY_FROM_ISR() \
1803  if (TRACE_GET_OBJECT_FILTER(TASK, xTaskToNotify) & CurrentFilterMask) \
1804  prvTraceStoreKernelCall(TRACE_TASK_NOTIFY_FROM_ISR, TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(xTaskToNotify));
1805 
1806 #else
1807 
1808 #define traceTASK_NOTIFY_FROM_ISR(index) \
1809  if (TRACE_GET_OBJECT_FILTER(TASK, xTaskToNotify) & CurrentFilterMask) \
1810  prvTraceStoreKernelCall(TRACE_TASK_NOTIFY_FROM_ISR, TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(xTaskToNotify));
1811 
1812 #endif
1813 
1814 #undef traceTASK_NOTIFY_GIVE_FROM_ISR
1815 #if (TRC_CFG_FREERTOS_VERSION < TRC_FREERTOS_VERSION_10_4_0)
1816 
1817 #define traceTASK_NOTIFY_GIVE_FROM_ISR() \
1818  if (TRACE_GET_OBJECT_FILTER(TASK, xTaskToNotify) & CurrentFilterMask) \
1819  prvTraceStoreKernelCall(TRACE_TASK_NOTIFY_GIVE_FROM_ISR, TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(xTaskToNotify));
1820 
1821 #else
1822 
1823 #define traceTASK_NOTIFY_GIVE_FROM_ISR(index) \
1824  if (TRACE_GET_OBJECT_FILTER(TASK, xTaskToNotify) & CurrentFilterMask) \
1825  prvTraceStoreKernelCall(TRACE_TASK_NOTIFY_GIVE_FROM_ISR, TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(xTaskToNotify));
1826 
1827 #endif
1828 
1829 #if (TRC_CFG_INCLUDE_STREAM_BUFFER_EVENTS == 1)
1830 
1831 #undef traceSTREAM_BUFFER_CREATE
1832 #define traceSTREAM_BUFFER_CREATE( pxStreamBuffer, xIsMessageBuffer ) \
1833  trcKERNEL_HOOKS_OBJECT_CREATE(TRACE_GET_OBJECT_EVENT_CODE(CREATE_OBJ, TRCSUCCESS, STREAMBUFFER, pxStreamBuffer), STREAMBUFFER, pxStreamBuffer);
1834 
1835 #undef traceSTREAM_BUFFER_CREATE_FAILED
1836 #define traceSTREAM_BUFFER_CREATE_FAILED( xIsMessageBuffer ) \
1837  trcKERNEL_HOOKS_OBJECT_CREATE_FAILED(TRACE_GET_CLASS_EVENT_CODE(CREATE_OBJ, TRCFAILED, STREAMBUFFER, xIsMessageBuffer), TRACE_GET_CLASS_TRACE_CLASS(STREAMBUFFER, xIsMessageBuffer))
1838 
1839 #undef traceSTREAM_BUFFER_CREATE_STATIC_FAILED
1840 #define traceSTREAM_BUFFER_CREATE_STATIC_FAILED( xReturn, xIsMessageBuffer ) \
1841  traceSTREAM_BUFFER_CREATE_FAILED( xIsMessageBuffer )
1842 
1843 #undef traceSTREAM_BUFFER_DELETE
1844 #define traceSTREAM_BUFFER_DELETE( xStreamBuffer ) \
1845  trcKERNEL_HOOKS_OBJECT_DELETE(TRACE_GET_OBJECT_EVENT_CODE(DELETE_OBJ, TRCSUCCESS, STREAMBUFFER, xStreamBuffer), TRACE_GET_OBJECT_EVENT_CODE(OBJCLOSE_NAME, TRCSUCCESS, STREAMBUFFER, xStreamBuffer), TRACE_GET_OBJECT_EVENT_CODE(OBJCLOSE_PROP, TRCSUCCESS, STREAMBUFFER, xStreamBuffer), STREAMBUFFER, xStreamBuffer);
1846 
1847 #undef traceSTREAM_BUFFER_RESET
1848 #define traceSTREAM_BUFFER_RESET( xStreamBuffer ) \
1849  trcKERNEL_HOOKS_KERNEL_SERVICE(prvGetStreamBufferType(xStreamBuffer) > 0 ? TRACE_MESSAGEBUFFER_RESET : TRACE_STREAMBUFFER_RESET, STREAMBUFFER, xStreamBuffer); \
1850  trcKERNEL_HOOKS_SET_OBJECT_STATE(STREAMBUFFER, xStreamBuffer, 0);
1851 
1852 #undef traceSTREAM_BUFFER_SEND
1853 #define traceSTREAM_BUFFER_SEND( xStreamBuffer, xReturn ) \
1854  trcKERNEL_HOOKS_KERNEL_SERVICE(TRACE_GET_OBJECT_EVENT_CODE(SEND, TRCSUCCESS, STREAMBUFFER, xStreamBuffer), STREAMBUFFER, xStreamBuffer); \
1855  trcKERNEL_HOOKS_SET_OBJECT_STATE(STREAMBUFFER, xStreamBuffer, prvBytesInBuffer(xStreamBuffer));
1856 
1857 #undef traceBLOCKING_ON_STREAM_BUFFER_SEND
1858 #define traceBLOCKING_ON_STREAM_BUFFER_SEND( xStreamBuffer ) \
1859  trcKERNEL_HOOKS_KERNEL_SERVICE(TRACE_GET_OBJECT_EVENT_CODE(SEND, TRCBLOCK, STREAMBUFFER, xStreamBuffer), STREAMBUFFER, xStreamBuffer);
1860 
1861 #undef traceSTREAM_BUFFER_SEND_FAILED
1862 #define traceSTREAM_BUFFER_SEND_FAILED( xStreamBuffer ) \
1863  trcKERNEL_HOOKS_KERNEL_SERVICE(TRACE_GET_OBJECT_EVENT_CODE(SEND, TRCFAILED, STREAMBUFFER, xStreamBuffer), STREAMBUFFER, xStreamBuffer);
1864 
1865 #undef traceSTREAM_BUFFER_RECEIVE
1866 #define traceSTREAM_BUFFER_RECEIVE( xStreamBuffer, xReceivedLength ) \
1867  trcKERNEL_HOOKS_KERNEL_SERVICE(TRACE_GET_OBJECT_EVENT_CODE(RECEIVE, TRCSUCCESS, STREAMBUFFER, xStreamBuffer), STREAMBUFFER, xStreamBuffer); \
1868  trcKERNEL_HOOKS_SET_OBJECT_STATE(STREAMBUFFER, xStreamBuffer, prvBytesInBuffer(xStreamBuffer));
1869 
1870 
1871 #undef traceBLOCKING_ON_STREAM_BUFFER_RECEIVE
1872 #define traceBLOCKING_ON_STREAM_BUFFER_RECEIVE( xStreamBuffer ) \
1873  trcKERNEL_HOOKS_KERNEL_SERVICE(TRACE_GET_OBJECT_EVENT_CODE(RECEIVE, TRCBLOCK, STREAMBUFFER, xStreamBuffer), STREAMBUFFER, xStreamBuffer);
1874 
1875 #undef traceSTREAM_BUFFER_RECEIVE_FAILED
1876 #define traceSTREAM_BUFFER_RECEIVE_FAILED( xStreamBuffer ) \
1877  trcKERNEL_HOOKS_KERNEL_SERVICE(TRACE_GET_OBJECT_EVENT_CODE(RECEIVE, TRCFAILED, STREAMBUFFER, xStreamBuffer), STREAMBUFFER, xStreamBuffer);
1878 
1879 #undef traceSTREAM_BUFFER_SEND_FROM_ISR
1880 #define traceSTREAM_BUFFER_SEND_FROM_ISR( xStreamBuffer, xReturn ) \
1881  if( xReturn > ( size_t ) 0 ) \
1882  { \
1883  trcKERNEL_HOOKS_KERNEL_SERVICE_FROM_ISR(TRACE_GET_OBJECT_EVENT_CODE(SEND_FROM_ISR, TRCSUCCESS, STREAMBUFFER, xStreamBuffer), STREAMBUFFER, xStreamBuffer); \
1884  trcKERNEL_HOOKS_SET_OBJECT_STATE(STREAMBUFFER, xStreamBuffer, prvBytesInBuffer(xStreamBuffer)); \
1885  } \
1886  else \
1887  { \
1888  trcKERNEL_HOOKS_KERNEL_SERVICE_FROM_ISR(TRACE_GET_OBJECT_EVENT_CODE(SEND_FROM_ISR, TRCFAILED, STREAMBUFFER, xStreamBuffer), STREAMBUFFER, xStreamBuffer); \
1889  }
1890 
1891 #undef traceSTREAM_BUFFER_RECEIVE_FROM_ISR
1892 #define traceSTREAM_BUFFER_RECEIVE_FROM_ISR( xStreamBuffer, xReceivedLength ) \
1893  if( xReceivedLength > ( size_t ) 0 ) \
1894  { \
1895  trcKERNEL_HOOKS_KERNEL_SERVICE_FROM_ISR(TRACE_GET_OBJECT_EVENT_CODE(RECEIVE_FROM_ISR, TRCSUCCESS, STREAMBUFFER, xStreamBuffer), STREAMBUFFER, xStreamBuffer); \
1896  trcKERNEL_HOOKS_SET_OBJECT_STATE(STREAMBUFFER, xStreamBuffer, prvBytesInBuffer(xStreamBuffer)); \
1897  } \
1898  else \
1899  { \
1900  trcKERNEL_HOOKS_KERNEL_SERVICE_FROM_ISR(TRACE_GET_OBJECT_EVENT_CODE(RECEIVE_FROM_ISR, TRCFAILED, STREAMBUFFER, xStreamBuffer), STREAMBUFFER, xStreamBuffer); \
1901  }
1902 
1903 #endif
1904 
1905 #endif
1906 
1907 #endif
1908 
1909 #if (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING)
1910 
1911 TraceHeapHandle_t xTraceKernelPortGetSystemHeapHandle(void);
1912 
1913 /*************************************************************************/
1914 /* KERNEL SPECIFIC OBJECT CONFIGURATION */
1915 /*************************************************************************/
1916 
1917 /*******************************************************************************
1918  * The event codes - should match the offline config file.
1919  ******************************************************************************/
1920 
1921 /*** Event codes for streaming - should match the Tracealyzer config file *****/
1922 #define PSF_EVENT_NULL_EVENT 0x00
1923 
1924 #define PSF_EVENT_TRACE_START 0x01
1925 #define PSF_EVENT_TS_CONFIG 0x02
1926 #define PSF_EVENT_OBJ_NAME 0x03
1927 #define PSF_EVENT_TASK_PRIORITY 0x04
1928 #define PSF_EVENT_TASK_PRIO_INHERIT 0x05
1929 #define PSF_EVENT_TASK_PRIO_DISINHERIT 0x06
1930 #define PSF_EVENT_DEFINE_ISR 0x07
1931 
1932 #define PSF_EVENT_TASK_CREATE 0x10
1933 #define PSF_EVENT_QUEUE_CREATE 0x11
1934 #define PSF_EVENT_SEMAPHORE_BINARY_CREATE 0x12
1935 #define PSF_EVENT_MUTEX_CREATE 0x13
1936 #define PSF_EVENT_TIMER_CREATE 0x14
1937 #define PSF_EVENT_EVENTGROUP_CREATE 0x15
1938 #define PSF_EVENT_SEMAPHORE_COUNTING_CREATE 0x16
1939 #define PSF_EVENT_MUTEX_RECURSIVE_CREATE 0x17
1940 #define PSF_EVENT_STREAMBUFFER_CREATE 0x18
1941 #define PSF_EVENT_MESSAGEBUFFER_CREATE 0x19
1942 
1943 #define PSF_EVENT_TASK_DELETE 0x20
1944 #define PSF_EVENT_QUEUE_DELETE 0x21
1945 #define PSF_EVENT_SEMAPHORE_DELETE 0x22
1946 #define PSF_EVENT_MUTEX_DELETE 0x23
1947 #define PSF_EVENT_TIMER_DELETE 0x24
1948 #define PSF_EVENT_EVENTGROUP_DELETE 0x25
1949 #define PSF_EVENT_STREAMBUFFER_DELETE 0x28
1950 #define PSF_EVENT_MESSAGEBUFFER_DELETE 0x29
1951 
1952 #define PSF_EVENT_TASK_READY 0x30
1953 #define PSF_EVENT_NEW_TIME 0x31
1954 #define PSF_EVENT_NEW_TIME_SCHEDULER_SUSPENDED 0x32
1955 #define PSF_EVENT_ISR_BEGIN 0x33
1956 #define PSF_EVENT_ISR_RESUME 0x34
1957 #define PSF_EVENT_TS_BEGIN 0x35
1958 #define PSF_EVENT_TS_RESUME 0x36
1959 #define PSF_EVENT_TASK_ACTIVATE 0x37
1960 
1961 #define PSF_EVENT_MALLOC 0x38
1962 #define PSF_EVENT_FREE 0x39
1963 
1964 #define PSF_EVENT_LOWPOWER_BEGIN 0x3A
1965 #define PSF_EVENT_LOWPOWER_END 0x3B
1966 
1967 #define PSF_EVENT_IFE_NEXT 0x3C
1968 #define PSF_EVENT_IFE_DIRECT 0x3D
1969 
1970 #define PSF_EVENT_TASK_CREATE_FAILED 0x40
1971 #define PSF_EVENT_QUEUE_CREATE_FAILED 0x41
1972 #define PSF_EVENT_SEMAPHORE_BINARY_CREATE_FAILED 0x42
1973 #define PSF_EVENT_MUTEX_CREATE_FAILED 0x43
1974 #define PSF_EVENT_TIMER_CREATE_FAILED 0x44
1975 #define PSF_EVENT_EVENTGROUP_CREATE_FAILED 0x45
1976 #define PSF_EVENT_SEMAPHORE_COUNTING_CREATE_FAILED 0x46
1977 #define PSF_EVENT_MUTEX_RECURSIVE_CREATE_FAILED 0x47
1978 #define PSF_EVENT_STREAMBUFFER_CREATE_FAILED 0x49
1979 #define PSF_EVENT_MESSAGEBUFFER_CREATE_FAILED 0x4A
1980 
1981 #define PSF_EVENT_TIMER_DELETE_FAILED 0x48
1982 
1983 #define PSF_EVENT_QUEUE_SEND 0x50
1984 #define PSF_EVENT_SEMAPHORE_GIVE 0x51
1985 #define PSF_EVENT_MUTEX_GIVE 0x52
1986 
1987 #define PSF_EVENT_QUEUE_SEND_FAILED 0x53
1988 #define PSF_EVENT_SEMAPHORE_GIVE_FAILED 0x54
1989 #define PSF_EVENT_MUTEX_GIVE_FAILED 0x55
1990 
1991 #define PSF_EVENT_QUEUE_SEND_BLOCK 0x56
1992 #define PSF_EVENT_SEMAPHORE_GIVE_BLOCK 0x57
1993 #define PSF_EVENT_MUTEX_GIVE_BLOCK 0x58
1994 
1995 #define PSF_EVENT_QUEUE_SEND_FROMISR 0x59
1996 #define PSF_EVENT_SEMAPHORE_GIVE_FROMISR 0x5A
1997 
1998 #define PSF_EVENT_QUEUE_SEND_FROMISR_FAILED 0x5C
1999 #define PSF_EVENT_SEMAPHORE_GIVE_FROMISR_FAILED 0x5D
2000 
2001 #define PSF_EVENT_QUEUE_RECEIVE 0x60
2002 #define PSF_EVENT_SEMAPHORE_TAKE 0x61
2003 #define PSF_EVENT_MUTEX_TAKE 0x62
2004 
2005 #define PSF_EVENT_QUEUE_RECEIVE_FAILED 0x63
2006 #define PSF_EVENT_SEMAPHORE_TAKE_FAILED 0x64
2007 #define PSF_EVENT_MUTEX_TAKE_FAILED 0x65
2008 
2009 #define PSF_EVENT_QUEUE_RECEIVE_BLOCK 0x66
2010 #define PSF_EVENT_SEMAPHORE_TAKE_BLOCK 0x67
2011 #define PSF_EVENT_MUTEX_TAKE_BLOCK 0x68
2012 
2013 #define PSF_EVENT_QUEUE_RECEIVE_FROMISR 0x69
2014 #define PSF_EVENT_SEMAPHORE_TAKE_FROMISR 0x6A
2015 
2016 #define PSF_EVENT_QUEUE_RECEIVE_FROMISR_FAILED 0x6C
2017 #define PSF_EVENT_SEMAPHORE_TAKE_FROMISR_FAILED 0x6D
2018 
2019 #define PSF_EVENT_QUEUE_PEEK 0x70
2020 #define PSF_EVENT_SEMAPHORE_PEEK 0x71
2021 #define PSF_EVENT_MUTEX_PEEK 0x72
2022 
2023 #define PSF_EVENT_QUEUE_PEEK_FAILED 0x73
2024 #define PSF_EVENT_SEMAPHORE_PEEK_FAILED 0x74
2025 #define PSF_EVENT_MUTEX_PEEK_FAILED 0x75
2026 
2027 #define PSF_EVENT_QUEUE_PEEK_BLOCK 0x76
2028 #define PSF_EVENT_SEMAPHORE_PEEK_BLOCK 0x77
2029 #define PSF_EVENT_MUTEX_PEEK_BLOCK 0x78
2030 
2031 #define PSF_EVENT_TASK_DELAY_UNTIL 0x79
2032 #define PSF_EVENT_TASK_DELAY 0x7A
2033 #define PSF_EVENT_TASK_SUSPEND 0x7B
2034 #define PSF_EVENT_TASK_RESUME 0x7C
2035 #define PSF_EVENT_TASK_RESUME_FROMISR 0x7D
2036 
2037 #define PSF_EVENT_TIMER_PENDFUNCCALL 0x80
2038 #define PSF_EVENT_TIMER_PENDFUNCCALL_FROMISR 0x81
2039 #define PSF_EVENT_TIMER_PENDFUNCCALL_FAILED 0x82
2040 #define PSF_EVENT_TIMER_PENDFUNCCALL_FROMISR_FAILED 0x83
2041 
2042 #define PSF_EVENT_USER_EVENT 0x90
2043 
2044 #define PSF_EVENT_TIMER_START 0xA0
2045 #define PSF_EVENT_TIMER_RESET 0xA1
2046 #define PSF_EVENT_TIMER_STOP 0xA2
2047 #define PSF_EVENT_TIMER_CHANGEPERIOD 0xA3
2048 #define PSF_EVENT_TIMER_START_FROMISR 0xA4
2049 #define PSF_EVENT_TIMER_RESET_FROMISR 0xA5
2050 #define PSF_EVENT_TIMER_STOP_FROMISR 0xA6
2051 #define PSF_EVENT_TIMER_CHANGEPERIOD_FROMISR 0xA7
2052 #define PSF_EVENT_TIMER_START_FAILED 0xA8
2053 #define PSF_EVENT_TIMER_RESET_FAILED 0xA9
2054 #define PSF_EVENT_TIMER_STOP_FAILED 0xAA
2055 #define PSF_EVENT_TIMER_CHANGEPERIOD_FAILED 0xAB
2056 #define PSF_EVENT_TIMER_START_FROMISR_FAILED 0xAC
2057 #define PSF_EVENT_TIMER_RESET_FROMISR_FAILED 0xAD
2058 #define PSF_EVENT_TIMER_STOP_FROMISR_FAILED 0xAE
2059 #define PSF_EVENT_TIMER_CHANGEPERIOD_FROMISR_FAILED 0xAF
2060 
2061 #define PSF_EVENT_EVENTGROUP_SYNC 0xB0
2062 #define PSF_EVENT_EVENTGROUP_WAITBITS 0xB1
2063 #define PSF_EVENT_EVENTGROUP_CLEARBITS 0xB2
2064 #define PSF_EVENT_EVENTGROUP_CLEARBITS_FROMISR 0xB3
2065 #define PSF_EVENT_EVENTGROUP_SETBITS 0xB4
2066 #define PSF_EVENT_EVENTGROUP_SETBITS_FROMISR 0xB5
2067 #define PSF_EVENT_EVENTGROUP_SYNC_BLOCK 0xB6
2068 #define PSF_EVENT_EVENTGROUP_WAITBITS_BLOCK 0xB7
2069 #define PSF_EVENT_EVENTGROUP_SYNC_FAILED 0xB8
2070 #define PSF_EVENT_EVENTGROUP_WAITBITS_FAILED 0xB9
2071 
2072 #define PSF_EVENT_QUEUE_SEND_FRONT 0xC0
2073 #define PSF_EVENT_QUEUE_SEND_FRONT_FAILED 0xC1
2074 #define PSF_EVENT_QUEUE_SEND_FRONT_BLOCK 0xC2
2075 #define PSF_EVENT_QUEUE_SEND_FRONT_FROMISR 0xC3
2076 #define PSF_EVENT_QUEUE_SEND_FRONT_FROMISR_FAILED 0xC4
2077 #define PSF_EVENT_MUTEX_GIVE_RECURSIVE 0xC5
2078 #define PSF_EVENT_MUTEX_GIVE_RECURSIVE_FAILED 0xC6
2079 #define PSF_EVENT_MUTEX_TAKE_RECURSIVE 0xC7
2080 #define PSF_EVENT_MUTEX_TAKE_RECURSIVE_FAILED 0xC8
2081 
2082 #define PSF_EVENT_TASK_NOTIFY 0xC9
2083 #define PSF_EVENT_TASK_NOTIFY_WAIT 0xCA
2084 #define PSF_EVENT_TASK_NOTIFY_WAIT_BLOCK 0xCB
2085 #define PSF_EVENT_TASK_NOTIFY_WAIT_FAILED 0xCC
2086 #define PSF_EVENT_TASK_NOTIFY_FROM_ISR 0xCD
2087 
2088 #define PSF_EVENT_TIMER_EXPIRED 0xD2
2089 
2090 #define PSF_EVENT_STREAMBUFFER_SEND 0xD3
2091 #define PSF_EVENT_STREAMBUFFER_SEND_BLOCK 0xD4
2092 #define PSF_EVENT_STREAMBUFFER_SEND_FAILED 0xD5
2093 #define PSF_EVENT_STREAMBUFFER_RECEIVE 0xD6
2094 #define PSF_EVENT_STREAMBUFFER_RECEIVE_BLOCK 0xD7
2095 #define PSF_EVENT_STREAMBUFFER_RECEIVE_FAILED 0xD8
2096 #define PSF_EVENT_STREAMBUFFER_SEND_FROM_ISR 0xD9
2097 #define PSF_EVENT_STREAMBUFFER_SEND_FROM_ISR_FAILED 0xDA
2098 #define PSF_EVENT_STREAMBUFFER_RECEIVE_FROM_ISR 0xDB
2099 #define PSF_EVENT_STREAMBUFFER_RECEIVE_FROM_ISR_FAILED 0xDC
2100 #define PSF_EVENT_STREAMBUFFER_RESET 0xDD
2101 
2102 #define PSF_EVENT_MESSAGEBUFFER_SEND 0xDE
2103 #define PSF_EVENT_MESSAGEBUFFER_SEND_BLOCK 0xDF
2104 #define PSF_EVENT_MESSAGEBUFFER_SEND_FAILED 0xE0
2105 #define PSF_EVENT_MESSAGEBUFFER_RECEIVE 0xE1
2106 #define PSF_EVENT_MESSAGEBUFFER_RECEIVE_BLOCK 0xE2
2107 #define PSF_EVENT_MESSAGEBUFFER_RECEIVE_FAILED 0xE3
2108 #define PSF_EVENT_MESSAGEBUFFER_SEND_FROM_ISR 0xE4
2109 #define PSF_EVENT_MESSAGEBUFFER_SEND_FROM_ISR_FAILED 0xE5
2110 #define PSF_EVENT_MESSAGEBUFFER_RECEIVE_FROM_ISR 0xE6
2111 #define PSF_EVENT_MESSAGEBUFFER_RECEIVE_FROM_ISR_FAILED 0xE7
2112 #define PSF_EVENT_MESSAGEBUFFER_RESET 0xE8
2113 
2114 #define PSF_EVENT_MALLOC_FAILED 0xE9
2115 #define PSF_EVENT_FREE_FAILED 0xEA
2116 
2117 #define PSF_EVENT_UNUSED_STACK 0xEB
2118 
2119 #define PSF_EVENT_STATEMACHINE_STATE_CREATE 0xEC
2120 #define PSF_EVENT_STATEMACHINE_CREATE 0xED
2121 #define PSF_EVENT_STATEMACHINE_STATECHANGE 0xEE
2122 
2123 #define PSF_EVENT_INTERVAL_CHANNEL_CREATE 0xEF
2124 #define PSF_EVENT_INTERVAL_START 0xF0
2125 
2126 #define PSF_EVENT_EXTENSION_CREATE 0xF1
2127 
2128 #define PSF_EVENT_HEAP_CREATE 0xF2
2129 
2130 #define PSF_EVENT_COUNTER_CREATE 0xF3
2131 #define PSF_EVENT_COUNTER_CHANGE 0xF4
2132 #define PSF_EVENT_COUNTER_LIMIT_EXCEEDED 0xF5
2133 
2134 #define PSF_EVENT_MUTEX_TAKE_RECURSIVE_BLOCK 0xF6
2135 
2136 #define PSF_EVENT_INTERVAL_STOP 0xF7
2137 #define PSF_EVENT_INTERVAL_CHANNEL_SET_CREATE 0xF8
2138 
2139 #define TRC_EVENT_LAST_ID PSF_EVENT_INTERVAL_CHANNEL_SET_CREATE
2140 
2141 /*** The trace macros for streaming ******************************************/
2142 
2143 /* A macro that will update the tick count when returning from tickless idle */
2144 #undef traceINCREASE_TICK_COUNT
2145 /* Note: This can handle time adjustments of max 2^32 ticks, i.e., 35 seconds at 120 MHz. Thus, tick-less idle periods longer than 2^32 ticks will appear "compressed" on the time line.*/
2146 #define traceINCREASE_TICK_COUNT( xCount ) { uint32_t uiTraceTickCount; xTraceTimestampGetOsTickCount(&uiTraceTickCount); xTraceTimestampSetOsTickCount(uiTraceTickCount + (xCount)); }
2147 
2148 #if (TRC_CFG_INCLUDE_OSTICK_EVENTS == 1)
2149 
2150 #define OS_TICK_EVENT(uxSchedulerSuspended, xTickCount) if ((uxSchedulerSuspended) == (unsigned portBASE_TYPE) pdFALSE) { prvTraceStoreEvent_Param(PSF_EVENT_NEW_TIME, (uint32_t)(xTickCount)); }
2151 
2152 #else
2153 
2154 #define OS_TICK_EVENT(uxSchedulerSuspended, xTickCount)
2155 
2156 #endif
2157 
2158 /* Called on each OS tick. Will call uiPortGetTimestamp to make sure it is called at least once every OS tick. */
2159 #undef traceTASK_INCREMENT_TICK
2160 #if TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_3_0
2161 
2162 #define traceTASK_INCREMENT_TICK( xTickCount ) \
2163  if (uxSchedulerSuspended == ( unsigned portBASE_TYPE ) pdTRUE || xPendedTicks == 0) { xTraceTimestampSetOsTickCount((xTickCount) + 1); } \
2164  OS_TICK_EVENT(uxSchedulerSuspended, (xTickCount) + 1)
2165 
2166 #elif TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_7_5_X
2167 
2168 #define traceTASK_INCREMENT_TICK( xTickCount ) \
2169  if (uxSchedulerSuspended == ( unsigned portBASE_TYPE ) pdTRUE || uxPendedTicks == 0) { xTraceTimestampSetOsTickCount(xTickCount + 1); } \
2170  OS_TICK_EVENT(uxSchedulerSuspended, xTickCount + 1)
2171 
2172 #else
2173 
2174 #define traceTASK_INCREMENT_TICK( xTickCount ) \
2175  if (uxSchedulerSuspended == ( unsigned portBASE_TYPE ) pdTRUE || uxMissedTicks == 0) { xTraceTimestampSetOsTickCount(xTickCount + 1); } \
2176  OS_TICK_EVENT(uxSchedulerSuspended, xTickCount + 1)
2177 
2178 #endif
2179 
2180 /* Called on each task-switch */
2181 #undef traceTASK_SWITCHED_IN
2182 #define traceTASK_SWITCHED_IN() \
2183  xTraceTaskSwitch(pxCurrentTCB, pxCurrentTCB->uxPriority)
2184 
2185 /* Called for each task that becomes ready */
2186 #undef traceMOVED_TASK_TO_READY_STATE
2187 #define traceMOVED_TASK_TO_READY_STATE( pxTCB ) \
2188  xTraceTaskReady(pxTCB)
2189 
2190 #undef traceTASK_CREATE
2191 #if TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_9_0_0
2192 
2193 #define traceTASK_CREATE(pxNewTCB) \
2194  if ((pxNewTCB) != 0) \
2195  { \
2196  xTraceTaskRegisterWithoutHandle((void*)(pxNewTCB), (pxNewTCB)->pcTaskName, (pxNewTCB)->uxPriority); \
2197  }
2198 
2199 #else
2200 
2201 #define traceTASK_CREATE(pxNewTCB) \
2202  if (pxNewTCB != 0) \
2203  { \
2204  xTraceTaskRegisterWithoutHandle((void*)pxNewTCB, (const char*)pcName, (uint32_t)uxPriority); \
2205  }
2206 
2207 #endif
2208 
2209 /* Called in vTaskCreate, if it fails (typically if the stack can not be allocated) */
2210 #undef traceTASK_CREATE_FAILED
2211 #define traceTASK_CREATE_FAILED() \
2212  prvTraceStoreEvent_None(PSF_EVENT_TASK_CREATE_FAILED)
2213 
2214 /* Called on vTaskDelete */
2215 #undef traceTASK_DELETE // We don't allow for filtering out "delete" events. They are important and not very frequent. Moreover, we can't exclude create events, so this should be symmetrical.
2216 #define traceTASK_DELETE( pxTaskToDelete ) \
2217  xTraceTaskUnregisterWithoutHandle(pxTaskToDelete, (pxTaskToDelete)->uxPriority)
2218 
2219 #if (TRC_CFG_SCHEDULING_ONLY == 0)
2220 
2221 #if (defined(configUSE_TICKLESS_IDLE) && configUSE_TICKLESS_IDLE != 0)
2222 
2223 #undef traceLOW_POWER_IDLE_BEGIN
2224 #define traceLOW_POWER_IDLE_BEGIN() \
2225  prvTraceStoreEvent_Param(PSF_EVENT_LOWPOWER_BEGIN, xExpectedIdleTime)
2226 
2227 #undef traceLOW_POWER_IDLE_END
2228 #define traceLOW_POWER_IDLE_END() \
2229  prvTraceStoreEvent_None(PSF_EVENT_LOWPOWER_END)
2230 
2231 #endif
2232 
2233 /* Called on vTaskSuspend */
2234 #undef traceTASK_SUSPEND
2235 #define traceTASK_SUSPEND( pxTaskToSuspend ) \
2236  prvTraceStoreEvent_Handle(PSF_EVENT_TASK_SUSPEND, pxTaskToSuspend)
2237 
2238 /* Called on vTaskDelay - note the use of FreeRTOS variable xTicksToDelay */
2239 #undef traceTASK_DELAY
2240 #define traceTASK_DELAY() \
2241  prvTraceStoreEvent_Param(PSF_EVENT_TASK_DELAY, xTicksToDelay)
2242 
2243 /* Called on vTaskDelayUntil - note the use of FreeRTOS variable xTimeToWake */
2244 #undef traceTASK_DELAY_UNTIL
2245 #if TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_9_0_0
2246 
2247 #define traceTASK_DELAY_UNTIL(xTimeToWake) \
2248  prvTraceStoreEvent_Param(PSF_EVENT_TASK_DELAY_UNTIL, (xTimeToWake))
2249 
2250 #else
2251 
2252 #define traceTASK_DELAY_UNTIL() \
2253  prvTraceStoreEvent_Param(PSF_EVENT_TASK_DELAY_UNTIL, xTimeToWake)
2254 
2255 #endif
2256 
2257 #if (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_9_0_0)
2258 
2259 #define traceQUEUE_CREATE_HELPER() \
2260  case queueQUEUE_TYPE_MUTEX: \
2261  xTraceObjectRegisterWithoutHandle(PSF_EVENT_MUTEX_CREATE, (void*)pxNewQueue, "", 0); \
2262  break; \
2263  case queueQUEUE_TYPE_RECURSIVE_MUTEX: \
2264  xTraceObjectRegisterWithoutHandle(PSF_EVENT_MUTEX_RECURSIVE_CREATE, (void*)pxNewQueue, "", 0); \
2265  break;
2266 
2267 #else
2268 
2269 #define traceQUEUE_CREATE_HELPER()
2270 
2271 #endif
2272 
2273 /* Called in xQueueCreate, and thereby for all other object based on queues, such as semaphores. */
2274 #undef traceQUEUE_CREATE
2275 #define traceQUEUE_CREATE( pxNewQueue )\
2276  switch ((pxNewQueue)->ucQueueType) \
2277  { \
2278  case queueQUEUE_TYPE_BASE: \
2279  xTraceObjectRegisterWithoutHandle(PSF_EVENT_QUEUE_CREATE, (void*)(pxNewQueue), "", (uint32_t)uxQueueLength); \
2280  break; \
2281  case queueQUEUE_TYPE_BINARY_SEMAPHORE: \
2282  xTraceObjectRegisterWithoutHandle(PSF_EVENT_SEMAPHORE_BINARY_CREATE, (void*)(pxNewQueue), "", 0); \
2283  break; \
2284  traceQUEUE_CREATE_HELPER() \
2285  }
2286 
2287 #if (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_9_0_0)
2288 
2289 #define traceQUEUE_CREATE_FAILED_HELPER() \
2290  case queueQUEUE_TYPE_MUTEX: \
2291  prvTraceStoreEvent_HandleParam(PSF_EVENT_MUTEX_CREATE_FAILED, 0, 0); \
2292  break; \
2293  case queueQUEUE_TYPE_RECURSIVE_MUTEX: \
2294  prvTraceStoreEvent_HandleParam(PSF_EVENT_MUTEX_RECURSIVE_CREATE_FAILED, 0, 0); \
2295  break;
2296 
2297 #else
2298 
2299 #define traceQUEUE_CREATE_FAILED_HELPER()
2300 
2301 #endif
2302 
2303 /* Called in xQueueCreate, if the queue creation fails */
2304 #undef traceQUEUE_CREATE_FAILED
2305 #define traceQUEUE_CREATE_FAILED( queueType ) \
2306  switch (queueType) \
2307  { \
2308  case queueQUEUE_TYPE_BASE: \
2309  prvTraceStoreEvent_HandleParam(PSF_EVENT_QUEUE_CREATE_FAILED, 0, uxQueueLength); \
2310  break; \
2311  case queueQUEUE_TYPE_BINARY_SEMAPHORE: \
2312  prvTraceStoreEvent_HandleParam(PSF_EVENT_SEMAPHORE_BINARY_CREATE_FAILED, 0, 0); \
2313  break; \
2314  traceQUEUE_CREATE_FAILED_HELPER() \
2315  }
2316 
2317 #undef traceQUEUE_DELETE // We don't allow for filtering out "delete" events. They are important and not very frequent. Moreover, we can't exclude create events, so this should be symmetrical.
2318 #define traceQUEUE_DELETE( pxQueue ) \
2319  switch ((pxQueue)->ucQueueType) \
2320  { \
2321  case queueQUEUE_TYPE_BASE: \
2322  xTraceObjectUnregisterWithoutHandle(PSF_EVENT_QUEUE_DELETE, (void*)(pxQueue), (pxQueue)->uxMessagesWaiting); \
2323  break; \
2324  case queueQUEUE_TYPE_MUTEX: \
2325  case queueQUEUE_TYPE_RECURSIVE_MUTEX: \
2326  xTraceObjectUnregisterWithoutHandle(PSF_EVENT_MUTEX_DELETE, (void*)(pxQueue), (pxQueue)->uxMessagesWaiting); \
2327  break; \
2328  case queueQUEUE_TYPE_COUNTING_SEMAPHORE: \
2329  case queueQUEUE_TYPE_BINARY_SEMAPHORE: \
2330  xTraceObjectUnregisterWithoutHandle(PSF_EVENT_SEMAPHORE_DELETE, (void*)(pxQueue), (pxQueue)->uxMessagesWaiting); \
2331  break; \
2332  }
2333 
2334 /* Called in xQueueCreateCountingSemaphore, if the queue creation fails */
2335 #undef traceCREATE_COUNTING_SEMAPHORE
2336 #if (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_8_X_X)
2337 
2338 #define traceCREATE_COUNTING_SEMAPHORE() \
2339  xTraceObjectRegisterWithoutHandle(PSF_EVENT_SEMAPHORE_COUNTING_CREATE, (void*)xHandle, "", (uint32_t)uxMaxCount)
2340 
2341 #elif (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_7_5_X)
2342 
2343 #define traceCREATE_COUNTING_SEMAPHORE() \
2344  xTraceObjectRegisterWithoutHandle(PSF_EVENT_SEMAPHORE_COUNTING_CREATE, (void*)xHandle, "", uxInitialCount)
2345 
2346 #elif (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_7_4_X)
2347 
2348 #define traceCREATE_COUNTING_SEMAPHORE() \
2349  xTraceObjectRegisterWithoutHandle(PSF_EVENT_SEMAPHORE_COUNTING_CREATE, (void*)xHandle, "", uxCountValue)
2350 
2351 #else
2352 
2353 #define traceCREATE_COUNTING_SEMAPHORE() \
2354  xTraceObjectRegisterWithoutHandle(PSF_EVENT_SEMAPHORE_COUNTING_CREATE, (void*)pxHandle, "", uxCountValue)
2355 
2356 #endif
2357 
2358 #undef traceCREATE_COUNTING_SEMAPHORE_FAILED
2359 #if (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_8_X_X)
2360 
2361 #define traceCREATE_COUNTING_SEMAPHORE_FAILED() \
2362  prvTraceStoreEvent_HandleParam(PSF_EVENT_SEMAPHORE_COUNTING_CREATE_FAILED, 0, uxMaxCount)
2363 
2364 #elif (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_7_5_X)
2365 
2366 #define traceCREATE_COUNTING_SEMAPHORE_FAILED() \
2367  prvTraceStoreEvent_HandleParam(PSF_EVENT_SEMAPHORE_COUNTING_CREATE_FAILED, 0, uxInitialCount)
2368 
2369 #elif (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_7_4_X)
2370 
2371 #define traceCREATE_COUNTING_SEMAPHORE_FAILED() \
2372  prvTraceStoreEvent_HandleParam(PSF_EVENT_SEMAPHORE_COUNTING_CREATE_FAILED, 0, uxCountValue)
2373 
2374 #else
2375 
2376 #define traceCREATE_COUNTING_SEMAPHORE_FAILED() \
2377  prvTraceStoreEvent_HandleParam(PSF_EVENT_SEMAPHORE_COUNTING_CREATE_FAILED, 0, uxCountValue)
2378 
2379 #endif
2380 
2381 
2382 /* This macro is not necessary as of FreeRTOS v9.0.0 */
2383 #if (TRC_CFG_FREERTOS_VERSION < TRC_FREERTOS_VERSION_9_0_0)
2384 
2385 /* Called in xQueueCreateMutex, and thereby also from xSemaphoreCreateMutex and xSemaphoreCreateRecursiveMutex */
2386 #undef traceCREATE_MUTEX
2387 #define traceCREATE_MUTEX( pxNewQueue ) \
2388  switch (pxNewQueue->ucQueueType) \
2389  { \
2390  case queueQUEUE_TYPE_MUTEX: \
2391  xTraceObjectRegisterWithoutHandle(PSF_EVENT_MUTEX_CREATE, (void*)(pxNewQueue), "", 0); \
2392  break; \
2393  case queueQUEUE_TYPE_RECURSIVE_MUTEX: \
2394  xTraceObjectRegisterWithoutHandle(PSF_EVENT_MUTEX_RECURSIVE_CREATE, (void*)(pxNewQueue), "", 0); \
2395  break; \
2396  }
2397 
2398 /* Called in xQueueCreateMutex when the operation fails (when memory allocation fails) */
2399 #undef traceCREATE_MUTEX_FAILED
2400 #define traceCREATE_MUTEX_FAILED() \
2401  prvTraceStoreEvent_HandleParam(PSF_EVENT_MUTEX_CREATE_FAILED, 0, 0)
2402 #endif /* (TRC_CFG_FREERTOS_VERSION < TRC_FREERTOS_VERSION_9_0_0) */
2403 
2404 /* Called when the Mutex can not be given, since not holder */
2405 #undef traceGIVE_MUTEX_RECURSIVE_FAILED
2406 #define traceGIVE_MUTEX_RECURSIVE_FAILED( pxMutex ) \
2407  prvTraceStoreEvent_Handle(PSF_EVENT_MUTEX_GIVE_RECURSIVE_FAILED, (void*)(pxMutex))
2408 
2409 /* Called when a message is sent to a queue */ /* CS IS NEW ! */
2410 #undef traceQUEUE_SEND
2411 #define traceQUEUE_SEND( pxQueue ) \
2412  switch ((pxQueue)->ucQueueType) \
2413  { \
2414  case queueQUEUE_TYPE_BASE: \
2415  prvTraceStoreEvent_HandleParam(xCopyPosition == queueSEND_TO_BACK ? PSF_EVENT_QUEUE_SEND : PSF_EVENT_QUEUE_SEND_FRONT, (void*)(pxQueue), (pxQueue)->uxMessagesWaiting + 1); \
2416  break; \
2417  case queueQUEUE_TYPE_BINARY_SEMAPHORE: \
2418  case queueQUEUE_TYPE_COUNTING_SEMAPHORE: \
2419  prvTraceStoreEvent_HandleParam(PSF_EVENT_SEMAPHORE_GIVE, (void*)(pxQueue), (pxQueue)->uxMessagesWaiting + 1); \
2420  break; \
2421  case queueQUEUE_TYPE_MUTEX: \
2422  prvTraceStoreEvent_Handle(PSF_EVENT_MUTEX_GIVE, (void*)(pxQueue)); \
2423  break; \
2424  case queueQUEUE_TYPE_RECURSIVE_MUTEX: \
2425  prvTraceStoreEvent_Handle(PSF_EVENT_MUTEX_GIVE_RECURSIVE, (void*)(pxQueue)); \
2426  break; \
2427  }
2428 
2429 #undef traceQUEUE_SET_SEND
2430 #define traceQUEUE_SET_SEND( pxQueue ) \
2431  prvTraceStoreEvent_HandleParam(PSF_EVENT_QUEUE_SEND, (void*)(pxQueue), (pxQueue)->uxMessagesWaiting + 1)
2432 
2433 /* Called when a message failed to be sent to a queue (timeout) */
2434 #undef traceQUEUE_SEND_FAILED
2435 #define traceQUEUE_SEND_FAILED( pxQueue ) \
2436  switch ((pxQueue)->ucQueueType) \
2437  { \
2438  case queueQUEUE_TYPE_BASE: \
2439  prvTraceStoreEvent_HandleParam(xCopyPosition == queueSEND_TO_BACK ? PSF_EVENT_QUEUE_SEND_FAILED : PSF_EVENT_QUEUE_SEND_FRONT_FAILED, (void*)(pxQueue), (pxQueue)->uxMessagesWaiting); \
2440  break; \
2441  case queueQUEUE_TYPE_BINARY_SEMAPHORE: \
2442  case queueQUEUE_TYPE_COUNTING_SEMAPHORE: \
2443  prvTraceStoreEvent_HandleParam(PSF_EVENT_SEMAPHORE_GIVE_FAILED, (void*)(pxQueue), (pxQueue)->uxMessagesWaiting); \
2444  break; \
2445  case queueQUEUE_TYPE_MUTEX: \
2446  case queueQUEUE_TYPE_RECURSIVE_MUTEX: \
2447  prvTraceStoreEvent_Handle(PSF_EVENT_MUTEX_GIVE_FAILED, (void*)(pxQueue)); \
2448  break; \
2449  }
2450 
2451 /* Called when the task is blocked due to a send operation on a full queue */
2452 #undef traceBLOCKING_ON_QUEUE_SEND
2453 #define traceBLOCKING_ON_QUEUE_SEND( pxQueue ) \
2454  switch ((pxQueue)->ucQueueType) \
2455  { \
2456  case queueQUEUE_TYPE_BASE: \
2457  prvTraceStoreEvent_HandleParam(xCopyPosition == queueSEND_TO_BACK ? PSF_EVENT_QUEUE_SEND_BLOCK : PSF_EVENT_QUEUE_SEND_FRONT_BLOCK, (void*)(pxQueue), (pxQueue)->uxMessagesWaiting); \
2458  break; \
2459  case queueQUEUE_TYPE_BINARY_SEMAPHORE: \
2460  case queueQUEUE_TYPE_COUNTING_SEMAPHORE: \
2461  prvTraceStoreEvent_HandleParam(PSF_EVENT_SEMAPHORE_GIVE_BLOCK, (void*)(pxQueue), (pxQueue)->uxMessagesWaiting); \
2462  break; \
2463  case queueQUEUE_TYPE_MUTEX: \
2464  case queueQUEUE_TYPE_RECURSIVE_MUTEX: \
2465  prvTraceStoreEvent_Handle(PSF_EVENT_MUTEX_GIVE_BLOCK, (void*)(pxQueue)); \
2466  break; \
2467  }
2468 
2469 /* Called when a message is sent from interrupt context, e.g., using xQueueSendFromISR */
2470 #undef traceQUEUE_SEND_FROM_ISR
2471 #define traceQUEUE_SEND_FROM_ISR( pxQueue ) \
2472  switch ((pxQueue)->ucQueueType) \
2473  { \
2474  case queueQUEUE_TYPE_BASE: \
2475  prvTraceStoreEvent_HandleParam(xCopyPosition == queueSEND_TO_BACK ? PSF_EVENT_QUEUE_SEND_FROMISR : PSF_EVENT_QUEUE_SEND_FRONT_FROMISR, (void*)(pxQueue), (pxQueue)->uxMessagesWaiting + 1); \
2476  break; \
2477  case queueQUEUE_TYPE_BINARY_SEMAPHORE: \
2478  case queueQUEUE_TYPE_COUNTING_SEMAPHORE: \
2479  prvTraceStoreEvent_HandleParam(PSF_EVENT_SEMAPHORE_GIVE_FROMISR, (void*)(pxQueue), (pxQueue)->uxMessagesWaiting + 1); \
2480  break; \
2481  }
2482 
2483 /* Called when a message send from interrupt context fails (since the queue was full) */
2484 #undef traceQUEUE_SEND_FROM_ISR_FAILED
2485 #define traceQUEUE_SEND_FROM_ISR_FAILED( pxQueue ) \
2486  switch ((pxQueue)->ucQueueType) \
2487  { \
2488  case queueQUEUE_TYPE_BASE: \
2489  prvTraceStoreEvent_HandleParam(xCopyPosition == queueSEND_TO_BACK ? PSF_EVENT_QUEUE_SEND_FROMISR_FAILED : PSF_EVENT_QUEUE_SEND_FRONT_FROMISR_FAILED, (void*)(pxQueue), (pxQueue)->uxMessagesWaiting); \
2490  break; \
2491  case queueQUEUE_TYPE_BINARY_SEMAPHORE: \
2492  case queueQUEUE_TYPE_COUNTING_SEMAPHORE: \
2493  prvTraceStoreEvent_HandleParam(PSF_EVENT_SEMAPHORE_GIVE_FROMISR_FAILED, (void*)(pxQueue), (pxQueue)->uxMessagesWaiting); \
2494  break; \
2495  }
2496 
2497 /* Called when a message is received from a queue */
2498 #undef traceQUEUE_RECEIVE
2499 #define traceQUEUE_RECEIVE( pxQueue ) \
2500  switch ((pxQueue)->ucQueueType) \
2501  { \
2502  case queueQUEUE_TYPE_BASE: \
2503  if (isQueueReceiveHookActuallyPeek) \
2504  { \
2505  prvTraceStoreEvent_HandleParamParam(PSF_EVENT_QUEUE_PEEK, (void*)(pxQueue), xTicksToWait, (pxQueue)->uxMessagesWaiting - 1); \
2506  } \
2507  else\
2508  { \
2509  prvTraceStoreEvent_HandleParamParam(PSF_EVENT_QUEUE_RECEIVE, (void*)(pxQueue), xTicksToWait, (pxQueue)->uxMessagesWaiting - 1); \
2510  } \
2511  break; \
2512  case queueQUEUE_TYPE_BINARY_SEMAPHORE: \
2513  case queueQUEUE_TYPE_COUNTING_SEMAPHORE: \
2514  if (isQueueReceiveHookActuallyPeek) \
2515  { \
2516  prvTraceStoreEvent_HandleParamParam(PSF_EVENT_SEMAPHORE_PEEK, (void*)(pxQueue), xTicksToWait, (pxQueue)->uxMessagesWaiting - 1); \
2517  } \
2518  else \
2519  { \
2520  prvTraceStoreEvent_HandleParamParam(PSF_EVENT_SEMAPHORE_TAKE, (void*)(pxQueue), xTicksToWait, (pxQueue)->uxMessagesWaiting - 1); \
2521  } \
2522  break; \
2523  case queueQUEUE_TYPE_MUTEX: \
2524  prvTraceStoreEvent_HandleParam(isQueueReceiveHookActuallyPeek ? PSF_EVENT_MUTEX_PEEK : PSF_EVENT_MUTEX_TAKE, (void*)(pxQueue), xTicksToWait); \
2525  break; \
2526  case queueQUEUE_TYPE_RECURSIVE_MUTEX: \
2527  prvTraceStoreEvent_HandleParam(isQueueReceiveHookActuallyPeek ? PSF_EVENT_MUTEX_PEEK : PSF_EVENT_MUTEX_TAKE_RECURSIVE, (void*)(pxQueue), xTicksToWait); \
2528  break; \
2529  }
2530 
2531 /* Called when a receive operation on a queue fails (timeout) */
2532 #undef traceQUEUE_RECEIVE_FAILED
2533 #define traceQUEUE_RECEIVE_FAILED( pxQueue ) \
2534  switch ((pxQueue)->ucQueueType) \
2535  { \
2536  case queueQUEUE_TYPE_BASE: \
2537  prvTraceStoreEvent_HandleParamParam(isQueueReceiveHookActuallyPeek ? PSF_EVENT_QUEUE_PEEK_FAILED : PSF_EVENT_QUEUE_RECEIVE_FAILED, (void*)(pxQueue), xTicksToWait, (pxQueue)->uxMessagesWaiting); \
2538  break; \
2539  case queueQUEUE_TYPE_BINARY_SEMAPHORE: \
2540  case queueQUEUE_TYPE_COUNTING_SEMAPHORE: \
2541  prvTraceStoreEvent_HandleParamParam(isQueueReceiveHookActuallyPeek ? PSF_EVENT_SEMAPHORE_PEEK_FAILED : PSF_EVENT_SEMAPHORE_TAKE_FAILED, (void*)(pxQueue), xTicksToWait, (pxQueue)->uxMessagesWaiting); \
2542  break; \
2543  case queueQUEUE_TYPE_MUTEX: \
2544  prvTraceStoreEvent_HandleParam(isQueueReceiveHookActuallyPeek ? PSF_EVENT_MUTEX_PEEK_FAILED : PSF_EVENT_MUTEX_TAKE_FAILED, (void*)(pxQueue), xTicksToWait); \
2545  break; \
2546  case queueQUEUE_TYPE_RECURSIVE_MUTEX: \
2547  prvTraceStoreEvent_HandleParam(isQueueReceiveHookActuallyPeek ? PSF_EVENT_MUTEX_PEEK_FAILED : PSF_EVENT_MUTEX_TAKE_RECURSIVE_FAILED, (void*)(pxQueue), xTicksToWait); \
2548  break; \
2549  }
2550 
2551 /* Called when the task is blocked due to a receive operation on an empty queue */
2552 #undef traceBLOCKING_ON_QUEUE_RECEIVE
2553 #define traceBLOCKING_ON_QUEUE_RECEIVE( pxQueue ) \
2554  switch ((pxQueue)->ucQueueType) \
2555  { \
2556  case queueQUEUE_TYPE_BASE: \
2557  prvTraceStoreEvent_HandleParamParam(isQueueReceiveHookActuallyPeek ? PSF_EVENT_QUEUE_PEEK_BLOCK : PSF_EVENT_QUEUE_RECEIVE_BLOCK, (void*)(pxQueue), xTicksToWait, (pxQueue)->uxMessagesWaiting); \
2558  break; \
2559  case queueQUEUE_TYPE_BINARY_SEMAPHORE: \
2560  case queueQUEUE_TYPE_COUNTING_SEMAPHORE: \
2561  prvTraceStoreEvent_HandleParamParam(isQueueReceiveHookActuallyPeek ? PSF_EVENT_SEMAPHORE_PEEK_BLOCK : PSF_EVENT_SEMAPHORE_TAKE_BLOCK, (void*)(pxQueue), xTicksToWait, (pxQueue)->uxMessagesWaiting); \
2562  break; \
2563  case queueQUEUE_TYPE_MUTEX: \
2564  prvTraceStoreEvent_HandleParam(isQueueReceiveHookActuallyPeek ? PSF_EVENT_MUTEX_PEEK_BLOCK : PSF_EVENT_MUTEX_TAKE_BLOCK, (void*)(pxQueue), xTicksToWait); \
2565  break; \
2566  case queueQUEUE_TYPE_RECURSIVE_MUTEX: \
2567  prvTraceStoreEvent_HandleParam(isQueueReceiveHookActuallyPeek ? PSF_EVENT_MUTEX_PEEK_BLOCK : PSF_EVENT_MUTEX_TAKE_RECURSIVE_BLOCK, (void*)(pxQueue), xTicksToWait); \
2568  break; \
2569  }
2570 
2571 #if (TRC_CFG_FREERTOS_VERSION > TRC_FREERTOS_VERSION_9_0_1)
2572 
2573 /* Called when a peek operation on a queue fails (timeout) */
2574 #undef traceQUEUE_PEEK_FAILED
2575 #define traceQUEUE_PEEK_FAILED( pxQueue ) \
2576  switch ((pxQueue)->ucQueueType) \
2577  { \
2578  case queueQUEUE_TYPE_BASE: \
2579  prvTraceStoreEvent_HandleParamParam(PSF_EVENT_QUEUE_PEEK_FAILED, (void*)(pxQueue), xTicksToWait, (pxQueue)->uxMessagesWaiting); \
2580  break; \
2581  case queueQUEUE_TYPE_BINARY_SEMAPHORE: \
2582  case queueQUEUE_TYPE_COUNTING_SEMAPHORE: \
2583  prvTraceStoreEvent_HandleParamParam(PSF_EVENT_SEMAPHORE_PEEK_FAILED, (void*)(pxQueue), xTicksToWait, (pxQueue)->uxMessagesWaiting); \
2584  break; \
2585  case queueQUEUE_TYPE_MUTEX: \
2586  case queueQUEUE_TYPE_RECURSIVE_MUTEX: \
2587  prvTraceStoreEvent_HandleParam(PSF_EVENT_MUTEX_PEEK_FAILED, (void*)(pxQueue), xTicksToWait); \
2588  break; \
2589  }
2590 
2591 /* Called when the task is blocked due to a peek operation on an empty queue */
2592 #undef traceBLOCKING_ON_QUEUE_PEEK
2593 #define traceBLOCKING_ON_QUEUE_PEEK( pxQueue ) \
2594  switch ((pxQueue)->ucQueueType) \
2595  { \
2596  case queueQUEUE_TYPE_BASE: \
2597  prvTraceStoreEvent_HandleParamParam(PSF_EVENT_QUEUE_PEEK_BLOCK, (void*)(pxQueue), xTicksToWait, (pxQueue)->uxMessagesWaiting); \
2598  break; \
2599  case queueQUEUE_TYPE_BINARY_SEMAPHORE: \
2600  case queueQUEUE_TYPE_COUNTING_SEMAPHORE: \
2601  prvTraceStoreEvent_HandleParamParam(PSF_EVENT_SEMAPHORE_PEEK_BLOCK, (void*)(pxQueue), xTicksToWait, (pxQueue)->uxMessagesWaiting); \
2602  break; \
2603  case queueQUEUE_TYPE_MUTEX: \
2604  case queueQUEUE_TYPE_RECURSIVE_MUTEX: \
2605  prvTraceStoreEvent_HandleParam(PSF_EVENT_MUTEX_PEEK_BLOCK, (void*)(pxQueue), xTicksToWait); \
2606  break; \
2607  }
2608 
2609 #endif
2610 
2611 /* Called when a message is received in interrupt context, e.g., using xQueueReceiveFromISR */
2612 #undef traceQUEUE_RECEIVE_FROM_ISR
2613 #define traceQUEUE_RECEIVE_FROM_ISR( pxQueue ) \
2614  switch ((pxQueue)->ucQueueType) \
2615  { \
2616  case queueQUEUE_TYPE_BASE: \
2617  prvTraceStoreEvent_HandleParam(PSF_EVENT_QUEUE_RECEIVE_FROMISR, (void*)(pxQueue), (pxQueue)->uxMessagesWaiting - 1); \
2618  break; \
2619  case queueQUEUE_TYPE_BINARY_SEMAPHORE: \
2620  case queueQUEUE_TYPE_COUNTING_SEMAPHORE: \
2621  prvTraceStoreEvent_HandleParam(PSF_EVENT_SEMAPHORE_TAKE_FROMISR, (void*)(pxQueue), (pxQueue)->uxMessagesWaiting - 1); \
2622  break; \
2623  }
2624 
2625 /* Called when a message receive from interrupt context fails (since the queue was empty) */
2626 #undef traceQUEUE_RECEIVE_FROM_ISR_FAILED
2627 #define traceQUEUE_RECEIVE_FROM_ISR_FAILED( pxQueue ) \
2628  switch ((pxQueue)->ucQueueType) \
2629  { \
2630  case queueQUEUE_TYPE_BASE: \
2631  prvTraceStoreEvent_HandleParam(PSF_EVENT_QUEUE_RECEIVE_FROMISR_FAILED, (void*)(pxQueue), (pxQueue)->uxMessagesWaiting); \
2632  break; \
2633  case queueQUEUE_TYPE_BINARY_SEMAPHORE: \
2634  case queueQUEUE_TYPE_COUNTING_SEMAPHORE: \
2635  prvTraceStoreEvent_HandleParam(PSF_EVENT_SEMAPHORE_TAKE_FROMISR_FAILED, (void*)(pxQueue), (pxQueue)->uxMessagesWaiting); \
2636  break; \
2637  }
2638 
2639 /* Called on xQueuePeek */
2640 #undef traceQUEUE_PEEK
2641 #define traceQUEUE_PEEK( pxQueue ) \
2642  switch ((pxQueue)->ucQueueType) \
2643  { \
2644  case queueQUEUE_TYPE_BASE: \
2645  prvTraceStoreEvent_HandleParamParam(PSF_EVENT_QUEUE_PEEK, (void*)(pxQueue), xTicksToWait, (pxQueue)->uxMessagesWaiting); \
2646  break; \
2647  case queueQUEUE_TYPE_BINARY_SEMAPHORE: \
2648  case queueQUEUE_TYPE_COUNTING_SEMAPHORE: \
2649  prvTraceStoreEvent_HandleParamParam(PSF_EVENT_SEMAPHORE_PEEK, (void*)(pxQueue), xTicksToWait, (pxQueue)->uxMessagesWaiting); \
2650  break; \
2651  case queueQUEUE_TYPE_MUTEX: \
2652  case queueQUEUE_TYPE_RECURSIVE_MUTEX: \
2653  prvTraceStoreEvent_HandleParam(PSF_EVENT_MUTEX_PEEK, (void*)(pxQueue), xTicksToWait); \
2654  break; \
2655  }
2656 
2657 /* Called in vTaskPrioritySet */
2658 #undef traceTASK_PRIORITY_SET
2659 #define traceTASK_PRIORITY_SET( pxTask, uxNewPriority ) \
2660  xTraceTaskSetPriorityWithoutHandle(pxTask, uxNewPriority)
2661 
2662 /* Called in vTaskPriorityInherit, which is called by Mutex operations */
2663 #undef traceTASK_PRIORITY_INHERIT
2664 #define traceTASK_PRIORITY_INHERIT( pxTask, uxNewPriority ) \
2665  prvTraceStoreEvent_HandleParam(PSF_EVENT_TASK_PRIO_INHERIT, (void*)(pxTask), uxNewPriority)
2666 
2667 /* Called in vTaskPriorityDisinherit, which is called by Mutex operations */
2668 #undef traceTASK_PRIORITY_DISINHERIT
2669 #define traceTASK_PRIORITY_DISINHERIT( pxTask, uxNewPriority ) \
2670  prvTraceStoreEvent_HandleParam(PSF_EVENT_TASK_PRIO_DISINHERIT, (void*)(pxTask), uxNewPriority)
2671 
2672 /* Called in vTaskResume */
2673 #undef traceTASK_RESUME
2674 #define traceTASK_RESUME( pxTaskToResume ) \
2675  prvTraceStoreEvent_Handle(PSF_EVENT_TASK_RESUME, (void*)(pxTaskToResume))
2676 
2677 /* Called in vTaskResumeFromISR */
2678 #undef traceTASK_RESUME_FROM_ISR
2679 #define traceTASK_RESUME_FROM_ISR( pxTaskToResume ) \
2680  prvTraceStoreEvent_Handle(PSF_EVENT_TASK_RESUME_FROMISR, (void*)(pxTaskToResume))
2681 
2682 #if (TRC_CFG_INCLUDE_MEMMANG_EVENTS == 1)
2683 
2684 #undef traceMALLOC
2685 #define traceMALLOC( pvAddress, uiSize ) \
2686  if (xTraceIsRecorderEnabled()) \
2687  { \
2688  xTraceHeapAlloc(xTraceKernelPortGetSystemHeapHandle(), pvAddress, uiSize); \
2689  }
2690 
2691 #undef traceFREE
2692 #define traceFREE( pvAddress, uiSize ) \
2693  if (xTraceIsRecorderEnabled()) \
2694  { \
2695  xTraceHeapFree(xTraceKernelPortGetSystemHeapHandle(), pvAddress, uiSize); \
2696  }
2697 
2698 #endif
2699 
2700 #if (TRC_CFG_INCLUDE_TIMER_EVENTS == 1)
2701 
2702 /* Called in timer.c - xTimerCreate */
2703 #undef traceTIMER_CREATE
2704 #define traceTIMER_CREATE(tmr) \
2705  xTraceObjectRegisterWithoutHandle(PSF_EVENT_TIMER_CREATE, (void*)(tmr), (const char*)(tmr)->pcTimerName, (uint32_t)(tmr)->xTimerPeriodInTicks)
2706 
2707 #undef traceTIMER_CREATE_FAILED
2708 #define traceTIMER_CREATE_FAILED() \
2709  prvTraceStoreEvent_None(PSF_EVENT_TIMER_CREATE_FAILED);
2710 
2711 #if (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_8_X_X)
2712 
2713 #define traceTIMER_COMMAND_SEND_8_0_CASES(tmr) \
2714  case tmrCOMMAND_RESET: \
2715  prvTraceStoreEvent_HandleParam((xReturn == pdPASS) ? PSF_EVENT_TIMER_RESET : PSF_EVENT_TIMER_RESET_FAILED, (void*)(tmr), xOptionalValue); \
2716  break; \
2717  case tmrCOMMAND_START_FROM_ISR: \
2718  prvTraceStoreEvent_HandleParam((xReturn == pdPASS) ? PSF_EVENT_TIMER_START_FROMISR : PSF_EVENT_TIMER_START_FROMISR_FAILED, (void*)(tmr), xOptionalValue); \
2719  break; \
2720  case tmrCOMMAND_RESET_FROM_ISR: \
2721  prvTraceStoreEvent_HandleParam((xReturn == pdPASS) ? PSF_EVENT_TIMER_RESET_FROMISR : PSF_EVENT_TIMER_RESET_FROMISR_FAILED, (void*)(tmr), xOptionalValue); \
2722  break; \
2723  case tmrCOMMAND_STOP_FROM_ISR: \
2724  prvTraceStoreEvent_HandleParam((xReturn == pdPASS) ? PSF_EVENT_TIMER_STOP_FROMISR : PSF_EVENT_TIMER_STOP_FROMISR_FAILED, (void*)(tmr), xOptionalValue); \
2725  break; \
2726  case tmrCOMMAND_CHANGE_PERIOD_FROM_ISR: \
2727  prvTraceStoreEvent_HandleParam((xReturn == pdPASS) ? PSF_EVENT_TIMER_CHANGEPERIOD_FROMISR : PSF_EVENT_TIMER_CHANGEPERIOD_FROMISR_FAILED, (void*)(tmr), xOptionalValue); \
2728  break;
2729 #else
2730 
2731 #define traceTIMER_COMMAND_SEND_8_0_CASES(tmr)
2732 
2733 #endif
2734 
2735 /* Note that xCommandID can never be tmrCOMMAND_EXECUTE_CALLBACK (-1) since the trace macro is not called in that case */
2736 #undef traceTIMER_COMMAND_SEND
2737 #define traceTIMER_COMMAND_SEND(tmr, xCommandID, xOptionalValue, xReturn) \
2738  switch(xCommandID) \
2739  { \
2740  case tmrCOMMAND_START: \
2741  prvTraceStoreEvent_Handle(((xReturn) == pdPASS) ? PSF_EVENT_TIMER_START : PSF_EVENT_TIMER_START_FAILED, (void*)(tmr)); \
2742  break; \
2743  case tmrCOMMAND_STOP: \
2744  prvTraceStoreEvent_Handle(((xReturn) == pdPASS) ? PSF_EVENT_TIMER_STOP : PSF_EVENT_TIMER_STOP_FAILED, (void*)(tmr)); \
2745  break; \
2746  case tmrCOMMAND_CHANGE_PERIOD: \
2747  prvTraceStoreEvent_HandleParam(((xReturn) == pdPASS) ? PSF_EVENT_TIMER_CHANGEPERIOD : PSF_EVENT_TIMER_CHANGEPERIOD_FAILED, (void*)(tmr), xOptionalValue); \
2748  break; \
2749  case tmrCOMMAND_DELETE: \
2750  xTraceObjectUnregisterWithoutHandle(((xReturn) == pdPASS) ? PSF_EVENT_TIMER_DELETE : PSF_EVENT_TIMER_DELETE_FAILED, (void*)(tmr), 0); \
2751  break; \
2752  traceTIMER_COMMAND_SEND_8_0_CASES(tmr) \
2753  }
2754 
2755 #undef traceTIMER_EXPIRED
2756 #define traceTIMER_EXPIRED(tmr) \
2757  prvTraceStoreEvent_HandleParam(PSF_EVENT_TIMER_EXPIRED, (void*)(tmr), (uint32_t)((tmr)->pxCallbackFunction))
2758 
2759 #endif
2760 
2761 
2762 #if (TRC_CFG_INCLUDE_PEND_FUNC_CALL_EVENTS == 1)
2763 
2764 #undef tracePEND_FUNC_CALL
2765 #define tracePEND_FUNC_CALL(func, arg1, arg2, ret) \
2766  prvTraceStoreEvent_Param(((ret) == pdPASS) ? PSF_EVENT_TIMER_PENDFUNCCALL : PSF_EVENT_TIMER_PENDFUNCCALL_FAILED, (uint32_t)(func))
2767 
2768 #undef tracePEND_FUNC_CALL_FROM_ISR
2769 #define tracePEND_FUNC_CALL_FROM_ISR(func, arg1, arg2, ret) \
2770  prvTraceStoreEvent_Param(((ret) == pdPASS) ? PSF_EVENT_TIMER_PENDFUNCCALL_FROMISR : PSF_EVENT_TIMER_PENDFUNCCALL_FROMISR_FAILED, (uint32_t)(func))
2771 
2772 #endif
2773 
2774 #if (TRC_CFG_INCLUDE_EVENT_GROUP_EVENTS == 1)
2775 
2776 #undef traceEVENT_GROUP_CREATE
2777 #define traceEVENT_GROUP_CREATE(eg) \
2778  xTraceObjectRegisterWithoutHandle(PSF_EVENT_EVENTGROUP_CREATE, (void*)(eg), 0, (uint32_t)(eg)->uxEventBits)
2779 
2780 #undef traceEVENT_GROUP_DELETE
2781 #define traceEVENT_GROUP_DELETE(eg) \
2782  xTraceObjectUnregisterWithoutHandle(PSF_EVENT_EVENTGROUP_DELETE, (void*)(eg), (uint32_t)(eg)->uxEventBits)
2783 
2784 #undef traceEVENT_GROUP_CREATE_FAILED
2785 #define traceEVENT_GROUP_CREATE_FAILED() \
2786  prvTraceStoreEvent_None(PSF_EVENT_EVENTGROUP_CREATE_FAILED)
2787 
2788 #undef traceEVENT_GROUP_SYNC_BLOCK
2789 #define traceEVENT_GROUP_SYNC_BLOCK(eg, bitsToSet, bitsToWaitFor) \
2790  prvTraceStoreEvent_HandleParam(PSF_EVENT_EVENTGROUP_SYNC_BLOCK, (void*)(eg), bitsToWaitFor)
2791 
2792 #undef traceEVENT_GROUP_SYNC_END
2793 #define traceEVENT_GROUP_SYNC_END(eg, bitsToSet, bitsToWaitFor, wasTimeout) \
2794  prvTraceStoreEvent_HandleParam(((wasTimeout) != pdTRUE) ? PSF_EVENT_EVENTGROUP_SYNC : PSF_EVENT_EVENTGROUP_SYNC_FAILED, (void*)(eg), bitsToWaitFor)
2795 
2796 #undef traceEVENT_GROUP_WAIT_BITS_BLOCK
2797 #define traceEVENT_GROUP_WAIT_BITS_BLOCK(eg, bitsToWaitFor) \
2798  prvTraceStoreEvent_HandleParam(PSF_EVENT_EVENTGROUP_WAITBITS_BLOCK, (void*)(eg), bitsToWaitFor)
2799 
2800 #undef traceEVENT_GROUP_WAIT_BITS_END
2801 #define traceEVENT_GROUP_WAIT_BITS_END(eg, bitsToWaitFor, wasTimeout) \
2802  prvTraceStoreEvent_HandleParam(((wasTimeout) != pdTRUE) ? PSF_EVENT_EVENTGROUP_WAITBITS : PSF_EVENT_EVENTGROUP_WAITBITS_FAILED, (void*)(eg), bitsToWaitFor)
2803 
2804 #undef traceEVENT_GROUP_CLEAR_BITS
2805 #define traceEVENT_GROUP_CLEAR_BITS(eg, bitsToClear) \
2806  prvTraceStoreEvent_HandleParam(PSF_EVENT_EVENTGROUP_CLEARBITS, (void*)(eg), bitsToClear)
2807 
2808 #undef traceEVENT_GROUP_CLEAR_BITS_FROM_ISR
2809 #define traceEVENT_GROUP_CLEAR_BITS_FROM_ISR(eg, bitsToClear) \
2810  prvTraceStoreEvent_HandleParam(PSF_EVENT_EVENTGROUP_CLEARBITS_FROMISR, (void*)(eg), bitsToClear)
2811 
2812 #undef traceEVENT_GROUP_SET_BITS
2813 #define traceEVENT_GROUP_SET_BITS(eg, bitsToSet) \
2814  prvTraceStoreEvent_HandleParam(PSF_EVENT_EVENTGROUP_SETBITS, (void*)(eg), bitsToSet)
2815 
2816 #undef traceEVENT_GROUP_SET_BITS_FROM_ISR
2817 #define traceEVENT_GROUP_SET_BITS_FROM_ISR(eg, bitsToSet) \
2818  prvTraceStoreEvent_HandleParam(PSF_EVENT_EVENTGROUP_SETBITS_FROMISR, (void*)(eg), bitsToSet)
2819 
2820 #endif
2821 
2822 #undef traceTASK_NOTIFY
2823 #if (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_4_0)
2824 
2825 #define traceTASK_NOTIFY(index) \
2826  prvTraceStoreEvent_Handle(PSF_EVENT_TASK_NOTIFY, (void*)xTaskToNotify)
2827 
2828 #else
2829 
2830 #define traceTASK_NOTIFY() \
2831  prvTraceStoreEvent_Handle(PSF_EVENT_TASK_NOTIFY, (void*)xTaskToNotify)
2832 
2833 #endif
2834 
2835 #undef traceTASK_NOTIFY_FROM_ISR
2836 #if (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_4_0)
2837 
2838 #define traceTASK_NOTIFY_FROM_ISR(index) \
2839  prvTraceStoreEvent_Handle(PSF_EVENT_TASK_NOTIFY_FROM_ISR, (void*)xTaskToNotify)
2840 
2841 #else
2842 
2843 #define traceTASK_NOTIFY_FROM_ISR() \
2844  prvTraceStoreEvent_Handle(PSF_EVENT_TASK_NOTIFY_FROM_ISR, (void*)xTaskToNotify)
2845 
2846 #endif
2847 
2848 /* NOTIFY and NOTIFY_GIVE will be handled identically */
2849 #undef traceTASK_NOTIFY_GIVE_FROM_ISR
2850 #define traceTASK_NOTIFY_GIVE_FROM_ISR traceTASK_NOTIFY_FROM_ISR
2851 
2852 #undef traceTASK_NOTIFY_WAIT
2853 #if (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_4_0)
2854 
2855 #define traceTASK_NOTIFY_WAIT(index) \
2856  prvTraceStoreEvent_HandleParam(pxCurrentTCB->ucNotifyState[index] == taskNOTIFICATION_RECEIVED ? PSF_EVENT_TASK_NOTIFY_WAIT : PSF_EVENT_TASK_NOTIFY_WAIT_FAILED, (void*)pxCurrentTCB, xTicksToWait)
2857 
2858 #elif (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_9_0_0)
2859 
2860 #define traceTASK_NOTIFY_WAIT() \
2861  prvTraceStoreEvent_HandleParam(pxCurrentTCB->ucNotifyState == taskNOTIFICATION_RECEIVED ? PSF_EVENT_TASK_NOTIFY_WAIT : PSF_EVENT_TASK_NOTIFY_WAIT_FAILED, (void*)pxCurrentTCB, xTicksToWait)
2862 
2863 #else
2864 
2865 #define traceTASK_NOTIFY_WAIT() \
2866  prvTraceStoreEvent_HandleParam(pxCurrentTCB->eNotifyState == eNotified ? PSF_EVENT_TASK_NOTIFY_WAIT : PSF_EVENT_TASK_NOTIFY_WAIT_FAILED, (void*)pxCurrentTCB, xTicksToWait)
2867 
2868 #endif
2869 
2870 /* WAIT and TAKE will be handled identically */
2871 #undef traceTASK_NOTIFY_TAKE
2872 #define traceTASK_NOTIFY_TAKE traceTASK_NOTIFY_WAIT
2873 
2874 #undef traceTASK_NOTIFY_WAIT_BLOCK
2875 #if (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_4_0)
2876 
2877 #define traceTASK_NOTIFY_WAIT_BLOCK(index) \
2878  prvTraceStoreEvent_HandleParam(PSF_EVENT_TASK_NOTIFY_WAIT_BLOCK, (void*)pxCurrentTCB, xTicksToWait)
2879 
2880 #else
2881 
2882 #define traceTASK_NOTIFY_WAIT_BLOCK() \
2883  prvTraceStoreEvent_HandleParam(PSF_EVENT_TASK_NOTIFY_WAIT_BLOCK, (void*)pxCurrentTCB, xTicksToWait)
2884 
2885 #endif
2886 
2887 /* WAIT_BLOCK and TAKE_BLOCK will be handled identically */
2888 #undef traceTASK_NOTIFY_TAKE_BLOCK
2889 #define traceTASK_NOTIFY_TAKE_BLOCK traceTASK_NOTIFY_WAIT_BLOCK
2890 
2891 #undef traceQUEUE_REGISTRY_ADD
2892 #define traceQUEUE_REGISTRY_ADD(object, name) \
2893  xTraceObjectSetNameWithoutHandle(object, (const char*)(name));
2894 
2895 #if (TRC_CFG_INCLUDE_STREAM_BUFFER_EVENTS == 1)
2896 
2897 #undef traceSTREAM_BUFFER_CREATE
2898 #define traceSTREAM_BUFFER_CREATE( pxStreamBuffer, xIsMessageBuffer ) \
2899  xTraceObjectRegisterWithoutHandle((xIsMessageBuffer) == 1 ? PSF_EVENT_MESSAGEBUFFER_CREATE : PSF_EVENT_STREAMBUFFER_CREATE, (void*)(pxStreamBuffer), "", (uint32_t)xBufferSizeBytes)
2900 
2901 #undef traceSTREAM_BUFFER_CREATE_FAILED
2902 #define traceSTREAM_BUFFER_CREATE_FAILED( xIsMessageBuffer ) \
2903  prvTraceStoreEvent_HandleParam((xIsMessageBuffer) == 1 ? PSF_EVENT_MESSAGEBUFFER_CREATE_FAILED : PSF_EVENT_STREAMBUFFER_CREATE_FAILED, 0 , xBufferSizeBytes)
2904 
2905 #undef traceSTREAM_BUFFER_CREATE_STATIC_FAILED
2906 #define traceSTREAM_BUFFER_CREATE_STATIC_FAILED( xReturn, xIsMessageBuffer ) \
2907  traceSTREAM_BUFFER_CREATE_FAILED( xIsMessageBuffer )
2908 
2909 #undef traceSTREAM_BUFFER_DELETE
2910 #define traceSTREAM_BUFFER_DELETE( xStreamBuffer ) \
2911  xTraceObjectUnregisterWithoutHandle(prvGetStreamBufferType(xStreamBuffer) > 0 ? PSF_EVENT_MESSAGEBUFFER_DELETE : PSF_EVENT_STREAMBUFFER_DELETE, (void*)(xStreamBuffer), prvBytesInBuffer(xStreamBuffer));
2912 
2913 #undef traceSTREAM_BUFFER_RESET
2914 #define traceSTREAM_BUFFER_RESET( xStreamBuffer ) \
2915  prvTraceStoreEvent_HandleParam(prvGetStreamBufferType(xStreamBuffer) > 0 ? PSF_EVENT_MESSAGEBUFFER_RESET : PSF_EVENT_STREAMBUFFER_RESET, (void*)(xStreamBuffer), 0)
2916 
2917 #undef traceSTREAM_BUFFER_SEND
2918 #define traceSTREAM_BUFFER_SEND( xStreamBuffer, xReturn ) \
2919  prvTraceStoreEvent_HandleParam(prvGetStreamBufferType(xStreamBuffer) > 0 ? PSF_EVENT_MESSAGEBUFFER_SEND : PSF_EVENT_STREAMBUFFER_SEND, (void*)(xStreamBuffer), prvBytesInBuffer(xStreamBuffer))
2920 
2921 #undef traceBLOCKING_ON_STREAM_BUFFER_SEND
2922 #define traceBLOCKING_ON_STREAM_BUFFER_SEND( xStreamBuffer ) \
2923  prvTraceStoreEvent_Handle(prvGetStreamBufferType(xStreamBuffer) > 0 ? PSF_EVENT_MESSAGEBUFFER_SEND_BLOCK : PSF_EVENT_STREAMBUFFER_SEND_BLOCK, (void*)(xStreamBuffer))
2924 
2925 #undef traceSTREAM_BUFFER_SEND_FAILED
2926 #define traceSTREAM_BUFFER_SEND_FAILED( xStreamBuffer ) \
2927  prvTraceStoreEvent_Handle(prvGetStreamBufferType(xStreamBuffer) > 0 ? PSF_EVENT_MESSAGEBUFFER_SEND_FAILED : PSF_EVENT_STREAMBUFFER_SEND_FAILED, (void*)(xStreamBuffer))
2928 
2929 #undef traceSTREAM_BUFFER_RECEIVE
2930 #define traceSTREAM_BUFFER_RECEIVE( xStreamBuffer, xReceivedLength ) \
2931  prvTraceStoreEvent_HandleParam(prvGetStreamBufferType(xStreamBuffer) > 0 ? PSF_EVENT_MESSAGEBUFFER_RECEIVE: PSF_EVENT_STREAMBUFFER_RECEIVE, (void*)(xStreamBuffer), prvBytesInBuffer(xStreamBuffer))
2932 
2933 #undef traceBLOCKING_ON_STREAM_BUFFER_RECEIVE
2934 #define traceBLOCKING_ON_STREAM_BUFFER_RECEIVE( xStreamBuffer ) \
2935  prvTraceStoreEvent_Handle(prvGetStreamBufferType(xStreamBuffer) > 0 ? PSF_EVENT_MESSAGEBUFFER_RECEIVE_BLOCK: PSF_EVENT_STREAMBUFFER_RECEIVE_BLOCK, (void*)(xStreamBuffer))
2936 
2937 #undef traceSTREAM_BUFFER_RECEIVE_FAILED
2938 #define traceSTREAM_BUFFER_RECEIVE_FAILED( xStreamBuffer ) \
2939  prvTraceStoreEvent_Handle(prvGetStreamBufferType(xStreamBuffer) > 0 ? PSF_EVENT_MESSAGEBUFFER_RECEIVE_FAILED: PSF_EVENT_STREAMBUFFER_RECEIVE_FAILED, (void*)(xStreamBuffer))
2940 
2941 #undef traceSTREAM_BUFFER_SEND_FROM_ISR
2942 #define traceSTREAM_BUFFER_SEND_FROM_ISR( xStreamBuffer, xReturn ) \
2943  if ( (xReturn) > ( size_t ) 0 ) \
2944  { \
2945  prvTraceStoreEvent_HandleParam(prvGetStreamBufferType(xStreamBuffer) > 0 ? PSF_EVENT_MESSAGEBUFFER_SEND_FROM_ISR : PSF_EVENT_STREAMBUFFER_SEND_FROM_ISR, (void*)(xStreamBuffer), prvBytesInBuffer(xStreamBuffer)); \
2946  } \
2947  else \
2948  { \
2949  prvTraceStoreEvent_Handle(prvGetStreamBufferType(xStreamBuffer) > 0 ? PSF_EVENT_MESSAGEBUFFER_SEND_FROM_ISR_FAILED : PSF_EVENT_STREAMBUFFER_SEND_FROM_ISR_FAILED, (void*)(xStreamBuffer)); \
2950  }
2951 
2952 #undef traceSTREAM_BUFFER_RECEIVE_FROM_ISR
2953 #define traceSTREAM_BUFFER_RECEIVE_FROM_ISR( xStreamBuffer, xReceivedLength ) \
2954  if ( (xReceivedLength) > ( size_t ) 0 ) \
2955  { \
2956  prvTraceStoreEvent_HandleParam(prvGetStreamBufferType(xStreamBuffer) > 0 ? PSF_EVENT_MESSAGEBUFFER_RECEIVE_FROM_ISR : PSF_EVENT_STREAMBUFFER_RECEIVE_FROM_ISR, (void*)(xStreamBuffer), prvBytesInBuffer(xStreamBuffer)); \
2957  } \
2958  else \
2959  { \
2960  prvTraceStoreEvent_Handle(prvGetStreamBufferType(xStreamBuffer) > 0 ? PSF_EVENT_MESSAGEBUFFER_RECEIVE_FROM_ISR_FAILED : PSF_EVENT_STREAMBUFFER_RECEIVE_FROM_ISR_FAILED, (void*)(xStreamBuffer)); \
2961  }
2962 
2963 #endif
2964 
2965 #endif
2966 
2967 #endif
2968 
2969 #else
2970 
2971 /* When recorder is disabled */
2972 #define vTraceSetQueueName(object, name)
2973 #define vTraceSetSemaphoreName(object, name)
2974 #define vTraceSetMutexName(object, name)
2975 #define vTraceSetEventGroupName(object, name)
2976 #define vTraceSetStreamBufferName(object, name)
2977 #define vTraceSetMessageBufferName(object, name)
2978 
2979 #endif
2980 
2981 #ifdef __cplusplus
2982 }
2983 #endif
2984 
2985 #endif /* TRC_KERNEL_PORT_H */
trcHeap.h
Public trace heap APIs.
TraceKernelPortDataBuffer
A structure representing the kernel port buffer.
Definition: trcKernelPort.h:105