Skip to content

Commit b5fb2cb

Browse files
committed
Armv8-M: Copy SMP changes to all Armv8-M based ports
This commit executes the `copy_files.py` python script to copy the changes applied in the previous commit (i.e., SMP changes) to all the Armv8-M based ports. Signed-off-by: Ahmed Ismail <Ahmed.Ismail@arm.com>
1 parent 41e1d62 commit b5fb2cb

96 files changed

Lines changed: 14024 additions & 3754 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

portable/GCC/ARM_CM23/non_secure/port.c

Lines changed: 399 additions & 128 deletions
Large diffs are not rendered by default.

portable/GCC/ARM_CM23/non_secure/portmacro.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*
22
* FreeRTOS Kernel <DEVELOPMENT BRANCH>
33
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4+
* Copyright 2026 Arm Limited and/or its affiliates <open-source-office@arm.com>
45
*
56
* SPDX-License-Identifier: MIT
67
*
@@ -52,6 +53,7 @@
5253
#define portHAS_ARMV8M_MAIN_EXTENSION 0
5354
#define portARMV8M_MINOR_VERSION 0
5455
#define portDONT_DISCARD __attribute__( ( used ) )
56+
#define portVALIDATED_FOR_SMP 0
5557
/*-----------------------------------------------------------*/
5658

5759
/* ARMv8-M common port configurations. */

portable/GCC/ARM_CM23/non_secure/portmacrocommon.h

