]> git.sur5r.net Git - freertos/blob - FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcKernelPort.h
Update trace recorder code.
[freertos] / FreeRTOS-Plus / Source / FreeRTOS-Plus-Trace / Include / trcKernelPort.h
1 /*******************************************************************************\r
2  * Trace Recorder Library for Tracealyzer v4.1.1\r
3  * Percepio AB, www.percepio.com\r
4  *\r
5  * Terms of Use\r
6  * This file is part of the trace recorder library (RECORDER), which is the \r
7  * intellectual property of Percepio AB (PERCEPIO) and provided under a\r
8  * license as follows.\r
9  * The RECORDER may be used free of charge for the purpose of recording data\r
10  * intended for analysis in PERCEPIO products. It may not be used or modified\r
11  * for other purposes without explicit permission from PERCEPIO.\r
12  * You may distribute the RECORDER in its original source code form, assuming\r
13  * this text (terms of use, disclaimer, copyright notice) is unchanged. You are\r
14  * allowed to distribute the RECORDER with minor modifications intended for\r
15  * configuration or porting of the RECORDER, e.g., to allow using it on a \r
16  * specific processor, processor family or with a specific communication\r
17  * interface. Any such modifications should be documented directly below\r
18  * this comment block.  \r
19  *\r
20  * Disclaimer\r
21  * The RECORDER is being delivered to you AS IS and PERCEPIO makes no warranty\r
22  * as to its use or performance. PERCEPIO does not and cannot warrant the \r
23  * performance or results you may obtain by using the RECORDER or documentation.\r
24  * PERCEPIO make no warranties, express or implied, as to noninfringement of\r
25  * third party rights, merchantability, or fitness for any particular purpose.\r
26  * In no event will PERCEPIO, its technology partners, or distributors be liable\r
27  * to you for any consequential, incidental or special damages, including any\r
28  * lost profits or lost savings, even if a representative of PERCEPIO has been\r
29  * advised of the possibility of such damages, or for any claim by any third\r
30  * party. Some jurisdictions do not allow the exclusion or limitation of\r
31  * incidental, consequential or special damages, or the exclusion of implied\r
32  * warranties or limitations on how long an implied warranty may last, so the\r
33  * above limitations may not apply to you.\r
34  *\r
35  * FreeRTOS-specific definitions needed by the trace recorder\r
36  *\r
37  * <LICENSE INFO>\r
38  *\r
39  * Tabs are used for indent in this file (1 tab = 4 spaces)\r
40  *\r
41  * Copyright Percepio AB, 2018.\r
42  * www.percepio.com\r
43  ******************************************************************************/\r
44 \r
45 #ifndef TRC_KERNEL_PORT_H\r
46 #define TRC_KERNEL_PORT_H\r
47 \r
48 #include "FreeRTOS.h"   /* Defines configUSE_TRACE_FACILITY */\r
49 #include "trcPortDefines.h"\r
50 \r
51 #ifdef __cplusplus\r
52 extern "C" {\r
53 #endif\r
54 \r
55 #define TRC_USE_TRACEALYZER_RECORDER configUSE_TRACE_FACILITY\r
56 \r
57 /*** FreeRTOS version codes **************************************************/\r
58 #define FREERTOS_VERSION_NOT_SET                                0\r
59 #define TRC_FREERTOS_VERSION_7_3                                1 /* v7.3 is earliest supported.*/\r
60 #define TRC_FREERTOS_VERSION_7_4                                2\r
61 #define TRC_FREERTOS_VERSION_7_5_OR_7_6                 3\r
62 #define TRC_FREERTOS_VERSION_8_X                                4 /* Any v8.x.x*/\r
63 #define TRC_FREERTOS_VERSION_9_0_0                              5 \r
64 #define TRC_FREERTOS_VERSION_9_0_1                              6 \r
65 #define TRC_FREERTOS_VERSION_9_0_2                              7\r
66 #define TRC_FREERTOS_VERSION_10_0_0                             8 /* If using FreeRTOS v10.0.0 or later version */\r
67 \r
68 #define TRC_FREERTOS_VERSION_9_X                                42 /* Not allowed anymore */\r
69 \r
70 #if (TRC_CFG_FREERTOS_VERSION == TRC_FREERTOS_VERSION_9_X)\r
71 /* This setting for TRC_CFG_FREERTOS_VERSION is no longer allowed as v9.0.1 needs special handling. */ \r
72 #error "Please specify your exact FreeRTOS version in trcConfig.h, from the options listed above."\r
73 #endif\r
74 \r
75 #if (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0)\r
76 #define prvGetStreamBufferType(x) ((( StreamBuffer_t * )x )->ucFlags & sbFLAGS_IS_MESSAGE_BUFFER)\r
77 #else\r
78 #define prvGetStreamBufferType(x) 0\r
79 #endif\r
80 \r
81 /* Added mainly for our internal testing. This makes it easier to create test applications that \r
82    runs on multiple FreeRTOS versions. */\r
83 #if (TRC_CFG_FREERTOS_VERSION < TRC_FREERTOS_VERSION_8_X)\r
84         /* FreeRTOS v7.0 and later */   \r
85         #define STRING_CAST(x) ( (signed char*) x )\r
86         #define TickType portTickType\r
87 #else\r
88         /* FreeRTOS v8.0 and later */\r
89         #define STRING_CAST(x) x\r
90         #define TickType TickType_t\r
91 #endif\r
92 \r
93 #if (defined(TRC_USE_TRACEALYZER_RECORDER)) && (TRC_USE_TRACEALYZER_RECORDER == 1)\r
94 \r
95 /*******************************************************************************\r
96  * INCLUDE_xTaskGetCurrentTaskHandle must be set to 1 for tracing to work properly\r
97  ******************************************************************************/\r
98 #undef INCLUDE_xTaskGetCurrentTaskHandle\r
99 #define INCLUDE_xTaskGetCurrentTaskHandle 1\r
100 \r
101 #if (TRC_CFG_SCHEDULING_ONLY == 0)\r
102 /*******************************************************************************\r
103  * vTraceSetQueueName(void* object, const char* name)\r
104  *\r
105  * Parameter object: pointer to the Queue that shall be named\r
106  * Parameter name: the name to set (const string literal)\r
107  *\r
108  * Sets a name for Queue objects for display in Tracealyzer.\r
109  ******************************************************************************/\r
110 void vTraceSetQueueName(void* object, const char* name);\r
111 \r
112 /*******************************************************************************\r
113  * vTraceSetSemaphoreName(void* object, const char* name)\r
114  *\r
115  * Parameter object: pointer to the Semaphore that shall be named\r
116  * Parameter name: the name to set (const string literal)\r
117  *\r
118  * Sets a name for Semaphore objects for display in Tracealyzer.\r
119  ******************************************************************************/\r
120 void vTraceSetSemaphoreName(void* object, const char* name);\r
121 \r
122 /*******************************************************************************\r
123  * vTraceSetMutexName(void* object, const char* name)\r
124  *\r
125  * Parameter object: pointer to the Mutex that shall be named\r
126  * Parameter name: the name to set (const string literal)\r
127  *\r
128  * Sets a name for Semaphore objects for display in Tracealyzer.\r
129  ******************************************************************************/\r
130 void vTraceSetMutexName(void* object, const char* name);\r
131 \r
132 #if (TRC_CFG_INCLUDE_EVENT_GROUP_EVENTS == 1)\r
133 /*******************************************************************************\r
134 * vTraceSetEventGroupName(void* object, const char* name)\r
135 *\r
136 * Parameter object: pointer to the EventGroup that shall be named\r
137 * Parameter name: the name to set (const string literal)\r
138 *\r
139 * Sets a name for EventGroup objects for display in Tracealyzer.\r
140 ******************************************************************************/\r
141 void vTraceSetEventGroupName(void* object, const char* name);\r
142 #else /* (TRC_CFG_INCLUDE_EVENT_GROUP_EVENTS == 1) */\r
143 #define vTraceSetEventGroupName(object, name) /* Do nothing */\r
144 #endif /* (TRC_CFG_INCLUDE_EVENT_GROUP_EVENTS == 1) */\r
145 \r
146 #if (TRC_CFG_INCLUDE_STREAM_BUFFER_EVENTS == 1)\r
147 /*******************************************************************************\r
148 * vTraceSetStreamBufferName(void* object, const char* name)\r
149 *\r
150 * Parameter object: pointer to the StreamBuffer that shall be named\r
151 * Parameter name: the name to set (const string literal)\r
152 *\r
153 * Sets a name for StreamBuffer objects for display in Tracealyzer.\r
154 ******************************************************************************/\r
155 void vTraceSetStreamBufferName(void* object, const char* name);\r
156 #else /* (TRC_CFG_INCLUDE_STREAM_BUFFER_EVENTS == 1) */\r
157 #define vTraceSetStreamBufferName(object, name) /* Do nothing */\r
158 #endif /* (TRC_CFG_INCLUDE_STREAM_BUFFER_EVENTS == 1) */\r
159 \r
160 #if (TRC_CFG_INCLUDE_STREAM_BUFFER_EVENTS == 1)\r
161 /*******************************************************************************\r
162  * vTraceSetMessageBufferName(void* object, const char* name)\r
163  *\r
164  * Parameter object: pointer to the MessageBuffer that shall be named\r
165  * Parameter name: the name to set (const string literal)\r
166  *\r
167  * Sets a name for MessageBuffer objects for display in Tracealyzer.\r
168  ******************************************************************************/\r
169 void vTraceSetMessageBufferName(void* object, const char* name);\r
170 #else /* (TRC_CFG_INCLUDE_STREAM_BUFFER_EVENTS == 1) */\r
171 #define vTraceSetMessageBufferName(object, name) /* Do nothing */\r
172 #endif /* (TRC_CFG_INCLUDE_STREAM_BUFFER_EVENTS == 1) */\r
173 \r
174 #else /* (TRC_CFG_SCHEDULING_ONLY == 0) */\r
175 \r
176 #define vTraceSetQueueName(object, name) /* Do nothing */\r
177 #define vTraceSetSemaphoreName(object, name) /* Do nothing */\r
178 #define vTraceSetMutexName(object, name) /* Do nothing */\r
179 #define vTraceSetEventGroupName(object, name) /* Do nothing */\r
180 #define vTraceSetStreamBufferName(object, name) /* Do nothing */\r
181 #define vTraceSetMessageBufferName(object, name) /* Do nothing */\r
182 \r
183 #endif /* (TRC_CFG_SCHEDULING_ONLY == 0) */\r
184 \r
185 /*******************************************************************************\r
186  * Note: Setting names for event groups is difficult to support, this has been \r
187  * excluded intentionally. This since we don't know if event_groups.c is \r
188  * included in the build, so referencing it from the recorder may cause errors.\r
189  ******************************************************************************/\r
190 \r
191 /* Gives the currently executing task (wrapper for RTOS-specific function) */\r
192 void* prvTraceGetCurrentTaskHandle(void);\r
193 \r
194 #if (((TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_SNAPSHOT) && (TRC_CFG_INCLUDE_ISR_TRACING == 1)) || (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING))\r
195 /* Tells if the scheduler currently is suspended (task-switches can't occur) */\r
196 unsigned char prvTraceIsSchedulerSuspended(void);\r
197 \r
198 /*******************************************************************************\r
199  * INCLUDE_xTaskGetSchedulerState must be set to 1 for tracing to work properly\r
200  ******************************************************************************/\r
201 #undef INCLUDE_xTaskGetSchedulerState\r
202 #define INCLUDE_xTaskGetSchedulerState 1\r
203 \r
204 #endif /* (((TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_SNAPSHOT) && (TRC_CFG_INCLUDE_ISR_TRACING == 1)) || (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING)) */\r
205 \r
206 #define TRACE_KERNEL_VERSION 0x1AA1\r
207 #define TRACE_TICK_RATE_HZ configTICK_RATE_HZ /* Defined in "FreeRTOS.h" */\r
208 #define TRACE_CPU_CLOCK_HZ configCPU_CLOCK_HZ /* Defined in "FreeRTOSConfig.h" */\r
209 #define TRACE_GET_CURRENT_TASK() prvTraceGetCurrentTaskHandle()\r
210 \r
211 #define TRACE_GET_OS_TICKS() (uiTraceTickCount) /* Streaming only */\r
212 \r
213 /* If using dynamic allocation of snapshot trace buffer... */\r
214 #define TRACE_MALLOC(size) pvPortMalloc(size)   \r
215 \r
216 #if defined(configUSE_TIMERS)\r
217 #if (configUSE_TIMERS == 1)\r
218 #undef INCLUDE_xTimerGetTimerDaemonTaskHandle\r
219 #define INCLUDE_xTimerGetTimerDaemonTaskHandle 1\r
220 #endif /* configUSE_TIMERS == 1*/\r
221 #endif /* configUSE_TIMERS */\r
222 \r
223 /* For ARM Cortex-M devices - assumes the ARM CMSIS API is available */\r
224 #if (defined (__CORTEX_M))      \r
225         #define TRACE_ALLOC_CRITICAL_SECTION() uint32_t __irq_status;\r
226         #define TRACE_ENTER_CRITICAL_SECTION() {__irq_status = __get_PRIMASK(); __set_PRIMASK(1);} /* PRIMASK disables ALL interrupts - allows for tracing in any ISR */\r
227         #define TRACE_EXIT_CRITICAL_SECTION() {__set_PRIMASK(__irq_status);}\r
228 #endif\r
229 \r
230 #if ((TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_ARM_CORTEX_A9) || (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_Renesas_RX600) || (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_MICROCHIP_PIC24_PIC32) || (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_Altera_NiosII))\r
231         #define TRACE_ALLOC_CRITICAL_SECTION() int __irq_status;\r
232         #define TRACE_ENTER_CRITICAL_SECTION() {__irq_status = portSET_INTERRUPT_MASK_FROM_ISR();}\r
233         #define TRACE_EXIT_CRITICAL_SECTION() {portCLEAR_INTERRUPT_MASK_FROM_ISR(__irq_status);}\r
234 #endif\r
235 \r
236 #if (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_Win32)\r
237     /* In the Win32 port, there are no real interrupts, so we can use the normal critical sections */\r
238         #define TRACE_ALLOC_CRITICAL_SECTION()\r
239         #define TRACE_ENTER_CRITICAL_SECTION() portENTER_CRITICAL()\r
240         #define TRACE_EXIT_CRITICAL_SECTION() portEXIT_CRITICAL()\r
241 #endif\r
242 \r
243 #if (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_POWERPC_Z4)\r
244 #if (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_8_X)\r
245     /* FreeRTOS v8.0 or later */    \r
246         #define TRACE_ALLOC_CRITICAL_SECTION() UBaseType_t __irq_status;\r
247     #define TRACE_ENTER_CRITICAL_SECTION() {__irq_status = portSET_INTERRUPT_MASK_FROM_ISR();}\r
248     #define TRACE_EXIT_CRITICAL_SECTION() {portCLEAR_INTERRUPT_MASK_FROM_ISR(__irq_status);}\r
249 #else \r
250         /* FreeRTOS v7.x */\r
251     #define TRACE_ALLOC_CRITICAL_SECTION() unsigned portBASE_TYPE __irq_status;\r
252     #define TRACE_ENTER_CRITICAL_SECTION() {__irq_status = portSET_INTERRUPT_MASK_FROM_ISR();}\r
253     #define TRACE_EXIT_CRITICAL_SECTION() {portCLEAR_INTERRUPT_MASK_FROM_ISR(__irq_status);}\r
254 #endif\r
255 #endif\r
256 \r
257 #ifndef TRACE_ENTER_CRITICAL_SECTION\r
258         #error "This hardware port has no definition for critical sections! See http://percepio.com/2014/10/27/how-to-define-critical-sections-for-the-recorder/"\r
259 #endif\r
260 \r
261 \r
262 #if (TRC_CFG_FREERTOS_VERSION == TRC_FREERTOS_VERSION_9_0_1)\r
263         /******************************************************************************\r
264         * Fix for FreeRTOS v9.0.1 to correctly identify xQueuePeek events.\r
265         *\r
266         * In FreeRTOS v9.0.1, the below trace hooks are incorrectly used from three\r
267         * different functions. This as the earlier function xQueueGenericReceive\r
268         * has been replaced by xQueuePeek, xQueueSemaphoreTake and xQueueReceive.\r
269         *\r
270         * xQueueGenericReceive had a parameter "xJustPeeking", used by the trace hooks\r
271         * to tell between xQueuePeek events and others. This is no longer present, so\r
272         * we need another way to correctly identify peek events. Since all three\r
273         * functions call the same trace macros, the context of these macro is unknown.\r
274         *\r
275         * We therefore check the __LINE__ macro inside of the trace macros. This gives\r
276         * the line number of queue.c, where the macros are used. This can be used to\r
277         * tell if the context is xQueuePeek or another function.\r
278         * __LINE__ is a standard compiler feature since ancient times, so it should\r
279         * work on all common compilers.\r
280         *\r
281         * This might seem as a quite brittle and unusual solution, but works in this\r
282         * particular case and is only for FreeRTOS v9.0.1.\r
283         * Future versions of FreeRTOS should not need this fix, as we have submitted\r
284         * a correction of queue.c with individual trace macros for each function.\r
285         ******************************************************************************/\r
286 #define isQueueReceiveHookActuallyPeek (__LINE__ > 1674) /* Half way between the closes trace points */\r
287 \r
288 #elif (TRC_CFG_FREERTOS_VERSION <= TRC_FREERTOS_VERSION_9_0_0)\r
289 #define isQueueReceiveHookActuallyPeek xJustPeeking\r
290 \r
291 #elif (TRC_CFG_FREERTOS_VERSION > TRC_FREERTOS_VERSION_9_0_1)\r
292 #define isQueueReceiveHookActuallyPeek (__LINE__ < 0) /* instead of pdFALSE to fix a warning of "constant condition" */\r
293 \r
294 #endif\r
295 \r
296 extern uint16_t CurrentFilterMask;\r
297 \r
298 extern uint16_t CurrentFilterGroup;\r
299 \r
300 uint8_t prvTraceGetQueueType(void* handle);\r
301 \r
302 uint16_t prvTraceGetTaskNumberLow16(void* handle);\r
303 uint16_t prvTraceGetTaskNumberHigh16(void* handle);\r
304 void prvTraceSetTaskNumberLow16(void* handle, uint16_t value);\r
305 void prvTraceSetTaskNumberHigh16(void* handle, uint16_t value);\r
306 \r
307 uint16_t prvTraceGetQueueNumberLow16(void* handle);\r
308 uint16_t prvTraceGetQueueNumberHigh16(void* handle);\r
309 void prvTraceSetQueueNumberLow16(void* handle, uint16_t value);\r
310 void prvTraceSetQueueNumberHigh16(void* handle, uint16_t value);\r
311 \r
312 #if (TRC_CFG_INCLUDE_TIMER_EVENTS == 1 && TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0)\r
313 uint16_t prvTraceGetTimerNumberLow16(void* handle);\r
314 uint16_t prvTraceGetTimerNumberHigh16(void* handle);\r
315 void prvTraceSetTimerNumberLow16(void* handle, uint16_t value);\r
316 void prvTraceSetTimerNumberHigh16(void* handle, uint16_t value);\r
317 #endif /* (TRC_CFG_INCLUDE_TIMER_EVENTS == 1 && TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0) */\r
318 \r
319 #if (TRC_CFG_INCLUDE_EVENT_GROUP_EVENTS == 1 && TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0)\r
320 uint16_t prvTraceGetEventGroupNumberLow16(void* handle);\r
321 uint16_t prvTraceGetEventGroupNumberHigh16(void* handle);\r
322 void prvTraceSetEventGroupNumberLow16(void* handle, uint16_t value);\r
323 void prvTraceSetEventGroupNumberHigh16(void* handle, uint16_t value);\r
324 #endif /* (TRC_CFG_INCLUDE_EVENT_GROUP_EVENTS == 1 && TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0) */\r
325 \r
326 #if (TRC_CFG_INCLUDE_STREAM_BUFFER_EVENTS == 1 && TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0)\r
327 uint16_t prvTraceGetStreamBufferNumberLow16(void* handle);\r
328 uint16_t prvTraceGetStreamBufferNumberHigh16(void* handle);\r
329 void prvTraceSetStreamBufferNumberLow16(void* handle, uint16_t value);\r
330 void prvTraceSetStreamBufferNumberHigh16(void* handle, uint16_t value);\r
331 #endif /* (TRC_CFG_INCLUDE_STREAM_BUFFER_EVENTS == 1 && TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0) */\r
332 \r
333 #define TRACE_GET_TASK_FILTER(pxTask) prvTraceGetTaskNumberHigh16((void*)pxTask)\r
334 #define TRACE_SET_TASK_FILTER(pxTask, group) prvTraceSetTaskNumberHigh16((void*)pxTask, group)\r
335 \r
336 #define TRACE_GET_QUEUE_FILTER(pxObject) prvTraceGetQueueNumberHigh16((void*)pxObject)\r
337 #define TRACE_SET_QUEUE_FILTER(pxObject, group) prvTraceSetQueueNumberHigh16((void*)pxObject, group)\r
338 \r
339 #if (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0)\r
340 #define TRACE_GET_EVENTGROUP_FILTER(pxObject) prvTraceGetEventGroupNumberHigh16((void*)pxObject)\r
341 #define TRACE_SET_EVENTGROUP_FILTER(pxObject, group) prvTraceSetEventGroupNumberHigh16((void*)pxObject, group)\r
342 #else /* (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0) */\r
343 /* FreeRTOS versions before v10.0 does not support filtering for event groups */\r
344 #define TRACE_GET_EVENTGROUP_FILTER(pxObject) 1\r
345 #define TRACE_SET_EVENTGROUP_FILTER(pxObject, group) \r
346 #endif /* (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0) */\r
347 \r
348 #if (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0)\r
349 #define TRACE_GET_TIMER_FILTER(pxObject) prvTraceGetTimerNumberHigh16((void*)pxObject)\r
350 #define TRACE_SET_TIMER_FILTER(pxObject, group) prvTraceSetTimerNumberHigh16((void*)pxObject, group)\r
351 #else /* (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0) */\r
352 /* FreeRTOS versions before v10.0 does not support filtering for timers */\r
353 #define TRACE_GET_TIMER_FILTER(pxObject) 1\r
354 #define TRACE_SET_TIMER_FILTER(pxObject, group) \r
355 #endif /* (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0) */\r
356 \r
357 #define TRACE_GET_STREAMBUFFER_FILTER(pxObject) prvTraceGetStreamBufferNumberHigh16((void*)pxObject)\r
358 #define TRACE_SET_STREAMBUFFER_FILTER(pxObject, group) prvTraceSetStreamBufferNumberHigh16((void*)pxObject, group)\r
359 \r
360 #define TRACE_GET_OBJECT_FILTER(CLASS, pxObject) TRACE_GET_##CLASS##_FILTER(pxObject)\r
361 #define TRACE_SET_OBJECT_FILTER(CLASS, pxObject, group) TRACE_SET_##CLASS##_FILTER(pxObject, group)\r
362 \r
363 /******************************************************************************/\r
364 /*** Definitions for Snapshot mode ********************************************/\r
365 /******************************************************************************/\r
366 #if (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_SNAPSHOT)\r
367 \r
368 /*** The object classes *******************************************************/\r
369 \r
370 #define TRACE_NCLASSES 9\r
371 #define TRACE_CLASS_QUEUE ((traceObjectClass)0)\r
372 #define TRACE_CLASS_SEMAPHORE ((traceObjectClass)1)\r
373 #define TRACE_CLASS_MUTEX ((traceObjectClass)2)\r
374 #define TRACE_CLASS_TASK ((traceObjectClass)3)\r
375 #define TRACE_CLASS_ISR ((traceObjectClass)4)\r
376 #define TRACE_CLASS_TIMER ((traceObjectClass)5)\r
377 #define TRACE_CLASS_EVENTGROUP ((traceObjectClass)6)\r
378 #define TRACE_CLASS_STREAMBUFFER ((traceObjectClass)7)\r
379 #define TRACE_CLASS_MESSAGEBUFFER ((traceObjectClass)8)\r
380 \r
381 /*** Definitions for Object Table ********************************************/\r
382 #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))\r
383 \r
384 /* Queue properties (except name):      current number of message in queue */\r
385 #define PropertyTableSizeQueue          ((TRC_CFG_NAME_LEN_QUEUE) + 1)\r
386 \r
387 /* Semaphore properties (except name): state (signaled = 1, cleared = 0) */\r
388 #define PropertyTableSizeSemaphore      ((TRC_CFG_NAME_LEN_SEMAPHORE) + 1)\r
389 \r
390 /* Mutex properties (except name):      owner (task handle, 0 = free) */\r
391 #define PropertyTableSizeMutex          ((TRC_CFG_NAME_LEN_MUTEX) + 1)\r
392 \r
393 /* Task properties (except name):       Byte 0: Current priority\r
394                                                                         Byte 1: state (if already active)\r
395                                                                         Byte 2: legacy, not used\r
396                                                                         Byte 3: legacy, not used */\r
397 #define PropertyTableSizeTask           ((TRC_CFG_NAME_LEN_TASK) + 4)\r
398 \r
399 /* ISR properties:                                      Byte 0: priority\r
400                                                                         Byte 1: state (if already active) */\r
401 #define PropertyTableSizeISR            ((TRC_CFG_NAME_LEN_ISR) + 2)\r
402 \r
403 /* TRC_CFG_NTIMER properties:                           Byte 0: state (unused for now) */\r
404 #define PropertyTableSizeTimer          ((TRC_CFG_NAME_LEN_TIMER) + 1)\r
405 \r
406 /* TRC_CFG_NEVENTGROUP properties:                      Byte 0-3: state (unused for now)*/\r
407 #define PropertyTableSizeEventGroup     ((TRC_CFG_NAME_LEN_EVENTGROUP) + 4)\r
408 \r
409 /* TRC_CFG_NSTREAMBUFFER properties:                    Byte 0-3: state (unused for now)*/\r
410 #define PropertyTableSizeStreamBuffer   ((TRC_CFG_NAME_LEN_STREAMBUFFER) + 4)\r
411 \r
412 /* TRC_CFG_NMESSAGEBUFFER properties:                   Byte 0-3: state (unused for now)*/\r
413 #define PropertyTableSizeMessageBuffer  ((TRC_CFG_NAME_LEN_MESSAGEBUFFER) + 4)\r
414 \r
415 \r
416 /* The layout of the byte array representing the Object Property Table */\r
417 #define StartIndexQueue                 (0)\r
418 #define StartIndexSemaphore             (StartIndexQueue                + (TRC_CFG_NQUEUE)                      * PropertyTableSizeQueue)\r
419 #define StartIndexMutex                 (StartIndexSemaphore    + (TRC_CFG_NSEMAPHORE)          * PropertyTableSizeSemaphore)\r
420 #define StartIndexTask                  (StartIndexMutex                + (TRC_CFG_NMUTEX)                      * PropertyTableSizeMutex)\r
421 #define StartIndexISR                   (StartIndexTask                 + (TRC_CFG_NTASK)                       * PropertyTableSizeTask)\r
422 #define StartIndexTimer                 (StartIndexISR                  + (TRC_CFG_NISR)                        * PropertyTableSizeISR)\r
423 #define StartIndexEventGroup    (StartIndexTimer                + (TRC_CFG_NTIMER)                      * PropertyTableSizeTimer)\r
424 #define StartIndexStreamBuffer  (StartIndexEventGroup   + (TRC_CFG_NEVENTGROUP)         * PropertyTableSizeEventGroup)\r
425 #define StartIndexMessageBuffer (StartIndexStreamBuffer + (TRC_CFG_NSTREAMBUFFER)       * PropertyTableSizeStreamBuffer)\r
426 \r
427 /* Number of bytes used by the object table */\r
428 #define TRACE_OBJECT_TABLE_SIZE (StartIndexMessageBuffer + (TRC_CFG_NMESSAGEBUFFER) * PropertyTableSizeMessageBuffer)\r
429 \r
430 /* Flag to tell the context of tracePEND_FUNC_CALL_FROM_ISR */\r
431 extern int uiInEventGroupSetBitsFromISR;\r
432 \r
433 /* Initialization of the object property table */\r
434 void vTraceInitObjectPropertyTable(void);\r
435 \r
436 /* Initialization of the handle mechanism, see e.g, prvTraceGetObjectHandle */\r
437 void vTraceInitObjectHandleStack(void);\r
438 \r
439 /* Returns the "Not enough handles" error message for the specified object class */\r
440 const char* pszTraceGetErrorNotEnoughHandles(traceObjectClass objectclass);\r
441 \r
442 void* prvTraceGetCurrentTaskHandle(void);\r
443 \r
444 /******************************************************************************\r
445  * TraceQueueClassTable\r
446  * Translates a FreeRTOS QueueType into trace objects classes (TRACE_CLASS_).\r
447  * Has one entry for each QueueType, gives TRACE_CLASS ID.\r
448  ******************************************************************************/                        \r
449 extern traceObjectClass TraceQueueClassTable[5];\r
450 \r
451 \r
452 /*** Event codes for snapshot mode - must match Tracealyzer config files ******/\r
453 \r
454 #define NULL_EVENT                                      (0x00UL)\r
455 \r
456 /*******************************************************************************\r
457  * EVENTGROUP_DIV\r
458  *\r
459  * Miscellaneous events.\r
460  ******************************************************************************/\r
461 #define EVENTGROUP_DIV                          (NULL_EVENT + 1UL)                                      /*0x01*/\r
462 #define DIV_XPS                                         (EVENTGROUP_DIV + 0UL)                          /*0x01*/\r
463 #define DIV_TASK_READY                          (EVENTGROUP_DIV + 1UL)                          /*0x02*/\r
464 #define DIV_NEW_TIME                            (EVENTGROUP_DIV + 2UL)                          /*0x03*/\r
465 \r
466 /*******************************************************************************\r
467  * EVENTGROUP_TS\r
468  *\r
469  * Events for storing task-switches and interrupts. The RESUME events are\r
470  * generated if the task/interrupt is already marked active.\r
471  ******************************************************************************/\r
472 #define EVENTGROUP_TS                           (EVENTGROUP_DIV + 3UL)                          /*0x04*/\r
473 #define TS_ISR_BEGIN                            (EVENTGROUP_TS + 0UL)                                   /*0x04*/\r
474 #define TS_ISR_RESUME                           (EVENTGROUP_TS + 1UL)                                   /*0x05*/\r
475 #define TS_TASK_BEGIN                           (EVENTGROUP_TS + 2UL)                                   /*0x06*/\r
476 #define TS_TASK_RESUME                          (EVENTGROUP_TS + 3UL)                                   /*0x07*/\r
477 \r
478 /*******************************************************************************\r
479  * EVENTGROUP_OBJCLOSE_NAME\r
480  *\r
481  * About Close Events\r
482  * When an object is evicted from the object property table (object close), two\r
483  * internal events are stored (EVENTGROUP_OBJCLOSE_NAME and\r
484  * EVENTGROUP_OBJCLOSE_PROP), containing the handle-name mapping and object\r
485  * properties valid up to this point.\r
486  ******************************************************************************/\r
487 #define EVENTGROUP_OBJCLOSE_NAME_TRCSUCCESS     (EVENTGROUP_TS + 4UL)                                   /*0x08*/\r
488 \r
489 /*******************************************************************************\r
490  * EVENTGROUP_OBJCLOSE_PROP\r
491  *\r
492  * The internal event carrying properties of deleted objects\r
493  * The handle and object class of the closed object is not stored in this event,\r
494  * but is assumed to be the same as in the preceding CLOSE event. Thus, these\r
495  * two events must be generated from within a critical section.\r
496  * When queues are closed, arg1 is the "state" property (i.e., number of\r
497  * buffered messages/signals).\r
498  * When actors are closed, arg1 is priority, arg2 is handle of the "instance\r
499  * finish" event, and arg3 is event code of the "instance finish" event.\r
500  * In this case, the lower three bits is the object class of the instance finish\r
501  * handle. The lower three bits are not used (always zero) when queues are\r
502  * closed since the queue type is given in the previous OBJCLOSE_NAME event.\r
503  ******************************************************************************/\r
504 #define EVENTGROUP_OBJCLOSE_PROP_TRCSUCCESS     (EVENTGROUP_OBJCLOSE_NAME_TRCSUCCESS + 8UL)             /*0x10*/\r
505 \r
506 /*******************************************************************************\r
507  * EVENTGROUP_CREATE\r
508  *\r
509  * The events in this group are used to log Kernel object creations.\r
510  * The lower three bits in the event code gives the object class, i.e., type of\r
511  * create operation (task, queue, semaphore, etc).\r
512  ******************************************************************************/\r
513 #define EVENTGROUP_CREATE_OBJ_TRCSUCCESS        (EVENTGROUP_OBJCLOSE_PROP_TRCSUCCESS + 8UL)     /*0x18*/\r
514 \r
515 /*******************************************************************************\r
516  * EVENTGROUP_SEND\r
517  *\r
518  * The events in this group are used to log Send/Give events on queues,\r
519  * semaphores and mutexes The lower three bits in the event code gives the\r
520  * object class, i.e., what type of object that is operated on (queue, semaphore\r
521  * or mutex).\r
522  ******************************************************************************/\r
523 #define EVENTGROUP_SEND_TRCSUCCESS      (EVENTGROUP_CREATE_OBJ_TRCSUCCESS + 8UL)                /*0x20*/\r
524 \r
525 /*******************************************************************************\r
526  * EVENTGROUP_RECEIVE\r
527  *\r
528  * The events in this group are used to log Receive/Take events on queues,\r
529  * semaphores and mutexes. The lower three bits in the event code gives the\r
530  * object class, i.e., what type of object that is operated on (queue, semaphore\r
531  * or mutex).\r
532  ******************************************************************************/\r
533 #define EVENTGROUP_RECEIVE_TRCSUCCESS   (EVENTGROUP_SEND_TRCSUCCESS + 8UL)              /*0x28*/\r
534 \r
535 /* Send/Give operations, from ISR */\r
536 #define EVENTGROUP_SEND_FROM_ISR_TRCSUCCESS \\r
537                                                                         (EVENTGROUP_RECEIVE_TRCSUCCESS + 8UL)   /*0x30*/\r
538 \r
539 /* Receive/Take operations, from ISR */\r
540 #define EVENTGROUP_RECEIVE_FROM_ISR_TRCSUCCESS \\r
541                                                         (EVENTGROUP_SEND_FROM_ISR_TRCSUCCESS + 8UL)             /*0x38*/\r
542 \r
543 /* "Failed" event type versions of above (timeout, failed allocation, etc) */\r
544 #define EVENTGROUP_KSE_TRCFAILED \\r
545                                                         (EVENTGROUP_RECEIVE_FROM_ISR_TRCSUCCESS + 8UL)  /*0x40*/\r
546 \r
547 /* Failed create calls - memory allocation failed */\r
548 #define EVENTGROUP_CREATE_OBJ_TRCFAILED (EVENTGROUP_KSE_TRCFAILED)                      /*0x40*/\r
549 \r
550 /* Failed send/give - timeout! */\r
551 #define EVENTGROUP_SEND_TRCFAILED               (EVENTGROUP_CREATE_OBJ_TRCFAILED + 8UL) /*0x48*/\r
552 \r
553 /* Failed receive/take - timeout! */\r
554 #define EVENTGROUP_RECEIVE_TRCFAILED     (EVENTGROUP_SEND_TRCFAILED + 8UL)              /*0x50*/\r
555 \r
556 /* Failed non-blocking send/give - queue full */\r
557 #define EVENTGROUP_SEND_FROM_ISR_TRCFAILED (EVENTGROUP_RECEIVE_TRCFAILED + 8UL) /*0x58*/\r
558 \r
559 /* Failed non-blocking receive/take - queue empty */\r
560 #define EVENTGROUP_RECEIVE_FROM_ISR_TRCFAILED \\r
561                                                                  (EVENTGROUP_SEND_FROM_ISR_TRCFAILED + 8UL)     /*0x60*/\r
562 \r
563 /* Events when blocking on receive/take */\r
564 #define EVENTGROUP_RECEIVE_TRCBLOCK \\r
565                                                         (EVENTGROUP_RECEIVE_FROM_ISR_TRCFAILED + 8UL)   /*0x68*/\r
566 \r
567 /* Events when blocking on send/give */\r
568 #define EVENTGROUP_SEND_TRCBLOCK        (EVENTGROUP_RECEIVE_TRCBLOCK + 8UL)                     /*0x70*/\r
569 \r
570 /* Events on queue peek (receive) */\r
571 #define EVENTGROUP_PEEK_TRCSUCCESS      (EVENTGROUP_SEND_TRCBLOCK + 8UL)                                /*0x78*/\r
572 \r
573 /* Events on object delete (vTaskDelete or vQueueDelete) */\r
574 #define EVENTGROUP_DELETE_OBJ_TRCSUCCESS        (EVENTGROUP_PEEK_TRCSUCCESS + 8UL)      /*0x80*/\r
575 \r
576 /* Other events - object class is implied: TASK */\r
577 #define EVENTGROUP_OTHERS       (EVENTGROUP_DELETE_OBJ_TRCSUCCESS + 8UL)                        /*0x88*/\r
578 #define TASK_DELAY_UNTIL        (EVENTGROUP_OTHERS + 0UL)                                               /*0x88*/\r
579 #define TASK_DELAY                      (EVENTGROUP_OTHERS + 1UL)                                               /*0x89*/\r
580 #define TASK_SUSPEND            (EVENTGROUP_OTHERS + 2UL)                                               /*0x8A*/\r
581 #define TASK_RESUME                     (EVENTGROUP_OTHERS + 3UL)                                               /*0x8B*/\r
582 #define TASK_RESUME_FROM_ISR    (EVENTGROUP_OTHERS + 4UL)                                       /*0x8C*/\r
583 #define TASK_PRIORITY_SET               (EVENTGROUP_OTHERS + 5UL)                                       /*0x8D*/\r
584 #define TASK_PRIORITY_INHERIT   (EVENTGROUP_OTHERS + 6UL)                                       /*0x8E*/\r
585 #define TASK_PRIORITY_DISINHERIT        (EVENTGROUP_OTHERS + 7UL)                               /*0x8F*/\r
586 \r
587 #define EVENTGROUP_MISC_PLACEHOLDER     (EVENTGROUP_OTHERS + 8UL)                               /*0x90*/\r
588 #define PEND_FUNC_CALL          (EVENTGROUP_MISC_PLACEHOLDER+0UL)                               /*0x90*/\r
589 #define PEND_FUNC_CALL_FROM_ISR (EVENTGROUP_MISC_PLACEHOLDER+1UL)                       /*0x91*/\r
590 #define PEND_FUNC_CALL_TRCFAILED (EVENTGROUP_MISC_PLACEHOLDER+2UL)                      /*0x92*/\r
591 #define PEND_FUNC_CALL_FROM_ISR_TRCFAILED (EVENTGROUP_MISC_PLACEHOLDER+3UL)     /*0x93*/\r
592 #define MEM_MALLOC_SIZE (EVENTGROUP_MISC_PLACEHOLDER+4UL)                                       /*0x94*/\r
593 #define MEM_MALLOC_ADDR (EVENTGROUP_MISC_PLACEHOLDER+5UL)                                       /*0x95*/\r
594 #define MEM_FREE_SIZE (EVENTGROUP_MISC_PLACEHOLDER+6UL)                                 /*0x96*/\r
595 #define MEM_FREE_ADDR (EVENTGROUP_MISC_PLACEHOLDER+7UL)                                 /*0x97*/\r
596 \r
597 /* User events */\r
598 #define EVENTGROUP_USEREVENT (EVENTGROUP_MISC_PLACEHOLDER + 8UL)                        /*0x98*/\r
599 #define USER_EVENT (EVENTGROUP_USEREVENT + 0UL)\r
600 \r
601 /* Allow for 0-15 arguments (the number of args is added to event code) */\r
602 #define USER_EVENT_LAST (EVENTGROUP_USEREVENT + 15UL)                                           /*0xA7*/\r
603 \r
604 /*******************************************************************************\r
605  * XTS Event - eXtended TimeStamp events\r
606  * The timestamps used in the recorder are "differential timestamps" (DTS), i.e.\r
607  * the time since the last stored event. The DTS fields are either 1 or 2 bytes\r
608  * in the other events, depending on the bytes available in the event struct.\r
609  * If the time since the last event (the DTS) is larger than allowed for by\r
610  * the DTS field of the current event, an XTS event is inserted immediately\r
611  * before the original event. The XTS event contains up to 3 additional bytes\r
612  * of the DTS value - the higher bytes of the true DTS value. The lower 1-2\r
613  * bytes are stored in the normal DTS field.\r
614  * There are two types of XTS events, XTS8 and XTS16. An XTS8 event is stored\r
615  * when there is only room for 1 byte (8 bit) DTS data in the original event,\r
616  * which means a limit of 0xFF (255UL). The XTS16 is used when the original event\r
617  * has a 16 bit DTS field and thereby can handle values up to 0xFFFF (65535UL).\r
618  *\r
619  * Using a very high frequency time base can result in many XTS events.\r
620  * Preferably, the time between two OS ticks should fit in 16 bits, i.e.,\r
621  * at most 65535. If your time base has a higher frequency, you can define\r
622  * the TRACE\r
623  ******************************************************************************/\r
624 \r
625 #define EVENTGROUP_SYS (EVENTGROUP_USEREVENT + 16UL)                                            /*0xA8*/\r
626 #define XTS8 (EVENTGROUP_SYS + 0UL)                                                                             /*0xA8*/\r
627 #define XTS16 (EVENTGROUP_SYS + 1UL)                                                                            /*0xA9*/\r
628 #define EVENT_BEING_WRITTEN (EVENTGROUP_SYS + 2UL)                                              /*0xAA*/\r
629 #define RESERVED_DUMMY_CODE (EVENTGROUP_SYS + 3UL)                                              /*0xAB*/\r
630 #define LOW_POWER_BEGIN (EVENTGROUP_SYS + 4UL)                                                  /*0xAC*/\r
631 #define LOW_POWER_END (EVENTGROUP_SYS + 5UL)                                                            /*0xAD*/\r
632 #define XID (EVENTGROUP_SYS + 6UL)                                                                              /*0xAE*/\r
633 #define XTS16L (EVENTGROUP_SYS + 7UL)                                                                           /*0xAF*/\r
634 \r
635 #define EVENTGROUP_TIMER (EVENTGROUP_SYS + 8UL)                                                 /*0xB0*/\r
636 #define TIMER_CREATE (EVENTGROUP_TIMER + 0UL)                                                           /*0xB0*/\r
637 #define TIMER_START (EVENTGROUP_TIMER + 1UL)                                                            /*0xB1*/\r
638 #define TIMER_RST (EVENTGROUP_TIMER + 2UL)                                                              /*0xB2*/\r
639 #define TIMER_STOP (EVENTGROUP_TIMER + 3UL)                                                             /*0xB3*/\r
640 #define TIMER_CHANGE_PERIOD (EVENTGROUP_TIMER + 4UL)                                            /*0xB4*/\r
641 #define TIMER_DELETE_OBJ (EVENTGROUP_TIMER + 5UL)                                                               /*0xB5*/\r
642 #define TIMER_START_FROM_ISR (EVENTGROUP_TIMER + 6UL)                                           /*0xB6*/\r
643 #define TIMER_RESET_FROM_ISR (EVENTGROUP_TIMER + 7UL)                                           /*0xB7*/\r
644 #define TIMER_STOP_FROM_ISR (EVENTGROUP_TIMER + 8UL)                                            /*0xB8*/\r
645 \r
646 #define TIMER_CREATE_TRCFAILED (EVENTGROUP_TIMER + 9UL)                                         /*0xB9*/\r
647 #define TIMER_START_TRCFAILED (EVENTGROUP_TIMER + 10UL)                                         /*0xBA*/\r
648 #define TIMER_RESET_TRCFAILED (EVENTGROUP_TIMER + 11UL)                                         /*0xBB*/\r
649 #define TIMER_STOP_TRCFAILED (EVENTGROUP_TIMER + 12UL)                                          /*0xBC*/\r
650 #define TIMER_CHANGE_PERIOD_TRCFAILED (EVENTGROUP_TIMER + 13UL)                         /*0xBD*/\r
651 #define TIMER_DELETE_TRCFAILED (EVENTGROUP_TIMER + 14UL)                                                /*0xBE*/\r
652 #define TIMER_START_FROM_ISR_TRCFAILED (EVENTGROUP_TIMER + 15UL)                                /*0xBF*/\r
653 #define TIMER_RESET_FROM_ISR_TRCFAILED (EVENTGROUP_TIMER + 16UL)                                /*0xC0*/\r
654 #define TIMER_STOP_FROM_ISR_TRCFAILED (EVENTGROUP_TIMER + 17UL)                         /*0xC1*/\r
655 \r
656 #define EVENTGROUP_EG (EVENTGROUP_TIMER + 18UL)                                                 /*0xC2*/\r
657 #define EVENT_GROUP_CREATE (EVENTGROUP_EG + 0UL)                                                        /*0xC2*/\r
658 #define EVENT_GROUP_CREATE_TRCFAILED (EVENTGROUP_EG + 1UL)                                      /*0xC3*/\r
659 #define EVENT_GROUP_SYNC_TRCBLOCK (EVENTGROUP_EG + 2UL)                                         /*0xC4*/\r
660 #define EVENT_GROUP_SYNC_END (EVENTGROUP_EG + 3UL)                                              /*0xC5*/\r
661 #define EVENT_GROUP_WAIT_BITS_TRCBLOCK (EVENTGROUP_EG + 4UL)                                    /*0xC6*/\r
662 #define EVENT_GROUP_WAIT_BITS_END (EVENTGROUP_EG + 5UL)                                 /*0xC7*/\r
663 #define EVENT_GROUP_CLEAR_BITS (EVENTGROUP_EG + 6UL)                                            /*0xC8*/\r
664 #define EVENT_GROUP_CLEAR_BITS_FROM_ISR (EVENTGROUP_EG + 7UL)                           /*0xC9*/\r
665 #define EVENT_GROUP_SET_BITS (EVENTGROUP_EG + 8UL)                                              /*0xCA*/\r
666 #define EVENT_GROUP_DELETE_OBJ (EVENTGROUP_EG + 9UL)                                                    /*0xCB*/\r
667 #define EVENT_GROUP_SYNC_END_TRCFAILED (EVENTGROUP_EG + 10UL)                           /*0xCC*/\r
668 #define EVENT_GROUP_WAIT_BITS_END_TRCFAILED (EVENTGROUP_EG + 11UL)                      /*0xCD*/\r
669 #define EVENT_GROUP_SET_BITS_FROM_ISR (EVENTGROUP_EG + 12UL)                            /*0xCE*/\r
670 #define EVENT_GROUP_SET_BITS_FROM_ISR_TRCFAILED (EVENTGROUP_EG + 13UL)          /*0xCF*/\r
671 \r
672 #define TASK_INSTANCE_FINISHED_NEXT_KSE (EVENTGROUP_EG + 14UL)                  /*0xD0*/\r
673 #define TASK_INSTANCE_FINISHED_DIRECT (EVENTGROUP_EG + 15UL)                            /*0xD1*/\r
674 \r
675 #define TRACE_TASK_NOTIFY_GROUP (EVENTGROUP_EG + 16UL)                                  /*0xD2*/\r
676 #define TRACE_TASK_NOTIFY (TRACE_TASK_NOTIFY_GROUP + 0UL)                                       /*0xD2*/\r
677 #define TRACE_TASK_NOTIFY_TAKE (TRACE_TASK_NOTIFY_GROUP + 1UL)                  /*0xD3*/\r
678 #define TRACE_TASK_NOTIFY_TAKE_TRCBLOCK (TRACE_TASK_NOTIFY_GROUP + 2UL)         /*0xD4*/\r
679 #define TRACE_TASK_NOTIFY_TAKE_TRCFAILED (TRACE_TASK_NOTIFY_GROUP + 3UL)                /*0xD5*/\r
680 #define TRACE_TASK_NOTIFY_WAIT (TRACE_TASK_NOTIFY_GROUP + 4UL)                  /*0xD6*/\r
681 #define TRACE_TASK_NOTIFY_WAIT_TRCBLOCK (TRACE_TASK_NOTIFY_GROUP + 5UL)         /*0xD7*/\r
682 #define TRACE_TASK_NOTIFY_WAIT_TRCFAILED (TRACE_TASK_NOTIFY_GROUP + 6UL)                /*0xD8*/\r
683 #define TRACE_TASK_NOTIFY_FROM_ISR (TRACE_TASK_NOTIFY_GROUP + 7UL)              /*0xD9*/\r
684 #define TRACE_TASK_NOTIFY_GIVE_FROM_ISR (TRACE_TASK_NOTIFY_GROUP + 8UL) /*0xDA*/\r
685 \r
686 #define TIMER_EXPIRED (TRACE_TASK_NOTIFY_GROUP + 9UL)           /* 0xDB */\r
687 \r
688  /* Events on queue peek (receive) */\r
689 #define EVENTGROUP_PEEK_TRCBLOCK        (TRACE_TASK_NOTIFY_GROUP + 10UL)                /*0xDC*/\r
690 /* peek block on queue:                 0xDC    */\r
691 /* peek block on semaphore:             0xDD    */\r
692 /* peek block on mutex:                 0xDE    */\r
693 \r
694 /* Events on queue peek (receive) */\r
695 #define EVENTGROUP_PEEK_TRCFAILED       (EVENTGROUP_PEEK_TRCBLOCK + 3UL)                /*0xDF*/\r
696 /* peek failed on queue:                0xDF    */\r
697 /* peek failed on semaphore:    0xE0    */\r
698 /* peek failed on mutex:                0xE1    */\r
699 \r
700 #define EVENTGROUP_STREAMBUFFER_DIV                                             (EVENTGROUP_PEEK_TRCFAILED + 3UL)                               /*0xE2*/\r
701 #define TRACE_STREAMBUFFER_RESET                                                (EVENTGROUP_STREAMBUFFER_DIV + 0)                       /*0xE2*/\r
702 #define TRACE_MESSAGEBUFFER_RESET                                               (EVENTGROUP_STREAMBUFFER_DIV + 1UL)                     /*0xE3*/\r
703 #define TRACE_STREAMBUFFER_OBJCLOSE_NAME_TRCSUCCESS             (EVENTGROUP_STREAMBUFFER_DIV + 2UL)                     /*0xE4*/\r
704 #define TRACE_MESSAGEBUFFER_OBJCLOSE_NAME_TRCSUCCESS            (EVENTGROUP_STREAMBUFFER_DIV + 3UL)                     /*0xE5*/\r
705 #define TRACE_STREAMBUFFER_OBJCLOSE_PROP_TRCSUCCESS             (EVENTGROUP_STREAMBUFFER_DIV + 4UL)                     /*0xE6*/\r
706 #define TRACE_MESSAGEBUFFER_OBJCLOSE_PROP_TRCSUCCESS            (EVENTGROUP_STREAMBUFFER_DIV + 5UL)                     /*0xE7*/\r
707 \r
708 /* The following are using previously "lost" event codes */\r
709 #define TRACE_STREAMBUFFER_CREATE_OBJ_TRCSUCCESS                        (EVENTGROUP_CREATE_OBJ_TRCSUCCESS + 4UL)                /*0x1C*/\r
710 #define TRACE_STREAMBUFFER_CREATE_OBJ_TRCFAILED                 (EVENTGROUP_CREATE_OBJ_TRCFAILED + 4UL)         /*0x44*/\r
711 #define TRACE_STREAMBUFFER_DELETE_OBJ_TRCSUCCESS                        (EVENTGROUP_DELETE_OBJ_TRCSUCCESS + 4UL)                /*0x84*/\r
712 #define TRACE_STREAMBUFFER_SEND_TRCSUCCESS                                      (EVENTGROUP_SEND_TRCSUCCESS + 3UL)                              /*0x23*/\r
713 #define TRACE_STREAMBUFFER_SEND_TRCBLOCK                                        (EVENTGROUP_SEND_TRCBLOCK + 3UL)                                /*0x73*/\r
714 #define TRACE_STREAMBUFFER_SEND_TRCFAILED                                       (EVENTGROUP_SEND_TRCFAILED + 3UL)                               /*0x4B*/\r
715 #define TRACE_STREAMBUFFER_RECEIVE_TRCSUCCESS                           (EVENTGROUP_RECEIVE_TRCSUCCESS + 3UL)                   /*0x2B*/\r
716 #define TRACE_STREAMBUFFER_RECEIVE_TRCBLOCK                             (EVENTGROUP_RECEIVE_TRCBLOCK + 3UL)                     /*0x6B*/\r
717 #define TRACE_STREAMBUFFER_RECEIVE_TRCFAILED                            (EVENTGROUP_RECEIVE_TRCFAILED + 3UL)                    /*0x53*/\r
718 #define TRACE_STREAMBUFFER_SEND_FROM_ISR_TRCSUCCESS             (EVENTGROUP_SEND_FROM_ISR_TRCSUCCESS + 3UL)     /*0x33*/\r
719 #define TRACE_STREAMBUFFER_SEND_FROM_ISR_TRCFAILED                      (EVENTGROUP_SEND_FROM_ISR_TRCFAILED + 3UL)              /*0x5B*/\r
720 #define TRACE_STREAMBUFFER_RECEIVE_FROM_ISR_TRCSUCCESS          (EVENTGROUP_RECEIVE_FROM_ISR_TRCSUCCESS + 3UL)  /*0x3B*/\r
721 #define TRACE_STREAMBUFFER_RECEIVE_FROM_ISR_TRCFAILED           (EVENTGROUP_RECEIVE_FROM_ISR_TRCFAILED + 3UL)   /*0x63*/\r
722 \r
723 /* The following are using previously "lost" event codes. These macros aren't even directly referenced, instead we do (equivalent STREAMBUFFER code) + 1. */\r
724 #define TRACE_MESSAGEBUFFER_CREATE_OBJ_TRCSUCCESS                       (EVENTGROUP_CREATE_OBJ_TRCSUCCESS + 5UL)                /*0x1D*/\r
725 #define TRACE_MESSAGEBUFFER_CREATE_OBJ_TRCFAILED                        (EVENTGROUP_CREATE_OBJ_TRCFAILED + 5UL)         /*0x45*/\r
726 #define TRACE_MESSAGEBUFFER_DELETE_OBJ_TRCSUCCESS                       (EVENTGROUP_DELETE_OBJ_TRCSUCCESS + 5UL)                /*0x85*/\r
727 #define TRACE_MESSAGEBUFFER_SEND_TRCSUCCESS                             (EVENTGROUP_SEND_TRCSUCCESS + 4UL)                              /*0x24*/\r
728 #define TRACE_MESSAGEBUFFER_SEND_TRCBLOCK                                       (EVENTGROUP_SEND_TRCBLOCK + 4UL)                                /*0x74*/\r
729 #define TRACE_MESSAGEBUFFER_SEND_TRCFAILED                                      (EVENTGROUP_SEND_TRCFAILED + 4UL)                               /*0x4C*/\r
730 #define TRACE_MESSAGEBUFFER_RECEIVE_TRCSUCCESS                          (EVENTGROUP_RECEIVE_TRCSUCCESS + 4UL)                   /*0x2C*/\r
731 #define TRACE_MESSAGEBUFFER_RECEIVE_TRCBLOCK                            (EVENTGROUP_RECEIVE_TRCBLOCK + 4UL)                     /*0x6C*/\r
732 #define TRACE_MESSAGEBUFFER_RECEIVE_TRCFAILED                           (EVENTGROUP_RECEIVE_TRCFAILED + 4UL)                    /*0x54*/\r
733 #define TRACE_MESSAGEBUFFER_SEND_FROM_ISR_TRCSUCCESS            (EVENTGROUP_SEND_FROM_ISR_TRCSUCCESS + 4UL)     /*0x34*/\r
734 #define TRACE_MESSAGEBUFFER_SEND_FROM_ISR_TRCFAILED             (EVENTGROUP_SEND_FROM_ISR_TRCFAILED + 4UL)              /*0x5C*/\r
735 #define TRACE_MESSAGEBUFFER_RECEIVE_FROM_ISR_TRCSUCCESS (EVENTGROUP_RECEIVE_FROM_ISR_TRCSUCCESS + 4UL)  /*0x3C*/\r
736 #define TRACE_MESSAGEBUFFER_RECEIVE_FROM_ISR_TRCFAILED          (EVENTGROUP_RECEIVE_FROM_ISR_TRCFAILED + 4UL)   /*0x64*/\r
737 \r
738 /* LAST EVENT (0xE7) */\r
739 \r
740 /****************************\r
741 * MACROS TO GET TRACE CLASS *\r
742 ****************************/\r
743 #define TRACE_GET_TRACE_CLASS_FROM_TASK_CLASS(kernelClass) (TRACE_CLASS_TASK)\r
744 #define TRACE_GET_TRACE_CLASS_FROM_TASK_OBJECT(pxObject) (TRACE_CLASS_TASK)\r
745 \r
746 #define TRACE_GET_TRACE_CLASS_FROM_QUEUE_CLASS(kernelClass) TraceQueueClassTable[kernelClass]\r
747 #define TRACE_GET_TRACE_CLASS_FROM_QUEUE_OBJECT(pxObject) TRACE_GET_TRACE_CLASS_FROM_QUEUE_CLASS(prvTraceGetQueueType(pxObject))\r
748 \r
749 #define TRACE_GET_TRACE_CLASS_FROM_TIMER_CLASS(kernelClass) (TRACE_CLASS_TIMER)\r
750 #define TRACE_GET_TRACE_CLASS_FROM_TIMER_OBJECT(pxObject) (TRACE_CLASS_TIMER)\r
751 \r
752 #define TRACE_GET_TRACE_CLASS_FROM_EVENTGROUP_CLASS(kernelClass) (TRACE_CLASS_EVENTGROUP)\r
753 #define TRACE_GET_TRACE_CLASS_FROM_EVENTGROUP_OBJECT(pxObject) (TRACE_CLASS_EVENTGROUP)\r
754 \r
755 /* TRACE_GET_TRACE_CLASS_FROM_STREAMBUFFER_CLASS can only be accessed with a parameter indicating if it is a MessageBuffer */\r
756 #define TRACE_GET_TRACE_CLASS_FROM_STREAMBUFFER_CLASS(xIsMessageBuffer) (xIsMessageBuffer == 1 ? TRACE_CLASS_MESSAGEBUFFER : TRACE_CLASS_STREAMBUFFER)\r
757 #define TRACE_GET_TRACE_CLASS_FROM_STREAMBUFFER_OBJECT(pxObject) (prvGetStreamBufferType(pxObject) == 1 ? TRACE_CLASS_MESSAGEBUFFER : TRACE_CLASS_STREAMBUFFER)\r
758 \r
759 /* Generic versions */\r
760 #define TRACE_GET_CLASS_TRACE_CLASS(CLASS, kernelClass) TRACE_GET_TRACE_CLASS_FROM_##CLASS##_CLASS(kernelClass)\r
761 #define TRACE_GET_OBJECT_TRACE_CLASS(CLASS, pxObject) TRACE_GET_TRACE_CLASS_FROM_##CLASS##_OBJECT(pxObject)\r
762 \r
763 /******************************\r
764 * MACROS TO GET OBJECT NUMBER *\r
765 ******************************/\r
766 #define TRACE_GET_TASK_NUMBER(pxTCB) (traceHandle)(prvTraceGetTaskNumberLow16(pxTCB))\r
767 #define TRACE_SET_TASK_NUMBER(pxTCB) prvTraceSetTaskNumberLow16(pxTCB, prvTraceGetObjectHandle(TRACE_GET_OBJECT_TRACE_CLASS(TASK, pxTCB)));\r
768 \r
769 #define TRACE_GET_QUEUE_NUMBER(queue) ( ( traceHandle ) prvTraceGetQueueNumberLow16(queue) )\r
770 #define TRACE_SET_QUEUE_NUMBER(queue) prvTraceSetQueueNumberLow16(queue, (uint16_t)prvTraceGetObjectHandle(TRACE_GET_OBJECT_TRACE_CLASS(QUEUE, queue)));\r
771 \r
772 #if (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0)\r
773 #define TRACE_GET_TIMER_NUMBER(tmr) ( ( traceHandle ) prvTraceGetTimerNumberLow16(tmr) )\r
774 #define TRACE_SET_TIMER_NUMBER(tmr) prvTraceSetTimerNumberLow16(tmr, (uint16_t)prvTraceGetObjectHandle(TRACE_GET_OBJECT_TRACE_CLASS(TIMER, tmr)));\r
775 #else /* (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0) */\r
776 #define TRACE_GET_TIMER_NUMBER(tmr) ( ( traceHandle ) ((Timer_t*)tmr)->uxTimerNumber )\r
777 #define TRACE_SET_TIMER_NUMBER(tmr) ((Timer_t*)tmr)->uxTimerNumber = prvTraceGetObjectHandle(TRACE_GET_OBJECT_TRACE_CLASS(TIMER, tmr));\r
778 #endif /* (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0) */\r
779 \r
780 #if (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0)\r
781 #define TRACE_GET_EVENTGROUP_NUMBER(eg) ( ( traceHandle ) prvTraceGetEventGroupNumberLow16(eg) )\r
782 #define TRACE_SET_EVENTGROUP_NUMBER(eg) prvTraceSetEventGroupNumberLow16(eg, (uint16_t)prvTraceGetObjectHandle(TRACE_GET_OBJECT_TRACE_CLASS(EVENTGROUP, eg)));\r
783 #else /* (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0) */\r
784 #define TRACE_GET_EVENTGROUP_NUMBER(eg) ( ( traceHandle ) uxEventGroupGetNumber(eg) )\r
785 #define TRACE_SET_EVENTGROUP_NUMBER(eg) ((EventGroup_t*)eg)->uxEventGroupNumber = prvTraceGetObjectHandle(TRACE_GET_OBJECT_TRACE_CLASS(EVENTGROUP, eg));\r
786 #endif /* (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0) */\r
787 \r
788 \r
789 #define TRACE_GET_STREAMBUFFER_NUMBER(sb) ( ( traceHandle ) prvTraceGetStreamBufferNumberLow16(sb) )\r
790 #define TRACE_SET_STREAMBUFFER_NUMBER(sb) prvTraceSetStreamBufferNumberLow16(sb, (uint16_t)prvTraceGetObjectHandle(TRACE_GET_OBJECT_TRACE_CLASS(STREAMBUFFER, sb)));\r
791 \r
792 /* Generic versions */\r
793 #define TRACE_GET_OBJECT_NUMBER(CLASS, pxObject) TRACE_GET_##CLASS##_NUMBER(pxObject)\r
794 #define TRACE_SET_OBJECT_NUMBER(CLASS, pxObject) TRACE_SET_##CLASS##_NUMBER(pxObject)\r
795 \r
796 /******************************\r
797 * MACROS TO GET EVENT CODES   *\r
798 ******************************/\r
799 #define TRACE_GET_TASK_CLASS_EVENT_CODE(SERVICE, RESULT, kernelClass) (uint8_t)(EVENTGROUP_##SERVICE##_##RESULT + TRACE_GET_CLASS_TRACE_CLASS(TASK, kernelClass))\r
800 #define TRACE_GET_QUEUE_CLASS_EVENT_CODE(SERVICE, RESULT, kernelClass) (uint8_t)(EVENTGROUP_##SERVICE##_##RESULT + TRACE_GET_CLASS_TRACE_CLASS(QUEUE, kernelClass))\r
801 #define TRACE_GET_TIMER_CLASS_EVENT_CODE(SERVICE, RESULT, kernelClass) -- THIS IS NOT USED --\r
802 #define TRACE_GET_EVENTGROUP_CLASS_EVENT_CODE(SERVICE, RESULT, kernelClass) -- THIS IS NOT USED --\r
803 #define TRACE_GET_STREAMBUFFER_CLASS_EVENT_CODE(SERVICE, RESULT, isMessageBuffer) (uint8_t)(TRACE_STREAMBUFFER_##SERVICE##_##RESULT + (uint8_t)isMessageBuffer)\r
804 \r
805 #define TRACE_GET_TASK_OBJECT_EVENT_CODE(SERVICE, RESULT, pxTCB) (uint8_t)(EVENTGROUP_##SERVICE##_##RESULT + TRACE_CLASS_TASK)\r
806 #define TRACE_GET_QUEUE_OBJECT_EVENT_CODE(SERVICE, RESULT, pxObject) (uint8_t)(EVENTGROUP_##SERVICE##_##RESULT + TRACE_GET_OBJECT_TRACE_CLASS(QUEUE, pxObject))\r
807 #define TRACE_GET_TIMER_OBJECT_EVENT_CODE(SERVICE, RESULT, UNUSED) -- THIS IS NOT USED --\r
808 #define TRACE_GET_EVENTGROUP_OBJECT_EVENT_CODE(SERVICE, RESULT, UNUSED) -- THIS IS NOT USED --\r
809 #define TRACE_GET_STREAMBUFFER_OBJECT_EVENT_CODE(SERVICE, RESULT, pxObject) (uint8_t)(TRACE_STREAMBUFFER_##SERVICE##_##RESULT + prvGetStreamBufferType(pxObject))\r
810 \r
811 /* Generic versions */\r
812 #define TRACE_GET_CLASS_EVENT_CODE(SERVICE, RESULT, CLASS, kernelClass) TRACE_GET_##CLASS##_CLASS_EVENT_CODE(SERVICE, RESULT, kernelClass)\r
813 #define TRACE_GET_OBJECT_EVENT_CODE(SERVICE, RESULT, CLASS, pxObject) TRACE_GET_##CLASS##_OBJECT_EVENT_CODE(SERVICE, RESULT, pxObject)\r
814 \r
815 /******************************\r
816 * SPECIAL MACROS FOR TASKS    *\r
817 ******************************/\r
818 #define TRACE_GET_TASK_PRIORITY(pxTCB) ((uint8_t)pxTCB->uxPriority)\r
819 #define TRACE_GET_TASK_NAME(pxTCB) ((char*)pxTCB->pcTaskName)\r
820 \r
821 /*** The trace macros for snapshot mode **************************************/ \r
822 \r
823 /* A macro that will update the tick count when returning from tickless idle */\r
824 #undef traceINCREASE_TICK_COUNT\r
825 #define traceINCREASE_TICK_COUNT( xCount ) \r
826 \r
827 /* Called for each task that becomes ready */\r
828 #undef traceMOVED_TASK_TO_READY_STATE\r
829 #define traceMOVED_TASK_TO_READY_STATE( pxTCB ) \\r
830         trcKERNEL_HOOKS_MOVED_TASK_TO_READY_STATE(pxTCB);\r
831 \r
832 /* Called on each OS tick. Will call uiPortGetTimestamp to make sure it is called at least once every OS tick. */\r
833 #undef traceTASK_INCREMENT_TICK\r
834 \r
835 #if (TRC_CFG_FREERTOS_VERSION <= TRC_FREERTOS_VERSION_7_4)\r
836 \r
837 #define traceTASK_INCREMENT_TICK( xTickCount ) \\r
838         if (uxSchedulerSuspended == ( unsigned portBASE_TYPE ) pdTRUE || uxMissedTicks == 0) { trcKERNEL_HOOKS_INCREMENT_TICK(); } \\r
839         if (uxSchedulerSuspended == ( unsigned portBASE_TYPE ) pdFALSE) { trcKERNEL_HOOKS_NEW_TIME(DIV_NEW_TIME, xTickCount + 1); }\r
840 \r
841 #else\r
842 \r
843 #define traceTASK_INCREMENT_TICK( xTickCount ) \\r
844         if (uxSchedulerSuspended == ( unsigned portBASE_TYPE ) pdTRUE || uxPendedTicks == 0) { trcKERNEL_HOOKS_INCREMENT_TICK(); } \\r
845         if (uxSchedulerSuspended == ( unsigned portBASE_TYPE ) pdFALSE) { trcKERNEL_HOOKS_NEW_TIME(DIV_NEW_TIME, xTickCount + 1); }\r
846 \r
847 #endif\r
848 \r
849 /* Called on each task-switch */\r
850 #undef traceTASK_SWITCHED_IN\r
851 #define traceTASK_SWITCHED_IN() \\r
852         trcKERNEL_HOOKS_TASK_SWITCH(TRACE_GET_CURRENT_TASK());\r
853 \r
854 /* Called on vTaskCreate */\r
855 #undef traceTASK_CREATE\r
856 #define traceTASK_CREATE(pxNewTCB) \\r
857         if (pxNewTCB != NULL) \\r
858         { \\r
859                 trcKERNEL_HOOKS_TASK_CREATE(TRACE_GET_OBJECT_EVENT_CODE(CREATE_OBJ, TRCSUCCESS, TASK, pxNewTCB), TASK, pxNewTCB); \\r
860         }\r
861 \r
862 /* Called in vTaskCreate, if it fails (typically if the stack can not be allocated) */\r
863 #undef traceTASK_CREATE_FAILED\r
864 #define traceTASK_CREATE_FAILED() \\r
865         trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_NUMERIC_PARAM_ONLY(TRACE_GET_CLASS_EVENT_CODE(CREATE_OBJ, TRCFAILED, TASK, NOT_USED), 0);\r
866 \r
867 /* Called on vTaskDelete */\r
868 #undef traceTASK_DELETE\r
869 #define traceTASK_DELETE( pxTaskToDelete ) \\r
870         { TRACE_ALLOC_CRITICAL_SECTION(); \\r
871         TRACE_ENTER_CRITICAL_SECTION(); \\r
872         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); \\r
873         TRACE_EXIT_CRITICAL_SECTION(); }\r
874 \r
875 #if (TRC_CFG_SCHEDULING_ONLY == 0)\r
876 \r
877 #if defined(configUSE_TICKLESS_IDLE)\r
878 #if (configUSE_TICKLESS_IDLE != 0)\r
879 \r
880 #undef traceLOW_POWER_IDLE_BEGIN\r
881 #define traceLOW_POWER_IDLE_BEGIN() \\r
882         { \\r
883                 extern uint32_t trace_disable_timestamp; \\r
884                 prvTraceStoreLowPower(0); \\r
885                 trace_disable_timestamp = 1; \\r
886         }\r
887 \r
888 #undef traceLOW_POWER_IDLE_END\r
889 #define traceLOW_POWER_IDLE_END() \\r
890         { \\r
891                 extern uint32_t trace_disable_timestamp; \\r
892                 trace_disable_timestamp = 0; \\r
893                 prvTraceStoreLowPower(1); \\r
894         }\r
895 \r
896 #endif /* (configUSE_TICKLESS_IDLE != 0) */\r
897 #endif /* defined(configUSE_TICKLESS_IDLE)  */\r
898 \r
899 /* Called on vTaskSuspend */\r
900 #undef traceTASK_SUSPEND\r
901 #define traceTASK_SUSPEND( pxTaskToSuspend ) \\r
902         trcKERNEL_HOOKS_TASK_SUSPEND(TASK_SUSPEND, pxTaskToSuspend);\r
903 \r
904 /* Called from special case with timer only */\r
905 #undef traceTASK_DELAY_SUSPEND\r
906 #define traceTASK_DELAY_SUSPEND( pxTaskToSuspend ) \\r
907         trcKERNEL_HOOKS_TASK_SUSPEND(TASK_SUSPEND, pxTaskToSuspend); \\r
908         trcKERNEL_HOOKS_SET_TASK_INSTANCE_FINISHED();\r
909 \r
910 /* Called on vTaskDelay - note the use of FreeRTOS variable xTicksToDelay */\r
911 #undef traceTASK_DELAY\r
912 #define traceTASK_DELAY() \\r
913         trcKERNEL_HOOKS_TASK_DELAY(TASK_DELAY, pxCurrentTCB, xTicksToDelay); \\r
914         trcKERNEL_HOOKS_SET_TASK_INSTANCE_FINISHED();\r
915 \r
916 /* Called on vTaskDelayUntil - note the use of FreeRTOS variable xTimeToWake */\r
917 #undef traceTASK_DELAY_UNTIL\r
918 #if TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_9_0_0\r
919 #define traceTASK_DELAY_UNTIL(xTimeToWake) \\r
920         trcKERNEL_HOOKS_TASK_DELAY(TASK_DELAY_UNTIL, pxCurrentTCB, xTimeToWake); \\r
921         trcKERNEL_HOOKS_SET_TASK_INSTANCE_FINISHED();\r
922 #else /* TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_9_0_0 */\r
923 #define traceTASK_DELAY_UNTIL() \\r
924         trcKERNEL_HOOKS_TASK_DELAY(TASK_DELAY_UNTIL, pxCurrentTCB, xTimeToWake); \\r
925         trcKERNEL_HOOKS_SET_TASK_INSTANCE_FINISHED();\r
926 #endif /* TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_9_0_0 */\r
927 \r
928 /* Called in xQueueCreate, and thereby for all other object based on queues, such as semaphores. */\r
929 #undef traceQUEUE_CREATE\r
930 #define traceQUEUE_CREATE( pxNewQueue ) \\r
931         trcKERNEL_HOOKS_OBJECT_CREATE(TRACE_GET_OBJECT_EVENT_CODE(CREATE_OBJ, TRCSUCCESS, QUEUE, pxNewQueue), QUEUE, pxNewQueue);\r
932 \r
933 /* Called in xQueueCreate, if the queue creation fails */\r
934 #undef traceQUEUE_CREATE_FAILED\r
935 #define traceQUEUE_CREATE_FAILED( queueType ) \\r
936         trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_NUMERIC_PARAM_ONLY(TRACE_GET_CLASS_EVENT_CODE(CREATE_OBJ, TRCFAILED, QUEUE, queueType), 0);\r
937 \r
938 /* Called on vQueueDelete */\r
939 #undef traceQUEUE_DELETE\r
940 #define traceQUEUE_DELETE( pxQueue ) \\r
941         { TRACE_ALLOC_CRITICAL_SECTION(); \\r
942         TRACE_ENTER_CRITICAL_SECTION(); \\r
943         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); \\r
944         TRACE_EXIT_CRITICAL_SECTION(); }\r
945 \r
946 /* This macro is not necessary as of FreeRTOS v9.0.0 */\r
947 #if (TRC_CFG_FREERTOS_VERSION < TRC_FREERTOS_VERSION_9_0_0)\r
948 /* Called in xQueueCreateMutex, and thereby also from xSemaphoreCreateMutex and xSemaphoreCreateRecursiveMutex */\r
949 #undef traceCREATE_MUTEX\r
950 #define traceCREATE_MUTEX( pxNewQueue ) \\r
951         trcKERNEL_HOOKS_OBJECT_CREATE(TRACE_GET_OBJECT_EVENT_CODE(CREATE_OBJ, TRCSUCCESS, QUEUE, pxNewQueue), QUEUE, pxNewQueue);\r
952         \r
953 /* Called in xQueueCreateMutex when the operation fails (when memory allocation fails) */\r
954 #undef traceCREATE_MUTEX_FAILED\r
955 #define traceCREATE_MUTEX_FAILED() \\r
956         trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_NUMERIC_PARAM_ONLY(TRACE_GET_CLASS_EVENT_CODE(CREATE_OBJ, TRCFAILED, QUEUE, queueQUEUE_TYPE_MUTEX), 0);\r
957 #endif /* (TRC_CFG_FREERTOS_VERSION < TRC_FREERTOS_VERSION_9_0_0) */\r
958 \r
959 /* Called when the Mutex can not be given, since not holder */\r
960 #undef traceGIVE_MUTEX_RECURSIVE_FAILED\r
961 #define traceGIVE_MUTEX_RECURSIVE_FAILED( pxMutex ) \\r
962         trcKERNEL_HOOKS_KERNEL_SERVICE(TRACE_GET_OBJECT_EVENT_CODE(SEND, TRCFAILED, QUEUE, pxMutex), QUEUE, pxMutex);\r
963 \r
964 /* Called when a message is sent to a queue */  /* CS IS NEW ! */\r
965 #undef traceQUEUE_SEND\r
966 #define traceQUEUE_SEND( pxQueue ) \\r
967         trcKERNEL_HOOKS_KERNEL_SERVICE(TRACE_GET_OBJECT_EVENT_CODE(SEND, TRCSUCCESS, QUEUE, pxQueue), QUEUE, pxQueue); \\r
968         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));\r
969 \r
970 /* Called when a message failed to be sent to a queue (timeout) */\r
971 #undef traceQUEUE_SEND_FAILED\r
972 #define traceQUEUE_SEND_FAILED( pxQueue ) \\r
973         trcKERNEL_HOOKS_KERNEL_SERVICE(TRACE_GET_OBJECT_EVENT_CODE(SEND, TRCFAILED, QUEUE, pxQueue), QUEUE, pxQueue);\r
974 \r
975 /* Called when the task is blocked due to a send operation on a full queue */\r
976 #undef traceBLOCKING_ON_QUEUE_SEND\r
977 #define traceBLOCKING_ON_QUEUE_SEND( pxQueue ) \\r
978         trcKERNEL_HOOKS_KERNEL_SERVICE(TRACE_GET_OBJECT_EVENT_CODE(SEND, TRCBLOCK, QUEUE, pxQueue), QUEUE, pxQueue);\r
979 \r
980 /* Called when a message is received from a queue */\r
981 #undef traceQUEUE_RECEIVE\r
982 #define traceQUEUE_RECEIVE( pxQueue ) \\r
983         if (isQueueReceiveHookActuallyPeek) \\r
984         { \\r
985                 trcKERNEL_HOOKS_KERNEL_SERVICE(TRACE_GET_OBJECT_EVENT_CODE(PEEK, TRCSUCCESS, QUEUE, pxQueue), QUEUE, pxQueue); \\r
986         } \\r
987         else \\r
988         { \\r
989                 trcKERNEL_HOOKS_KERNEL_SERVICE(TRACE_GET_OBJECT_EVENT_CODE(RECEIVE, TRCSUCCESS, QUEUE, pxQueue), QUEUE, pxQueue); \\r
990         } \\r
991         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));\r
992 \r
993 /* Called when a receive operation on a queue fails (timeout) */\r
994 #undef traceQUEUE_RECEIVE_FAILED\r
995 #define traceQUEUE_RECEIVE_FAILED( pxQueue ) \\r
996         if (isQueueReceiveHookActuallyPeek) \\r
997         { \\r
998                 trcKERNEL_HOOKS_KERNEL_SERVICE(TRACE_GET_OBJECT_EVENT_CODE(PEEK, TRCFAILED, QUEUE, pxQueue), QUEUE, pxQueue); \\r
999         } \\r
1000         else \\r
1001         { \\r
1002                 trcKERNEL_HOOKS_KERNEL_SERVICE(TRACE_GET_OBJECT_EVENT_CODE(RECEIVE, TRCFAILED, QUEUE, pxQueue), QUEUE, pxQueue); \\r
1003         }\r
1004 \r
1005 /* Called when the task is blocked due to a receive operation on an empty queue */\r
1006 #undef traceBLOCKING_ON_QUEUE_RECEIVE\r
1007 #define traceBLOCKING_ON_QUEUE_RECEIVE( pxQueue ) \\r
1008         if (isQueueReceiveHookActuallyPeek) \\r
1009         { \\r
1010                 trcKERNEL_HOOKS_KERNEL_SERVICE(TRACE_GET_OBJECT_EVENT_CODE(PEEK, TRCBLOCK, QUEUE, pxQueue), QUEUE, pxQueue); \\r
1011         } \\r
1012         else \\r
1013         { \\r
1014                 trcKERNEL_HOOKS_KERNEL_SERVICE(TRACE_GET_OBJECT_EVENT_CODE(RECEIVE, TRCBLOCK, QUEUE, pxQueue), QUEUE, pxQueue); \\r
1015         } \\r
1016         if (TRACE_GET_OBJECT_TRACE_CLASS(QUEUE, pxQueue) != TRACE_CLASS_MUTEX) \\r
1017         { \\r
1018                 trcKERNEL_HOOKS_SET_TASK_INSTANCE_FINISHED(); \\r
1019         }\r
1020 \r
1021 /* Called on xQueuePeek */\r
1022 #undef traceQUEUE_PEEK\r
1023 #define traceQUEUE_PEEK( pxQueue ) \\r
1024         trcKERNEL_HOOKS_KERNEL_SERVICE(TRACE_GET_OBJECT_EVENT_CODE(PEEK, TRCSUCCESS, QUEUE, pxQueue), QUEUE, pxQueue);\r
1025 \r
1026 /* Called on xQueuePeek fail/timeout (added in FreeRTOS v9.0.2) */\r
1027 #undef traceQUEUE_PEEK_FAILED\r
1028 #define traceQUEUE_PEEK_FAILED( pxQueue ) \\r
1029         trcKERNEL_HOOKS_KERNEL_SERVICE(TRACE_GET_OBJECT_EVENT_CODE(PEEK, TRCFAILED, QUEUE, pxQueue), QUEUE, pxQueue);\r
1030 \r
1031 /* Called on xQueuePeek blocking (added in FreeRTOS v9.0.2) */\r
1032 #undef traceBLOCKING_ON_QUEUE_PEEK\r
1033 #define traceBLOCKING_ON_QUEUE_PEEK( pxQueue ) \\r
1034         trcKERNEL_HOOKS_KERNEL_SERVICE(TRACE_GET_OBJECT_EVENT_CODE(PEEK, TRCBLOCK, QUEUE, pxQueue), QUEUE, pxQueue); \\r
1035         if (TRACE_GET_OBJECT_TRACE_CLASS(QUEUE, pxQueue) != TRACE_CLASS_MUTEX) \\r
1036         { \\r
1037                 trcKERNEL_HOOKS_SET_TASK_INSTANCE_FINISHED(); \\r
1038         }\r
1039 \r
1040 /* Called when a message is sent from interrupt context, e.g., using xQueueSendFromISR */\r
1041 #undef traceQUEUE_SEND_FROM_ISR\r
1042 #define traceQUEUE_SEND_FROM_ISR( pxQueue ) \\r
1043         trcKERNEL_HOOKS_KERNEL_SERVICE_FROM_ISR(TRACE_GET_OBJECT_EVENT_CODE(SEND_FROM_ISR, TRCSUCCESS, QUEUE, pxQueue), QUEUE, pxQueue); \\r
1044         trcKERNEL_HOOKS_SET_OBJECT_STATE(QUEUE, pxQueue, (uint8_t)(pxQueue->uxMessagesWaiting + 1));\r
1045 \r
1046 /* Called when a message send from interrupt context fails (since the queue was full) */\r
1047 #undef traceQUEUE_SEND_FROM_ISR_FAILED\r
1048 #define traceQUEUE_SEND_FROM_ISR_FAILED( pxQueue ) \\r
1049         trcKERNEL_HOOKS_KERNEL_SERVICE_FROM_ISR(TRACE_GET_OBJECT_EVENT_CODE(SEND_FROM_ISR, TRCFAILED, QUEUE, pxQueue), QUEUE, pxQueue);\r
1050 \r
1051 /* Called when a message is received in interrupt context, e.g., using xQueueReceiveFromISR */\r
1052 #undef traceQUEUE_RECEIVE_FROM_ISR\r
1053 #define traceQUEUE_RECEIVE_FROM_ISR( pxQueue ) \\r
1054         trcKERNEL_HOOKS_KERNEL_SERVICE_FROM_ISR(TRACE_GET_OBJECT_EVENT_CODE(RECEIVE_FROM_ISR, TRCSUCCESS, QUEUE, pxQueue), QUEUE, pxQueue); \\r
1055         trcKERNEL_HOOKS_SET_OBJECT_STATE(QUEUE, pxQueue, (uint8_t)(pxQueue->uxMessagesWaiting - 1));\r
1056 \r
1057 /* Called when a message receive from interrupt context fails (since the queue was empty) */\r
1058 #undef traceQUEUE_RECEIVE_FROM_ISR_FAILED\r
1059 #define traceQUEUE_RECEIVE_FROM_ISR_FAILED( pxQueue ) \\r
1060         trcKERNEL_HOOKS_KERNEL_SERVICE_FROM_ISR(TRACE_GET_OBJECT_EVENT_CODE(RECEIVE_FROM_ISR, TRCFAILED, QUEUE, pxQueue), QUEUE, pxQueue);\r
1061 \r
1062 #undef traceQUEUE_REGISTRY_ADD\r
1063 #define traceQUEUE_REGISTRY_ADD(object, name) prvTraceSetObjectName(TRACE_GET_OBJECT_TRACE_CLASS(QUEUE, object), TRACE_GET_OBJECT_NUMBER(QUEUE, object), name);\r
1064 \r
1065 /* Called in vTaskPrioritySet */\r
1066 #undef traceTASK_PRIORITY_SET\r
1067 #define traceTASK_PRIORITY_SET( pxTask, uxNewPriority ) \\r
1068         trcKERNEL_HOOKS_TASK_PRIORITY_CHANGE(TASK_PRIORITY_SET, pxTask, uxNewPriority);\r
1069 \r
1070 /* Called in vTaskPriorityInherit, which is called by Mutex operations */\r
1071 #undef traceTASK_PRIORITY_INHERIT\r
1072 #define traceTASK_PRIORITY_INHERIT( pxTask, uxNewPriority ) \\r
1073         trcKERNEL_HOOKS_TASK_PRIORITY_CHANGE(TASK_PRIORITY_INHERIT, pxTask, uxNewPriority);\r
1074 \r
1075 /* Called in vTaskPriorityDisinherit, which is called by Mutex operations */\r
1076 #undef traceTASK_PRIORITY_DISINHERIT\r
1077 #define traceTASK_PRIORITY_DISINHERIT( pxTask, uxNewPriority ) \\r
1078         trcKERNEL_HOOKS_TASK_PRIORITY_CHANGE(TASK_PRIORITY_DISINHERIT, pxTask, uxNewPriority);\r
1079 \r
1080 /* Called in vTaskResume */\r
1081 #undef traceTASK_RESUME\r
1082 #define traceTASK_RESUME( pxTaskToResume ) \\r
1083         trcKERNEL_HOOKS_TASK_RESUME(TASK_RESUME, pxTaskToResume);\r
1084 \r
1085 /* Called in vTaskResumeFromISR */\r
1086 #undef traceTASK_RESUME_FROM_ISR\r
1087 #define traceTASK_RESUME_FROM_ISR( pxTaskToResume ) \\r
1088         trcKERNEL_HOOKS_TASK_RESUME_FROM_ISR(TASK_RESUME_FROM_ISR, pxTaskToResume);\r
1089 \r
1090 \r
1091 #if (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_8_X)\r
1092 \r
1093 #if (TRC_CFG_INCLUDE_MEMMANG_EVENTS == 1)\r
1094 \r
1095 extern void vTraceStoreMemMangEvent(uint32_t ecode, uint32_t address, int32_t size);\r
1096 \r
1097 /* MALLOC and FREE are always stored, no matter if they happen inside filtered task */\r
1098 #undef traceMALLOC\r
1099 #define traceMALLOC( pvAddress, uiSize ) \\r
1100         if (pvAddress != 0) \\r
1101                 vTraceStoreMemMangEvent(MEM_MALLOC_SIZE, ( uint32_t ) pvAddress, (int32_t)uiSize);\r
1102 \r
1103 #undef traceFREE\r
1104 #define traceFREE( pvAddress, uiSize ) \\r
1105         vTraceStoreMemMangEvent(MEM_FREE_SIZE, ( uint32_t ) pvAddress, -((int32_t)uiSize));\r
1106 \r
1107 #endif /* (TRC_CFG_INCLUDE_MEMMANG_EVENTS == 1) */\r
1108 \r
1109 #if (TRC_CFG_INCLUDE_TIMER_EVENTS == 1)\r
1110 \r
1111 /* Called in timer.c - xTimerCreate */\r
1112 #undef traceTIMER_CREATE\r
1113 #define traceTIMER_CREATE(tmr) \\r
1114         trcKERNEL_HOOKS_OBJECT_CREATE(TIMER_CREATE, TIMER, tmr);\r
1115 \r
1116 #undef traceTIMER_CREATE_FAILED\r
1117 #define traceTIMER_CREATE_FAILED() \\r
1118         trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_NUMERIC_PARAM_ONLY(TIMER_CREATE_TRCFAILED, 0);\r
1119 \r
1120 /* Note that xCommandID can never be tmrCOMMAND_EXECUTE_CALLBACK (-1) since the trace macro is not called in that case */\r
1121 #undef traceTIMER_COMMAND_SEND\r
1122 #define traceTIMER_COMMAND_SEND(tmr, xCommandID, xOptionalValue, xReturn) \\r
1123         if (xCommandID > tmrCOMMAND_START_DONT_TRACE) \\r
1124         { \\r
1125                 if (xCommandID == tmrCOMMAND_CHANGE_PERIOD) \\r
1126                 { \\r
1127                         if (xReturn == pdPASS) { \\r
1128                                 trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM(TIMER_CHANGE_PERIOD, TIMER, tmr, xOptionalValue); \\r
1129                         } \\r
1130                         else \\r
1131                         { \\r
1132                                 trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM(TIMER_CHANGE_PERIOD_TRCFAILED, TIMER, tmr, xOptionalValue); \\r
1133                         } \\r
1134                 } \\r
1135                 else if ((xCommandID == tmrCOMMAND_DELETE) && (xReturn == pdPASS)) \\r
1136                 { \\r
1137                         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); \\r
1138                 } \\r
1139                 else \\r
1140                 { \\r
1141                         trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM(EVENTGROUP_TIMER + (uint32_t)xCommandID + ((xReturn == pdPASS) ? 0 : (TIMER_CREATE_TRCFAILED - TIMER_CREATE)), TIMER, tmr, xOptionalValue); \\r
1142                 }\\r
1143         }\r
1144 \r
1145 #undef traceTIMER_EXPIRED\r
1146 #define traceTIMER_EXPIRED(tmr) \\r
1147         trcKERNEL_HOOKS_KERNEL_SERVICE(TIMER_EXPIRED, TIMER, tmr);\r
1148 \r
1149 #endif /* (TRC_CFG_INCLUDE_TIMER_EVENTS == 1) */\r
1150 \r
1151 #if (TRC_CFG_INCLUDE_PEND_FUNC_CALL_EVENTS == 1)\r
1152 \r
1153 #undef tracePEND_FUNC_CALL\r
1154 #define tracePEND_FUNC_CALL(func, arg1, arg2, ret) \\r
1155         if (ret == pdPASS){ \\r
1156                 trcKERNEL_HOOKS_KERNEL_SERVICE(PEND_FUNC_CALL, TASK, xTimerGetTimerDaemonTaskHandle() ); \\r
1157         } \\r
1158         else \\r
1159         { \\r
1160                 trcKERNEL_HOOKS_KERNEL_SERVICE(PEND_FUNC_CALL_TRCFAILED, TASK, xTimerGetTimerDaemonTaskHandle() ); \\r
1161         }\r
1162 \r
1163 #undef tracePEND_FUNC_CALL_FROM_ISR\r
1164 #define tracePEND_FUNC_CALL_FROM_ISR(func, arg1, arg2, ret) \\r
1165         if (! uiInEventGroupSetBitsFromISR) \\r
1166                 prvTraceStoreKernelCall(PEND_FUNC_CALL_FROM_ISR, TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(xTimerGetTimerDaemonTaskHandle()) ); \\r
1167         uiInEventGroupSetBitsFromISR = 0;\r
1168 \r
1169 #endif /* (TRC_CFG_INCLUDE_PEND_FUNC_CALL_EVENTS == 1) */\r
1170 \r
1171 #endif /* (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_8_X) */\r
1172 \r
1173 #if (TRC_CFG_INCLUDE_EVENT_GROUP_EVENTS == 1)\r
1174 \r
1175 #undef traceEVENT_GROUP_CREATE\r
1176 #define traceEVENT_GROUP_CREATE(eg) \\r
1177         trcKERNEL_HOOKS_OBJECT_CREATE(EVENT_GROUP_CREATE, EVENTGROUP, eg);\r
1178 \r
1179 #undef traceEVENT_GROUP_CREATE_FAILED\r
1180 #define traceEVENT_GROUP_CREATE_FAILED() \\r
1181         trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_NUMERIC_PARAM_ONLY(EVENT_GROUP_CREATE_TRCFAILED, 0);\r
1182 \r
1183 #undef traceEVENT_GROUP_DELETE\r
1184 #define traceEVENT_GROUP_DELETE(eg) \\r
1185         { TRACE_ALLOC_CRITICAL_SECTION(); \\r
1186         TRACE_ENTER_CRITICAL_SECTION(); \\r
1187         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); \\r
1188         TRACE_EXIT_CRITICAL_SECTION(); }\r
1189 \r
1190 #undef traceEVENT_GROUP_SYNC_BLOCK\r
1191 #define traceEVENT_GROUP_SYNC_BLOCK(eg, bitsToSet, bitsToWaitFor) \\r
1192         trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM(EVENT_GROUP_SYNC_TRCBLOCK, EVENTGROUP, eg, bitsToWaitFor);\r
1193 \r
1194 #undef traceEVENT_GROUP_SYNC_END\r
1195 #define traceEVENT_GROUP_SYNC_END(eg, bitsToSet, bitsToWaitFor, wasTimeout) \\r
1196         if (wasTimeout) \\r
1197         { \\r
1198                 trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM(EVENT_GROUP_SYNC_END_TRCFAILED, EVENTGROUP, eg, bitsToWaitFor); \\r
1199         } \\r
1200         else \\r
1201         { \\r
1202                 trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM(EVENT_GROUP_SYNC_END, EVENTGROUP, eg, bitsToWaitFor); \\r
1203         }\r
1204 \r
1205 #undef traceEVENT_GROUP_WAIT_BITS_BLOCK\r
1206 #define traceEVENT_GROUP_WAIT_BITS_BLOCK(eg, bitsToWaitFor) \\r
1207         trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM(EVENT_GROUP_WAIT_BITS_TRCBLOCK, EVENTGROUP, eg, bitsToWaitFor); \\r
1208         trcKERNEL_HOOKS_SET_TASK_INSTANCE_FINISHED();\r
1209 \r
1210 #undef traceEVENT_GROUP_WAIT_BITS_END\r
1211 #define traceEVENT_GROUP_WAIT_BITS_END(eg, bitsToWaitFor, wasTimeout) \\r
1212         if (wasTimeout) \\r
1213         { \\r
1214                 trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM(EVENT_GROUP_WAIT_BITS_END_TRCFAILED, EVENTGROUP, eg, bitsToWaitFor); \\r
1215         } \\r
1216         else \\r
1217         { \\r
1218                 trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM(EVENT_GROUP_WAIT_BITS_END, EVENTGROUP, eg, bitsToWaitFor); \\r
1219         }\r
1220 \r
1221 #undef traceEVENT_GROUP_CLEAR_BITS\r
1222 #define traceEVENT_GROUP_CLEAR_BITS(eg, bitsToClear) \\r
1223         trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM(EVENT_GROUP_CLEAR_BITS, EVENTGROUP, eg, bitsToClear);\r
1224 \r
1225 #undef traceEVENT_GROUP_CLEAR_BITS_FROM_ISR\r
1226 #define traceEVENT_GROUP_CLEAR_BITS_FROM_ISR(eg, bitsToClear) \\r
1227         trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM_FROM_ISR(EVENT_GROUP_CLEAR_BITS_FROM_ISR, EVENTGROUP, eg, bitsToClear);\r
1228 \r
1229 #undef traceEVENT_GROUP_SET_BITS\r
1230 #define traceEVENT_GROUP_SET_BITS(eg, bitsToSet) \\r
1231         trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM(EVENT_GROUP_SET_BITS, EVENTGROUP, eg, bitsToSet);\r
1232 \r
1233 #undef traceEVENT_GROUP_SET_BITS_FROM_ISR\r
1234 #define traceEVENT_GROUP_SET_BITS_FROM_ISR(eg, bitsToSet) \\r
1235         trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM_FROM_ISR(EVENT_GROUP_SET_BITS_FROM_ISR, EVENTGROUP, eg, bitsToSet); \\r
1236         uiInEventGroupSetBitsFromISR = 1;\r
1237 \r
1238 #endif /* (TRC_CFG_INCLUDE_EVENT_GROUP_EVENTS == 1) */\r
1239 \r
1240 #undef traceTASK_NOTIFY_TAKE\r
1241 #if (TRC_CFG_FREERTOS_VERSION < TRC_FREERTOS_VERSION_9_0_0)\r
1242 #define traceTASK_NOTIFY_TAKE() \\r
1243         if (pxCurrentTCB->eNotifyState == eNotified){ \\r
1244                 trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM(TRACE_TASK_NOTIFY_TAKE, TASK, pxCurrentTCB, xTicksToWait); \\r
1245         } \\r
1246         else{ \\r
1247                 trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM(TRACE_TASK_NOTIFY_TAKE_TRCFAILED, TASK, pxCurrentTCB, xTicksToWait); \\r
1248         }\r
1249 #else /* TRC_CFG_FREERTOS_VERSION < TRC_FREERTOS_VERSION_9_0_0 */\r
1250 #define traceTASK_NOTIFY_TAKE() \\r
1251         if (pxCurrentTCB->ucNotifyState == taskNOTIFICATION_RECEIVED){ \\r
1252                 trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM(TRACE_TASK_NOTIFY_TAKE, TASK, pxCurrentTCB, xTicksToWait); \\r
1253         }else{ \\r
1254                 trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM(TRACE_TASK_NOTIFY_TAKE_TRCFAILED, TASK, pxCurrentTCB, xTicksToWait);}\r
1255 #endif /* TRC_CFG_FREERTOS_VERSION < TRC_FREERTOS_VERSION_9_0_0 */\r
1256 \r
1257 #undef traceTASK_NOTIFY_TAKE_BLOCK\r
1258 #define traceTASK_NOTIFY_TAKE_BLOCK() \\r
1259         trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM(TRACE_TASK_NOTIFY_TAKE_TRCBLOCK, TASK, pxCurrentTCB, xTicksToWait); \\r
1260         trcKERNEL_HOOKS_SET_TASK_INSTANCE_FINISHED();\r
1261 \r
1262 #undef traceTASK_NOTIFY_WAIT\r
1263 #if (TRC_CFG_FREERTOS_VERSION < TRC_FREERTOS_VERSION_9_0_0)\r
1264 #define traceTASK_NOTIFY_WAIT() \\r
1265         if (TRACE_GET_TASK_FILTER(pxCurrentTCB) & CurrentFilterMask) \\r
1266         { \\r
1267                 if (pxCurrentTCB->eNotifyState == eNotified) \\r
1268                         prvTraceStoreKernelCallWithParam(TRACE_TASK_NOTIFY_WAIT, TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxCurrentTCB), xTicksToWait); \\r
1269                 else \\r
1270                         prvTraceStoreKernelCallWithParam(TRACE_TASK_NOTIFY_WAIT_TRCFAILED, TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxCurrentTCB), xTicksToWait); \\r
1271         }\r
1272 #else /* TRC_CFG_FREERTOS_VERSION < TRC_FREERTOS_VERSION_9_0_0 */\r
1273 #define traceTASK_NOTIFY_WAIT() \\r
1274         if (TRACE_GET_TASK_FILTER(pxCurrentTCB) & CurrentFilterMask) \\r
1275         { \\r
1276                 if (pxCurrentTCB->ucNotifyState == taskNOTIFICATION_RECEIVED) \\r
1277                         prvTraceStoreKernelCallWithParam(TRACE_TASK_NOTIFY_WAIT, TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxCurrentTCB), xTicksToWait); \\r
1278                 else \\r
1279                         prvTraceStoreKernelCallWithParam(TRACE_TASK_NOTIFY_WAIT_TRCFAILED, TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxCurrentTCB), xTicksToWait); \\r
1280         }\r
1281 #endif /* TRC_CFG_FREERTOS_VERSION < TRC_FREERTOS_VERSION_9_0_0 */\r
1282 \r
1283 #undef traceTASK_NOTIFY_WAIT_BLOCK\r
1284 #define traceTASK_NOTIFY_WAIT_BLOCK() \\r
1285         if (TRACE_GET_TASK_FILTER(pxCurrentTCB) & CurrentFilterMask) \\r
1286                 prvTraceStoreKernelCallWithParam(TRACE_TASK_NOTIFY_WAIT_TRCBLOCK, TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxCurrentTCB), xTicksToWait); \\r
1287         trcKERNEL_HOOKS_SET_TASK_INSTANCE_FINISHED();\r
1288 \r
1289 #undef traceTASK_NOTIFY\r
1290 #define traceTASK_NOTIFY() \\r
1291         if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
1292                 if (TRACE_GET_TASK_FILTER(xTaskToNotify) & CurrentFilterMask) \\r
1293                         prvTraceStoreKernelCall(TRACE_TASK_NOTIFY, TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(xTaskToNotify));\r
1294 \r
1295 #undef traceTASK_NOTIFY_FROM_ISR\r
1296 #define traceTASK_NOTIFY_FROM_ISR() \\r
1297         if (TRACE_GET_TASK_FILTER(xTaskToNotify) & CurrentFilterMask) \\r
1298                 prvTraceStoreKernelCall(TRACE_TASK_NOTIFY_FROM_ISR, TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(xTaskToNotify));\r
1299         \r
1300 #undef traceTASK_NOTIFY_GIVE_FROM_ISR\r
1301 #define traceTASK_NOTIFY_GIVE_FROM_ISR() \\r
1302         if (TRACE_GET_TASK_FILTER(xTaskToNotify) & CurrentFilterMask) \\r
1303                 prvTraceStoreKernelCall(TRACE_TASK_NOTIFY_GIVE_FROM_ISR, TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(xTaskToNotify));\r
1304 \r
1305 #if (TRC_CFG_INCLUDE_STREAM_BUFFER_EVENTS == 1)\r
1306 \r
1307 #undef traceSTREAM_BUFFER_CREATE\r
1308 #define traceSTREAM_BUFFER_CREATE( pxStreamBuffer, xIsMessageBuffer ) \\r
1309         trcKERNEL_HOOKS_OBJECT_CREATE(TRACE_GET_OBJECT_EVENT_CODE(CREATE_OBJ, TRCSUCCESS, STREAMBUFFER, pxStreamBuffer), STREAMBUFFER, pxStreamBuffer);\r
1310 \r
1311 #undef traceSTREAM_BUFFER_CREATE_FAILED\r
1312 #define traceSTREAM_BUFFER_CREATE_FAILED( xIsMessageBuffer ) \\r
1313         trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_NUMERIC_PARAM_ONLY(TRACE_GET_CLASS_EVENT_CODE(CREATE_OBJ, TRCFAILED, STREAMBUFFER, xIsMessageBuffer), 0);\r
1314 \r
1315 #if 0 /*_RB_ Not defined anywhere*/\r
1316 #undef traceSTREAM_BUFFER_CREATE_STATIC_FAILED\r
1317 #define traceSTREAM_BUFFER_CREATE_STATIC_FAILED( xReturn, xIsMessageBuffer ) \\r
1318         traceSTREAM_BUFFER_CREATE_TRCFAILED( xIsMessageBuffer )\r
1319 #endif\r
1320 \r
1321 #undef traceSTREAM_BUFFER_DELETE\r
1322 #define traceSTREAM_BUFFER_DELETE( xStreamBuffer ) \\r
1323         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);\r
1324 \r
1325 #undef traceSTREAM_BUFFER_RESET\r
1326 #define traceSTREAM_BUFFER_RESET( xStreamBuffer ) \\r
1327         trcKERNEL_HOOKS_KERNEL_SERVICE(prvGetStreamBufferType(xStreamBuffer) > 0 ? TRACE_MESSAGEBUFFER_RESET : TRACE_STREAMBUFFER_RESET, STREAMBUFFER, xStreamBuffer); \\r
1328         trcKERNEL_HOOKS_SET_OBJECT_STATE(STREAMBUFFER, xStreamBuffer, 0);\r
1329 \r
1330 #undef traceSTREAM_BUFFER_SEND\r
1331 #define traceSTREAM_BUFFER_SEND( xStreamBuffer, xReturn ) \\r
1332         trcKERNEL_HOOKS_KERNEL_SERVICE(TRACE_GET_OBJECT_EVENT_CODE(SEND, TRCSUCCESS, STREAMBUFFER, xStreamBuffer), STREAMBUFFER, xStreamBuffer); \\r
1333         trcKERNEL_HOOKS_SET_OBJECT_STATE(STREAMBUFFER, xStreamBuffer, prvBytesInBuffer(xStreamBuffer));\r
1334         \r
1335 #undef traceBLOCKING_ON_STREAM_BUFFER_SEND\r
1336 #define traceBLOCKING_ON_STREAM_BUFFER_SEND( xStreamBuffer ) \\r
1337         trcKERNEL_HOOKS_KERNEL_SERVICE(TRACE_GET_OBJECT_EVENT_CODE(SEND, TRCBLOCK, STREAMBUFFER, xStreamBuffer), STREAMBUFFER, xStreamBuffer);\r
1338 \r
1339 #undef traceSTREAM_BUFFER_SEND_FAILED\r
1340 #define traceSTREAM_BUFFER_SEND_FAILED( xStreamBuffer ) \\r
1341         trcKERNEL_HOOKS_KERNEL_SERVICE(TRACE_GET_OBJECT_EVENT_CODE(SEND, TRCFAILED, STREAMBUFFER, xStreamBuffer), STREAMBUFFER, xStreamBuffer);\r
1342 \r
1343 #undef traceSTREAM_BUFFER_RECEIVE\r
1344 #define traceSTREAM_BUFFER_RECEIVE( xStreamBuffer, xReceivedLength ) \\r
1345         trcKERNEL_HOOKS_KERNEL_SERVICE(TRACE_GET_OBJECT_EVENT_CODE(RECEIVE, TRCSUCCESS, STREAMBUFFER, xStreamBuffer), STREAMBUFFER, xStreamBuffer); \\r
1346         trcKERNEL_HOOKS_SET_OBJECT_STATE(STREAMBUFFER, xStreamBuffer, prvBytesInBuffer(xStreamBuffer));\r
1347 \r
1348 \r
1349 #undef traceBLOCKING_ON_STREAM_BUFFER_RECEIVE\r
1350 #define traceBLOCKING_ON_STREAM_BUFFER_RECEIVE( xStreamBuffer ) \\r
1351         trcKERNEL_HOOKS_KERNEL_SERVICE(TRACE_GET_OBJECT_EVENT_CODE(RECEIVE, TRCBLOCK, STREAMBUFFER, xStreamBuffer), STREAMBUFFER, xStreamBuffer);\r
1352 \r
1353 #undef traceSTREAM_BUFFER_RECEIVE_FAILED\r
1354 #define traceSTREAM_BUFFER_RECEIVE_FAILED( xStreamBuffer ) \\r
1355         trcKERNEL_HOOKS_KERNEL_SERVICE(TRACE_GET_OBJECT_EVENT_CODE(RECEIVE, TRCFAILED, STREAMBUFFER, xStreamBuffer), STREAMBUFFER, xStreamBuffer);\r
1356 \r
1357 #undef traceSTREAM_BUFFER_SEND_FROM_ISR\r
1358 #define traceSTREAM_BUFFER_SEND_FROM_ISR( xStreamBuffer, xReturn ) \\r
1359         if( xReturn > ( size_t ) 0 ) \\r
1360         { \\r
1361                 trcKERNEL_HOOKS_KERNEL_SERVICE_FROM_ISR(TRACE_GET_OBJECT_EVENT_CODE(SEND_FROM_ISR, TRCSUCCESS, STREAMBUFFER, xStreamBuffer), STREAMBUFFER, xStreamBuffer); \\r
1362                 trcKERNEL_HOOKS_SET_OBJECT_STATE(STREAMBUFFER, xStreamBuffer, prvBytesInBuffer(xStreamBuffer)); \\r
1363         } \\r
1364         else \\r
1365         { \\r
1366                 trcKERNEL_HOOKS_KERNEL_SERVICE_FROM_ISR(TRACE_GET_OBJECT_EVENT_CODE(SEND_FROM_ISR, TRCFAILED, STREAMBUFFER, xStreamBuffer), STREAMBUFFER, xStreamBuffer); \\r
1367         }\r
1368 \r
1369 #undef traceSTREAM_BUFFER_RECEIVE_FROM_ISR\r
1370 #define traceSTREAM_BUFFER_RECEIVE_FROM_ISR( xStreamBuffer, xReceivedLength ) \\r
1371         if( xReceivedLength > ( size_t ) 0 ) \\r
1372         { \\r
1373                 trcKERNEL_HOOKS_KERNEL_SERVICE_FROM_ISR(TRACE_GET_OBJECT_EVENT_CODE(RECEIVE_FROM_ISR, TRCSUCCESS, STREAMBUFFER, xStreamBuffer), STREAMBUFFER, xStreamBuffer); \\r
1374                 trcKERNEL_HOOKS_SET_OBJECT_STATE(STREAMBUFFER, xStreamBuffer, prvBytesInBuffer(xStreamBuffer)); \\r
1375         } \\r
1376         else \\r
1377         { \\r
1378                 trcKERNEL_HOOKS_KERNEL_SERVICE_FROM_ISR(TRACE_GET_OBJECT_EVENT_CODE(RECEIVE_FROM_ISR, TRCFAILED, STREAMBUFFER, xStreamBuffer), STREAMBUFFER, xStreamBuffer); \\r
1379         }\r
1380 \r
1381 #endif /* (TRC_CFG_INCLUDE_STREAM_BUFFER_EVENTS == 1) */\r
1382 \r
1383 #endif /* (TRC_CFG_SCHEDULING_ONLY == 0) */\r
1384 \r
1385 #endif /*#if TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_SNAPSHOT */\r
1386 \r
1387 /******************************************************************************/\r
1388 /*** Definitions for Streaming mode *******************************************/\r
1389 /******************************************************************************/\r
1390 #if (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING)\r
1391 \r
1392 /*******************************************************************************\r
1393 * vTraceStoreKernelObjectName\r
1394 *\r
1395 * Set the name for a kernel object (defined by its address).\r
1396 ******************************************************************************/                 \r
1397 void vTraceStoreKernelObjectName(void* object, const char* name); \r
1398 \r
1399 /*******************************************************************************\r
1400 * prvIsNewTCB\r
1401 *\r
1402 * Tells if this task is already executing, or if there has been a task-switch.\r
1403 * Assumed to be called within a trace hook in kernel context.\r
1404 *******************************************************************************/\r
1405 uint32_t prvIsNewTCB(void* pNewTCB);\r
1406 \r
1407 #define TRACE_GET_CURRENT_TASK() prvTraceGetCurrentTaskHandle()\r
1408 \r
1409 /*************************************************************************/\r
1410 /* KERNEL SPECIFIC OBJECT CONFIGURATION                                                                  */\r
1411 /*************************************************************************/\r
1412 \r
1413 /*******************************************************************************\r
1414  * The event codes - should match the offline config file.\r
1415  ******************************************************************************/\r
1416 \r
1417 /*** Event codes for streaming - should match the Tracealyzer config file *****/\r
1418 #define PSF_EVENT_NULL_EVENT                                                            0x00\r
1419 \r
1420 #define PSF_EVENT_TRACE_START                                                           0x01\r
1421 #define PSF_EVENT_TS_CONFIG                                                                     0x02\r
1422 #define PSF_EVENT_OBJ_NAME                                                                      0x03\r
1423 #define PSF_EVENT_TASK_PRIORITY                                                         0x04\r
1424 #define PSF_EVENT_TASK_PRIO_INHERIT                                                     0x05\r
1425 #define PSF_EVENT_TASK_PRIO_DISINHERIT                                          0x06\r
1426 #define PSF_EVENT_DEFINE_ISR                                                            0x07\r
1427 \r
1428 #define PSF_EVENT_TASK_CREATE                                                           0x10\r
1429 #define PSF_EVENT_QUEUE_CREATE                                                          0x11\r
1430 #define PSF_EVENT_SEMAPHORE_BINARY_CREATE                                       0x12\r
1431 #define PSF_EVENT_MUTEX_CREATE                                                          0x13\r
1432 #define PSF_EVENT_TIMER_CREATE                                                          0x14\r
1433 #define PSF_EVENT_EVENTGROUP_CREATE                                                     0x15\r
1434 #define PSF_EVENT_SEMAPHORE_COUNTING_CREATE                                     0x16\r
1435 #define PSF_EVENT_MUTEX_RECURSIVE_CREATE                                        0x17\r
1436 #define PSF_EVENT_STREAMBUFFER_CREATE                                           0x18\r
1437 #define PSF_EVENT_MESSAGEBUFFER_CREATE                                          0x19\r
1438 \r
1439 #define PSF_EVENT_TASK_DELETE                                                           0x20\r
1440 #define PSF_EVENT_QUEUE_DELETE                                                          0x21\r
1441 #define PSF_EVENT_SEMAPHORE_DELETE                                                      0x22\r
1442 #define PSF_EVENT_MUTEX_DELETE                                                          0x23\r
1443 #define PSF_EVENT_TIMER_DELETE                                                          0x24\r
1444 #define PSF_EVENT_EVENTGROUP_DELETE                                                     0x25\r
1445 #define PSF_EVENT_STREAMBUFFER_DELETE                                           0x28\r
1446 #define PSF_EVENT_MESSAGEBUFFER_DELETE                                          0x29\r
1447 \r
1448 #define PSF_EVENT_TASK_READY                                                            0x30\r
1449 #define PSF_EVENT_NEW_TIME                                                                      0x31\r
1450 #define PSF_EVENT_NEW_TIME_SCHEDULER_SUSPENDED                          0x32\r
1451 #define PSF_EVENT_ISR_BEGIN                                                                     0x33\r
1452 #define PSF_EVENT_ISR_RESUME                                                            0x34\r
1453 #define PSF_EVENT_TS_BEGIN                                                                      0x35\r
1454 #define PSF_EVENT_TS_RESUME                                                                     0x36\r
1455 #define PSF_EVENT_TASK_ACTIVATE                                                         0x37\r
1456 \r
1457 #define PSF_EVENT_MALLOC                                                                        0x38\r
1458 #define PSF_EVENT_FREE                                                                          0x39\r
1459 \r
1460 #define PSF_EVENT_LOWPOWER_BEGIN                                                        0x3A\r
1461 #define PSF_EVENT_LOWPOWER_END                                                          0x3B\r
1462 \r
1463 #define PSF_EVENT_IFE_NEXT                                                                      0x3C\r
1464 #define PSF_EVENT_IFE_DIRECT                                                            0x3D\r
1465 \r
1466 #define PSF_EVENT_TASK_CREATE_FAILED                                            0x40\r
1467 #define PSF_EVENT_QUEUE_CREATE_FAILED                                           0x41\r
1468 #define PSF_EVENT_SEMAPHORE_BINARY_CREATE_FAILED                        0x42\r
1469 #define PSF_EVENT_MUTEX_CREATE_FAILED                                           0x43\r
1470 #define PSF_EVENT_TIMER_CREATE_FAILED                                           0x44\r
1471 #define PSF_EVENT_EVENTGROUP_CREATE_FAILED                                      0x45\r
1472 #define PSF_EVENT_SEMAPHORE_COUNTING_CREATE_FAILED                      0x46\r
1473 #define PSF_EVENT_MUTEX_RECURSIVE_CREATE_FAILED                         0x47\r
1474 #define PSF_EVENT_STREAMBUFFER_CREATE_FAILED                            0x49\r
1475 #define PSF_EVENT_MESSAGEBUFFER_CREATE_FAILED                           0x4A\r
1476 \r
1477 #define PSF_EVENT_TIMER_DELETE_FAILED                                           0x48\r
1478 \r
1479 #define PSF_EVENT_QUEUE_SEND                                                            0x50\r
1480 #define PSF_EVENT_SEMAPHORE_GIVE                                                        0x51\r
1481 #define PSF_EVENT_MUTEX_GIVE                                                            0x52\r
1482 \r
1483 #define PSF_EVENT_QUEUE_SEND_FAILED                                                     0x53\r
1484 #define PSF_EVENT_SEMAPHORE_GIVE_FAILED                                         0x54\r
1485 #define PSF_EVENT_MUTEX_GIVE_FAILED                                                     0x55\r
1486 \r
1487 #define PSF_EVENT_QUEUE_SEND_BLOCK                                                      0x56\r
1488 #define PSF_EVENT_SEMAPHORE_GIVE_BLOCK                                          0x57\r
1489 #define PSF_EVENT_MUTEX_GIVE_BLOCK                                                      0x58\r
1490 \r
1491 #define PSF_EVENT_QUEUE_SEND_FROMISR                                            0x59\r
1492 #define PSF_EVENT_SEMAPHORE_GIVE_FROMISR                                        0x5A\r
1493 \r
1494 #define PSF_EVENT_QUEUE_SEND_FROMISR_FAILED                                     0x5C\r
1495 #define PSF_EVENT_SEMAPHORE_GIVE_FROMISR_FAILED                         0x5D\r
1496 \r
1497 #define PSF_EVENT_QUEUE_RECEIVE                                                         0x60\r
1498 #define PSF_EVENT_SEMAPHORE_TAKE                                                        0x61\r
1499 #define PSF_EVENT_MUTEX_TAKE                                                            0x62\r
1500 \r
1501 #define PSF_EVENT_QUEUE_RECEIVE_FAILED                                          0x63\r
1502 #define PSF_EVENT_SEMAPHORE_TAKE_FAILED                                         0x64\r
1503 #define PSF_EVENT_MUTEX_TAKE_FAILED                                                     0x65\r
1504 \r
1505 #define PSF_EVENT_QUEUE_RECEIVE_BLOCK                                           0x66\r
1506 #define PSF_EVENT_SEMAPHORE_TAKE_BLOCK                                          0x67\r
1507 #define PSF_EVENT_MUTEX_TAKE_BLOCK                                                      0x68\r
1508 \r
1509 #define PSF_EVENT_QUEUE_RECEIVE_FROMISR                                         0x69\r
1510 #define PSF_EVENT_SEMAPHORE_TAKE_FROMISR                                        0x6A\r
1511 \r
1512 #define PSF_EVENT_QUEUE_RECEIVE_FROMISR_FAILED                          0x6C\r
1513 #define PSF_EVENT_SEMAPHORE_TAKE_FROMISR_FAILED                         0x6D\r
1514 \r
1515 #define PSF_EVENT_QUEUE_PEEK                                                            0x70\r
1516 #define PSF_EVENT_SEMAPHORE_PEEK                                                        0x71\r
1517 #define PSF_EVENT_MUTEX_PEEK                                                            0x72\r
1518 \r
1519 #define PSF_EVENT_QUEUE_PEEK_FAILED                                                     0x73\r
1520 #define PSF_EVENT_SEMAPHORE_PEEK_FAILED                                         0x74    \r
1521 #define PSF_EVENT_MUTEX_PEEK_FAILED                                                     0x75\r
1522 \r
1523 #define PSF_EVENT_QUEUE_PEEK_BLOCK                                                      0x76\r
1524 #define PSF_EVENT_SEMAPHORE_PEEK_BLOCK                                          0x77\r
1525 #define PSF_EVENT_MUTEX_PEEK_BLOCK                                                      0x78\r
1526 \r
1527 #define PSF_EVENT_TASK_DELAY_UNTIL                                                      0x79\r
1528 #define PSF_EVENT_TASK_DELAY                                                            0x7A\r
1529 #define PSF_EVENT_TASK_SUSPEND                                                          0x7B\r
1530 #define PSF_EVENT_TASK_RESUME                                                           0x7C\r
1531 #define PSF_EVENT_TASK_RESUME_FROMISR                                           0x7D\r
1532 \r
1533 #define PSF_EVENT_TIMER_PENDFUNCCALL                                            0x80\r
1534 #define PSF_EVENT_TIMER_PENDFUNCCALL_FROMISR                            0x81\r
1535 #define PSF_EVENT_TIMER_PENDFUNCCALL_FAILED                                     0x82\r
1536 #define PSF_EVENT_TIMER_PENDFUNCCALL_FROMISR_FAILED                     0x83\r
1537 \r
1538 #define PSF_EVENT_USER_EVENT                                                            0x90\r
1539 \r
1540 #define PSF_EVENT_TIMER_START                                                           0xA0\r
1541 #define PSF_EVENT_TIMER_RESET                                                           0xA1\r
1542 #define PSF_EVENT_TIMER_STOP                                                            0xA2\r
1543 #define PSF_EVENT_TIMER_CHANGEPERIOD                                            0xA3\r
1544 #define PSF_EVENT_TIMER_START_FROMISR                                           0xA4\r
1545 #define PSF_EVENT_TIMER_RESET_FROMISR                                           0xA5\r
1546 #define PSF_EVENT_TIMER_STOP_FROMISR                                            0xA6\r
1547 #define PSF_EVENT_TIMER_CHANGEPERIOD_FROMISR                            0xA7\r
1548 #define PSF_EVENT_TIMER_START_FAILED                                            0xA8\r
1549 #define PSF_EVENT_TIMER_RESET_FAILED                                            0xA9\r
1550 #define PSF_EVENT_TIMER_STOP_FAILED                                                     0xAA\r
1551 #define PSF_EVENT_TIMER_CHANGEPERIOD_FAILED                                     0xAB\r
1552 #define PSF_EVENT_TIMER_START_FROMISR_FAILED                            0xAC\r
1553 #define PSF_EVENT_TIMER_RESET_FROMISR_FAILED                            0xAD\r
1554 #define PSF_EVENT_TIMER_STOP_FROMISR_FAILED                                     0xAE\r
1555 #define PSF_EVENT_TIMER_CHANGEPERIOD_FROMISR_FAILED                     0xAF\r
1556 \r
1557 #define PSF_EVENT_EVENTGROUP_SYNC                                                       0xB0\r
1558 #define PSF_EVENT_EVENTGROUP_WAITBITS                                           0xB1\r
1559 #define PSF_EVENT_EVENTGROUP_CLEARBITS                                          0xB2\r
1560 #define PSF_EVENT_EVENTGROUP_CLEARBITS_FROMISR                          0xB3\r
1561 #define PSF_EVENT_EVENTGROUP_SETBITS                                            0xB4\r
1562 #define PSF_EVENT_EVENTGROUP_SETBITS_FROMISR                            0xB5\r
1563 #define PSF_EVENT_EVENTGROUP_SYNC_BLOCK                                         0xB6\r
1564 #define PSF_EVENT_EVENTGROUP_WAITBITS_BLOCK                                     0xB7\r
1565 #define PSF_EVENT_EVENTGROUP_SYNC_FAILED                                        0xB8\r
1566 #define PSF_EVENT_EVENTGROUP_WAITBITS_FAILED                            0xB9\r
1567 \r
1568 #define PSF_EVENT_QUEUE_SEND_FRONT                                                      0xC0\r
1569 #define PSF_EVENT_QUEUE_SEND_FRONT_FAILED                                       0xC1\r
1570 #define PSF_EVENT_QUEUE_SEND_FRONT_BLOCK                                        0xC2\r
1571 #define PSF_EVENT_QUEUE_SEND_FRONT_FROMISR                                      0xC3\r
1572 #define PSF_EVENT_QUEUE_SEND_FRONT_FROMISR_FAILED                       0xC4\r
1573 #define PSF_EVENT_MUTEX_GIVE_RECURSIVE                                          0xC5\r
1574 #define PSF_EVENT_MUTEX_GIVE_RECURSIVE_FAILED                           0xC6\r
1575 #define PSF_EVENT_MUTEX_TAKE_RECURSIVE                                          0xC7\r
1576 #define PSF_EVENT_MUTEX_TAKE_RECURSIVE_FAILED                           0xC8\r
1577 \r
1578 #define PSF_EVENT_TASK_NOTIFY                                                           0xC9\r
1579 #define PSF_EVENT_TASK_NOTIFY_TAKE                                                      0xCA\r
1580 #define PSF_EVENT_TASK_NOTIFY_TAKE_BLOCK                                        0xCB\r
1581 #define PSF_EVENT_TASK_NOTIFY_TAKE_FAILED                                       0xCC\r
1582 #define PSF_EVENT_TASK_NOTIFY_WAIT                                                      0xCD\r
1583 #define PSF_EVENT_TASK_NOTIFY_WAIT_BLOCK                                        0xCE\r
1584 #define PSF_EVENT_TASK_NOTIFY_WAIT_FAILED                                       0xCF\r
1585 #define PSF_EVENT_TASK_NOTIFY_FROM_ISR                                          0xD0\r
1586 #define PSF_EVENT_TASK_NOTIFY_GIVE_FROM_ISR                                     0xD1\r
1587 \r
1588 #define PSF_EVENT_TIMER_EXPIRED                                                         0xD2\r
1589 \r
1590 #define PSF_EVENT_STREAMBUFFER_SEND                                                     0xD3\r
1591 #define PSF_EVENT_STREAMBUFFER_SEND_BLOCK                                       0xD4\r
1592 #define PSF_EVENT_STREAMBUFFER_SEND_FAILED                                      0xD5\r
1593 #define PSF_EVENT_STREAMBUFFER_RECEIVE                                          0xD6\r
1594 #define PSF_EVENT_STREAMBUFFER_RECEIVE_BLOCK                            0xD7\r
1595 #define PSF_EVENT_STREAMBUFFER_RECEIVE_FAILED                           0xD8\r
1596 #define PSF_EVENT_STREAMBUFFER_SEND_FROM_ISR                            0xD9\r
1597 #define PSF_EVENT_STREAMBUFFER_SEND_FROM_ISR_FAILED                     0xDA\r
1598 #define PSF_EVENT_STREAMBUFFER_RECEIVE_FROM_ISR                         0xDB\r
1599 #define PSF_EVENT_STREAMBUFFER_RECEIVE_FROM_ISR_FAILED          0xDC\r
1600 #define PSF_EVENT_STREAMBUFFER_RESET                                            0xDD\r
1601 \r
1602 #define PSF_EVENT_MESSAGEBUFFER_SEND                                            0xDE\r
1603 #define PSF_EVENT_MESSAGEBUFFER_SEND_BLOCK                                      0xDF\r
1604 #define PSF_EVENT_MESSAGEBUFFER_SEND_FAILED                                     0xE0\r
1605 #define PSF_EVENT_MESSAGEBUFFER_RECEIVE                                         0xE1\r
1606 #define PSF_EVENT_MESSAGEBUFFER_RECEIVE_BLOCK                           0xE2\r
1607 #define PSF_EVENT_MESSAGEBUFFER_RECEIVE_FAILED                          0xE3\r
1608 #define PSF_EVENT_MESSAGEBUFFER_SEND_FROM_ISR                           0xE4\r
1609 #define PSF_EVENT_MESSAGEBUFFER_SEND_FROM_ISR_FAILED            0xE5\r
1610 #define PSF_EVENT_MESSAGEBUFFER_RECEIVE_FROM_ISR                        0xE6\r
1611 #define PSF_EVENT_MESSAGEBUFFER_RECEIVE_FROM_ISR_FAILED         0xE7\r
1612 #define PSF_EVENT_MESSAGEBUFFER_RESET                                           0xE8\r
1613 \r
1614 /*** The trace macros for streaming ******************************************/\r
1615 \r
1616 /* A macro that will update the tick count when returning from tickless idle */\r
1617 #undef traceINCREASE_TICK_COUNT\r
1618 /* 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.*/\r
1619 #define traceINCREASE_TICK_COUNT( xCount ) { extern uint32_t uiTraceTickCount; uiTraceTickCount += xCount; }\r
1620 \r
1621 #if (TRC_CFG_INCLUDE_OSTICK_EVENTS == 1)\r
1622 #define OS_TICK_EVENT(uxSchedulerSuspended, xTickCount) if (uxSchedulerSuspended == (unsigned portBASE_TYPE) pdFALSE) { prvTraceStoreEvent1(PSF_EVENT_NEW_TIME, (uint32_t)(xTickCount + 1)); }\r
1623 #else\r
1624 #define OS_TICK_EVENT(uxSchedulerSuspended, xTickCount) \r
1625 #endif\r
1626 \r
1627 /* Called on each OS tick. Will call uiPortGetTimestamp to make sure it is called at least once every OS tick. */\r
1628 #undef traceTASK_INCREMENT_TICK\r
1629 #if TRC_CFG_FREERTOS_VERSION <= TRC_FREERTOS_VERSION_7_4\r
1630 #define traceTASK_INCREMENT_TICK( xTickCount ) \\r
1631         if (uxSchedulerSuspended == ( unsigned portBASE_TYPE ) pdTRUE || uxMissedTicks == 0) { extern uint32_t uiTraceTickCount; uiTraceTickCount++; } \\r
1632         OS_TICK_EVENT(uxSchedulerSuspended, xTickCount)\r
1633 #else\r
1634 #define traceTASK_INCREMENT_TICK( xTickCount ) \\r
1635         if (uxSchedulerSuspended == ( unsigned portBASE_TYPE ) pdTRUE || uxPendedTicks == 0) { extern uint32_t uiTraceTickCount; uiTraceTickCount++; } \\r
1636         OS_TICK_EVENT(uxSchedulerSuspended, xTickCount)\r
1637 #endif /* TRC_CFG_FREERTOS_VERSION <= TRC_FREERTOS_VERSION_7_4 */\r
1638 \r
1639 /* Called on each task-switch */\r
1640 #undef traceTASK_SWITCHED_IN\r
1641 #define traceTASK_SWITCHED_IN() \\r
1642         if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
1643         { \\r
1644                 if (prvIsNewTCB(pxCurrentTCB)) \\r
1645                 { \\r
1646                         prvTraceStoreEvent2(PSF_EVENT_TASK_ACTIVATE, (uint32_t)pxCurrentTCB, pxCurrentTCB->uxPriority); \\r
1647                 } \\r
1648         }\r
1649 \r
1650 /* Called for each task that becomes ready */\r
1651 #if (TRC_CFG_INCLUDE_READY_EVENTS == 1)\r
1652 #undef traceMOVED_TASK_TO_READY_STATE\r
1653 #define traceMOVED_TASK_TO_READY_STATE( pxTCB ) \\r
1654         if (TRACE_GET_TASK_FILTER(pxTCB) & CurrentFilterMask) \\r
1655                 prvTraceStoreEvent1(PSF_EVENT_TASK_READY, (uint32_t)pxTCB);\r
1656 #endif\r
1657 \r
1658 #undef traceTASK_CREATE\r
1659 #if TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_9_0_0\r
1660 #define traceTASK_CREATE(pxNewTCB) \\r
1661         if (pxNewTCB != NULL) \\r
1662         { \\r
1663                 prvTraceSaveSymbol(pxNewTCB, pxNewTCB->pcTaskName); \\r
1664                 prvTraceSaveObjectData(pxNewTCB, pxNewTCB->uxPriority); \\r
1665                 prvTraceStoreStringEvent(1, PSF_EVENT_OBJ_NAME, pxNewTCB->pcTaskName, pxNewTCB); \\r
1666                 TRACE_SET_TASK_FILTER(pxNewTCB, CurrentFilterGroup); \\r
1667                 if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
1668                         if (TRACE_GET_TASK_FILTER(pxNewTCB) & CurrentFilterMask) \\r
1669                                 prvTraceStoreEvent2(PSF_EVENT_TASK_CREATE, (uint32_t)pxNewTCB, pxNewTCB->uxPriority); \\r
1670         }\r
1671 #else /* TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_9_0_0 */\r
1672 #define traceTASK_CREATE(pxNewTCB) \\r
1673         if (pxNewTCB != NULL) \\r
1674         { \\r
1675                 prvTraceSaveSymbol(pxNewTCB, (const char*)pcName); \\r
1676                 prvTraceSaveObjectData(pxNewTCB, uxPriority); \\r
1677                 prvTraceStoreStringEvent(1, PSF_EVENT_OBJ_NAME, (const char*)pcName, pxNewTCB); \\r
1678                 TRACE_SET_TASK_FILTER(pxNewTCB, CurrentFilterGroup); \\r
1679                 if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
1680                         if (TRACE_GET_TASK_FILTER(pxNewTCB) & CurrentFilterMask) \\r
1681                                 prvTraceStoreEvent2(PSF_EVENT_TASK_CREATE, (uint32_t)pxNewTCB, uxPriority); \\r
1682         }\r
1683 #endif /* TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_9_0_0 */\r
1684 \r
1685 /* Called in vTaskCreate, if it fails (typically if the stack can not be allocated) */\r
1686 #undef traceTASK_CREATE_FAILED\r
1687 #define traceTASK_CREATE_FAILED() \\r
1688         if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
1689                 prvTraceStoreEvent0(PSF_EVENT_TASK_CREATE_FAILED);\r
1690 \r
1691 /* Called on vTaskDelete */\r
1692 #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.\r
1693 #define traceTASK_DELETE( pxTaskToDelete ) \\r
1694         if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
1695                 if (TRACE_GET_TASK_FILTER(pxTaskToDelete) & CurrentFilterMask) \\r
1696                         prvTraceStoreEvent2(PSF_EVENT_TASK_DELETE, (uint32_t)pxTaskToDelete, (pxTaskToDelete != NULL) ? (pxTaskToDelete->uxPriority) : 0); \\r
1697         prvTraceDeleteSymbol(pxTaskToDelete); \\r
1698         prvTraceDeleteObjectData(pxTaskToDelete);\r
1699 \r
1700 #if (TRC_CFG_SCHEDULING_ONLY == 0)\r
1701 \r
1702 #if (defined(configUSE_TICKLESS_IDLE) && configUSE_TICKLESS_IDLE != 0)\r
1703 \r
1704 #undef traceLOW_POWER_IDLE_BEGIN\r
1705 #define traceLOW_POWER_IDLE_BEGIN() \\r
1706         { \\r
1707                 prvTraceStoreEvent1(PSF_EVENT_LOWPOWER_BEGIN, xExpectedIdleTime); \\r
1708         }\r
1709 \r
1710 #undef traceLOW_POWER_IDLE_END\r
1711 #define traceLOW_POWER_IDLE_END() \\r
1712         { \\r
1713                 prvTraceStoreEvent0(PSF_EVENT_LOWPOWER_END); \\r
1714         }\r
1715 \r
1716 #endif /* (defined(configUSE_TICKLESS_IDLE) && configUSE_TICKLESS_IDLE != 0) */\r
1717 \r
1718 /* Called on vTaskSuspend */\r
1719 #undef traceTASK_SUSPEND\r
1720 #define traceTASK_SUSPEND( pxTaskToSuspend ) \\r
1721         if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
1722                 if (TRACE_GET_TASK_FILTER(pxTaskToSuspend) & CurrentFilterMask) \\r
1723                         prvTraceStoreEvent1(PSF_EVENT_TASK_SUSPEND, (uint32_t)pxTaskToSuspend);\r
1724 \r
1725 /* Called on vTaskDelay - note the use of FreeRTOS variable xTicksToDelay */\r
1726 #undef traceTASK_DELAY\r
1727 #define traceTASK_DELAY() \\r
1728         if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
1729                 prvTraceStoreEvent1(PSF_EVENT_TASK_DELAY, xTicksToDelay);\r
1730 \r
1731 /* Called on vTaskDelayUntil - note the use of FreeRTOS variable xTimeToWake */\r
1732 #undef traceTASK_DELAY_UNTIL\r
1733 #if TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_9_0_0\r
1734 #define traceTASK_DELAY_UNTIL(xTimeToWake) \\r
1735         if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
1736                 prvTraceStoreEvent1(PSF_EVENT_TASK_DELAY_UNTIL, (uint32_t)xTimeToWake);\r
1737 #else /* TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_9_0_0 */\r
1738 #define traceTASK_DELAY_UNTIL() \\r
1739         if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
1740                 prvTraceStoreEvent1(PSF_EVENT_TASK_DELAY_UNTIL, (uint32_t)xTimeToWake);\r
1741 #endif /* TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_9_0_0 */\r
1742 \r
1743 #if (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_9_0_0)\r
1744 #define traceQUEUE_CREATE_HELPER() \\r
1745                 case queueQUEUE_TYPE_MUTEX: \\r
1746                         prvTraceStoreEvent1(PSF_EVENT_MUTEX_CREATE, (uint32_t)pxNewQueue); \\r
1747                         break; \\r
1748                 case queueQUEUE_TYPE_RECURSIVE_MUTEX: \\r
1749                         prvTraceStoreEvent1(PSF_EVENT_MUTEX_RECURSIVE_CREATE, (uint32_t)pxNewQueue); \\r
1750                         break;\r
1751 #else\r
1752 #define traceQUEUE_CREATE_HELPER()\r
1753 #endif /* (TRC_CFG_FREERTOS_VERSION < TRC_FREERTOS_VERSION_9_0_0) */\r
1754 \r
1755 /* Called in xQueueCreate, and thereby for all other object based on queues, such as semaphores. */\r
1756 #undef traceQUEUE_CREATE\r
1757 #define traceQUEUE_CREATE( pxNewQueue )\\r
1758         TRACE_SET_OBJECT_FILTER(QUEUE, pxNewQueue, CurrentFilterGroup); \\r
1759         if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
1760         { \\r
1761                 if (TRACE_GET_OBJECT_FILTER(QUEUE, pxNewQueue) & CurrentFilterMask) \\r
1762                 { \\r
1763                         switch (pxNewQueue->ucQueueType) \\r
1764                         { \\r
1765                                 case queueQUEUE_TYPE_BASE: \\r
1766                                         prvTraceStoreEvent2(PSF_EVENT_QUEUE_CREATE, (uint32_t)pxNewQueue, uxQueueLength); \\r
1767                                         break; \\r
1768                                 case queueQUEUE_TYPE_BINARY_SEMAPHORE: \\r
1769                                         prvTraceStoreEvent1(PSF_EVENT_SEMAPHORE_BINARY_CREATE, (uint32_t)pxNewQueue); \\r
1770                                         break; \\r
1771                                 traceQUEUE_CREATE_HELPER() \\r
1772                         } \\r
1773                 } \\r
1774         }\r
1775 \r
1776 #if (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_9_0_0)\r
1777 #define traceQUEUE_CREATE_FAILED_HELPER() \\r
1778                 case queueQUEUE_TYPE_MUTEX: \\r
1779                         prvTraceStoreEvent1(PSF_EVENT_MUTEX_CREATE_FAILED, 0); \\r
1780                         break; \\r
1781                 case queueQUEUE_TYPE_RECURSIVE_MUTEX: \\r
1782                         prvTraceStoreEvent1(PSF_EVENT_MUTEX_RECURSIVE_CREATE_FAILED, 0); \\r
1783                         break;\r
1784 #else\r
1785 #define traceQUEUE_CREATE_FAILED_HELPER()\r
1786 #endif /* (TRC_CFG_FREERTOS_VERSION < TRC_FREERTOS_VERSION_9_0_0) */\r
1787 \r
1788 /* Called in xQueueCreate, if the queue creation fails */\r
1789 #undef traceQUEUE_CREATE_FAILED\r
1790 #define traceQUEUE_CREATE_FAILED( queueType ) \\r
1791         if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
1792         { \\r
1793                 switch (queueType) \\r
1794                 { \\r
1795                         case queueQUEUE_TYPE_BASE: \\r
1796                                 prvTraceStoreEvent2(PSF_EVENT_QUEUE_CREATE_FAILED, 0, uxQueueLength); \\r
1797                                 break; \\r
1798                         case queueQUEUE_TYPE_BINARY_SEMAPHORE: \\r
1799                                 prvTraceStoreEvent1(PSF_EVENT_SEMAPHORE_BINARY_CREATE_FAILED, 0); \\r
1800                                 break; \\r
1801                         traceQUEUE_CREATE_FAILED_HELPER() \\r
1802                 } \\r
1803         }\r
1804 \r
1805 #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.\r
1806 #define traceQUEUE_DELETE( pxQueue ) \\r
1807         if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
1808         { \\r
1809                 if (TRACE_GET_OBJECT_FILTER(QUEUE, pxQueue) & CurrentFilterMask) \\r
1810                 { \\r
1811                         switch (pxQueue->ucQueueType) \\r
1812                         { \\r
1813                                 case queueQUEUE_TYPE_BASE: \\r
1814                                         prvTraceStoreEvent2(PSF_EVENT_QUEUE_DELETE, (uint32_t)pxQueue, (pxQueue != NULL) ? (pxQueue->uxMessagesWaiting) : 0); \\r
1815                                         break; \\r
1816                                 case queueQUEUE_TYPE_MUTEX: \\r
1817                                 case queueQUEUE_TYPE_RECURSIVE_MUTEX: \\r
1818                                         prvTraceStoreEvent2(PSF_EVENT_MUTEX_DELETE, (uint32_t)pxQueue, (pxQueue != NULL) ? (pxQueue->uxMessagesWaiting) : 0); \\r
1819                                         break; \\r
1820                                 case queueQUEUE_TYPE_COUNTING_SEMAPHORE: \\r
1821                                 case queueQUEUE_TYPE_BINARY_SEMAPHORE: \\r
1822                                         prvTraceStoreEvent2(PSF_EVENT_SEMAPHORE_DELETE, (uint32_t)pxQueue, (pxQueue != NULL) ? (pxQueue->uxMessagesWaiting) : 0); \\r
1823                                         break; \\r
1824                         } \\r
1825                 } \\r
1826         } \\r
1827         prvTraceDeleteSymbol(pxQueue);\r
1828 \r
1829 /* Called in xQueueCreateCountingSemaphore, if the queue creation fails */\r
1830 #undef traceCREATE_COUNTING_SEMAPHORE\r
1831 #if (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_8_X)\r
1832 #define traceCREATE_COUNTING_SEMAPHORE() \\r
1833         TRACE_SET_OBJECT_FILTER(QUEUE, xHandle, CurrentFilterGroup); \\r
1834         if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
1835                 if (TRACE_GET_OBJECT_FILTER(QUEUE, xHandle) & CurrentFilterMask) \\r
1836                         prvTraceStoreEvent2(PSF_EVENT_SEMAPHORE_COUNTING_CREATE, (uint32_t)xHandle, uxMaxCount)\r
1837 #elif (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_7_5_OR_7_6)\r
1838 #define traceCREATE_COUNTING_SEMAPHORE() \\r
1839         TRACE_SET_OBJECT_FILTER(QUEUE, xHandle, CurrentFilterGroup); \\r
1840         if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
1841                 if (TRACE_GET_OBJECT_FILTER(QUEUE, xHandle) & CurrentFilterMask) \\r
1842                         prvTraceStoreEvent2(PSF_EVENT_SEMAPHORE_COUNTING_CREATE, (uint32_t)xHandle, uxInitialCount);\r
1843 #elif (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_7_4)\r
1844 #define traceCREATE_COUNTING_SEMAPHORE() \\r
1845         TRACE_SET_OBJECT_FILTER(QUEUE, xHandle, CurrentFilterGroup); \\r
1846         if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
1847                 if (TRACE_GET_OBJECT_FILTER(QUEUE, xHandle) & CurrentFilterMask) \\r
1848                         prvTraceStoreEvent2(PSF_EVENT_SEMAPHORE_COUNTING_CREATE, (uint32_t)xHandle, uxCountValue);\r
1849 #else\r
1850 #define traceCREATE_COUNTING_SEMAPHORE() \\r
1851         TRACE_SET_OBJECT_FILTER(QUEUE, pxHandle, CurrentFilterGroup); \\r
1852         if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
1853                 if (TRACE_GET_OBJECT_FILTER(QUEUE, pxHandle) & CurrentFilterMask) \\r
1854                         prvTraceStoreEvent2(PSF_EVENT_SEMAPHORE_COUNTING_CREATE, (uint32_t)pxHandle, uxCountValue);\r
1855 #endif /* TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_8_X */\r
1856 \r
1857 #undef traceCREATE_COUNTING_SEMAPHORE_FAILED\r
1858 #if (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_8_X)\r
1859 #define traceCREATE_COUNTING_SEMAPHORE_FAILED() \\r
1860         if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
1861                 prvTraceStoreEvent2(PSF_EVENT_SEMAPHORE_COUNTING_CREATE_FAILED, 0, uxMaxCount);\r
1862 #elif (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_7_5_OR_7_6)\r
1863 #define traceCREATE_COUNTING_SEMAPHORE_FAILED() \\r
1864         if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
1865                 prvTraceStoreEvent2(PSF_EVENT_SEMAPHORE_COUNTING_CREATE_FAILED, 0, uxInitialCount);\r
1866 #elif (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_7_4)\r
1867 #define traceCREATE_COUNTING_SEMAPHORE_FAILED() \\r
1868         if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
1869                 prvTraceStoreEvent2(PSF_EVENT_SEMAPHORE_COUNTING_CREATE_FAILED, 0, uxCountValue);\r
1870 #else\r
1871 #define traceCREATE_COUNTING_SEMAPHORE_FAILED() \\r
1872         if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
1873                 prvTraceStoreEvent2(PSF_EVENT_SEMAPHORE_COUNTING_CREATE_FAILED, 0, uxCountValue);\r
1874 #endif /* TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_8_X */\r
1875 \r
1876 \r
1877 /* This macro is not necessary as of FreeRTOS v9.0.0 */\r
1878 #if (TRC_CFG_FREERTOS_VERSION < TRC_FREERTOS_VERSION_9_0_0)\r
1879 /* Called in xQueueCreateMutex, and thereby also from xSemaphoreCreateMutex and xSemaphoreCreateRecursiveMutex */\r
1880 #undef traceCREATE_MUTEX\r
1881 #define traceCREATE_MUTEX( pxNewQueue ) \\r
1882         TRACE_SET_OBJECT_FILTER(QUEUE, pxNewQueue, CurrentFilterGroup); \\r
1883         if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
1884         { \\r
1885                 if (TRACE_GET_OBJECT_FILTER(QUEUE, pxNewQueue) & CurrentFilterMask) \\r
1886                 { \\r
1887                         switch (pxNewQueue->ucQueueType) \\r
1888                         { \\r
1889                                 case queueQUEUE_TYPE_MUTEX: \\r
1890                                         prvTraceStoreEvent1(PSF_EVENT_MUTEX_CREATE, (uint32_t)pxNewQueue); \\r
1891                                         break; \\r
1892                                 case queueQUEUE_TYPE_RECURSIVE_MUTEX: \\r
1893                                         prvTraceStoreEvent1(PSF_EVENT_MUTEX_RECURSIVE_CREATE, (uint32_t)pxNewQueue); \\r
1894                                         break; \\r
1895                         } \\r
1896                 }\\r
1897         }\r
1898 \r
1899 /* Called in xQueueCreateMutex when the operation fails (when memory allocation fails) */\r
1900 #undef traceCREATE_MUTEX_FAILED\r
1901 #define traceCREATE_MUTEX_FAILED() \\r
1902         if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
1903                 prvTraceStoreEvent1(PSF_EVENT_MUTEX_CREATE_FAILED, 0);\r
1904 #endif /* (TRC_CFG_FREERTOS_VERSION < TRC_FREERTOS_VERSION_9_0_0) */\r
1905 \r
1906 /* Called when a message is sent to a queue */  /* CS IS NEW ! */\r
1907 #undef traceQUEUE_SEND\r
1908 #define traceQUEUE_SEND( pxQueue ) \\r
1909         if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
1910                 if (TRACE_GET_OBJECT_FILTER(QUEUE, pxQueue) & CurrentFilterMask) \\r
1911                         switch (pxQueue->ucQueueType) \\r
1912                         { \\r
1913                                 case queueQUEUE_TYPE_BASE: \\r
1914                                         prvTraceStoreEvent2(xCopyPosition == queueSEND_TO_BACK ? PSF_EVENT_QUEUE_SEND : PSF_EVENT_QUEUE_SEND_FRONT, (uint32_t)pxQueue, pxQueue->uxMessagesWaiting + 1); \\r
1915                                         break; \\r
1916                                 case queueQUEUE_TYPE_BINARY_SEMAPHORE: \\r
1917                                 case queueQUEUE_TYPE_COUNTING_SEMAPHORE: \\r
1918                                         prvTraceStoreEvent2(PSF_EVENT_SEMAPHORE_GIVE, (uint32_t)pxQueue, pxQueue->uxMessagesWaiting + 1); \\r
1919                                         break; \\r
1920                                 case queueQUEUE_TYPE_MUTEX: \\r
1921                                 case queueQUEUE_TYPE_RECURSIVE_MUTEX: \\r
1922                                         prvTraceStoreEvent1(PSF_EVENT_MUTEX_GIVE, (uint32_t)pxQueue); \\r
1923                                         break; \\r
1924                         }\r
1925 \r
1926 /* Called when a message failed to be sent to a queue (timeout) */\r
1927 #undef traceQUEUE_SEND_FAILED\r
1928 #define traceQUEUE_SEND_FAILED( pxQueue ) \\r
1929         if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
1930                 if (TRACE_GET_OBJECT_FILTER(QUEUE, pxQueue) & CurrentFilterMask) \\r
1931                         switch (pxQueue->ucQueueType) \\r
1932                         { \\r
1933                                 case queueQUEUE_TYPE_BASE: \\r
1934                                         prvTraceStoreEvent2(xCopyPosition == queueSEND_TO_BACK ? PSF_EVENT_QUEUE_SEND_FAILED : PSF_EVENT_QUEUE_SEND_FRONT_FAILED, (uint32_t)pxQueue, pxQueue->uxMessagesWaiting); \\r
1935                                         break; \\r
1936                                 case queueQUEUE_TYPE_BINARY_SEMAPHORE: \\r
1937                                 case queueQUEUE_TYPE_COUNTING_SEMAPHORE: \\r
1938                                         prvTraceStoreEvent2(PSF_EVENT_SEMAPHORE_GIVE_FAILED, (uint32_t)pxQueue, pxQueue->uxMessagesWaiting); \\r
1939                                         break; \\r
1940                                 case queueQUEUE_TYPE_MUTEX: \\r
1941                                 case queueQUEUE_TYPE_RECURSIVE_MUTEX: \\r
1942                                         prvTraceStoreEvent1(PSF_EVENT_MUTEX_GIVE_FAILED, (uint32_t)pxQueue); \\r
1943                                         break; \\r
1944                         }\r
1945 \r
1946 /* Called when the task is blocked due to a send operation on a full queue */\r
1947 #undef traceBLOCKING_ON_QUEUE_SEND\r
1948 #define traceBLOCKING_ON_QUEUE_SEND( pxQueue ) \\r
1949         if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
1950                 if (TRACE_GET_OBJECT_FILTER(QUEUE, pxQueue) & CurrentFilterMask) \\r
1951                         switch (pxQueue->ucQueueType) \\r
1952                         { \\r
1953                                 case queueQUEUE_TYPE_BASE: \\r
1954                                         prvTraceStoreEvent2(xCopyPosition == queueSEND_TO_BACK ? PSF_EVENT_QUEUE_SEND_BLOCK : PSF_EVENT_QUEUE_SEND_FRONT_BLOCK, (uint32_t)pxQueue, pxQueue->uxMessagesWaiting); \\r
1955                                         break; \\r
1956                                 case queueQUEUE_TYPE_BINARY_SEMAPHORE: \\r
1957                                 case queueQUEUE_TYPE_COUNTING_SEMAPHORE: \\r
1958                                         prvTraceStoreEvent2(PSF_EVENT_SEMAPHORE_GIVE_BLOCK, (uint32_t)pxQueue, pxQueue->uxMessagesWaiting); \\r
1959                                         break; \\r
1960                                 case queueQUEUE_TYPE_MUTEX: \\r
1961                                 case queueQUEUE_TYPE_RECURSIVE_MUTEX: \\r
1962                                         prvTraceStoreEvent1(PSF_EVENT_MUTEX_GIVE_BLOCK, (uint32_t)pxQueue); \\r
1963                                         break; \\r
1964                         }\r
1965 \r
1966 /**************************************************************************/\r
1967 /* Makes sure xQueueGiveFromISR also has a xCopyPosition parameter        */\r
1968 /**************************************************************************/\r
1969 /* Helpers needed to correctly expand names */\r
1970 #define TZ__CAT2(a,b) a ## b\r
1971 #define TZ__CAT(a,b) TZ__CAT2(a, b)\r
1972 \r
1973 /* 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 */\r
1974 #define xQueueGiveFromISR(a,b) TZ__CAT(xQueueGiveFromISR__, uxQueueType) (a,b)\r
1975 \r
1976 /* If in queue.c, the "uxQueueType" macro expands to "pcHead". queueSEND_TO_BACK is the value we need to send in */\r
1977 #define xQueueGiveFromISR__pcHead(__a, __b) MyWrapper(__a, __b, const BaseType_t xCopyPosition); \\r
1978 BaseType_t xQueueGiveFromISR(__a, __b) { return MyWrapper(xQueue, pxHigherPriorityTaskWoken, queueSEND_TO_BACK); } \\r
1979 BaseType_t MyWrapper(__a, __b, const BaseType_t xCopyPosition)\r
1980 \r
1981 /* If not in queue.c, "uxQueueType" isn't expanded */\r
1982 #define xQueueGiveFromISR__uxQueueType(__a, __b) xQueueGiveFromISR(__a,__b)\r
1983 \r
1984 /**************************************************************************/\r
1985 /* End of xQueueGiveFromISR fix                                           */\r
1986 /**************************************************************************/\r
1987 \r
1988 /* Called when a message is sent from interrupt context, e.g., using xQueueSendFromISR */\r
1989 #undef traceQUEUE_SEND_FROM_ISR\r
1990 #define traceQUEUE_SEND_FROM_ISR( pxQueue ) \\r
1991         if (TRACE_GET_OBJECT_FILTER(QUEUE, pxQueue) & CurrentFilterMask) \\r
1992                 switch (pxQueue->ucQueueType) \\r
1993                 { \\r
1994                         case queueQUEUE_TYPE_BASE: \\r
1995                                 prvTraceStoreEvent2(xCopyPosition == queueSEND_TO_BACK ? PSF_EVENT_QUEUE_SEND_FROMISR : PSF_EVENT_QUEUE_SEND_FRONT_FROMISR, (uint32_t)pxQueue, pxQueue->uxMessagesWaiting + 1); \\r
1996                                 break; \\r
1997                         case queueQUEUE_TYPE_BINARY_SEMAPHORE: \\r
1998                         case queueQUEUE_TYPE_COUNTING_SEMAPHORE: \\r
1999                                 prvTraceStoreEvent2(PSF_EVENT_SEMAPHORE_GIVE_FROMISR, (uint32_t)pxQueue, pxQueue->uxMessagesWaiting + 1); \\r
2000                                 break; \\r
2001                 }\r
2002 \r
2003 /* Called when a message send from interrupt context fails (since the queue was full) */\r
2004 #undef traceQUEUE_SEND_FROM_ISR_FAILED\r
2005 #define traceQUEUE_SEND_FROM_ISR_FAILED( pxQueue ) \\r
2006         if (TRACE_GET_OBJECT_FILTER(QUEUE, pxQueue) & CurrentFilterMask) \\r
2007                 switch (pxQueue->ucQueueType) \\r
2008                 { \\r
2009                         case queueQUEUE_TYPE_BASE: \\r
2010                                 prvTraceStoreEvent2(xCopyPosition == queueSEND_TO_BACK ? PSF_EVENT_QUEUE_SEND_FROMISR_FAILED : PSF_EVENT_QUEUE_SEND_FRONT_FROMISR_FAILED, (uint32_t)pxQueue, pxQueue->uxMessagesWaiting); \\r
2011                                 break; \\r
2012                         case queueQUEUE_TYPE_BINARY_SEMAPHORE: \\r
2013                         case queueQUEUE_TYPE_COUNTING_SEMAPHORE: \\r
2014                                 prvTraceStoreEvent2(PSF_EVENT_SEMAPHORE_GIVE_FROMISR_FAILED, (uint32_t)pxQueue, pxQueue->uxMessagesWaiting); \\r
2015                                 break; \\r
2016                 }\r
2017 \r
2018 /* Called when a message is received from a queue */\r
2019 #undef traceQUEUE_RECEIVE\r
2020 #define traceQUEUE_RECEIVE( pxQueue ) \\r
2021         if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
2022                 if (TRACE_GET_OBJECT_FILTER(QUEUE, pxQueue) & CurrentFilterMask) \\r
2023                         switch (pxQueue->ucQueueType) \\r
2024                         { \\r
2025                                 case queueQUEUE_TYPE_BASE: \\r
2026                                         if (isQueueReceiveHookActuallyPeek) \\r
2027                                                 prvTraceStoreEvent3(PSF_EVENT_QUEUE_PEEK, (uint32_t)pxQueue, xTicksToWait, pxQueue->uxMessagesWaiting - 1); \\r
2028                                         else\\r
2029                                                 prvTraceStoreEvent3(PSF_EVENT_QUEUE_RECEIVE, (uint32_t)pxQueue, xTicksToWait, pxQueue->uxMessagesWaiting - 1); \\r
2030                                         break; \\r
2031                                 case queueQUEUE_TYPE_BINARY_SEMAPHORE: \\r
2032                                 case queueQUEUE_TYPE_COUNTING_SEMAPHORE: \\r
2033                                         if (isQueueReceiveHookActuallyPeek) \\r
2034                                                 prvTraceStoreEvent3(PSF_EVENT_SEMAPHORE_PEEK, (uint32_t)pxQueue, xTicksToWait, pxQueue->uxMessagesWaiting - 1); \\r
2035                                         else \\r
2036                                                 prvTraceStoreEvent3(PSF_EVENT_SEMAPHORE_TAKE, (uint32_t)pxQueue, xTicksToWait, pxQueue->uxMessagesWaiting - 1); \\r
2037                                         break; \\r
2038                                 case queueQUEUE_TYPE_MUTEX: \\r
2039                                 case queueQUEUE_TYPE_RECURSIVE_MUTEX: \\r
2040                                         if (isQueueReceiveHookActuallyPeek) \\r
2041                                                 prvTraceStoreEvent2(PSF_EVENT_MUTEX_PEEK, (uint32_t)pxQueue, xTicksToWait); \\r
2042                                         else \\r
2043                                                 prvTraceStoreEvent2(PSF_EVENT_MUTEX_TAKE, (uint32_t)pxQueue, xTicksToWait); \\r
2044                                         break; \\r
2045                         }\r
2046 \r
2047 /* Called when a receive operation on a queue fails (timeout) */\r
2048 #undef traceQUEUE_RECEIVE_FAILED\r
2049 #define traceQUEUE_RECEIVE_FAILED( pxQueue ) \\r
2050         if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
2051                 if (TRACE_GET_OBJECT_FILTER(QUEUE, pxQueue) & CurrentFilterMask) \\r
2052                         switch (pxQueue->ucQueueType) \\r
2053                         { \\r
2054                                 case queueQUEUE_TYPE_BASE: \\r
2055                                         prvTraceStoreEvent3(isQueueReceiveHookActuallyPeek ? PSF_EVENT_QUEUE_PEEK_FAILED : PSF_EVENT_QUEUE_RECEIVE_FAILED, (uint32_t)pxQueue, xTicksToWait, pxQueue->uxMessagesWaiting); \\r
2056                                         break; \\r
2057                                 case queueQUEUE_TYPE_BINARY_SEMAPHORE: \\r
2058                                 case queueQUEUE_TYPE_COUNTING_SEMAPHORE: \\r
2059                                         prvTraceStoreEvent3(isQueueReceiveHookActuallyPeek ? PSF_EVENT_SEMAPHORE_PEEK_FAILED : PSF_EVENT_SEMAPHORE_TAKE_FAILED, (uint32_t)pxQueue, xTicksToWait, pxQueue->uxMessagesWaiting); \\r
2060                                         break; \\r
2061                                 case queueQUEUE_TYPE_MUTEX: \\r
2062                                 case queueQUEUE_TYPE_RECURSIVE_MUTEX: \\r
2063                                         prvTraceStoreEvent2(isQueueReceiveHookActuallyPeek ? PSF_EVENT_MUTEX_PEEK_FAILED : PSF_EVENT_MUTEX_TAKE_FAILED, (uint32_t)pxQueue, xTicksToWait); \\r
2064                                         break; \\r
2065                         }\r
2066 \r
2067 /* Called when the task is blocked due to a receive operation on an empty queue */\r
2068 #undef traceBLOCKING_ON_QUEUE_RECEIVE\r
2069 #define traceBLOCKING_ON_QUEUE_RECEIVE( pxQueue ) \\r
2070         if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
2071                 if (TRACE_GET_OBJECT_FILTER(QUEUE, pxQueue) & CurrentFilterMask) \\r
2072                         switch (pxQueue->ucQueueType) \\r
2073                         { \\r
2074                                 case queueQUEUE_TYPE_BASE: \\r
2075                                         prvTraceStoreEvent3(isQueueReceiveHookActuallyPeek ? PSF_EVENT_QUEUE_PEEK_BLOCK : PSF_EVENT_QUEUE_RECEIVE_BLOCK, (uint32_t)pxQueue, xTicksToWait, pxQueue->uxMessagesWaiting); \\r
2076                                         break; \\r
2077                                 case queueQUEUE_TYPE_BINARY_SEMAPHORE: \\r
2078                                 case queueQUEUE_TYPE_COUNTING_SEMAPHORE: \\r
2079                                         prvTraceStoreEvent3(isQueueReceiveHookActuallyPeek ? PSF_EVENT_SEMAPHORE_PEEK_BLOCK : PSF_EVENT_SEMAPHORE_TAKE_BLOCK, (uint32_t)pxQueue, xTicksToWait, pxQueue->uxMessagesWaiting); \\r
2080                                         break; \\r
2081                                 case queueQUEUE_TYPE_MUTEX: \\r
2082                                 case queueQUEUE_TYPE_RECURSIVE_MUTEX: \\r
2083                                         prvTraceStoreEvent2(isQueueReceiveHookActuallyPeek ? PSF_EVENT_MUTEX_PEEK_BLOCK : PSF_EVENT_MUTEX_TAKE_BLOCK, (uint32_t)pxQueue, xTicksToWait); \\r
2084                                         break; \\r
2085                         }\r
2086 \r
2087 #if (TRC_CFG_FREERTOS_VERSION > TRC_FREERTOS_VERSION_9_0_1)\r
2088 /* Called when a peek operation on a queue fails (timeout) */\r
2089 #undef traceQUEUE_PEEK_FAILED\r
2090 #define traceQUEUE_PEEK_FAILED( pxQueue ) \\r
2091         if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
2092                 if (TRACE_GET_OBJECT_FILTER(QUEUE, pxQueue) & CurrentFilterMask) \\r
2093                         switch (pxQueue->ucQueueType) \\r
2094                         { \\r
2095                                 case queueQUEUE_TYPE_BASE: \\r
2096                                         prvTraceStoreEvent3(PSF_EVENT_QUEUE_PEEK_FAILED, (uint32_t)pxQueue, xTicksToWait, pxQueue->uxMessagesWaiting); \\r
2097                                         break; \\r
2098                                 case queueQUEUE_TYPE_BINARY_SEMAPHORE: \\r
2099                                 case queueQUEUE_TYPE_COUNTING_SEMAPHORE: \\r
2100                                         prvTraceStoreEvent3(PSF_EVENT_SEMAPHORE_PEEK_FAILED, (uint32_t)pxQueue, xTicksToWait, pxQueue->uxMessagesWaiting); \\r
2101                                         break; \\r
2102                                 case queueQUEUE_TYPE_MUTEX: \\r
2103                                 case queueQUEUE_TYPE_RECURSIVE_MUTEX: \\r
2104                                         prvTraceStoreEvent2(PSF_EVENT_MUTEX_PEEK_FAILED, (uint32_t)pxQueue, xTicksToWait); \\r
2105                                         break; \\r
2106                         }\r
2107 \r
2108 /* Called when the task is blocked due to a peek operation on an empty queue */\r
2109 #undef traceBLOCKING_ON_QUEUE_PEEK\r
2110 #define traceBLOCKING_ON_QUEUE_PEEK( pxQueue ) \\r
2111         if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
2112                 if (TRACE_GET_OBJECT_FILTER(QUEUE, pxQueue) & CurrentFilterMask) \\r
2113                         switch (pxQueue->ucQueueType) \\r
2114                         { \\r
2115                                 case queueQUEUE_TYPE_BASE: \\r
2116                                         prvTraceStoreEvent3(PSF_EVENT_QUEUE_PEEK_BLOCK, (uint32_t)pxQueue, xTicksToWait, pxQueue->uxMessagesWaiting); \\r
2117                                         break; \\r
2118                                 case queueQUEUE_TYPE_BINARY_SEMAPHORE: \\r
2119                                 case queueQUEUE_TYPE_COUNTING_SEMAPHORE: \\r
2120                                         prvTraceStoreEvent3(PSF_EVENT_SEMAPHORE_PEEK_BLOCK, (uint32_t)pxQueue, xTicksToWait, pxQueue->uxMessagesWaiting); \\r
2121                                         break; \\r
2122                                 case queueQUEUE_TYPE_MUTEX: \\r
2123                                 case queueQUEUE_TYPE_RECURSIVE_MUTEX: \\r
2124                                         prvTraceStoreEvent2(PSF_EVENT_MUTEX_PEEK_BLOCK, (uint32_t)pxQueue, xTicksToWait); \\r
2125                                         break; \\r
2126                         }\r
2127 \r
2128 #endif /* (TRC_CFG_FREERTOS_VERSION > TRC_FREERTOS_VERSION_9_0_1) */\r
2129 \r
2130 /* Called when a message is received in interrupt context, e.g., using xQueueReceiveFromISR */\r
2131 #undef traceQUEUE_RECEIVE_FROM_ISR\r
2132 #define traceQUEUE_RECEIVE_FROM_ISR( pxQueue ) \\r
2133         if (TRACE_GET_OBJECT_FILTER(QUEUE, pxQueue) & CurrentFilterMask) \\r
2134                 switch (pxQueue->ucQueueType) \\r
2135                 { \\r
2136                         case queueQUEUE_TYPE_BASE: \\r
2137                                 prvTraceStoreEvent2(PSF_EVENT_QUEUE_RECEIVE_FROMISR, (uint32_t)pxQueue, pxQueue->uxMessagesWaiting - 1); \\r
2138                                 break; \\r
2139                         case queueQUEUE_TYPE_BINARY_SEMAPHORE: \\r
2140                         case queueQUEUE_TYPE_COUNTING_SEMAPHORE: \\r
2141                                 prvTraceStoreEvent2(PSF_EVENT_SEMAPHORE_TAKE_FROMISR, (uint32_t)pxQueue, pxQueue->uxMessagesWaiting - 1); \\r
2142                                 break; \\r
2143                 }\r
2144 \r
2145 /* Called when a message receive from interrupt context fails (since the queue was empty) */\r
2146 #undef traceQUEUE_RECEIVE_FROM_ISR_FAILED\r
2147 #define traceQUEUE_RECEIVE_FROM_ISR_FAILED( pxQueue ) \\r
2148         if (TRACE_GET_OBJECT_FILTER(QUEUE, pxQueue) & CurrentFilterMask) \\r
2149                 switch (pxQueue->ucQueueType) \\r
2150                 { \\r
2151                         case queueQUEUE_TYPE_BASE: \\r
2152                                 prvTraceStoreEvent2(PSF_EVENT_QUEUE_RECEIVE_FROMISR_FAILED, (uint32_t)pxQueue, pxQueue->uxMessagesWaiting); \\r
2153                                 break; \\r
2154                         case queueQUEUE_TYPE_BINARY_SEMAPHORE: \\r
2155                         case queueQUEUE_TYPE_COUNTING_SEMAPHORE: \\r
2156                                 prvTraceStoreEvent2(PSF_EVENT_SEMAPHORE_TAKE_FROMISR_FAILED, (uint32_t)pxQueue, pxQueue->uxMessagesWaiting); \\r
2157                                 break; \\r
2158                 }\r
2159 \r
2160 /* Called on xQueuePeek */\r
2161 #undef traceQUEUE_PEEK\r
2162 #define traceQUEUE_PEEK( pxQueue ) \\r
2163         if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
2164                 if (TRACE_GET_OBJECT_FILTER(QUEUE, pxQueue) & CurrentFilterMask) \\r
2165                         switch (pxQueue->ucQueueType) \\r
2166                         { \\r
2167                                 case queueQUEUE_TYPE_BASE: \\r
2168                                         prvTraceStoreEvent3(PSF_EVENT_QUEUE_PEEK, (uint32_t)pxQueue, xTicksToWait, pxQueue->uxMessagesWaiting); \\r
2169                                         break; \\r
2170                                 case queueQUEUE_TYPE_BINARY_SEMAPHORE: \\r
2171                                 case queueQUEUE_TYPE_COUNTING_SEMAPHORE: \\r
2172                                         prvTraceStoreEvent3(PSF_EVENT_SEMAPHORE_PEEK, (uint32_t)pxQueue, xTicksToWait, pxQueue->uxMessagesWaiting); \\r
2173                                         break; \\r
2174                                 case queueQUEUE_TYPE_MUTEX: \\r
2175                                 case queueQUEUE_TYPE_RECURSIVE_MUTEX: \\r
2176                                         prvTraceStoreEvent1(PSF_EVENT_MUTEX_PEEK, (uint32_t)pxQueue); \\r
2177                                         break; \\r
2178                         }\r
2179 \r
2180 /* Called in vTaskPrioritySet */\r
2181 #undef traceTASK_PRIORITY_SET\r
2182 #define traceTASK_PRIORITY_SET( pxTask, uxNewPriority ) \\r
2183         prvTraceSaveObjectData(pxTask, uxNewPriority); \\r
2184         if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
2185                 if (TRACE_GET_TASK_FILTER(pxTask) & CurrentFilterMask) \\r
2186                         prvTraceStoreEvent2(PSF_EVENT_TASK_PRIORITY, (uint32_t)pxTask, uxNewPriority);\r
2187         \r
2188 /* Called in vTaskPriorityInherit, which is called by Mutex operations */\r
2189 #undef traceTASK_PRIORITY_INHERIT\r
2190 #define traceTASK_PRIORITY_INHERIT( pxTask, uxNewPriority ) \\r
2191         if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
2192                 if (TRACE_GET_TASK_FILTER(pxTask) & CurrentFilterMask) \\r
2193                         prvTraceStoreEvent2(PSF_EVENT_TASK_PRIO_INHERIT, (uint32_t)pxTask, uxNewPriority);\r
2194 \r
2195 /* Called in vTaskPriorityDisinherit, which is called by Mutex operations */\r
2196 #undef traceTASK_PRIORITY_DISINHERIT\r
2197 #define traceTASK_PRIORITY_DISINHERIT( pxTask, uxNewPriority ) \\r
2198         if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
2199                 if (TRACE_GET_TASK_FILTER(pxTask) & CurrentFilterMask) \\r
2200                         prvTraceStoreEvent2(PSF_EVENT_TASK_PRIO_DISINHERIT, (uint32_t)pxTask, uxNewPriority);\r
2201 \r
2202 /* Called in vTaskResume */\r
2203 #undef traceTASK_RESUME\r
2204 #define traceTASK_RESUME( pxTaskToResume ) \\r
2205         if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
2206                 if (TRACE_GET_TASK_FILTER(pxTaskToResume) & CurrentFilterMask) \\r
2207                         prvTraceStoreEvent1(PSF_EVENT_TASK_RESUME, (uint32_t)pxTaskToResume);\r
2208 \r
2209 /* Called in vTaskResumeFromISR */\r
2210 #undef traceTASK_RESUME_FROM_ISR\r
2211 #define traceTASK_RESUME_FROM_ISR( pxTaskToResume ) \\r
2212         if (TRACE_GET_TASK_FILTER(pxTaskToResume) & CurrentFilterMask) \\r
2213                 prvTraceStoreEvent1(PSF_EVENT_TASK_RESUME_FROMISR, (uint32_t)pxTaskToResume);\r
2214 \r
2215 #if (TRC_CFG_INCLUDE_MEMMANG_EVENTS == 1)\r
2216 \r
2217 #undef traceMALLOC\r
2218 #define traceMALLOC( pvAddress, uiSize ) \\r
2219         if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
2220                 prvTraceStoreEvent2(PSF_EVENT_MALLOC, (uint32_t)pvAddress, uiSize);\r
2221 \r
2222 #undef traceFREE\r
2223 #define traceFREE( pvAddress, uiSize ) \\r
2224         if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
2225                 prvTraceStoreEvent2(PSF_EVENT_FREE, (uint32_t)pvAddress, (uint32_t)(0 - uiSize)); /* "0 -" instead of just "-" to get rid of a warning... */\r
2226 \r
2227 #endif /* (TRC_CFG_INCLUDE_MEMMANG_EVENTS == 1) */\r
2228 \r
2229 #if (TRC_CFG_INCLUDE_TIMER_EVENTS == 1)\r
2230 \r
2231 /* Called in timer.c - xTimerCreate */\r
2232 #undef traceTIMER_CREATE\r
2233 #define traceTIMER_CREATE(tmr) \\r
2234         TRACE_SET_OBJECT_FILTER(TIMER, tmr, CurrentFilterGroup); \\r
2235         prvTraceSaveSymbol(tmr, tmr->pcTimerName); \\r
2236         prvTraceStoreStringEvent(1, PSF_EVENT_OBJ_NAME, tmr->pcTimerName, tmr); \\r
2237         if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
2238                 if (TRACE_GET_OBJECT_FILTER(TIMER, tmr) & CurrentFilterMask) \\r
2239                         prvTraceStoreEvent2(PSF_EVENT_TIMER_CREATE, (uint32_t)tmr, tmr->xTimerPeriodInTicks);\r
2240 \r
2241 #undef traceTIMER_CREATE_FAILED\r
2242 #define traceTIMER_CREATE_FAILED() \\r
2243         if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
2244                 prvTraceStoreEvent0(PSF_EVENT_TIMER_CREATE_FAILED);\r
2245 \r
2246 #if (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_8_X)\r
2247 #define traceTIMER_COMMAND_SEND_8_0_CASES(tmr) \\r
2248                                 case tmrCOMMAND_RESET: \\r
2249                                         prvTraceStoreEvent2((xReturn == pdPASS) ? PSF_EVENT_TIMER_RESET : PSF_EVENT_TIMER_RESET_FAILED, (uint32_t)tmr, xOptionalValue); \\r
2250                                         break; \\r
2251                                 case tmrCOMMAND_START_FROM_ISR: \\r
2252                                         prvTraceStoreEvent2((xReturn == pdPASS) ? PSF_EVENT_TIMER_START_FROMISR : PSF_EVENT_TIMER_START_FROMISR_FAILED, (uint32_t)tmr, xOptionalValue); \\r
2253                                         break; \\r
2254                                 case tmrCOMMAND_RESET_FROM_ISR: \\r
2255                                         prvTraceStoreEvent2((xReturn == pdPASS) ? PSF_EVENT_TIMER_RESET_FROMISR : PSF_EVENT_TIMER_RESET_FROMISR_FAILED, (uint32_t)tmr, xOptionalValue); \\r
2256                                         break; \\r
2257                                 case tmrCOMMAND_STOP_FROM_ISR: \\r
2258                                         prvTraceStoreEvent2((xReturn == pdPASS) ? PSF_EVENT_TIMER_STOP_FROMISR : PSF_EVENT_TIMER_STOP_FROMISR_FAILED, (uint32_t)tmr, xOptionalValue); \\r
2259                                         break; \\r
2260                                 case tmrCOMMAND_CHANGE_PERIOD_FROM_ISR: \\r
2261                                         prvTraceStoreEvent2((xReturn == pdPASS) ? PSF_EVENT_TIMER_CHANGEPERIOD_FROMISR : PSF_EVENT_TIMER_CHANGEPERIOD_FROMISR_FAILED, (uint32_t)tmr, xOptionalValue); \\r
2262                                         break;\r
2263 #else /* TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_8_X */\r
2264 #define traceTIMER_COMMAND_SEND_8_0_CASES(tmr) \r
2265 #endif /* TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_8_X */\r
2266 \r
2267 /* Note that xCommandID can never be tmrCOMMAND_EXECUTE_CALLBACK (-1) since the trace macro is not called in that case */\r
2268 #undef traceTIMER_COMMAND_SEND\r
2269 #define traceTIMER_COMMAND_SEND(tmr, xCommandID, xOptionalValue, xReturn) \\r
2270         if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
2271                 if (TRACE_GET_OBJECT_FILTER(TIMER, tmr) & CurrentFilterMask) \\r
2272                         switch(xCommandID) \\r
2273                         { \\r
2274                                 case tmrCOMMAND_START: \\r
2275                                         prvTraceStoreEvent1((xReturn == pdPASS) ? PSF_EVENT_TIMER_START : PSF_EVENT_TIMER_START_FAILED, (uint32_t)tmr); \\r
2276                                         break; \\r
2277                                 case tmrCOMMAND_STOP: \\r
2278                                         prvTraceStoreEvent1((xReturn == pdPASS) ? PSF_EVENT_TIMER_STOP : PSF_EVENT_TIMER_STOP_FAILED, (uint32_t)tmr); \\r
2279                                         break; \\r
2280                                 case tmrCOMMAND_CHANGE_PERIOD: \\r
2281                                         prvTraceStoreEvent2((xReturn == pdPASS) ? PSF_EVENT_TIMER_CHANGEPERIOD : PSF_EVENT_TIMER_CHANGEPERIOD_FAILED, (uint32_t)tmr, xOptionalValue); \\r
2282                                         break; \\r
2283                                 case tmrCOMMAND_DELETE: \\r
2284                                         prvTraceStoreEvent1((xReturn == pdPASS) ? PSF_EVENT_TIMER_DELETE : PSF_EVENT_TIMER_DELETE_FAILED, (uint32_t)tmr); \\r
2285                                         break; \\r
2286                                 traceTIMER_COMMAND_SEND_8_0_CASES(tmr) \\r
2287                         }\r
2288 \r
2289 #undef traceTIMER_EXPIRED\r
2290 #define traceTIMER_EXPIRED(tmr) \\r
2291         if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
2292                 if (TRACE_GET_OBJECT_FILTER(TIMER, tmr) & CurrentFilterMask) \\r
2293                         prvTraceStoreEvent2(PSF_EVENT_TIMER_EXPIRED, (uint32_t)tmr->pxCallbackFunction, (uint32_t)tmr->pvTimerID);\r
2294 \r
2295 #endif /* #if (TRC_CFG_INCLUDE_TIMER_EVENTS == 1) */\r
2296 \r
2297 \r
2298 #if (TRC_CFG_INCLUDE_PEND_FUNC_CALL_EVENTS == 1)\r
2299 \r
2300 #undef tracePEND_FUNC_CALL\r
2301 #define tracePEND_FUNC_CALL(func, arg1, arg2, ret) \\r
2302         prvTraceStoreEvent1((ret == pdPASS) ? PSF_EVENT_TIMER_PENDFUNCCALL : PSF_EVENT_TIMER_PENDFUNCCALL_FAILED, (uint32_t)func);\r
2303 \r
2304 #undef tracePEND_FUNC_CALL_FROM_ISR\r
2305 #define tracePEND_FUNC_CALL_FROM_ISR(func, arg1, arg2, ret) \\r
2306         prvTraceStoreEvent1((ret == pdPASS) ? PSF_EVENT_TIMER_PENDFUNCCALL_FROMISR : PSF_EVENT_TIMER_PENDFUNCCALL_FROMISR_FAILED, (uint32_t)func);\r
2307 \r
2308 #endif /* (TRC_CFG_INCLUDE_PEND_FUNC_CALL_EVENTS == 1) */\r
2309 \r
2310 #if (TRC_CFG_INCLUDE_EVENT_GROUP_EVENTS == 1)\r
2311 \r
2312 #undef traceEVENT_GROUP_CREATE\r
2313 #define traceEVENT_GROUP_CREATE(eg) \\r
2314         TRACE_SET_OBJECT_FILTER(EVENTGROUP, eg, CurrentFilterGroup); \\r
2315         if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
2316                 if (TRACE_GET_OBJECT_FILTER(EVENTGROUP, eg) & CurrentFilterMask) \\r
2317                         prvTraceStoreEvent1(PSF_EVENT_EVENTGROUP_CREATE, (uint32_t)eg);\r
2318 \r
2319 #undef traceEVENT_GROUP_DELETE\r
2320 #define traceEVENT_GROUP_DELETE(eg) \\r
2321         if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
2322                 if (TRACE_GET_OBJECT_FILTER(EVENTGROUP, eg) & CurrentFilterMask) \\r
2323                         prvTraceStoreEvent1(PSF_EVENT_EVENTGROUP_DELETE, (uint32_t)eg); \\r
2324         prvTraceDeleteSymbol(eg);\r
2325 \r
2326 #undef traceEVENT_GROUP_CREATE_FAILED\r
2327 #define traceEVENT_GROUP_CREATE_FAILED() \\r
2328         if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
2329                 prvTraceStoreEvent0(PSF_EVENT_EVENTGROUP_CREATE_FAILED);\r
2330 \r
2331 #undef traceEVENT_GROUP_SYNC_BLOCK\r
2332 #define traceEVENT_GROUP_SYNC_BLOCK(eg, bitsToSet, bitsToWaitFor) \\r
2333         if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
2334                 if (TRACE_GET_OBJECT_FILTER(EVENTGROUP, eg) & CurrentFilterMask) \\r
2335                         prvTraceStoreEvent2(PSF_EVENT_EVENTGROUP_SYNC_BLOCK, (uint32_t)eg, bitsToWaitFor);\r
2336 \r
2337 #undef traceEVENT_GROUP_SYNC_END\r
2338 #define traceEVENT_GROUP_SYNC_END(eg, bitsToSet, bitsToWaitFor, wasTimeout) \\r
2339         if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
2340                 if (TRACE_GET_OBJECT_FILTER(EVENTGROUP, eg) & CurrentFilterMask) \\r
2341                         prvTraceStoreEvent2((wasTimeout != pdTRUE) ? PSF_EVENT_EVENTGROUP_SYNC : PSF_EVENT_EVENTGROUP_SYNC_FAILED, (uint32_t)eg, bitsToWaitFor);\r
2342 \r
2343 #undef traceEVENT_GROUP_WAIT_BITS_BLOCK\r
2344 #define traceEVENT_GROUP_WAIT_BITS_BLOCK(eg, bitsToWaitFor) \\r
2345         if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
2346                 if (TRACE_GET_OBJECT_FILTER(EVENTGROUP, eg) & CurrentFilterMask) \\r
2347                         prvTraceStoreEvent2(PSF_EVENT_EVENTGROUP_WAITBITS_BLOCK, (uint32_t)eg, bitsToWaitFor);\r
2348 \r
2349 #undef traceEVENT_GROUP_WAIT_BITS_END\r
2350 #define traceEVENT_GROUP_WAIT_BITS_END(eg, bitsToWaitFor, wasTimeout) \\r
2351         if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
2352                 if (TRACE_GET_OBJECT_FILTER(EVENTGROUP, eg) & CurrentFilterMask) \\r
2353                         prvTraceStoreEvent2((wasTimeout != pdTRUE) ? PSF_EVENT_EVENTGROUP_WAITBITS : PSF_EVENT_EVENTGROUP_WAITBITS_FAILED, (uint32_t)eg, bitsToWaitFor);\r
2354 \r
2355 #undef traceEVENT_GROUP_CLEAR_BITS\r
2356 #define traceEVENT_GROUP_CLEAR_BITS(eg, bitsToClear) \\r
2357         if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
2358                 if (TRACE_GET_OBJECT_FILTER(EVENTGROUP, eg) & CurrentFilterMask) \\r
2359                         prvTraceStoreEvent2(PSF_EVENT_EVENTGROUP_CLEARBITS, (uint32_t)eg, bitsToClear);\r
2360 \r
2361 #undef traceEVENT_GROUP_CLEAR_BITS_FROM_ISR\r
2362 #define traceEVENT_GROUP_CLEAR_BITS_FROM_ISR(eg, bitsToClear) \\r
2363         if (TRACE_GET_OBJECT_FILTER(EVENTGROUP, eg) & CurrentFilterMask) \\r
2364                 prvTraceStoreEvent2(PSF_EVENT_EVENTGROUP_CLEARBITS_FROMISR, (uint32_t)eg, bitsToClear);\r
2365 \r
2366 #undef traceEVENT_GROUP_SET_BITS\r
2367 #define traceEVENT_GROUP_SET_BITS(eg, bitsToSet) \\r
2368         if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
2369                 if (TRACE_GET_OBJECT_FILTER(EVENTGROUP, eg) & CurrentFilterMask) \\r
2370                         prvTraceStoreEvent2(PSF_EVENT_EVENTGROUP_SETBITS, (uint32_t)eg, bitsToSet);\r
2371 \r
2372 #undef traceEVENT_GROUP_SET_BITS_FROM_ISR\r
2373 #define traceEVENT_GROUP_SET_BITS_FROM_ISR(eg, bitsToSet) \\r
2374         if (TRACE_GET_OBJECT_FILTER(EVENTGROUP, eg) & CurrentFilterMask) \\r
2375                 prvTraceStoreEvent2(PSF_EVENT_EVENTGROUP_SETBITS_FROMISR, (uint32_t)eg, bitsToSet);\r
2376 \r
2377 #endif /* (TRC_CFG_INCLUDE_EVENT_GROUP_EVENTS == 1) */\r
2378 \r
2379 #undef traceTASK_NOTIFY_TAKE\r
2380 #if (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_9_0_0)\r
2381 #define traceTASK_NOTIFY_TAKE() \\r
2382         if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask){ \\r
2383                 if (pxCurrentTCB->ucNotifyState == taskNOTIFICATION_RECEIVED) \\r
2384                         prvTraceStoreEvent2(PSF_EVENT_TASK_NOTIFY_TAKE, (uint32_t)pxCurrentTCB, xTicksToWait); \\r
2385                 else \\r
2386                         prvTraceStoreEvent2(PSF_EVENT_TASK_NOTIFY_TAKE_FAILED, (uint32_t)pxCurrentTCB, xTicksToWait);}\r
2387 #else /* TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_9_0_0 */\r
2388 #define traceTASK_NOTIFY_TAKE() \\r
2389         if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask){ \\r
2390                 if (pxCurrentTCB->eNotifyState == eNotified) \\r
2391                         prvTraceStoreEvent2(PSF_EVENT_TASK_NOTIFY_TAKE, (uint32_t)pxCurrentTCB, xTicksToWait); \\r
2392                 else \\r
2393                         prvTraceStoreEvent2(PSF_EVENT_TASK_NOTIFY_TAKE_FAILED, (uint32_t)pxCurrentTCB, xTicksToWait);}\r
2394 #endif /* TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_9_0_0 */\r
2395 \r
2396 #undef traceTASK_NOTIFY_TAKE_BLOCK\r
2397 #define traceTASK_NOTIFY_TAKE_BLOCK() \\r
2398         if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
2399                 prvTraceStoreEvent2(PSF_EVENT_TASK_NOTIFY_TAKE_BLOCK, (uint32_t)pxCurrentTCB, xTicksToWait);\r
2400 \r
2401 #undef traceTASK_NOTIFY_WAIT\r
2402 #if (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_9_0_0)\r
2403 #define traceTASK_NOTIFY_WAIT() \\r
2404         if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask){ \\r
2405                 if (pxCurrentTCB->ucNotifyState == taskNOTIFICATION_RECEIVED) \\r
2406                         prvTraceStoreEvent2(PSF_EVENT_TASK_NOTIFY_WAIT, (uint32_t)pxCurrentTCB, xTicksToWait); \\r
2407                 else \\r
2408                         prvTraceStoreEvent2(PSF_EVENT_TASK_NOTIFY_WAIT_FAILED, (uint32_t)pxCurrentTCB, xTicksToWait);}\r
2409 #else /* TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_9_0_0 */\r
2410 #define traceTASK_NOTIFY_WAIT() \\r
2411         if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask){ \\r
2412                 if (pxCurrentTCB->eNotifyState == eNotified) \\r
2413                         prvTraceStoreEvent2(PSF_EVENT_TASK_NOTIFY_WAIT, (uint32_t)pxCurrentTCB, xTicksToWait); \\r
2414                 else \\r
2415                         prvTraceStoreEvent2(PSF_EVENT_TASK_NOTIFY_WAIT_FAILED, (uint32_t)pxCurrentTCB, xTicksToWait);}\r
2416 #endif /* TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_9_0_0 */\r
2417 \r
2418 #undef traceTASK_NOTIFY_WAIT_BLOCK\r
2419 #define traceTASK_NOTIFY_WAIT_BLOCK() \\r
2420         if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
2421                 prvTraceStoreEvent2(PSF_EVENT_TASK_NOTIFY_WAIT_BLOCK, (uint32_t)pxCurrentTCB, xTicksToWait);\r
2422 \r
2423 #undef traceTASK_NOTIFY\r
2424 #define traceTASK_NOTIFY() \\r
2425         if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
2426                 if (TRACE_GET_TASK_FILTER(xTaskToNotify) & CurrentFilterMask) \\r
2427                         prvTraceStoreEvent1(PSF_EVENT_TASK_NOTIFY, (uint32_t)xTaskToNotify);\r
2428 \r
2429 #undef traceTASK_NOTIFY_FROM_ISR\r
2430 #define traceTASK_NOTIFY_FROM_ISR() \\r
2431         if (TRACE_GET_TASK_FILTER(xTaskToNotify) & CurrentFilterMask) \\r
2432                 prvTraceStoreEvent1(PSF_EVENT_TASK_NOTIFY_FROM_ISR, (uint32_t)xTaskToNotify);\r
2433         \r
2434 #undef traceTASK_NOTIFY_GIVE_FROM_ISR\r
2435 #define traceTASK_NOTIFY_GIVE_FROM_ISR() \\r
2436         if (TRACE_GET_TASK_FILTER(xTaskToNotify) & CurrentFilterMask) \\r
2437                 prvTraceStoreEvent1(PSF_EVENT_TASK_NOTIFY_GIVE_FROM_ISR, (uint32_t)xTaskToNotify);\r
2438 \r
2439 #undef traceQUEUE_REGISTRY_ADD\r
2440 #define traceQUEUE_REGISTRY_ADD(object, name) \\r
2441         prvTraceSaveSymbol(object, (const char*)name); \\r
2442         prvTraceStoreStringEvent(1, PSF_EVENT_OBJ_NAME, name, object);\r
2443 \r
2444 #if (TRC_CFG_INCLUDE_STREAM_BUFFER_EVENTS == 1)\r
2445 \r
2446 #undef traceSTREAM_BUFFER_CREATE\r
2447 #define traceSTREAM_BUFFER_CREATE( pxStreamBuffer, xIsMessageBuffer ) \\r
2448         TRACE_SET_OBJECT_FILTER(STREAMBUFFER, pxStreamBuffer, CurrentFilterGroup); \\r
2449         if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
2450                 if (TRACE_GET_OBJECT_FILTER(STREAMBUFFER, pxStreamBuffer) & CurrentFilterMask) \\r
2451                         prvTraceStoreEvent2(xIsMessageBuffer == 1 ? PSF_EVENT_MESSAGEBUFFER_CREATE : PSF_EVENT_STREAMBUFFER_CREATE, (uint32_t)pxStreamBuffer, xBufferSizeBytes);\r
2452 \r
2453 #undef traceSTREAM_BUFFER_CREATE_FAILED\r
2454 #define traceSTREAM_BUFFER_CREATE_FAILED( xIsMessageBuffer ) \\r
2455         if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
2456                 prvTraceStoreEvent2(xIsMessageBuffer == 1 ? PSF_EVENT_MESSAGEBUFFER_CREATE_FAILED : PSF_EVENT_STREAMBUFFER_CREATE_FAILED, 0 , xBufferSizeBytes);\r
2457 \r
2458 #undef traceSTREAM_BUFFER_CREATE_STATIC_FAILED\r
2459 #define traceSTREAM_BUFFER_CREATE_STATIC_FAILED( xReturn, xIsMessageBuffer ) \\r
2460         traceSTREAM_BUFFER_CREATE_FAILED( xIsMessageBuffer )\r
2461 \r
2462 #undef traceSTREAM_BUFFER_DELETE\r
2463 #define traceSTREAM_BUFFER_DELETE( xStreamBuffer ) \\r
2464         if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
2465                 if (TRACE_GET_OBJECT_FILTER(STREAMBUFFER, pxStreamBuffer) & CurrentFilterMask) \\r
2466                         prvTraceStoreEvent2(prvGetStreamBufferType(xStreamBuffer) > 0 ? PSF_EVENT_MESSAGEBUFFER_DELETE : PSF_EVENT_STREAMBUFFER_DELETE, (uint32_t)xStreamBuffer, prvBytesInBuffer(xStreamBuffer)); \\r
2467         prvTraceDeleteSymbol(xStreamBuffer);\r
2468 \r
2469 #undef traceSTREAM_BUFFER_RESET\r
2470 #define traceSTREAM_BUFFER_RESET( xStreamBuffer ) \\r
2471         if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
2472                 if (TRACE_GET_OBJECT_FILTER(STREAMBUFFER, xStreamBuffer) & CurrentFilterMask) \\r
2473                         prvTraceStoreEvent2(prvGetStreamBufferType(xStreamBuffer) > 0 ? PSF_EVENT_MESSAGEBUFFER_RESET : PSF_EVENT_STREAMBUFFER_RESET, (uint32_t)xStreamBuffer, 0);\r
2474 \r
2475 #undef traceSTREAM_BUFFER_SEND\r
2476 #define traceSTREAM_BUFFER_SEND( xStreamBuffer, xReturn ) \\r
2477         if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
2478                 if (TRACE_GET_OBJECT_FILTER(STREAMBUFFER, xStreamBuffer) & CurrentFilterMask) \\r
2479                         prvTraceStoreEvent2(prvGetStreamBufferType(xStreamBuffer) > 0 ? PSF_EVENT_MESSAGEBUFFER_SEND : PSF_EVENT_STREAMBUFFER_SEND, (uint32_t)xStreamBuffer, prvBytesInBuffer(xStreamBuffer));\r
2480 \r
2481 #undef traceBLOCKING_ON_STREAM_BUFFER_SEND\r
2482 #define traceBLOCKING_ON_STREAM_BUFFER_SEND( xStreamBuffer ) \\r
2483         if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
2484                 if (TRACE_GET_OBJECT_FILTER(STREAMBUFFER, xStreamBuffer) & CurrentFilterMask) \\r
2485                         prvTraceStoreEvent1(prvGetStreamBufferType(xStreamBuffer) > 0 ? PSF_EVENT_MESSAGEBUFFER_SEND_BLOCK : PSF_EVENT_STREAMBUFFER_SEND_BLOCK, (uint32_t)xStreamBuffer);\r
2486 \r
2487 #undef traceSTREAM_BUFFER_SEND_FAILED\r
2488 #define traceSTREAM_BUFFER_SEND_FAILED( xStreamBuffer ) \\r
2489         if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
2490                 if (TRACE_GET_OBJECT_FILTER(STREAMBUFFER, xStreamBuffer) & CurrentFilterMask) \\r
2491                         prvTraceStoreEvent1(prvGetStreamBufferType(xStreamBuffer) > 0 ? PSF_EVENT_MESSAGEBUFFER_SEND_FAILED : PSF_EVENT_STREAMBUFFER_SEND_FAILED, (uint32_t)xStreamBuffer);\r
2492 \r
2493 #undef traceSTREAM_BUFFER_RECEIVE\r
2494 #define traceSTREAM_BUFFER_RECEIVE( xStreamBuffer, xReceivedLength ) \\r
2495         if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
2496                 if (TRACE_GET_OBJECT_FILTER(STREAMBUFFER, xStreamBuffer) & CurrentFilterMask) \\r
2497                         prvTraceStoreEvent2(prvGetStreamBufferType(xStreamBuffer) > 0 ? PSF_EVENT_MESSAGEBUFFER_RECEIVE: PSF_EVENT_STREAMBUFFER_RECEIVE, (uint32_t)xStreamBuffer, prvBytesInBuffer(xStreamBuffer));\r
2498 \r
2499 #undef traceBLOCKING_ON_STREAM_BUFFER_RECEIVE\r
2500 #define traceBLOCKING_ON_STREAM_BUFFER_RECEIVE( xStreamBuffer ) \\r
2501         if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
2502                 if (TRACE_GET_OBJECT_FILTER(STREAMBUFFER, xStreamBuffer) & CurrentFilterMask) \\r
2503                         prvTraceStoreEvent1(prvGetStreamBufferType(xStreamBuffer) > 0 ? PSF_EVENT_MESSAGEBUFFER_RECEIVE_BLOCK: PSF_EVENT_STREAMBUFFER_RECEIVE_BLOCK, (uint32_t)xStreamBuffer);\r
2504 \r
2505 #undef traceSTREAM_BUFFER_RECEIVE_FAILED\r
2506 #define traceSTREAM_BUFFER_RECEIVE_FAILED( xStreamBuffer ) \\r
2507         if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
2508                 if (TRACE_GET_OBJECT_FILTER(STREAMBUFFER, xStreamBuffer) & CurrentFilterMask) \\r
2509                         prvTraceStoreEvent1(prvGetStreamBufferType(xStreamBuffer) > 0 ? PSF_EVENT_MESSAGEBUFFER_RECEIVE_FAILED: PSF_EVENT_STREAMBUFFER_RECEIVE_FAILED, (uint32_t)xStreamBuffer);\r
2510 \r
2511 #undef traceSTREAM_BUFFER_SEND_FROM_ISR\r
2512 #define traceSTREAM_BUFFER_SEND_FROM_ISR( xStreamBuffer, xReturn ) \\r
2513         if (TRACE_GET_OBJECT_FILTER(STREAMBUFFER, xStreamBuffer) & CurrentFilterMask) \\r
2514         { \\r
2515                 if ( xReturn > ( size_t ) 0 ) \\r
2516                 { \\r
2517                         prvTraceStoreEvent2(prvGetStreamBufferType(xStreamBuffer) > 0 ? PSF_EVENT_MESSAGEBUFFER_SEND_FROM_ISR : PSF_EVENT_STREAMBUFFER_SEND_FROM_ISR, (uint32_t)xStreamBuffer, prvBytesInBuffer(xStreamBuffer)); \\r
2518                 } \\r
2519                 else \\r
2520                 { \\r
2521                         prvTraceStoreEvent1(prvGetStreamBufferType(xStreamBuffer) > 0 ? PSF_EVENT_MESSAGEBUFFER_SEND_FROM_ISR_FAILED : PSF_EVENT_STREAMBUFFER_SEND_FROM_ISR_FAILED, (uint32_t)xStreamBuffer); \\r
2522                 } \\r
2523         }\r
2524 \r
2525 #undef traceSTREAM_BUFFER_RECEIVE_FROM_ISR\r
2526 #define traceSTREAM_BUFFER_RECEIVE_FROM_ISR( xStreamBuffer, xReceivedLength ) \\r
2527 if (TRACE_GET_OBJECT_FILTER(STREAMBUFFER, xStreamBuffer) & CurrentFilterMask) \\r
2528         { \\r
2529                 if ( xReceivedLength > ( size_t ) 0 ) \\r
2530                 { \\r
2531                         prvTraceStoreEvent2(prvGetStreamBufferType(xStreamBuffer) > 0 ? PSF_EVENT_MESSAGEBUFFER_RECEIVE_FROM_ISR : PSF_EVENT_STREAMBUFFER_RECEIVE_FROM_ISR, (uint32_t)xStreamBuffer, prvBytesInBuffer(xStreamBuffer)); \\r
2532                 } \\r
2533                 else \\r
2534                 { \\r
2535                         prvTraceStoreEvent1(prvGetStreamBufferType(xStreamBuffer) > 0 ? PSF_EVENT_MESSAGEBUFFER_RECEIVE_FROM_ISR_FAILED : PSF_EVENT_STREAMBUFFER_RECEIVE_FROM_ISR_FAILED, (uint32_t)xStreamBuffer); \\r
2536                 } \\r
2537         }\r
2538 \r
2539 #endif /* (TRC_CFG_INCLUDE_STREAM_BUFFER_EVENTS == 1) */\r
2540 \r
2541 #endif /* (TRC_CFG_SCHEDULING_ONLY == 0) */\r
2542 \r
2543 #endif /* (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING) */\r
2544 \r
2545 #else /* (TRC_USE_TRACEALYZER_RECORDER == 1) */\r
2546         \r
2547 /* When recorder is disabled */\r
2548 #define vTraceSetQueueName(object, name)\r
2549 #define vTraceSetSemaphoreName(object, name)\r
2550 #define vTraceSetMutexName(object, name)\r
2551 #define vTraceSetEventGroupName(object, name)\r
2552 #define vTraceSetStreamBufferName(object, name)\r
2553 #define vTraceSetMessageBufferName(object, name)\r
2554         \r
2555 #endif /* (TRC_USE_TRACEALYZER_RECORDER == 1) */\r
2556 \r
2557 #ifdef __cplusplus\r
2558 }\r
2559 #endif\r
2560 \r
2561 #endif /* TRC_KERNEL_PORT_H */\r