Compare commits

...

10 commits

Author SHA1 Message Date
jasonpcarroll
5282247346
Add assert to check for overflow in xStreamBufferSendFromISR. (#1357)
Co-authored-by: czjaso <czjaso@amazon.com>
2026-01-13 13:35:01 -08:00
Maxim De Clercq
8a416d79c0
fix: Add big-endian support to ARM_CRx_No_GIC port (#1355)
This change makes sure the Data endianness bit is set in the SPSR
register when the program is being compiled for big-endian.

Signed-off-by: Maxim De Clercq <maximdeclercq00@gmail.com>
2026-01-12 21:22:07 +05:30
Bernd Edlinger
d5c3c98ae4
Add CFI frame unwind info in portable/IAR/RXv2/port_asm.s (#1341)
This allows the IAR debugger to display the callstack beyond
__interrupt_27 when a breakpoint in vTaskSwitchContext is made.
2026-01-12 17:53:32 +05:30
Graham Sanderson
c53a6b0547
RP2040: Add xPortIsInsideInterrupt to match other ARM ports (#1356)
Co-authored-by: graham sanderson <graham.sanderson@raspeberryi.com>
2026-01-12 12:28:27 +05:30
Kody Stribrny
1dbc77697f
[Fix] Reset correct priority on disinherit timeout (#1338)
This commit corrects vTaskPriorityDisinheritAfterTimeout
to reset the previously inherited priority when the task
disiheriting timeout was the only task at that priority.
Without this change the ready list for the inherited
priority will remain set when no task is ready at that priority.
This can have consequences later as the ready priority flags are
assumed to be accurate.

Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com>
2025-12-31 10:07:49 -08:00
Sidharth
26f9a2fdd3
Add cast in stack allocation for task creation (#1340)
for negative portSTACK_GROWTH, add cast to stack allocation, just like it is in positive portSTACK_GROWTH
2025-12-31 12:43:24 +05:30
Harsh Soni
14b30f209f
fix: Add missing macro guards in task.h (#1342)
- Add missing conditions to prevent unintended access to
  certain APIs in task.h
- The condition is mentioned in the API description but was
  absent in the code
2025-12-29 23:37:57 +05:30
AniruddhaKanhere
3ace38969b Add asserts to check stack overflow at task creation
This commit adds assert to allow developers to check for overflow of
undersized task stack during task creation.
2025-12-24 14:19:20 -08:00
nordync
a9cb459206
Win32: Guard timeapi.h include for MinGW compatibility (#1345)
* bugfix/mingw-timeapi

* fix: clean up Windows timer includes

- Removed legacy GCC-specific include block.
- Added compiler-specific headers:
  - MSVC (_MSC_VER): includes <timeapi.h> and links winmm.lib
  - Other compilers: includes <mmsystem.h>
- Ensures cross-compiler compatibility and avoids duplicate headers.

---------

Co-authored-by: Metehan Öztürk <mete_pukkada@outlook.com>
Co-authored-by: Monika Singh <moninom@amazon.com>
2025-12-23 12:01:31 -08:00
Kody Stribrny
536914b2a4
Add catch up behavior to xTaskDelayUntil. (#1348)
Adds an explanation for why xTaskDelayUntil
can break from the configured frequency when
catching up for past events. More will be added
to the website documentation.
2025-12-23 09:30:36 -08:00
8 changed files with 86 additions and 11 deletions

View file

@ -29,6 +29,7 @@ APIC
APROCFREQ
APSR
ARMCM
ARMEB
Armv
ARMVFP
ASTRINGZ

View file

@ -602,12 +602,12 @@ typedef enum
* \defgroup xTaskCreateRestricted xTaskCreateRestricted
* \ingroup Tasks
*/
#if ( portUSING_MPU_WRAPPERS == 1 )
#if ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )
BaseType_t xTaskCreateRestricted( const TaskParameters_t * const pxTaskDefinition,
TaskHandle_t * pxCreatedTask ) PRIVILEGED_FUNCTION;
#endif
#if ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configNUMBER_OF_CORES > 1 ) && ( configUSE_CORE_AFFINITY == 1 ) )
#if ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configNUMBER_OF_CORES > 1 ) && ( configUSE_CORE_AFFINITY == 1 ) )
BaseType_t xTaskCreateRestrictedAffinitySet( const TaskParameters_t * const pxTaskDefinition,
UBaseType_t uxCoreAffinityMask,
TaskHandle_t * pxCreatedTask ) PRIVILEGED_FUNCTION;
@ -897,7 +897,8 @@ void vTaskDelay( const TickType_t xTicksToDelay ) PRIVILEGED_FUNCTION;
*
* @return Value which can be used to check whether the task was actually delayed.
* Will be pdTRUE if the task way delayed and pdFALSE otherwise. A task will not
* be delayed if the next expected wake time is in the past.
* be delayed if the next expected wake time is in the past. This prevents periodic
* tasks from accumulating delays and allows them to resume their regular timing pattern.
*
* Example usage:
* @code{c}

View file

@ -61,7 +61,11 @@
#define portNO_FLOATING_POINT_CONTEXT ( ( StackType_t ) 0 )
/* Constants required to setup the initial task context. */
#define portINITIAL_SPSR ( ( StackType_t ) 0x1f ) /* System mode, ARM mode, IRQ enabled FIQ enabled. */
#ifdef __ARMEB__
#define portINITIAL_SPSR ( ( StackType_t ) 0x21f ) /* System mode, ARM mode, IRQ enabled FIQ enabled, Big-endian. */
#else
#define portINITIAL_SPSR ( ( StackType_t ) 0x01f ) /* System mode, ARM mode, IRQ enabled FIQ enabled, Little-endian. */
#endif
#define portTHUMB_MODE_BIT ( ( StackType_t ) 0x20 )
#define portTHUMB_MODE_ADDRESS ( 0x01UL )

View file

@ -34,6 +34,37 @@
EXTERN _pxCurrentTCB
EXTERN _vTaskSwitchContext
CFI Names cfiNames0
CFI StackFrame CFA SP DATA
CFI VirtualResource ?RET:32
CFI Resource R1:32, R2:32, R3:32, R4:32, R5:32, R6:32, R7:32, R8:32
CFI Resource R9:32, R10:32, R11:32, R12:32, R13:32, R14:32, R15:32
CFI Resource SP:32
CFI EndNames cfiNames0
CFI Common cfiCommon0 Using cfiNames0
CFI CodeAlign 1
CFI DataAlign 1
CFI ReturnAddress ?RET CODE
CFI CFA SP+4
CFI ?RET Frame(CFA, -4)
CFI R1 Undefined
CFI R2 Undefined
CFI R3 Undefined
CFI R4 Undefined
CFI R5 Undefined
CFI R6 SameValue
CFI R7 SameValue
CFI R8 SameValue
CFI R9 SameValue
CFI R10 SameValue
CFI R11 SameValue
CFI R12 SameValue
CFI R13 SameValue
CFI R14 Undefined
CFI R15 Undefined
CFI EndCommon cfiCommon0
RSEG CODE:CODE(4)
_prvStartFirstTask:
@ -91,6 +122,9 @@ _prvStartFirstTask:
/*-----------------------------------------------------------*/
/* The software interrupt - overwrite the default 'weak' definition. */
CFI Block cfiBlock0 Using cfiCommon0
CFI Function ___interrupt_27
CODE
___interrupt_27:
/* Re-enable interrupts. */
@ -151,6 +185,24 @@ ___interrupt_27:
MVTIPL #configMAX_SYSCALL_INTERRUPT_PRIORITY
/* Select the next task to run. */
CFI ?RET Frame(CFA, -8)
CFI R15 Frame(CFA, -12)
CFI R14 Frame(CFA, -16)
CFI R13 Frame(CFA, -20)
CFI R12 Frame(CFA, -24)
CFI R11 Frame(CFA, -28)
CFI R10 Frame(CFA, -32)
CFI R9 Frame(CFA, -36)
CFI R8 Frame(CFA, -40)
CFI R7 Frame(CFA, -44)
CFI R6 Frame(CFA, -48)
CFI R5 Frame(CFA, -52)
CFI R4 Frame(CFA, -56)
CFI R3 Frame(CFA, -60)
CFI R2 Frame(CFA, -64)
CFI R1 Frame(CFA, -68)
CFI CFA SP+96
CFI FunCall _vTaskSwitchContext
BSR.A _vTaskSwitchContext
/* Reset the interrupt mask as no more data structure access is required. */
@ -194,6 +246,7 @@ ___interrupt_27:
RTE
NOP
NOP
CFI EndBlock cfiBlock0
/*-----------------------------------------------------------*/

View file

@ -39,12 +39,11 @@
#include <winsock.h>
#endif
#include <timeapi.h>
#ifdef __GNUC__
#include "mmsystem.h"
#else
#ifdef _MSC_VER
#include <timeapi.h>
#pragma comment(lib, "winmm.lib")
#else
#include <mmsystem.h>
#endif
#define portMAX_INTERRUPTS ( ( uint32_t ) sizeof( uint32_t ) * 8UL ) /* The number of bits in an uint32_t. */

View file

@ -149,6 +149,10 @@ extern void vPortYield( void );
__asm volatile ( "mrs %0, IPSR" : "=r" ( ulIPSR )::); \
( ( uint8_t ) ulIPSR ) > 0; } )
/* Use #define rather than inline method to make it easier for user code
* to work with kernel versions both with and without xPortIsInsideInterrupt */
#define xPortIsInsideInterrupt() ((BaseType_t)portCHECK_IF_IN_ISR())
void vYieldCore( int xCoreID );
#define portYIELD_CORE( a ) vYieldCore( a )

View file

@ -961,6 +961,9 @@ size_t xStreamBufferSendFromISR( StreamBufferHandle_t xStreamBuffer,
if( ( pxStreamBuffer->ucFlags & sbFLAGS_IS_MESSAGE_BUFFER ) != ( uint8_t ) 0 )
{
xRequiredSpace += sbBYTES_TO_STORE_MESSAGE_LENGTH;
/* Overflow? */
configASSERT( xRequiredSpace > xDataLengthBytes );
}
else
{

14
tasks.c
View file

@ -1689,7 +1689,7 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB ) PRIVILEGED_FUNCTION;
/* MISRA Ref 11.5.1 [Malloc memory assignment] */
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/main/MISRA.md#rule-115 */
/* coverity[misra_c_2012_rule_11_5_violation] */
pxStack = pvPortMallocStack( ( ( ( size_t ) uxStackDepth ) * sizeof( StackType_t ) ) );
pxStack = ( StackType_t * ) pvPortMallocStack( ( ( ( size_t ) uxStackDepth ) * sizeof( StackType_t ) ) );
if( pxStack != NULL )
{
@ -2010,6 +2010,16 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
}
#endif /* portUSING_MPU_WRAPPERS */
#if ( portSTACK_GROWTH < 0 )
{
configASSERT( ( ( portPOINTER_SIZE_TYPE ) ( pxTopOfStack - pxNewTCB->pxTopOfStack ) ) < ( ( portPOINTER_SIZE_TYPE ) uxStackDepth ) );
}
#else /* portSTACK_GROWTH */
{
configASSERT( ( ( portPOINTER_SIZE_TYPE ) ( pxNewTCB->pxTopOfStack - pxTopOfStack ) ) < ( ( portPOINTER_SIZE_TYPE ) uxStackDepth ) );
}
#endif
/* Initialize task state and task attributes. */
#if ( configNUMBER_OF_CORES > 1 )
{
@ -6906,7 +6916,7 @@ static void prvResetNextTaskUnblockTime( void )
/* It is known that the task is in its ready list so
* there is no need to check again and the port level
* reset macro can be called directly. */
portRESET_READY_PRIORITY( pxTCB->uxPriority, uxTopReadyPriority );
portRESET_READY_PRIORITY( uxPriorityUsedOnEntry, uxTopReadyPriority );
}
else
{