1 /* 2 * Copyright (c) 2019 Intel corporation 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #ifndef _TRACE_CORE_H 8 #define _TRACE_CORE_H 9 10 #include <zephyr/irq.h> 11 #include <zephyr/types.h> 12 13 #ifdef __cplusplus 14 extern "C" { 15 #endif 16 17 #define TRACING_LOCK() { int key; key = irq_lock() 18 19 #define TRACING_UNLOCK() { irq_unlock(key); } } 20 21 /** 22 * @brief Check tracing enabled or not. 23 * 24 * @return True if tracing enabled; False if tracing disabled. 25 */ 26 bool is_tracing_enabled(void); 27 28 /** 29 * @brief Give tracing buffer to backend. 30 * 31 * @param data Tracing buffer address. 32 * @param length Tracing buffer length. 33 */ 34 void tracing_buffer_handle(uint8_t *data, uint32_t length); 35 36 /** 37 * @brief Handle tracing packet drop. 38 */ 39 void tracing_packet_drop_handle(void); 40 41 /** 42 * @brief Handle tracing command. 43 * 44 * @param buf Tracing command buffer address. 45 * @param length Tracing command buffer length. 46 */ 47 void tracing_cmd_handle(uint8_t *buf, uint32_t length); 48 49 /** 50 * @brief Trigger tracing thread to run after every first put. 51 * 52 * @param before_put_is_empty If tracing buffer is empty before this put. 53 */ 54 void tracing_trigger_output(bool before_put_is_empty); 55 56 /** 57 * @brief Check if we are in tracing thread context. 58 * 59 * @return True if in tracing thread context; False if not. 60 */ 61 bool is_tracing_thread(void); 62 63 #ifdef __cplusplus 64 } 65 #endif 66 67 #endif 68