Merge branch 'feature/freertos_static_allocation_task_memory_callbacks_v4.4' into 'release/v4.4'

freertos: Add memory hooks for static IDLE and Timer tasks (v4.4)

See merge request espressif/esp-idf!15614
pull/7868/head
Darian 2021-11-03 11:20:10 +00:00
commit 9fae314f50
3 zmienionych plików z 73 dodań i 23 usunięć

Wyświetl plik

@ -145,3 +145,54 @@ bool xPortcheckValidStackMem(const void *ptr)
return esp_ptr_internal(ptr) && esp_ptr_byte_accessible(ptr);
#endif
}
// ------------- FreeRTOS Static Allocation ----------------
/*
This function is required by FreeRTOS when configSUPPORT_STATIC_ALLOCATION is
enabled and is used by FreeRTOS to obtain memory for its IDLE tasks.
Like the pvPortMallocTcbMem() and pvPortMallocStackMem() macros, TCB and stack
memory MUST be placed in internal RAM.
*/
void vApplicationGetIdleTaskMemory(StaticTask_t **ppxIdleTaskTCBBuffer,
StackType_t **ppxIdleTaskStackBuffer,
uint32_t *pulIdleTaskStackSize )
{
StaticTask_t *pxTCBBufferTemp;
StackType_t *pxStackBufferTemp;
//Allocate TCB and stack buffer in internal memory
pxTCBBufferTemp = pvPortMallocTcbMem(sizeof(StaticTask_t));
pxStackBufferTemp = pvPortMallocStackMem(configIDLE_TASK_STACK_SIZE);
assert(pxTCBBufferTemp != NULL);
assert(pxStackBufferTemp != NULL);
//Write back pointers
*ppxIdleTaskTCBBuffer = pxTCBBufferTemp;
*ppxIdleTaskStackBuffer = pxStackBufferTemp;
*pulIdleTaskStackSize = configIDLE_TASK_STACK_SIZE;
}
/*
This function is required by FreeRTOS when configSUPPORT_STATIC_ALLOCATION is
enabled and is used by the FreeRTOS Timer to obtain memory for its daemone task.
Like the pvPortMallocTcbMem() and pvPortMallocStackMem() macros, TCB and stack
memory MUST be placed in internal RAM.
*/
void vApplicationGetTimerTaskMemory(StaticTask_t **ppxTimerTaskTCBBuffer,
StackType_t **ppxTimerTaskStackBuffer,
uint32_t *pulTimerTaskStackSize )
{
StaticTask_t *pxTCBBufferTemp;
StackType_t *pxStackBufferTemp;
//Allocate TCB and stack buffer in internal memory
pxTCBBufferTemp = pvPortMallocTcbMem(sizeof(StaticTask_t));
pxStackBufferTemp = pvPortMallocStackMem(configTIMER_TASK_STACK_DEPTH);
assert(pxTCBBufferTemp != NULL);
assert(pxStackBufferTemp != NULL);
//Write back pointers
*ppxTimerTaskTCBBuffer = pxTCBBufferTemp;
*ppxTimerTaskStackBuffer = pxStackBufferTemp;
*pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;
}

Wyświetl plik

