Skip to content

Commit

Permalink
use configSTACK_DEPTH_TYPE consequently (updated for 11.0.x) (#942)
Browse files Browse the repository at this point in the history
* use configSTACK_DEPTH_TYPE consequently

* update default to uint32_t

* Update FreeRTOS.h

Revert for backwards compatibility

* Update portable.h

* configSTACK_DEPTH_TYPE - unify stack variable naming

* update lexicon.txt

* update typo lexicon.txt

* Update task.h

* Update timers.h

* fix merge typo

* fix stack type

* fix timer stack type

* fix timer stack more

* fix affinity set stack

* adjust ports to use configSTACK_DEPTH_TYPE

* fix vTaskListTasks

* set default stack depth type in portable.h

* fix History.txt

* update affinityset

* resolve reviewer comments

* fix prvTaskCheckFreeStackSpace for variable stack size type

* restore CoRoutine defines

* remove obsolete stack ttype casts

* fix (attempt) for format portable.h

* Formatting fixes

* prvTaskCheckFreeStackSpace make variable naming compliant

* Update portable/GCC/ARM_CM33/non_secure/port.c

Co-authored-by: Soren Ptak <ptaksoren@gmail.com>

* Update portable/GCC/ARM_CM23/non_secure/port.c

Co-authored-by: Soren Ptak <ptaksoren@gmail.com>

* Apply suggestions from code review

Update ulStackDepth to uxStackDepth

Co-authored-by: Soren Ptak <ptaksoren@gmail.com>

* Correct uxStackDepth in port.c

Also add uint32_t cast prvGetMPURegionSizeSetting.

* Update ARM CM3 MPU port.c

Revert casting of ( uint32_t ) pxBottomOfStack

* Code review suggestions

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>

---------

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
Co-authored-by: Rahul Kar <118818625+kar-rahul-aws@users.noreply.github.com>
Co-authored-by: Soren Ptak <ptaksoren@gmail.com>
Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com>
Co-authored-by: Gaurav Aggarwal <aggarg@amazon.com>
  • Loading branch information
5 people committed Jan 27, 2024
1 parent 5040a67 commit 14dd5b5
Show file tree
Hide file tree
Showing 38 changed files with 197 additions and 189 deletions.
3 changes: 3 additions & 0 deletions History.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
Documentation and download available at https://www.FreeRTOS.org/

+ Update all the APIs to use configSTACK_DEPTH_TYPE for stack type. If left
undefined, configSTACK_DEPTH_TYPE defaults to StackType_t.

Changes between FreeRTOS V11.0.0 and FreeRTOS V11.0.1 released December 21, 2023

+ Updated the SBOM file.
Expand Down
8 changes: 4 additions & 4 deletions include/FreeRTOS.h
Original file line number Diff line number Diff line change
Expand Up @@ -1642,15 +1642,15 @@
#endif

#ifndef traceENTER_xTaskCreateStatic
#define traceENTER_xTaskCreateStatic( pxTaskCode, pcName, ulStackDepth, pvParameters, uxPriority, puxStackBuffer, pxTaskBuffer )
#define traceENTER_xTaskCreateStatic( pxTaskCode, pcName, uxStackDepth, pvParameters, uxPriority, puxStackBuffer, pxTaskBuffer )
#endif

#ifndef traceRETURN_xTaskCreateStatic
#define traceRETURN_xTaskCreateStatic( xReturn )
#endif

#ifndef traceENTER_xTaskCreateStaticAffinitySet
#define traceENTER_xTaskCreateStaticAffinitySet( pxTaskCode, pcName, ulStackDepth, pvParameters, uxPriority, puxStackBuffer, pxTaskBuffer, uxCoreAffinityMask )
#define traceENTER_xTaskCreateStaticAffinitySet( pxTaskCode, pcName, uxStackDepth, pvParameters, uxPriority, puxStackBuffer, pxTaskBuffer, uxCoreAffinityMask )
#endif

#ifndef traceRETURN_xTaskCreateStaticAffinitySet
Expand Down Expand Up @@ -1690,15 +1690,15 @@
#endif

#ifndef traceENTER_xTaskCreate
#define traceENTER_xTaskCreate( pxTaskCode, pcName, usStackDepth, pvParameters, uxPriority, pxCreatedTask )
#define traceENTER_xTaskCreate( pxTaskCode, pcName, uxStackDepth, pvParameters, uxPriority, pxCreatedTask )
#endif

#ifndef traceRETURN_xTaskCreate
#define traceRETURN_xTaskCreate( xReturn )
#endif

#ifndef traceENTER_xTaskCreateAffinitySet
#define traceENTER_xTaskCreateAffinitySet( pxTaskCode, pcName, usStackDepth, pvParameters, uxPriority, uxCoreAffinityMask, pxCreatedTask )
#define traceENTER_xTaskCreateAffinitySet( pxTaskCode, pcName, uxStackDepth, pvParameters, uxPriority, uxCoreAffinityMask, pxCreatedTask )
#endif

#ifndef traceRETURN_xTaskCreateAffinitySet
Expand Down
4 changes: 2 additions & 2 deletions include/mpu_prototypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,13 @@ BaseType_t MPU_xTaskGetSchedulerState( void ) FREERTOS_SYSTEM_CALL;
* with all the APIs. */
BaseType_t MPU_xTaskCreate( TaskFunction_t pxTaskCode,
const char * const pcName,
const uint16_t usStackDepth,
const configSTACK_DEPTH_TYPE uxStackDepth,
void * const pvParameters,
UBaseType_t uxPriority,
TaskHandle_t * const pxCreatedTask ) PRIVILEGED_FUNCTION;
TaskHandle_t MPU_xTaskCreateStatic( TaskFunction_t pxTaskCode,
const char * const pcName,
const uint32_t ulStackDepth,
const configSTACK_DEPTH_TYPE uxStackDepth,
void * const pvParameters,
UBaseType_t uxPriority,
StackType_t * const puxStackBuffer,
Expand Down
6 changes: 5 additions & 1 deletion include/portable.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@
#define portARCH_NAME NULL
#endif

#ifndef configSTACK_DEPTH_TYPE
#define configSTACK_DEPTH_TYPE StackType_t
#endif

#ifndef configSTACK_ALLOCATION_FROM_SEPARATE_HEAP
/* Defaults to 0 for backward compatibility. */
#define configSTACK_ALLOCATION_FROM_SEPARATE_HEAP 0
Expand Down Expand Up @@ -228,7 +232,7 @@ void vPortEndScheduler( void ) PRIVILEGED_FUNCTION;
void vPortStoreTaskMPUSettings( xMPU_SETTINGS * xMPUSettings,
const struct xMEMORY_REGION * const xRegions,
StackType_t * pxBottomOfStack,
uint32_t ulStackDepth ) PRIVILEGED_FUNCTION;
configSTACK_DEPTH_TYPE uxStackDepth ) PRIVILEGED_FUNCTION;
#endif

/**
Expand Down
42 changes: 21 additions & 21 deletions include/task.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,8 @@ typedef enum
* @code{c}
* BaseType_t xTaskCreate(
* TaskFunction_t pxTaskCode,
* const char *pcName,
* configSTACK_DEPTH_TYPE usStackDepth,
* const char * const pcName,
* const configSTACK_DEPTH_TYPE uxStackDepth,
* void *pvParameters,
* UBaseType_t uxPriority,
* TaskHandle_t *pxCreatedTask
Expand Down Expand Up @@ -323,9 +323,9 @@ typedef enum
* facilitate debugging. Max length defined by configMAX_TASK_NAME_LEN - default
* is 16.
*
* @param usStackDepth The size of the task stack specified as the number of
* @param uxStackDepth The size of the task stack specified as the number of
* variables the stack can hold - not the number of bytes. For example, if
* the stack is 16 bits wide and usStackDepth is defined as 100, 200 bytes
* the stack is 16 bits wide and uxStackDepth is defined as 100, 200 bytes
* will be allocated for stack storage.
*
* @param pvParameters Pointer that will be used as the parameter for the task
Expand Down Expand Up @@ -380,7 +380,7 @@ typedef enum
#if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
BaseType_t xTaskCreate( TaskFunction_t pxTaskCode,
const char * const pcName,
const configSTACK_DEPTH_TYPE usStackDepth,
const configSTACK_DEPTH_TYPE uxStackDepth,
void * const pvParameters,
UBaseType_t uxPriority,
TaskHandle_t * const pxCreatedTask ) PRIVILEGED_FUNCTION;
Expand All @@ -389,7 +389,7 @@ typedef enum
#if ( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configNUMBER_OF_CORES > 1 ) && ( configUSE_CORE_AFFINITY == 1 ) )
BaseType_t xTaskCreateAffinitySet( TaskFunction_t pxTaskCode,
const char * const pcName,
const configSTACK_DEPTH_TYPE usStackDepth,
const configSTACK_DEPTH_TYPE uxStackDepth,
void * const pvParameters,
UBaseType_t uxPriority,
UBaseType_t uxCoreAffinityMask,
Expand All @@ -400,8 +400,8 @@ typedef enum
* task. h
* @code{c}
* TaskHandle_t xTaskCreateStatic( TaskFunction_t pxTaskCode,
* const char *pcName,
* uint32_t ulStackDepth,
* const char * const pcName,
* const configSTACK_DEPTH_TYPE uxStackDepth,
* void *pvParameters,
* UBaseType_t uxPriority,
* StackType_t *puxStackBuffer,
Expand All @@ -427,9 +427,9 @@ typedef enum
* facilitate debugging. The maximum length of the string is defined by
* configMAX_TASK_NAME_LEN in FreeRTOSConfig.h.
*
* @param ulStackDepth The size of the task stack specified as the number of
* @param uxStackDepth The size of the task stack specified as the number of
* variables the stack can hold - not the number of bytes. For example, if
* the stack is 32-bits wide and ulStackDepth is defined as 100 then 400 bytes
* the stack is 32-bits wide and uxStackDepth is defined as 100 then 400 bytes
* will be allocated for stack storage.
*
* @param pvParameters Pointer that will be used as the parameter for the task
Expand All @@ -438,7 +438,7 @@ typedef enum
* @param uxPriority The priority at which the task will run.
*
* @param puxStackBuffer Must point to a StackType_t array that has at least
* ulStackDepth indexes - the array will then be used as the task's stack,
* uxStackDepth indexes - the array will then be used as the task's stack,
* removing the need for the stack to be allocated dynamically.
*
* @param pxTaskBuffer Must point to a variable of type StaticTask_t, which will
Expand Down Expand Up @@ -507,7 +507,7 @@ typedef enum
#if ( configSUPPORT_STATIC_ALLOCATION == 1 )
TaskHandle_t xTaskCreateStatic( TaskFunction_t pxTaskCode,
const char * const pcName,
const uint32_t ulStackDepth,
const configSTACK_DEPTH_TYPE uxStackDepth,
void * const pvParameters,
UBaseType_t uxPriority,
StackType_t * const puxStackBuffer,
Expand All @@ -517,7 +517,7 @@ typedef enum
#if ( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configNUMBER_OF_CORES > 1 ) && ( configUSE_CORE_AFFINITY == 1 ) )
TaskHandle_t xTaskCreateStaticAffinitySet( TaskFunction_t pxTaskCode,
const char * const pcName,
const uint32_t ulStackDepth,
const configSTACK_DEPTH_TYPE uxStackDepth,
void * const pvParameters,
UBaseType_t uxPriority,
StackType_t * const puxStackBuffer,
Expand Down Expand Up @@ -561,7 +561,7 @@ typedef enum
* {
* vATask, // pvTaskCode - the function that implements the task.
* "ATask", // pcName - just a text name for the task to assist debugging.
* 100, // usStackDepth - the stack size DEFINED IN WORDS.
* 100, // uxStackDepth - the stack size DEFINED IN WORDS.
* NULL, // pvParameters - passed into the task function as the function parameters.
* ( 1UL | portPRIVILEGE_BIT ),// uxPriority - task priority, set the portPRIVILEGE_BIT if the task should run in a privileged state.
* cStackBuffer,// puxStackBuffer - the buffer to be used as the task stack.
Expand Down Expand Up @@ -655,7 +655,7 @@ typedef enum
* {
* vATask, // pvTaskCode - the function that implements the task.
* "ATask", // pcName - just a text name for the task to assist debugging.
* 100, // usStackDepth - the stack size DEFINED IN WORDS.
* 100, // uxStackDepth - the stack size DEFINED IN WORDS.
* NULL, // pvParameters - passed into the task function as the function parameters.
* ( 1UL | portPRIVILEGE_BIT ),// uxPriority - task priority, set the portPRIVILEGE_BIT if the task should run in a privileged state.
* cStackBuffer,// puxStackBuffer - the buffer to be used as the task stack.
Expand Down Expand Up @@ -1987,24 +1987,24 @@ char * pcTaskGetName( TaskHandle_t xTaskToQuery ) PRIVILEGED_FUNCTION;
/**
* task.h
* @code{c}
* void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer, StackType_t ** ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize )
* void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer, StackType_t ** ppxIdleTaskStackBuffer, configSTACK_DEPTH_TYPE * puxIdleTaskStackSize )
* @endcode
*
* This function is used to provide a statically allocated block of memory to FreeRTOS to hold the Idle Task TCB. This function is required when
* configSUPPORT_STATIC_ALLOCATION is set. For more information see this URI: https://www.FreeRTOS.org/a00110.html#configSUPPORT_STATIC_ALLOCATION
*
* @param ppxIdleTaskTCBBuffer A handle to a statically allocated TCB buffer
* @param ppxIdleTaskStackBuffer A handle to a statically allocated Stack buffer for the idle task
* @param pulIdleTaskStackSize A pointer to the number of elements that will fit in the allocated stack buffer
* @param puxIdleTaskStackSize A pointer to the number of elements that will fit in the allocated stack buffer
*/
void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer,
StackType_t ** ppxIdleTaskStackBuffer,
uint32_t * pulIdleTaskStackSize );
configSTACK_DEPTH_TYPE * puxIdleTaskStackSize );

