2021-09-24 08:56:45 +00:00
|
|
|
/*
|
2021-06-07 19:54:09 +00:00
|
|
|
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
2021-09-24 08:56:45 +00:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
2020-11-06 04:03:21 +00:00
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include "FreeRTOS.h"
|
|
|
|
#include "task.h"
|
|
|
|
#include "esp_system.h"
|
2022-03-31 07:07:51 +00:00
|
|
|
#include "esp_memory_utils.h"
|
2020-11-06 04:03:21 +00:00
|
|
|
#include "sdkconfig.h"
|
2021-09-24 08:56:45 +00:00
|
|
|
|
2022-11-24 14:28:13 +00:00
|
|
|
/* ----------------------------------------- Port Implementations (Common) --------------------------------------------
|
|
|
|
* - Common FreeRTOS port function implementations
|
|
|
|
* - These functions are common to all FreeRTOS ports (i.e., on all architectures and all FreeRTOS implementations).
|
|
|
|
* ------------------------------------------------------------------------------------------------------------------ */
|
|
|
|
|
2021-10-15 17:08:46 +00:00
|
|
|
// ------------- FreeRTOS Static Allocation ----------------
|
|
|
|
|
|
|
|
/*
|
2022-11-24 14:28:13 +00:00
|
|
|
These function are required by FreeRTOS when configSUPPORT_STATIC_ALLOCATION is
|
|
|
|
enabled and is used by FreeRTOS to obtain memory for its IDLE/Timer tasks.
|
2021-10-15 17:08:46 +00:00
|
|
|
|
2023-03-01 11:06:10 +00:00
|
|
|
We simply allocate the IDLE/Timer tasks memory from the FreeRTOS heap.
|
2021-10-15 17:08:46 +00:00
|
|
|
*/
|
2022-11-24 14:28:13 +00:00
|
|
|
#if ( configSUPPORT_STATIC_ALLOCATION == 1 )
|
2021-10-15 17:08:46 +00:00
|
|
|
void vApplicationGetIdleTaskMemory(StaticTask_t **ppxIdleTaskTCBBuffer,
|
|
|
|
StackType_t **ppxIdleTaskStackBuffer,
|
|
|
|
uint32_t *pulIdleTaskStackSize )
|
|
|
|
{
|
|
|
|
StaticTask_t *pxTCBBufferTemp;
|
|
|
|
StackType_t *pxStackBufferTemp;
|
2022-05-09 10:15:38 +00:00
|
|
|
|
2023-03-01 11:06:10 +00:00
|
|
|
/* Allocate TCB and stack buffer from the FreeRTOS heap
|
|
|
|
*
|
|
|
|
* If the stack grows down then allocate the stack then the TCB so the stack
|
2022-05-09 10:15:38 +00:00
|
|
|
* does not grow into the TCB. Likewise if the stack grows up then allocate
|
|
|
|
* the TCB then the stack. */
|
|
|
|
#if (portSTACK_GROWTH > 0)
|
|
|
|
{
|
2023-03-01 11:06:10 +00:00
|
|
|
pxTCBBufferTemp = pvPortMalloc(sizeof(StaticTask_t));
|
|
|
|
pxStackBufferTemp = pvPortMalloc(configMINIMAL_STACK_SIZE);
|
2022-05-09 10:15:38 +00:00
|
|
|
}
|
|
|
|
#else /* portSTACK_GROWTH */
|
|
|
|
{
|
2023-03-01 11:06:10 +00:00
|
|
|
pxStackBufferTemp = pvPortMalloc(configMINIMAL_STACK_SIZE);
|
|
|
|
pxTCBBufferTemp = pvPortMalloc(sizeof(StaticTask_t));
|
2022-05-09 10:15:38 +00:00
|
|
|
}
|
|
|
|
#endif /* portSTACK_GROWTH */
|
|
|
|
|
2021-10-15 17:08:46 +00:00
|
|
|
assert(pxTCBBufferTemp != NULL);
|
|
|
|
assert(pxStackBufferTemp != NULL);
|
|
|
|
//Write back pointers
|
|
|
|
*ppxIdleTaskTCBBuffer = pxTCBBufferTemp;
|
|
|
|
*ppxIdleTaskStackBuffer = pxStackBufferTemp;
|
2022-11-03 12:56:19 +00:00
|
|
|
*pulIdleTaskStackSize = configMINIMAL_STACK_SIZE;
|
2021-10-15 17:08:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void vApplicationGetTimerTaskMemory(StaticTask_t **ppxTimerTaskTCBBuffer,
|
|
|
|
StackType_t **ppxTimerTaskStackBuffer,
|
|
|
|
uint32_t *pulTimerTaskStackSize )
|
|
|
|
{
|
|
|
|
StaticTask_t *pxTCBBufferTemp;
|
|
|
|
StackType_t *pxStackBufferTemp;
|
2022-05-09 10:15:38 +00:00
|
|
|
|
2023-03-01 11:06:10 +00:00
|
|
|
/* Allocate TCB and stack buffer from the FreeRTOS heap
|
|
|
|
*
|
|
|
|
* If the stack grows down then allocate the stack then the TCB so the stack
|
2022-05-09 10:15:38 +00:00
|
|
|
* does not grow into the TCB. Likewise if the stack grows up then allocate
|
|
|
|
* the TCB then the stack. */
|
|
|
|
#if (portSTACK_GROWTH > 0)
|
|
|
|
{
|
2023-03-01 11:06:10 +00:00
|
|
|
pxTCBBufferTemp = pvPortMalloc(sizeof(StaticTask_t));
|
|
|
|
pxStackBufferTemp = pvPortMalloc(configTIMER_TASK_STACK_DEPTH);
|
2022-05-09 10:15:38 +00:00
|
|
|
}
|
|
|
|
#else /* portSTACK_GROWTH */
|
|
|
|
{
|
2023-03-01 11:06:10 +00:00
|
|
|
pxStackBufferTemp = pvPortMalloc(configTIMER_TASK_STACK_DEPTH);
|
|
|
|
pxTCBBufferTemp = pvPortMalloc(sizeof(StaticTask_t));
|
2022-05-09 10:15:38 +00:00
|
|
|
}
|
|
|
|
#endif /* portSTACK_GROWTH */
|
|
|
|
|
2021-10-15 17:08:46 +00:00
|
|
|
assert(pxTCBBufferTemp != NULL);
|
|
|
|
assert(pxStackBufferTemp != NULL);
|
|
|
|
//Write back pointers
|
|
|
|
*ppxTimerTaskTCBBuffer = pxTCBBufferTemp;
|
|
|
|
*ppxTimerTaskStackBuffer = pxStackBufferTemp;
|
|
|
|
*pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;
|
|
|
|
}
|
2022-11-24 14:28:13 +00:00
|
|
|
#endif // configSUPPORT_STATIC_ALLOCATION == 1
|