1 /* 2 * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #pragma once 8 9 #include "sdkconfig.h" 10 #include "freertos/FreeRTOS.h" 11 #include "freertos/task.h" 12 13 #ifdef __cplusplus 14 extern "C" { 15 #endif 16 17 #if CONFIG_FREERTOS_ENABLE_TASK_SNAPSHOT || defined __DOXYGEN__ 18 /** 19 * @brief Task Snapshot structure 20 * 21 * - Used with the uxTaskGetSnapshotAll() function to save memory snapshot of each task in the system. 22 * - We need this structure because TCB_t is defined (hidden) in tasks.c. 23 */ 24 typedef struct xTASK_SNAPSHOT 25 { 26 void *pxTCB; /*!< Address of the task control block. */ 27 StackType_t *pxTopOfStack; /*!< Points to the location of the last item placed on the tasks stack. */ 28 StackType_t *pxEndOfStack; /*!< Points to the end of the stack. pxTopOfStack < pxEndOfStack, stack grows hi2lo 29 pxTopOfStack > pxEndOfStack, stack grows lo2hi*/ 30 } TaskSnapshot_t; 31 32 /** 33 * @brief Iterate over all tasks in the system 34 * 35 * - This function can be used to iterate over every task in the system 36 * - The first call to this function must set pxTask to NULL 37 * - When all functions have been iterated, this function will return NULL. 38 * - This function is only available when CONFIG_FREERTOS_ENABLE_TASK_SNAPSHOT is set to 1. 39 * 40 * @note This function should only be called when FreeRTOS is no longer running (e.g., during a panic) as this function 41 * does not acquire any locks. 42 * @param pxTask Handle of the previous task (or NULL on the first call of this function) 43 * @return TaskHandle_t Handle of the next task (or NULL when all tasks have been iterated over) 44 */ 45 TaskHandle_t pxTaskGetNext( TaskHandle_t pxTask ); 46 47 /** 48 * @brief Fill a TaskSnapshot_t structure for specified task. 49 * 50 * - This function is used by the panic handler to get the snapshot of a particular task. 51 * - This function is only available when CONFIG_FREERTOS_ENABLE_TASK_SNAPSHOT is set to 1. 52 * 53 * @note This function should only be called when FreeRTOS is no longer running (e.g., during a panic) as this function 54 * does not acquire any locks. 55 * @param[in] pxTask Task's handle 56 * @param[out] pxTaskSnapshot Snapshot of the task 57 * @return pdTRUE if operation was successful else pdFALSE 58 */ 59 BaseType_t vTaskGetSnapshot( TaskHandle_t pxTask, TaskSnapshot_t *pxTaskSnapshot ); 60 61 /** 62 * @brief Fill an array of TaskSnapshot_t structures for every task in the system 63 * 64 * - This function is used by the panic handler to get a snapshot of all tasks in the system 65 * - This function is only available when CONFIG_FREERTOS_ENABLE_TASK_SNAPSHOT is set to 1. 66 * 67 * @note This function should only be called when FreeRTOS is no longer running (e.g., during a panic) as this function 68 * does not acquire any locks. 69 * @param[out] pxTaskSnapshotArray Array of TaskSnapshot_t structures filled by this function 70 * @param[in] uxArrayLength Length of the provided array 71 * @param[out] pxTCBSize Size of the a task's TCB structure 72 * @return UBaseType_t 73 */ 74 UBaseType_t uxTaskGetSnapshotAll( TaskSnapshot_t * const pxTaskSnapshotArray, const UBaseType_t uxArrayLength, UBaseType_t * const pxTCBSize ); 75 76 #endif // CONFIG_FREERTOS_ENABLE_TASK_SNAPSHOT || defined __DOXYGEN__ 77 78 #ifdef __cplusplus 79 } 80 #endif 81