1 /* 2 * Trace Recorder for Tracealyzer v4.5.1 3 * Copyright 2021 Percepio AB 4 * www.percepio.com 5 * 6 * SPDX-License-Identifier: Apache-2.0 7 * 8 * For bare-metal use of Tracealyzer (no RTOS) 9 */ 10 11 #ifndef TRC_KERNEL_PORT_H 12 #define TRC_KERNEL_PORT_H 13 14 #include "trcPortDefines.h" 15 16 #ifdef __cplusplus 17 extern "C" { 18 #endif 19 20 #define TRC_USE_TRACEALYZER_RECORDER 1 /* Allows for disabling the recorder */ 21 22 #define TRACE_CPU_CLOCK_HZ 100000 /* Change this, or get the below error */ 23 24 #if (TRACE_CPU_CLOCK_HZ == 1) 25 #error "Please set TRACE_CPU_CLOCK_HZ to match the processor clock frequency." 26 #endif 27 28 /* If using dynamic allocation of snapshot trace buffer, set this to your memory allocation function... */ 29 #define TRACE_MALLOC(size) malloc(size) 30 31 /*** Don't change the below definitions, unless you know what you are doing! ***/ 32 33 #define TRACE_KERNEL_VERSION 0x1AA1 34 35 /* Dummy definitions, since no RTOS */ 36 #define TRACE_TICK_RATE_HZ 1 /* Must not be 0. */ 37 #define TRACE_GET_CURRENT_TASK() 0 38 #define TRACE_GET_OS_TICKS() (0) 39 #define TRACE_GET_TASK_NUMBER(x) 0 40 41 /* Hardcoded to 0 for bare metal */ 42 #define prvTraceIsSchedulerSuspended() 0 43 #define prvIsNewTCB(x) 0 44 #define prvTraceGetCurrentTaskHandle(x) NULL 45 46 #if (defined(TRC_USE_TRACEALYZER_RECORDER)) && (TRC_USE_TRACEALYZER_RECORDER == 1) 47 48 #define TRC_PLATFORM_CFG "" 49 #define TRC_PLATFORM_CFG_MAJOR 1 50 #define TRC_PLATFORM_CFG_MINOR 0 51 #define TRC_PLATFORM_CFG_PATCH 0 52 53 /* For ARM Cortex-M devices - assumes the ARM CMSIS API is available */ 54 #if (defined (__CORTEX_M)) 55 #define TRACE_ALLOC_CRITICAL_SECTION() uint32_t __irq_status; 56 #define TRACE_ENTER_CRITICAL_SECTION() {__irq_status = __get_PRIMASK(); __set_PRIMASK(1);} /* PRIMASK disables ALL interrupts - allows for tracing in any ISR */ 57 #define TRACE_EXIT_CRITICAL_SECTION() {__set_PRIMASK(__irq_status);} 58 #endif 59 60 #if (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_Win32) 61 /* In the Win32 port, there are no real ISRs, so we don't need critical sections in this case... */ 62 #define TRACE_ALLOC_CRITICAL_SECTION() 63 #define TRACE_ENTER_CRITICAL_SECTION() 64 #define TRACE_EXIT_CRITICAL_SECTION() 65 #endif 66 67 #ifndef TRACE_ENTER_CRITICAL_SECTION 68 #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/" 69 #endif 70 71 72 /******************************************************************************/ 73 /*** Definitions for Snapshot mode ********************************************/ 74 /******************************************************************************/ 75 #if (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_SNAPSHOT) 76 77 /*** The object classes *******************************************************/ 78 79 /* Only the ISR class is needed for bare metal, so TRC_CFG_NTASK, TRC_CFG_NTIMER, etc. can be 0 to reduce memory usage. */ 80 81 #define TRACE_NCLASSES 9 82 #define TRACE_CLASS_QUEUE ((traceObjectClass)0) 83 #define TRACE_CLASS_SEMAPHORE ((traceObjectClass)1) 84 #define TRACE_CLASS_MUTEX ((traceObjectClass)2) 85 #define TRACE_CLASS_TASK ((traceObjectClass)3) 86 #define TRACE_CLASS_ISR ((traceObjectClass)4) 87 #define TRACE_CLASS_TIMER ((traceObjectClass)5) 88 #define TRACE_CLASS_EVENTGROUP ((traceObjectClass)6) 89 #define TRACE_CLASS_STREAMBUFFER ((traceObjectClass)7) 90 #define TRACE_CLASS_MESSAGEBUFFER ((traceObjectClass)8) 91 92 /*** Definitions for Object Table ********************************************/ 93 #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) 94 95 /* Queue properties (except name): current number of message in queue */ 96 #define PropertyTableSizeQueue (TRC_CFG_NAME_LEN_QUEUE + 1) 97 98 /* Semaphore properties (except name): state (signaled = 1, cleared = 0) */ 99 #define PropertyTableSizeSemaphore (TRC_CFG_NAME_LEN_SEMAPHORE + 1) 100 101 /* Mutex properties (except name): owner (task handle, 0 = free) */ 102 #define PropertyTableSizeMutex (TRC_CFG_NAME_LEN_MUTEX + 1) 103 104 /* Task properties (except name): Byte 0: Current priority 105 Byte 1: state (if already active) 106 Byte 2: legacy, not used 107 Byte 3: legacy, not used */ 108 #define PropertyTableSizeTask (TRC_CFG_NAME_LEN_TASK + 4) 109 110 /* ISR properties: Byte 0: priority 111 Byte 1: state (if already active) */ 112 #define PropertyTableSizeISR (TRC_CFG_NAME_LEN_ISR + 2) 113 114 /* TRC_CFG_NTIMER properties: Byte 0: state (unused for now) */ 115 #define PropertyTableSizeTimer (TRC_CFG_NAME_LEN_TIMER + 1) 116 117 /* TRC_CFG_NEVENTGROUP properties: Byte 0-3: state (unused for now)*/ 118 #define PropertyTableSizeEventGroup (TRC_CFG_NAME_LEN_EVENTGROUP + 4) 119 120 /* TRC_CFG_NSTREAMBUFFER properties: Byte 0-3: state (unused for now)*/ 121 #define PropertyTableSizeStreamBuffer (TRC_CFG_NAME_LEN_STREAMBUFFER + 4) 122 123 /* TRC_CFG_NMESSAGEBUFFER properties: Byte 0-3: state (unused for now)*/ 124 #define PropertyTableSizeMessageBuffer (TRC_CFG_NAME_LEN_MESSAGEBUFFER + 4) 125 126 127 /* The layout of the byte array representing the Object Property Table */ 128 #define StartIndexQueue 0 129 #define StartIndexSemaphore StartIndexQueue + TRC_CFG_NQUEUE * PropertyTableSizeQueue 130 #define StartIndexMutex StartIndexSemaphore + TRC_CFG_NSEMAPHORE * PropertyTableSizeSemaphore 131 #define StartIndexTask StartIndexMutex + TRC_CFG_NMUTEX * PropertyTableSizeMutex 132 #define StartIndexISR StartIndexTask + TRC_CFG_NTASK * PropertyTableSizeTask 133 #define StartIndexTimer StartIndexISR + TRC_CFG_NISR * PropertyTableSizeISR 134 #define StartIndexEventGroup StartIndexTimer + TRC_CFG_NTIMER * PropertyTableSizeTimer 135 #define StartIndexStreamBuffer StartIndexEventGroup + TRC_CFG_NEVENTGROUP * PropertyTableSizeEventGroup 136 #define StartIndexMessageBuffer StartIndexStreamBuffer + TRC_CFG_NSTREAMBUFFER * PropertyTableSizeStreamBuffer 137 138 /* Number of bytes used by the object table */ 139 #define TRACE_OBJECT_TABLE_SIZE StartIndexMessageBuffer + TRC_CFG_NMESSAGEBUFFER * PropertyTableSizeMessageBuffer 140 141 /* Initialization of the object property table */ 142 void vTraceInitObjectPropertyTable(void); 143 144 /* Initialization of the handle mechanism, see e.g, prvTraceGetObjectHandle */ 145 void vTraceInitObjectHandleStack(void); 146 147 /* Returns the "Not enough handles" error message for the specified object class */ 148 const char* pszTraceGetErrorNotEnoughHandles(traceObjectClass objectclass); 149 150 151 /*** Event codes for snapshot mode - must match Tracealyzer config files ******/ 152 153 #define NULL_EVENT (0x00UL) 154 155 /******************************************************************************* 156 * EVENTGROUP_DIV 157 * 158 * Miscellaneous events. 159 ******************************************************************************/ 160 #define EVENTGROUP_DIV (NULL_EVENT + 1UL) /*0x01*/ 161 #define DIV_XPS (EVENTGROUP_DIV + 0UL) /*0x01*/ 162 #define DIV_TASK_READY (EVENTGROUP_DIV + 1UL) /*0x02*/ 163 #define DIV_NEW_TIME (EVENTGROUP_DIV + 2UL) /*0x03*/ 164 165 /******************************************************************************* 166 * EVENTGROUP_TS 167 * 168 * Events for storing task-switches and interrupts. The RESUME events are 169 * generated if the task/interrupt is already marked active. 170 ******************************************************************************/ 171 #define EVENTGROUP_TS (EVENTGROUP_DIV + 3UL) /*0x04*/ 172 #define TS_ISR_BEGIN (EVENTGROUP_TS + 0UL) /*0x04*/ 173 #define TS_ISR_RESUME (EVENTGROUP_TS + 1UL) /*0x05*/ 174 #define TS_TASK_BEGIN (EVENTGROUP_TS + 2UL) /*0x06*/ 175 #define TS_TASK_RESUME (EVENTGROUP_TS + 3UL) /*0x07*/ 176 177 /******************************************************************************* 178 * EVENTGROUP_OBJCLOSE_NAME 179 * 180 * About Close Events 181 * When an object is evicted from the object property table (object close), two 182 * internal events are stored (EVENTGROUP_OBJCLOSE_NAME and 183 * EVENTGROUP_OBJCLOSE_PROP), containing the handle-name mapping and object 184 * properties valid up to this point. 185 ******************************************************************************/ 186 #define EVENTGROUP_OBJCLOSE_NAME_SUCCESS (EVENTGROUP_TS + 4UL) /*0x08*/ 187 188 /******************************************************************************* 189 * EVENTGROUP_OBJCLOSE_PROP 190 * 191 * The internal event carrying properties of deleted objects 192 * The handle and object class of the closed object is not stored in this event, 193 * but is assumed to be the same as in the preceding CLOSE event. Thus, these 194 * two events must be generated from within a critical section. 195 * When queues are closed, arg1 is the "state" property (i.e., number of 196 * buffered messages/signals). 197 * When actors are closed, arg1 is priority, arg2 is handle of the "instance 198 * finish" event, and arg3 is event code of the "instance finish" event. 199 * In this case, the lower three bits is the object class of the instance finish 200 * handle. The lower three bits are not used (always zero) when queues are 201 * closed since the queue type is given in the previous OBJCLOSE_NAME event. 202 ******************************************************************************/ 203 #define EVENTGROUP_OBJCLOSE_PROP_SUCCESS (EVENTGROUP_OBJCLOSE_NAME_SUCCESS + 8UL) /*0x10*/ 204 205 /******************************************************************************* 206 * EVENTGROUP_CREATE 207 * 208 * The events in this group are used to log Kernel object creations. 209 * The lower three bits in the event code gives the object class, i.e., type of 210 * create operation (task, queue, semaphore, etc). 211 ******************************************************************************/ 212 #define EVENTGROUP_CREATE_OBJ_SUCCESS (EVENTGROUP_OBJCLOSE_PROP_SUCCESS + 8UL) /*0x18*/ 213 214 /******************************************************************************* 215 * EVENTGROUP_SEND 216 * 217 * The events in this group are used to log Send/Give events on queues, 218 * semaphores and mutexes The lower three bits in the event code gives the 219 * object class, i.e., what type of object that is operated on (queue, semaphore 220 * or mutex). 221 ******************************************************************************/ 222 #define EVENTGROUP_SEND_SUCCESS (EVENTGROUP_CREATE_OBJ_SUCCESS + 8UL) /*0x20*/ 223 224 /******************************************************************************* 225 * EVENTGROUP_RECEIVE 226 * 227 * The events in this group are used to log Receive/Take events on queues, 228 * semaphores and mutexes. The lower three bits in the event code gives the 229 * object class, i.e., what type of object that is operated on (queue, semaphore 230 * or mutex). 231 ******************************************************************************/ 232 #define EVENTGROUP_RECEIVE_SUCCESS (EVENTGROUP_SEND_SUCCESS + 8UL) /*0x28*/ 233 234 /* Send/Give operations, from ISR */ 235 #define EVENTGROUP_SEND_FROM_ISR_SUCCESS \ 236 (EVENTGROUP_RECEIVE_SUCCESS + 8UL) /*0x30*/ 237 238 /* Receive/Take operations, from ISR */ 239 #define EVENTGROUP_RECEIVE_FROM_ISR_SUCCESS \ 240 (EVENTGROUP_SEND_FROM_ISR_SUCCESS + 8UL) /*0x38*/ 241 242 /* "Failed" event type versions of above (timeout, failed allocation, etc) */ 243 #define EVENTGROUP_KSE_FAILED \ 244 (EVENTGROUP_RECEIVE_FROM_ISR_SUCCESS + 8UL) /*0x40*/ 245 246 /* Failed create calls - memory allocation failed */ 247 #define EVENTGROUP_CREATE_OBJ_FAILED (EVENTGROUP_KSE_FAILED) /*0x40*/ 248 249 /* Failed send/give - timeout! */ 250 #define EVENTGROUP_SEND_FAILED (EVENTGROUP_CREATE_OBJ_FAILED + 8UL) /*0x48*/ 251 252 /* Failed receive/take - timeout! */ 253 #define EVENTGROUP_RECEIVE_FAILED (EVENTGROUP_SEND_FAILED + 8UL) /*0x50*/ 254 255 /* Failed non-blocking send/give - queue full */ 256 #define EVENTGROUP_SEND_FROM_ISR_FAILED (EVENTGROUP_RECEIVE_FAILED + 8UL) /*0x58*/ 257 258 /* Failed non-blocking receive/take - queue empty */ 259 #define EVENTGROUP_RECEIVE_FROM_ISR_FAILED \ 260 (EVENTGROUP_SEND_FROM_ISR_FAILED + 8UL) /*0x60*/ 261 262 /* Events when blocking on receive/take */ 263 #define EVENTGROUP_RECEIVE_BLOCK \ 264 (EVENTGROUP_RECEIVE_FROM_ISR_FAILED + 8UL) /*0x68*/ 265 266 /* Events when blocking on send/give */ 267 #define EVENTGROUP_SEND_BLOCK (EVENTGROUP_RECEIVE_BLOCK + 8UL) /*0x70*/ 268 269 /* Events on queue peek (receive) */ 270 #define EVENTGROUP_PEEK_SUCCESS (EVENTGROUP_SEND_BLOCK + 8UL) /*0x78*/ 271 272 /* Events on object delete (vTaskDelete or vQueueDelete) */ 273 #define EVENTGROUP_DELETE_OBJ_SUCCESS (EVENTGROUP_PEEK_SUCCESS + 8UL) /*0x80*/ 274 275 /* Other events - object class is implied: TASK */ 276 #define EVENTGROUP_OTHERS (EVENTGROUP_DELETE_OBJ_SUCCESS + 8UL) /*0x88*/ 277 #define TASK_DELAY_UNTIL (EVENTGROUP_OTHERS + 0UL) /*0x88*/ 278 #define TASK_DELAY (EVENTGROUP_OTHERS + 1UL) /*0x89*/ 279 #define TASK_SUSPEND (EVENTGROUP_OTHERS + 2UL) /*0x8A*/ 280 #define TASK_RESUME (EVENTGROUP_OTHERS + 3UL) /*0x8B*/ 281 #define TASK_RESUME_FROM_ISR (EVENTGROUP_OTHERS + 4UL) /*0x8C*/ 282 #define TASK_PRIORITY_SET (EVENTGROUP_OTHERS + 5UL) /*0x8D*/ 283 #define TASK_PRIORITY_INHERIT (EVENTGROUP_OTHERS + 6UL) /*0x8E*/ 284 #define TASK_PRIORITY_DISINHERIT (EVENTGROUP_OTHERS + 7UL) /*0x8F*/ 285 286 #define EVENTGROUP_MISC_PLACEHOLDER (EVENTGROUP_OTHERS + 8UL) /*0x90*/ 287 #define PEND_FUNC_CALL (EVENTGROUP_MISC_PLACEHOLDER+0UL) /*0x90*/ 288 #define PEND_FUNC_CALL_FROM_ISR (EVENTGROUP_MISC_PLACEHOLDER+1UL) /*0x91*/ 289 #define PEND_FUNC_CALL_FAILED (EVENTGROUP_MISC_PLACEHOLDER+2UL) /*0x92*/ 290 #define PEND_FUNC_CALL_FROM_ISR_FAILED (EVENTGROUP_MISC_PLACEHOLDER+3UL) /*0x93*/ 291 #define MEM_MALLOC_SIZE (EVENTGROUP_MISC_PLACEHOLDER+4UL) /*0x94*/ 292 #define MEM_MALLOC_ADDR (EVENTGROUP_MISC_PLACEHOLDER+5UL) /*0x95*/ 293 #define MEM_FREE_SIZE (EVENTGROUP_MISC_PLACEHOLDER+6UL) /*0x96*/ 294 #define MEM_FREE_ADDR (EVENTGROUP_MISC_PLACEHOLDER+7UL) /*0x97*/ 295 296 /* User events */ 297 #define EVENTGROUP_USEREVENT (EVENTGROUP_MISC_PLACEHOLDER + 8UL) /*0x98*/ 298 #define USER_EVENT (EVENTGROUP_USEREVENT + 0UL) 299 300 /* Allow for 0-15 arguments (the number of args is added to event code) */ 301 #define USER_EVENT_LAST (EVENTGROUP_USEREVENT + 15UL) /*0xA7*/ 302 303 #define EVENTGROUP_SYS (EVENTGROUP_USEREVENT + 16UL) /*0xA8*/ 304 #define XTS8 (EVENTGROUP_SYS + 0UL) /*0xA8*/ 305 #define XTS16 (EVENTGROUP_SYS + 1UL) /*0xA9*/ 306 #define EVENT_BEING_WRITTEN (EVENTGROUP_SYS + 2UL) /*0xAA*/ 307 #define RESERVED_DUMMY_CODE (EVENTGROUP_SYS + 3UL) /*0xAB*/ 308 #define LOW_POWER_BEGIN (EVENTGROUP_SYS + 4UL) /*0xAC*/ 309 #define LOW_POWER_END (EVENTGROUP_SYS + 5UL) /*0xAD*/ 310 #define XID (EVENTGROUP_SYS + 6UL) /*0xAE*/ 311 #define XTS16L (EVENTGROUP_SYS + 7UL) /*0xAF*/ 312 313 #define EVENTGROUP_TIMER (EVENTGROUP_SYS + 8UL) /*0xB0*/ 314 #define TIMER_CREATE (EVENTGROUP_TIMER + 0UL) /*0xB0*/ 315 #define TIMER_START (EVENTGROUP_TIMER + 1UL) /*0xB1*/ 316 #define TIMER_RST (EVENTGROUP_TIMER + 2UL) /*0xB2*/ 317 #define TIMER_STOP (EVENTGROUP_TIMER + 3UL) /*0xB3*/ 318 #define TIMER_CHANGE_PERIOD (EVENTGROUP_TIMER + 4UL) /*0xB4*/ 319 #define TIMER_DELETE_OBJ (EVENTGROUP_TIMER + 5UL) /*0xB5*/ 320 #define TIMER_START_FROM_ISR (EVENTGROUP_TIMER + 6UL) /*0xB6*/ 321 #define TIMER_RESET_FROM_ISR (EVENTGROUP_TIMER + 7UL) /*0xB7*/ 322 #define TIMER_STOP_FROM_ISR (EVENTGROUP_TIMER + 8UL) /*0xB8*/ 323 324 #define TIMER_CREATE_FAILED (EVENTGROUP_TIMER + 9UL) /*0xB9*/ 325 #define TIMER_START_FAILED (EVENTGROUP_TIMER + 10UL) /*0xBA*/ 326 #define TIMER_RESET_FAILED (EVENTGROUP_TIMER + 11UL) /*0xBB*/ 327 #define TIMER_STOP_FAILED (EVENTGROUP_TIMER + 12UL) /*0xBC*/ 328 #define TIMER_CHANGE_PERIOD_FAILED (EVENTGROUP_TIMER + 13UL) /*0xBD*/ 329 #define TIMER_DELETE_FAILED (EVENTGROUP_TIMER + 14UL) /*0xBE*/ 330 #define TIMER_START_FROM_ISR_FAILED (EVENTGROUP_TIMER + 15UL) /*0xBF*/ 331 #define TIMER_RESET_FROM_ISR_FAILED (EVENTGROUP_TIMER + 16UL) /*0xC0*/ 332 #define TIMER_STOP_FROM_ISR_FAILED (EVENTGROUP_TIMER + 17UL) /*0xC1*/ 333 334 #define EVENTGROUP_EG (EVENTGROUP_TIMER + 18UL) /*0xC2*/ 335 #define EVENT_GROUP_CREATE (EVENTGROUP_EG + 0UL) /*0xC2*/ 336 #define EVENT_GROUP_CREATE_FAILED (EVENTGROUP_EG + 1UL) /*0xC3*/ 337 #define EVENT_GROUP_SYNC_BLOCK (EVENTGROUP_EG + 2UL) /*0xC4*/ 338 #define EVENT_GROUP_SYNC_END (EVENTGROUP_EG + 3UL) /*0xC5*/ 339 #define EVENT_GROUP_WAIT_BITS_BLOCK (EVENTGROUP_EG + 4UL) /*0xC6*/ 340 #define EVENT_GROUP_WAIT_BITS_END (EVENTGROUP_EG + 5UL) /*0xC7*/ 341 #define EVENT_GROUP_CLEAR_BITS (EVENTGROUP_EG + 6UL) /*0xC8*/ 342 #define EVENT_GROUP_CLEAR_BITS_FROM_ISR (EVENTGROUP_EG + 7UL) /*0xC9*/ 343 #define EVENT_GROUP_SET_BITS (EVENTGROUP_EG + 8UL) /*0xCA*/ 344 #define EVENT_GROUP_DELETE_OBJ (EVENTGROUP_EG + 9UL) /*0xCB*/ 345 #define EVENT_GROUP_SYNC_END_FAILED (EVENTGROUP_EG + 10UL) /*0xCC*/ 346 #define EVENT_GROUP_WAIT_BITS_END_FAILED (EVENTGROUP_EG + 11UL) /*0xCD*/ 347 #define EVENT_GROUP_SET_BITS_FROM_ISR (EVENTGROUP_EG + 12UL) /*0xCE*/ 348 #define EVENT_GROUP_SET_BITS_FROM_ISR_FAILED (EVENTGROUP_EG + 13UL) /*0xCF*/ 349 350 #define TASK_INSTANCE_FINISHED_NEXT_KSE (EVENTGROUP_EG + 14UL) /*0xD0*/ 351 #define TASK_INSTANCE_FINISHED_DIRECT (EVENTGROUP_EG + 15UL) /*0xD1*/ 352 353 #define TRACE_TASK_NOTIFY_GROUP (EVENTGROUP_EG + 16UL) /*0xD2*/ 354 #define TRACE_TASK_NOTIFY (TRACE_TASK_NOTIFY_GROUP + 0UL) /*0xD2*/ 355 #define TRACE_TASK_NOTIFY_TAKE (TRACE_TASK_NOTIFY_GROUP + 1UL) /*0xD3*/ 356 #define TRACE_TASK_NOTIFY_TAKE_BLOCK (TRACE_TASK_NOTIFY_GROUP + 2UL) /*0xD4*/ 357 #define TRACE_TASK_NOTIFY_TAKE_FAILED (TRACE_TASK_NOTIFY_GROUP + 3UL) /*0xD5*/ 358 #define TRACE_TASK_NOTIFY_WAIT (TRACE_TASK_NOTIFY_GROUP + 4UL) /*0xD6*/ 359 #define TRACE_TASK_NOTIFY_WAIT_BLOCK (TRACE_TASK_NOTIFY_GROUP + 5UL) /*0xD7*/ 360 #define TRACE_TASK_NOTIFY_WAIT_FAILED (TRACE_TASK_NOTIFY_GROUP + 6UL) /*0xD8*/ 361 #define TRACE_TASK_NOTIFY_FROM_ISR (TRACE_TASK_NOTIFY_GROUP + 7UL) /*0xD9*/ 362 #define TRACE_TASK_NOTIFY_GIVE_FROM_ISR (TRACE_TASK_NOTIFY_GROUP + 8UL) /*0xDA*/ 363 364 #define TIMER_EXPIRED (TRACE_TASK_NOTIFY_GROUP + 9UL) /* 0xDB */ 365 366 /* Events on queue peek (receive) */ 367 #define EVENTGROUP_PEEK_BLOCK (TRACE_TASK_NOTIFY_GROUP + 10UL) /*0xDC*/ 368 /* peek block on queue: 0xDC */ 369 /* peek block on semaphore: 0xDD */ 370 /* peek block on mutex: 0xDE */ 371 372 /* Events on queue peek (receive) */ 373 #define EVENTGROUP_PEEK_FAILED (EVENTGROUP_PEEK_BLOCK + 3UL) /*0xDF*/ 374 /* peek failed on queue: 0xDF */ 375 /* peek failed on semaphore: 0xE0 */ 376 /* peek failed on mutex: 0xE1 */ 377 378 #define EVENTGROUP_STREAMBUFFER_DIV (EVENTGROUP_PEEK_FAILED + 3UL) /*0xE2*/ 379 #define TRACE_STREAMBUFFER_RESET (EVENTGROUP_STREAMBUFFER_DIV + 0) /*0xE2*/ 380 #define TRACE_MESSAGEBUFFER_RESET (EVENTGROUP_STREAMBUFFER_DIV + 1UL) /*0xE3*/ 381 #define TRACE_STREAMBUFFER_OBJCLOSE_NAME_SUCCESS (EVENTGROUP_STREAMBUFFER_DIV + 2UL) /*0xE4*/ 382 #define TRACE_MESSAGEBUFFER_OBJCLOSE_NAME_SUCCESS (EVENTGROUP_STREAMBUFFER_DIV + 3UL) /*0xE5*/ 383 #define TRACE_STREAMBUFFER_OBJCLOSE_PROP_SUCCESS (EVENTGROUP_STREAMBUFFER_DIV + 4UL) /*0xE6*/ 384 #define TRACE_MESSAGEBUFFER_OBJCLOSE_PROP_SUCCESS (EVENTGROUP_STREAMBUFFER_DIV + 5UL) /*0xE7*/ 385 386 /* The following are using previously "lost" event codes */ 387 #define TRACE_STREAMBUFFER_CREATE_OBJ_SUCCESS (EVENTGROUP_CREATE_OBJ_SUCCESS + 4UL) /*0x1C*/ 388 #define TRACE_STREAMBUFFER_CREATE_OBJ_FAILED (EVENTGROUP_CREATE_OBJ_FAILED + 4UL) /*0x44*/ 389 #define TRACE_STREAMBUFFER_DELETE_OBJ_SUCCESS (EVENTGROUP_DELETE_OBJ_SUCCESS + 4UL) /*0x84*/ 390 #define TRACE_STREAMBUFFER_SEND_SUCCESS (EVENTGROUP_SEND_SUCCESS + 3UL) /*0x23*/ 391 #define TRACE_STREAMBUFFER_SEND_BLOCK (EVENTGROUP_SEND_BLOCK + 3UL) /*0x73*/ 392 #define TRACE_STREAMBUFFER_SEND_FAILED (EVENTGROUP_SEND_FAILED + 3UL) /*0x4B*/ 393 #define TRACE_STREAMBUFFER_RECEIVE_SUCCESS (EVENTGROUP_RECEIVE_SUCCESS + 3UL) /*0x2B*/ 394 #define TRACE_STREAMBUFFER_RECEIVE_BLOCK (EVENTGROUP_RECEIVE_BLOCK + 3UL) /*0x6B*/ 395 #define TRACE_STREAMBUFFER_RECEIVE_FAILED (EVENTGROUP_RECEIVE_FAILED + 3UL) /*0x53*/ 396 #define TRACE_STREAMBUFFER_SEND_FROM_ISR_SUCCESS (EVENTGROUP_SEND_FROM_ISR_SUCCESS + 3UL) /*0x33*/ 397 #define TRACE_STREAMBUFFER_SEND_FROM_ISR_FAILED (EVENTGROUP_SEND_FROM_ISR_FAILED + 3UL) /*0x5B*/ 398 #define TRACE_STREAMBUFFER_RECEIVE_FROM_ISR_SUCCESS (EVENTGROUP_RECEIVE_FROM_ISR_SUCCESS + 3UL) /*0x3B*/ 399 #define TRACE_STREAMBUFFER_RECEIVE_FROM_ISR_FAILED (EVENTGROUP_RECEIVE_FROM_ISR_FAILED + 3UL) /*0x63*/ 400 401 /* The following are using previously "lost" event codes. These macros aren't even directly referenced, instead we do (equivalent STREAMBUFFER code) + 1. */ 402 #define TRACE_MESSAGEBUFFER_CREATE_OBJ_SUCCESS (EVENTGROUP_CREATE_OBJ_SUCCESS + 5UL) /*0x1D*/ 403 #define TRACE_MESSAGEBUFFER_CREATE_OBJ_FAILED (EVENTGROUP_CREATE_OBJ_FAILED + 5UL) /*0x45*/ 404 #define TRACE_MESSAGEBUFFER_DELETE_OBJ_SUCCESS (EVENTGROUP_DELETE_OBJ_SUCCESS + 5UL) /*0x85*/ 405 #define TRACE_MESSAGEBUFFER_SEND_SUCCESS (EVENTGROUP_SEND_SUCCESS + 4UL) /*0x24*/ 406 #define TRACE_MESSAGEBUFFER_SEND_BLOCK (EVENTGROUP_SEND_BLOCK + 4UL) /*0x74*/ 407 #define TRACE_MESSAGEBUFFER_SEND_FAILED (EVENTGROUP_SEND_FAILED + 4UL) /*0x4C*/ 408 #define TRACE_MESSAGEBUFFER_RECEIVE_SUCCESS (EVENTGROUP_RECEIVE_SUCCESS + 4UL) /*0x2C*/ 409 #define TRACE_MESSAGEBUFFER_RECEIVE_BLOCK (EVENTGROUP_RECEIVE_BLOCK + 4UL) /*0x6C*/ 410 #define TRACE_MESSAGEBUFFER_RECEIVE_FAILED (EVENTGROUP_RECEIVE_FAILED + 4UL) /*0x54*/ 411 #define TRACE_MESSAGEBUFFER_SEND_FROM_ISR_SUCCESS (EVENTGROUP_SEND_FROM_ISR_SUCCESS + 4UL) /*0x34*/ 412 #define TRACE_MESSAGEBUFFER_SEND_FROM_ISR_FAILED (EVENTGROUP_SEND_FROM_ISR_FAILED + 4UL) /*0x5C*/ 413 #define TRACE_MESSAGEBUFFER_RECEIVE_FROM_ISR_SUCCESS (EVENTGROUP_RECEIVE_FROM_ISR_SUCCESS + 4UL) /*0x3C*/ 414 #define TRACE_MESSAGEBUFFER_RECEIVE_FROM_ISR_FAILED (EVENTGROUP_RECEIVE_FROM_ISR_FAILED + 4UL) /*0x64*/ 415 416 /* LAST EVENT (0xE7) */ 417 418 /* Not needed in snapshot mode */ 419 #define vTracePeriodicControl() 420 421 #endif /*#if TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_SNAPSHOT */ 422 423 /******************************************************************************/ 424 /*** Definitions for Streaming mode *******************************************/ 425 /******************************************************************************/ 426 #if (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING) 427 428 /******************************************************************************* 429 * vTraceStoreKernelObjectName 430 * 431 * Set the name for a kernel object (defined by its address). 432 ******************************************************************************/ 433 void vTraceStoreKernelObjectName(void* object, const char* name); 434 435 /* For bare metal test - replaces TzCtrl task - call this periodically */ 436 void vTracePeriodicControl(void); 437 438 /*************************************************************************/ 439 /* KERNEL SPECIFIC OBJECT CONFIGURATION */ 440 /*************************************************************************/ 441 442 /******************************************************************************* 443 * The event codes - should match the offline config file. 444 ******************************************************************************/ 445 446 /*** Event codes for streaming - should match the Tracealyzer config file *****/ 447 #define PSF_EVENT_NULL_EVENT 0x00 448 449 #define PSF_EVENT_TRACE_START 0x01 450 #define PSF_EVENT_TS_CONFIG 0x02 451 #define PSF_EVENT_OBJ_NAME 0x03 452 453 #define PSF_EVENT_TASK_PRIORITY 0x04 454 #define PSF_EVENT_TASK_PRIO_INHERIT 0x05 455 #define PSF_EVENT_TASK_PRIO_DISINHERIT 0x06 456 #define PSF_EVENT_DEFINE_ISR 0x07 457 458 #define PSF_EVENT_TASK_CREATE 0x10 459 #define PSF_EVENT_QUEUE_CREATE 0x11 460 #define PSF_EVENT_SEMAPHORE_BINARY_CREATE 0x12 461 #define PSF_EVENT_MUTEX_CREATE 0x13 462 #define PSF_EVENT_TIMER_CREATE 0x14 463 #define PSF_EVENT_EVENTGROUP_CREATE 0x15 464 #define PSF_EVENT_SEMAPHORE_COUNTING_CREATE 0x16 465 #define PSF_EVENT_MUTEX_RECURSIVE_CREATE 0x17 466 #define PSF_EVENT_STREAMBUFFER_CREATE 0x18 467 #define PSF_EVENT_MESSAGEBUFFER_CREATE 0x19 468 469 #define PSF_EVENT_TASK_DELETE 0x20 470 #define PSF_EVENT_QUEUE_DELETE 0x21 471 #define PSF_EVENT_SEMAPHORE_DELETE 0x22 472 #define PSF_EVENT_MUTEX_DELETE 0x23 473 #define PSF_EVENT_TIMER_DELETE 0x24 474 #define PSF_EVENT_EVENTGROUP_DELETE 0x25 475 #define PSF_EVENT_STREAMBUFFER_DELETE 0x28 476 #define PSF_EVENT_MESSAGEBUFFER_DELETE 0x29 477 478 #define PSF_EVENT_TASK_READY 0x30 479 #define PSF_EVENT_NEW_TIME 0x31 480 #define PSF_EVENT_NEW_TIME_SCHEDULER_SUSPENDED 0x32 481 #define PSF_EVENT_ISR_BEGIN 0x33 482 #define PSF_EVENT_ISR_RESUME 0x34 483 #define PSF_EVENT_TS_BEGIN 0x35 484 #define PSF_EVENT_TS_RESUME 0x36 485 #define PSF_EVENT_TASK_ACTIVATE 0x37 486 487 #define PSF_EVENT_MALLOC 0x38 488 #define PSF_EVENT_FREE 0x39 489 490 #define PSF_EVENT_LOWPOWER_BEGIN 0x3A 491 #define PSF_EVENT_LOWPOWER_END 0x3B 492 493 #define PSF_EVENT_IFE_NEXT 0x3C 494 #define PSF_EVENT_IFE_DIRECT 0x3D 495 496 #define PSF_EVENT_TASK_CREATE_FAILED 0x40 497 #define PSF_EVENT_QUEUE_CREATE_FAILED 0x41 498 #define PSF_EVENT_SEMAPHORE_BINARY_CREATE_FAILED 0x42 499 #define PSF_EVENT_MUTEX_CREATE_FAILED 0x43 500 #define PSF_EVENT_TIMER_CREATE_FAILED 0x44 501 #define PSF_EVENT_EVENTGROUP_CREATE_FAILED 0x45 502 #define PSF_EVENT_SEMAPHORE_COUNTING_CREATE_FAILED 0x46 503 #define PSF_EVENT_MUTEX_RECURSIVE_CREATE_FAILED 0x47 504 #define PSF_EVENT_STREAMBUFFER_CREATE_FAILED 0x49 505 #define PSF_EVENT_MESSAGEBUFFER_CREATE_FAILED 0x4A 506 507 #define PSF_EVENT_TIMER_DELETE_FAILED 0x48 508 509 #define PSF_EVENT_QUEUE_SEND 0x50 510 #define PSF_EVENT_SEMAPHORE_GIVE 0x51 511 #define PSF_EVENT_MUTEX_GIVE 0x52 512 513 #define PSF_EVENT_QUEUE_SEND_FAILED 0x53 514 #define PSF_EVENT_SEMAPHORE_GIVE_FAILED 0x54 515 #define PSF_EVENT_MUTEX_GIVE_FAILED 0x55 516 517 #define PSF_EVENT_QUEUE_SEND_BLOCK 0x56 518 #define PSF_EVENT_SEMAPHORE_GIVE_BLOCK 0x57 519 #define PSF_EVENT_MUTEX_GIVE_BLOCK 0x58 520 521 #define PSF_EVENT_QUEUE_SEND_FROMISR 0x59 522 #define PSF_EVENT_SEMAPHORE_GIVE_FROMISR 0x5A 523 524 #define PSF_EVENT_QUEUE_SEND_FROMISR_FAILED 0x5C 525 #define PSF_EVENT_SEMAPHORE_GIVE_FROMISR_FAILED 0x5D 526 527 #define PSF_EVENT_QUEUE_RECEIVE 0x60 528 #define PSF_EVENT_SEMAPHORE_TAKE 0x61 529 #define PSF_EVENT_MUTEX_TAKE 0x62 530 531 #define PSF_EVENT_QUEUE_RECEIVE_FAILED 0x63 532 #define PSF_EVENT_SEMAPHORE_TAKE_FAILED 0x64 533 #define PSF_EVENT_MUTEX_TAKE_FAILED 0x65 534 535 #define PSF_EVENT_QUEUE_RECEIVE_BLOCK 0x66 536 #define PSF_EVENT_SEMAPHORE_TAKE_BLOCK 0x67 537 #define PSF_EVENT_MUTEX_TAKE_BLOCK 0x68 538 539 #define PSF_EVENT_QUEUE_RECEIVE_FROMISR 0x69 540 #define PSF_EVENT_SEMAPHORE_TAKE_FROMISR 0x6A 541 542 #define PSF_EVENT_QUEUE_RECEIVE_FROMISR_FAILED 0x6C 543 #define PSF_EVENT_SEMAPHORE_TAKE_FROMISR_FAILED 0x6D 544 545 #define PSF_EVENT_QUEUE_PEEK 0x70 546 #define PSF_EVENT_SEMAPHORE_PEEK 0x71 547 #define PSF_EVENT_MUTEX_PEEK 0x72 548 549 #define PSF_EVENT_QUEUE_PEEK_FAILED 0x73 550 #define PSF_EVENT_SEMAPHORE_PEEK_FAILED 0x74 551 #define PSF_EVENT_MUTEX_PEEK_FAILED 0x75 552 553 #define PSF_EVENT_QUEUE_PEEK_BLOCK 0x76 554 #define PSF_EVENT_SEMAPHORE_PEEK_BLOCK 0x77 555 #define PSF_EVENT_MUTEX_PEEK_BLOCK 0x78 556 557 #define PSF_EVENT_TASK_DELAY_UNTIL 0x79 558 #define PSF_EVENT_TASK_DELAY 0x7A 559 #define PSF_EVENT_TASK_SUSPEND 0x7B 560 #define PSF_EVENT_TASK_RESUME 0x7C 561 #define PSF_EVENT_TASK_RESUME_FROMISR 0x7D 562 563 #define PSF_EVENT_TIMER_PENDFUNCCALL 0x80 564 #define PSF_EVENT_TIMER_PENDFUNCCALL_FROMISR 0x81 565 #define PSF_EVENT_TIMER_PENDFUNCCALL_FAILED 0x82 566 #define PSF_EVENT_TIMER_PENDFUNCCALL_FROMISR_FAILED 0x83 567 568 #define PSF_EVENT_USER_EVENT 0x90 569 570 #define PSF_EVENT_TIMER_START 0xA0 571 #define PSF_EVENT_TIMER_RESET 0xA1 572 #define PSF_EVENT_TIMER_STOP 0xA2 573 #define PSF_EVENT_TIMER_CHANGEPERIOD 0xA3 574 #define PSF_EVENT_TIMER_START_FROMISR 0xA4 575 #define PSF_EVENT_TIMER_RESET_FROMISR 0xA5 576 #define PSF_EVENT_TIMER_STOP_FROMISR 0xA6 577 #define PSF_EVENT_TIMER_CHANGEPERIOD_FROMISR 0xA7 578 #define PSF_EVENT_TIMER_START_FAILED 0xA8 579 #define PSF_EVENT_TIMER_RESET_FAILED 0xA9 580 #define PSF_EVENT_TIMER_STOP_FAILED 0xAA 581 #define PSF_EVENT_TIMER_CHANGEPERIOD_FAILED 0xAB 582 #define PSF_EVENT_TIMER_START_FROMISR_FAILED 0xAC 583 #define PSF_EVENT_TIMER_RESET_FROMISR_FAILED 0xAD 584 #define PSF_EVENT_TIMER_STOP_FROMISR_FAILED 0xAE 585 #define PSF_EVENT_TIMER_CHANGEPERIOD_FROMISR_FAILED 0xAF 586 587 #define PSF_EVENT_EVENTGROUP_SYNC 0xB0 588 #define PSF_EVENT_EVENTGROUP_WAITBITS 0xB1 589 #define PSF_EVENT_EVENTGROUP_CLEARBITS 0xB2 590 #define PSF_EVENT_EVENTGROUP_CLEARBITS_FROMISR 0xB3 591 #define PSF_EVENT_EVENTGROUP_SETBITS 0xB4 592 #define PSF_EVENT_EVENTGROUP_SETBITS_FROMISR 0xB5 593 #define PSF_EVENT_EVENTGROUP_SYNC_BLOCK 0xB6 594 #define PSF_EVENT_EVENTGROUP_WAITBITS_BLOCK 0xB7 595 #define PSF_EVENT_EVENTGROUP_SYNC_FAILED 0xB8 596 #define PSF_EVENT_EVENTGROUP_WAITBITS_FAILED 0xB9 597 598 #define PSF_EVENT_QUEUE_SEND_FRONT 0xC0 599 #define PSF_EVENT_QUEUE_SEND_FRONT_FAILED 0xC1 600 #define PSF_EVENT_QUEUE_SEND_FRONT_BLOCK 0xC2 601 #define PSF_EVENT_QUEUE_SEND_FRONT_FROMISR 0xC3 602 #define PSF_EVENT_QUEUE_SEND_FRONT_FROMISR_FAILED 0xC4 603 #define PSF_EVENT_MUTEX_GIVE_RECURSIVE 0xC5 604 #define PSF_EVENT_MUTEX_GIVE_RECURSIVE_FAILED 0xC6 605 #define PSF_EVENT_MUTEX_TAKE_RECURSIVE 0xC7 606 #define PSF_EVENT_MUTEX_TAKE_RECURSIVE_FAILED 0xC8 607 608 #define PSF_EVENT_TASK_NOTIFY 0xC9 609 #define PSF_EVENT_TASK_NOTIFY_TAKE 0xCA 610 #define PSF_EVENT_TASK_NOTIFY_TAKE_BLOCK 0xCB 611 #define PSF_EVENT_TASK_NOTIFY_TAKE_FAILED 0xCC 612 #define PSF_EVENT_TASK_NOTIFY_WAIT 0xCD 613 #define PSF_EVENT_TASK_NOTIFY_WAIT_BLOCK 0xCE 614 #define PSF_EVENT_TASK_NOTIFY_WAIT_FAILED 0xCF 615 #define PSF_EVENT_TASK_NOTIFY_FROM_ISR 0xD0 616 #define PSF_EVENT_TASK_NOTIFY_GIVE_FROM_ISR 0xD1 617 618 #define PSF_EVENT_TIMER_EXPIRED 0xD2 619 620 #define PSF_EVENT_STREAMBUFFER_SEND 0xD3 621 #define PSF_EVENT_STREAMBUFFER_SEND_BLOCK 0xD4 622 #define PSF_EVENT_STREAMBUFFER_SEND_FAILED 0xD5 623 #define PSF_EVENT_STREAMBUFFER_RECEIVE 0xD6 624 #define PSF_EVENT_STREAMBUFFER_RECEIVE_BLOCK 0xD7 625 #define PSF_EVENT_STREAMBUFFER_RECEIVE_FAILED 0xD8 626 #define PSF_EVENT_STREAMBUFFER_SEND_FROM_ISR 0xD9 627 #define PSF_EVENT_STREAMBUFFER_SEND_FROM_ISR_FAILED 0xDA 628 #define PSF_EVENT_STREAMBUFFER_RECEIVE_FROM_ISR 0xDB 629 #define PSF_EVENT_STREAMBUFFER_RECEIVE_FROM_ISR_FAILED 0xDC 630 #define PSF_EVENT_STREAMBUFFER_RESET 0xDD 631 632 #define PSF_EVENT_MESSAGEBUFFER_SEND 0xDE 633 #define PSF_EVENT_MESSAGEBUFFER_SEND_BLOCK 0xDF 634 #define PSF_EVENT_MESSAGEBUFFER_SEND_FAILED 0xE0 635 #define PSF_EVENT_MESSAGEBUFFER_RECEIVE 0xE1 636 #define PSF_EVENT_MESSAGEBUFFER_RECEIVE_BLOCK 0xE2 637 #define PSF_EVENT_MESSAGEBUFFER_RECEIVE_FAILED 0xE3 638 #define PSF_EVENT_MESSAGEBUFFER_SEND_FROM_ISR 0xE4 639 #define PSF_EVENT_MESSAGEBUFFER_SEND_FROM_ISR_FAILED 0xE5 640 #define PSF_EVENT_MESSAGEBUFFER_RECEIVE_FROM_ISR 0xE6 641 #define PSF_EVENT_MESSAGEBUFFER_RECEIVE_FROM_ISR_FAILED 0xE7 642 #define PSF_EVENT_MESSAGEBUFFER_RESET 0xE8 643 644 #endif /* (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING) */ 645 646 #endif /* (TRC_USE_TRACEALYZER_RECORDER == 1) */ 647 648 #ifdef __cplusplus 649 } 650 #endif 651 652 #endif /* TRC_KERNEL_PORT_H */ 653