1 // Copyright 2015-2021 Espressif Systems (Shanghai) PTE LTD 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #pragma once 16 17 #include "freertos/FreeRTOS.h" 18 #include "freertos/task.h" 19 20 #if ( configENABLE_TASK_SNAPSHOT == 1 ) 21 22 #ifdef __cplusplus 23 extern "C" { 24 #endif 25 26 /** 27 * Check `freertos_tasks_c_additions.h` file for more info 28 * about these functions declaration. 29 */ 30 UBaseType_t pxTCBGetSize ( void ); 31 ListItem_t* pxTCBGetStateListItem ( void *pxTCB ); 32 StackType_t* pxTCBGetStartOfStack ( void *pxTCB ); 33 StackType_t* pxTCBGetTopOfStack ( void *pxTCB ); 34 StackType_t* pxTCBGetEndOfStack ( void *pxTCB ); 35 List_t* pxListGetReadyTask ( UBaseType_t idx ); 36 List_t* pxListGetReadyPendingTask ( UBaseType_t idx ); 37 List_t* pxGetDelayedTaskList ( void ); 38 List_t* pxGetOverflowDelayedTaskList ( void ); 39 List_t* pxGetTasksWaitingTermination ( void ); 40 List_t* pxGetSuspendedTaskList ( void ); 41 42 /** 43 * Used with the uxTaskGetSnapshotAll() function to save memory snapshot of each task in the system. 44 * We need this struct because TCB_t is defined (hidden) in tasks.c. 45 */ 46 typedef struct xTASK_SNAPSHOT 47 { 48 void *pxTCB; /*!< Address of task control block. */ 49 StackType_t *pxTopOfStack; /*!< Points to the location of the last item placed on the tasks stack. */ 50 StackType_t *pxEndOfStack; /*!< Points to the end of the stack. pxTopOfStack < pxEndOfStack, stack grows hi2lo 51 pxTopOfStack > pxEndOfStack, stack grows lo2hi*/ 52 } TaskSnapshot_t; 53 54 55 /* 56 * This function fills array with TaskSnapshot_t structures for every task in the system. 57 * Used by panic handling code to get snapshots of all tasks in the system. 58 * Only available when configENABLE_TASK_SNAPSHOT is set to 1. 59 * @param pxTaskSnapshotArray Pointer to array of TaskSnapshot_t structures to store tasks snapshot data. 60 * @param uxArraySize Size of tasks snapshots array. 61 * @param pxTcbSz Pointer to store size of TCB. 62 * @return Number of elements stored in array. 63 */ 64 UBaseType_t uxTaskGetSnapshotAll( TaskSnapshot_t * const pxTaskSnapshotArray, const UBaseType_t uxArraySize, UBaseType_t * const pxTcbSz ); 65 66 /* 67 * This function iterates over all tasks in the system. 68 * Used by panic handling code to iterate over tasks in the system. 69 * Only available when configENABLE_TASK_SNAPSHOT is set to 1. 70 * @note This function should not be used while FreeRTOS is running (as it doesn't acquire any locks). 71 * @param pxTask task handle. 72 * @return Handle for the next task. If pxTask is NULL, returns hadnle for the first task. 73 */ 74 TaskHandle_t pxTaskGetNext( TaskHandle_t pxTask ); 75 76 /* 77 * This function fills TaskSnapshot_t structure for specified task. 78 * Used by panic handling code to get snapshot of a task. 79 * Only available when configENABLE_TASK_SNAPSHOT is set to 1. 80 * @note This function should not be used while FreeRTOS is running (as it doesn't acquire any locks). 81 * @param pxTask task handle. 82 * @param pxTaskSnapshot address of TaskSnapshot_t structure to fill. 83 */ 84 void vTaskGetSnapshot( TaskHandle_t pxTask, TaskSnapshot_t *pxTaskSnapshot ); 85 86 #ifdef __cplusplus 87 } 88 #endif 89 90 #endif 91