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 
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	/* Aligned */
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	/* Aligned */
49 {
50 	TraceCoreStaticBuffer_t coreDummyEvents[TRC_CFG_CORE_COUNT]; /**< Temporary buffers used for event or blob creation. */
51 } TraceStaticBufferTable_t;
52 
53 extern TraceStaticBufferTable_t* pxTraceStaticBufferTable;
54 
55 /**
56  * @internal Initialize trace static buffer.
57  *
58  * @param[in] pxBuffer Pointer to memory that will be used by the
59  * trace static buffer.
60  *
61  * @retval TRC_FAIL Failure
62  * @retval TRC_SUCCESS Success
63  */
64 traceResult xTraceStaticBufferInitialize(TraceStaticBufferTable_t* pxBuffer);
65 
66 #if ((TRC_CFG_USE_TRACE_ASSERT) == 1)
67 
68 /**
69  * @brief Gets trace static buffer.
70  *
71  * @param[out] ppvBuffer Buffer.
72  *
73  * @retval TRC_FAIL Failure
74  * @retval TRC_SUCCESS Success
75  */
76 traceResult xTraceStaticBufferGet(void **ppvBuffer);
77 
78 #else /* ((TRC_CFG_USE_TRACE_ASSERT) == 1) */
79 
80 /**
81  * @brief Gets trace static buffer.
82  *
83  * @param[out] ppvBuffer Buffer.
84  *
85  * @retval TRC_FAIL Failure
86  * @retval TRC_SUCCESS Success
87  */
88 #define xTraceStaticBufferGet(ppvBuffer) (*(ppvBuffer) = (void*)&pxTraceStaticBufferTable->coreDummyEvents[TRC_CFG_GET_CURRENT_CORE()].dummyEvents[xTraceISRGetCurrentNestingReturned() + 1], TRC_SUCCESS)
89 
90 #endif /* ((TRC_CFG_USE_TRACE_ASSERT) == 1) */
91 
92 /** @} */
93 
94 #ifdef __cplusplus
95 }
96 #endif
97 
98 #endif /* (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING) */
99 
100 #endif /* (TRC_USE_TRACEALYZER_RECORDER == 1) */
101 
102 #endif /* TRC_STATIC_BUFFER_H */
103