Lines changed: 78 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
/*
22
* FreeRTOS Kernel <DEVELOPMENT BRANCH>
33
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4-
* Copyright 2024 Arm Limited and/or its affiliates
5-
* <open-source-office@arm.com>
4+
* Copyright 2024, 2026 Arm Limited and/or its affiliates <open-source-office@arm.com>
65
*
76
* SPDX-License-Identifier: MIT
87
*
@@ -31,6 +30,8 @@
3130
#ifndef PORTMACROCOMMON_H
3231
#define PORTMACROCOMMON_H
3332

33+
#include "mpu_wrappers.h"
34+
3435
/* *INDENT-OFF* */
3536
#ifdef __cplusplus
3637
extern "C" {
@@ -59,6 +60,19 @@
5960
#error configENABLE_TRUSTZONE must be defined in FreeRTOSConfig.h. Set configENABLE_TRUSTZONE to 1 to enable TrustZone or 0 to disable TrustZone.
6061
#endif /* configENABLE_TRUSTZONE */
6162

63+
#if ( configNUMBER_OF_CORES > 1 )
64+
#if ( portVALIDATED_FOR_SMP != 1 ) || ( configENABLE_MPU == 1 ) || ( configENABLE_TRUSTZONE == 1 )
65+
#error "Multi-core SMP is currently only validated for Cortex-M33 non-TrustZone non-MPU port."
66+
#endif /* if ( portVALIDATED_FOR_SMP != 1 ) || ( configENABLE_MPU == 1 ) || ( configENABLE_TRUSTZONE == 1 ) ) */
67+
68+
#ifndef configCORE_ID_REGISTER
69+
#error "configCORE_ID_REGISTER must be defined to the address of the register used to identify the core executing the code."
70+
#endif /* ifndef configCORE_ID_REGISTER */
71+
72+
#ifndef configWAKE_SECONDARY_CORES
73+
#error "configWAKE_SECONDARY_CORES must be defined to a function that wakes the secondary cores."
74+
#endif /* ifndef configWAKE_SECONDARY_CORES */
75+
#endif /* #if ( configNUMBER_OF_CORES > 1 ) */
6276
/*-----------------------------------------------------------*/
6377

6478
/**
@@ -139,6 +153,11 @@ extern void vClearInterruptMask( uint32_t ulMask ) /* __attribute__(( naked )) P
139153
void vApplicationGenerateTaskRandomPacKey( uint32_t * pulTaskPacKey );
140154

141155
#endif /* configENABLE_PAC */
156+
157+
/**
158+
* @brief Configures interrupt priorities.
159+
*/
160+
void vPortConfigureInterruptPriorities( void ) PRIVILEGED_FUNCTION;
142161
/*-----------------------------------------------------------*/
143162

144163
/**
@@ -428,10 +447,26 @@ extern void vClearInterruptMask( uint32_t ulMask ) /* __attribute__(( naked )) P
428447
/**
429448
* @brief Critical section management.
430449
*/
450+
451+
#define portSET_INTERRUPT_MASK() ulSetInterruptMask()
452+
#define portCLEAR_INTERRUPT_MASK( x ) vClearInterruptMask( x )
431453
#define portSET_INTERRUPT_MASK_FROM_ISR() ulSetInterruptMask()
432454
#define portCLEAR_INTERRUPT_MASK_FROM_ISR( x ) vClearInterruptMask( x )
433-
#define portENTER_CRITICAL() vPortEnterCritical()
434-
#define portEXIT_CRITICAL() vPortExitCritical()
455+
456+
#if ( configNUMBER_OF_CORES == 1 )
457+
#define portENTER_CRITICAL() vPortEnterCritical()
458+
#define portEXIT_CRITICAL() vPortExitCritical()
459+
#else /* ( configNUMBER_OF_CORES == 1 ) */
460+
extern void vTaskEnterCritical( void );
461+
extern void vTaskExitCritical( void );
462+
extern UBaseType_t vTaskEnterCriticalFromISR( void );
463+
extern void vTaskExitCriticalFromISR( UBaseType_t uxSavedInterruptStatus );
464+
465+
#define portENTER_CRITICAL() vTaskEnterCritical()
466+
#define portEXIT_CRITICAL() vTaskExitCritical()
467+
#define portENTER_CRITICAL_FROM_ISR() vTaskEnterCriticalFromISR()
468+
#define portEXIT_CRITICAL_FROM_ISR( x ) vTaskExitCriticalFromISR( x )
469+
#endif /* if ( configNUMBER_OF_CORES != 1 ) */
435470
/*-----------------------------------------------------------*/
436471

437472
/**
@@ -526,7 +561,7 @@ extern void vClearInterruptMask( uint32_t ulMask ) /* __attribute__(( naked )) P
526561
/* Select correct value of configUSE_PORT_OPTIMISED_TASK_SELECTION
527562
* based on whether or not Mainline extension is implemented. */
528563
#ifndef configUSE_PORT_OPTIMISED_TASK_SELECTION
529-
#if ( portHAS_ARMV8M_MAIN_EXTENSION == 1 )
564+
#if ( ( portHAS_ARMV8M_MAIN_EXTENSION == 1 ) && ( configNUMBER_OF_CORES == 1 ) )
530565
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
531566
#else
532567
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0
@@ -573,6 +608,44 @@ extern void vClearInterruptMask( uint32_t ulMask ) /* __attribute__(( naked )) P
573608
#endif /* configUSE_PORT_OPTIMISED_TASK_SELECTION */
574609
/*-----------------------------------------------------------*/
575610

611+
612+
#if ( configNUMBER_OF_CORES > 1 )
613+
typedef enum
614+
{
615+
eIsrLock = 0,
616+
eTaskLock,
617+
eLockCount
618+
} ePortRTOSLock;
619+
620+
extern volatile uint32_t ulCriticalNestings[ configNUMBER_OF_CORES ];
621+
extern void vPortRecursiveLock( uint8_t ucCoreID,
622+
ePortRTOSLock eLockNum,
623+
BaseType_t uxAcquire );
624+
extern uint8_t ucPortGetCoreID( void );
625+
extern void vInterruptCore( uint8_t ucCoreID );
626+
627+
#define portGET_CORE_ID() ucPortGetCoreID()
628+
629+
#define portGET_CRITICAL_NESTING_COUNT( xCoreID ) ( ulCriticalNestings[ ( uint8_t ) xCoreID ] )
630+
#define portSET_CRITICAL_NESTING_COUNT( xCoreID, x ) ( ulCriticalNestings[ ( uint8_t ) xCoreID ] = ( x ) )
631+
#define portINCREMENT_CRITICAL_NESTING_COUNT( xCoreID ) ( ulCriticalNestings[ ( uint8_t ) xCoreID ]++ )
632+
#define portDECREMENT_CRITICAL_NESTING_COUNT( xCoreID ) ( ulCriticalNestings[ ( uint8_t ) xCoreID ]-- )
633+
634+
#define portMAX_CORE_COUNT ( configNUMBER_OF_CORES )
635+
636+
#define portYIELD_CORE( xCoreID ) vInterruptCore( xCoreID )
637+
638+
#define portRELEASE_ISR_LOCK( xCoreID ) vPortRecursiveLock( ( uint8_t ) xCoreID, eIsrLock, pdFALSE )
639+
#define portGET_ISR_LOCK( xCoreID ) vPortRecursiveLock( ( uint8_t ) xCoreID, eIsrLock, pdTRUE )
640+
641+
#define portRELEASE_TASK_LOCK( xCoreID ) vPortRecursiveLock( ( uint8_t ) xCoreID, eTaskLock, pdFALSE )
642+
#define portGET_TASK_LOCK( xCoreID ) vPortRecursiveLock( ( uint8_t ) xCoreID, eTaskLock, pdTRUE )
643+
644+
#if ( ( configENABLE_PAC == 1 ) || ( configENABLE_BTI == 1 ) )
645+
uint32_t vConfigurePACBTI( BaseType_t xWriteControlRegister );
646+
#endif /* ( configENABLE_PAC == 1 || configENABLE_BTI == 1 ) */
647+
#endif
648+
576649
/* *INDENT-OFF* */
577650
#ifdef __cplusplus
578651
}

0 commit comments

Comments
 (0)