Percepio Trace Recorder v4.11.0
Loading...
Searching...
No Matches
trcStreamPort.h
1/*
2* Trace Recorder for Tracealyzer v4.11.0
3* Copyright 2025 Percepio AB
4* www.percepio.com
5*
6* SPDX-License-Identifier: Apache-2.0
7*
8* The interface definitions for trace streaming ("stream ports").
9* This "stream port" sets up the recorder to stream to a Ring Buffer.
10*/
11
12#ifndef TRC_STREAM_PORT_H
13#define TRC_STREAM_PORT_H
14
15#if (TRC_USE_TRACEALYZER_RECORDER == 1)
16
17#include <trcTypes.h>
18#include <trcStreamPortConfig.h>
19#include <trcRecorder.h>
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
30#define TRC_EXTERNAL_BUFFERS 1
31
37#define TRC_SEND_NAME_ONLY_ON_DELETE 1
38
44
45#define TRC_CFG_STREAM_PORT_USE_INTERNAL_BUFFER 0
46
47/* The RingBuffer StreamPort is using the Internal Event Buffer in a specific way and therefor we classify this as a custom streamport allocation method */
48#define TRC_USE_CUSTOM_STREAMPORT_ALLOCATION
49
50#define TRC_STREAM_PORT_BUFFER_SIZE (((uint32_t)(TRC_CFG_STREAM_PORT_BUFFER_SIZE) / sizeof(TraceUnsignedBaseType_t)) * sizeof(TraceUnsignedBaseType_t)) /* aligned */
51
55typedef struct TraceMultiCoreBuffer /* Aligned */
56{
57 TraceUnsignedBaseType_t uxSize; /* aligned */
58 uint8_t uiBuffer[TRC_STREAM_PORT_BUFFER_SIZE]; /* size is aligned */
59} TraceMultiCoreBuffer_t;
60
64typedef struct TraceRingBuffer
65{
66 uint32_t reserved0; /* alignment with START_MARKERS */
67 volatile uint8_t START_MARKERS[12];
68 TraceHeaderBuffer_t xHeaderBuffer; /* aligned */
69 TraceTimestampData_t xTimestampInfo; /* aligned */
70 TraceEntryTable_t xEntryTable; /* aligned */
71 TraceMultiCoreBuffer_t xEventBuffer; /* aligned */
72 volatile uint8_t END_MARKERS[12];
73 uint32_t reserved1; /* alignment */
74} TraceRingBuffer_t;
75
79typedef struct TraceStreamPortBuffer
80{
81 TraceMultiCoreEventBuffer_t xMultiCoreEventBuffer;
82 TraceRingBuffer_t xRingBuffer;
83} TraceStreamPortBuffer_t;
84
85extern TraceStreamPortBuffer_t* pxStreamPortData;
86
97traceResult xTraceStreamPortInitialize(TraceStreamPortBuffer_t* pxBuffer);
98
108#define xTraceStreamPortAllocate(_uiSize, _ppvData) xTraceMultiCoreEventBufferAlloc(&pxStreamPortData->xMultiCoreEventBuffer, _uiSize, _ppvData)
109
122#define xTraceStreamPortCommit(_pvData, _uiSize, _piBytesCommitted) xTraceMultiCoreEventBufferAllocCommit(&pxStreamPortData->xMultiCoreEventBuffer, _pvData, _uiSize, _piBytesCommitted)
123
134#define xTraceStreamPortWriteData(_pvData, _uiSize, _uiChannel, _piBytesWritten) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_5((void)(_pvData), (void)(_uiSize), (void)(_uiChannel), (void)(_piBytesWritten), TRC_SUCCESS)
135
146#define xTraceStreamPortReadData(pvData, uiSize, piBytesRead) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_4((void)(pvData), (void)(uiSize), (void)(piBytesRead), TRC_SUCCESS)
147
156#define xTraceStreamPortOnEnable(uiStartOption) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_2((void)(uiStartOption), TRC_SUCCESS)
157
164#define xTraceStreamPortOnDisable() TRC_COMMA_EXPR_TO_STATEMENT_EXPR_1(TRC_SUCCESS)
165
172traceResult xTraceStreamPortOnTraceBegin(void);
173
180#define xTraceStreamPortOnTraceEnd() TRC_COMMA_EXPR_TO_STATEMENT_EXPR_1(TRC_SUCCESS)
181
182#ifdef __cplusplus
183}
184#endif
185
186#endif /*(TRC_USE_TRACEALYZER_RECORDER == 1)*/
187
188#endif /* TRC_STREAM_PORT_H */
struct TraceMultiCoreEventBuffer TraceMultiCoreEventBuffer_t
Trace Multi-Core Event Buffer Structure.
struct TraceTimestampData TraceTimestampData_t
Trace Timestamp Structure.
A structure representing the trace stream port buffer.
Definition trcStreamPort.h:71
The public API of the Percepio trace recorder.