mirror of
https://github.com/espressif/esp-idf.git
synced 2025-12-10 18:06:29 +00:00
freertos: Refactor port common functions
This commit refactors port_common.c so that it only contains implementation of FreeRTOS port functions that are common to all FreeRTOS ports (i.e., on all architectures and on all FreeRTOS implementations).
This commit is contained in:
@@ -95,6 +95,7 @@ void vApplicationTickHook( void )
|
||||
|
||||
void vPortYieldOtherCore( BaseType_t coreid ) { } // trying to skip for now
|
||||
|
||||
#if ( configSUPPORT_STATIC_ALLOCATION == 1 )
|
||||
/* configUSE_STATIC_ALLOCATION is set to 1, so the application must provide an
|
||||
* implementation of vApplicationGetIdleTaskMemory() to provide the memory that is
|
||||
* used by the Idle task. */
|
||||
@@ -120,8 +121,10 @@ void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer,
|
||||
* configMINIMAL_STACK_SIZE is specified in words, not bytes. */
|
||||
*pulIdleTaskStackSize = configMINIMAL_STACK_SIZE;
|
||||
}
|
||||
#endif // configSUPPORT_STATIC_ALLOCATION == 1
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
#if ( configSUPPORT_STATIC_ALLOCATION == 1 )
|
||||
/* configUSE_STATIC_ALLOCATION and configUSE_TIMERS are both set to 1, so the
|
||||
* application must provide an implementation of vApplicationGetTimerTaskMemory()
|
||||
* to provide the memory that is used by the Timer service task. */
|
||||
@@ -146,6 +149,7 @@ void vApplicationGetTimerTaskMemory( StaticTask_t ** ppxTimerTaskTCBBuffer,
|
||||
* configMINIMAL_STACK_SIZE is specified in words, not bytes. */
|
||||
*pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;
|
||||
}
|
||||
#endif // configSUPPORT_STATIC_ALLOCATION == 1
|
||||
|
||||
void __attribute__((weak)) vApplicationStackOverflowHook(TaskHandle_t xTask, char *pcTaskName)
|
||||
{
|
||||
|
||||
@@ -1,109 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "esp_system.h"
|
||||
#include "esp_memory_utils.h"
|
||||
#include "sdkconfig.h"
|
||||
|
||||
// -------------------- Heap Related -----------------------
|
||||
|
||||
bool xPortCheckValidTCBMem(const void *ptr)
|
||||
{
|
||||
return esp_ptr_internal(ptr) && esp_ptr_byte_accessible(ptr);
|
||||
}
|
||||
|
||||
bool xPortcheckValidStackMem(const void *ptr)
|
||||
{
|
||||
#ifdef CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY
|
||||
return esp_ptr_byte_accessible(ptr);
|
||||
#else
|
||||
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;
|
||||
|
||||
/* If the stack grows down then allocate the stack then the TCB so the stack
|
||||
* does not grow into the TCB. Likewise if the stack grows up then allocate
|
||||
* the TCB then the stack. */
|
||||
#if (portSTACK_GROWTH > 0)
|
||||
{
|
||||
//Allocate TCB and stack buffer in internal memory
|
||||
pxTCBBufferTemp = pvPortMallocTcbMem(sizeof(StaticTask_t));
|
||||
pxStackBufferTemp = pvPortMallocStackMem(configMINIMAL_STACK_SIZE);
|
||||
}
|
||||
#else /* portSTACK_GROWTH */
|
||||
{
|
||||
//Allocate TCB and stack buffer in internal memory
|
||||
pxStackBufferTemp = pvPortMallocStackMem(configMINIMAL_STACK_SIZE);
|
||||
pxTCBBufferTemp = pvPortMallocTcbMem(sizeof(StaticTask_t));
|
||||
}
|
||||
#endif /* portSTACK_GROWTH */
|
||||
|
||||
assert(pxTCBBufferTemp != NULL);
|
||||
assert(pxStackBufferTemp != NULL);
|
||||
//Write back pointers
|
||||
*ppxIdleTaskTCBBuffer = pxTCBBufferTemp;
|
||||
*ppxIdleTaskStackBuffer = pxStackBufferTemp;
|
||||
*pulIdleTaskStackSize = configMINIMAL_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;
|
||||
|
||||
/* If the stack grows down then allocate the stack then the TCB so the stack
|
||||
* does not grow into the TCB. Likewise if the stack grows up then allocate
|
||||
* the TCB then the stack. */
|
||||
#if (portSTACK_GROWTH > 0)
|
||||
{
|
||||
//Allocate TCB and stack buffer in internal memory
|
||||
pxTCBBufferTemp = pvPortMallocTcbMem(sizeof(StaticTask_t));
|
||||
pxStackBufferTemp = pvPortMallocStackMem(configTIMER_TASK_STACK_DEPTH);
|
||||
}
|
||||
#else /* portSTACK_GROWTH */
|
||||
{
|
||||
//Allocate TCB and stack buffer in internal memory
|
||||
pxStackBufferTemp = pvPortMallocStackMem(configTIMER_TASK_STACK_DEPTH);
|
||||
pxTCBBufferTemp = pvPortMallocTcbMem(sizeof(StaticTask_t));
|
||||
}
|
||||
#endif /* portSTACK_GROWTH */
|
||||
|
||||
assert(pxTCBBufferTemp != NULL);
|
||||
assert(pxStackBufferTemp != NULL);
|
||||
//Write back pointers
|
||||
*ppxTimerTaskTCBBuffer = pxTCBBufferTemp;
|
||||
*ppxTimerTaskStackBuffer = pxStackBufferTemp;
|
||||
*pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;
|
||||
}
|
||||
Reference in New Issue
Block a user