1 /*
2 * Percepio Trace Recorder for Tracealyzer v4.9.2
3 * Copyright 2023 Percepio AB
4 * www.percepio.com
5 *
6 * SPDX-License-Identifier: Apache-2.0
7 *
8 * The implementation for the static buffer.
9 */
10 
11 #include <trcRecorder.h>
12 
13 #if (TRC_USE_TRACEALYZER_RECORDER == 1) && (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING)
14 
15 TraceStaticBufferTable_t *pxTraceStaticBufferTable TRC_CFG_RECORDER_DATA_ATTRIBUTE;
16 
xTraceStaticBufferInitialize(TraceStaticBufferTable_t * pxBuffer)17 traceResult xTraceStaticBufferInitialize(TraceStaticBufferTable_t *pxBuffer)
18 {
19 	/* This should never fail */
20 	TRC_ASSERT(pxBuffer != (void*)0);
21 
22 	pxTraceStaticBufferTable = pxBuffer;
23 
24 	xTraceSetComponentInitialized(TRC_RECORDER_COMPONENT_STATIC_BUFFER);
25 
26 	return TRC_SUCCESS;
27 }
28 
29 #if ((TRC_CFG_USE_TRACE_ASSERT) == 1)
30 
31 /* Returns a pointer to a maximum sized static buffer */
xTraceStaticBufferGet(void ** ppvBuffer)32 traceResult xTraceStaticBufferGet(void **ppvBuffer)
33 {
34 	int32_t ISR_nesting;
35 
36 	/* This should never fail */
37 	TRC_ASSERT(xTraceIsComponentInitialized(TRC_RECORDER_COMPONENT_STATIC_BUFFER));
38 
39 	TRC_ASSERT(ppvBuffer != (void*)0);
40 
41 	TRC_ASSERT(xTraceISRGetCurrentNesting(&ISR_nesting) ==  TRC_SUCCESS);
42 
43 	/* Task dummy events begin at 0, ISR dummy events begin at index 1 */
44 	*ppvBuffer = (void*)&pxTraceStaticBufferTable->coreDummyEvents[TRC_CFG_GET_CURRENT_CORE()].dummyEvents[ISR_nesting + 1];
45 
46 	return TRC_SUCCESS;
47 }
48 
49 #endif
50 
51 #endif
52