forked from zephyrproject-rtos/TraceRecorderSource
-
Notifications
You must be signed in to change notification settings - Fork 0
/
trcExtension.c
111 lines (79 loc) · 3.61 KB
/
trcExtension.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/*
* Trace Recorder for Tracealyzer v4.8.0.hotfix2
* Copyright 2023 Percepio AB
* www.percepio.com
*
* SPDX-License-Identifier: Apache-2.0
*
* The implementation of extensions.
*/
#include <trcRecorder.h>
#if (TRC_USE_TRACEALYZER_RECORDER == 1)
#if (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING)
#define TRC_EXTENSION_BASE_EVENT_ID (TRC_EVENT_LAST_ID + 1UL)
#define TRC_EXTENSION_COMBINE_VERSION(_major, _minor, _patch) \
( \
((0x000000FFUL & (TraceUnsignedBaseType_t)(_major)) << 24) | \
((0x000000FFUL & (TraceUnsignedBaseType_t)(_minor)) << 16) | \
((0x0000FFFFUL & (TraceUnsignedBaseType_t)(_patch)) << 0) \
)
static TraceExtensionData_t *pxExtensionData TRC_CFG_RECORDER_DATA_ATTRIBUTE;
traceResult xTraceExtensionInitialize(TraceExtensionData_t* const pxBuffer)
{
/* This should never fail */
TRC_ASSERT(pxBuffer != (void*)0);
pxExtensionData = pxBuffer;
pxExtensionData->uxNextFreeExtensionEventId = TRC_EXTENSION_BASE_EVENT_ID;
xTraceSetComponentInitialized(TRC_RECORDER_COMPONENT_EXTENSION);
return TRC_SUCCESS;
}
/*cstat !MISRAC2004-6.3 !MISRAC2012-Dir-4.6_a Suppress basic char type usage*/
traceResult xTraceExtensionCreate(const char* szName, uint8_t uiMajor, uint8_t uiMinor, uint16_t uiPatch, uint32_t uiEventCount, TraceExtensionHandle_t* pxExtensionHandle)
{
TraceObjectHandle_t xObjectHandle;
TraceUnsignedBaseType_t uxStates[3];
/* This should never fail */
TRC_ASSERT(xTraceIsComponentInitialized(TRC_RECORDER_COMPONENT_EXTENSION));
/* This should never fail */
TRC_ASSERT(uiEventCount != 0u);
/* This should never fail */
TRC_ASSERT(pxExtensionHandle != (void*)0);
/* This should never fail */
TRC_ASSERT(pxExtensionHandle != (void*)0);
/* This should never fail */
TRC_ASSERT(szName != (void*)0);
/* This should never fail */
TRC_ASSERT(szName[0] != (char)0); /*cstat !MISRAC2004-17.4_b We need to check the first characted*/ /*cstat !MISRAC2004-6.3 !MISRAC2012-Dir-4.6_a Suppress basic char type usage*/
uxStates[TRC_EXTENSION_STATE_INDEX_VERSION] = TRC_EXTENSION_COMBINE_VERSION(uiMajor, uiMinor, uiPatch);
uxStates[TRC_EXTENSION_STATE_INDEX_BASE_EVENT_ID] = pxExtensionData->uxNextFreeExtensionEventId;
uxStates[TRC_EXTENSION_STATE_INDEX_EVENT_COUNT] = uiEventCount;
/* We need to check this */
if (xTraceObjectRegisterInternal(PSF_EVENT_EXTENSION_CREATE, (void*)0, szName, 3u, uxStates, TRC_ENTRY_OPTION_EXTENSION, &xObjectHandle) == TRC_FAIL)
{
return TRC_FAIL;
}
pxExtensionData->uxNextFreeExtensionEventId += uiEventCount;
*pxExtensionHandle = (TraceExtensionHandle_t)xObjectHandle;
return TRC_SUCCESS;
}
traceResult xTraceExtensionGetBaseEventId(TraceExtensionHandle_t xExtensionHandle, uint32_t *puiBaseEventId)
{
TraceUnsignedBaseType_t uxBaseEventId;
/* This should never fail */
TRC_ASSERT(xTraceIsComponentInitialized(TRC_RECORDER_COMPONENT_EXTENSION));
/* This should never fail */
TRC_ASSERT(puiBaseEventId != (void*)0);
/* This should never fail */
TRC_ASSERT_ALWAYS_EVALUATE(xTraceEntryGetState((TraceEntryHandle_t)xExtensionHandle, TRC_EXTENSION_STATE_INDEX_BASE_EVENT_ID, &uxBaseEventId) == TRC_SUCCESS);
*puiBaseEventId = (uint32_t)uxBaseEventId;
return TRC_SUCCESS;
}
/*cstat !MISRAC2004-6.3 !MISRAC2012-Dir-4.6_a Suppress basic char type usage*/
traceResult xTraceExtensionGetConfigName(TraceExtensionHandle_t xExtensionHandle, const char **pszName)
{
/* This should never fail */
TRC_ASSERT(xTraceIsComponentInitialized(TRC_RECORDER_COMPONENT_EXTENSION));
return xTraceEntryGetSymbol((TraceEntryHandle_t)xExtensionHandle, pszName);
}
#endif /* (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING) */
#endif /* (TRC_USE_TRACEALYZER_RECORDER == 1) */