1 /*
2 * 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 * The implementation of the internal buffer.
9 */
10
11 #include <trcRecorder.h>
12
13 #if (TRC_USE_TRACEALYZER_RECORDER == 1)
14
15 #if (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING)
16
17 #if (TRC_USE_INTERNAL_BUFFER == 1)
18
19 #include <stdio.h>
20 #include <string.h>
21 #include <stdarg.h>
22
23 static TraceMultiCoreEventBuffer_t *pxInternalEventBuffer;
24
xTraceInternalEventBufferInitialize(uint8_t * puiBuffer,uint32_t uiSize)25 traceResult xTraceInternalEventBufferInitialize(uint8_t* puiBuffer, uint32_t uiSize)
26 {
27 /* uiSize must be larger than sizeof(TraceMultiCoreEventBuffer_t) or there will be no room for any data */
28 /* This should never fail */
29 TRC_ASSERT(uiSize > sizeof(TraceMultiCoreEventBuffer_t));
30
31 /* pxInternalBuffer will be placed at the beginning of the puiBuffer */
32 pxInternalEventBuffer = (TraceMultiCoreEventBuffer_t*)puiBuffer;
33
34 /* Send in a an address pointing after the TraceMultiCoreEventBuffer_t */
35 /* We need to check this */
36 if (xTraceMultiCoreEventBufferInitialize(pxInternalEventBuffer, TRC_EVENT_BUFFER_OPTION_SKIP,
37 &puiBuffer[sizeof(TraceMultiCoreEventBuffer_t)], uiSize - sizeof(TraceMultiCoreEventBuffer_t)) == TRC_FAIL)
38 {
39 return TRC_FAIL;
40 }
41
42 xTraceSetComponentInitialized(TRC_RECORDER_COMPONENT_INTERNAL_EVENT_BUFFER);
43
44 return TRC_SUCCESS;
45 }
46
xTraceInternalEventBufferPush(void * pvData,uint32_t uiSize,int32_t * piBytesWritten)47 traceResult xTraceInternalEventBufferPush(void *pvData, uint32_t uiSize, int32_t *piBytesWritten)
48 {
49 /* This should never fail */
50 TRC_ASSERT(xTraceIsComponentInitialized(TRC_RECORDER_COMPONENT_INTERNAL_EVENT_BUFFER));
51
52 return xTraceMultiCoreEventBufferPush(pxInternalEventBuffer, pvData, uiSize, piBytesWritten);
53 }
54
xTraceInternalEventBufferTransfer(int32_t * piBytesWritten)55 traceResult xTraceInternalEventBufferTransfer(int32_t *piBytesWritten)
56 {
57 /* This should never fail */
58 TRC_ASSERT(xTraceIsComponentInitialized(TRC_RECORDER_COMPONENT_INTERNAL_EVENT_BUFFER));
59
60 return xTraceMultiCoreEventBufferTransfer(pxInternalEventBuffer, piBytesWritten);
61 }
62
xTraceInternalEventBufferClear()63 traceResult xTraceInternalEventBufferClear()
64 {
65 /* This should never fail */
66 TRC_ASSERT(xTraceIsComponentInitialized(TRC_RECORDER_COMPONENT_INTERNAL_EVENT_BUFFER));
67
68 return xTraceMultiCoreEventBufferClear(pxInternalEventBuffer);
69 }
70
71 #endif /* (TRC_USE_INTERNAL_BUFFER == 1) */
72
73 #endif /* (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING) */
74
75 #endif /* (TRC_USE_TRACEALYZER_RECORDER == 1) */
76