1 /* 2 * Percepio Trace Recorder for Tracealyzer v4.6.6 3 * Copyright 2021 Percepio AB 4 * www.percepio.com 5 * 6 * SPDX-License-Identifier: Apache-2.0 7 */ 8 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) 19 20 #if (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING) 21 22 #include <trcTypes.h> 23 24 #ifdef __cplusplus 25 extern "C" { 26 #endif 27 28 /** 29 * @defgroup trace_static_buffer_apis Trace Static Buffer APIs 30 * @ingroup trace_recorder_apis 31 * @{ 32 */ 33 34 /* A buffer type that is maximum size */ 35 typedef uint8_t TraceStaticBuffer_t[TRC_MAX_BLOB_SIZE]; 36 37 /** 38 * @internal Trace Core Static Buffer Core Structure 39 */ 40 typedef struct TraceCoreStaticBufferCore 41 { 42 TraceStaticBuffer_t dummyEvents[(TRC_CFG_MAX_ISR_NESTING)+1]; /**< */ 43 } TraceCoreStaticBuffer_t; 44 45 /** 46 * @internal Trace Static Buffer Table Structure 47 */ 48 typedef struct TraceStaticBufferTable 49 { 50 TraceCoreStaticBuffer_t coreDummyEvents[TRC_CFG_CORE_COUNT]; /**< Temporary buffers used for event or blob creation. */ 51 } TraceStaticBufferTable_t; 52 53 #define TRC_STATIC_BUFFER_BUFFER_SIZE (sizeof(TraceStaticBufferTable_t)) 54 55 /** 56 * @internal Trace Static Buffer Buffer Structure 57 */ 58 typedef struct TraceStaticBufferBuffer 59 { 60 uint8_t buffer[TRC_STATIC_BUFFER_BUFFER_SIZE]; /**< */ 61 } TraceStaticBufferBuffer_t; 62 63 extern TraceStaticBufferTable_t* pxTraceStaticBufferTable; 64 65 /** 66 * @internal Initialize trace static buffer. 67 * 68 * @param[in] pxBuffer Pointer to memory that will be used by the 69 * trace static buffer. 70 * 71 * @retval TRC_FAIL Failure 72 * @retval TRC_SUCCESS Success 73 */ 74 traceResult xTraceStaticBufferInitialize(TraceStaticBufferBuffer_t* pxBuffer); 75 76 #if ((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 traceResult xTraceStaticBufferGet(void **ppvBuffer); 87 88 #else /* ((TRC_CFG_USE_TRACE_ASSERT) == 1) */ 89 90 /** 91 * @brief Gets trace static buffer. 92 * 93 * @param[out] ppvBuffer Buffer. 94 * 95 * @retval TRC_FAIL Failure 96 * @retval TRC_SUCCESS Success 97 */ 98 #define xTraceStaticBufferGet(ppvBuffer) (*ppvBuffer = (void*)&pxTraceStaticBufferTable->coreDummyEvents[TRC_CFG_GET_CURRENT_CORE()].dummyEvents[xTraceISRGetCurrentNestingReturned() + 1], TRC_SUCCESS) 99 100 #endif /* ((TRC_CFG_USE_TRACE_ASSERT) == 1) */ 101 102 /** @} */ 103 104 #ifdef __cplusplus 105 } 106 #endif 107 108 #endif /* (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING) */ 109 110 #endif /* (TRC_USE_TRACEALYZER_RECORDER == 1) */ 111 112 #endif /* TRC_STATIC_BUFFER_H */ 113