Line data Source code
1 0 : /* 2 : * Copyright (c) 2024 Nordic Semiconductor ASA. 3 : * 4 : * SPDX-License-Identifier: Apache-2.0 5 : */ 6 : 7 : #ifndef ZEPHYR_INCLUDE_DEBUG_CORESIGHT_CS_TRACE_DEFMT_H__ 8 : #define ZEPHYR_INCLUDE_DEBUG_CORESIGHT_CS_TRACE_DEFMT_H__ 9 : 10 : #include <zephyr/kernel.h> 11 : #ifdef __cplusplus 12 : extern "C" { 13 : #endif 14 : 15 : /** 16 : * @defgroup coresight_apis Coresight APIs 17 : * @{ 18 : * @} 19 : * @defgroup cs_trace_defmt Coresight Trace Deformatter 20 : * @ingroup coresight_apis 21 : * @{ 22 : */ 23 : 24 : /** @brief Callback signature. 25 : * 26 : * @param id Stream ID. 27 : * @param data Data. 28 : * @param len Data length. 29 : */ 30 1 : typedef void (*cs_trace_defmt_cb)(uint32_t id, const uint8_t *data, size_t len); 31 : 32 : /** @brief Size of trace deformatter frame size in 32 bit words. */ 33 1 : #define CORESIGHT_TRACE_FRAME_SIZE32 4 34 : 35 : /** @brief Size of trace deformatter frame size in bytes. */ 36 1 : #define CORESIGHT_TRACE_FRAME_SIZE (CORESIGHT_TRACE_FRAME_SIZE32 * sizeof(uint32_t)) 37 : 38 : /** @brief Initialize Coresight Trace Deformatter. 39 : * 40 : * @param cb Callback. 41 : */ 42 1 : int cs_trace_defmt_init(cs_trace_defmt_cb cb); 43 : 44 : /** @brief Decode data from the stream. 45 : * 46 : * Trace formatter puts data in the 16 byte long blocks. 47 : * 48 : * Callback is called with decoded data. 49 : * 50 : * @param data Data. 51 : * @param len Data length. Must equal 16. 52 : * 53 : * @retval 0 On successful deformatting. 54 : * @retval -EINVAL If wrong length is provided. 55 : */ 56 1 : int cs_trace_defmt_process(const uint8_t *data, size_t len); 57 : 58 : /** @} */ 59 : 60 : #ifdef __cplusplus 61 : } 62 : #endif 63 : 64 : #endif /* ZEPHYR_INCLUDE_DEBUG_CORESIGHT_CS_TRACE_DEFMT_H__ */