1 /* 2 * Percepio DFM v2.1.0 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 DFM Zephyr Kernel port API 13 */ 14 15 #ifndef DFM_KERNEL_PORT_H 16 #define DFM_KERNEL_PORT_H 17 18 #include <dfmConfig.h> 19 #include <zephyr/kernel.h> 20 #include <zephyr/irq.h> 21 22 #if ((DFM_CFG_ENABLED) == 1) 23 24 #ifdef __cplusplus 25 extern "C" { 26 #endif 27 28 /** 29 * @defgroup dfm_kernel_port_zephyr_apis DFM Zephyr Kernel port API 30 * @ingroup dfm_apis 31 * @{ 32 */ 33 34 /** 35 * @brief Kernel port system data 36 */ 37 typedef struct DfmKernelPortData 38 { 39 uint32_t dummy; 40 } DfmKernelPortData_t; 41 42 /** 43 * @brief Initialize Kernel port system 44 * 45 * @param[in] pxBuffer Kernel port system buffer. 46 * 47 * @retval DFM_FAIL Failure 48 * @retval DFM_SUCCESS Success 49 */ 50 DfmResult_t xDfmKernelPortInitialize(DfmKernelPortData_t* pxBuffer); 51 52 /** 53 * @brief Retrieves the current task name 54 * 55 * @param[in] ppvTask Pointer where current task will be written. 56 * 57 * @retval DFM_FAIL Failure 58 * @retval DFM_SUCCESS Success 59 */ 60 DfmResult_t xDfmKernelPortGetCurrentTaskName(char** pszTaskName); 61 62 /** @} */ 63 64 /** 65 * Disable interrupts, kernel port specific 66 */ 67 #define vDfmDisableInterrupts() irq_lock(); 68 69 #if DFM_CFG_ENABLE_COREDUMPS == 1 70 /** 71 * Append a coredump to an alert. Where a normal coredump called from the kernel will result in a new alert being generated, 72 * this is meant for alerts with a reason > 0xFFFF0000. When calling upon this function, the internal state stored within the 73 * kernel port is appended to the alert specified (which could be either to be sent directly to the CloudPort or stored 74 * by the StoragePort, depending on CloudPort availability and user settings). 75 * @param xAlertHandle The alert which the coredump should be attached to 76 * @return 77 */ 78 DfmResult_t xDfmAlertAddCoredump(DfmAlertHandle_t xAlertHandle); 79 #else 80 #define xDfmAlertAddCoredump(xAlertHandle) (DFM_FAIL) 81 #endif 82 83 #if defined(CONFIG_PERCEPIO_TRACERECORDER) && CONFIG_PERCEPIO_TRACERECORDER == 1 && defined(CONFIG_PERCEPIO_TRC_CFG_STREAM_PORT_RINGBUFFER) 84 /** 85 * Attach a trace to the Alert. This requires the TraceAlyzer module to be enabled and configured to use the Ring Buffer. 86 * Note that this function will disable tracing to be able to capture and attach the trace, thus, if you wish to have the 87 * tracing continue after adding the trace to your alert, you will need to re-enable tracing bu executing xTraceEnable(TRC_START) 88 * afterwards. 89 * 90 * @param xAlertHandle The alert which the trace should be attached to 91 * @return 92 */ 93 DfmResult_t xDfmAlertAddTrace(DfmAlertHandle_t xAlertHandle); 94 #endif 95 96 #ifdef __cplusplus 97 } 98 #endif 99 100 #endif 101 102 #endif 103