/**
* task.h
* @code{c}
* void vApplicationGetPassiveIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer, StackType_t ** ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize, BaseType_t xCoreID )
* void vApplicationGetPassiveIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer, StackType_t ** ppxIdleTaskStackBuffer, configSTACK_DEPTH_TYPE * puxIdleTaskStackSize, BaseType_t xCoreID )
* @endcode
*
* This function is used to provide a statically allocated block of memory to FreeRTOS to hold the Idle Tasks TCB. This function is required when
Expand All @@ -2022,13 +2022,13 @@ char * pcTaskGetName( TaskHandle_t xTaskToQuery ) PRIVILEGED_FUNCTION;
*
* @param ppxIdleTaskTCBBuffer A handle to a statically allocated TCB buffer
* @param ppxIdleTaskStackBuffer A handle to a statically allocated Stack buffer for the idle task
* @param pulIdleTaskStackSize A pointer to the number of elements that will fit in the allocated stack buffer
* @param puxIdleTaskStackSize A pointer to the number of elements that will fit in the allocated stack buffer
* @param xPassiveIdleTaskIndex The passive idle task index of the idle task buffer
*/
#if ( configNUMBER_OF_CORES > 1 )
void vApplicationGetPassiveIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer,
StackType_t ** ppxIdleTaskStackBuffer,
uint32_t * pulIdleTaskStackSize,
configSTACK_DEPTH_TYPE * puxIdleTaskStackSize,
BaseType_t xPassiveIdleTaskIndex );
#endif /* #if ( configNUMBER_OF_CORES > 1 ) */
#endif /* if ( configSUPPORT_STATIC_ALLOCATION == 1 ) */
Expand Down
6 changes: 3 additions & 3 deletions include/timers.h
Original file line number Diff line number Diff line change
Expand Up @@ -1384,19 +1384,19 @@ BaseType_t xTimerGenericCommandFromISR( TimerHandle_t xTimer,
/**
* task.h
* @code{c}
* void vApplicationGetTimerTaskMemory( StaticTask_t ** ppxTimerTaskTCBBuffer, StackType_t ** ppxTimerTaskStackBuffer, uint32_t *pulTimerTaskStackSize )
* void vApplicationGetTimerTaskMemory( StaticTask_t ** ppxTimerTaskTCBBuffer, StackType_t ** ppxTimerTaskStackBuffer, configSTACK_DEPTH_TYPE * puxTimerTaskStackSize )
* @endcode
*
* This function is used to provide a statically allocated block of memory to FreeRTOS to hold the Timer Task TCB. This function is required when
* configSUPPORT_STATIC_ALLOCATION is set. For more information see this URI: https://www.FreeRTOS.org/a00110.html#configSUPPORT_STATIC_ALLOCATION
*
* @param ppxTimerTaskTCBBuffer A handle to a statically allocated TCB buffer
* @param ppxTimerTaskStackBuffer A handle to a statically allocated Stack buffer for the idle task
* @param pulTimerTaskStackSize A pointer to the number of elements that will fit in the allocated stack buffer
* @param puxTimerTaskStackSize A pointer to the number of elements that will fit in the allocated stack buffer
*/
void vApplicationGetTimerTaskMemory( StaticTask_t ** ppxTimerTaskTCBBuffer,
StackType_t ** ppxTimerTaskStackBuffer,
uint32_t * pulTimerTaskStackSize );
configSTACK_DEPTH_TYPE * puxTimerTaskStackSize );

