1 /* 2 * Percepio Trace Recorder for Tracealyzer v4.10.3 3 * Copyright 2023 Percepio AB 4 * www.percepio.com 5 * 6 * SPDX-License-Identifier: Apache-2.0 7 */ 8 9 /** 10 * @file 11 * 12 * @brief Public trace static buffer APIs. 13 */ 14 15 #ifndef TRC_STATIC_BUFFER_H 16 #define TRC_STATIC_BUFFER_H 17 18 #if (TRC_USE_TRACEALYZER_RECORDER == 1) && (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING) 19 20 #include <trcTypes.h> 21 22 #ifdef __cplusplus 23 extern "C" { 24 #endif 25 26 /** 27 * @defgroup trace_static_buffer_apis Trace Static Buffer APIs 28 * @ingroup trace_recorder_apis 29 * @{ 30 */ 31 32 /* A buffer type that is maximum size */ 33 typedef uint8_t TraceStaticBuffer_t[TRC_MAX_BLOB_SIZE]; 34 35 /** 36 * @internal Trace Core Static Buffer Core Structure 37 */ 38 typedef struct TraceCoreStaticBufferCore /* Aligned */ 39 { 40 TraceStaticBuffer_t dummyEvents[(TRC_CFG_MAX_ISR_NESTING) + 1]; /**< */ 41 } TraceCoreStaticBuffer_t; 42 43 /** 44 * @internal Trace Static Buffer Table Structure 45 */ 46 typedef struct TraceStaticBufferTable /* Aligned */ 47 { 48 TraceCoreStaticBuffer_t coreDummyEvents[TRC_CFG_CORE_COUNT]; /**< Temporary buffers used for event or blob creation. */ 49 } TraceStaticBufferTable_t; 50 51 extern TraceStaticBufferTable_t* pxTraceStaticBufferTable; 52 53 /** 54 * @internal Initialize trace static buffer. 55 * 56 * @param[in] pxBuffer Pointer to memory that will be used by the 57 * trace static buffer. 58 * 59 * @retval TRC_FAIL Failure 60 * @retval TRC_SUCCESS Success 61 */ 62 traceResult xTraceStaticBufferInitialize(TraceStaticBufferTable_t* pxBuffer); 63 64 #if ((TRC_CFG_USE_TRACE_ASSERT) == 1) 65 66 /** 67 * @brief Gets trace static buffer. 68 * 69 * @param[out] ppvBuffer Buffer. 70 * 71 * @retval TRC_FAIL Failure 72 * @retval TRC_SUCCESS Success 73 */ 74 traceResult xTraceStaticBufferGet(void **ppvBuffer); 75 76 #else /* ((TRC_CFG_USE_TRACE_ASSERT) == 1) */ 77 78 /** 79 * @brief Gets trace static buffer. 80 * 81 * @param[out] ppvBuffer Buffer. 82 * 83 * @retval TRC_FAIL Failure 84 * @retval TRC_SUCCESS Success 85 */ 86 #define xTraceStaticBufferGet(ppvBuffer) (*(ppvBuffer) = (void*)&pxTraceStaticBufferTable->coreDummyEvents[TRC_CFG_GET_CURRENT_CORE()].dummyEvents[xTraceISRGetCurrentNestingReturned() + 1], TRC_SUCCESS) 87 88 #endif /* ((TRC_CFG_USE_TRACE_ASSERT) == 1) */ 89 90 /** @} */ 91 92 #ifdef __cplusplus 93 } 94 #endif 95 96 #endif 97 98 #endif 99