mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-31 19:24:33 +02:00
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
This commit is contained in:
@@ -145,3 +145,54 @@ bool xPortcheckValidStackMem(const void *ptr)
|
|||||||
return esp_ptr_internal(ptr) && esp_ptr_byte_accessible(ptr);
|
return esp_ptr_internal(ptr) && esp_ptr_byte_accessible(ptr);
|
||||||
#endif
|
#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;
|
||||||
|
}
|
||||||
|
@@ -2260,30 +2260,30 @@ void vTaskStartScheduler( void )
|
|||||||
{
|
{
|
||||||
BaseType_t xReturn;
|
BaseType_t xReturn;
|
||||||
|
|
||||||
#if ( configSUPPORT_STATIC_ALLOCATION == 1 && configSUPPORT_STATIC_ALLOCATION == 0 )
|
#ifdef ESP_PLATFORM
|
||||||
StaticTask_t *pxIdleTaskTCBBuffer[configNUM_CORES] = {NULL};
|
/* Create an IDLE task for each core */
|
||||||
StackType_t *pxIdleTaskStackBuffer[configNUM_CORES] = {NULL};
|
for(BaseType_t xCoreID = 0; xCoreID < configNUM_CORES; xCoreID++)
|
||||||
uint32_t ulIdleTaskStackSize;
|
#endif //ESP_PLATFORM
|
||||||
#endif
|
|
||||||
|
|
||||||
for(BaseType_t i = 0; i < configNUM_CORES; i++)
|
|
||||||
{
|
|
||||||
/* Add the idle task at the lowest priority. */
|
/* Add the idle task at the lowest priority. */
|
||||||
#if( 0 ) /* configSUPPORT_STATIC_ALLOCATION == 1 ) Temporarily unsupported IDF-2243 */
|
#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
|
/* The Idle task is created using user provided RAM - obtain the
|
||||||
address of the RAM then create the idle task. */
|
address of the RAM then create the idle task. */
|
||||||
vApplicationGetIdleTaskMemory( &pxIdleTaskTCBBuffer[i], &pxIdleTaskStackBuffer[i], &ulIdleTaskStackSize );
|
vApplicationGetIdleTaskMemory( &pxIdleTaskTCBBuffer, &pxIdleTaskStackBuffer, &ulIdleTaskStackSize );
|
||||||
xIdleTaskHandle[i] = xTaskCreateStaticPinnedToCore( prvIdleTask,
|
xIdleTaskHandle[ xCoreID ] = xTaskCreateStaticPinnedToCore( prvIdleTask,
|
||||||
configIDLE_TASK_NAME,
|
configIDLE_TASK_NAME,
|
||||||
ulIdleTaskStackSize,
|
ulIdleTaskStackSize,
|
||||||
( void * ) NULL, /*lint !e961. The cast is not redundant for all 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. */
|
portPRIVILEGE_BIT, /* In effect ( tskIDLE_PRIORITY | portPRIVILEGE_BIT ), but tskIDLE_PRIORITY is zero. */
|
||||||
pxIdleTaskStackBuffer[i],
|
pxIdleTaskStackBuffer,
|
||||||
pxIdleTaskTCBBuffer[i],
|
pxIdleTaskTCBBuffer,
|
||||||
i ); /*lint !e961 MISRA exception, justified as it is not a redundant explicit cast to all supported compilers. */
|
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;
|
xReturn = pdPASS;
|
||||||
}
|
}
|
||||||
@@ -2300,10 +2300,10 @@ void vTaskStartScheduler( void )
|
|||||||
configIDLE_TASK_STACK_SIZE,
|
configIDLE_TASK_STACK_SIZE,
|
||||||
( void * ) NULL,
|
( void * ) NULL,
|
||||||
portPRIVILEGE_BIT, /* In effect ( tskIDLE_PRIORITY | portPRIVILEGE_BIT ), but tskIDLE_PRIORITY is zero. */
|
portPRIVILEGE_BIT, /* In effect ( tskIDLE_PRIORITY | portPRIVILEGE_BIT ), but tskIDLE_PRIORITY is zero. */
|
||||||
&xIdleTaskHandle[i],
|
&xIdleTaskHandle[ xCoreID ],
|
||||||
i ); /*lint !e961 MISRA exception, justified as it is not a redundant explicit cast to all supported compilers. */
|
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;
|
xReturn = pdPASS;
|
||||||
}
|
}
|
||||||
@@ -2313,7 +2313,6 @@ void vTaskStartScheduler( void )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* configSUPPORT_STATIC_ALLOCATION */
|
#endif /* configSUPPORT_STATIC_ALLOCATION */
|
||||||
}
|
|
||||||
|
|
||||||
#if ( configUSE_TIMERS == 1 )
|
#if ( configUSE_TIMERS == 1 )
|
||||||
{
|
{
|
||||||
|
@@ -247,7 +247,7 @@ PRIVILEGED_DATA portMUX_TYPE xTimerMux = portMUX_INITIALIZER_UNLOCKED;
|
|||||||
|
|
||||||
if( xTimerQueue != NULL )
|
if( xTimerQueue != NULL )
|
||||||
{
|
{
|
||||||
#if ( configSUPPORT_STATIC_ALLOCATION == 1 && configSUPPORT_STATIC_ALLOCATION == 0 )
|
#if ( configSUPPORT_STATIC_ALLOCATION == 1 )
|
||||||
{
|
{
|
||||||
StaticTask_t * pxTimerTaskTCBBuffer = NULL;
|
StaticTask_t * pxTimerTaskTCBBuffer = NULL;
|
||||||
StackType_t * pxTimerTaskStackBuffer = NULL;
|
StackType_t * pxTimerTaskStackBuffer = NULL;
|
||||||
|
Reference in New Issue
Block a user