#endif

Expand Down
6 changes: 3 additions & 3 deletions portable/ARMv8M/non_secure/port.c
Original file line number Diff line number Diff line change
Expand Up @@ -1775,7 +1775,7 @@ void vPortEndScheduler( void ) /* PRIVILEGED_FUNCTION */
void vPortStoreTaskMPUSettings( xMPU_SETTINGS * xMPUSettings,
const struct xMEMORY_REGION * const xRegions,
StackType_t * pxBottomOfStack,
uint32_t ulStackDepth )
configSTACK_DEPTH_TYPE uxStackDepth )
{
uint32_t ulRegionStartAddress, ulRegionEndAddress, ulRegionNumber;
int32_t lIndex = 0;
Expand All @@ -1800,10 +1800,10 @@ void vPortEndScheduler( void ) /* PRIVILEGED_FUNCTION */
* which case the stack region parameters will be valid. At all other
* times the stack parameters will not be valid and it is assumed that
* the stack region has already been configured. */
if( ulStackDepth > 0 )
if( uxStackDepth > 0 )
{
ulRegionStartAddress = ( uint32_t ) pxBottomOfStack;
ulRegionEndAddress = ( uint32_t ) pxBottomOfStack + ( ulStackDepth * ( uint32_t ) sizeof( StackType_t ) ) - 1;
ulRegionEndAddress = ( uint32_t ) pxBottomOfStack + ( uxStackDepth * ( configSTACK_DEPTH_TYPE ) sizeof( StackType_t ) ) - 1;

/* If the stack is within the privileged SRAM, do not protect it
* using a separate MPU region. This is needed because privileged
Expand Down
12 changes: 6 additions & 6 deletions portable/Common/mpu_wrappers.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
#if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
BaseType_t MPU_xTaskCreate( TaskFunction_t pvTaskCode,
const char * const pcName,
uint16_t usStackDepth,
const configSTACK_DEPTH_TYPE uxStackDepth,
void * pvParameters,
UBaseType_t uxPriority,
TaskHandle_t * pxCreatedTask ) /* FREERTOS_SYSTEM_CALL */
Expand All @@ -72,15 +72,15 @@
uxPriority = uxPriority & ~( portPRIVILEGE_BIT );
portMEMORY_BARRIER();

xReturn = xTaskCreate( pvTaskCode, pcName, usStackDepth, pvParameters, uxPriority, pxCreatedTask );
xReturn = xTaskCreate( pvTaskCode, pcName, uxStackDepth, pvParameters, uxPriority, pxCreatedTask );
portMEMORY_BARRIER();

portRESET_PRIVILEGE();
portMEMORY_BARRIER();
}
else
{
xReturn = xTaskCreate( pvTaskCode, pcName, usStackDepth, pvParameters, uxPriority, pxCreatedTask );
xReturn = xTaskCreate( pvTaskCode, pcName, uxStackDepth, pvParameters, uxPriority, pxCreatedTask );
}

return xReturn;
Expand All @@ -91,7 +91,7 @@
#if ( configSUPPORT_STATIC_ALLOCATION == 1 )
TaskHandle_t MPU_xTaskCreateStatic( TaskFunction_t pxTaskCode,
const char * const pcName,
const uint32_t ulStackDepth,
const configSTACK_DEPTH_TYPE uxStackDepth,
void * const pvParameters,
UBaseType_t uxPriority,
StackType_t * const puxStackBuffer,
Expand All @@ -107,15 +107,15 @@
uxPriority = uxPriority & ~( portPRIVILEGE_BIT );
portMEMORY_BARRIER();

xReturn = xTaskCreateStatic( pxTaskCode, pcName, ulStackDepth, pvParameters, uxPriority, puxStackBuffer, pxTaskBuffer );
xReturn = xTaskCreateStatic( pxTaskCode, pcName, uxStackDepth, pvParameters, uxPriority, puxStackBuffer, pxTaskBuffer );
portMEMORY_BARRIER();

portRESET_PRIVILEGE();
portMEMORY_BARRIER();
}
else
{
xReturn = xTaskCreateStatic( pxTaskCode, pcName, ulStackDepth, pvParameters, uxPriority, puxStackBuffer, pxTaskBuffer );
xReturn = xTaskCreateStatic( pxTaskCode, pcName, uxStackDepth, pvParameters, uxPriority, puxStackBuffer, pxTaskBuffer );
}

return xReturn;
Expand Down
Loading

0 comments on commit 14dd5b5

Please sign in to comment.