Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .github/scripts/kernel_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@
r'.*portable/.*/ARM_CM35*',
r'.*portable/.*/ARM_CM55*',
r'.*portable/.*/ARM_CM85*',
r'.*portable/.*/ARM_CM0*',
r'.*portable/.*/ARM_CM3_MPU*',
r'.*portable/.*/ARM_CM4_MPU*',
r'.*portable/.*/ARM_CM4F_MPU*',
]

KERNEL_HEADER = [
Expand Down Expand Up @@ -150,8 +154,8 @@
FREERTOS_COPYRIGHT_REGEX = r"^(;|#)?( *(\/\*|\*|#|\/\/))? Copyright \(C\) 20\d\d Amazon.com, Inc. or its affiliates. All Rights Reserved\.( \*\/)?$"

FREERTOS_ARM_COLLAB_COPYRIGHT_REGEX = r"(^(;|#)?( *(\/\*|\*|#|\/\/))? Copyright \(C\) 20\d\d Amazon.com, Inc. or its affiliates. All Rights Reserved\.( \*\/)?$)|" + \
r"(^(;|#)?( *(\/\*|\*|#|\/\/))? Copyright 20\d\d Arm Limited and/or its affiliates( \*\/)?$)|" + \
r"(^(;|#)?( *(\/\*|\*|#|\/\/))? <[email protected]>( \*\/)?$)"
r"(^(;|#)?( *(\/\*|\*|#|\/\/))? Copyright 20\d\d(-20\d\d)? Arm Limited and/or its affiliates( +<open-source-office@arm\.com>)?( \*\/)?$)|" + \
r"(^(;|#)?( *(\/\*|\*|#|\/\/))? <open-source-office@arm\.com>( \*\/)?$)"


class KernelHeaderChecker(HeaderChecker):
Expand Down
36 changes: 22 additions & 14 deletions portable/ARMv8M/non_secure/port.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* FreeRTOS Kernel <DEVELOPMENT BRANCH>
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
* Copyright 2024 Arm Limited and/or its affiliates
* Copyright 2024-2025 Arm Limited and/or its affiliates
* <[email protected]>
*
* SPDX-License-Identifier: MIT
Expand Down Expand Up @@ -1200,7 +1200,7 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO
extern UBaseType_t uxSystemCallImplementations[ NUM_SYSTEM_CALLS ];
xMPU_SETTINGS * pxMpuSettings;
uint32_t * pulSystemCallStack;
uint32_t ulStackFrameSize, ulSystemCallLocation, i;
uint32_t ulHardwareSavedExceptionFrameSize, ulSystemCallLocation, i;

#if defined( __ARMCC_VERSION )

Expand Down Expand Up @@ -1236,12 +1236,16 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO
{
pulSystemCallStack = pxMpuSettings->xSystemCallStackInfo.pulSystemCallStack;

/* Hardware Saved Stack Frame Size upon Exception entry:
* - No FPU: basic frame (R0-R3, R12, LR, PC, and xPSR) = 8 words.
* - With FPU (lazy stacking): basic frame + S0–S15 + FPSCR + reserved word = 26 words.
*/
#if ( ( configENABLE_FPU == 1 ) || ( configENABLE_MVE == 1 ) )
{
if( ( ulLR & portEXC_RETURN_STACK_FRAME_TYPE_MASK ) == 0UL )
{
/* Extended frame i.e. FPU in use. */
ulStackFrameSize = 26;
ulHardwareSavedExceptionFrameSize = 26;
__asm volatile (
" vpush {s0} \n" /* Trigger lazy stacking. */
" vpop {s0} \n" /* Nullify the affect of the above instruction. */
Expand All @@ -1251,20 +1255,20 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO
else
{
/* Standard frame i.e. FPU not in use. */
ulStackFrameSize = 8;
ulHardwareSavedExceptionFrameSize = 8;
}
}
#else /* if ( ( configENABLE_FPU == 1 ) || ( configENABLE_MVE == 1 ) ) */
{
ulStackFrameSize = 8;
ulHardwareSavedExceptionFrameSize = 8;
}
#endif /* configENABLE_FPU || configENABLE_MVE */

/* Make space on the system call stack for the stack frame. */
pulSystemCallStack = pulSystemCallStack - ulStackFrameSize;
pulSystemCallStack = pulSystemCallStack - ulHardwareSavedExceptionFrameSize;

/* Copy the stack frame. */
for( i = 0; i < ulStackFrameSize; i++ )
for( i = 0; i < ulHardwareSavedExceptionFrameSize; i++ )
{
pulSystemCallStack[ i ] = pulTaskStack[ i ];
}
Expand Down Expand Up @@ -1300,7 +1304,7 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO

/* Remember the location where we should copy the stack frame when we exit from
* the system call. */
pxMpuSettings->xSystemCallStackInfo.pulTaskStack = pulTaskStack + ulStackFrameSize;
pxMpuSettings->xSystemCallStackInfo.pulTaskStack = pulTaskStack + ulHardwareSavedExceptionFrameSize;

/* Record if the hardware used padding to force the stack pointer
* to be double word aligned. */
Expand Down Expand Up @@ -1350,7 +1354,7 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO
extern TaskHandle_t pxCurrentTCB;
xMPU_SETTINGS * pxMpuSettings;
uint32_t * pulTaskStack;
uint32_t ulStackFrameSize, ulSystemCallLocation, i;
uint32_t ulHardwareSavedExceptionFrameSize, ulSystemCallLocation, i;

#if defined( __ARMCC_VERSION )

Expand Down Expand Up @@ -1382,12 +1386,16 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO
{
pulTaskStack = pxMpuSettings->xSystemCallStackInfo.pulTaskStack;

/* Hardware Saved Stack Frame Size upon Exception entry:
* - No FPU: basic frame (R0-R3, R12, LR, PC, and xPSR) = 8 words.
* - With FPU (lazy stacking): basic frame + S0–S15 + FPSCR + reserved word = 26 words.
*/
#if ( ( configENABLE_FPU == 1 ) || ( configENABLE_MVE == 1 ) )
{
if( ( ulLR & portEXC_RETURN_STACK_FRAME_TYPE_MASK ) == 0UL )
{
/* Extended frame i.e. FPU in use. */
ulStackFrameSize = 26;
ulHardwareSavedExceptionFrameSize = 26;
__asm volatile (
" vpush {s0} \n" /* Trigger lazy stacking. */
" vpop {s0} \n" /* Nullify the affect of the above instruction. */
Expand All @@ -1397,20 +1405,20 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO
else
{
/* Standard frame i.e. FPU not in use. */
ulStackFrameSize = 8;
ulHardwareSavedExceptionFrameSize = 8;
}
}
#else /* if ( ( configENABLE_FPU == 1 ) || ( configENABLE_MVE == 1 ) ) */
{
ulStackFrameSize = 8;
ulHardwareSavedExceptionFrameSize = 8;
}
#endif /* configENABLE_FPU || configENABLE_MVE */

/* Make space on the task stack for the stack frame. */
pulTaskStack = pulTaskStack - ulStackFrameSize;
pulTaskStack = pulTaskStack - ulHardwareSavedExceptionFrameSize;

/* Copy the stack frame. */
for( i = 0; i < ulStackFrameSize; i++ )
for( i = 0; i < ulHardwareSavedExceptionFrameSize; i++ )
{
pulTaskStack[ i ] = pulSystemCallStack[ i ];
}
Expand Down
22 changes: 15 additions & 7 deletions portable/GCC/ARM_CM0/port.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/*
* FreeRTOS Kernel <DEVELOPMENT BRANCH>
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
* Copyright 2025 Arm Limited and/or its affiliates
* <[email protected]>
*
* SPDX-License-Identifier: MIT
*
Expand Down Expand Up @@ -915,7 +917,10 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO
xMPU_SETTINGS * pxMpuSettings;
uint32_t * pulSystemCallStack;
uint32_t ulSystemCallLocation, i;
const uint32_t ulStackFrameSize = 8;
/* Hardware Saved Stack Frame Size upon Exception entry:
* Basic frame (R0-R3, R12, LR, PC, and xPSR) = 8 words.
*/
const uint32_t ulHardwareSavedExceptionFrameSize = 8;

#if defined( __ARMCC_VERSION )

Expand Down Expand Up @@ -955,10 +960,10 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO
pulSystemCallStack = pxMpuSettings->xSystemCallStackInfo.pulSystemCallStack;

/* Make space on the system call stack for the stack frame. */
pulSystemCallStack = pulSystemCallStack - ulStackFrameSize;
pulSystemCallStack = pulSystemCallStack - ulHardwareSavedExceptionFrameSize;

/* Copy the stack frame. */
for( i = 0; i < ulStackFrameSize; i++ )
for( i = 0; i < ulHardwareSavedExceptionFrameSize; i++ )
{
pulSystemCallStack[ i ] = pulTaskStack[ i ];
}
Expand All @@ -981,7 +986,7 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO

/* Remember the location where we should copy the stack frame when we exit from
* the system call. */
pxMpuSettings->xSystemCallStackInfo.pulTaskStack = pulTaskStack + ulStackFrameSize;
pxMpuSettings->xSystemCallStackInfo.pulTaskStack = pulTaskStack + ulHardwareSavedExceptionFrameSize;

/* Record if the hardware used padding to force the stack pointer
* to be double word aligned. */
Expand Down Expand Up @@ -1036,7 +1041,10 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO
xMPU_SETTINGS * pxMpuSettings;
uint32_t * pulTaskStack;
uint32_t ulSystemCallLocation, i;
const uint32_t ulStackFrameSize = 8;
/* Hardware Saved Stack Frame Size upon Exception entry:
* Basic frame (R0-R3, R12, LR, PC, and xPSR) = 8 words.
*/
const uint32_t ulHardwareSavedExceptionFrameSize = 8;

#if defined( __ARMCC_VERSION )

Expand Down Expand Up @@ -1072,10 +1080,10 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO
pulTaskStack = pxMpuSettings->xSystemCallStackInfo.pulTaskStack;

/* Make space on the task stack for the stack frame. */
pulTaskStack = pulTaskStack - ulStackFrameSize;
pulTaskStack = pulTaskStack - ulHardwareSavedExceptionFrameSize;

/* Copy the stack frame. */
for( i = 0; i < ulStackFrameSize; i++ )
for( i = 0; i < ulHardwareSavedExceptionFrameSize; i++ )
{
pulTaskStack[ i ] = pulSystemCallStack[ i ];
}
Expand Down
36 changes: 22 additions & 14 deletions portable/GCC/ARM_CM23/non_secure/port.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* FreeRTOS Kernel <DEVELOPMENT BRANCH>
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
* Copyright 2024 Arm Limited and/or its affiliates
* Copyright 2024-2025 Arm Limited and/or its affiliates
* <[email protected]>
*
* SPDX-License-Identifier: MIT
Expand Down Expand Up @@ -1200,7 +1200,7 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO
extern UBaseType_t uxSystemCallImplementations[ NUM_SYSTEM_CALLS ];
xMPU_SETTINGS * pxMpuSettings;
uint32_t * pulSystemCallStack;
uint32_t ulStackFrameSize, ulSystemCallLocation, i;
uint32_t ulHardwareSavedExceptionFrameSize, ulSystemCallLocation, i;

#if defined( __ARMCC_VERSION )

Expand Down Expand Up @@ -1236,12 +1236,16 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO
{
pulSystemCallStack = pxMpuSettings->xSystemCallStackInfo.pulSystemCallStack;

/* Hardware Saved Stack Frame Size upon Exception entry:
* - No FPU: basic frame (R0-R3, R12, LR, PC, and xPSR) = 8 words.
* - With FPU (lazy stacking): basic frame + S0–S15 + FPSCR + reserved word = 26 words.
*/
#if ( ( configENABLE_FPU == 1 ) || ( configENABLE_MVE == 1 ) )
{
if( ( ulLR & portEXC_RETURN_STACK_FRAME_TYPE_MASK ) == 0UL )
{
/* Extended frame i.e. FPU in use. */
ulStackFrameSize = 26;
ulHardwareSavedExceptionFrameSize = 26;
__asm volatile (
" vpush {s0} \n" /* Trigger lazy stacking. */
" vpop {s0} \n" /* Nullify the affect of the above instruction. */
Expand All @@ -1251,20 +1255,20 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO
else
{
/* Standard frame i.e. FPU not in use. */
ulStackFrameSize = 8;
ulHardwareSavedExceptionFrameSize = 8;
}
}
#else /* if ( ( configENABLE_FPU == 1 ) || ( configENABLE_MVE == 1 ) ) */
{
ulStackFrameSize = 8;
ulHardwareSavedExceptionFrameSize = 8;
}
#endif /* configENABLE_FPU || configENABLE_MVE */

/* Make space on the system call stack for the stack frame. */
pulSystemCallStack = pulSystemCallStack - ulStackFrameSize;
pulSystemCallStack = pulSystemCallStack - ulHardwareSavedExceptionFrameSize;

/* Copy the stack frame. */
for( i = 0; i < ulStackFrameSize; i++ )
for( i = 0; i < ulHardwareSavedExceptionFrameSize; i++ )
{
pulSystemCallStack[ i ] = pulTaskStack[ i ];
}
Expand Down Expand Up @@ -1300,7 +1304,7 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO

/* Remember the location where we should copy the stack frame when we exit from
* the system call. */
pxMpuSettings->xSystemCallStackInfo.pulTaskStack = pulTaskStack + ulStackFrameSize;
pxMpuSettings->xSystemCallStackInfo.pulTaskStack = pulTaskStack + ulHardwareSavedExceptionFrameSize;

/* Record if the hardware used padding to force the stack pointer
* to be double word aligned. */
Expand Down Expand Up @@ -1350,7 +1354,7 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO
extern TaskHandle_t pxCurrentTCB;
xMPU_SETTINGS * pxMpuSettings;
uint32_t * pulTaskStack;
uint32_t ulStackFrameSize, ulSystemCallLocation, i;
uint32_t ulHardwareSavedExceptionFrameSize, ulSystemCallLocation, i;

#if defined( __ARMCC_VERSION )

Expand Down Expand Up @@ -1382,12 +1386,16 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO
{
pulTaskStack = pxMpuSettings->xSystemCallStackInfo.pulTaskStack;

/* Hardware Saved Stack Frame Size upon Exception entry:
* - No FPU: basic frame (R0-R3, R12, LR, PC, and xPSR) = 8 words.
* - With FPU (lazy stacking): basic frame + S0–S15 + FPSCR + reserved word = 26 words.
*/
#if ( ( configENABLE_FPU == 1 ) || ( configENABLE_MVE == 1 ) )
{
if( ( ulLR & portEXC_RETURN_STACK_FRAME_TYPE_MASK ) == 0UL )
{
/* Extended frame i.e. FPU in use. */
ulStackFrameSize = 26;
ulHardwareSavedExceptionFrameSize = 26;
__asm volatile (
" vpush {s0} \n" /* Trigger lazy stacking. */
" vpop {s0} \n" /* Nullify the affect of the above instruction. */
Expand All @@ -1397,20 +1405,20 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO
else
{
/* Standard frame i.e. FPU not in use. */
ulStackFrameSize = 8;
ulHardwareSavedExceptionFrameSize = 8;
}
}
#else /* if ( ( configENABLE_FPU == 1 ) || ( configENABLE_MVE == 1 ) ) */
{
ulStackFrameSize = 8;
ulHardwareSavedExceptionFrameSize = 8;
}
#endif /* configENABLE_FPU || configENABLE_MVE */

/* Make space on the task stack for the stack frame. */
pulTaskStack = pulTaskStack - ulStackFrameSize;
pulTaskStack = pulTaskStack - ulHardwareSavedExceptionFrameSize;

/* Copy the stack frame. */
for( i = 0; i < ulStackFrameSize; i++ )
for( i = 0; i < ulHardwareSavedExceptionFrameSize; i++ )
{
pulTaskStack[ i ] = pulSystemCallStack[ i ];
}
Expand Down
Loading