Percepio Trace Recorder v4.11.0
Loading...
Searching...
No Matches
trcInternalEventBuffer.h
Go to the documentation of this file.
1/*
2 * Percepio 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
14
15#ifndef TRC_INTERNAL_BUFFER_H
16#define TRC_INTERNAL_BUFFER_H
17
18#if (TRC_USE_TRACEALYZER_RECORDER == 1)
19
20#include <trcDefines.h>
21
22#ifdef TRC_CFG_STREAM_PORT_USE_INTERNAL_BUFFER
23#define TRC_USE_INTERNAL_BUFFER TRC_CFG_STREAM_PORT_USE_INTERNAL_BUFFER
24#else
25#define TRC_USE_INTERNAL_BUFFER 1
26#endif
27
28#if (TRC_USE_INTERNAL_BUFFER == 1)
29
30/* Aligned */
31#define TRC_INTERNAL_BUFFER_SIZE ((((TRC_CFG_STREAM_PORT_INTERNAL_BUFFER_SIZE) + sizeof(TraceUnsignedBaseType_t) - 1) / sizeof(TraceUnsignedBaseType_t)) * sizeof(TraceUnsignedBaseType_t))
32
36typedef struct TraceInternalEventBufferData /* Aligned */
37{
38 uint8_t aubBuffer[TRC_INTERNAL_BUFFER_SIZE];
40
41#include <trcTypes.h>
42
43#ifdef __cplusplus
44extern "C" {
45#endif
46
47#ifdef TRC_CFG_STREAM_PORT_INTERNAL_BUFFER_TRANSFER_MODE
48#define TRC_INTERNAL_EVENT_BUFFER_TRANSFER_MODE TRC_CFG_STREAM_PORT_INTERNAL_BUFFER_TRANSFER_MODE
49#else
50#define TRC_INTERNAL_EVENT_BUFFER_TRANSFER_MODE TRC_INTERNAL_EVENT_BUFFER_OPTION_TRANSFER_MODE_ALL
51#endif
52
53#ifdef TRC_CFG_STREAM_PORT_INTERNAL_BUFFER_CHUNK_SIZE
54#define TRC_INTERNAL_BUFFER_CHUNK_SIZE TRC_CFG_STREAM_PORT_INTERNAL_BUFFER_CHUNK_SIZE
55#else
56#define TRC_INTERNAL_BUFFER_CHUNK_SIZE (1024UL)
57#endif
58
59#ifdef TRC_CFG_STREAM_PORT_INTERNAL_BUFFER_CHUNK_TRANSFER_AGAIN_SIZE_LIMIT
60#define TRC_INTERNAL_BUFFER_CHUNK_TRANSFER_AGAIN_SIZE_LIMIT TRC_CFG_STREAM_PORT_INTERNAL_BUFFER_CHUNK_TRANSFER_AGAIN_SIZE_LIMIT
61#else
62#define TRC_INTERNAL_BUFFER_CHUNK_TRANSFER_AGAIN_SIZE_LIMIT (512UL)
63#endif
64
65#ifdef TRC_CFG_STREAM_PORT_INTERNAL_BUFFER_CHUNK_TRANSFER_AGAIN_COUNT_LIMIT
66#define TRC_INTERNAL_BUFFER_CHUNK_TRANSFER_AGAIN_COUNT_LIMIT TRC_CFG_STREAM_PORT_INTERNAL_BUFFER_CHUNK_TRANSFER_AGAIN_COUNT_LIMIT
67#else
68#define TRC_INTERNAL_BUFFER_CHUNK_TRANSFER_AGAIN_COUNT_LIMIT (5UL)
69#endif
70
76
85traceResult xTraceInternalEventBufferInitialize(TraceInternalEventBufferData_t* pxBuffer);
86
96traceResult xTraceInternalEventBufferAlloc(uint32_t uiSize, void **ppvData);
97
114traceResult xTraceInternalEventBufferAllocCommit(void *pvData, uint32_t uiSize, int32_t *piBytesWritten);
115
126traceResult xTraceInternalEventBufferPush(void *pvData, uint32_t uiSize, int32_t *piBytesWritten);
127
128#if (TRC_INTERNAL_EVENT_BUFFER_TRANSFER_MODE == TRC_INTERNAL_EVENT_BUFFER_OPTION_TRANSFER_MODE_ALL)
129#define xTraceInternalEventBufferTransfer xTraceInternalEventBufferTransferAll
130#else
131#define xTraceInternalEventBufferTransfer xTraceInternalEventBufferTransferChunk
132#endif
133
148
166
174
176
177#ifdef __cplusplus
178}
179#endif
180
181#else /* (TRC_USE_INTERNAL_BUFFER == 1)*/
182
183#define xTraceInternalEventBufferInitialize(pxBuffer) ((pxBuffer) != 0 ? TRC_SUCCESS : TRC_FAIL)
184#define xTraceInternalEventBufferAlloc(ppvData, uiSize) ((void)(uiSize), (ppvData) != 0 ? TRC_SUCCESS : TRC_FAIL)
185#define xTraceInternalEventBufferAllocCommit(pvData, uiSize, piBytesWritten) ((void)(pvData), (void)(uiSize), (void)(piBytesWritten), TRC_SUCCESS)
186#define xTraceInternalEventBufferPush(pvData, uiSize, piBytesWritten) ((void)(uiSize), (void)(piBytesWritten), (pvData) != 0 ? TRC_SUCCESS : TRC_FAIL)
187#define xTraceInternalEventBufferTransfer() (void)(TRC_SUCCESS)
188#define xTraceInternalEventBufferTransferChunk(piBytesWritten, uiChunkSize) ((void)(piBytesWritten), (void)(uiChunkSize), TRC_SUCCESS)
189#define xTraceInternalEventBufferClear() (void)(TRC_SUCCESS)
190
191#endif /* (TRC_USE_INTERNAL_BUFFER == 1)*/
192
193#endif /* (TRC_USE_TRACEALYZER_RECORDER == 1) */
194
195#endif /* TRC_INTERNAL_BUFFER_H */
traceResult xTraceInternalEventBufferAlloc(uint32_t uiSize, void **ppvData)
Allocates a data slot directly from the internal event buffer.
traceResult xTraceInternalEventBufferTransferChunk(void)
Transfer internal trace event buffer data through streamport.
traceResult xTraceInternalEventBufferPush(void *pvData, uint32_t uiSize, int32_t *piBytesWritten)
Pushes data to the internal trace event buffer.
traceResult xTraceInternalEventBufferAllocCommit(void *pvData, uint32_t uiSize, int32_t *piBytesWritten)
Commits the last allocated block to the internal event buffer.
traceResult xTraceInternalEventBufferClear(void)
Clears all trace events in the internal trace event buffer.
traceResult xTraceInternalEventBufferTransferAll(void)
Transfers all internal trace event buffer data using the function xTraceStreamPortWriteData(....
A structure representing the trace stream port buffer.
Definition trcInternalEventBuffer.h:37
struct TraceInternalEventBufferData TraceInternalEventBufferData_t
A structure representing the trace stream port buffer.