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 * @internal Public trace multicore event buffer APIs. 13 */ 14 15 #ifndef TRC_MULTI_CORE_EVENT_BUFFER_H 16 #define TRC_MULTI_CORE_EVENT_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_multi_core_event_buffer_apis Trace Multi-Core Event Buffer APIs 30 * @ingroup trace_recorder_apis 31 * @{ 32 */ 33 34 /** 35 * @brief Trace Multi-Core Event Buffer Structure 36 */ 37 typedef struct TraceMultiCoreEventBuffer 38 { 39 TraceEventBuffer_t *xEventBuffer[TRC_CFG_CORE_COUNT]; /**< */ 40 } TraceMultiCoreEventBuffer_t; 41 42 /** 43 * @internal Initialize multi-core event buffer. 44 * 45 * This routine initializes a multi-core trace event buffer and assignts it 46 * a memory area based on the supplied buffer. 47 * 48 * Trace event buffer options specifies the buffer behavior regarding 49 * old data, the alternatives are TRC_EVENT_BUFFER_OPTION_SKIP and 50 * TRC_EVENT_BUFFER_OPTION_OVERWRITE (mutal exclusive). 51 * 52 * @param[out] pxTraceMultiCoreEventBuffer Pointer to unitialized multi-core trace event buffer. 53 * @param[in] uiOptions Trace event buffer options. 54 * @param[in] puiBuffer Pointer to buffer that will be used by the multi-core trace event buffer. 55 * @param[in] uiSize Size of buffer. 56 * 57 * @retval TRC_FAIL Failure 58 * @retval TRC_SUCCESS Success 59 */ 60 traceResult xTraceMultiCoreEventBufferInitialize(TraceMultiCoreEventBuffer_t* pxTraceMultiCoreEventBuffer, uint32_t uiOptions, 61 uint8_t* puiBuffer, uint32_t uiSize); 62 63 64 65 #if ((TRC_CFG_USE_TRACE_ASSERT) == 1) 66 67 /** 68 * @brief Pushes data into multi-core trace event buffer. 69 * 70 * This routine attempts to push data into the multi-core trace event buffer. Selection 71 * of which core the data is pushed for is managed automatically through the 72 * TRC_CFG_GET_CURRENT_CORE macro which is defined on an RTOS basis. 73 * 74 * @param[in] pxTraceMultiCoreEventBuffer Pointer to initialized multi-core event buffer. 75 * @param[in] pvData Pointer to data should be pushed into multi-core event buffer. 76 * @param[in] uiSize Size of data that should be pushed into multi-core trace event buffer. 77 * @param[out] piBytesWritten Pointer to variable which the routine will write the number 78 * of bytes that was pushed into the multi-core trace event buffer. 79 * 80 * @retval TRC_FAIL Failure 81 * @retval TRC_SUCCESS Success 82 */ 83 traceResult xTraceMultiCoreEventBufferPush(TraceMultiCoreEventBuffer_t* pxTraceMultiCoreEventBuffer, void* pvData, uint32_t uiSize, int32_t* piBytesWritten); 84 85 #else 86 87 /** 88 * @brief Pushes data into multi-core trace event buffer. 89 * 90 * This routine attempts to push data into the multi-core trace event buffer. Selection 91 * of which core the data is pushed for is managed automatically through the 92 * TRC_CFG_GET_CURRENT_CORE macro which is defined on an RTOS basis. 93 * 94 * @param[in] pxTraceMultiCoreEventBuffer Pointer to initialized multi-core event buffer. 95 * @param[in] pvData Pointer to data should be pushed into multi-core event buffer. 96 * @param[in] uiSize Size of data that should be pushed into multi-core trace event buffer. 97 * @param[out] piBytesWritten Pointer to variable which the routine will write the number 98 * of bytes that was pushed into the multi-core trace event buffer. 99 * 100 * @retval TRC_FAIL Failure 101 * @retval TRC_SUCCESS Success 102 */ 103 #define xTraceMultiCoreEventBufferPush(pxTraceMultiCoreEventBuffer, pvData, uiSize, piBytesWritten) xTraceEventBufferPush((pxTraceMultiCoreEventBuffer)->xEventBuffer[TRC_CFG_GET_CURRENT_CORE()], pvData, uiSize, piBytesWritten) 104 105 #endif 106 107 /** 108 * @brief Transfer multi-core trace event buffer data through streamport. 109 * 110 * This routine will attempt to transfer all existing data in the multi-core trace event 111 * buffer through the streamport. New data pushed to the trace event buffer 112 * during the execution of this routine will not be transfered to 113 * 114 * @param[in] pxTraceMultiCoreEventBuffer Pointer to initialized multi-core event buffer. 115 * @param[out] piBytesWritten Pointer to variable which the routine will write the number 116 * of bytes that was pushed into the multi-core trace event buffer. 117 * 118 * @retval TRC_FAIL Failure 119 * @retval TRC_SUCCESS Success 120 */ 121 traceResult xTraceMultiCoreEventBufferTransfer(TraceMultiCoreEventBuffer_t* pxTraceMultiCoreEventBuffer, int32_t* piBytesWritten); 122 123 /** 124 * @brief Clears all data from event buffer. 125 * 126 * @param[in] pxTraceMultiCoreEventBuffer Pointer to initialized multi-core trace event buffer. 127 * 128 * @retval TRC_FAIL Failure 129 * @retval TRC_SUCCESS Success 130 */ 131 traceResult xTraceMultiCoreEventBufferClear(TraceMultiCoreEventBuffer_t* pxTraceMultiCoreEventBuffer); 132 133 /** @} */ 134 135 #ifdef __cplusplus 136 } 137 #endif 138 139 #endif /* (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING) */ 140 141 #endif /* (TRC_USE_TRACEALYZER_RECORDER == 1) */ 142 143 #endif /* TRC_MULTI_CORE_EVENT_BUFFER_H */ 144