Merge branch 'main' into ARM_CRx_MPU

This commit is contained in:
Soren Ptak 2024-01-22 12:10:44 -05:00 committed by GitHub
commit 9919eee837
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 131 additions and 35 deletions

View file

@ -88,11 +88,13 @@ add_library(freertos_kernel_port STATIC
GCC/ARM_CM3/port.c>
$<$<STREQUAL:${FREERTOS_PORT},GCC_ARM_CM3_MPU>:
GCC/ARM_CM3_MPU/port.c>
GCC/ARM_CM3_MPU/port.c
GCC/ARM_CM3_MPU/mpu_wrappers_v2_asm.c>
# ARMv7E-M ports for GCC
$<$<STREQUAL:${FREERTOS_PORT},GCC_ARM_CM4_MPU>:
GCC/ARM_CM4_MPU/port.c>
GCC/ARM_CM4_MPU/port.c
GCC/ARM_CM4_MPU/mpu_wrappers_v2_asm.c>
$<$<STREQUAL:${FREERTOS_PORT},GCC_ARM_CM4F>:
GCC/ARM_CM4F/port.c>
@ -103,7 +105,8 @@ add_library(freertos_kernel_port STATIC
# ARMv8-M ports for GCC
$<$<STREQUAL:${FREERTOS_PORT},GCC_ARM_CM23_NONSECURE>:
GCC/ARM_CM23/non_secure/port.c
GCC/ARM_CM23/non_secure/portasm.c>
GCC/ARM_CM23/non_secure/portasm.c
GCC/ARM_CM23/non_secure/mpu_wrappers_v2_asm.c>
$<$<STREQUAL:${FREERTOS_PORT},GCC_ARM_CM23_SECURE>:
GCC/ARM_CM23/secure/secure_context_port.c
@ -113,11 +116,13 @@ add_library(freertos_kernel_port STATIC
$<$<STREQUAL:${FREERTOS_PORT},GCC_ARM_CM23_NTZ_NONSECURE>:
GCC/ARM_CM23_NTZ/non_secure/port.c
GCC/ARM_CM23_NTZ/non_secure/portasm.c>
GCC/ARM_CM23_NTZ/non_secure/portasm.c
GCC/ARM_CM23_NTZ/non_secure/mpu_wrappers_v2_asm.c>
$<$<STREQUAL:${FREERTOS_PORT},GCC_ARM_CM33_NONSECURE>:
GCC/ARM_CM33/non_secure/port.c
GCC/ARM_CM33/non_secure/portasm.c>
GCC/ARM_CM33/non_secure/portasm.c
GCC/ARM_CM33/non_secure/mpu_wrappers_v2_asm.c>
$<$<STREQUAL:${FREERTOS_PORT},GCC_ARM_CM33_SECURE>:
GCC/ARM_CM33/secure/secure_context_port.c
@ -127,16 +132,19 @@ add_library(freertos_kernel_port STATIC
$<$<STREQUAL:${FREERTOS_PORT},GCC_ARM_CM33_NTZ_NONSECURE>:
GCC/ARM_CM33_NTZ/non_secure/port.c
GCC/ARM_CM33_NTZ/non_secure/portasm.c>
GCC/ARM_CM33_NTZ/non_secure/portasm.c
GCC/ARM_CM33_NTZ/non_secure/mpu_wrappers_v2_asm.c>
$<$<STREQUAL:${FREERTOS_PORT},GCC_ARM_CM33_TFM>:
GCC/ARM_CM33_NTZ/non_secure/port.c
GCC/ARM_CM33_NTZ/non_secure/portasm.c
GCC/ARM_CM33_NTZ/non_secure/mpu_wrappers_v2_asm.c
ThirdParty/GCC/ARM_TFM/os_wrapper_freertos.c>
$<$<STREQUAL:${FREERTOS_PORT},GCC_ARM_CM35P_NONSECURE>:
GCC/ARM_CM35P/non_secure/port.c
GCC/ARM_CM35P/non_secure/portasm.c>
GCC/ARM_CM35P/non_secure/portasm.c
GCC/ARM_CM35P/non_secure/mpu_wrappers_v2_asm.c>
$<$<STREQUAL:${FREERTOS_PORT},GCC_ARM_CM35P_SECURE>:
GCC/ARM_CM35P/secure/secure_context_port.c
@ -146,12 +154,14 @@ add_library(freertos_kernel_port STATIC
$<$<STREQUAL:${FREERTOS_PORT},GCC_ARM_CM35P_NTZ_NONSECURE>:
GCC/ARM_CM35P_NTZ/non_secure/port.c
GCC/ARM_CM35P_NTZ/non_secure/portasm.c>
GCC/ARM_CM35P_NTZ/non_secure/portasm.c
GCC/ARM_CM35P_NTZ/non_secure/mpu_wrappers_v2_asm.c>
# ARMv8.1-M ports for GCC
$<$<STREQUAL:${FREERTOS_PORT},GCC_ARM_CM55_NONSECURE>:
GCC/ARM_CM55/non_secure/port.c
GCC/ARM_CM55/non_secure/portasm.c>
GCC/ARM_CM55/non_secure/portasm.c
GCC/ARM_CM55/non_secure/mpu_wrappers_v2_asm.c>
$<$<STREQUAL:${FREERTOS_PORT},GCC_ARM_CM55_SECURE>:
GCC/ARM_CM55/secure/secure_context_port.c
@ -161,16 +171,19 @@ add_library(freertos_kernel_port STATIC
$<$<STREQUAL:${FREERTOS_PORT},GCC_ARM_CM55_NTZ_NONSECURE>:
GCC/ARM_CM55_NTZ/non_secure/port.c
GCC/ARM_CM55_NTZ/non_secure/portasm.c>
GCC/ARM_CM55_NTZ/non_secure/portasm.c
GCC/ARM_CM55_NTZ/non_secure/mpu_wrappers_v2_asm.c>
$<$<STREQUAL:${FREERTOS_PORT},GCC_ARM_CM55_TFM>:
GCC/ARM_CM55_NTZ/non_secure/port.c
GCC/ARM_CM55_NTZ/non_secure/portasm.c
GCC/ARM_CM55_NTZ/non_secure/mpu_wrappers_v2_asm.c
ThirdParty/GCC/ARM_TFM/os_wrapper_freertos.c>
$<$<STREQUAL:${FREERTOS_PORT},GCC_ARM_CM85_NONSECURE>:
GCC/ARM_CM85/non_secure/port.c
GCC/ARM_CM85/non_secure/portasm.c>
GCC/ARM_CM85/non_secure/portasm.c
GCC/ARM_CM85/non_secure/mpu_wrappers_v2_asm.c>
$<$<STREQUAL:${FREERTOS_PORT},GCC_ARM_CM85_SECURE>:
GCC/ARM_CM85/secure/secure_context_port.c
@ -180,11 +193,13 @@ add_library(freertos_kernel_port STATIC
$<$<STREQUAL:${FREERTOS_PORT},GCC_ARM_CM85_NTZ_NONSECURE>:
GCC/ARM_CM85_NTZ/non_secure/port.c
GCC/ARM_CM85_NTZ/non_secure/portasm.c>
GCC/ARM_CM85_NTZ/non_secure/portasm.c
GCC/ARM_CM85_NTZ/non_secure/mpu_wrappers_v2_asm.c>
$<$<STREQUAL:${FREERTOS_PORT},GCC_ARM_CM85_TFM>:
GCC/ARM_CM85_NTZ/non_secure/port.c
GCC/ARM_CM85_NTZ/non_secure/portasm.c
GCC/ARM_CM85_NTZ/non_secure/mpu_wrappers_v2_asm.c
ThirdParty/GCC/ARM_TFM/os_wrapper_freertos.c>
# ARMv7-R ports for GCC
@ -396,7 +411,8 @@ add_library(freertos_kernel_port STATIC
$<$<STREQUAL:${FREERTOS_PORT},IAR_ARM_CM4F_MPU>:
IAR/ARM_CM4F_MPU/port.c
IAR/ARM_CM4F_MPU/portasm.s>
IAR/ARM_CM4F_MPU/portasm.s
IAR/ARM_CM4F_MPU/mpu_wrappers_v2_asm.S>
$<$<STREQUAL:${FREERTOS_PORT},IAR_ARM_CM7>:
IAR/ARM_CM7/r0p1/port.c
@ -405,7 +421,8 @@ add_library(freertos_kernel_port STATIC
# ARMv8-M Ports for IAR EWARM
$<$<STREQUAL:${FREERTOS_PORT},IAR_ARM_CM23_NONSECURE>:
IAR/ARM_CM23/non_secure/port.c
IAR/ARM_CM23/non_secure/portasm.s>
IAR/ARM_CM23/non_secure/portasm.s
IAR/ARM_CM23/non_secure/mpu_wrappers_v2_asm.S>
$<$<STREQUAL:${FREERTOS_PORT},IAR_ARM_CM23_SECURE>:
IAR/ARM_CM23/secure/secure_context_port_asm.s
@ -415,11 +432,13 @@ add_library(freertos_kernel_port STATIC
$<$<STREQUAL:${FREERTOS_PORT},IAR_ARM_CM23_NTZ_NONSECURE>:
IAR/ARM_CM23_NTZ/non_secure/port.c
IAR/ARM_CM23_NTZ/non_secure/portasm.s>
IAR/ARM_CM23_NTZ/non_secure/portasm.s
IAR/ARM_CM23_NTZ/non_secure/mpu_wrappers_v2_asm.S>
$<$<STREQUAL:${FREERTOS_PORT},IAR_ARM_CM33_NONSECURE>:
IAR/ARM_CM33/non_secure/port.c
IAR/ARM_CM33/non_secure/portasm.s>
IAR/ARM_CM33/non_secure/portasm.s
IAR/ARM_CM33/non_secure/mpu_wrappers_v2_asm.S>
$<$<STREQUAL:${FREERTOS_PORT},IAR_ARM_CM33_SECURE>:
IAR/ARM_CM33/secure/secure_context_port_asm.s
@ -429,11 +448,13 @@ add_library(freertos_kernel_port STATIC
$<$<STREQUAL:${FREERTOS_PORT},IAR_ARM_CM33_NTZ_NONSECURE>:
IAR/ARM_CM33_NTZ/non_secure/port.c
IAR/ARM_CM33_NTZ/non_secure/portasm.s>
IAR/ARM_CM33_NTZ/non_secure/portasm.s
IAR/ARM_CM33_NTZ/non_secure/mpu_wrappers_v2_asm.S>
$<$<STREQUAL:${FREERTOS_PORT},IAR_ARM_CM35P_NONSECURE>:
IAR/ARM_CM35P/non_secure/port.c
IAR/ARM_CM35P/non_secure/portasm.s>
IAR/ARM_CM35P/non_secure/portasm.s
IAR/ARM_CM35P/non_secure/mpu_wrappers_v2_asm.S>
$<$<STREQUAL:${FREERTOS_PORT},IAR_ARM_CM35P_SECURE>:
IAR/ARM_CM35P/secure/secure_context_port_asm.s
@ -443,12 +464,14 @@ add_library(freertos_kernel_port STATIC
$<$<STREQUAL:${FREERTOS_PORT},IAR_ARM_CM35P_NTZ_NONSECURE>:
IAR/ARM_CM35P_NTZ/non_secure/port.c
IAR/ARM_CM35P_NTZ/non_secure/portasm.s>
IAR/ARM_CM35P_NTZ/non_secure/portasm.s
IAR/ARM_CM35P_NTZ/non_secure/mpu_wrappers_v2_asm.S>
# ARMv8.1-M ports for IAR EWARM
$<$<STREQUAL:${FREERTOS_PORT},IAR_ARM_CM55_NONSECURE>:
IAR/ARM_CM55/non_secure/port.c
IAR/ARM_CM55/non_secure/portasm.s>
IAR/ARM_CM55/non_secure/portasm.s
IAR/ARM_CM55/non_secure/mpu_wrappers_v2_asm.S>
$<$<STREQUAL:${FREERTOS_PORT},IAR_ARM_CM55_SECURE>:
IAR/ARM_CM55/secure/secure_context_port_asm.s
@ -458,11 +481,13 @@ add_library(freertos_kernel_port STATIC
$<$<STREQUAL:${FREERTOS_PORT},IAR_ARM_CM55_NTZ_NONSECURE>:
IAR/ARM_CM55_NTZ/non_secure/port.c
IAR/ARM_CM55_NTZ/non_secure/portasm.s>
IAR/ARM_CM55_NTZ/non_secure/portasm.s
IAR/ARM_CM55_NTZ/non_secure/mpu_wrappers_v2_asm.S>
$<$<STREQUAL:${FREERTOS_PORT},IAR_ARM_CM85_NONSECURE>:
IAR/ARM_CM85/non_secure/port.c
IAR/ARM_CM85/non_secure/portasm.s>
IAR/ARM_CM85/non_secure/portasm.s
IAR/ARM_CM85/non_secure/mpu_wrappers_v2_asm.S>
$<$<STREQUAL:${FREERTOS_PORT},IAR_ARM_CM85_SECURE>:
IAR/ARM_CM85/secure/secure_context_port_asm.s
@ -472,7 +497,8 @@ add_library(freertos_kernel_port STATIC
$<$<STREQUAL:${FREERTOS_PORT},IAR_ARM_CM85_NTZ_NONSECURE>:
IAR/ARM_CM85_NTZ/non_secure/port.c
IAR/ARM_CM85_NTZ/non_secure/portasm.s>
IAR/ARM_CM85_NTZ/non_secure/portasm.s
IAR/ARM_CM85_NTZ/non_secure/mpu_wrappers_v2_asm.S>
# ARMv7-R Ports for IAR EWARM
$<$<STREQUAL:${FREERTOS_PORT},IAR_ARM_CRX_NOGIC>:
@ -664,7 +690,8 @@ add_library(freertos_kernel_port STATIC
# ARMv7E-M ports for ARM RVDS / armcc
$<$<STREQUAL:${FREERTOS_PORT},RVDS_ARM_CM4_MPU>:
RVDS/ARM_CM4_MPU/port.c>
RVDS/ARM_CM4_MPU/port.c
RVDS/ARM_CM4_MPU/mpu_wrappers_v2_asm.c>
$<$<STREQUAL:${FREERTOS_PORT},RVDS_ARM_CM4F>:
RVDS/ARM_CM4F/port.c>
@ -728,7 +755,10 @@ if( FREERTOS_PORT MATCHES "GCC_ARM_CM(3|4)_MPU" OR
FREERTOS_PORT MATCHES "IAR_ARM_CM(23|33|55|85)_NTZ_NONSECURE" OR
FREERTOS_PORT MATCHES "IAR_ARM_CM(23|33|55|85)_NONSECURE"
)
target_sources(freertos_kernel_port PRIVATE Common/mpu_wrappers.c)
target_sources(freertos_kernel_port PRIVATE
Common/mpu_wrappers.c
Common/mpu_wrappers_v2.c
)
endif()
target_include_directories(freertos_kernel_port PUBLIC

View file

@ -1095,12 +1095,28 @@ __attribute__( ( weak ) ) void vPortSetupTimerInterrupt( void )
static void prvSetupMPU( void )
{
extern uint32_t __privileged_functions_start__[];
extern uint32_t __privileged_functions_end__[];
extern uint32_t __FLASH_segment_start__[];
extern uint32_t __FLASH_segment_end__[];
extern uint32_t __privileged_data_start__[];
extern uint32_t __privileged_data_end__[];
#if defined( __ARMCC_VERSION )
/* Declaration when these variable are defined in code instead of being
* exported from linker scripts. */
extern uint32_t * __privileged_functions_start__;
extern uint32_t * __privileged_functions_end__;
extern uint32_t * __FLASH_segment_start__;
extern uint32_t * __FLASH_segment_end__;
extern uint32_t * __privileged_data_start__;
extern uint32_t * __privileged_data_end__;
#else
/* Declaration when these variable are exported from linker scripts. */
extern uint32_t __privileged_functions_start__[];
extern uint32_t __privileged_functions_end__[];
extern uint32_t __FLASH_segment_start__[];
extern uint32_t __FLASH_segment_end__[];
extern uint32_t __privileged_data_start__[];
extern uint32_t __privileged_data_end__[];
#endif /* if defined( __ARMCC_VERSION ) */
/* Ensure that the device has the expected MPU type */
configASSERT( portMPU_TYPE_REG == portEXPECTED_MPU_TYPE_VALUE );
/* Check the expected MPU is present. */
if( portMPU_TYPE_REG == portEXPECTED_MPU_TYPE_VALUE )
@ -1229,10 +1245,22 @@ void vPortStoreTaskMPUSettings( xMPU_SETTINGS * xMPUSettings,
StackType_t * pxBottomOfStack,
uint32_t ulStackDepth )
{
extern uint32_t __SRAM_segment_start__[];
extern uint32_t __SRAM_segment_end__[];
extern uint32_t __privileged_data_start__[];
extern uint32_t __privileged_data_end__[];
#if defined( __ARMCC_VERSION )
/* Declaration when these variable are defined in code instead of being
* exported from linker scripts. */
extern uint32_t * __SRAM_segment_start__;
extern uint32_t * __SRAM_segment_end__;
extern uint32_t * __privileged_data_start__;
extern uint32_t * __privileged_data_end__;
#else
/* Declaration when these variable are exported from linker scripts. */
extern uint32_t __SRAM_segment_start__[];
extern uint32_t __SRAM_segment_end__[];
extern uint32_t __privileged_data_start__[];
extern uint32_t __privileged_data_end__[];
#endif /* if defined( __ARMCC_VERSION ) */
int32_t lIndex;
uint32_t ul;

View file

@ -86,6 +86,15 @@ typedef unsigned long UBaseType_t;
#define portMPU_REGION_CACHEABLE_BUFFERABLE ( 0x07UL << 16UL )
#define portMPU_REGION_EXECUTE_NEVER ( 0x01UL << 28UL )
/* MPU settings that can be overriden in FreeRTOSConfig.h. */
#ifndef configTOTAL_MPU_REGIONS
/* Define to 8 for backward compatibility. */
#define configTOTAL_MPU_REGIONS ( 8UL )
#elif( configTOTAL_MPU_REGIONS != 8UL )
/* The Cortex M3 only supports 8 MPU regions. For more information refer to:
* https://developer.arm.com/documentation/dui0552/a/cortex-m3-peripherals/optional-memory-protection-unit */
#error configTOTAL_MPU_REGIONS must be 8 for this port.
#endif /* configTOTAL_MPU_REGIONS Check */
#define portSTACK_REGION ( 3UL )
#define portGENERAL_PERIPHERALS_REGION ( 4UL )
#define portUNPRIVILEGED_FLASH_REGION ( 5UL )

View file

@ -51,6 +51,10 @@
*----------------------------------------------------------*/
#include "portmacro.h"
#ifdef __linux__
#define __USE_GNU
#endif
#include <errno.h>
#include <pthread.h>
#include <signal.h>
@ -134,6 +138,16 @@ void prvFatalError( const char * pcCall,
}
/*-----------------------------------------------------------*/
static void prvPortSetCurrentThreadName(char * pxThreadName)
{
#ifdef __APPLE__
pthread_setname_np(pxThreadName);
#else
pthread_setname_np(pthread_self(), pxThreadName);
#endif
}
/*-----------------------------------------------------------*/
/*
* See header file for description.
*/
@ -224,6 +238,7 @@ BaseType_t xPortStartScheduler( void )
const ListItem_t * pxEndMarker;
hMainThread = pthread_self();
prvPortSetCurrentThreadName("Scheduler");
/* Start the timer that generates the tick ISR(SIGALRM).
* Interrupts are disabled here already. */
@ -381,6 +396,10 @@ static uint64_t prvGetTimeNs( void )
static void * prvTimerTickHandler( void * arg )
{
( void ) arg;
prvPortSetCurrentThreadName("Scheduler timer");
while( xTimerTickThreadShouldRun )
{
/*
@ -491,6 +510,9 @@ static void * prvWaitForStart( void * pvParams )
uxCriticalNesting = 0;
vPortEnableInterrupts();
/* Set thread name */
prvPortSetCurrentThreadName(pcTaskGetName(xTaskGetCurrentTaskHandle()));
/* Call the task's entry point. */
pxThread->pxCode( pxThread->pvParams );

View file

@ -41,6 +41,13 @@
#include "timers.h"
#include "stack_macros.h"
/* The default definitions are only available for non-MPU ports. The
* reason is that the stack alignment requirements vary for different
* architectures.*/
#if ( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configKERNEL_PROVIDED_STATIC_MEMORY == 1 ) && ( portUSING_MPU_WRAPPERS != 0 ) )
#error configKERNEL_PROVIDED_STATIC_MEMORY cannot be set to 1 when using an MPU port. The vApplicationGet*TaskMemory() functions must be provided manually.
#endif
/* The MPU ports require MPU_WRAPPERS_INCLUDED_FROM_API_FILE to be defined
* for the header files above, but not in this file, in order to generate the
* correct privileged Vs unprivileged linkage and placement. */