@ -2260,30 +2260,30 @@ void vTaskStartScheduler( void )
{
BaseType_t xReturn;
#if ( configSUPPORT_STATIC_ALLOCATION == 1 && configSUPPORT_STATIC_ALLOCATION == 0 )
StaticTask_t *pxIdleTaskTCBBuffer[configNUM_CORES] = {NULL};
StackType_t *pxIdleTaskStackBuffer[configNUM_CORES] = {NULL};
uint32_t ulIdleTaskStackSize;
#endif
for(BaseType_t i = 0; i < configNUM_CORES; i++)
{
/* Add the idle task at the lowest priority. */
#if( 0 ) /* configSUPPORT_STATIC_ALLOCATION == 1 ) Temporarily unsupported IDF-2243 */
#ifdef ESP_PLATFORM
/* Create an IDLE task for each core */
for(BaseType_t xCoreID = 0; xCoreID < configNUM_CORES; xCoreID++)
#endif //ESP_PLATFORM
/* Add the idle task at the lowest priority. */
#if ( configSUPPORT_STATIC_ALLOCATION == 1 )
{
StaticTask_t * pxIdleTaskTCBBuffer = NULL;
StackType_t * pxIdleTaskStackBuffer = NULL;
uint32_t ulIdleTaskStackSize;
/* The Idle task is created using user provided RAM - obtain the
address of the RAM then create the idle task. */
vApplicationGetIdleTaskMemory( &pxIdleTaskTCBBuffer[i], &pxIdleTaskStackBuffer[i], &ulIdleTaskStackSize );
xIdleTaskHandle[i] = xTaskCreateStaticPinnedToCore( prvIdleTask,
vApplicationGetIdleTaskMemory( &pxIdleTaskTCBBuffer, &pxIdleTaskStackBuffer, &ulIdleTaskStackSize );
xIdleTaskHandle[ xCoreID ] = xTaskCreateStaticPinnedToCore( prvIdleTask,
configIDLE_TASK_NAME,
ulIdleTaskStackSize,
( void * ) NULL, /*lint !e961. The cast is not redundant for all compilers. */
portPRIVILEGE_BIT, /* In effect ( tskIDLE_PRIORITY | portPRIVILEGE_BIT ), but tskIDLE_PRIORITY is zero. */
pxIdleTaskStackBuffer[i],
pxIdleTaskTCBBuffer[i],
i ); /*lint !e961 MISRA exception, justified as it is not a redundant explicit cast to all supported compilers. */
( void * ) NULL, /*lint !e961. The cast is not redundant for all compilers. */
portPRIVILEGE_BIT, /* In effect ( tskIDLE_PRIORITY | portPRIVILEGE_BIT ), but tskIDLE_PRIORITY is zero. */
pxIdleTaskStackBuffer,
pxIdleTaskTCBBuffer,
xCoreID ); /*lint !e961 MISRA exception, justified as it is not a redundant explicit cast to all supported compilers. */
if( xIdleTaskHandle[i] != NULL )
if( xIdleTaskHandle[ xCoreID ] != NULL )
{
xReturn = pdPASS;
}
@ -2300,10 +2300,10 @@ void vTaskStartScheduler( void )
configIDLE_TASK_STACK_SIZE,
( void * ) NULL,
portPRIVILEGE_BIT, /* In effect ( tskIDLE_PRIORITY | portPRIVILEGE_BIT ), but tskIDLE_PRIORITY is zero. */
&xIdleTaskHandle[i],
i ); /*lint !e961 MISRA exception, justified as it is not a redundant explicit cast to all supported compilers. */
&xIdleTaskHandle[ xCoreID ],
xCoreID ); /*lint !e961 MISRA exception, justified as it is not a redundant explicit cast to all supported compilers. */
if( xIdleTaskHandle[i] != NULL )
if( xIdleTaskHandle[ xCoreID ] != NULL )
{
xReturn = pdPASS;
}
@ -2313,7 +2313,6 @@ void vTaskStartScheduler( void )
}
}
#endif /* configSUPPORT_STATIC_ALLOCATION */
}
#if ( configUSE_TIMERS == 1 )
{

Wyświetl plik

@ -247,7 +247,7 @@ PRIVILEGED_DATA portMUX_TYPE xTimerMux = portMUX_INITIALIZER_UNLOCKED;
if( xTimerQueue != NULL )
{
#if ( configSUPPORT_STATIC_ALLOCATION == 1 && configSUPPORT_STATIC_ALLOCATION == 0 )
#if ( configSUPPORT_STATIC_ALLOCATION == 1 )
{
StaticTask_t * pxTimerTaskTCBBuffer = NULL;
StackType_t * pxTimerTaskStackBuffer = NULL;