Percepio Trace Recorder v4.8.0.hotfix1
Loading...
Searching...
No Matches
trcStreamPort.h
1/*
2 * Trace Recorder for Tracealyzer v4.8.0.hotfix1
3 * Copyright 2023 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 the trace to file.
10 */
11
12#ifndef TRC_STREAM_PORT_H
13#define TRC_STREAM_PORT_H
14
15#if (TRC_USE_TRACEALYZER_RECORDER == 1)
16
17#if (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING)
18
19#include <stdint.h>
20#include <trcTypes.h>
21#include <trcStreamPortConfig.h>
22#include <stdio.h>
23#include <zephyr/arch/common/semihost.h>
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
29#define TRC_USE_INTERNAL_BUFFER (TRC_CFG_STREAM_PORT_USE_INTERNAL_BUFFER)
30
31#define TRC_INTERNAL_EVENT_BUFFER_WRITE_MODE (TRC_CFG_STREAM_PORT_INTERNAL_BUFFER_WRITE_MODE)
32
33#define TRC_INTERNAL_EVENT_BUFFER_TRANSFER_MODE (TRC_CFG_STREAM_PORT_INTERNAL_BUFFER_TRANSFER_MODE)
34
35#define TRC_INTERNAL_BUFFER_CHUNK_SIZE (TRC_CFG_STREAM_PORT_INTERNAL_BUFFER_CHUNK_SIZE)
36
37#define TRC_INTERNAL_BUFFER_CHUNK_TRANSFER_AGAIN_SIZE_LIMIT (TRC_CFG_STREAM_PORT_INTERNAL_BUFFER_CHUNK_TRANSFER_AGAIN_SIZE_LIMIT)
38
39#define TRC_INTERNAL_BUFFER_CHUNK_TRANSFER_AGAIN_COUNT_LIMIT (TRC_CFG_STREAM_PORT_INTERNAL_BUFFER_CHUNK_TRANSFER_AGAIN_COUNT_LIMIT)
40
41/* Aligned */
42#define TRC_STREAM_PORT_INTERNAL_BUFFER_SIZE ((((TRC_CFG_STREAM_PORT_INTERNAL_BUFFER_SIZE) + sizeof(TraceUnsignedBaseType_t) - 1) / sizeof(TraceUnsignedBaseType_t)) * sizeof(TraceUnsignedBaseType_t))
43
44typedef struct TraceStreamPortFile /* Aligned */
45{
46 long pxFileDescriptor;
47#if (TRC_USE_INTERNAL_BUFFER)
48 uint8_t buffer[TRC_STREAM_PORT_INTERNAL_BUFFER_SIZE];
49#endif
50} TraceStreamPortFile_t;
51
52extern TraceStreamPortFile_t* pxStreamPortFile;
53
54#define TRC_STREAM_PORT_BUFFER_SIZE (sizeof(TraceStreamPortFile_t))
55
56typedef struct TraceStreamPortBuffer
57{
58 uint8_t buffer[TRC_STREAM_PORT_BUFFER_SIZE];
60
71traceResult xTraceStreamPortInitialize(TraceStreamPortBuffer_t* pxBuffer);
72
82#if (TRC_USE_INTERNAL_BUFFER == 1)
83#if (TRC_INTERNAL_EVENT_BUFFER_WRITE_MODE == TRC_INTERNAL_EVENT_BUFFER_OPTION_WRITE_MODE_COPY)
84#define xTraceStreamPortAllocate(uiSize, ppvData) ((void)(uiSize), xTraceStaticBufferGet(ppvData))
85#else
86#define xTraceStreamPortAllocate(uiSize, ppvData) ((void)(uiSize), xTraceInternalEventBufferAlloc(uiSize, ppvData))
87#endif
88#else
89#define xTraceStreamPortAllocate(uiSize, ppvData) ((void)(uiSize), xTraceStaticBufferGet(ppvData))
90#endif
91
104#if (TRC_USE_INTERNAL_BUFFER == 1)
105#if (TRC_INTERNAL_EVENT_BUFFER_WRITE_MODE == TRC_INTERNAL_EVENT_BUFFER_OPTION_WRITE_MODE_COPY)
106#define xTraceStreamPortCommit xTraceInternalEventBufferPush
107#else
108#define xTraceStreamPortCommit xTraceInternalEventBufferAllocCommit
109#endif
110#else
111#define xTraceStreamPortCommit xTraceStreamPortWriteData
112#endif
113
124#define xTraceStreamPortReadData(pvData, uiSize, piBytesRead) ((void)(pvData), (void)(uiSize), (void)(piBytesRead), TRC_SUCCESS)
125
126#define xTraceStreamPortOnEnable(uiStartOption) ((void)(uiStartOption), TRC_SUCCESS)
127
128#define xTraceStreamPortOnDisable() (TRC_SUCCESS)
129
130traceResult xTraceStreamPortOnTraceBegin(void);
131
132traceResult xTraceStreamPortOnTraceEnd(void);
133
134//TODO: Might want to change these to non-32bit types, however this depends on what Tracealyzer expects
135traceResult xTraceStreamPortWriteData(void* pvData, uint32_t uiSize, int32_t* piBytesWritten);
136
137#ifdef __cplusplus
138}
139#endif
140
141#endif /*(TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING)*/
142
143#endif /*(TRC_USE_TRACEALYZER_RECORDER == 1)*/
144
145#endif /* TRC_STREAM_PORT_H */
A structure representing the trace stream port buffer.
Definition: trcStreamPort.h:93