|
1 | 1 | /* |
2 | 2 | * FreeRTOS Kernel <DEVELOPMENT BRANCH> |
3 | 3 | * 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> |
6 | 5 | * |
7 | 6 | * SPDX-License-Identifier: MIT |
8 | 7 | * |
|
31 | 30 | #ifndef PORTMACROCOMMON_H |
32 | 31 | #define PORTMACROCOMMON_H |
33 | 32 |
|
| 33 | +#include "mpu_wrappers.h" |
| 34 | + |
34 | 35 | /* *INDENT-OFF* */ |
35 | 36 | #ifdef __cplusplus |
36 | 37 | extern "C" { |
|
59 | 60 | #error configENABLE_TRUSTZONE must be defined in FreeRTOSConfig.h. Set configENABLE_TRUSTZONE to 1 to enable TrustZone or 0 to disable TrustZone. |
60 | 61 | #endif /* configENABLE_TRUSTZONE */ |
61 | 62 |
|
| 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 ) */ |
62 | 76 | /*-----------------------------------------------------------*/ |
63 | 77 |
|
64 | 78 | /** |
@@ -139,6 +153,11 @@ extern void vClearInterruptMask( uint32_t ulMask ) /* __attribute__(( naked )) P |
139 | 153 | void vApplicationGenerateTaskRandomPacKey( uint32_t * pulTaskPacKey ); |
140 | 154 |
|
141 | 155 | #endif /* configENABLE_PAC */ |
| 156 | + |
| 157 | +/** |
| 158 | + * @brief Configures interrupt priorities. |
| 159 | + */ |
| 160 | +void vPortConfigureInterruptPriorities( void ) PRIVILEGED_FUNCTION; |
142 | 161 | /*-----------------------------------------------------------*/ |
143 | 162 |
|
144 | 163 | /** |
@@ -428,10 +447,26 @@ extern void vClearInterruptMask( uint32_t ulMask ) /* __attribute__(( naked )) P |
428 | 447 | /** |
429 | 448 | * @brief Critical section management. |
430 | 449 | */ |
| 450 | + |
| 451 | +#define portSET_INTERRUPT_MASK() ulSetInterruptMask() |
| 452 | +#define portCLEAR_INTERRUPT_MASK( x ) vClearInterruptMask( x ) |
431 | 453 | #define portSET_INTERRUPT_MASK_FROM_ISR() ulSetInterruptMask() |
432 | 454 | #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 ) */ |
435 | 470 | /*-----------------------------------------------------------*/ |
436 | 471 |
|
437 | 472 | /** |
@@ -526,7 +561,7 @@ extern void vClearInterruptMask( uint32_t ulMask ) /* __attribute__(( naked )) P |
526 | 561 | /* Select correct value of configUSE_PORT_OPTIMISED_TASK_SELECTION |
527 | 562 | * based on whether or not Mainline extension is implemented. */ |
528 | 563 | #ifndef configUSE_PORT_OPTIMISED_TASK_SELECTION |
529 | | - #if ( portHAS_ARMV8M_MAIN_EXTENSION == 1 ) |
| 564 | + #if ( ( portHAS_ARMV8M_MAIN_EXTENSION == 1 ) && ( configNUMBER_OF_CORES == 1 ) ) |
530 | 565 | #define configUSE_PORT_OPTIMISED_TASK_SELECTION 1 |
531 | 566 | #else |
532 | 567 | #define configUSE_PORT_OPTIMISED_TASK_SELECTION 0 |
@@ -573,6 +608,44 @@ extern void vClearInterruptMask( uint32_t ulMask ) /* __attribute__(( naked )) P |
573 | 608 | #endif /* configUSE_PORT_OPTIMISED_TASK_SELECTION */ |
574 | 609 | /*-----------------------------------------------------------*/ |
575 | 610 |
|
| 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 | + |
576 | 649 | /* *INDENT-OFF* */ |
577 | 650 | #ifdef __cplusplus |
578 | 651 | } |
|
0 commit comments