1 /*
2 * Percepio Trace Recorder for Tracealyzer v4.8.1
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)
14 
15 #if (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING)
16 
17 TraceStaticBufferTable_t *pxTraceStaticBufferTable TRC_CFG_RECORDER_DATA_ATTRIBUTE;
18 
xTraceStaticBufferInitialize(TraceStaticBufferTable_t * pxBuffer)19 traceResult xTraceStaticBufferInitialize(TraceStaticBufferTable_t *pxBuffer)
20 {
21 	/* This should never fail */
22 	TRC_ASSERT(pxBuffer != (void*)0);
23 
24 	pxTraceStaticBufferTable = pxBuffer;
25 
26 	xTraceSetComponentInitialized(TRC_RECORDER_COMPONENT_STATIC_BUFFER);
27 
28 	return TRC_SUCCESS;
29 }
30 
31 #if ((TRC_CFG_USE_TRACE_ASSERT) == 1)
32 
33 /* Returns a pointer to a maximum sized static buffer */
xTraceStaticBufferGet(void ** ppvBuffer)34 traceResult xTraceStaticBufferGet(void **ppvBuffer)
35 {
36 	int32_t ISR_nesting;
37 
38 	/* This should never fail */
39 	TRC_ASSERT(xTraceIsComponentInitialized(TRC_RECORDER_COMPONENT_STATIC_BUFFER));
40 
41 	TRC_ASSERT(ppvBuffer != (void*)0);
42 
43 	TRC_ASSERT(xTraceISRGetCurrentNesting(&ISR_nesting) ==  TRC_SUCCESS);
44 
45 	/* Task dummy events begin at 0, ISR dummy events begin at index 1 */
46 	*ppvBuffer = (void*)&pxTraceStaticBufferTable->coreDummyEvents[TRC_CFG_GET_CURRENT_CORE()].dummyEvents[ISR_nesting + 1];
47 
48 	return TRC_SUCCESS;
49 }
50 
51 #endif /* ((TRC_CFG_USE_TRACE_ASSERT) == 1) */
52 
53 #endif /* (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING) */
54 
55 #endif /* (TRC_USE_TRACEALYZER_RECORDER == 1) */
56