1 /* 2 * Percepio Trace Recorder for Tracealyzer v4.10.3 3 * Copyright 2023 Percepio AB 4 * www.percepio.com 5 * 6 * SPDX-License-Identifier: Apache-2.0 7 */ 8 9 /** 10 * @file 11 * 12 * @brief Public trace extension APIs. 13 */ 14 15 #ifndef TRC_EXTENSION_H 16 #define TRC_EXTENSION_H 17 18 #if (TRC_USE_TRACEALYZER_RECORDER == 1) && (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING) 19 20 #include <trcTypes.h> 21 22 #ifdef __cplusplus 23 extern "C" { 24 #endif 25 26 #define TRC_EXTENSION_STATE_INDEX_VERSION 0 27 #define TRC_EXTENSION_STATE_INDEX_BASE_EVENT_ID 1 28 #define TRC_EXTENSION_STATE_INDEX_EVENT_COUNT 2 29 30 /** 31 * @defgroup trace_extension_apis Trace Extension APIs 32 * @ingroup trace_recorder_apis 33 * @{ 34 */ 35 36 typedef struct TraceExtensionData /* Aligned */ 37 { 38 TraceUnsignedBaseType_t uxNextFreeExtensionEventId; 39 } TraceExtensionData_t; 40 41 /** 42 * @brief Initializes the Extension trace system 43 * 44 * @param[in] pxBuffer Pointer to memory that is used by the extension trace system 45 * 46 * @retval TRC_FAIL Failure 47 * @retval TRC_SUCCESS Success 48 */ 49 traceResult xTraceExtensionInitialize(TraceExtensionData_t* const pxBuffer); 50 51 /** 52 * @brief Creates trace extension. 53 * 54 * @param[in] szName Name. 55 * @param[in] uiMajor Major version. 56 * @param[in] uiMinor Minor version. 57 * @param[in] uiPatch Patch version. 58 * @param[in] uiEventCount Event count. 59 * @param[out] pxExtensionHandle Pointer to uninitialized extension handle. 60 * 61 * @retval TRC_FAIL Failure 62 * @retval TRC_SUCCESS Success 63 */ 64 traceResult xTraceExtensionCreate(const char *szName, uint8_t uiMajor, uint8_t uiMinor, uint16_t uiPatch, uint32_t uiEventCount, TraceExtensionHandle_t *pxExtensionHandle); 65 66 /** 67 * @brief Gets extension base event id. 68 * 69 * @param[in] xExtensionHandle Pointer to initialized extension handle. 70 * @param[out] puiBaseEventId Base event id. 71 * 72 * @retval TRC_FAIL Failure 73 * @retval TRC_SUCCESS Success 74 */ 75 traceResult xTraceExtensionGetBaseEventId(TraceExtensionHandle_t xExtensionHandle, uint32_t *puiBaseEventId); 76 77 /** 78 * @brief Gets extension configuration name. 79 * 80 * @param[in] xExtensionHandle Pointer to initialized extension handle. 81 * @param[out] pszName Name. 82 * 83 * @retval TRC_FAIL Failure 84 * @retval TRC_SUCCESS Success 85 */ 86 traceResult xTraceExtensionGetConfigName(TraceExtensionHandle_t xExtensionHandle, const char** pszName); 87 88 /** 89 * @brief Returns extension event id. 90 * 91 * @param[in] xExtensionHandle Pointer to initialized extension handle. 92 * @param[in] uiLocalEventId Local event id. 93 * 94 * @returns Extension event id 95 */ 96 #define xTraceExtensionGetEventId(xExtensionHandle, uiLocalEventId) ((uint32_t)xTraceEntryGetStateReturn((TraceEntryHandle_t)(xExtensionHandle), TRC_EXTENSION_STATE_INDEX_BASE_EVENT_ID) + (uiLocalEventId)) 97 98 /** @} */ 99 100 #ifdef __cplusplus 101 } 102 #endif 103 104 #else 105 106 #define xTraceExtensionCreate(szName, uiMajor, uiMinor, uiPatch, uiEventCount, pxExtensionHandle) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_7((void)(szName), (void)(uiMajor), (void)(uiMinor), (void)(uiPatch), (void)(uiEventCount), (void)(pxExtensionHandle), TRC_SUCCESS) 107 108 #define xTraceExtensionGetBaseEventId(xExtensionHandle, puiBaseEventId) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_3((void)(xExtensionHandle), (void)(puiBaseEventId), TRC_SUCCESS) 109 110 #define xTraceExtensionGetConfigName(xExtensionHandle, pszName) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_3((void)(xExtensionHandle), (void)(pszName), TRC_SUCCESS) 111 112 #define xTraceExtensionGetEventId(xExtensionHandle, uiLocalEventId) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_3((void)(xExtensionHandle), (void)(uiLocalEventId), 0) 113 114 #endif 115 116 #endif 117