forked from percepio/TraceRecorderSource
-
Notifications
You must be signed in to change notification settings - Fork 0
/
trcExtension.c
80 lines (58 loc) · 2.36 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
/*
* Trace Recorder for Tracealyzer v4.6.3
* Copyright 2021 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)
#include <stdio.h>
#define TRC_EXTENSION_BASE_EVENT_ID (TRC_EVENT_LAST_ID + 1)
uint32_t uiTraceNextFreeExtensionEventId = TRC_EXTENSION_BASE_EVENT_ID;
#define TRC_EXTENSION_COMBINE_VERSION(_major, _minor, _patch) \
( \
((0x000000FF & (_major)) << 24) | \
((0x000000FF & (_minor)) << 16) | \
((0x0000FFFF & (_patch)) << 0) \
)
/* TODO: INITIALIZE */
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(uiEventCount != 0);
/* This should never fail */
TRC_ASSERT(pxExtensionHandle != 0);
uxStates[TRC_EXTENSION_STATE_INDEX_VERSION] = TRC_EXTENSION_COMBINE_VERSION(uiMajor, uiMinor, uiPatch);
uxStates[TRC_EXTENSION_STATE_INDEX_BASE_EVENT_ID] = uiTraceNextFreeExtensionEventId;
uxStates[TRC_EXTENSION_STATE_INDEX_EVENT_COUNT] = uiEventCount;
/* We need to check this */
if (xTraceObjectRegisterInternal(PSF_EVENT_EXTENSION_CREATE, 0, szName, 3, uxStates, TRC_ENTRY_OPTION_EXTENSION, &xObjectHandle) == TRC_FAIL)
{
return TRC_FAIL;
}
uiTraceNextFreeExtensionEventId += 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(puiBaseEventId != 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;
}
traceResult xTraceExtensionGetConfigName(TraceExtensionHandle_t xExtensionHandle, const char **pszName)
{
return xTraceEntryGetSymbol((TraceEntryHandle_t)xExtensionHandle, pszName);
}
#endif /* (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING) */
#endif /* (TRC_USE_TRACEALYZER_RECORDER == 1) */