From 5f7d21b0011825058bc996153c22274cb43d5179 Mon Sep 17 00:00:00 2001 From: Jeff Tenney Date: Wed, 11 Oct 2023 13:41:27 -0700 Subject: [PATCH 01/23] Verify installation of PendSV and SVCall handlers --- portable/GCC/ARM_CM4F/port.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/portable/GCC/ARM_CM4F/port.c b/portable/GCC/ARM_CM4F/port.c index 3846a50f6a..859f76b245 100644 --- a/portable/GCC/ARM_CM4F/port.c +++ b/portable/GCC/ARM_CM4F/port.c @@ -62,6 +62,13 @@ #define portNVIC_PENDSV_PRI ( ( ( uint32_t ) portMIN_INTERRUPT_PRIORITY ) << 16UL ) #define portNVIC_SYSTICK_PRI ( ( ( uint32_t ) portMIN_INTERRUPT_PRIORITY ) << 24UL ) +/* Types and constants used to check for proper installation of the FreeRTOS + * interrupt handlers. */ +typedef void (* portISR_t)( void ); +#define portSCB_VTOR_REG ( *( ( portISR_t ** ) 0xE000ED08 ) ) +#define portVECTOR_INDEX_SVC 11 +#define portVECTOR_INDEX_PENDSV 14 + /* Constants required to check the validity of an interrupt priority. */ #define portFIRST_USER_INTERRUPT_NUMBER ( 16 ) #define portNVIC_IP_REGISTERS_OFFSET_16 ( 0xE000E3F0 ) @@ -308,6 +315,7 @@ BaseType_t xPortStartScheduler( void ) volatile uint32_t ulImplementedPrioBits = 0; volatile uint8_t * const pucFirstUserPriorityRegister = ( volatile uint8_t * const ) ( portNVIC_IP_REGISTERS_OFFSET_16 + portFIRST_USER_INTERRUPT_NUMBER ); volatile uint8_t ucMaxPriorityValue; + const portISR_t * vectorTable = portSCB_VTOR_REG; /* Determine the maximum priority from which ISR safe FreeRTOS API * functions can be called. ISR safe functions are those that end in @@ -383,6 +391,21 @@ BaseType_t xPortStartScheduler( void ) /* Restore the clobbered interrupt priority register to its original * value. */ *pucFirstUserPriorityRegister = ucOriginalPriority; + + /* Verify correct installation of the FreeRTOS handlers for SVCall and + * PendSV. Do not check the installation of the SysTick handler because + * the application may provide the system tick without using the SysTick + * timer. + * + * Assertion failures here can be caused by incorrect installation of + * the FreeRTOS handlers. For help installing the handlers, see + * https://www.FreeRTOS.org/FAQHelp.html + * + * Systems with a configurable base address for the vector table can + * also encounter assertion failures here if VTOR is not set correctly + * to point to the application's interrupt vector table. */ + configASSERT( vectorTable[ portVECTOR_INDEX_SVC ] == vPortSVCHandler ); + configASSERT( vectorTable[ portVECTOR_INDEX_PENDSV ] == xPortPendSVHandler ); } #endif /* configASSERT_DEFINED */ From 76814d00c6c646cbc0cc8491c0acbd5168d43e94 Mon Sep 17 00:00:00 2001 From: Jeff Tenney Date: Wed, 11 Oct 2023 13:45:28 -0700 Subject: [PATCH 02/23] Make sure SVCall uses highest exception priority --- portable/GCC/ARM_CM4F/port.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/portable/GCC/ARM_CM4F/port.c b/portable/GCC/ARM_CM4F/port.c index 859f76b245..970c9e333d 100644 --- a/portable/GCC/ARM_CM4F/port.c +++ b/portable/GCC/ARM_CM4F/port.c @@ -42,6 +42,7 @@ #define portNVIC_SYSTICK_CTRL_REG ( *( ( volatile uint32_t * ) 0xe000e010 ) ) #define portNVIC_SYSTICK_LOAD_REG ( *( ( volatile uint32_t * ) 0xe000e014 ) ) #define portNVIC_SYSTICK_CURRENT_VALUE_REG ( *( ( volatile uint32_t * ) 0xe000e018 ) ) +#define portNVIC_SHPR2_REG ( *( ( volatile uint32_t * ) 0xe000e01c ) ) #define portNVIC_SHPR3_REG ( *( ( volatile uint32_t * ) 0xe000ed20 ) ) /* ...then bits in the registers. */ #define portNVIC_SYSTICK_CLK_BIT ( 1UL << 2UL ) @@ -409,9 +410,11 @@ BaseType_t xPortStartScheduler( void ) } #endif /* configASSERT_DEFINED */ - /* Make PendSV and SysTick the lowest priority interrupts. */ + /* Make PendSV and SysTick the lowest priority interrupts, and make SVCall + * the highest priority. */ portNVIC_SHPR3_REG |= portNVIC_PENDSV_PRI; portNVIC_SHPR3_REG |= portNVIC_SYSTICK_PRI; + portNVIC_SHPR2_REG = 0; /* Start the timer that generates the tick ISR. Interrupts are disabled * here already. */ From 6237ca33b1d273c1a278432fdf4f6759c6fabf02 Mon Sep 17 00:00:00 2001 From: Jeff Tenney Date: Thu, 12 Oct 2023 10:08:56 -0700 Subject: [PATCH 03/23] Fix style and update comments --- portable/GCC/ARM_CM4F/port.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/portable/GCC/ARM_CM4F/port.c b/portable/GCC/ARM_CM4F/port.c index 970c9e333d..3e9f069f0d 100644 --- a/portable/GCC/ARM_CM4F/port.c +++ b/portable/GCC/ARM_CM4F/port.c @@ -38,6 +38,9 @@ #error This port can only be used when the project options are configured to enable hardware floating point support. #endif +/* Prototype to which all Interrupt Service Routines conform. */ +typedef void (* portISR_t)( void ); + /* Constants required to manipulate the core. Registers first... */ #define portNVIC_SYSTICK_CTRL_REG ( *( ( volatile uint32_t * ) 0xe000e010 ) ) #define portNVIC_SYSTICK_LOAD_REG ( *( ( volatile uint32_t * ) 0xe000e014 ) ) @@ -63,12 +66,10 @@ #define portNVIC_PENDSV_PRI ( ( ( uint32_t ) portMIN_INTERRUPT_PRIORITY ) << 16UL ) #define portNVIC_SYSTICK_PRI ( ( ( uint32_t ) portMIN_INTERRUPT_PRIORITY ) << 24UL ) -/* Types and constants used to check for proper installation of the FreeRTOS - * interrupt handlers. */ -typedef void (* portISR_t)( void ); +/* Constants used to check the installation of the FreeRTOS interrupt handlers. */ #define portSCB_VTOR_REG ( *( ( portISR_t ** ) 0xE000ED08 ) ) -#define portVECTOR_INDEX_SVC 11 -#define portVECTOR_INDEX_PENDSV 14 +#define portVECTOR_INDEX_SVC ( 11 ) +#define portVECTOR_INDEX_PENDSV ( 14 ) /* Constants required to check the validity of an interrupt priority. */ #define portFIRST_USER_INTERRUPT_NUMBER ( 16 ) @@ -316,7 +317,7 @@ BaseType_t xPortStartScheduler( void ) volatile uint32_t ulImplementedPrioBits = 0; volatile uint8_t * const pucFirstUserPriorityRegister = ( volatile uint8_t * const ) ( portNVIC_IP_REGISTERS_OFFSET_16 + portFIRST_USER_INTERRUPT_NUMBER ); volatile uint8_t ucMaxPriorityValue; - const portISR_t * vectorTable = portSCB_VTOR_REG; + const portISR_t * const vectorTable = portSCB_VTOR_REG; /* Determine the maximum priority from which ISR safe FreeRTOS API * functions can be called. ISR safe functions are those that end in @@ -395,16 +396,16 @@ BaseType_t xPortStartScheduler( void ) /* Verify correct installation of the FreeRTOS handlers for SVCall and * PendSV. Do not check the installation of the SysTick handler because - * the application may provide the system tick without using the SysTick - * timer. + * the application may provide the OS tick without using the SysTick + * timer by overriding the weak function vPortSetupTimerInterrupt(). * * Assertion failures here can be caused by incorrect installation of * the FreeRTOS handlers. For help installing the handlers, see * https://www.FreeRTOS.org/FAQHelp.html - * - * Systems with a configurable base address for the vector table can - * also encounter assertion failures here if VTOR is not set correctly - * to point to the application's interrupt vector table. */ + * + * Systems with a configurable address for the interrupt vector table + * can also encounter assertion failures or even system faults here if + * VTOR is not set correctly to point to the application's vector table. */ configASSERT( vectorTable[ portVECTOR_INDEX_SVC ] == vPortSVCHandler ); configASSERT( vectorTable[ portVECTOR_INDEX_PENDSV ] == xPortPendSVHandler ); } From b957a080aabec189ac2a52daa1bcce79d4ce3019 Mon Sep 17 00:00:00 2001 From: Jeff Tenney Date: Thu, 12 Oct 2023 19:59:49 -0700 Subject: [PATCH 04/23] Make equivalent changes to ARMv8-M Delay replication (copy_files.py) to simplify review for now. --- portable/ARMv8M/non_secure/port.c | 50 +++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 13 deletions(-) diff --git a/portable/ARMv8M/non_secure/port.c b/portable/ARMv8M/non_secure/port.c index 52d68d3eaf..90e3cfd659 100644 --- a/portable/ARMv8M/non_secure/port.c +++ b/portable/ARMv8M/non_secure/port.c @@ -79,6 +79,12 @@ #endif /*-----------------------------------------------------------*/ +/** + * @brief Prototype to which all Interrupt Service Routines conform. + */ +typedef void (* portISR_t)( void ); +/*-----------------------------------------------------------*/ + /** * @brief Constants required to manipulate the NVIC. */ @@ -100,10 +106,18 @@ /** * @brief Constants required to manipulate the SCB. */ +#define portSCB_VTOR_REG ( *( ( portISR_t ** ) 0xe000ed08 ) ) #define portSCB_SYS_HANDLER_CTRL_STATE_REG ( *( volatile uint32_t * ) 0xe000ed24 ) #define portSCB_MEM_FAULT_ENABLE_BIT ( 1UL << 16UL ) /*-----------------------------------------------------------*/ +/** + * @brief Constants used to check the installation of the FreeRTOS interrupt handlers. + */ +#define portVECTOR_INDEX_SVC ( 11 ) +#define portVECTOR_INDEX_PENDSV ( 14 ) +/*-----------------------------------------------------------*/ + /** * @brief Constants required to check the validity of an interrupt priority. */ @@ -1681,20 +1695,17 @@ BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ { #if ( ( configASSERT_DEFINED == 1 ) && ( portHAS_ARMV8M_MAIN_EXTENSION == 1 ) ) { - volatile uint32_t ulOriginalPriority; volatile uint32_t ulImplementedPrioBits = 0; volatile uint8_t ucMaxPriorityValue; + const portISR_t * const vectorTable = portSCB_VTOR_REG; /* Determine the maximum priority from which ISR safe FreeRTOS API - * functions can be called. ISR safe functions are those that end in - * "FromISR". FreeRTOS maintains separate thread and ISR API functions to + * functions can be called. ISR safe functions are those that end in + * "FromISR". FreeRTOS maintains separate thread and ISR API functions to * ensure interrupt entry is as fast and simple as possible. * - * Save the interrupt priority value that is about to be clobbered. */ - ulOriginalPriority = portNVIC_SHPR2_REG; - - /* Determine the number of priority bits available. First write to all - * possible bits. */ + * First, determine the number of priority bits available. Write to all + * possible bits in the priority setting for SVCall. */ portNVIC_SHPR2_REG = 0xFF000000; /* Read the value back to see how many bits stuck. */ @@ -1717,7 +1728,6 @@ BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ /* Calculate the maximum acceptable priority group value for the number * of bits read back. */ - while( ( ucMaxPriorityValue & portTOP_BIT_OF_BYTE ) == portTOP_BIT_OF_BYTE ) { ulImplementedPrioBits++; @@ -1756,15 +1766,29 @@ BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ ulMaxPRIGROUPValue <<= portPRIGROUP_SHIFT; ulMaxPRIGROUPValue &= portPRIORITY_GROUP_MASK; - /* Restore the clobbered interrupt priority register to its original - * value. */ - portNVIC_SHPR2_REG = ulOriginalPriority; + /* Verify correct installation of the FreeRTOS handlers for SVCall and + * PendSV. Do not check the installation of the SysTick handler because + * the application may provide the OS tick without using the SysTick + * timer by overriding the weak function vPortSetupTimerInterrupt(). + * + * Assertion failures here can be caused by incorrect installation of + * the FreeRTOS handlers. For help installing the handlers, see + * https://www.FreeRTOS.org/FAQHelp.html + * + * Systems with a configurable address for the interrupt vector table + * can also encounter assertion failures or even system faults here if + * VTOR is not set correctly to point to the application's vector table. */ + configASSERT( vectorTable[ portVECTOR_INDEX_SVC ] == SVC_Handler ); + configASSERT( vectorTable[ portVECTOR_INDEX_PENDSV ] == PendSV_Handler ); + } #endif /* #if ( ( configASSERT_DEFINED == 1 ) && ( portHAS_ARMV8M_MAIN_EXTENSION == 1 ) ) */ - /* Make PendSV, CallSV and SysTick the same priority as the kernel. */ + /* Make PendSV and SysTick the lowest priority interrupts, and make SVCall + * the highest priority. */ portNVIC_SHPR3_REG |= portNVIC_PENDSV_PRI; portNVIC_SHPR3_REG |= portNVIC_SYSTICK_PRI; + portNVIC_SHPR2_REG = 0; #if ( configENABLE_MPU == 1 ) { From efeba9648a76200c7f557877944eb2f7a24985f2 Mon Sep 17 00:00:00 2001 From: Jeff Tenney Date: Thu, 12 Oct 2023 20:05:44 -0700 Subject: [PATCH 05/23] uncrustify --- portable/ARMv8M/non_secure/port.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/portable/ARMv8M/non_secure/port.c b/portable/ARMv8M/non_secure/port.c index 90e3cfd659..ac2c843ae0 100644 --- a/portable/ARMv8M/non_secure/port.c +++ b/portable/ARMv8M/non_secure/port.c @@ -114,8 +114,8 @@ typedef void (* portISR_t)( void ); /** * @brief Constants used to check the installation of the FreeRTOS interrupt handlers. */ -#define portVECTOR_INDEX_SVC ( 11 ) -#define portVECTOR_INDEX_PENDSV ( 14 ) +#define portVECTOR_INDEX_SVC ( 11 ) +#define portVECTOR_INDEX_PENDSV ( 14 ) /*-----------------------------------------------------------*/ /** @@ -1780,7 +1780,6 @@ BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ * VTOR is not set correctly to point to the application's vector table. */ configASSERT( vectorTable[ portVECTOR_INDEX_SVC ] == SVC_Handler ); configASSERT( vectorTable[ portVECTOR_INDEX_PENDSV ] == PendSV_Handler ); - } #endif /* #if ( ( configASSERT_DEFINED == 1 ) && ( portHAS_ARMV8M_MAIN_EXTENSION == 1 ) ) */ From 8fcb11f12683970264a9f9fa23d26f9b8cccccee Mon Sep 17 00:00:00 2001 From: Jeff Tenney Date: Thu, 12 Oct 2023 20:51:27 -0700 Subject: [PATCH 06/23] match style of parenthesis usage Style issue addressed here was previously existing --- portable/ARMv8M/non_secure/port.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/portable/ARMv8M/non_secure/port.c b/portable/ARMv8M/non_secure/port.c index ac2c843ae0..4afcfef32b 100644 --- a/portable/ARMv8M/non_secure/port.c +++ b/portable/ARMv8M/non_secure/port.c @@ -107,7 +107,7 @@ typedef void (* portISR_t)( void ); * @brief Constants required to manipulate the SCB. */ #define portSCB_VTOR_REG ( *( ( portISR_t ** ) 0xe000ed08 ) ) -#define portSCB_SYS_HANDLER_CTRL_STATE_REG ( *( volatile uint32_t * ) 0xe000ed24 ) +#define portSCB_SYS_HANDLER_CTRL_STATE_REG ( *( ( volatile uint32_t * ) 0xe000ed24 ) ) #define portSCB_MEM_FAULT_ENABLE_BIT ( 1UL << 16UL ) /*-----------------------------------------------------------*/ From f8565bc4d46cacc5bd57ecc72b3d10b298b07109 Mon Sep 17 00:00:00 2001 From: Jeff Tenney Date: Fri, 13 Oct 2023 14:27:44 -0700 Subject: [PATCH 07/23] change vectorTable to pxVectorTable --- portable/ARMv8M/non_secure/port.c | 6 +++--- portable/GCC/ARM_CM4F/port.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/portable/ARMv8M/non_secure/port.c b/portable/ARMv8M/non_secure/port.c index 4afcfef32b..0aea6033f9 100644 --- a/portable/ARMv8M/non_secure/port.c +++ b/portable/ARMv8M/non_secure/port.c @@ -1697,7 +1697,7 @@ BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ { volatile uint32_t ulImplementedPrioBits = 0; volatile uint8_t ucMaxPriorityValue; - const portISR_t * const vectorTable = portSCB_VTOR_REG; + const portISR_t * const pxVectorTable = portSCB_VTOR_REG; /* Determine the maximum priority from which ISR safe FreeRTOS API * functions can be called. ISR safe functions are those that end in @@ -1778,8 +1778,8 @@ BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ * Systems with a configurable address for the interrupt vector table * can also encounter assertion failures or even system faults here if * VTOR is not set correctly to point to the application's vector table. */ - configASSERT( vectorTable[ portVECTOR_INDEX_SVC ] == SVC_Handler ); - configASSERT( vectorTable[ portVECTOR_INDEX_PENDSV ] == PendSV_Handler ); + configASSERT( pxVectorTable[ portVECTOR_INDEX_SVC ] == SVC_Handler ); + configASSERT( pxVectorTable[ portVECTOR_INDEX_PENDSV ] == PendSV_Handler ); } #endif /* #if ( ( configASSERT_DEFINED == 1 ) && ( portHAS_ARMV8M_MAIN_EXTENSION == 1 ) ) */ diff --git a/portable/GCC/ARM_CM4F/port.c b/portable/GCC/ARM_CM4F/port.c index 3e9f069f0d..6344dd5567 100644 --- a/portable/GCC/ARM_CM4F/port.c +++ b/portable/GCC/ARM_CM4F/port.c @@ -317,7 +317,7 @@ BaseType_t xPortStartScheduler( void ) volatile uint32_t ulImplementedPrioBits = 0; volatile uint8_t * const pucFirstUserPriorityRegister = ( volatile uint8_t * const ) ( portNVIC_IP_REGISTERS_OFFSET_16 + portFIRST_USER_INTERRUPT_NUMBER ); volatile uint8_t ucMaxPriorityValue; - const portISR_t * const vectorTable = portSCB_VTOR_REG; + const portISR_t * const pxVectorTable = portSCB_VTOR_REG; /* Determine the maximum priority from which ISR safe FreeRTOS API * functions can be called. ISR safe functions are those that end in @@ -406,8 +406,8 @@ BaseType_t xPortStartScheduler( void ) * Systems with a configurable address for the interrupt vector table * can also encounter assertion failures or even system faults here if * VTOR is not set correctly to point to the application's vector table. */ - configASSERT( vectorTable[ portVECTOR_INDEX_SVC ] == vPortSVCHandler ); - configASSERT( vectorTable[ portVECTOR_INDEX_PENDSV ] == xPortPendSVHandler ); + configASSERT( pxVectorTable[ portVECTOR_INDEX_SVC ] == vPortSVCHandler ); + configASSERT( pxVectorTable[ portVECTOR_INDEX_PENDSV ] == xPortPendSVHandler ); } #endif /* configASSERT_DEFINED */ From 77b5aa7c52e4988fdde2de16bf6f450e4310f76e Mon Sep 17 00:00:00 2001 From: Jeff Tenney Date: Fri, 13 Oct 2023 14:55:27 -0700 Subject: [PATCH 08/23] Fix typo in address of SHPR2 register --- portable/GCC/ARM_CM4F/port.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/portable/GCC/ARM_CM4F/port.c b/portable/GCC/ARM_CM4F/port.c index 6344dd5567..fe0a96c2d4 100644 --- a/portable/GCC/ARM_CM4F/port.c +++ b/portable/GCC/ARM_CM4F/port.c @@ -45,7 +45,7 @@ typedef void (* portISR_t)( void ); #define portNVIC_SYSTICK_CTRL_REG ( *( ( volatile uint32_t * ) 0xe000e010 ) ) #define portNVIC_SYSTICK_LOAD_REG ( *( ( volatile uint32_t * ) 0xe000e014 ) ) #define portNVIC_SYSTICK_CURRENT_VALUE_REG ( *( ( volatile uint32_t * ) 0xe000e018 ) ) -#define portNVIC_SHPR2_REG ( *( ( volatile uint32_t * ) 0xe000e01c ) ) +#define portNVIC_SHPR2_REG ( *( ( volatile uint32_t * ) 0xe000ed1c ) ) #define portNVIC_SHPR3_REG ( *( ( volatile uint32_t * ) 0xe000ed20 ) ) /* ...then bits in the registers. */ #define portNVIC_SYSTICK_CLK_BIT ( 1UL << 2UL ) From cbe473a0d2c672b3715f500721adc24ba52dfa15 Mon Sep 17 00:00:00 2001 From: Jeff Tenney Date: Fri, 13 Oct 2023 14:55:58 -0700 Subject: [PATCH 09/23] Make equivalent changes to ARMv6-M --- portable/GCC/ARM_CM0/port.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/portable/GCC/ARM_CM0/port.c b/portable/GCC/ARM_CM0/port.c index 93e6d04895..0a16d86f13 100644 --- a/portable/GCC/ARM_CM0/port.c +++ b/portable/GCC/ARM_CM0/port.c @@ -34,11 +34,15 @@ #include "FreeRTOS.h" #include "task.h" +/* Prototype to which all Interrupt Service Routines conform. */ +typedef void (* portISR_t)( void ); + /* Constants required to manipulate the NVIC. */ #define portNVIC_SYSTICK_CTRL_REG ( *( ( volatile uint32_t * ) 0xe000e010 ) ) #define portNVIC_SYSTICK_LOAD_REG ( *( ( volatile uint32_t * ) 0xe000e014 ) ) #define portNVIC_SYSTICK_CURRENT_VALUE_REG ( *( ( volatile uint32_t * ) 0xe000e018 ) ) #define portNVIC_INT_CTRL_REG ( *( ( volatile uint32_t * ) 0xe000ed04 ) ) +#define portNVIC_SHPR2_REG ( *( ( volatile uint32_t * ) 0xe000ed1c ) ) #define portNVIC_SHPR3_REG ( *( ( volatile uint32_t * ) 0xe000ed20 ) ) #define portNVIC_SYSTICK_CLK_BIT ( 1UL << 2UL ) #define portNVIC_SYSTICK_INT_BIT ( 1UL << 1UL ) @@ -51,6 +55,11 @@ #define portNVIC_PENDSV_PRI ( portMIN_INTERRUPT_PRIORITY << 16UL ) #define portNVIC_SYSTICK_PRI ( portMIN_INTERRUPT_PRIORITY << 24UL ) +/* Constants used to check the installation of the FreeRTOS interrupt handlers. */ +#define portSCB_VTOR_REG ( *( ( portISR_t ** ) 0xe000ed08 ) ) +#define portVECTOR_INDEX_SVC ( 11 ) +#define portVECTOR_INDEX_PENDSV ( 14 ) + /* Constants required to set up the initial stack. */ #define portINITIAL_XPSR ( 0x01000000 ) @@ -231,9 +240,32 @@ void vPortStartFirstTask( void ) */ BaseType_t xPortStartScheduler( void ) { - /* Make PendSV, CallSV and SysTick the same priority as the kernel. */ + #if ( configASSERT_DEFINED == 1 ) + { + const portISR_t * const pxVectorTable = portSCB_VTOR_REG; + + /* Verify correct installation of the FreeRTOS handlers for SVCall and + * PendSV. Do not check the installation of the SysTick handler because + * the application may provide the OS tick without using the SysTick + * timer by overriding the weak function vPortSetupTimerInterrupt(). + * + * Assertion failures here can be caused by incorrect installation of + * the FreeRTOS handlers. For help installing the handlers, see + * https://www.FreeRTOS.org/FAQHelp.html + * + * Systems with a configurable address for the interrupt vector table + * can also encounter assertion failures or even system faults here if + * VTOR is not set correctly to point to the application's vector table. */ + configASSERT( pxVectorTable[ portVECTOR_INDEX_SVC ] == vPortSVCHandler ); + configASSERT( pxVectorTable[ portVECTOR_INDEX_PENDSV ] == xPortPendSVHandler ); + } + #endif /* configASSERT_DEFINED */ + + /* Make PendSV and SysTick the lowest priority interrupt, and make SVCall + * the highest priority. */ portNVIC_SHPR3_REG |= portNVIC_PENDSV_PRI; portNVIC_SHPR3_REG |= portNVIC_SYSTICK_PRI; + portNVIC_SHPR2_REG = 0; /* Start the timer that generates the tick ISR. Interrupts are disabled * here already. */ From f8b89faf3cf7786ac80de08555c8217ee1bc013c Mon Sep 17 00:00:00 2001 From: Jeff Tenney Date: Sun, 15 Oct 2023 21:35:00 -0700 Subject: [PATCH 10/23] Revert check of SVC handler installation on CM0 SVC is not used in the CM0 port, and some FreeRTOS demos do not install the SVC vector. --- portable/GCC/ARM_CM0/port.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/portable/GCC/ARM_CM0/port.c b/portable/GCC/ARM_CM0/port.c index 0a16d86f13..2adfdcceff 100644 --- a/portable/GCC/ARM_CM0/port.c +++ b/portable/GCC/ARM_CM0/port.c @@ -42,7 +42,6 @@ typedef void (* portISR_t)( void ); #define portNVIC_SYSTICK_LOAD_REG ( *( ( volatile uint32_t * ) 0xe000e014 ) ) #define portNVIC_SYSTICK_CURRENT_VALUE_REG ( *( ( volatile uint32_t * ) 0xe000e018 ) ) #define portNVIC_INT_CTRL_REG ( *( ( volatile uint32_t * ) 0xe000ed04 ) ) -#define portNVIC_SHPR2_REG ( *( ( volatile uint32_t * ) 0xe000ed1c ) ) #define portNVIC_SHPR3_REG ( *( ( volatile uint32_t * ) 0xe000ed20 ) ) #define portNVIC_SYSTICK_CLK_BIT ( 1UL << 2UL ) #define portNVIC_SYSTICK_INT_BIT ( 1UL << 1UL ) @@ -57,7 +56,6 @@ typedef void (* portISR_t)( void ); /* Constants used to check the installation of the FreeRTOS interrupt handlers. */ #define portSCB_VTOR_REG ( *( ( portISR_t ** ) 0xe000ed08 ) ) -#define portVECTOR_INDEX_SVC ( 11 ) #define portVECTOR_INDEX_PENDSV ( 14 ) /* Constants required to set up the initial stack. */ @@ -209,9 +207,6 @@ void vPortSVCHandler( void ) void vPortStartFirstTask( void ) { - /* The MSP stack is not reset as, unlike on M3/4 parts, there is no vector - * table offset register that can be used to locate the initial stack value. - * Not all M0 parts have the application vector table at address 0. */ __asm volatile ( " .syntax unified \n" " ldr r2, pxCurrentTCBConst2 \n" /* Obtain location of pxCurrentTCB. */ @@ -242,12 +237,15 @@ BaseType_t xPortStartScheduler( void ) { #if ( configASSERT_DEFINED == 1 ) { + /* Point pxVectorTable at the interrupt vector table. Systems without + * a VTOR register provide the value zero in place of the VTOR register + * and provide the vector table itself at address 0x00000000. */ const portISR_t * const pxVectorTable = portSCB_VTOR_REG; - /* Verify correct installation of the FreeRTOS handlers for SVCall and - * PendSV. Do not check the installation of the SysTick handler because - * the application may provide the OS tick without using the SysTick - * timer by overriding the weak function vPortSetupTimerInterrupt(). + /* Verify correct installation of the FreeRTOS handler for PendSV. Do + * not check the installation of the SysTick handler because the + * application may provide the OS tick without using the SysTick timer + * by overriding the weak function vPortSetupTimerInterrupt(). * * Assertion failures here can be caused by incorrect installation of * the FreeRTOS handlers. For help installing the handlers, see @@ -256,16 +254,13 @@ BaseType_t xPortStartScheduler( void ) * Systems with a configurable address for the interrupt vector table * can also encounter assertion failures or even system faults here if * VTOR is not set correctly to point to the application's vector table. */ - configASSERT( pxVectorTable[ portVECTOR_INDEX_SVC ] == vPortSVCHandler ); configASSERT( pxVectorTable[ portVECTOR_INDEX_PENDSV ] == xPortPendSVHandler ); } #endif /* configASSERT_DEFINED */ - /* Make PendSV and SysTick the lowest priority interrupt, and make SVCall - * the highest priority. */ + /* Make PendSV and SysTick the lowest priority interrupt. */ portNVIC_SHPR3_REG |= portNVIC_PENDSV_PRI; portNVIC_SHPR3_REG |= portNVIC_SYSTICK_PRI; - portNVIC_SHPR2_REG = 0; /* Start the timer that generates the tick ISR. Interrupts are disabled * here already. */ From 5c08b83b8d200daf7c61931a25494108ca6de660 Mon Sep 17 00:00:00 2001 From: Jeff Tenney Date: Mon, 16 Oct 2023 13:11:33 -0700 Subject: [PATCH 11/23] Update preexisting comment about not resetting MSP --- portable/GCC/ARM_CM0/port.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/portable/GCC/ARM_CM0/port.c b/portable/GCC/ARM_CM0/port.c index 2adfdcceff..9679c9e3c2 100644 --- a/portable/GCC/ARM_CM0/port.c +++ b/portable/GCC/ARM_CM0/port.c @@ -207,6 +207,9 @@ void vPortSVCHandler( void ) void vPortStartFirstTask( void ) { + /* Don't reset the MSP stack as is done on CM3/4 devices. The vector table + * in some CM0 devices cannot be modified and thus may not hold the + * application's initial MSP value. */ __asm volatile ( " .syntax unified \n" " ldr r2, pxCurrentTCBConst2 \n" /* Obtain location of pxCurrentTCB. */ @@ -237,7 +240,7 @@ BaseType_t xPortStartScheduler( void ) { #if ( configASSERT_DEFINED == 1 ) { - /* Point pxVectorTable at the interrupt vector table. Systems without + /* Point pxVectorTable at the interrupt vector table. Systems without * a VTOR register provide the value zero in place of the VTOR register * and provide the vector table itself at address 0x00000000. */ const portISR_t * const pxVectorTable = portSCB_VTOR_REG; From fde7256c0ade116f5da31210daa61f204a14bb45 Mon Sep 17 00:00:00 2001 From: Jeff Tenney Date: Mon, 16 Oct 2023 13:54:10 -0700 Subject: [PATCH 12/23] Add configCHECK_HANDLER_INSTALLATION --- portable/ARMv8M/non_secure/port.c | 36 +++++++++++--------- portable/ARMv8M/non_secure/portmacrocommon.h | 14 ++++++++ portable/GCC/ARM_CM0/port.c | 4 +-- portable/GCC/ARM_CM0/portmacro.h | 14 ++++++++ portable/GCC/ARM_CM4F/port.c | 36 +++++++++++--------- portable/GCC/ARM_CM4F/portmacro.h | 14 ++++++++ 6 files changed, 84 insertions(+), 34 deletions(-) diff --git a/portable/ARMv8M/non_secure/port.c b/portable/ARMv8M/non_secure/port.c index 0aea6033f9..fe5a232db9 100644 --- a/portable/ARMv8M/non_secure/port.c +++ b/portable/ARMv8M/non_secure/port.c @@ -1693,11 +1693,30 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ { + #if ( configCHECK_HANDLER_INSTALLATION == 1 ) + { + const portISR_t * const pxVectorTable = portSCB_VTOR_REG; + + /* Verify correct installation of the FreeRTOS handlers for SVCall and + * PendSV. Do not check the installation of the SysTick handler because + * the application may provide the OS tick without using the SysTick + * timer by overriding the weak function vPortSetupTimerInterrupt(). + * + * Assertion failures here can be caused by incorrect installation of + * the FreeRTOS handlers. For help installing the handlers, see + * https://www.FreeRTOS.org/FAQHelp.html + * + * Systems with a configurable address for the interrupt vector table + * can also encounter assertion failures or even system faults here if + * VTOR is not set correctly to point to the application's vector table. */ + configASSERT( pxVectorTable[ portVECTOR_INDEX_SVC ] == SVC_Handler ); + configASSERT( pxVectorTable[ portVECTOR_INDEX_PENDSV ] == PendSV_Handler ); + } /* configCHECK_HANDLER_INSTALLATION */ + #if ( ( configASSERT_DEFINED == 1 ) && ( portHAS_ARMV8M_MAIN_EXTENSION == 1 ) ) { volatile uint32_t ulImplementedPrioBits = 0; volatile uint8_t ucMaxPriorityValue; - const portISR_t * const pxVectorTable = portSCB_VTOR_REG; /* Determine the maximum priority from which ISR safe FreeRTOS API * functions can be called. ISR safe functions are those that end in @@ -1765,21 +1784,6 @@ BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ * register. */ ulMaxPRIGROUPValue <<= portPRIGROUP_SHIFT; ulMaxPRIGROUPValue &= portPRIORITY_GROUP_MASK; - - /* Verify correct installation of the FreeRTOS handlers for SVCall and - * PendSV. Do not check the installation of the SysTick handler because - * the application may provide the OS tick without using the SysTick - * timer by overriding the weak function vPortSetupTimerInterrupt(). - * - * Assertion failures here can be caused by incorrect installation of - * the FreeRTOS handlers. For help installing the handlers, see - * https://www.FreeRTOS.org/FAQHelp.html - * - * Systems with a configurable address for the interrupt vector table - * can also encounter assertion failures or even system faults here if - * VTOR is not set correctly to point to the application's vector table. */ - configASSERT( pxVectorTable[ portVECTOR_INDEX_SVC ] == SVC_Handler ); - configASSERT( pxVectorTable[ portVECTOR_INDEX_PENDSV ] == PendSV_Handler ); } #endif /* #if ( ( configASSERT_DEFINED == 1 ) && ( portHAS_ARMV8M_MAIN_EXTENSION == 1 ) ) */ diff --git a/portable/ARMv8M/non_secure/portmacrocommon.h b/portable/ARMv8M/non_secure/portmacrocommon.h index 60ef37380a..dc096021f7 100644 --- a/portable/ARMv8M/non_secure/portmacrocommon.h +++ b/portable/ARMv8M/non_secure/portmacrocommon.h @@ -370,6 +370,20 @@ extern void vClearInterruptMask( uint32_t ulMask ) /* __attribute__(( naked )) P #define portEXIT_CRITICAL() vPortExitCritical() /*-----------------------------------------------------------*/ +/* Runtime Checks on Port Configuration */ +#ifndef configCHECK_HANDLER_INSTALLATION + #if ( configASSERT_DEFINED == 1 ) + #define configCHECK_HANDLER_INSTALLATION 1 + #else + #define configCHECK_HANDLER_INSTALLATION 0 + #endif +#else + #if ( configCHECK_HANDLER_INSTALLATION == 1 && configASSERT_DEFINED == 0 ) + #error You must define configASSERT() when configCHECK_HANDLER_INSTALLATION is 1. + #endif +#endif +/*-----------------------------------------------------------*/ + /** * @brief Tickless idle/low power functionality. */ diff --git a/portable/GCC/ARM_CM0/port.c b/portable/GCC/ARM_CM0/port.c index 9679c9e3c2..e990dd1c32 100644 --- a/portable/GCC/ARM_CM0/port.c +++ b/portable/GCC/ARM_CM0/port.c @@ -238,7 +238,7 @@ void vPortStartFirstTask( void ) */ BaseType_t xPortStartScheduler( void ) { - #if ( configASSERT_DEFINED == 1 ) + #if ( configCHECK_HANDLER_INSTALLATION == 1 ) { /* Point pxVectorTable at the interrupt vector table. Systems without * a VTOR register provide the value zero in place of the VTOR register @@ -259,7 +259,7 @@ BaseType_t xPortStartScheduler( void ) * VTOR is not set correctly to point to the application's vector table. */ configASSERT( pxVectorTable[ portVECTOR_INDEX_PENDSV ] == xPortPendSVHandler ); } - #endif /* configASSERT_DEFINED */ + #endif /* configCHECK_HANDLER_INSTALLATION */ /* Make PendSV and SysTick the lowest priority interrupt. */ portNVIC_SHPR3_REG |= portNVIC_PENDSV_PRI; diff --git a/portable/GCC/ARM_CM0/portmacro.h b/portable/GCC/ARM_CM0/portmacro.h index 3c55b5d0c4..606a94f4a7 100644 --- a/portable/GCC/ARM_CM0/portmacro.h +++ b/portable/GCC/ARM_CM0/portmacro.h @@ -143,6 +143,20 @@ extern void vClearInterruptMaskFromISR( uint32_t ulMask ) __attribute__( ( nake /*-----------------------------------------------------------*/ +/* Runtime Checks on Port Configuration */ +#ifndef configCHECK_HANDLER_INSTALLATION + #if ( configASSERT_DEFINED == 1 ) + #define configCHECK_HANDLER_INSTALLATION 1 + #else + #define configCHECK_HANDLER_INSTALLATION 0 + #endif +#else + #if ( configCHECK_HANDLER_INSTALLATION == 1 && configASSERT_DEFINED == 0 ) + #error You must define configASSERT() when configCHECK_HANDLER_INSTALLATION is 1. + #endif +#endif +/*-----------------------------------------------------------*/ + portFORCE_INLINE static BaseType_t xPortIsInsideInterrupt( void ) { uint32_t ulCurrentInterrupt; diff --git a/portable/GCC/ARM_CM4F/port.c b/portable/GCC/ARM_CM4F/port.c index fe0a96c2d4..cf667d3124 100644 --- a/portable/GCC/ARM_CM4F/port.c +++ b/portable/GCC/ARM_CM4F/port.c @@ -310,6 +310,26 @@ BaseType_t xPortStartScheduler( void ) * /source/portable/GCC/ARM_CM7/r0p1 directory. */ configASSERT( portCPUID != portCORTEX_M7_r0p1_ID ); configASSERT( portCPUID != portCORTEX_M7_r0p0_ID ); + + #if ( configCHECK_HANDLER_INSTALLATION == 1 ) + { + const portISR_t * const pxVectorTable = portSCB_VTOR_REG; + + /* Verify correct installation of the FreeRTOS handlers for SVCall and + * PendSV. Do not check the installation of the SysTick handler because + * the application may provide the OS tick without using the SysTick + * timer by overriding the weak function vPortSetupTimerInterrupt(). + * + * Assertion failures here can be caused by incorrect installation of + * the FreeRTOS handlers. For help installing the handlers, see + * https://www.FreeRTOS.org/FAQHelp.html + * + * Systems with a configurable address for the interrupt vector table + * can also encounter assertion failures or even system faults here if + * VTOR is not set correctly to point to the application's vector table. */ + configASSERT( pxVectorTable[ portVECTOR_INDEX_SVC ] == vPortSVCHandler ); + configASSERT( pxVectorTable[ portVECTOR_INDEX_PENDSV ] == xPortPendSVHandler ); + } /* configCHECK_HANDLER_INSTALLATION */ #if ( configASSERT_DEFINED == 1 ) { @@ -317,7 +337,6 @@ BaseType_t xPortStartScheduler( void ) volatile uint32_t ulImplementedPrioBits = 0; volatile uint8_t * const pucFirstUserPriorityRegister = ( volatile uint8_t * const ) ( portNVIC_IP_REGISTERS_OFFSET_16 + portFIRST_USER_INTERRUPT_NUMBER ); volatile uint8_t ucMaxPriorityValue; - const portISR_t * const pxVectorTable = portSCB_VTOR_REG; /* Determine the maximum priority from which ISR safe FreeRTOS API * functions can be called. ISR safe functions are those that end in @@ -393,21 +412,6 @@ BaseType_t xPortStartScheduler( void ) /* Restore the clobbered interrupt priority register to its original * value. */ *pucFirstUserPriorityRegister = ucOriginalPriority; - - /* Verify correct installation of the FreeRTOS handlers for SVCall and - * PendSV. Do not check the installation of the SysTick handler because - * the application may provide the OS tick without using the SysTick - * timer by overriding the weak function vPortSetupTimerInterrupt(). - * - * Assertion failures here can be caused by incorrect installation of - * the FreeRTOS handlers. For help installing the handlers, see - * https://www.FreeRTOS.org/FAQHelp.html - * - * Systems with a configurable address for the interrupt vector table - * can also encounter assertion failures or even system faults here if - * VTOR is not set correctly to point to the application's vector table. */ - configASSERT( pxVectorTable[ portVECTOR_INDEX_SVC ] == vPortSVCHandler ); - configASSERT( pxVectorTable[ portVECTOR_INDEX_PENDSV ] == xPortPendSVHandler ); } #endif /* configASSERT_DEFINED */ diff --git a/portable/GCC/ARM_CM4F/portmacro.h b/portable/GCC/ARM_CM4F/portmacro.h index 40b2d03e91..956f9ed0b7 100644 --- a/portable/GCC/ARM_CM4F/portmacro.h +++ b/portable/GCC/ARM_CM4F/portmacro.h @@ -133,6 +133,20 @@ extern void vPortExitCritical( void ); #define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void * pvParameters ) /*-----------------------------------------------------------*/ +/* Runtime Checks on Port Configuration */ +#ifndef configCHECK_HANDLER_INSTALLATION + #if ( configASSERT_DEFINED == 1 ) + #define configCHECK_HANDLER_INSTALLATION 1 + #else + #define configCHECK_HANDLER_INSTALLATION 0 + #endif +#else + #if ( configCHECK_HANDLER_INSTALLATION == 1 && configASSERT_DEFINED == 0 ) + #error You must define configASSERT() when configCHECK_HANDLER_INSTALLATION is 1. + #endif +#endif +/*-----------------------------------------------------------*/ + /* Tickless idle/low power functionality. */ #ifndef portSUPPRESS_TICKS_AND_SLEEP extern void vPortSuppressTicksAndSleep( TickType_t xExpectedIdleTime ); From 5d3726fe14872f3983111fc35734f1ecfcdf347a Mon Sep 17 00:00:00 2001 From: Jeff Tenney Date: Mon, 16 Oct 2023 14:46:28 -0700 Subject: [PATCH 13/23] clean up whitespace --- portable/GCC/ARM_CM4F/port.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/portable/GCC/ARM_CM4F/port.c b/portable/GCC/ARM_CM4F/port.c index cf667d3124..f7b08f05e8 100644 --- a/portable/GCC/ARM_CM4F/port.c +++ b/portable/GCC/ARM_CM4F/port.c @@ -310,7 +310,7 @@ BaseType_t xPortStartScheduler( void ) * /source/portable/GCC/ARM_CM7/r0p1 directory. */ configASSERT( portCPUID != portCORTEX_M7_r0p1_ID ); configASSERT( portCPUID != portCORTEX_M7_r0p0_ID ); - + #if ( configCHECK_HANDLER_INSTALLATION == 1 ) { const portISR_t * const pxVectorTable = portSCB_VTOR_REG; From 830957d51f7fb3669752b258c40faadf051c6978 Mon Sep 17 00:00:00 2001 From: Jeff Tenney Date: Tue, 17 Oct 2023 16:42:21 -0700 Subject: [PATCH 14/23] Add comment on configCHECK_HANDLER_INSTALLATION --- portable/ARMv8M/non_secure/port.c | 5 +++++ portable/GCC/ARM_CM0/port.c | 5 +++++ portable/GCC/ARM_CM4F/port.c | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/portable/ARMv8M/non_secure/port.c b/portable/ARMv8M/non_secure/port.c index fe5a232db9..3fa316e1f6 100644 --- a/portable/ARMv8M/non_secure/port.c +++ b/portable/ARMv8M/non_secure/port.c @@ -1693,6 +1693,11 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ { + /* Applications that route program control to the FreeRTOS interrupt + * handlers through intermediate handlers (indirect routing) should set + * configCHECK_HANDLER_INSTALLATION to 0 in FreeRTOSConfig.h. Direct + * routing, which is validated here when configCHECK_HANDLER_INSTALLATION + * is 1, is preferred when possible. */ #if ( configCHECK_HANDLER_INSTALLATION == 1 ) { const portISR_t * const pxVectorTable = portSCB_VTOR_REG; diff --git a/portable/GCC/ARM_CM0/port.c b/portable/GCC/ARM_CM0/port.c index e990dd1c32..40c6b35460 100644 --- a/portable/GCC/ARM_CM0/port.c +++ b/portable/GCC/ARM_CM0/port.c @@ -238,6 +238,11 @@ void vPortStartFirstTask( void ) */ BaseType_t xPortStartScheduler( void ) { + /* Applications that route program control to the FreeRTOS interrupt + * handlers through intermediate handlers (indirect routing) should set + * configCHECK_HANDLER_INSTALLATION to 0 in FreeRTOSConfig.h. Direct + * routing, which is validated here when configCHECK_HANDLER_INSTALLATION + * is 1, is preferred when possible. */ #if ( configCHECK_HANDLER_INSTALLATION == 1 ) { /* Point pxVectorTable at the interrupt vector table. Systems without diff --git a/portable/GCC/ARM_CM4F/port.c b/portable/GCC/ARM_CM4F/port.c index f7b08f05e8..08a779e0f6 100644 --- a/portable/GCC/ARM_CM4F/port.c +++ b/portable/GCC/ARM_CM4F/port.c @@ -311,6 +311,11 @@ BaseType_t xPortStartScheduler( void ) configASSERT( portCPUID != portCORTEX_M7_r0p1_ID ); configASSERT( portCPUID != portCORTEX_M7_r0p0_ID ); + /* Applications that route program control to the FreeRTOS interrupt + * handlers through intermediate handlers (indirect routing) should set + * configCHECK_HANDLER_INSTALLATION to 0 in FreeRTOSConfig.h. Direct + * routing, which is validated here when configCHECK_HANDLER_INSTALLATION + * is 1, is preferred when possible. */ #if ( configCHECK_HANDLER_INSTALLATION == 1 ) { const portISR_t * const pxVectorTable = portSCB_VTOR_REG; From a7588dc17f532f4a73c85b6c6f424bba25726717 Mon Sep 17 00:00:00 2001 From: Jeff Tenney Date: Wed, 18 Oct 2023 21:41:03 -0700 Subject: [PATCH 15/23] Add closing #endif (oops) --- portable/ARMv8M/non_secure/port.c | 3 ++- portable/GCC/ARM_CM4F/port.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/portable/ARMv8M/non_secure/port.c b/portable/ARMv8M/non_secure/port.c index 3fa316e1f6..617e0c8689 100644 --- a/portable/ARMv8M/non_secure/port.c +++ b/portable/ARMv8M/non_secure/port.c @@ -1716,7 +1716,8 @@ BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ * VTOR is not set correctly to point to the application's vector table. */ configASSERT( pxVectorTable[ portVECTOR_INDEX_SVC ] == SVC_Handler ); configASSERT( pxVectorTable[ portVECTOR_INDEX_PENDSV ] == PendSV_Handler ); - } /* configCHECK_HANDLER_INSTALLATION */ + } + #endif /* configCHECK_HANDLER_INSTALLATION */ #if ( ( configASSERT_DEFINED == 1 ) && ( portHAS_ARMV8M_MAIN_EXTENSION == 1 ) ) { diff --git a/portable/GCC/ARM_CM4F/port.c b/portable/GCC/ARM_CM4F/port.c index 08a779e0f6..4d92bb3a68 100644 --- a/portable/GCC/ARM_CM4F/port.c +++ b/portable/GCC/ARM_CM4F/port.c @@ -334,7 +334,8 @@ BaseType_t xPortStartScheduler( void ) * VTOR is not set correctly to point to the application's vector table. */ configASSERT( pxVectorTable[ portVECTOR_INDEX_SVC ] == vPortSVCHandler ); configASSERT( pxVectorTable[ portVECTOR_INDEX_PENDSV ] == xPortPendSVHandler ); - } /* configCHECK_HANDLER_INSTALLATION */ + } + #endif /* configCHECK_HANDLER_INSTALLATION */ #if ( configASSERT_DEFINED == 1 ) { From 4c8ba4a9947d8f42f340e1d5852ee1a9957f9c6e Mon Sep 17 00:00:00 2001 From: Jeff Tenney Date: Mon, 23 Oct 2023 15:32:15 -0700 Subject: [PATCH 16/23] Replicate to all Cortex M ports for GCC and IAR --- portable/ARMv8M/non_secure/portmacrocommon.h | 2 +- portable/GCC/ARM_CM0/port.c | 2 +- portable/GCC/ARM_CM0/portmacro.h | 2 +- portable/GCC/ARM_CM23/non_secure/port.c | 63 ++++++++++++++----- .../GCC/ARM_CM23/non_secure/portmacrocommon.h | 14 +++++ portable/GCC/ARM_CM23_NTZ/non_secure/port.c | 63 ++++++++++++++----- .../ARM_CM23_NTZ/non_secure/portmacrocommon.h | 14 +++++ portable/GCC/ARM_CM3/port.c | 39 +++++++++++- portable/GCC/ARM_CM3/portmacro.h | 14 +++++ portable/GCC/ARM_CM33/non_secure/port.c | 63 ++++++++++++++----- .../GCC/ARM_CM33/non_secure/portmacrocommon.h | 14 +++++ portable/GCC/ARM_CM33_NTZ/non_secure/port.c | 63 ++++++++++++++----- .../ARM_CM33_NTZ/non_secure/portmacrocommon.h | 14 +++++ portable/GCC/ARM_CM35P/non_secure/port.c | 63 ++++++++++++++----- .../ARM_CM35P/non_secure/portmacrocommon.h | 14 +++++ portable/GCC/ARM_CM35P_NTZ/non_secure/port.c | 63 ++++++++++++++----- .../non_secure/portmacrocommon.h | 14 +++++ portable/GCC/ARM_CM3_MPU/port.c | 34 ++++++++++ portable/GCC/ARM_CM3_MPU/portmacro.h | 14 +++++ portable/GCC/ARM_CM4F/portmacro.h | 2 +- portable/GCC/ARM_CM4_MPU/port.c | 34 ++++++++++ portable/GCC/ARM_CM4_MPU/portmacro.h | 14 +++++ portable/GCC/ARM_CM55/non_secure/port.c | 63 ++++++++++++++----- .../GCC/ARM_CM55/non_secure/portmacrocommon.h | 14 +++++ portable/GCC/ARM_CM55_NTZ/non_secure/port.c | 63 ++++++++++++++----- .../ARM_CM55_NTZ/non_secure/portmacrocommon.h | 14 +++++ portable/GCC/ARM_CM85/non_secure/port.c | 63 ++++++++++++++----- .../GCC/ARM_CM85/non_secure/portmacrocommon.h | 14 +++++ portable/GCC/ARM_CM85_NTZ/non_secure/port.c | 63 ++++++++++++++----- .../ARM_CM85_NTZ/non_secure/portmacrocommon.h | 14 +++++ portable/IAR/ARM_CM0/port.c | 35 +++++++++++ portable/IAR/ARM_CM0/portasm.s | 8 +-- portable/IAR/ARM_CM0/portmacro.h | 14 +++++ portable/IAR/ARM_CM23/non_secure/port.c | 63 ++++++++++++++----- .../IAR/ARM_CM23/non_secure/portmacrocommon.h | 14 +++++ portable/IAR/ARM_CM23_NTZ/non_secure/port.c | 63 ++++++++++++++----- .../ARM_CM23_NTZ/non_secure/portmacrocommon.h | 14 +++++ portable/IAR/ARM_CM3/port.c | 39 +++++++++++- portable/IAR/ARM_CM3/portmacro.h | 14 +++++ portable/IAR/ARM_CM33/non_secure/port.c | 63 ++++++++++++++----- .../IAR/ARM_CM33/non_secure/portmacrocommon.h | 14 +++++ portable/IAR/ARM_CM33_NTZ/non_secure/port.c | 63 ++++++++++++++----- .../ARM_CM33_NTZ/non_secure/portmacrocommon.h | 14 +++++ portable/IAR/ARM_CM35P/non_secure/port.c | 63 ++++++++++++++----- .../ARM_CM35P/non_secure/portmacrocommon.h | 14 +++++ portable/IAR/ARM_CM35P_NTZ/non_secure/port.c | 63 ++++++++++++++----- .../non_secure/portmacrocommon.h | 14 +++++ portable/IAR/ARM_CM4F/port.c | 39 +++++++++++- portable/IAR/ARM_CM4F/portmacro.h | 14 +++++ portable/IAR/ARM_CM4F_MPU/port.c | 34 ++++++++++ portable/IAR/ARM_CM4F_MPU/portmacro.h | 14 +++++ portable/IAR/ARM_CM55/non_secure/port.c | 63 ++++++++++++++----- .../IAR/ARM_CM55/non_secure/portmacrocommon.h | 14 +++++ portable/IAR/ARM_CM55_NTZ/non_secure/port.c | 63 ++++++++++++++----- .../ARM_CM55_NTZ/non_secure/portmacrocommon.h | 14 +++++ portable/IAR/ARM_CM85/non_secure/port.c | 63 ++++++++++++++----- .../IAR/ARM_CM85/non_secure/portmacrocommon.h | 14 +++++ portable/IAR/ARM_CM85_NTZ/non_secure/port.c | 63 ++++++++++++++----- .../ARM_CM85_NTZ/non_secure/portmacrocommon.h | 14 +++++ 59 files changed, 1597 insertions(+), 311 deletions(-) diff --git a/portable/ARMv8M/non_secure/portmacrocommon.h b/portable/ARMv8M/non_secure/portmacrocommon.h index dc096021f7..083eea5cf0 100644 --- a/portable/ARMv8M/non_secure/portmacrocommon.h +++ b/portable/ARMv8M/non_secure/portmacrocommon.h @@ -370,7 +370,7 @@ extern void vClearInterruptMask( uint32_t ulMask ) /* __attribute__(( naked )) P #define portEXIT_CRITICAL() vPortExitCritical() /*-----------------------------------------------------------*/ -/* Runtime Checks on Port Configuration */ +/* Runtime checks on port configuration */ #ifndef configCHECK_HANDLER_INSTALLATION #if ( configASSERT_DEFINED == 1 ) #define configCHECK_HANDLER_INSTALLATION 1 diff --git a/portable/GCC/ARM_CM0/port.c b/portable/GCC/ARM_CM0/port.c index 40c6b35460..d7ccee29ac 100644 --- a/portable/GCC/ARM_CM0/port.c +++ b/portable/GCC/ARM_CM0/port.c @@ -266,7 +266,7 @@ BaseType_t xPortStartScheduler( void ) } #endif /* configCHECK_HANDLER_INSTALLATION */ - /* Make PendSV and SysTick the lowest priority interrupt. */ + /* Make PendSV and SysTick the lowest priority interrupts. */ portNVIC_SHPR3_REG |= portNVIC_PENDSV_PRI; portNVIC_SHPR3_REG |= portNVIC_SYSTICK_PRI; diff --git a/portable/GCC/ARM_CM0/portmacro.h b/portable/GCC/ARM_CM0/portmacro.h index 606a94f4a7..f967a70a75 100644 --- a/portable/GCC/ARM_CM0/portmacro.h +++ b/portable/GCC/ARM_CM0/portmacro.h @@ -143,7 +143,7 @@ extern void vClearInterruptMaskFromISR( uint32_t ulMask ) __attribute__( ( nake /*-----------------------------------------------------------*/ -/* Runtime Checks on Port Configuration */ +/* Runtime checks on port configuration */ #ifndef configCHECK_HANDLER_INSTALLATION #if ( configASSERT_DEFINED == 1 ) #define configCHECK_HANDLER_INSTALLATION 1 diff --git a/portable/GCC/ARM_CM23/non_secure/port.c b/portable/GCC/ARM_CM23/non_secure/port.c index 52d68d3eaf..617e0c8689 100644 --- a/portable/GCC/ARM_CM23/non_secure/port.c +++ b/portable/GCC/ARM_CM23/non_secure/port.c @@ -79,6 +79,12 @@ #endif /*-----------------------------------------------------------*/ +/** + * @brief Prototype to which all Interrupt Service Routines conform. + */ +typedef void (* portISR_t)( void ); +/*-----------------------------------------------------------*/ + /** * @brief Constants required to manipulate the NVIC. */ @@ -100,10 +106,18 @@ /** * @brief Constants required to manipulate the SCB. */ -#define portSCB_SYS_HANDLER_CTRL_STATE_REG ( *( volatile uint32_t * ) 0xe000ed24 ) +#define portSCB_VTOR_REG ( *( ( portISR_t ** ) 0xe000ed08 ) ) +#define portSCB_SYS_HANDLER_CTRL_STATE_REG ( *( ( volatile uint32_t * ) 0xe000ed24 ) ) #define portSCB_MEM_FAULT_ENABLE_BIT ( 1UL << 16UL ) /*-----------------------------------------------------------*/ +/** + * @brief Constants used to check the installation of the FreeRTOS interrupt handlers. + */ +#define portVECTOR_INDEX_SVC ( 11 ) +#define portVECTOR_INDEX_PENDSV ( 14 ) +/*-----------------------------------------------------------*/ + /** * @brief Constants required to check the validity of an interrupt priority. */ @@ -1679,22 +1693,44 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ { + /* Applications that route program control to the FreeRTOS interrupt + * handlers through intermediate handlers (indirect routing) should set + * configCHECK_HANDLER_INSTALLATION to 0 in FreeRTOSConfig.h. Direct + * routing, which is validated here when configCHECK_HANDLER_INSTALLATION + * is 1, is preferred when possible. */ + #if ( configCHECK_HANDLER_INSTALLATION == 1 ) + { + const portISR_t * const pxVectorTable = portSCB_VTOR_REG; + + /* Verify correct installation of the FreeRTOS handlers for SVCall and + * PendSV. Do not check the installation of the SysTick handler because + * the application may provide the OS tick without using the SysTick + * timer by overriding the weak function vPortSetupTimerInterrupt(). + * + * Assertion failures here can be caused by incorrect installation of + * the FreeRTOS handlers. For help installing the handlers, see + * https://www.FreeRTOS.org/FAQHelp.html + * + * Systems with a configurable address for the interrupt vector table + * can also encounter assertion failures or even system faults here if + * VTOR is not set correctly to point to the application's vector table. */ + configASSERT( pxVectorTable[ portVECTOR_INDEX_SVC ] == SVC_Handler ); + configASSERT( pxVectorTable[ portVECTOR_INDEX_PENDSV ] == PendSV_Handler ); + } + #endif /* configCHECK_HANDLER_INSTALLATION */ + #if ( ( configASSERT_DEFINED == 1 ) && ( portHAS_ARMV8M_MAIN_EXTENSION == 1 ) ) { - volatile uint32_t ulOriginalPriority; volatile uint32_t ulImplementedPrioBits = 0; volatile uint8_t ucMaxPriorityValue; /* Determine the maximum priority from which ISR safe FreeRTOS API - * functions can be called. ISR safe functions are those that end in - * "FromISR". FreeRTOS maintains separate thread and ISR API functions to + * functions can be called. ISR safe functions are those that end in + * "FromISR". FreeRTOS maintains separate thread and ISR API functions to * ensure interrupt entry is as fast and simple as possible. * - * Save the interrupt priority value that is about to be clobbered. */ - ulOriginalPriority = portNVIC_SHPR2_REG; - - /* Determine the number of priority bits available. First write to all - * possible bits. */ + * First, determine the number of priority bits available. Write to all + * possible bits in the priority setting for SVCall. */ portNVIC_SHPR2_REG = 0xFF000000; /* Read the value back to see how many bits stuck. */ @@ -1717,7 +1753,6 @@ BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ /* Calculate the maximum acceptable priority group value for the number * of bits read back. */ - while( ( ucMaxPriorityValue & portTOP_BIT_OF_BYTE ) == portTOP_BIT_OF_BYTE ) { ulImplementedPrioBits++; @@ -1755,16 +1790,14 @@ BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ * register. */ ulMaxPRIGROUPValue <<= portPRIGROUP_SHIFT; ulMaxPRIGROUPValue &= portPRIORITY_GROUP_MASK; - - /* Restore the clobbered interrupt priority register to its original - * value. */ - portNVIC_SHPR2_REG = ulOriginalPriority; } #endif /* #if ( ( configASSERT_DEFINED == 1 ) && ( portHAS_ARMV8M_MAIN_EXTENSION == 1 ) ) */ - /* Make PendSV, CallSV and SysTick the same priority as the kernel. */ + /* Make PendSV and SysTick the lowest priority interrupts, and make SVCall + * the highest priority. */ portNVIC_SHPR3_REG |= portNVIC_PENDSV_PRI; portNVIC_SHPR3_REG |= portNVIC_SYSTICK_PRI; + portNVIC_SHPR2_REG = 0; #if ( configENABLE_MPU == 1 ) { diff --git a/portable/GCC/ARM_CM23/non_secure/portmacrocommon.h b/portable/GCC/ARM_CM23/non_secure/portmacrocommon.h index 60ef37380a..083eea5cf0 100644 --- a/portable/GCC/ARM_CM23/non_secure/portmacrocommon.h +++ b/portable/GCC/ARM_CM23/non_secure/portmacrocommon.h @@ -370,6 +370,20 @@ extern void vClearInterruptMask( uint32_t ulMask ) /* __attribute__(( naked )) P #define portEXIT_CRITICAL() vPortExitCritical() /*-----------------------------------------------------------*/ +/* Runtime checks on port configuration */ +#ifndef configCHECK_HANDLER_INSTALLATION + #if ( configASSERT_DEFINED == 1 ) + #define configCHECK_HANDLER_INSTALLATION 1 + #else + #define configCHECK_HANDLER_INSTALLATION 0 + #endif +#else + #if ( configCHECK_HANDLER_INSTALLATION == 1 && configASSERT_DEFINED == 0 ) + #error You must define configASSERT() when configCHECK_HANDLER_INSTALLATION is 1. + #endif +#endif +/*-----------------------------------------------------------*/ + /** * @brief Tickless idle/low power functionality. */ diff --git a/portable/GCC/ARM_CM23_NTZ/non_secure/port.c b/portable/GCC/ARM_CM23_NTZ/non_secure/port.c index 52d68d3eaf..617e0c8689 100644 --- a/portable/GCC/ARM_CM23_NTZ/non_secure/port.c +++ b/portable/GCC/ARM_CM23_NTZ/non_secure/port.c @@ -79,6 +79,12 @@ #endif /*-----------------------------------------------------------*/ +/** + * @brief Prototype to which all Interrupt Service Routines conform. + */ +typedef void (* portISR_t)( void ); +/*-----------------------------------------------------------*/ + /** * @brief Constants required to manipulate the NVIC. */ @@ -100,10 +106,18 @@ /** * @brief Constants required to manipulate the SCB. */ -#define portSCB_SYS_HANDLER_CTRL_STATE_REG ( *( volatile uint32_t * ) 0xe000ed24 ) +#define portSCB_VTOR_REG ( *( ( portISR_t ** ) 0xe000ed08 ) ) +#define portSCB_SYS_HANDLER_CTRL_STATE_REG ( *( ( volatile uint32_t * ) 0xe000ed24 ) ) #define portSCB_MEM_FAULT_ENABLE_BIT ( 1UL << 16UL ) /*-----------------------------------------------------------*/ +/** + * @brief Constants used to check the installation of the FreeRTOS interrupt handlers. + */ +#define portVECTOR_INDEX_SVC ( 11 ) +#define portVECTOR_INDEX_PENDSV ( 14 ) +/*-----------------------------------------------------------*/ + /** * @brief Constants required to check the validity of an interrupt priority. */ @@ -1679,22 +1693,44 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ { + /* Applications that route program control to the FreeRTOS interrupt + * handlers through intermediate handlers (indirect routing) should set + * configCHECK_HANDLER_INSTALLATION to 0 in FreeRTOSConfig.h. Direct + * routing, which is validated here when configCHECK_HANDLER_INSTALLATION + * is 1, is preferred when possible. */ + #if ( configCHECK_HANDLER_INSTALLATION == 1 ) + { + const portISR_t * const pxVectorTable = portSCB_VTOR_REG; + + /* Verify correct installation of the FreeRTOS handlers for SVCall and + * PendSV. Do not check the installation of the SysTick handler because + * the application may provide the OS tick without using the SysTick + * timer by overriding the weak function vPortSetupTimerInterrupt(). + * + * Assertion failures here can be caused by incorrect installation of + * the FreeRTOS handlers. For help installing the handlers, see + * https://www.FreeRTOS.org/FAQHelp.html + * + * Systems with a configurable address for the interrupt vector table + * can also encounter assertion failures or even system faults here if + * VTOR is not set correctly to point to the application's vector table. */ + configASSERT( pxVectorTable[ portVECTOR_INDEX_SVC ] == SVC_Handler ); + configASSERT( pxVectorTable[ portVECTOR_INDEX_PENDSV ] == PendSV_Handler ); + } + #endif /* configCHECK_HANDLER_INSTALLATION */ + #if ( ( configASSERT_DEFINED == 1 ) && ( portHAS_ARMV8M_MAIN_EXTENSION == 1 ) ) { - volatile uint32_t ulOriginalPriority; volatile uint32_t ulImplementedPrioBits = 0; volatile uint8_t ucMaxPriorityValue; /* Determine the maximum priority from which ISR safe FreeRTOS API - * functions can be called. ISR safe functions are those that end in - * "FromISR". FreeRTOS maintains separate thread and ISR API functions to + * functions can be called. ISR safe functions are those that end in + * "FromISR". FreeRTOS maintains separate thread and ISR API functions to * ensure interrupt entry is as fast and simple as possible. * - * Save the interrupt priority value that is about to be clobbered. */ - ulOriginalPriority = portNVIC_SHPR2_REG; - - /* Determine the number of priority bits available. First write to all - * possible bits. */ + * First, determine the number of priority bits available. Write to all + * possible bits in the priority setting for SVCall. */ portNVIC_SHPR2_REG = 0xFF000000; /* Read the value back to see how many bits stuck. */ @@ -1717,7 +1753,6 @@ BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ /* Calculate the maximum acceptable priority group value for the number * of bits read back. */ - while( ( ucMaxPriorityValue & portTOP_BIT_OF_BYTE ) == portTOP_BIT_OF_BYTE ) { ulImplementedPrioBits++; @@ -1755,16 +1790,14 @@ BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ * register. */ ulMaxPRIGROUPValue <<= portPRIGROUP_SHIFT; ulMaxPRIGROUPValue &= portPRIORITY_GROUP_MASK; - - /* Restore the clobbered interrupt priority register to its original - * value. */ - portNVIC_SHPR2_REG = ulOriginalPriority; } #endif /* #if ( ( configASSERT_DEFINED == 1 ) && ( portHAS_ARMV8M_MAIN_EXTENSION == 1 ) ) */ - /* Make PendSV, CallSV and SysTick the same priority as the kernel. */ + /* Make PendSV and SysTick the lowest priority interrupts, and make SVCall + * the highest priority. */ portNVIC_SHPR3_REG |= portNVIC_PENDSV_PRI; portNVIC_SHPR3_REG |= portNVIC_SYSTICK_PRI; + portNVIC_SHPR2_REG = 0; #if ( configENABLE_MPU == 1 ) { diff --git a/portable/GCC/ARM_CM23_NTZ/non_secure/portmacrocommon.h b/portable/GCC/ARM_CM23_NTZ/non_secure/portmacrocommon.h index 60ef37380a..083eea5cf0 100644 --- a/portable/GCC/ARM_CM23_NTZ/non_secure/portmacrocommon.h +++ b/portable/GCC/ARM_CM23_NTZ/non_secure/portmacrocommon.h @@ -370,6 +370,20 @@ extern void vClearInterruptMask( uint32_t ulMask ) /* __attribute__(( naked )) P #define portEXIT_CRITICAL() vPortExitCritical() /*-----------------------------------------------------------*/ +/* Runtime checks on port configuration */ +#ifndef configCHECK_HANDLER_INSTALLATION + #if ( configASSERT_DEFINED == 1 ) + #define configCHECK_HANDLER_INSTALLATION 1 + #else + #define configCHECK_HANDLER_INSTALLATION 0 + #endif +#else + #if ( configCHECK_HANDLER_INSTALLATION == 1 && configASSERT_DEFINED == 0 ) + #error You must define configASSERT() when configCHECK_HANDLER_INSTALLATION is 1. + #endif +#endif +/*-----------------------------------------------------------*/ + /** * @brief Tickless idle/low power functionality. */ diff --git a/portable/GCC/ARM_CM3/port.c b/portable/GCC/ARM_CM3/port.c index 483f81324a..88246336e8 100644 --- a/portable/GCC/ARM_CM3/port.c +++ b/portable/GCC/ARM_CM3/port.c @@ -34,10 +34,14 @@ #include "FreeRTOS.h" #include "task.h" +/* Prototype to which all Interrupt Service Routines conform. */ +typedef void (* portISR_t)( void ); + /* Constants required to manipulate the core. Registers first... */ #define portNVIC_SYSTICK_CTRL_REG ( *( ( volatile uint32_t * ) 0xe000e010 ) ) #define portNVIC_SYSTICK_LOAD_REG ( *( ( volatile uint32_t * ) 0xe000e014 ) ) #define portNVIC_SYSTICK_CURRENT_VALUE_REG ( *( ( volatile uint32_t * ) 0xe000e018 ) ) +#define portNVIC_SHPR2_REG ( *( ( volatile uint32_t * ) 0xe000ed1c ) ) #define portNVIC_SHPR3_REG ( *( ( volatile uint32_t * ) 0xe000ed20 ) ) /* ...then bits in the registers. */ #define portNVIC_SYSTICK_CLK_BIT ( 1UL << 2UL ) @@ -52,6 +56,11 @@ #define portNVIC_PENDSV_PRI ( ( ( uint32_t ) portMIN_INTERRUPT_PRIORITY ) << 16UL ) #define portNVIC_SYSTICK_PRI ( ( ( uint32_t ) portMIN_INTERRUPT_PRIORITY ) << 24UL ) +/* Constants used to check the installation of the FreeRTOS interrupt handlers. */ +#define portSCB_VTOR_REG ( *( ( portISR_t ** ) 0xE000ED08 ) ) +#define portVECTOR_INDEX_SVC ( 11 ) +#define portVECTOR_INDEX_PENDSV ( 14 ) + /* Constants required to check the validity of an interrupt priority. */ #define portFIRST_USER_INTERRUPT_NUMBER ( 16 ) #define portNVIC_IP_REGISTERS_OFFSET_16 ( 0xE000E3F0 ) @@ -259,6 +268,32 @@ static void prvPortStartFirstTask( void ) */ BaseType_t xPortStartScheduler( void ) { + /* Applications that route program control to the FreeRTOS interrupt + * handlers through intermediate handlers (indirect routing) should set + * configCHECK_HANDLER_INSTALLATION to 0 in FreeRTOSConfig.h. Direct + * routing, which is validated here when configCHECK_HANDLER_INSTALLATION + * is 1, is preferred when possible. */ + #if ( configCHECK_HANDLER_INSTALLATION == 1 ) + { + const portISR_t * const pxVectorTable = portSCB_VTOR_REG; + + /* Verify correct installation of the FreeRTOS handlers for SVCall and + * PendSV. Do not check the installation of the SysTick handler because + * the application may provide the OS tick without using the SysTick + * timer by overriding the weak function vPortSetupTimerInterrupt(). + * + * Assertion failures here can be caused by incorrect installation of + * the FreeRTOS handlers. For help installing the handlers, see + * https://www.FreeRTOS.org/FAQHelp.html + * + * Systems with a configurable address for the interrupt vector table + * can also encounter assertion failures or even system faults here if + * VTOR is not set correctly to point to the application's vector table. */ + configASSERT( pxVectorTable[ portVECTOR_INDEX_SVC ] == vPortSVCHandler ); + configASSERT( pxVectorTable[ portVECTOR_INDEX_PENDSV ] == xPortPendSVHandler ); + } + #endif /* configCHECK_HANDLER_INSTALLATION */ + #if ( configASSERT_DEFINED == 1 ) { volatile uint8_t ucOriginalPriority; @@ -343,9 +378,11 @@ BaseType_t xPortStartScheduler( void ) } #endif /* configASSERT_DEFINED */ - /* Make PendSV and SysTick the lowest priority interrupts. */ + /* Make PendSV and SysTick the lowest priority interrupts, and make SVCall + * the highest priority. */ portNVIC_SHPR3_REG |= portNVIC_PENDSV_PRI; portNVIC_SHPR3_REG |= portNVIC_SYSTICK_PRI; + portNVIC_SHPR2_REG = 0; /* Start the timer that generates the tick ISR. Interrupts are disabled * here already. */ diff --git a/portable/GCC/ARM_CM3/portmacro.h b/portable/GCC/ARM_CM3/portmacro.h index 5d91d2139e..ac843131fd 100644 --- a/portable/GCC/ARM_CM3/portmacro.h +++ b/portable/GCC/ARM_CM3/portmacro.h @@ -130,6 +130,20 @@ extern void vPortExitCritical( void ); #define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void * pvParameters ) /*-----------------------------------------------------------*/ +/* Runtime checks on port configuration */ +#ifndef configCHECK_HANDLER_INSTALLATION + #if ( configASSERT_DEFINED == 1 ) + #define configCHECK_HANDLER_INSTALLATION 1 + #else + #define configCHECK_HANDLER_INSTALLATION 0 + #endif +#else + #if ( configCHECK_HANDLER_INSTALLATION == 1 && configASSERT_DEFINED == 0 ) + #error You must define configASSERT() when configCHECK_HANDLER_INSTALLATION is 1. + #endif +#endif +/*-----------------------------------------------------------*/ + /* Tickless idle/low power functionality. */ #ifndef portSUPPRESS_TICKS_AND_SLEEP extern void vPortSuppressTicksAndSleep( TickType_t xExpectedIdleTime ); diff --git a/portable/GCC/ARM_CM33/non_secure/port.c b/portable/GCC/ARM_CM33/non_secure/port.c index 52d68d3eaf..617e0c8689 100644 --- a/portable/GCC/ARM_CM33/non_secure/port.c +++ b/portable/GCC/ARM_CM33/non_secure/port.c @@ -79,6 +79,12 @@ #endif /*-----------------------------------------------------------*/ +/** + * @brief Prototype to which all Interrupt Service Routines conform. + */ +typedef void (* portISR_t)( void ); +/*-----------------------------------------------------------*/ + /** * @brief Constants required to manipulate the NVIC. */ @@ -100,10 +106,18 @@ /** * @brief Constants required to manipulate the SCB. */ -#define portSCB_SYS_HANDLER_CTRL_STATE_REG ( *( volatile uint32_t * ) 0xe000ed24 ) +#define portSCB_VTOR_REG ( *( ( portISR_t ** ) 0xe000ed08 ) ) +#define portSCB_SYS_HANDLER_CTRL_STATE_REG ( *( ( volatile uint32_t * ) 0xe000ed24 ) ) #define portSCB_MEM_FAULT_ENABLE_BIT ( 1UL << 16UL ) /*-----------------------------------------------------------*/ +/** + * @brief Constants used to check the installation of the FreeRTOS interrupt handlers. + */ +#define portVECTOR_INDEX_SVC ( 11 ) +#define portVECTOR_INDEX_PENDSV ( 14 ) +/*-----------------------------------------------------------*/ + /** * @brief Constants required to check the validity of an interrupt priority. */ @@ -1679,22 +1693,44 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ { + /* Applications that route program control to the FreeRTOS interrupt + * handlers through intermediate handlers (indirect routing) should set + * configCHECK_HANDLER_INSTALLATION to 0 in FreeRTOSConfig.h. Direct + * routing, which is validated here when configCHECK_HANDLER_INSTALLATION + * is 1, is preferred when possible. */ + #if ( configCHECK_HANDLER_INSTALLATION == 1 ) + { + const portISR_t * const pxVectorTable = portSCB_VTOR_REG; + + /* Verify correct installation of the FreeRTOS handlers for SVCall and + * PendSV. Do not check the installation of the SysTick handler because + * the application may provide the OS tick without using the SysTick + * timer by overriding the weak function vPortSetupTimerInterrupt(). + * + * Assertion failures here can be caused by incorrect installation of + * the FreeRTOS handlers. For help installing the handlers, see + * https://www.FreeRTOS.org/FAQHelp.html + * + * Systems with a configurable address for the interrupt vector table + * can also encounter assertion failures or even system faults here if + * VTOR is not set correctly to point to the application's vector table. */ + configASSERT( pxVectorTable[ portVECTOR_INDEX_SVC ] == SVC_Handler ); + configASSERT( pxVectorTable[ portVECTOR_INDEX_PENDSV ] == PendSV_Handler ); + } + #endif /* configCHECK_HANDLER_INSTALLATION */ + #if ( ( configASSERT_DEFINED == 1 ) && ( portHAS_ARMV8M_MAIN_EXTENSION == 1 ) ) { - volatile uint32_t ulOriginalPriority; volatile uint32_t ulImplementedPrioBits = 0; volatile uint8_t ucMaxPriorityValue; /* Determine the maximum priority from which ISR safe FreeRTOS API - * functions can be called. ISR safe functions are those that end in - * "FromISR". FreeRTOS maintains separate thread and ISR API functions to + * functions can be called. ISR safe functions are those that end in + * "FromISR". FreeRTOS maintains separate thread and ISR API functions to * ensure interrupt entry is as fast and simple as possible. * - * Save the interrupt priority value that is about to be clobbered. */ - ulOriginalPriority = portNVIC_SHPR2_REG; - - /* Determine the number of priority bits available. First write to all - * possible bits. */ + * First, determine the number of priority bits available. Write to all + * possible bits in the priority setting for SVCall. */ portNVIC_SHPR2_REG = 0xFF000000; /* Read the value back to see how many bits stuck. */ @@ -1717,7 +1753,6 @@ BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ /* Calculate the maximum acceptable priority group value for the number * of bits read back. */ - while( ( ucMaxPriorityValue & portTOP_BIT_OF_BYTE ) == portTOP_BIT_OF_BYTE ) { ulImplementedPrioBits++; @@ -1755,16 +1790,14 @@ BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ * register. */ ulMaxPRIGROUPValue <<= portPRIGROUP_SHIFT; ulMaxPRIGROUPValue &= portPRIORITY_GROUP_MASK; - - /* Restore the clobbered interrupt priority register to its original - * value. */ - portNVIC_SHPR2_REG = ulOriginalPriority; } #endif /* #if ( ( configASSERT_DEFINED == 1 ) && ( portHAS_ARMV8M_MAIN_EXTENSION == 1 ) ) */ - /* Make PendSV, CallSV and SysTick the same priority as the kernel. */ + /* Make PendSV and SysTick the lowest priority interrupts, and make SVCall + * the highest priority. */ portNVIC_SHPR3_REG |= portNVIC_PENDSV_PRI; portNVIC_SHPR3_REG |= portNVIC_SYSTICK_PRI; + portNVIC_SHPR2_REG = 0; #if ( configENABLE_MPU == 1 ) { diff --git a/portable/GCC/ARM_CM33/non_secure/portmacrocommon.h b/portable/GCC/ARM_CM33/non_secure/portmacrocommon.h index 60ef37380a..083eea5cf0 100644 --- a/portable/GCC/ARM_CM33/non_secure/portmacrocommon.h +++ b/portable/GCC/ARM_CM33/non_secure/portmacrocommon.h @@ -370,6 +370,20 @@ extern void vClearInterruptMask( uint32_t ulMask ) /* __attribute__(( naked )) P #define portEXIT_CRITICAL() vPortExitCritical() /*-----------------------------------------------------------*/ +/* Runtime checks on port configuration */ +#ifndef configCHECK_HANDLER_INSTALLATION + #if ( configASSERT_DEFINED == 1 ) + #define configCHECK_HANDLER_INSTALLATION 1 + #else + #define configCHECK_HANDLER_INSTALLATION 0 + #endif +#else + #if ( configCHECK_HANDLER_INSTALLATION == 1 && configASSERT_DEFINED == 0 ) + #error You must define configASSERT() when configCHECK_HANDLER_INSTALLATION is 1. + #endif +#endif +/*-----------------------------------------------------------*/ + /** * @brief Tickless idle/low power functionality. */ diff --git a/portable/GCC/ARM_CM33_NTZ/non_secure/port.c b/portable/GCC/ARM_CM33_NTZ/non_secure/port.c index 52d68d3eaf..617e0c8689 100644 --- a/portable/GCC/ARM_CM33_NTZ/non_secure/port.c +++ b/portable/GCC/ARM_CM33_NTZ/non_secure/port.c @@ -79,6 +79,12 @@ #endif /*-----------------------------------------------------------*/ +/** + * @brief Prototype to which all Interrupt Service Routines conform. + */ +typedef void (* portISR_t)( void ); +/*-----------------------------------------------------------*/ + /** * @brief Constants required to manipulate the NVIC. */ @@ -100,10 +106,18 @@ /** * @brief Constants required to manipulate the SCB. */ -#define portSCB_SYS_HANDLER_CTRL_STATE_REG ( *( volatile uint32_t * ) 0xe000ed24 ) +#define portSCB_VTOR_REG ( *( ( portISR_t ** ) 0xe000ed08 ) ) +#define portSCB_SYS_HANDLER_CTRL_STATE_REG ( *( ( volatile uint32_t * ) 0xe000ed24 ) ) #define portSCB_MEM_FAULT_ENABLE_BIT ( 1UL << 16UL ) /*-----------------------------------------------------------*/ +/** + * @brief Constants used to check the installation of the FreeRTOS interrupt handlers. + */ +#define portVECTOR_INDEX_SVC ( 11 ) +#define portVECTOR_INDEX_PENDSV ( 14 ) +/*-----------------------------------------------------------*/ + /** * @brief Constants required to check the validity of an interrupt priority. */ @@ -1679,22 +1693,44 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ { + /* Applications that route program control to the FreeRTOS interrupt + * handlers through intermediate handlers (indirect routing) should set + * configCHECK_HANDLER_INSTALLATION to 0 in FreeRTOSConfig.h. Direct + * routing, which is validated here when configCHECK_HANDLER_INSTALLATION + * is 1, is preferred when possible. */ + #if ( configCHECK_HANDLER_INSTALLATION == 1 ) + { + const portISR_t * const pxVectorTable = portSCB_VTOR_REG; + + /* Verify correct installation of the FreeRTOS handlers for SVCall and + * PendSV. Do not check the installation of the SysTick handler because + * the application may provide the OS tick without using the SysTick + * timer by overriding the weak function vPortSetupTimerInterrupt(). + * + * Assertion failures here can be caused by incorrect installation of + * the FreeRTOS handlers. For help installing the handlers, see + * https://www.FreeRTOS.org/FAQHelp.html + * + * Systems with a configurable address for the interrupt vector table + * can also encounter assertion failures or even system faults here if + * VTOR is not set correctly to point to the application's vector table. */ + configASSERT( pxVectorTable[ portVECTOR_INDEX_SVC ] == SVC_Handler ); + configASSERT( pxVectorTable[ portVECTOR_INDEX_PENDSV ] == PendSV_Handler ); + } + #endif /* configCHECK_HANDLER_INSTALLATION */ + #if ( ( configASSERT_DEFINED == 1 ) && ( portHAS_ARMV8M_MAIN_EXTENSION == 1 ) ) { - volatile uint32_t ulOriginalPriority; volatile uint32_t ulImplementedPrioBits = 0; volatile uint8_t ucMaxPriorityValue; /* Determine the maximum priority from which ISR safe FreeRTOS API - * functions can be called. ISR safe functions are those that end in - * "FromISR". FreeRTOS maintains separate thread and ISR API functions to + * functions can be called. ISR safe functions are those that end in + * "FromISR". FreeRTOS maintains separate thread and ISR API functions to * ensure interrupt entry is as fast and simple as possible. * - * Save the interrupt priority value that is about to be clobbered. */ - ulOriginalPriority = portNVIC_SHPR2_REG; - - /* Determine the number of priority bits available. First write to all - * possible bits. */ + * First, determine the number of priority bits available. Write to all + * possible bits in the priority setting for SVCall. */ portNVIC_SHPR2_REG = 0xFF000000; /* Read the value back to see how many bits stuck. */ @@ -1717,7 +1753,6 @@ BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ /* Calculate the maximum acceptable priority group value for the number * of bits read back. */ - while( ( ucMaxPriorityValue & portTOP_BIT_OF_BYTE ) == portTOP_BIT_OF_BYTE ) { ulImplementedPrioBits++; @@ -1755,16 +1790,14 @@ BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ * register. */ ulMaxPRIGROUPValue <<= portPRIGROUP_SHIFT; ulMaxPRIGROUPValue &= portPRIORITY_GROUP_MASK; - - /* Restore the clobbered interrupt priority register to its original - * value. */ - portNVIC_SHPR2_REG = ulOriginalPriority; } #endif /* #if ( ( configASSERT_DEFINED == 1 ) && ( portHAS_ARMV8M_MAIN_EXTENSION == 1 ) ) */ - /* Make PendSV, CallSV and SysTick the same priority as the kernel. */ + /* Make PendSV and SysTick the lowest priority interrupts, and make SVCall + * the highest priority. */ portNVIC_SHPR3_REG |= portNVIC_PENDSV_PRI; portNVIC_SHPR3_REG |= portNVIC_SYSTICK_PRI; + portNVIC_SHPR2_REG = 0; #if ( configENABLE_MPU == 1 ) { diff --git a/portable/GCC/ARM_CM33_NTZ/non_secure/portmacrocommon.h b/portable/GCC/ARM_CM33_NTZ/non_secure/portmacrocommon.h index 60ef37380a..083eea5cf0 100644 --- a/portable/GCC/ARM_CM33_NTZ/non_secure/portmacrocommon.h +++ b/portable/GCC/ARM_CM33_NTZ/non_secure/portmacrocommon.h @@ -370,6 +370,20 @@ extern void vClearInterruptMask( uint32_t ulMask ) /* __attribute__(( naked )) P #define portEXIT_CRITICAL() vPortExitCritical() /*-----------------------------------------------------------*/ +/* Runtime checks on port configuration */ +#ifndef configCHECK_HANDLER_INSTALLATION + #if ( configASSERT_DEFINED == 1 ) + #define configCHECK_HANDLER_INSTALLATION 1 + #else + #define configCHECK_HANDLER_INSTALLATION 0 + #endif +#else + #if ( configCHECK_HANDLER_INSTALLATION == 1 && configASSERT_DEFINED == 0 ) + #error You must define configASSERT() when configCHECK_HANDLER_INSTALLATION is 1. + #endif +#endif +/*-----------------------------------------------------------*/ + /** * @brief Tickless idle/low power functionality. */ diff --git a/portable/GCC/ARM_CM35P/non_secure/port.c b/portable/GCC/ARM_CM35P/non_secure/port.c index 52d68d3eaf..617e0c8689 100644 --- a/portable/GCC/ARM_CM35P/non_secure/port.c +++ b/portable/GCC/ARM_CM35P/non_secure/port.c @@ -79,6 +79,12 @@ #endif /*-----------------------------------------------------------*/ +/** + * @brief Prototype to which all Interrupt Service Routines conform. + */ +typedef void (* portISR_t)( void ); +/*-----------------------------------------------------------*/ + /** * @brief Constants required to manipulate the NVIC. */ @@ -100,10 +106,18 @@ /** * @brief Constants required to manipulate the SCB. */ -#define portSCB_SYS_HANDLER_CTRL_STATE_REG ( *( volatile uint32_t * ) 0xe000ed24 ) +#define portSCB_VTOR_REG ( *( ( portISR_t ** ) 0xe000ed08 ) ) +#define portSCB_SYS_HANDLER_CTRL_STATE_REG ( *( ( volatile uint32_t * ) 0xe000ed24 ) ) #define portSCB_MEM_FAULT_ENABLE_BIT ( 1UL << 16UL ) /*-----------------------------------------------------------*/ +/** + * @brief Constants used to check the installation of the FreeRTOS interrupt handlers. + */ +#define portVECTOR_INDEX_SVC ( 11 ) +#define portVECTOR_INDEX_PENDSV ( 14 ) +/*-----------------------------------------------------------*/ + /** * @brief Constants required to check the validity of an interrupt priority. */ @@ -1679,22 +1693,44 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ { + /* Applications that route program control to the FreeRTOS interrupt + * handlers through intermediate handlers (indirect routing) should set + * configCHECK_HANDLER_INSTALLATION to 0 in FreeRTOSConfig.h. Direct + * routing, which is validated here when configCHECK_HANDLER_INSTALLATION + * is 1, is preferred when possible. */ + #if ( configCHECK_HANDLER_INSTALLATION == 1 ) + { + const portISR_t * const pxVectorTable = portSCB_VTOR_REG; + + /* Verify correct installation of the FreeRTOS handlers for SVCall and + * PendSV. Do not check the installation of the SysTick handler because + * the application may provide the OS tick without using the SysTick + * timer by overriding the weak function vPortSetupTimerInterrupt(). + * + * Assertion failures here can be caused by incorrect installation of + * the FreeRTOS handlers. For help installing the handlers, see + * https://www.FreeRTOS.org/FAQHelp.html + * + * Systems with a configurable address for the interrupt vector table + * can also encounter assertion failures or even system faults here if + * VTOR is not set correctly to point to the application's vector table. */ + configASSERT( pxVectorTable[ portVECTOR_INDEX_SVC ] == SVC_Handler ); + configASSERT( pxVectorTable[ portVECTOR_INDEX_PENDSV ] == PendSV_Handler ); + } + #endif /* configCHECK_HANDLER_INSTALLATION */ + #if ( ( configASSERT_DEFINED == 1 ) && ( portHAS_ARMV8M_MAIN_EXTENSION == 1 ) ) { - volatile uint32_t ulOriginalPriority; volatile uint32_t ulImplementedPrioBits = 0; volatile uint8_t ucMaxPriorityValue; /* Determine the maximum priority from which ISR safe FreeRTOS API - * functions can be called. ISR safe functions are those that end in - * "FromISR". FreeRTOS maintains separate thread and ISR API functions to + * functions can be called. ISR safe functions are those that end in + * "FromISR". FreeRTOS maintains separate thread and ISR API functions to * ensure interrupt entry is as fast and simple as possible. * - * Save the interrupt priority value that is about to be clobbered. */ - ulOriginalPriority = portNVIC_SHPR2_REG; - - /* Determine the number of priority bits available. First write to all - * possible bits. */ + * First, determine the number of priority bits available. Write to all + * possible bits in the priority setting for SVCall. */ portNVIC_SHPR2_REG = 0xFF000000; /* Read the value back to see how many bits stuck. */ @@ -1717,7 +1753,6 @@ BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ /* Calculate the maximum acceptable priority group value for the number * of bits read back. */ - while( ( ucMaxPriorityValue & portTOP_BIT_OF_BYTE ) == portTOP_BIT_OF_BYTE ) { ulImplementedPrioBits++; @@ -1755,16 +1790,14 @@ BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ * register. */ ulMaxPRIGROUPValue <<= portPRIGROUP_SHIFT; ulMaxPRIGROUPValue &= portPRIORITY_GROUP_MASK; - - /* Restore the clobbered interrupt priority register to its original - * value. */ - portNVIC_SHPR2_REG = ulOriginalPriority; } #endif /* #if ( ( configASSERT_DEFINED == 1 ) && ( portHAS_ARMV8M_MAIN_EXTENSION == 1 ) ) */ - /* Make PendSV, CallSV and SysTick the same priority as the kernel. */ + /* Make PendSV and SysTick the lowest priority interrupts, and make SVCall + * the highest priority. */ portNVIC_SHPR3_REG |= portNVIC_PENDSV_PRI; portNVIC_SHPR3_REG |= portNVIC_SYSTICK_PRI; + portNVIC_SHPR2_REG = 0; #if ( configENABLE_MPU == 1 ) { diff --git a/portable/GCC/ARM_CM35P/non_secure/portmacrocommon.h b/portable/GCC/ARM_CM35P/non_secure/portmacrocommon.h index 60ef37380a..083eea5cf0 100644 --- a/portable/GCC/ARM_CM35P/non_secure/portmacrocommon.h +++ b/portable/GCC/ARM_CM35P/non_secure/portmacrocommon.h @@ -370,6 +370,20 @@ extern void vClearInterruptMask( uint32_t ulMask ) /* __attribute__(( naked )) P #define portEXIT_CRITICAL() vPortExitCritical() /*-----------------------------------------------------------*/ +/* Runtime checks on port configuration */ +#ifndef configCHECK_HANDLER_INSTALLATION + #if ( configASSERT_DEFINED == 1 ) + #define configCHECK_HANDLER_INSTALLATION 1 + #else + #define configCHECK_HANDLER_INSTALLATION 0 + #endif +#else + #if ( configCHECK_HANDLER_INSTALLATION == 1 && configASSERT_DEFINED == 0 ) + #error You must define configASSERT() when configCHECK_HANDLER_INSTALLATION is 1. + #endif +#endif +/*-----------------------------------------------------------*/ + /** * @brief Tickless idle/low power functionality. */ diff --git a/portable/GCC/ARM_CM35P_NTZ/non_secure/port.c b/portable/GCC/ARM_CM35P_NTZ/non_secure/port.c index 52d68d3eaf..617e0c8689 100644 --- a/portable/GCC/ARM_CM35P_NTZ/non_secure/port.c +++ b/portable/GCC/ARM_CM35P_NTZ/non_secure/port.c @@ -79,6 +79,12 @@ #endif /*-----------------------------------------------------------*/ +/** + * @brief Prototype to which all Interrupt Service Routines conform. + */ +typedef void (* portISR_t)( void ); +/*-----------------------------------------------------------*/ + /** * @brief Constants required to manipulate the NVIC. */ @@ -100,10 +106,18 @@ /** * @brief Constants required to manipulate the SCB. */ -#define portSCB_SYS_HANDLER_CTRL_STATE_REG ( *( volatile uint32_t * ) 0xe000ed24 ) +#define portSCB_VTOR_REG ( *( ( portISR_t ** ) 0xe000ed08 ) ) +#define portSCB_SYS_HANDLER_CTRL_STATE_REG ( *( ( volatile uint32_t * ) 0xe000ed24 ) ) #define portSCB_MEM_FAULT_ENABLE_BIT ( 1UL << 16UL ) /*-----------------------------------------------------------*/ +/** + * @brief Constants used to check the installation of the FreeRTOS interrupt handlers. + */ +#define portVECTOR_INDEX_SVC ( 11 ) +#define portVECTOR_INDEX_PENDSV ( 14 ) +/*-----------------------------------------------------------*/ + /** * @brief Constants required to check the validity of an interrupt priority. */ @@ -1679,22 +1693,44 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ { + /* Applications that route program control to the FreeRTOS interrupt + * handlers through intermediate handlers (indirect routing) should set + * configCHECK_HANDLER_INSTALLATION to 0 in FreeRTOSConfig.h. Direct + * routing, which is validated here when configCHECK_HANDLER_INSTALLATION + * is 1, is preferred when possible. */ + #if ( configCHECK_HANDLER_INSTALLATION == 1 ) + { + const portISR_t * const pxVectorTable = portSCB_VTOR_REG; + + /* Verify correct installation of the FreeRTOS handlers for SVCall and + * PendSV. Do not check the installation of the SysTick handler because + * the application may provide the OS tick without using the SysTick + * timer by overriding the weak function vPortSetupTimerInterrupt(). + * + * Assertion failures here can be caused by incorrect installation of + * the FreeRTOS handlers. For help installing the handlers, see + * https://www.FreeRTOS.org/FAQHelp.html + * + * Systems with a configurable address for the interrupt vector table + * can also encounter assertion failures or even system faults here if + * VTOR is not set correctly to point to the application's vector table. */ + configASSERT( pxVectorTable[ portVECTOR_INDEX_SVC ] == SVC_Handler ); + configASSERT( pxVectorTable[ portVECTOR_INDEX_PENDSV ] == PendSV_Handler ); + } + #endif /* configCHECK_HANDLER_INSTALLATION */ + #if ( ( configASSERT_DEFINED == 1 ) && ( portHAS_ARMV8M_MAIN_EXTENSION == 1 ) ) { - volatile uint32_t ulOriginalPriority; volatile uint32_t ulImplementedPrioBits = 0; volatile uint8_t ucMaxPriorityValue; /* Determine the maximum priority from which ISR safe FreeRTOS API - * functions can be called. ISR safe functions are those that end in - * "FromISR". FreeRTOS maintains separate thread and ISR API functions to + * functions can be called. ISR safe functions are those that end in + * "FromISR". FreeRTOS maintains separate thread and ISR API functions to * ensure interrupt entry is as fast and simple as possible. * - * Save the interrupt priority value that is about to be clobbered. */ - ulOriginalPriority = portNVIC_SHPR2_REG; - - /* Determine the number of priority bits available. First write to all - * possible bits. */ + * First, determine the number of priority bits available. Write to all + * possible bits in the priority setting for SVCall. */ portNVIC_SHPR2_REG = 0xFF000000; /* Read the value back to see how many bits stuck. */ @@ -1717,7 +1753,6 @@ BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ /* Calculate the maximum acceptable priority group value for the number * of bits read back. */ - while( ( ucMaxPriorityValue & portTOP_BIT_OF_BYTE ) == portTOP_BIT_OF_BYTE ) { ulImplementedPrioBits++; @@ -1755,16 +1790,14 @@ BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ * register. */ ulMaxPRIGROUPValue <<= portPRIGROUP_SHIFT; ulMaxPRIGROUPValue &= portPRIORITY_GROUP_MASK; - - /* Restore the clobbered interrupt priority register to its original - * value. */ - portNVIC_SHPR2_REG = ulOriginalPriority; } #endif /* #if ( ( configASSERT_DEFINED == 1 ) && ( portHAS_ARMV8M_MAIN_EXTENSION == 1 ) ) */ - /* Make PendSV, CallSV and SysTick the same priority as the kernel. */ + /* Make PendSV and SysTick the lowest priority interrupts, and make SVCall + * the highest priority. */ portNVIC_SHPR3_REG |= portNVIC_PENDSV_PRI; portNVIC_SHPR3_REG |= portNVIC_SYSTICK_PRI; + portNVIC_SHPR2_REG = 0; #if ( configENABLE_MPU == 1 ) { diff --git a/portable/GCC/ARM_CM35P_NTZ/non_secure/portmacrocommon.h b/portable/GCC/ARM_CM35P_NTZ/non_secure/portmacrocommon.h index 60ef37380a..083eea5cf0 100644 --- a/portable/GCC/ARM_CM35P_NTZ/non_secure/portmacrocommon.h +++ b/portable/GCC/ARM_CM35P_NTZ/non_secure/portmacrocommon.h @@ -370,6 +370,20 @@ extern void vClearInterruptMask( uint32_t ulMask ) /* __attribute__(( naked )) P #define portEXIT_CRITICAL() vPortExitCritical() /*-----------------------------------------------------------*/ +/* Runtime checks on port configuration */ +#ifndef configCHECK_HANDLER_INSTALLATION + #if ( configASSERT_DEFINED == 1 ) + #define configCHECK_HANDLER_INSTALLATION 1 + #else + #define configCHECK_HANDLER_INSTALLATION 0 + #endif +#else + #if ( configCHECK_HANDLER_INSTALLATION == 1 && configASSERT_DEFINED == 0 ) + #error You must define configASSERT() when configCHECK_HANDLER_INSTALLATION is 1. + #endif +#endif +/*-----------------------------------------------------------*/ + /** * @brief Tickless idle/low power functionality. */ diff --git a/portable/GCC/ARM_CM3_MPU/port.c b/portable/GCC/ARM_CM3_MPU/port.c index ea2b9355e2..916b84e823 100644 --- a/portable/GCC/ARM_CM3_MPU/port.c +++ b/portable/GCC/ARM_CM3_MPU/port.c @@ -57,6 +57,9 @@ #define configALLOW_UNPRIVILEGED_CRITICAL_SECTIONS 1 #endif +/* Prototype to which all Interrupt Service Routines conform. */ +typedef void (* portISR_t)( void ); + /* Constants required to access and manipulate the NVIC. */ #define portNVIC_SYSTICK_CTRL_REG ( *( ( volatile uint32_t * ) 0xe000e010 ) ) #define portNVIC_SYSTICK_LOAD_REG ( *( ( volatile uint32_t * ) 0xe000e014 ) ) @@ -94,6 +97,11 @@ #define portINITIAL_CONTROL_IF_UNPRIVILEGED ( 0x03 ) #define portINITIAL_CONTROL_IF_PRIVILEGED ( 0x02 ) +/* Constants used to check the installation of the FreeRTOS interrupt handlers. */ +#define portSCB_VTOR_REG ( *( ( portISR_t ** ) 0xE000ED08 ) ) +#define portVECTOR_INDEX_SVC ( 11 ) +#define portVECTOR_INDEX_PENDSV ( 14 ) + /* Constants required to check the validity of an interrupt priority. */ #define portFIRST_USER_INTERRUPT_NUMBER ( 16 ) #define portNVIC_IP_REGISTERS_OFFSET_16 ( 0xE000E3F0 ) @@ -787,6 +795,32 @@ static void prvRestoreContextOfFirstTask( void ) */ BaseType_t xPortStartScheduler( void ) { + /* Applications that route program control to the FreeRTOS interrupt + * handlers through intermediate handlers (indirect routing) should set + * configCHECK_HANDLER_INSTALLATION to 0 in FreeRTOSConfig.h. Direct + * routing, which is validated here when configCHECK_HANDLER_INSTALLATION + * is 1, is preferred when possible. */ + #if ( configCHECK_HANDLER_INSTALLATION == 1 ) + { + const portISR_t * const pxVectorTable = portSCB_VTOR_REG; + + /* Verify correct installation of the FreeRTOS handlers for SVCall and + * PendSV. Do not check the installation of the SysTick handler because + * the application may provide the OS tick without using the SysTick + * timer by overriding the weak function vPortSetupTimerInterrupt(). + * + * Assertion failures here can be caused by incorrect installation of + * the FreeRTOS handlers. For help installing the handlers, see + * https://www.FreeRTOS.org/FAQHelp.html + * + * Systems with a configurable address for the interrupt vector table + * can also encounter assertion failures or even system faults here if + * VTOR is not set correctly to point to the application's vector table. */ + configASSERT( pxVectorTable[ portVECTOR_INDEX_SVC ] == vPortSVCHandler ); + configASSERT( pxVectorTable[ portVECTOR_INDEX_PENDSV ] == xPortPendSVHandler ); + } + #endif /* configCHECK_HANDLER_INSTALLATION */ + #if ( configASSERT_DEFINED == 1 ) { volatile uint8_t ucOriginalPriority; diff --git a/portable/GCC/ARM_CM3_MPU/portmacro.h b/portable/GCC/ARM_CM3_MPU/portmacro.h index d0822e1443..bdb528f802 100644 --- a/portable/GCC/ARM_CM3_MPU/portmacro.h +++ b/portable/GCC/ARM_CM3_MPU/portmacro.h @@ -215,6 +215,20 @@ extern void vPortExitCritical( void ); #define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void * pvParameters ) /*-----------------------------------------------------------*/ +/* Runtime checks on port configuration */ +#ifndef configCHECK_HANDLER_INSTALLATION + #if ( configASSERT_DEFINED == 1 ) + #define configCHECK_HANDLER_INSTALLATION 1 + #else + #define configCHECK_HANDLER_INSTALLATION 0 + #endif +#else + #if ( configCHECK_HANDLER_INSTALLATION == 1 && configASSERT_DEFINED == 0 ) + #error You must define configASSERT() when configCHECK_HANDLER_INSTALLATION is 1. + #endif +#endif +/*-----------------------------------------------------------*/ + /* Architecture specific optimisations. */ #ifndef configUSE_PORT_OPTIMISED_TASK_SELECTION #define configUSE_PORT_OPTIMISED_TASK_SELECTION 1 diff --git a/portable/GCC/ARM_CM4F/portmacro.h b/portable/GCC/ARM_CM4F/portmacro.h index 956f9ed0b7..25089af391 100644 --- a/portable/GCC/ARM_CM4F/portmacro.h +++ b/portable/GCC/ARM_CM4F/portmacro.h @@ -133,7 +133,7 @@ extern void vPortExitCritical( void ); #define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void * pvParameters ) /*-----------------------------------------------------------*/ -/* Runtime Checks on Port Configuration */ +/* Runtime checks on port configuration */ #ifndef configCHECK_HANDLER_INSTALLATION #if ( configASSERT_DEFINED == 1 ) #define configCHECK_HANDLER_INSTALLATION 1 diff --git a/portable/GCC/ARM_CM4_MPU/port.c b/portable/GCC/ARM_CM4_MPU/port.c index e2ef1f054b..710838d4a3 100644 --- a/portable/GCC/ARM_CM4_MPU/port.c +++ b/portable/GCC/ARM_CM4_MPU/port.c @@ -61,6 +61,9 @@ #define configALLOW_UNPRIVILEGED_CRITICAL_SECTIONS 1 #endif +/* Prototype to which all Interrupt Service Routines conform. */ +typedef void (* portISR_t)( void ); + /* Constants required to access and manipulate the NVIC. */ #define portNVIC_SYSTICK_CTRL_REG ( *( ( volatile uint32_t * ) 0xe000e010 ) ) #define portNVIC_SYSTICK_LOAD_REG ( *( ( volatile uint32_t * ) 0xe000e014 ) ) @@ -108,6 +111,11 @@ #define portINITIAL_CONTROL_IF_UNPRIVILEGED ( 0x03 ) #define portINITIAL_CONTROL_IF_PRIVILEGED ( 0x02 ) +/* Constants used to check the installation of the FreeRTOS interrupt handlers. */ +#define portSCB_VTOR_REG ( *( ( portISR_t ** ) 0xE000ED08 ) ) +#define portVECTOR_INDEX_SVC ( 11 ) +#define portVECTOR_INDEX_PENDSV ( 14 ) + /* Constants required to check the validity of an interrupt priority. */ #define portFIRST_USER_INTERRUPT_NUMBER ( 16 ) #define portNVIC_IP_REGISTERS_OFFSET_16 ( 0xE000E3F0 ) @@ -895,6 +903,32 @@ BaseType_t xPortStartScheduler( void ) configASSERT( portCPUID != portCORTEX_M7_r0p0_ID ); #endif + /* Applications that route program control to the FreeRTOS interrupt + * handlers through intermediate handlers (indirect routing) should set + * configCHECK_HANDLER_INSTALLATION to 0 in FreeRTOSConfig.h. Direct + * routing, which is validated here when configCHECK_HANDLER_INSTALLATION + * is 1, is preferred when possible. */ + #if ( configCHECK_HANDLER_INSTALLATION == 1 ) + { + const portISR_t * const pxVectorTable = portSCB_VTOR_REG; + + /* Verify correct installation of the FreeRTOS handlers for SVCall and + * PendSV. Do not check the installation of the SysTick handler because + * the application may provide the OS tick without using the SysTick + * timer by overriding the weak function vPortSetupTimerInterrupt(). + * + * Assertion failures here can be caused by incorrect installation of + * the FreeRTOS handlers. For help installing the handlers, see + * https://www.FreeRTOS.org/FAQHelp.html + * + * Systems with a configurable address for the interrupt vector table + * can also encounter assertion failures or even system faults here if + * VTOR is not set correctly to point to the application's vector table. */ + configASSERT( pxVectorTable[ portVECTOR_INDEX_SVC ] == vPortSVCHandler ); + configASSERT( pxVectorTable[ portVECTOR_INDEX_PENDSV ] == xPortPendSVHandler ); + } + #endif /* configCHECK_HANDLER_INSTALLATION */ + #if ( configASSERT_DEFINED == 1 ) { volatile uint8_t ucOriginalPriority; diff --git a/portable/GCC/ARM_CM4_MPU/portmacro.h b/portable/GCC/ARM_CM4_MPU/portmacro.h index 1f62279b04..c532ce2781 100644 --- a/portable/GCC/ARM_CM4_MPU/portmacro.h +++ b/portable/GCC/ARM_CM4_MPU/portmacro.h @@ -309,6 +309,20 @@ extern void vPortExitCritical( void ); #define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void * pvParameters ) /*-----------------------------------------------------------*/ +/* Runtime checks on port configuration */ +#ifndef configCHECK_HANDLER_INSTALLATION + #if ( configASSERT_DEFINED == 1 ) + #define configCHECK_HANDLER_INSTALLATION 1 + #else + #define configCHECK_HANDLER_INSTALLATION 0 + #endif +#else + #if ( configCHECK_HANDLER_INSTALLATION == 1 && configASSERT_DEFINED == 0 ) + #error You must define configASSERT() when configCHECK_HANDLER_INSTALLATION is 1. + #endif +#endif +/*-----------------------------------------------------------*/ + /* Architecture specific optimisations. */ #ifndef configUSE_PORT_OPTIMISED_TASK_SELECTION #define configUSE_PORT_OPTIMISED_TASK_SELECTION 1 diff --git a/portable/GCC/ARM_CM55/non_secure/port.c b/portable/GCC/ARM_CM55/non_secure/port.c index 52d68d3eaf..617e0c8689 100644 --- a/portable/GCC/ARM_CM55/non_secure/port.c +++ b/portable/GCC/ARM_CM55/non_secure/port.c @@ -79,6 +79,12 @@ #endif /*-----------------------------------------------------------*/ +/** + * @brief Prototype to which all Interrupt Service Routines conform. + */ +typedef void (* portISR_t)( void ); +/*-----------------------------------------------------------*/ + /** * @brief Constants required to manipulate the NVIC. */ @@ -100,10 +106,18 @@ /** * @brief Constants required to manipulate the SCB. */ -#define portSCB_SYS_HANDLER_CTRL_STATE_REG ( *( volatile uint32_t * ) 0xe000ed24 ) +#define portSCB_VTOR_REG ( *( ( portISR_t ** ) 0xe000ed08 ) ) +#define portSCB_SYS_HANDLER_CTRL_STATE_REG ( *( ( volatile uint32_t * ) 0xe000ed24 ) ) #define portSCB_MEM_FAULT_ENABLE_BIT ( 1UL << 16UL ) /*-----------------------------------------------------------*/ +/** + * @brief Constants used to check the installation of the FreeRTOS interrupt handlers. + */ +#define portVECTOR_INDEX_SVC ( 11 ) +#define portVECTOR_INDEX_PENDSV ( 14 ) +/*-----------------------------------------------------------*/ + /** * @brief Constants required to check the validity of an interrupt priority. */ @@ -1679,22 +1693,44 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ { + /* Applications that route program control to the FreeRTOS interrupt + * handlers through intermediate handlers (indirect routing) should set + * configCHECK_HANDLER_INSTALLATION to 0 in FreeRTOSConfig.h. Direct + * routing, which is validated here when configCHECK_HANDLER_INSTALLATION + * is 1, is preferred when possible. */ + #if ( configCHECK_HANDLER_INSTALLATION == 1 ) + { + const portISR_t * const pxVectorTable = portSCB_VTOR_REG; + + /* Verify correct installation of the FreeRTOS handlers for SVCall and + * PendSV. Do not check the installation of the SysTick handler because + * the application may provide the OS tick without using the SysTick + * timer by overriding the weak function vPortSetupTimerInterrupt(). + * + * Assertion failures here can be caused by incorrect installation of + * the FreeRTOS handlers. For help installing the handlers, see + * https://www.FreeRTOS.org/FAQHelp.html + * + * Systems with a configurable address for the interrupt vector table + * can also encounter assertion failures or even system faults here if + * VTOR is not set correctly to point to the application's vector table. */ + configASSERT( pxVectorTable[ portVECTOR_INDEX_SVC ] == SVC_Handler ); + configASSERT( pxVectorTable[ portVECTOR_INDEX_PENDSV ] == PendSV_Handler ); + } + #endif /* configCHECK_HANDLER_INSTALLATION */ + #if ( ( configASSERT_DEFINED == 1 ) && ( portHAS_ARMV8M_MAIN_EXTENSION == 1 ) ) { - volatile uint32_t ulOriginalPriority; volatile uint32_t ulImplementedPrioBits = 0; volatile uint8_t ucMaxPriorityValue; /* Determine the maximum priority from which ISR safe FreeRTOS API - * functions can be called. ISR safe functions are those that end in - * "FromISR". FreeRTOS maintains separate thread and ISR API functions to + * functions can be called. ISR safe functions are those that end in + * "FromISR". FreeRTOS maintains separate thread and ISR API functions to * ensure interrupt entry is as fast and simple as possible. * - * Save the interrupt priority value that is about to be clobbered. */ - ulOriginalPriority = portNVIC_SHPR2_REG; - - /* Determine the number of priority bits available. First write to all - * possible bits. */ + * First, determine the number of priority bits available. Write to all + * possible bits in the priority setting for SVCall. */ portNVIC_SHPR2_REG = 0xFF000000; /* Read the value back to see how many bits stuck. */ @@ -1717,7 +1753,6 @@ BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ /* Calculate the maximum acceptable priority group value for the number * of bits read back. */ - while( ( ucMaxPriorityValue & portTOP_BIT_OF_BYTE ) == portTOP_BIT_OF_BYTE ) { ulImplementedPrioBits++; @@ -1755,16 +1790,14 @@ BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ * register. */ ulMaxPRIGROUPValue <<= portPRIGROUP_SHIFT; ulMaxPRIGROUPValue &= portPRIORITY_GROUP_MASK; - - /* Restore the clobbered interrupt priority register to its original - * value. */ - portNVIC_SHPR2_REG = ulOriginalPriority; } #endif /* #if ( ( configASSERT_DEFINED == 1 ) && ( portHAS_ARMV8M_MAIN_EXTENSION == 1 ) ) */ - /* Make PendSV, CallSV and SysTick the same priority as the kernel. */ + /* Make PendSV and SysTick the lowest priority interrupts, and make SVCall + * the highest priority. */ portNVIC_SHPR3_REG |= portNVIC_PENDSV_PRI; portNVIC_SHPR3_REG |= portNVIC_SYSTICK_PRI; + portNVIC_SHPR2_REG = 0; #if ( configENABLE_MPU == 1 ) { diff --git a/portable/GCC/ARM_CM55/non_secure/portmacrocommon.h b/portable/GCC/ARM_CM55/non_secure/portmacrocommon.h index 60ef37380a..083eea5cf0 100644 --- a/portable/GCC/ARM_CM55/non_secure/portmacrocommon.h +++ b/portable/GCC/ARM_CM55/non_secure/portmacrocommon.h @@ -370,6 +370,20 @@ extern void vClearInterruptMask( uint32_t ulMask ) /* __attribute__(( naked )) P #define portEXIT_CRITICAL() vPortExitCritical() /*-----------------------------------------------------------*/ +/* Runtime checks on port configuration */ +#ifndef configCHECK_HANDLER_INSTALLATION + #if ( configASSERT_DEFINED == 1 ) + #define configCHECK_HANDLER_INSTALLATION 1 + #else + #define configCHECK_HANDLER_INSTALLATION 0 + #endif +#else + #if ( configCHECK_HANDLER_INSTALLATION == 1 && configASSERT_DEFINED == 0 ) + #error You must define configASSERT() when configCHECK_HANDLER_INSTALLATION is 1. + #endif +#endif +/*-----------------------------------------------------------*/ + /** * @brief Tickless idle/low power functionality. */ diff --git a/portable/GCC/ARM_CM55_NTZ/non_secure/port.c b/portable/GCC/ARM_CM55_NTZ/non_secure/port.c index 52d68d3eaf..617e0c8689 100644 --- a/portable/GCC/ARM_CM55_NTZ/non_secure/port.c +++ b/portable/GCC/ARM_CM55_NTZ/non_secure/port.c @@ -79,6 +79,12 @@ #endif /*-----------------------------------------------------------*/ +/** + * @brief Prototype to which all Interrupt Service Routines conform. + */ +typedef void (* portISR_t)( void ); +/*-----------------------------------------------------------*/ + /** * @brief Constants required to manipulate the NVIC. */ @@ -100,10 +106,18 @@ /** * @brief Constants required to manipulate the SCB. */ -#define portSCB_SYS_HANDLER_CTRL_STATE_REG ( *( volatile uint32_t * ) 0xe000ed24 ) +#define portSCB_VTOR_REG ( *( ( portISR_t ** ) 0xe000ed08 ) ) +#define portSCB_SYS_HANDLER_CTRL_STATE_REG ( *( ( volatile uint32_t * ) 0xe000ed24 ) ) #define portSCB_MEM_FAULT_ENABLE_BIT ( 1UL << 16UL ) /*-----------------------------------------------------------*/ +/** + * @brief Constants used to check the installation of the FreeRTOS interrupt handlers. + */ +#define portVECTOR_INDEX_SVC ( 11 ) +#define portVECTOR_INDEX_PENDSV ( 14 ) +/*-----------------------------------------------------------*/ + /** * @brief Constants required to check the validity of an interrupt priority. */ @@ -1679,22 +1693,44 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ { + /* Applications that route program control to the FreeRTOS interrupt + * handlers through intermediate handlers (indirect routing) should set + * configCHECK_HANDLER_INSTALLATION to 0 in FreeRTOSConfig.h. Direct + * routing, which is validated here when configCHECK_HANDLER_INSTALLATION + * is 1, is preferred when possible. */ + #if ( configCHECK_HANDLER_INSTALLATION == 1 ) + { + const portISR_t * const pxVectorTable = portSCB_VTOR_REG; + + /* Verify correct installation of the FreeRTOS handlers for SVCall and + * PendSV. Do not check the installation of the SysTick handler because + * the application may provide the OS tick without using the SysTick + * timer by overriding the weak function vPortSetupTimerInterrupt(). + * + * Assertion failures here can be caused by incorrect installation of + * the FreeRTOS handlers. For help installing the handlers, see + * https://www.FreeRTOS.org/FAQHelp.html + * + * Systems with a configurable address for the interrupt vector table + * can also encounter assertion failures or even system faults here if + * VTOR is not set correctly to point to the application's vector table. */ + configASSERT( pxVectorTable[ portVECTOR_INDEX_SVC ] == SVC_Handler ); + configASSERT( pxVectorTable[ portVECTOR_INDEX_PENDSV ] == PendSV_Handler ); + } + #endif /* configCHECK_HANDLER_INSTALLATION */ + #if ( ( configASSERT_DEFINED == 1 ) && ( portHAS_ARMV8M_MAIN_EXTENSION == 1 ) ) { - volatile uint32_t ulOriginalPriority; volatile uint32_t ulImplementedPrioBits = 0; volatile uint8_t ucMaxPriorityValue; /* Determine the maximum priority from which ISR safe FreeRTOS API - * functions can be called. ISR safe functions are those that end in - * "FromISR". FreeRTOS maintains separate thread and ISR API functions to + * functions can be called. ISR safe functions are those that end in + * "FromISR". FreeRTOS maintains separate thread and ISR API functions to * ensure interrupt entry is as fast and simple as possible. * - * Save the interrupt priority value that is about to be clobbered. */ - ulOriginalPriority = portNVIC_SHPR2_REG; - - /* Determine the number of priority bits available. First write to all - * possible bits. */ + * First, determine the number of priority bits available. Write to all + * possible bits in the priority setting for SVCall. */ portNVIC_SHPR2_REG = 0xFF000000; /* Read the value back to see how many bits stuck. */ @@ -1717,7 +1753,6 @@ BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ /* Calculate the maximum acceptable priority group value for the number * of bits read back. */ - while( ( ucMaxPriorityValue & portTOP_BIT_OF_BYTE ) == portTOP_BIT_OF_BYTE ) { ulImplementedPrioBits++; @@ -1755,16 +1790,14 @@ BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ * register. */ ulMaxPRIGROUPValue <<= portPRIGROUP_SHIFT; ulMaxPRIGROUPValue &= portPRIORITY_GROUP_MASK; - - /* Restore the clobbered interrupt priority register to its original - * value. */ - portNVIC_SHPR2_REG = ulOriginalPriority; } #endif /* #if ( ( configASSERT_DEFINED == 1 ) && ( portHAS_ARMV8M_MAIN_EXTENSION == 1 ) ) */ - /* Make PendSV, CallSV and SysTick the same priority as the kernel. */ + /* Make PendSV and SysTick the lowest priority interrupts, and make SVCall + * the highest priority. */ portNVIC_SHPR3_REG |= portNVIC_PENDSV_PRI; portNVIC_SHPR3_REG |= portNVIC_SYSTICK_PRI; + portNVIC_SHPR2_REG = 0; #if ( configENABLE_MPU == 1 ) { diff --git a/portable/GCC/ARM_CM55_NTZ/non_secure/portmacrocommon.h b/portable/GCC/ARM_CM55_NTZ/non_secure/portmacrocommon.h index 60ef37380a..083eea5cf0 100644 --- a/portable/GCC/ARM_CM55_NTZ/non_secure/portmacrocommon.h +++ b/portable/GCC/ARM_CM55_NTZ/non_secure/portmacrocommon.h @@ -370,6 +370,20 @@ extern void vClearInterruptMask( uint32_t ulMask ) /* __attribute__(( naked )) P #define portEXIT_CRITICAL() vPortExitCritical() /*-----------------------------------------------------------*/ +/* Runtime checks on port configuration */ +#ifndef configCHECK_HANDLER_INSTALLATION + #if ( configASSERT_DEFINED == 1 ) + #define configCHECK_HANDLER_INSTALLATION 1 + #else + #define configCHECK_HANDLER_INSTALLATION 0 + #endif +#else + #if ( configCHECK_HANDLER_INSTALLATION == 1 && configASSERT_DEFINED == 0 ) + #error You must define configASSERT() when configCHECK_HANDLER_INSTALLATION is 1. + #endif +#endif +/*-----------------------------------------------------------*/ + /** * @brief Tickless idle/low power functionality. */ diff --git a/portable/GCC/ARM_CM85/non_secure/port.c b/portable/GCC/ARM_CM85/non_secure/port.c index 52d68d3eaf..617e0c8689 100644 --- a/portable/GCC/ARM_CM85/non_secure/port.c +++ b/portable/GCC/ARM_CM85/non_secure/port.c @@ -79,6 +79,12 @@ #endif /*-----------------------------------------------------------*/ +/** + * @brief Prototype to which all Interrupt Service Routines conform. + */ +typedef void (* portISR_t)( void ); +/*-----------------------------------------------------------*/ + /** * @brief Constants required to manipulate the NVIC. */ @@ -100,10 +106,18 @@ /** * @brief Constants required to manipulate the SCB. */ -#define portSCB_SYS_HANDLER_CTRL_STATE_REG ( *( volatile uint32_t * ) 0xe000ed24 ) +#define portSCB_VTOR_REG ( *( ( portISR_t ** ) 0xe000ed08 ) ) +#define portSCB_SYS_HANDLER_CTRL_STATE_REG ( *( ( volatile uint32_t * ) 0xe000ed24 ) ) #define portSCB_MEM_FAULT_ENABLE_BIT ( 1UL << 16UL ) /*-----------------------------------------------------------*/ +/** + * @brief Constants used to check the installation of the FreeRTOS interrupt handlers. + */ +#define portVECTOR_INDEX_SVC ( 11 ) +#define portVECTOR_INDEX_PENDSV ( 14 ) +/*-----------------------------------------------------------*/ + /** * @brief Constants required to check the validity of an interrupt priority. */ @@ -1679,22 +1693,44 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ { + /* Applications that route program control to the FreeRTOS interrupt + * handlers through intermediate handlers (indirect routing) should set + * configCHECK_HANDLER_INSTALLATION to 0 in FreeRTOSConfig.h. Direct + * routing, which is validated here when configCHECK_HANDLER_INSTALLATION + * is 1, is preferred when possible. */ + #if ( configCHECK_HANDLER_INSTALLATION == 1 ) + { + const portISR_t * const pxVectorTable = portSCB_VTOR_REG; + + /* Verify correct installation of the FreeRTOS handlers for SVCall and + * PendSV. Do not check the installation of the SysTick handler because + * the application may provide the OS tick without using the SysTick + * timer by overriding the weak function vPortSetupTimerInterrupt(). + * + * Assertion failures here can be caused by incorrect installation of + * the FreeRTOS handlers. For help installing the handlers, see + * https://www.FreeRTOS.org/FAQHelp.html + * + * Systems with a configurable address for the interrupt vector table + * can also encounter assertion failures or even system faults here if + * VTOR is not set correctly to point to the application's vector table. */ + configASSERT( pxVectorTable[ portVECTOR_INDEX_SVC ] == SVC_Handler ); + configASSERT( pxVectorTable[ portVECTOR_INDEX_PENDSV ] == PendSV_Handler ); + } + #endif /* configCHECK_HANDLER_INSTALLATION */ + #if ( ( configASSERT_DEFINED == 1 ) && ( portHAS_ARMV8M_MAIN_EXTENSION == 1 ) ) { - volatile uint32_t ulOriginalPriority; volatile uint32_t ulImplementedPrioBits = 0; volatile uint8_t ucMaxPriorityValue; /* Determine the maximum priority from which ISR safe FreeRTOS API - * functions can be called. ISR safe functions are those that end in - * "FromISR". FreeRTOS maintains separate thread and ISR API functions to + * functions can be called. ISR safe functions are those that end in + * "FromISR". FreeRTOS maintains separate thread and ISR API functions to * ensure interrupt entry is as fast and simple as possible. * - * Save the interrupt priority value that is about to be clobbered. */ - ulOriginalPriority = portNVIC_SHPR2_REG; - - /* Determine the number of priority bits available. First write to all - * possible bits. */ + * First, determine the number of priority bits available. Write to all + * possible bits in the priority setting for SVCall. */ portNVIC_SHPR2_REG = 0xFF000000; /* Read the value back to see how many bits stuck. */ @@ -1717,7 +1753,6 @@ BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ /* Calculate the maximum acceptable priority group value for the number * of bits read back. */ - while( ( ucMaxPriorityValue & portTOP_BIT_OF_BYTE ) == portTOP_BIT_OF_BYTE ) { ulImplementedPrioBits++; @@ -1755,16 +1790,14 @@ BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ * register. */ ulMaxPRIGROUPValue <<= portPRIGROUP_SHIFT; ulMaxPRIGROUPValue &= portPRIORITY_GROUP_MASK; - - /* Restore the clobbered interrupt priority register to its original - * value. */ - portNVIC_SHPR2_REG = ulOriginalPriority; } #endif /* #if ( ( configASSERT_DEFINED == 1 ) && ( portHAS_ARMV8M_MAIN_EXTENSION == 1 ) ) */ - /* Make PendSV, CallSV and SysTick the same priority as the kernel. */ + /* Make PendSV and SysTick the lowest priority interrupts, and make SVCall + * the highest priority. */ portNVIC_SHPR3_REG |= portNVIC_PENDSV_PRI; portNVIC_SHPR3_REG |= portNVIC_SYSTICK_PRI; + portNVIC_SHPR2_REG = 0; #if ( configENABLE_MPU == 1 ) { diff --git a/portable/GCC/ARM_CM85/non_secure/portmacrocommon.h b/portable/GCC/ARM_CM85/non_secure/portmacrocommon.h index 60ef37380a..083eea5cf0 100644 --- a/portable/GCC/ARM_CM85/non_secure/portmacrocommon.h +++ b/portable/GCC/ARM_CM85/non_secure/portmacrocommon.h @@ -370,6 +370,20 @@ extern void vClearInterruptMask( uint32_t ulMask ) /* __attribute__(( naked )) P #define portEXIT_CRITICAL() vPortExitCritical() /*-----------------------------------------------------------*/ +/* Runtime checks on port configuration */ +#ifndef configCHECK_HANDLER_INSTALLATION + #if ( configASSERT_DEFINED == 1 ) + #define configCHECK_HANDLER_INSTALLATION 1 + #else + #define configCHECK_HANDLER_INSTALLATION 0 + #endif +#else + #if ( configCHECK_HANDLER_INSTALLATION == 1 && configASSERT_DEFINED == 0 ) + #error You must define configASSERT() when configCHECK_HANDLER_INSTALLATION is 1. + #endif +#endif +/*-----------------------------------------------------------*/ + /** * @brief Tickless idle/low power functionality. */ diff --git a/portable/GCC/ARM_CM85_NTZ/non_secure/port.c b/portable/GCC/ARM_CM85_NTZ/non_secure/port.c index 52d68d3eaf..617e0c8689 100644 --- a/portable/GCC/ARM_CM85_NTZ/non_secure/port.c +++ b/portable/GCC/ARM_CM85_NTZ/non_secure/port.c @@ -79,6 +79,12 @@ #endif /*-----------------------------------------------------------*/ +/** + * @brief Prototype to which all Interrupt Service Routines conform. + */ +typedef void (* portISR_t)( void ); +/*-----------------------------------------------------------*/ + /** * @brief Constants required to manipulate the NVIC. */ @@ -100,10 +106,18 @@ /** * @brief Constants required to manipulate the SCB. */ -#define portSCB_SYS_HANDLER_CTRL_STATE_REG ( *( volatile uint32_t * ) 0xe000ed24 ) +#define portSCB_VTOR_REG ( *( ( portISR_t ** ) 0xe000ed08 ) ) +#define portSCB_SYS_HANDLER_CTRL_STATE_REG ( *( ( volatile uint32_t * ) 0xe000ed24 ) ) #define portSCB_MEM_FAULT_ENABLE_BIT ( 1UL << 16UL ) /*-----------------------------------------------------------*/ +/** + * @brief Constants used to check the installation of the FreeRTOS interrupt handlers. + */ +#define portVECTOR_INDEX_SVC ( 11 ) +#define portVECTOR_INDEX_PENDSV ( 14 ) +/*-----------------------------------------------------------*/ + /** * @brief Constants required to check the validity of an interrupt priority. */ @@ -1679,22 +1693,44 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ { + /* Applications that route program control to the FreeRTOS interrupt + * handlers through intermediate handlers (indirect routing) should set + * configCHECK_HANDLER_INSTALLATION to 0 in FreeRTOSConfig.h. Direct + * routing, which is validated here when configCHECK_HANDLER_INSTALLATION + * is 1, is preferred when possible. */ + #if ( configCHECK_HANDLER_INSTALLATION == 1 ) + { + const portISR_t * const pxVectorTable = portSCB_VTOR_REG; + + /* Verify correct installation of the FreeRTOS handlers for SVCall and + * PendSV. Do not check the installation of the SysTick handler because + * the application may provide the OS tick without using the SysTick + * timer by overriding the weak function vPortSetupTimerInterrupt(). + * + * Assertion failures here can be caused by incorrect installation of + * the FreeRTOS handlers. For help installing the handlers, see + * https://www.FreeRTOS.org/FAQHelp.html + * + * Systems with a configurable address for the interrupt vector table + * can also encounter assertion failures or even system faults here if + * VTOR is not set correctly to point to the application's vector table. */ + configASSERT( pxVectorTable[ portVECTOR_INDEX_SVC ] == SVC_Handler ); + configASSERT( pxVectorTable[ portVECTOR_INDEX_PENDSV ] == PendSV_Handler ); + } + #endif /* configCHECK_HANDLER_INSTALLATION */ + #if ( ( configASSERT_DEFINED == 1 ) && ( portHAS_ARMV8M_MAIN_EXTENSION == 1 ) ) { - volatile uint32_t ulOriginalPriority; volatile uint32_t ulImplementedPrioBits = 0; volatile uint8_t ucMaxPriorityValue; /* Determine the maximum priority from which ISR safe FreeRTOS API - * functions can be called. ISR safe functions are those that end in - * "FromISR". FreeRTOS maintains separate thread and ISR API functions to + * functions can be called. ISR safe functions are those that end in + * "FromISR". FreeRTOS maintains separate thread and ISR API functions to * ensure interrupt entry is as fast and simple as possible. * - * Save the interrupt priority value that is about to be clobbered. */ - ulOriginalPriority = portNVIC_SHPR2_REG; - - /* Determine the number of priority bits available. First write to all - * possible bits. */ + * First, determine the number of priority bits available. Write to all + * possible bits in the priority setting for SVCall. */ portNVIC_SHPR2_REG = 0xFF000000; /* Read the value back to see how many bits stuck. */ @@ -1717,7 +1753,6 @@ BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ /* Calculate the maximum acceptable priority group value for the number * of bits read back. */ - while( ( ucMaxPriorityValue & portTOP_BIT_OF_BYTE ) == portTOP_BIT_OF_BYTE ) { ulImplementedPrioBits++; @@ -1755,16 +1790,14 @@ BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ * register. */ ulMaxPRIGROUPValue <<= portPRIGROUP_SHIFT; ulMaxPRIGROUPValue &= portPRIORITY_GROUP_MASK; - - /* Restore the clobbered interrupt priority register to its original - * value. */ - portNVIC_SHPR2_REG = ulOriginalPriority; } #endif /* #if ( ( configASSERT_DEFINED == 1 ) && ( portHAS_ARMV8M_MAIN_EXTENSION == 1 ) ) */ - /* Make PendSV, CallSV and SysTick the same priority as the kernel. */ + /* Make PendSV and SysTick the lowest priority interrupts, and make SVCall + * the highest priority. */ portNVIC_SHPR3_REG |= portNVIC_PENDSV_PRI; portNVIC_SHPR3_REG |= portNVIC_SYSTICK_PRI; + portNVIC_SHPR2_REG = 0; #if ( configENABLE_MPU == 1 ) { diff --git a/portable/GCC/ARM_CM85_NTZ/non_secure/portmacrocommon.h b/portable/GCC/ARM_CM85_NTZ/non_secure/portmacrocommon.h index 60ef37380a..083eea5cf0 100644 --- a/portable/GCC/ARM_CM85_NTZ/non_secure/portmacrocommon.h +++ b/portable/GCC/ARM_CM85_NTZ/non_secure/portmacrocommon.h @@ -370,6 +370,20 @@ extern void vClearInterruptMask( uint32_t ulMask ) /* __attribute__(( naked )) P #define portEXIT_CRITICAL() vPortExitCritical() /*-----------------------------------------------------------*/ +/* Runtime checks on port configuration */ +#ifndef configCHECK_HANDLER_INSTALLATION + #if ( configASSERT_DEFINED == 1 ) + #define configCHECK_HANDLER_INSTALLATION 1 + #else + #define configCHECK_HANDLER_INSTALLATION 0 + #endif +#else + #if ( configCHECK_HANDLER_INSTALLATION == 1 && configASSERT_DEFINED == 0 ) + #error You must define configASSERT() when configCHECK_HANDLER_INSTALLATION is 1. + #endif +#endif +/*-----------------------------------------------------------*/ + /** * @brief Tickless idle/low power functionality. */ diff --git a/portable/IAR/ARM_CM0/port.c b/portable/IAR/ARM_CM0/port.c index f4d77120c0..62c0adcf8e 100644 --- a/portable/IAR/ARM_CM0/port.c +++ b/portable/IAR/ARM_CM0/port.c @@ -37,6 +37,9 @@ #include "FreeRTOS.h" #include "task.h" +/* Prototype to which all Interrupt Service Routines conform. */ +typedef void (* portISR_t)( void ); + /* Constants required to manipulate the NVIC. */ #define portNVIC_SYSTICK_CTRL_REG ( *( ( volatile uint32_t * ) 0xe000e010 ) ) #define portNVIC_SYSTICK_LOAD_REG ( *( ( volatile uint32_t * ) 0xe000e014 ) ) @@ -53,6 +56,10 @@ #define portNVIC_PENDSV_PRI ( portMIN_INTERRUPT_PRIORITY << 16UL ) #define portNVIC_SYSTICK_PRI ( portMIN_INTERRUPT_PRIORITY << 24UL ) +/* Constants used to check the installation of the FreeRTOS interrupt handlers. */ +#define portSCB_VTOR_REG ( *( ( portISR_t ** ) 0xe000ed08 ) ) +#define portVECTOR_INDEX_PENDSV ( 14 ) + /* Constants required to set up the initial stack. */ #define portINITIAL_XPSR ( 0x01000000 ) @@ -168,6 +175,34 @@ static void prvTaskExitError( void ) */ BaseType_t xPortStartScheduler( void ) { + /* Applications that route program control to the FreeRTOS interrupt + * handlers through intermediate handlers (indirect routing) should set + * configCHECK_HANDLER_INSTALLATION to 0 in FreeRTOSConfig.h. Direct + * routing, which is validated here when configCHECK_HANDLER_INSTALLATION + * is 1, is preferred when possible. */ + #if ( configCHECK_HANDLER_INSTALLATION == 1 ) + { + /* Point pxVectorTable at the interrupt vector table. Systems without + * a VTOR register provide the value zero in place of the VTOR register + * and provide the vector table itself at address 0x00000000. */ + const portISR_t * const pxVectorTable = portSCB_VTOR_REG; + + /* Verify correct installation of the FreeRTOS handler for PendSV. Do + * not check the installation of the SysTick handler because the + * application may provide the OS tick without using the SysTick timer + * by overriding the weak function vPortSetupTimerInterrupt(). + * + * Assertion failures here can be caused by incorrect installation of + * the FreeRTOS handlers. For help installing the handlers, see + * https://www.FreeRTOS.org/FAQHelp.html + * + * Systems with a configurable address for the interrupt vector table + * can also encounter assertion failures or even system faults here if + * VTOR is not set correctly to point to the application's vector table. */ + configASSERT( pxVectorTable[ portVECTOR_INDEX_PENDSV ] == xPortPendSVHandler ); + } + #endif /* configCHECK_HANDLER_INSTALLATION */ + /* Make PendSV and SysTick the lowest priority interrupts. */ portNVIC_SHPR3_REG |= portNVIC_PENDSV_PRI; portNVIC_SHPR3_REG |= portNVIC_SYSTICK_PRI; diff --git a/portable/IAR/ARM_CM0/portasm.s b/portable/IAR/ARM_CM0/portasm.s index 768ce41cb8..ede4921353 100644 --- a/portable/IAR/ARM_CM0/portasm.s +++ b/portable/IAR/ARM_CM0/portasm.s @@ -91,15 +91,15 @@ xPortPendSVHandler: vPortSVCHandler; /* This function is no longer used, but retained for backward - compatibility. */ + * compatibility. */ bx lr /*-----------------------------------------------------------*/ vPortStartFirstTask - /* The MSP stack is not reset as, unlike on M3/4 parts, there is no vector - table offset register that can be used to locate the initial stack value. - Not all M0 parts have the application vector table at address 0. */ + /* Don't reset the MSP stack as is done on CM3/4 devices. The vector table + * in some CM0 devices cannot be modified and thus may not hold the + * application's initial MSP value. */ ldr r3, =pxCurrentTCB /* Obtain location of pxCurrentTCB. */ ldr r1, [r3] diff --git a/portable/IAR/ARM_CM0/portmacro.h b/portable/IAR/ARM_CM0/portmacro.h index fa8438fecf..8f4cb30c52 100644 --- a/portable/IAR/ARM_CM0/portmacro.h +++ b/portable/IAR/ARM_CM0/portmacro.h @@ -141,6 +141,20 @@ extern void vClearInterruptMaskFromISR( uint32_t ulMask ); /*-----------------------------------------------------------*/ +/* Runtime checks on port configuration */ +#ifndef configCHECK_HANDLER_INSTALLATION + #if ( configASSERT_DEFINED == 1 ) + #define configCHECK_HANDLER_INSTALLATION 1 + #else + #define configCHECK_HANDLER_INSTALLATION 0 + #endif +#else + #if ( configCHECK_HANDLER_INSTALLATION == 1 && configASSERT_DEFINED == 0 ) + #error You must define configASSERT() when configCHECK_HANDLER_INSTALLATION is 1. + #endif +#endif +/*-----------------------------------------------------------*/ + portFORCE_INLINE static BaseType_t xPortIsInsideInterrupt( void ) { uint32_t ulCurrentInterrupt; diff --git a/portable/IAR/ARM_CM23/non_secure/port.c b/portable/IAR/ARM_CM23/non_secure/port.c index 52d68d3eaf..617e0c8689 100644 --- a/portable/IAR/ARM_CM23/non_secure/port.c +++ b/portable/IAR/ARM_CM23/non_secure/port.c @@ -79,6 +79,12 @@ #endif /*-----------------------------------------------------------*/ +/** + * @brief Prototype to which all Interrupt Service Routines conform. + */ +typedef void (* portISR_t)( void ); +/*-----------------------------------------------------------*/ + /** * @brief Constants required to manipulate the NVIC. */ @@ -100,10 +106,18 @@ /** * @brief Constants required to manipulate the SCB. */ -#define portSCB_SYS_HANDLER_CTRL_STATE_REG ( *( volatile uint32_t * ) 0xe000ed24 ) +#define portSCB_VTOR_REG ( *( ( portISR_t ** ) 0xe000ed08 ) ) +#define portSCB_SYS_HANDLER_CTRL_STATE_REG ( *( ( volatile uint32_t * ) 0xe000ed24 ) ) #define portSCB_MEM_FAULT_ENABLE_BIT ( 1UL << 16UL ) /*-----------------------------------------------------------*/ +/** + * @brief Constants used to check the installation of the FreeRTOS interrupt handlers. + */ +#define portVECTOR_INDEX_SVC ( 11 ) +#define portVECTOR_INDEX_PENDSV ( 14 ) +/*-----------------------------------------------------------*/ + /** * @brief Constants required to check the validity of an interrupt priority. */ @@ -1679,22 +1693,44 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ { + /* Applications that route program control to the FreeRTOS interrupt + * handlers through intermediate handlers (indirect routing) should set + * configCHECK_HANDLER_INSTALLATION to 0 in FreeRTOSConfig.h. Direct + * routing, which is validated here when configCHECK_HANDLER_INSTALLATION + * is 1, is preferred when possible. */ + #if ( configCHECK_HANDLER_INSTALLATION == 1 ) + { + const portISR_t * const pxVectorTable = portSCB_VTOR_REG; + + /* Verify correct installation of the FreeRTOS handlers for SVCall and + * PendSV. Do not check the installation of the SysTick handler because + * the application may provide the OS tick without using the SysTick + * timer by overriding the weak function vPortSetupTimerInterrupt(). + * + * Assertion failures here can be caused by incorrect installation of + * the FreeRTOS handlers. For help installing the handlers, see + * https://www.FreeRTOS.org/FAQHelp.html + * + * Systems with a configurable address for the interrupt vector table + * can also encounter assertion failures or even system faults here if + * VTOR is not set correctly to point to the application's vector table. */ + configASSERT( pxVectorTable[ portVECTOR_INDEX_SVC ] == SVC_Handler ); + configASSERT( pxVectorTable[ portVECTOR_INDEX_PENDSV ] == PendSV_Handler ); + } + #endif /* configCHECK_HANDLER_INSTALLATION */ + #if ( ( configASSERT_DEFINED == 1 ) && ( portHAS_ARMV8M_MAIN_EXTENSION == 1 ) ) { - volatile uint32_t ulOriginalPriority; volatile uint32_t ulImplementedPrioBits = 0; volatile uint8_t ucMaxPriorityValue; /* Determine the maximum priority from which ISR safe FreeRTOS API - * functions can be called. ISR safe functions are those that end in - * "FromISR". FreeRTOS maintains separate thread and ISR API functions to + * functions can be called. ISR safe functions are those that end in + * "FromISR". FreeRTOS maintains separate thread and ISR API functions to * ensure interrupt entry is as fast and simple as possible. * - * Save the interrupt priority value that is about to be clobbered. */ - ulOriginalPriority = portNVIC_SHPR2_REG; - - /* Determine the number of priority bits available. First write to all - * possible bits. */ + * First, determine the number of priority bits available. Write to all + * possible bits in the priority setting for SVCall. */ portNVIC_SHPR2_REG = 0xFF000000; /* Read the value back to see how many bits stuck. */ @@ -1717,7 +1753,6 @@ BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ /* Calculate the maximum acceptable priority group value for the number * of bits read back. */ - while( ( ucMaxPriorityValue & portTOP_BIT_OF_BYTE ) == portTOP_BIT_OF_BYTE ) { ulImplementedPrioBits++; @@ -1755,16 +1790,14 @@ BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ * register. */ ulMaxPRIGROUPValue <<= portPRIGROUP_SHIFT; ulMaxPRIGROUPValue &= portPRIORITY_GROUP_MASK; - - /* Restore the clobbered interrupt priority register to its original - * value. */ - portNVIC_SHPR2_REG = ulOriginalPriority; } #endif /* #if ( ( configASSERT_DEFINED == 1 ) && ( portHAS_ARMV8M_MAIN_EXTENSION == 1 ) ) */ - /* Make PendSV, CallSV and SysTick the same priority as the kernel. */ + /* Make PendSV and SysTick the lowest priority interrupts, and make SVCall + * the highest priority. */ portNVIC_SHPR3_REG |= portNVIC_PENDSV_PRI; portNVIC_SHPR3_REG |= portNVIC_SYSTICK_PRI; + portNVIC_SHPR2_REG = 0; #if ( configENABLE_MPU == 1 ) { diff --git a/portable/IAR/ARM_CM23/non_secure/portmacrocommon.h b/portable/IAR/ARM_CM23/non_secure/portmacrocommon.h index 60ef37380a..083eea5cf0 100644 --- a/portable/IAR/ARM_CM23/non_secure/portmacrocommon.h +++ b/portable/IAR/ARM_CM23/non_secure/portmacrocommon.h @@ -370,6 +370,20 @@ extern void vClearInterruptMask( uint32_t ulMask ) /* __attribute__(( naked )) P #define portEXIT_CRITICAL() vPortExitCritical() /*-----------------------------------------------------------*/ +/* Runtime checks on port configuration */ +#ifndef configCHECK_HANDLER_INSTALLATION + #if ( configASSERT_DEFINED == 1 ) + #define configCHECK_HANDLER_INSTALLATION 1 + #else + #define configCHECK_HANDLER_INSTALLATION 0 + #endif +#else + #if ( configCHECK_HANDLER_INSTALLATION == 1 && configASSERT_DEFINED == 0 ) + #error You must define configASSERT() when configCHECK_HANDLER_INSTALLATION is 1. + #endif +#endif +/*-----------------------------------------------------------*/ + /** * @brief Tickless idle/low power functionality. */ diff --git a/portable/IAR/ARM_CM23_NTZ/non_secure/port.c b/portable/IAR/ARM_CM23_NTZ/non_secure/port.c index 52d68d3eaf..617e0c8689 100644 --- a/portable/IAR/ARM_CM23_NTZ/non_secure/port.c +++ b/portable/IAR/ARM_CM23_NTZ/non_secure/port.c @@ -79,6 +79,12 @@ #endif /*-----------------------------------------------------------*/ +/** + * @brief Prototype to which all Interrupt Service Routines conform. + */ +typedef void (* portISR_t)( void ); +/*-----------------------------------------------------------*/ + /** * @brief Constants required to manipulate the NVIC. */ @@ -100,10 +106,18 @@ /** * @brief Constants required to manipulate the SCB. */ -#define portSCB_SYS_HANDLER_CTRL_STATE_REG ( *( volatile uint32_t * ) 0xe000ed24 ) +#define portSCB_VTOR_REG ( *( ( portISR_t ** ) 0xe000ed08 ) ) +#define portSCB_SYS_HANDLER_CTRL_STATE_REG ( *( ( volatile uint32_t * ) 0xe000ed24 ) ) #define portSCB_MEM_FAULT_ENABLE_BIT ( 1UL << 16UL ) /*-----------------------------------------------------------*/ +/** + * @brief Constants used to check the installation of the FreeRTOS interrupt handlers. + */ +#define portVECTOR_INDEX_SVC ( 11 ) +#define portVECTOR_INDEX_PENDSV ( 14 ) +/*-----------------------------------------------------------*/ + /** * @brief Constants required to check the validity of an interrupt priority. */ @@ -1679,22 +1693,44 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ { + /* Applications that route program control to the FreeRTOS interrupt + * handlers through intermediate handlers (indirect routing) should set + * configCHECK_HANDLER_INSTALLATION to 0 in FreeRTOSConfig.h. Direct + * routing, which is validated here when configCHECK_HANDLER_INSTALLATION + * is 1, is preferred when possible. */ + #if ( configCHECK_HANDLER_INSTALLATION == 1 ) + { + const portISR_t * const pxVectorTable = portSCB_VTOR_REG; + + /* Verify correct installation of the FreeRTOS handlers for SVCall and + * PendSV. Do not check the installation of the SysTick handler because + * the application may provide the OS tick without using the SysTick + * timer by overriding the weak function vPortSetupTimerInterrupt(). + * + * Assertion failures here can be caused by incorrect installation of + * the FreeRTOS handlers. For help installing the handlers, see + * https://www.FreeRTOS.org/FAQHelp.html + * + * Systems with a configurable address for the interrupt vector table + * can also encounter assertion failures or even system faults here if + * VTOR is not set correctly to point to the application's vector table. */ + configASSERT( pxVectorTable[ portVECTOR_INDEX_SVC ] == SVC_Handler ); + configASSERT( pxVectorTable[ portVECTOR_INDEX_PENDSV ] == PendSV_Handler ); + } + #endif /* configCHECK_HANDLER_INSTALLATION */ + #if ( ( configASSERT_DEFINED == 1 ) && ( portHAS_ARMV8M_MAIN_EXTENSION == 1 ) ) { - volatile uint32_t ulOriginalPriority; volatile uint32_t ulImplementedPrioBits = 0; volatile uint8_t ucMaxPriorityValue; /* Determine the maximum priority from which ISR safe FreeRTOS API - * functions can be called. ISR safe functions are those that end in - * "FromISR". FreeRTOS maintains separate thread and ISR API functions to + * functions can be called. ISR safe functions are those that end in + * "FromISR". FreeRTOS maintains separate thread and ISR API functions to * ensure interrupt entry is as fast and simple as possible. * - * Save the interrupt priority value that is about to be clobbered. */ - ulOriginalPriority = portNVIC_SHPR2_REG; - - /* Determine the number of priority bits available. First write to all - * possible bits. */ + * First, determine the number of priority bits available. Write to all + * possible bits in the priority setting for SVCall. */ portNVIC_SHPR2_REG = 0xFF000000; /* Read the value back to see how many bits stuck. */ @@ -1717,7 +1753,6 @@ BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ /* Calculate the maximum acceptable priority group value for the number * of bits read back. */ - while( ( ucMaxPriorityValue & portTOP_BIT_OF_BYTE ) == portTOP_BIT_OF_BYTE ) { ulImplementedPrioBits++; @@ -1755,16 +1790,14 @@ BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ * register. */ ulMaxPRIGROUPValue <<= portPRIGROUP_SHIFT; ulMaxPRIGROUPValue &= portPRIORITY_GROUP_MASK; - - /* Restore the clobbered interrupt priority register to its original - * value. */ - portNVIC_SHPR2_REG = ulOriginalPriority; } #endif /* #if ( ( configASSERT_DEFINED == 1 ) && ( portHAS_ARMV8M_MAIN_EXTENSION == 1 ) ) */ - /* Make PendSV, CallSV and SysTick the same priority as the kernel. */ + /* Make PendSV and SysTick the lowest priority interrupts, and make SVCall + * the highest priority. */ portNVIC_SHPR3_REG |= portNVIC_PENDSV_PRI; portNVIC_SHPR3_REG |= portNVIC_SYSTICK_PRI; + portNVIC_SHPR2_REG = 0; #if ( configENABLE_MPU == 1 ) { diff --git a/portable/IAR/ARM_CM23_NTZ/non_secure/portmacrocommon.h b/portable/IAR/ARM_CM23_NTZ/non_secure/portmacrocommon.h index 60ef37380a..083eea5cf0 100644 --- a/portable/IAR/ARM_CM23_NTZ/non_secure/portmacrocommon.h +++ b/portable/IAR/ARM_CM23_NTZ/non_secure/portmacrocommon.h @@ -370,6 +370,20 @@ extern void vClearInterruptMask( uint32_t ulMask ) /* __attribute__(( naked )) P #define portEXIT_CRITICAL() vPortExitCritical() /*-----------------------------------------------------------*/ +/* Runtime checks on port configuration */ +#ifndef configCHECK_HANDLER_INSTALLATION + #if ( configASSERT_DEFINED == 1 ) + #define configCHECK_HANDLER_INSTALLATION 1 + #else + #define configCHECK_HANDLER_INSTALLATION 0 + #endif +#else + #if ( configCHECK_HANDLER_INSTALLATION == 1 && configASSERT_DEFINED == 0 ) + #error You must define configASSERT() when configCHECK_HANDLER_INSTALLATION is 1. + #endif +#endif +/*-----------------------------------------------------------*/ + /** * @brief Tickless idle/low power functionality. */ diff --git a/portable/IAR/ARM_CM3/port.c b/portable/IAR/ARM_CM3/port.c index 1fbe96d44f..91fe02fe53 100644 --- a/portable/IAR/ARM_CM3/port.c +++ b/portable/IAR/ARM_CM3/port.c @@ -41,10 +41,14 @@ #error configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to 0. See http: /*www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */ #endif +/* Prototype to which all Interrupt Service Routines conform. */ +typedef void (* portISR_t)( void ); + /* Constants required to manipulate the core. Registers first... */ #define portNVIC_SYSTICK_CTRL_REG ( *( ( volatile uint32_t * ) 0xe000e010 ) ) #define portNVIC_SYSTICK_LOAD_REG ( *( ( volatile uint32_t * ) 0xe000e014 ) ) #define portNVIC_SYSTICK_CURRENT_VALUE_REG ( *( ( volatile uint32_t * ) 0xe000e018 ) ) +#define portNVIC_SHPR2_REG ( *( ( volatile uint32_t * ) 0xe000ed1c ) ) #define portNVIC_SHPR3_REG ( *( ( volatile uint32_t * ) 0xe000ed20 ) ) /* ...then bits in the registers. */ #define portNVIC_SYSTICK_CLK_BIT ( 1UL << 2UL ) @@ -59,6 +63,11 @@ #define portNVIC_PENDSV_PRI ( ( ( uint32_t ) portMIN_INTERRUPT_PRIORITY ) << 16UL ) #define portNVIC_SYSTICK_PRI ( ( ( uint32_t ) portMIN_INTERRUPT_PRIORITY ) << 24UL ) +/* Constants used to check the installation of the FreeRTOS interrupt handlers. */ +#define portSCB_VTOR_REG ( *( ( portISR_t ** ) 0xE000ED08 ) ) +#define portVECTOR_INDEX_SVC ( 11 ) +#define portVECTOR_INDEX_PENDSV ( 14 ) + /* Constants required to check the validity of an interrupt priority. */ #define portFIRST_USER_INTERRUPT_NUMBER ( 16 ) #define portNVIC_IP_REGISTERS_OFFSET_16 ( 0xE000E3F0 ) @@ -208,6 +217,32 @@ static void prvTaskExitError( void ) */ BaseType_t xPortStartScheduler( void ) { + /* Applications that route program control to the FreeRTOS interrupt + * handlers through intermediate handlers (indirect routing) should set + * configCHECK_HANDLER_INSTALLATION to 0 in FreeRTOSConfig.h. Direct + * routing, which is validated here when configCHECK_HANDLER_INSTALLATION + * is 1, is preferred when possible. */ + #if ( configCHECK_HANDLER_INSTALLATION == 1 ) + { + const portISR_t * const pxVectorTable = portSCB_VTOR_REG; + + /* Verify correct installation of the FreeRTOS handlers for SVCall and + * PendSV. Do not check the installation of the SysTick handler because + * the application may provide the OS tick without using the SysTick + * timer by overriding the weak function vPortSetupTimerInterrupt(). + * + * Assertion failures here can be caused by incorrect installation of + * the FreeRTOS handlers. For help installing the handlers, see + * https://www.FreeRTOS.org/FAQHelp.html + * + * Systems with a configurable address for the interrupt vector table + * can also encounter assertion failures or even system faults here if + * VTOR is not set correctly to point to the application's vector table. */ + configASSERT( pxVectorTable[ portVECTOR_INDEX_SVC ] == vPortSVCHandler ); + configASSERT( pxVectorTable[ portVECTOR_INDEX_PENDSV ] == xPortPendSVHandler ); + } + #endif /* configCHECK_HANDLER_INSTALLATION */ + #if ( configASSERT_DEFINED == 1 ) { volatile uint8_t ucOriginalPriority; @@ -292,9 +327,11 @@ BaseType_t xPortStartScheduler( void ) } #endif /* configASSERT_DEFINED */ - /* Make PendSV and SysTick the lowest priority interrupts. */ + /* Make PendSV and SysTick the lowest priority interrupts, and make SVCall + * the highest priority. */ portNVIC_SHPR3_REG |= portNVIC_PENDSV_PRI; portNVIC_SHPR3_REG |= portNVIC_SYSTICK_PRI; + portNVIC_SHPR2_REG = 0; /* Start the timer that generates the tick ISR. Interrupts are disabled * here already. */ diff --git a/portable/IAR/ARM_CM3/portmacro.h b/portable/IAR/ARM_CM3/portmacro.h index c90a952e2b..cf1aaa668e 100644 --- a/portable/IAR/ARM_CM3/portmacro.h +++ b/portable/IAR/ARM_CM3/portmacro.h @@ -173,6 +173,20 @@ extern void vPortExitCritical( void ); #define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void * pvParameters ) /*-----------------------------------------------------------*/ +/* Runtime checks on port configuration */ +#ifndef configCHECK_HANDLER_INSTALLATION + #if ( configASSERT_DEFINED == 1 ) + #define configCHECK_HANDLER_INSTALLATION 1 + #else + #define configCHECK_HANDLER_INSTALLATION 0 + #endif +#else + #if ( configCHECK_HANDLER_INSTALLATION == 1 && configASSERT_DEFINED == 0 ) + #error You must define configASSERT() when configCHECK_HANDLER_INSTALLATION is 1. + #endif +#endif +/*-----------------------------------------------------------*/ + #ifdef configASSERT void vPortValidateInterruptPriority( void ); #define portASSERT_IF_INTERRUPT_PRIORITY_INVALID() vPortValidateInterruptPriority() diff --git a/portable/IAR/ARM_CM33/non_secure/port.c b/portable/IAR/ARM_CM33/non_secure/port.c index 52d68d3eaf..617e0c8689 100644 --- a/portable/IAR/ARM_CM33/non_secure/port.c +++ b/portable/IAR/ARM_CM33/non_secure/port.c @@ -79,6 +79,12 @@ #endif /*-----------------------------------------------------------*/ +/** + * @brief Prototype to which all Interrupt Service Routines conform. + */ +typedef void (* portISR_t)( void ); +/*-----------------------------------------------------------*/ + /** * @brief Constants required to manipulate the NVIC. */ @@ -100,10 +106,18 @@ /** * @brief Constants required to manipulate the SCB. */ -#define portSCB_SYS_HANDLER_CTRL_STATE_REG ( *( volatile uint32_t * ) 0xe000ed24 ) +#define portSCB_VTOR_REG ( *( ( portISR_t ** ) 0xe000ed08 ) ) +#define portSCB_SYS_HANDLER_CTRL_STATE_REG ( *( ( volatile uint32_t * ) 0xe000ed24 ) ) #define portSCB_MEM_FAULT_ENABLE_BIT ( 1UL << 16UL ) /*-----------------------------------------------------------*/ +/** + * @brief Constants used to check the installation of the FreeRTOS interrupt handlers. + */ +#define portVECTOR_INDEX_SVC ( 11 ) +#define portVECTOR_INDEX_PENDSV ( 14 ) +/*-----------------------------------------------------------*/ + /** * @brief Constants required to check the validity of an interrupt priority. */ @@ -1679,22 +1693,44 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ { + /* Applications that route program control to the FreeRTOS interrupt + * handlers through intermediate handlers (indirect routing) should set + * configCHECK_HANDLER_INSTALLATION to 0 in FreeRTOSConfig.h. Direct + * routing, which is validated here when configCHECK_HANDLER_INSTALLATION + * is 1, is preferred when possible. */ + #if ( configCHECK_HANDLER_INSTALLATION == 1 ) + { + const portISR_t * const pxVectorTable = portSCB_VTOR_REG; + + /* Verify correct installation of the FreeRTOS handlers for SVCall and + * PendSV. Do not check the installation of the SysTick handler because + * the application may provide the OS tick without using the SysTick + * timer by overriding the weak function vPortSetupTimerInterrupt(). + * + * Assertion failures here can be caused by incorrect installation of + * the FreeRTOS handlers. For help installing the handlers, see + * https://www.FreeRTOS.org/FAQHelp.html + * + * Systems with a configurable address for the interrupt vector table + * can also encounter assertion failures or even system faults here if + * VTOR is not set correctly to point to the application's vector table. */ + configASSERT( pxVectorTable[ portVECTOR_INDEX_SVC ] == SVC_Handler ); + configASSERT( pxVectorTable[ portVECTOR_INDEX_PENDSV ] == PendSV_Handler ); + } + #endif /* configCHECK_HANDLER_INSTALLATION */ + #if ( ( configASSERT_DEFINED == 1 ) && ( portHAS_ARMV8M_MAIN_EXTENSION == 1 ) ) { - volatile uint32_t ulOriginalPriority; volatile uint32_t ulImplementedPrioBits = 0; volatile uint8_t ucMaxPriorityValue; /* Determine the maximum priority from which ISR safe FreeRTOS API - * functions can be called. ISR safe functions are those that end in - * "FromISR". FreeRTOS maintains separate thread and ISR API functions to + * functions can be called. ISR safe functions are those that end in + * "FromISR". FreeRTOS maintains separate thread and ISR API functions to * ensure interrupt entry is as fast and simple as possible. * - * Save the interrupt priority value that is about to be clobbered. */ - ulOriginalPriority = portNVIC_SHPR2_REG; - - /* Determine the number of priority bits available. First write to all - * possible bits. */ + * First, determine the number of priority bits available. Write to all + * possible bits in the priority setting for SVCall. */ portNVIC_SHPR2_REG = 0xFF000000; /* Read the value back to see how many bits stuck. */ @@ -1717,7 +1753,6 @@ BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ /* Calculate the maximum acceptable priority group value for the number * of bits read back. */ - while( ( ucMaxPriorityValue & portTOP_BIT_OF_BYTE ) == portTOP_BIT_OF_BYTE ) { ulImplementedPrioBits++; @@ -1755,16 +1790,14 @@ BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ * register. */ ulMaxPRIGROUPValue <<= portPRIGROUP_SHIFT; ulMaxPRIGROUPValue &= portPRIORITY_GROUP_MASK; - - /* Restore the clobbered interrupt priority register to its original - * value. */ - portNVIC_SHPR2_REG = ulOriginalPriority; } #endif /* #if ( ( configASSERT_DEFINED == 1 ) && ( portHAS_ARMV8M_MAIN_EXTENSION == 1 ) ) */ - /* Make PendSV, CallSV and SysTick the same priority as the kernel. */ + /* Make PendSV and SysTick the lowest priority interrupts, and make SVCall + * the highest priority. */ portNVIC_SHPR3_REG |= portNVIC_PENDSV_PRI; portNVIC_SHPR3_REG |= portNVIC_SYSTICK_PRI; + portNVIC_SHPR2_REG = 0; #if ( configENABLE_MPU == 1 ) { diff --git a/portable/IAR/ARM_CM33/non_secure/portmacrocommon.h b/portable/IAR/ARM_CM33/non_secure/portmacrocommon.h index 60ef37380a..083eea5cf0 100644 --- a/portable/IAR/ARM_CM33/non_secure/portmacrocommon.h +++ b/portable/IAR/ARM_CM33/non_secure/portmacrocommon.h @@ -370,6 +370,20 @@ extern void vClearInterruptMask( uint32_t ulMask ) /* __attribute__(( naked )) P #define portEXIT_CRITICAL() vPortExitCritical() /*-----------------------------------------------------------*/ +/* Runtime checks on port configuration */ +#ifndef configCHECK_HANDLER_INSTALLATION + #if ( configASSERT_DEFINED == 1 ) + #define configCHECK_HANDLER_INSTALLATION 1 + #else + #define configCHECK_HANDLER_INSTALLATION 0 + #endif +#else + #if ( configCHECK_HANDLER_INSTALLATION == 1 && configASSERT_DEFINED == 0 ) + #error You must define configASSERT() when configCHECK_HANDLER_INSTALLATION is 1. + #endif +#endif +/*-----------------------------------------------------------*/ + /** * @brief Tickless idle/low power functionality. */ diff --git a/portable/IAR/ARM_CM33_NTZ/non_secure/port.c b/portable/IAR/ARM_CM33_NTZ/non_secure/port.c index 52d68d3eaf..617e0c8689 100644 --- a/portable/IAR/ARM_CM33_NTZ/non_secure/port.c +++ b/portable/IAR/ARM_CM33_NTZ/non_secure/port.c @@ -79,6 +79,12 @@ #endif /*-----------------------------------------------------------*/ +/** + * @brief Prototype to which all Interrupt Service Routines conform. + */ +typedef void (* portISR_t)( void ); +/*-----------------------------------------------------------*/ + /** * @brief Constants required to manipulate the NVIC. */ @@ -100,10 +106,18 @@ /** * @brief Constants required to manipulate the SCB. */ -#define portSCB_SYS_HANDLER_CTRL_STATE_REG ( *( volatile uint32_t * ) 0xe000ed24 ) +#define portSCB_VTOR_REG ( *( ( portISR_t ** ) 0xe000ed08 ) ) +#define portSCB_SYS_HANDLER_CTRL_STATE_REG ( *( ( volatile uint32_t * ) 0xe000ed24 ) ) #define portSCB_MEM_FAULT_ENABLE_BIT ( 1UL << 16UL ) /*-----------------------------------------------------------*/ +/** + * @brief Constants used to check the installation of the FreeRTOS interrupt handlers. + */ +#define portVECTOR_INDEX_SVC ( 11 ) +#define portVECTOR_INDEX_PENDSV ( 14 ) +/*-----------------------------------------------------------*/ + /** * @brief Constants required to check the validity of an interrupt priority. */ @@ -1679,22 +1693,44 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ { + /* Applications that route program control to the FreeRTOS interrupt + * handlers through intermediate handlers (indirect routing) should set + * configCHECK_HANDLER_INSTALLATION to 0 in FreeRTOSConfig.h. Direct + * routing, which is validated here when configCHECK_HANDLER_INSTALLATION + * is 1, is preferred when possible. */ + #if ( configCHECK_HANDLER_INSTALLATION == 1 ) + { + const portISR_t * const pxVectorTable = portSCB_VTOR_REG; + + /* Verify correct installation of the FreeRTOS handlers for SVCall and + * PendSV. Do not check the installation of the SysTick handler because + * the application may provide the OS tick without using the SysTick + * timer by overriding the weak function vPortSetupTimerInterrupt(). + * + * Assertion failures here can be caused by incorrect installation of + * the FreeRTOS handlers. For help installing the handlers, see + * https://www.FreeRTOS.org/FAQHelp.html + * + * Systems with a configurable address for the interrupt vector table + * can also encounter assertion failures or even system faults here if + * VTOR is not set correctly to point to the application's vector table. */ + configASSERT( pxVectorTable[ portVECTOR_INDEX_SVC ] == SVC_Handler ); + configASSERT( pxVectorTable[ portVECTOR_INDEX_PENDSV ] == PendSV_Handler ); + } + #endif /* configCHECK_HANDLER_INSTALLATION */ + #if ( ( configASSERT_DEFINED == 1 ) && ( portHAS_ARMV8M_MAIN_EXTENSION == 1 ) ) { - volatile uint32_t ulOriginalPriority; volatile uint32_t ulImplementedPrioBits = 0; volatile uint8_t ucMaxPriorityValue; /* Determine the maximum priority from which ISR safe FreeRTOS API - * functions can be called. ISR safe functions are those that end in - * "FromISR". FreeRTOS maintains separate thread and ISR API functions to + * functions can be called. ISR safe functions are those that end in + * "FromISR". FreeRTOS maintains separate thread and ISR API functions to * ensure interrupt entry is as fast and simple as possible. * - * Save the interrupt priority value that is about to be clobbered. */ - ulOriginalPriority = portNVIC_SHPR2_REG; - - /* Determine the number of priority bits available. First write to all - * possible bits. */ + * First, determine the number of priority bits available. Write to all + * possible bits in the priority setting for SVCall. */ portNVIC_SHPR2_REG = 0xFF000000; /* Read the value back to see how many bits stuck. */ @@ -1717,7 +1753,6 @@ BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ /* Calculate the maximum acceptable priority group value for the number * of bits read back. */ - while( ( ucMaxPriorityValue & portTOP_BIT_OF_BYTE ) == portTOP_BIT_OF_BYTE ) { ulImplementedPrioBits++; @@ -1755,16 +1790,14 @@ BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ * register. */ ulMaxPRIGROUPValue <<= portPRIGROUP_SHIFT; ulMaxPRIGROUPValue &= portPRIORITY_GROUP_MASK; - - /* Restore the clobbered interrupt priority register to its original - * value. */ - portNVIC_SHPR2_REG = ulOriginalPriority; } #endif /* #if ( ( configASSERT_DEFINED == 1 ) && ( portHAS_ARMV8M_MAIN_EXTENSION == 1 ) ) */ - /* Make PendSV, CallSV and SysTick the same priority as the kernel. */ + /* Make PendSV and SysTick the lowest priority interrupts, and make SVCall + * the highest priority. */ portNVIC_SHPR3_REG |= portNVIC_PENDSV_PRI; portNVIC_SHPR3_REG |= portNVIC_SYSTICK_PRI; + portNVIC_SHPR2_REG = 0; #if ( configENABLE_MPU == 1 ) { diff --git a/portable/IAR/ARM_CM33_NTZ/non_secure/portmacrocommon.h b/portable/IAR/ARM_CM33_NTZ/non_secure/portmacrocommon.h index 60ef37380a..083eea5cf0 100644 --- a/portable/IAR/ARM_CM33_NTZ/non_secure/portmacrocommon.h +++ b/portable/IAR/ARM_CM33_NTZ/non_secure/portmacrocommon.h @@ -370,6 +370,20 @@ extern void vClearInterruptMask( uint32_t ulMask ) /* __attribute__(( naked )) P #define portEXIT_CRITICAL() vPortExitCritical() /*-----------------------------------------------------------*/ +/* Runtime checks on port configuration */ +#ifndef configCHECK_HANDLER_INSTALLATION + #if ( configASSERT_DEFINED == 1 ) + #define configCHECK_HANDLER_INSTALLATION 1 + #else + #define configCHECK_HANDLER_INSTALLATION 0 + #endif +#else + #if ( configCHECK_HANDLER_INSTALLATION == 1 && configASSERT_DEFINED == 0 ) + #error You must define configASSERT() when configCHECK_HANDLER_INSTALLATION is 1. + #endif +#endif +/*-----------------------------------------------------------*/ + /** * @brief Tickless idle/low power functionality. */ diff --git a/portable/IAR/ARM_CM35P/non_secure/port.c b/portable/IAR/ARM_CM35P/non_secure/port.c index 52d68d3eaf..617e0c8689 100644 --- a/portable/IAR/ARM_CM35P/non_secure/port.c +++ b/portable/IAR/ARM_CM35P/non_secure/port.c @@ -79,6 +79,12 @@ #endif /*-----------------------------------------------------------*/ +/** + * @brief Prototype to which all Interrupt Service Routines conform. + */ +typedef void (* portISR_t)( void ); +/*-----------------------------------------------------------*/ + /** * @brief Constants required to manipulate the NVIC. */ @@ -100,10 +106,18 @@ /** * @brief Constants required to manipulate the SCB. */ -#define portSCB_SYS_HANDLER_CTRL_STATE_REG ( *( volatile uint32_t * ) 0xe000ed24 ) +#define portSCB_VTOR_REG ( *( ( portISR_t ** ) 0xe000ed08 ) ) +#define portSCB_SYS_HANDLER_CTRL_STATE_REG ( *( ( volatile uint32_t * ) 0xe000ed24 ) ) #define portSCB_MEM_FAULT_ENABLE_BIT ( 1UL << 16UL ) /*-----------------------------------------------------------*/ +/** + * @brief Constants used to check the installation of the FreeRTOS interrupt handlers. + */ +#define portVECTOR_INDEX_SVC ( 11 ) +#define portVECTOR_INDEX_PENDSV ( 14 ) +/*-----------------------------------------------------------*/ + /** * @brief Constants required to check the validity of an interrupt priority. */ @@ -1679,22 +1693,44 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ { + /* Applications that route program control to the FreeRTOS interrupt + * handlers through intermediate handlers (indirect routing) should set + * configCHECK_HANDLER_INSTALLATION to 0 in FreeRTOSConfig.h. Direct + * routing, which is validated here when configCHECK_HANDLER_INSTALLATION + * is 1, is preferred when possible. */ + #if ( configCHECK_HANDLER_INSTALLATION == 1 ) + { + const portISR_t * const pxVectorTable = portSCB_VTOR_REG; + + /* Verify correct installation of the FreeRTOS handlers for SVCall and + * PendSV. Do not check the installation of the SysTick handler because + * the application may provide the OS tick without using the SysTick + * timer by overriding the weak function vPortSetupTimerInterrupt(). + * + * Assertion failures here can be caused by incorrect installation of + * the FreeRTOS handlers. For help installing the handlers, see + * https://www.FreeRTOS.org/FAQHelp.html + * + * Systems with a configurable address for the interrupt vector table + * can also encounter assertion failures or even system faults here if + * VTOR is not set correctly to point to the application's vector table. */ + configASSERT( pxVectorTable[ portVECTOR_INDEX_SVC ] == SVC_Handler ); + configASSERT( pxVectorTable[ portVECTOR_INDEX_PENDSV ] == PendSV_Handler ); + } + #endif /* configCHECK_HANDLER_INSTALLATION */ + #if ( ( configASSERT_DEFINED == 1 ) && ( portHAS_ARMV8M_MAIN_EXTENSION == 1 ) ) { - volatile uint32_t ulOriginalPriority; volatile uint32_t ulImplementedPrioBits = 0; volatile uint8_t ucMaxPriorityValue; /* Determine the maximum priority from which ISR safe FreeRTOS API - * functions can be called. ISR safe functions are those that end in - * "FromISR". FreeRTOS maintains separate thread and ISR API functions to + * functions can be called. ISR safe functions are those that end in + * "FromISR". FreeRTOS maintains separate thread and ISR API functions to * ensure interrupt entry is as fast and simple as possible. * - * Save the interrupt priority value that is about to be clobbered. */ - ulOriginalPriority = portNVIC_SHPR2_REG; - - /* Determine the number of priority bits available. First write to all - * possible bits. */ + * First, determine the number of priority bits available. Write to all + * possible bits in the priority setting for SVCall. */ portNVIC_SHPR2_REG = 0xFF000000; /* Read the value back to see how many bits stuck. */ @@ -1717,7 +1753,6 @@ BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ /* Calculate the maximum acceptable priority group value for the number * of bits read back. */ - while( ( ucMaxPriorityValue & portTOP_BIT_OF_BYTE ) == portTOP_BIT_OF_BYTE ) { ulImplementedPrioBits++; @@ -1755,16 +1790,14 @@ BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ * register. */ ulMaxPRIGROUPValue <<= portPRIGROUP_SHIFT; ulMaxPRIGROUPValue &= portPRIORITY_GROUP_MASK; - - /* Restore the clobbered interrupt priority register to its original - * value. */ - portNVIC_SHPR2_REG = ulOriginalPriority; } #endif /* #if ( ( configASSERT_DEFINED == 1 ) && ( portHAS_ARMV8M_MAIN_EXTENSION == 1 ) ) */ - /* Make PendSV, CallSV and SysTick the same priority as the kernel. */ + /* Make PendSV and SysTick the lowest priority interrupts, and make SVCall + * the highest priority. */ portNVIC_SHPR3_REG |= portNVIC_PENDSV_PRI; portNVIC_SHPR3_REG |= portNVIC_SYSTICK_PRI; + portNVIC_SHPR2_REG = 0; #if ( configENABLE_MPU == 1 ) { diff --git a/portable/IAR/ARM_CM35P/non_secure/portmacrocommon.h b/portable/IAR/ARM_CM35P/non_secure/portmacrocommon.h index 60ef37380a..083eea5cf0 100644 --- a/portable/IAR/ARM_CM35P/non_secure/portmacrocommon.h +++ b/portable/IAR/ARM_CM35P/non_secure/portmacrocommon.h @@ -370,6 +370,20 @@ extern void vClearInterruptMask( uint32_t ulMask ) /* __attribute__(( naked )) P #define portEXIT_CRITICAL() vPortExitCritical() /*-----------------------------------------------------------*/ +/* Runtime checks on port configuration */ +#ifndef configCHECK_HANDLER_INSTALLATION + #if ( configASSERT_DEFINED == 1 ) + #define configCHECK_HANDLER_INSTALLATION 1 + #else + #define configCHECK_HANDLER_INSTALLATION 0 + #endif +#else + #if ( configCHECK_HANDLER_INSTALLATION == 1 && configASSERT_DEFINED == 0 ) + #error You must define configASSERT() when configCHECK_HANDLER_INSTALLATION is 1. + #endif +#endif +/*-----------------------------------------------------------*/ + /** * @brief Tickless idle/low power functionality. */ diff --git a/portable/IAR/ARM_CM35P_NTZ/non_secure/port.c b/portable/IAR/ARM_CM35P_NTZ/non_secure/port.c index 52d68d3eaf..617e0c8689 100644 --- a/portable/IAR/ARM_CM35P_NTZ/non_secure/port.c +++ b/portable/IAR/ARM_CM35P_NTZ/non_secure/port.c @@ -79,6 +79,12 @@ #endif /*-----------------------------------------------------------*/ +/** + * @brief Prototype to which all Interrupt Service Routines conform. + */ +typedef void (* portISR_t)( void ); +/*-----------------------------------------------------------*/ + /** * @brief Constants required to manipulate the NVIC. */ @@ -100,10 +106,18 @@ /** * @brief Constants required to manipulate the SCB. */ -#define portSCB_SYS_HANDLER_CTRL_STATE_REG ( *( volatile uint32_t * ) 0xe000ed24 ) +#define portSCB_VTOR_REG ( *( ( portISR_t ** ) 0xe000ed08 ) ) +#define portSCB_SYS_HANDLER_CTRL_STATE_REG ( *( ( volatile uint32_t * ) 0xe000ed24 ) ) #define portSCB_MEM_FAULT_ENABLE_BIT ( 1UL << 16UL ) /*-----------------------------------------------------------*/ +/** + * @brief Constants used to check the installation of the FreeRTOS interrupt handlers. + */ +#define portVECTOR_INDEX_SVC ( 11 ) +#define portVECTOR_INDEX_PENDSV ( 14 ) +/*-----------------------------------------------------------*/ + /** * @brief Constants required to check the validity of an interrupt priority. */ @@ -1679,22 +1693,44 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ { + /* Applications that route program control to the FreeRTOS interrupt + * handlers through intermediate handlers (indirect routing) should set + * configCHECK_HANDLER_INSTALLATION to 0 in FreeRTOSConfig.h. Direct + * routing, which is validated here when configCHECK_HANDLER_INSTALLATION + * is 1, is preferred when possible. */ + #if ( configCHECK_HANDLER_INSTALLATION == 1 ) + { + const portISR_t * const pxVectorTable = portSCB_VTOR_REG; + + /* Verify correct installation of the FreeRTOS handlers for SVCall and + * PendSV. Do not check the installation of the SysTick handler because + * the application may provide the OS tick without using the SysTick + * timer by overriding the weak function vPortSetupTimerInterrupt(). + * + * Assertion failures here can be caused by incorrect installation of + * the FreeRTOS handlers. For help installing the handlers, see + * https://www.FreeRTOS.org/FAQHelp.html + * + * Systems with a configurable address for the interrupt vector table + * can also encounter assertion failures or even system faults here if + * VTOR is not set correctly to point to the application's vector table. */ + configASSERT( pxVectorTable[ portVECTOR_INDEX_SVC ] == SVC_Handler ); + configASSERT( pxVectorTable[ portVECTOR_INDEX_PENDSV ] == PendSV_Handler ); + } + #endif /* configCHECK_HANDLER_INSTALLATION */ + #if ( ( configASSERT_DEFINED == 1 ) && ( portHAS_ARMV8M_MAIN_EXTENSION == 1 ) ) { - volatile uint32_t ulOriginalPriority; volatile uint32_t ulImplementedPrioBits = 0; volatile uint8_t ucMaxPriorityValue; /* Determine the maximum priority from which ISR safe FreeRTOS API - * functions can be called. ISR safe functions are those that end in - * "FromISR". FreeRTOS maintains separate thread and ISR API functions to + * functions can be called. ISR safe functions are those that end in + * "FromISR". FreeRTOS maintains separate thread and ISR API functions to * ensure interrupt entry is as fast and simple as possible. * - * Save the interrupt priority value that is about to be clobbered. */ - ulOriginalPriority = portNVIC_SHPR2_REG; - - /* Determine the number of priority bits available. First write to all - * possible bits. */ + * First, determine the number of priority bits available. Write to all + * possible bits in the priority setting for SVCall. */ portNVIC_SHPR2_REG = 0xFF000000; /* Read the value back to see how many bits stuck. */ @@ -1717,7 +1753,6 @@ BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ /* Calculate the maximum acceptable priority group value for the number * of bits read back. */ - while( ( ucMaxPriorityValue & portTOP_BIT_OF_BYTE ) == portTOP_BIT_OF_BYTE ) { ulImplementedPrioBits++; @@ -1755,16 +1790,14 @@ BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ * register. */ ulMaxPRIGROUPValue <<= portPRIGROUP_SHIFT; ulMaxPRIGROUPValue &= portPRIORITY_GROUP_MASK; - - /* Restore the clobbered interrupt priority register to its original - * value. */ - portNVIC_SHPR2_REG = ulOriginalPriority; } #endif /* #if ( ( configASSERT_DEFINED == 1 ) && ( portHAS_ARMV8M_MAIN_EXTENSION == 1 ) ) */ - /* Make PendSV, CallSV and SysTick the same priority as the kernel. */ + /* Make PendSV and SysTick the lowest priority interrupts, and make SVCall + * the highest priority. */ portNVIC_SHPR3_REG |= portNVIC_PENDSV_PRI; portNVIC_SHPR3_REG |= portNVIC_SYSTICK_PRI; + portNVIC_SHPR2_REG = 0; #if ( configENABLE_MPU == 1 ) { diff --git a/portable/IAR/ARM_CM35P_NTZ/non_secure/portmacrocommon.h b/portable/IAR/ARM_CM35P_NTZ/non_secure/portmacrocommon.h index 60ef37380a..083eea5cf0 100644 --- a/portable/IAR/ARM_CM35P_NTZ/non_secure/portmacrocommon.h +++ b/portable/IAR/ARM_CM35P_NTZ/non_secure/portmacrocommon.h @@ -370,6 +370,20 @@ extern void vClearInterruptMask( uint32_t ulMask ) /* __attribute__(( naked )) P #define portEXIT_CRITICAL() vPortExitCritical() /*-----------------------------------------------------------*/ +/* Runtime checks on port configuration */ +#ifndef configCHECK_HANDLER_INSTALLATION + #if ( configASSERT_DEFINED == 1 ) + #define configCHECK_HANDLER_INSTALLATION 1 + #else + #define configCHECK_HANDLER_INSTALLATION 0 + #endif +#else + #if ( configCHECK_HANDLER_INSTALLATION == 1 && configASSERT_DEFINED == 0 ) + #error You must define configASSERT() when configCHECK_HANDLER_INSTALLATION is 1. + #endif +#endif +/*-----------------------------------------------------------*/ + /** * @brief Tickless idle/low power functionality. */ diff --git a/portable/IAR/ARM_CM4F/port.c b/portable/IAR/ARM_CM4F/port.c index effedcb14b..d75e48492d 100644 --- a/portable/IAR/ARM_CM4F/port.c +++ b/portable/IAR/ARM_CM4F/port.c @@ -45,10 +45,14 @@ #error configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to 0. See http: /*www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */ #endif +/* Prototype to which all Interrupt Service Routines conform. */ +typedef void (* portISR_t)( void ); + /* Constants required to manipulate the core. Registers first... */ #define portNVIC_SYSTICK_CTRL_REG ( *( ( volatile uint32_t * ) 0xe000e010 ) ) #define portNVIC_SYSTICK_LOAD_REG ( *( ( volatile uint32_t * ) 0xe000e014 ) ) #define portNVIC_SYSTICK_CURRENT_VALUE_REG ( *( ( volatile uint32_t * ) 0xe000e018 ) ) +#define portNVIC_SHPR2_REG ( *( ( volatile uint32_t * ) 0xe000ed1c ) ) #define portNVIC_SHPR3_REG ( *( ( volatile uint32_t * ) 0xe000ed20 ) ) /* ...then bits in the registers. */ #define portNVIC_SYSTICK_CLK_BIT ( 1UL << 2UL ) @@ -69,6 +73,11 @@ #define portNVIC_PENDSV_PRI ( ( ( uint32_t ) portMIN_INTERRUPT_PRIORITY ) << 16UL ) #define portNVIC_SYSTICK_PRI ( ( ( uint32_t ) portMIN_INTERRUPT_PRIORITY ) << 24UL ) +/* Constants used to check the installation of the FreeRTOS interrupt handlers. */ +#define portSCB_VTOR_REG ( *( ( portISR_t ** ) 0xE000ED08 ) ) +#define portVECTOR_INDEX_SVC ( 11 ) +#define portVECTOR_INDEX_PENDSV ( 14 ) + /* Constants required to check the validity of an interrupt priority. */ #define portFIRST_USER_INTERRUPT_NUMBER ( 16 ) #define portNVIC_IP_REGISTERS_OFFSET_16 ( 0xE000E3F0 ) @@ -246,6 +255,32 @@ BaseType_t xPortStartScheduler( void ) configASSERT( portCPUID != portCORTEX_M7_r0p1_ID ); configASSERT( portCPUID != portCORTEX_M7_r0p0_ID ); + /* Applications that route program control to the FreeRTOS interrupt + * handlers through intermediate handlers (indirect routing) should set + * configCHECK_HANDLER_INSTALLATION to 0 in FreeRTOSConfig.h. Direct + * routing, which is validated here when configCHECK_HANDLER_INSTALLATION + * is 1, is preferred when possible. */ + #if ( configCHECK_HANDLER_INSTALLATION == 1 ) + { + const portISR_t * const pxVectorTable = portSCB_VTOR_REG; + + /* Verify correct installation of the FreeRTOS handlers for SVCall and + * PendSV. Do not check the installation of the SysTick handler because + * the application may provide the OS tick without using the SysTick + * timer by overriding the weak function vPortSetupTimerInterrupt(). + * + * Assertion failures here can be caused by incorrect installation of + * the FreeRTOS handlers. For help installing the handlers, see + * https://www.FreeRTOS.org/FAQHelp.html + * + * Systems with a configurable address for the interrupt vector table + * can also encounter assertion failures or even system faults here if + * VTOR is not set correctly to point to the application's vector table. */ + configASSERT( pxVectorTable[ portVECTOR_INDEX_SVC ] == vPortSVCHandler ); + configASSERT( pxVectorTable[ portVECTOR_INDEX_PENDSV ] == xPortPendSVHandler ); + } + #endif /* configCHECK_HANDLER_INSTALLATION */ + #if ( configASSERT_DEFINED == 1 ) { volatile uint8_t ucOriginalPriority; @@ -330,9 +365,11 @@ BaseType_t xPortStartScheduler( void ) } #endif /* configASSERT_DEFINED */ - /* Make PendSV and SysTick the lowest priority interrupts. */ + /* Make PendSV and SysTick the lowest priority interrupts, and make SVCall + * the highest priority. */ portNVIC_SHPR3_REG |= portNVIC_PENDSV_PRI; portNVIC_SHPR3_REG |= portNVIC_SYSTICK_PRI; + portNVIC_SHPR2_REG = 0; /* Start the timer that generates the tick ISR. Interrupts are disabled * here already. */ diff --git a/portable/IAR/ARM_CM4F/portmacro.h b/portable/IAR/ARM_CM4F/portmacro.h index 20467efcbb..7b82c0c939 100644 --- a/portable/IAR/ARM_CM4F/portmacro.h +++ b/portable/IAR/ARM_CM4F/portmacro.h @@ -172,6 +172,20 @@ extern void vPortExitCritical( void ); #define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void * pvParameters ) /*-----------------------------------------------------------*/ +/* Runtime checks on port configuration */ +#ifndef configCHECK_HANDLER_INSTALLATION + #if ( configASSERT_DEFINED == 1 ) + #define configCHECK_HANDLER_INSTALLATION 1 + #else + #define configCHECK_HANDLER_INSTALLATION 0 + #endif +#else + #if ( configCHECK_HANDLER_INSTALLATION == 1 && configASSERT_DEFINED == 0 ) + #error You must define configASSERT() when configCHECK_HANDLER_INSTALLATION is 1. + #endif +#endif +/*-----------------------------------------------------------*/ + #ifdef configASSERT void vPortValidateInterruptPriority( void ); #define portASSERT_IF_INTERRUPT_PRIORITY_INVALID() vPortValidateInterruptPriority() diff --git a/portable/IAR/ARM_CM4F_MPU/port.c b/portable/IAR/ARM_CM4F_MPU/port.c index 6db7bd796a..0a9d8272c5 100644 --- a/portable/IAR/ARM_CM4F_MPU/port.c +++ b/portable/IAR/ARM_CM4F_MPU/port.c @@ -68,6 +68,9 @@ #define configALLOW_UNPRIVILEGED_CRITICAL_SECTIONS 1 #endif +/* Prototype to which all Interrupt Service Routines conform. */ +typedef void (* portISR_t)( void ); + /* Constants required to manipulate the core. Registers first... */ #define portNVIC_SYSTICK_CTRL_REG ( *( ( volatile uint32_t * ) 0xe000e010 ) ) #define portNVIC_SYSTICK_LOAD_REG ( *( ( volatile uint32_t * ) 0xe000e014 ) ) @@ -109,6 +112,11 @@ #define portNVIC_SYSTICK_PRI ( ( ( uint32_t ) portMIN_INTERRUPT_PRIORITY ) << 24UL ) #define portNVIC_SVC_PRI ( ( ( uint32_t ) configMAX_SYSCALL_INTERRUPT_PRIORITY - 1UL ) << 24UL ) +/* Constants used to check the installation of the FreeRTOS interrupt handlers. */ +#define portSCB_VTOR_REG ( *( ( portISR_t ** ) 0xE000ED08 ) ) +#define portVECTOR_INDEX_SVC ( 11 ) +#define portVECTOR_INDEX_PENDSV ( 14 ) + /* Constants required to check the validity of an interrupt priority. */ #define portFIRST_USER_INTERRUPT_NUMBER ( 16 ) #define portNVIC_IP_REGISTERS_OFFSET_16 ( 0xE000E3F0 ) @@ -777,6 +785,32 @@ BaseType_t xPortStartScheduler( void ) configASSERT( portCPUID != portCORTEX_M7_r0p0_ID ); #endif + /* Applications that route program control to the FreeRTOS interrupt + * handlers through intermediate handlers (indirect routing) should set + * configCHECK_HANDLER_INSTALLATION to 0 in FreeRTOSConfig.h. Direct + * routing, which is validated here when configCHECK_HANDLER_INSTALLATION + * is 1, is preferred when possible. */ + #if ( configCHECK_HANDLER_INSTALLATION == 1 ) + { + const portISR_t * const pxVectorTable = portSCB_VTOR_REG; + + /* Verify correct installation of the FreeRTOS handlers for SVCall and + * PendSV. Do not check the installation of the SysTick handler because + * the application may provide the OS tick without using the SysTick + * timer by overriding the weak function vPortSetupTimerInterrupt(). + * + * Assertion failures here can be caused by incorrect installation of + * the FreeRTOS handlers. For help installing the handlers, see + * https://www.FreeRTOS.org/FAQHelp.html + * + * Systems with a configurable address for the interrupt vector table + * can also encounter assertion failures or even system faults here if + * VTOR is not set correctly to point to the application's vector table. */ + configASSERT( pxVectorTable[ portVECTOR_INDEX_SVC ] == vPortSVCHandler ); + configASSERT( pxVectorTable[ portVECTOR_INDEX_PENDSV ] == xPortPendSVHandler ); + } + #endif /* configCHECK_HANDLER_INSTALLATION */ + #if ( configASSERT_DEFINED == 1 ) { volatile uint8_t ucOriginalPriority; diff --git a/portable/IAR/ARM_CM4F_MPU/portmacro.h b/portable/IAR/ARM_CM4F_MPU/portmacro.h index 98b087e11f..6dad44d93e 100644 --- a/portable/IAR/ARM_CM4F_MPU/portmacro.h +++ b/portable/IAR/ARM_CM4F_MPU/portmacro.h @@ -288,6 +288,20 @@ typedef struct MPU_SETTINGS #define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x ) /*-----------------------------------------------------------*/ +/* Runtime checks on port configuration */ +#ifndef configCHECK_HANDLER_INSTALLATION + #if ( configASSERT_DEFINED == 1 ) + #define configCHECK_HANDLER_INSTALLATION 1 + #else + #define configCHECK_HANDLER_INSTALLATION 0 + #endif +#else + #if ( configCHECK_HANDLER_INSTALLATION == 1 && configASSERT_DEFINED == 0 ) + #error You must define configASSERT() when configCHECK_HANDLER_INSTALLATION is 1. + #endif +#endif +/*-----------------------------------------------------------*/ + /* Architecture specific optimisations. */ #ifndef configUSE_PORT_OPTIMISED_TASK_SELECTION #define configUSE_PORT_OPTIMISED_TASK_SELECTION 1 diff --git a/portable/IAR/ARM_CM55/non_secure/port.c b/portable/IAR/ARM_CM55/non_secure/port.c index 52d68d3eaf..617e0c8689 100644 --- a/portable/IAR/ARM_CM55/non_secure/port.c +++ b/portable/IAR/ARM_CM55/non_secure/port.c @@ -79,6 +79,12 @@ #endif /*-----------------------------------------------------------*/ +/** + * @brief Prototype to which all Interrupt Service Routines conform. + */ +typedef void (* portISR_t)( void ); +/*-----------------------------------------------------------*/ + /** * @brief Constants required to manipulate the NVIC. */ @@ -100,10 +106,18 @@ /** * @brief Constants required to manipulate the SCB. */ -#define portSCB_SYS_HANDLER_CTRL_STATE_REG ( *( volatile uint32_t * ) 0xe000ed24 ) +#define portSCB_VTOR_REG ( *( ( portISR_t ** ) 0xe000ed08 ) ) +#define portSCB_SYS_HANDLER_CTRL_STATE_REG ( *( ( volatile uint32_t * ) 0xe000ed24 ) ) #define portSCB_MEM_FAULT_ENABLE_BIT ( 1UL << 16UL ) /*-----------------------------------------------------------*/ +/** + * @brief Constants used to check the installation of the FreeRTOS interrupt handlers. + */ +#define portVECTOR_INDEX_SVC ( 11 ) +#define portVECTOR_INDEX_PENDSV ( 14 ) +/*-----------------------------------------------------------*/ + /** * @brief Constants required to check the validity of an interrupt priority. */ @@ -1679,22 +1693,44 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ { + /* Applications that route program control to the FreeRTOS interrupt + * handlers through intermediate handlers (indirect routing) should set + * configCHECK_HANDLER_INSTALLATION to 0 in FreeRTOSConfig.h. Direct + * routing, which is validated here when configCHECK_HANDLER_INSTALLATION + * is 1, is preferred when possible. */ + #if ( configCHECK_HANDLER_INSTALLATION == 1 ) + { + const portISR_t * const pxVectorTable = portSCB_VTOR_REG; + + /* Verify correct installation of the FreeRTOS handlers for SVCall and + * PendSV. Do not check the installation of the SysTick handler because + * the application may provide the OS tick without using the SysTick + * timer by overriding the weak function vPortSetupTimerInterrupt(). + * + * Assertion failures here can be caused by incorrect installation of + * the FreeRTOS handlers. For help installing the handlers, see + * https://www.FreeRTOS.org/FAQHelp.html + * + * Systems with a configurable address for the interrupt vector table + * can also encounter assertion failures or even system faults here if + * VTOR is not set correctly to point to the application's vector table. */ + configASSERT( pxVectorTable[ portVECTOR_INDEX_SVC ] == SVC_Handler ); + configASSERT( pxVectorTable[ portVECTOR_INDEX_PENDSV ] == PendSV_Handler ); + } + #endif /* configCHECK_HANDLER_INSTALLATION */ + #if ( ( configASSERT_DEFINED == 1 ) && ( portHAS_ARMV8M_MAIN_EXTENSION == 1 ) ) { - volatile uint32_t ulOriginalPriority; volatile uint32_t ulImplementedPrioBits = 0; volatile uint8_t ucMaxPriorityValue; /* Determine the maximum priority from which ISR safe FreeRTOS API - * functions can be called. ISR safe functions are those that end in - * "FromISR". FreeRTOS maintains separate thread and ISR API functions to + * functions can be called. ISR safe functions are those that end in + * "FromISR". FreeRTOS maintains separate thread and ISR API functions to * ensure interrupt entry is as fast and simple as possible. * - * Save the interrupt priority value that is about to be clobbered. */ - ulOriginalPriority = portNVIC_SHPR2_REG; - - /* Determine the number of priority bits available. First write to all - * possible bits. */ + * First, determine the number of priority bits available. Write to all + * possible bits in the priority setting for SVCall. */ portNVIC_SHPR2_REG = 0xFF000000; /* Read the value back to see how many bits stuck. */ @@ -1717,7 +1753,6 @@ BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ /* Calculate the maximum acceptable priority group value for the number * of bits read back. */ - while( ( ucMaxPriorityValue & portTOP_BIT_OF_BYTE ) == portTOP_BIT_OF_BYTE ) { ulImplementedPrioBits++; @@ -1755,16 +1790,14 @@ BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ * register. */ ulMaxPRIGROUPValue <<= portPRIGROUP_SHIFT; ulMaxPRIGROUPValue &= portPRIORITY_GROUP_MASK; - - /* Restore the clobbered interrupt priority register to its original - * value. */ - portNVIC_SHPR2_REG = ulOriginalPriority; } #endif /* #if ( ( configASSERT_DEFINED == 1 ) && ( portHAS_ARMV8M_MAIN_EXTENSION == 1 ) ) */ - /* Make PendSV, CallSV and SysTick the same priority as the kernel. */ + /* Make PendSV and SysTick the lowest priority interrupts, and make SVCall + * the highest priority. */ portNVIC_SHPR3_REG |= portNVIC_PENDSV_PRI; portNVIC_SHPR3_REG |= portNVIC_SYSTICK_PRI; + portNVIC_SHPR2_REG = 0; #if ( configENABLE_MPU == 1 ) { diff --git a/portable/IAR/ARM_CM55/non_secure/portmacrocommon.h b/portable/IAR/ARM_CM55/non_secure/portmacrocommon.h index 60ef37380a..083eea5cf0 100644 --- a/portable/IAR/ARM_CM55/non_secure/portmacrocommon.h +++ b/portable/IAR/ARM_CM55/non_secure/portmacrocommon.h @@ -370,6 +370,20 @@ extern void vClearInterruptMask( uint32_t ulMask ) /* __attribute__(( naked )) P #define portEXIT_CRITICAL() vPortExitCritical() /*-----------------------------------------------------------*/ +/* Runtime checks on port configuration */ +#ifndef configCHECK_HANDLER_INSTALLATION + #if ( configASSERT_DEFINED == 1 ) + #define configCHECK_HANDLER_INSTALLATION 1 + #else + #define configCHECK_HANDLER_INSTALLATION 0 + #endif +#else + #if ( configCHECK_HANDLER_INSTALLATION == 1 && configASSERT_DEFINED == 0 ) + #error You must define configASSERT() when configCHECK_HANDLER_INSTALLATION is 1. + #endif +#endif +/*-----------------------------------------------------------*/ + /** * @brief Tickless idle/low power functionality. */ diff --git a/portable/IAR/ARM_CM55_NTZ/non_secure/port.c b/portable/IAR/ARM_CM55_NTZ/non_secure/port.c index 52d68d3eaf..617e0c8689 100644 --- a/portable/IAR/ARM_CM55_NTZ/non_secure/port.c +++ b/portable/IAR/ARM_CM55_NTZ/non_secure/port.c @@ -79,6 +79,12 @@ #endif /*-----------------------------------------------------------*/ +/** + * @brief Prototype to which all Interrupt Service Routines conform. + */ +typedef void (* portISR_t)( void ); +/*-----------------------------------------------------------*/ + /** * @brief Constants required to manipulate the NVIC. */ @@ -100,10 +106,18 @@ /** * @brief Constants required to manipulate the SCB. */ -#define portSCB_SYS_HANDLER_CTRL_STATE_REG ( *( volatile uint32_t * ) 0xe000ed24 ) +#define portSCB_VTOR_REG ( *( ( portISR_t ** ) 0xe000ed08 ) ) +#define portSCB_SYS_HANDLER_CTRL_STATE_REG ( *( ( volatile uint32_t * ) 0xe000ed24 ) ) #define portSCB_MEM_FAULT_ENABLE_BIT ( 1UL << 16UL ) /*-----------------------------------------------------------*/ +/** + * @brief Constants used to check the installation of the FreeRTOS interrupt handlers. + */ +#define portVECTOR_INDEX_SVC ( 11 ) +#define portVECTOR_INDEX_PENDSV ( 14 ) +/*-----------------------------------------------------------*/ + /** * @brief Constants required to check the validity of an interrupt priority. */ @@ -1679,22 +1693,44 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ { + /* Applications that route program control to the FreeRTOS interrupt + * handlers through intermediate handlers (indirect routing) should set + * configCHECK_HANDLER_INSTALLATION to 0 in FreeRTOSConfig.h. Direct + * routing, which is validated here when configCHECK_HANDLER_INSTALLATION + * is 1, is preferred when possible. */ + #if ( configCHECK_HANDLER_INSTALLATION == 1 ) + { + const portISR_t * const pxVectorTable = portSCB_VTOR_REG; + + /* Verify correct installation of the FreeRTOS handlers for SVCall and + * PendSV. Do not check the installation of the SysTick handler because + * the application may provide the OS tick without using the SysTick + * timer by overriding the weak function vPortSetupTimerInterrupt(). + * + * Assertion failures here can be caused by incorrect installation of + * the FreeRTOS handlers. For help installing the handlers, see + * https://www.FreeRTOS.org/FAQHelp.html + * + * Systems with a configurable address for the interrupt vector table + * can also encounter assertion failures or even system faults here if + * VTOR is not set correctly to point to the application's vector table. */ + configASSERT( pxVectorTable[ portVECTOR_INDEX_SVC ] == SVC_Handler ); + configASSERT( pxVectorTable[ portVECTOR_INDEX_PENDSV ] == PendSV_Handler ); + } + #endif /* configCHECK_HANDLER_INSTALLATION */ + #if ( ( configASSERT_DEFINED == 1 ) && ( portHAS_ARMV8M_MAIN_EXTENSION == 1 ) ) { - volatile uint32_t ulOriginalPriority; volatile uint32_t ulImplementedPrioBits = 0; volatile uint8_t ucMaxPriorityValue; /* Determine the maximum priority from which ISR safe FreeRTOS API - * functions can be called. ISR safe functions are those that end in - * "FromISR". FreeRTOS maintains separate thread and ISR API functions to + * functions can be called. ISR safe functions are those that end in + * "FromISR". FreeRTOS maintains separate thread and ISR API functions to * ensure interrupt entry is as fast and simple as possible. * - * Save the interrupt priority value that is about to be clobbered. */ - ulOriginalPriority = portNVIC_SHPR2_REG; - - /* Determine the number of priority bits available. First write to all - * possible bits. */ + * First, determine the number of priority bits available. Write to all + * possible bits in the priority setting for SVCall. */ portNVIC_SHPR2_REG = 0xFF000000; /* Read the value back to see how many bits stuck. */ @@ -1717,7 +1753,6 @@ BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ /* Calculate the maximum acceptable priority group value for the number * of bits read back. */ - while( ( ucMaxPriorityValue & portTOP_BIT_OF_BYTE ) == portTOP_BIT_OF_BYTE ) { ulImplementedPrioBits++; @@ -1755,16 +1790,14 @@ BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ * register. */ ulMaxPRIGROUPValue <<= portPRIGROUP_SHIFT; ulMaxPRIGROUPValue &= portPRIORITY_GROUP_MASK; - - /* Restore the clobbered interrupt priority register to its original - * value. */ - portNVIC_SHPR2_REG = ulOriginalPriority; } #endif /* #if ( ( configASSERT_DEFINED == 1 ) && ( portHAS_ARMV8M_MAIN_EXTENSION == 1 ) ) */ - /* Make PendSV, CallSV and SysTick the same priority as the kernel. */ + /* Make PendSV and SysTick the lowest priority interrupts, and make SVCall + * the highest priority. */ portNVIC_SHPR3_REG |= portNVIC_PENDSV_PRI; portNVIC_SHPR3_REG |= portNVIC_SYSTICK_PRI; + portNVIC_SHPR2_REG = 0; #if ( configENABLE_MPU == 1 ) { diff --git a/portable/IAR/ARM_CM55_NTZ/non_secure/portmacrocommon.h b/portable/IAR/ARM_CM55_NTZ/non_secure/portmacrocommon.h index 60ef37380a..083eea5cf0 100644 --- a/portable/IAR/ARM_CM55_NTZ/non_secure/portmacrocommon.h +++ b/portable/IAR/ARM_CM55_NTZ/non_secure/portmacrocommon.h @@ -370,6 +370,20 @@ extern void vClearInterruptMask( uint32_t ulMask ) /* __attribute__(( naked )) P #define portEXIT_CRITICAL() vPortExitCritical() /*-----------------------------------------------------------*/ +/* Runtime checks on port configuration */ +#ifndef configCHECK_HANDLER_INSTALLATION + #if ( configASSERT_DEFINED == 1 ) + #define configCHECK_HANDLER_INSTALLATION 1 + #else + #define configCHECK_HANDLER_INSTALLATION 0 + #endif +#else + #if ( configCHECK_HANDLER_INSTALLATION == 1 && configASSERT_DEFINED == 0 ) + #error You must define configASSERT() when configCHECK_HANDLER_INSTALLATION is 1. + #endif +#endif +/*-----------------------------------------------------------*/ + /** * @brief Tickless idle/low power functionality. */ diff --git a/portable/IAR/ARM_CM85/non_secure/port.c b/portable/IAR/ARM_CM85/non_secure/port.c index 52d68d3eaf..617e0c8689 100644 --- a/portable/IAR/ARM_CM85/non_secure/port.c +++ b/portable/IAR/ARM_CM85/non_secure/port.c @@ -79,6 +79,12 @@ #endif /*-----------------------------------------------------------*/ +/** + * @brief Prototype to which all Interrupt Service Routines conform. + */ +typedef void (* portISR_t)( void ); +/*-----------------------------------------------------------*/ + /** * @brief Constants required to manipulate the NVIC. */ @@ -100,10 +106,18 @@ /** * @brief Constants required to manipulate the SCB. */ -#define portSCB_SYS_HANDLER_CTRL_STATE_REG ( *( volatile uint32_t * ) 0xe000ed24 ) +#define portSCB_VTOR_REG ( *( ( portISR_t ** ) 0xe000ed08 ) ) +#define portSCB_SYS_HANDLER_CTRL_STATE_REG ( *( ( volatile uint32_t * ) 0xe000ed24 ) ) #define portSCB_MEM_FAULT_ENABLE_BIT ( 1UL << 16UL ) /*-----------------------------------------------------------*/ +/** + * @brief Constants used to check the installation of the FreeRTOS interrupt handlers. + */ +#define portVECTOR_INDEX_SVC ( 11 ) +#define portVECTOR_INDEX_PENDSV ( 14 ) +/*-----------------------------------------------------------*/ + /** * @brief Constants required to check the validity of an interrupt priority. */ @@ -1679,22 +1693,44 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ { + /* Applications that route program control to the FreeRTOS interrupt + * handlers through intermediate handlers (indirect routing) should set + * configCHECK_HANDLER_INSTALLATION to 0 in FreeRTOSConfig.h. Direct + * routing, which is validated here when configCHECK_HANDLER_INSTALLATION + * is 1, is preferred when possible. */ + #if ( configCHECK_HANDLER_INSTALLATION == 1 ) + { + const portISR_t * const pxVectorTable = portSCB_VTOR_REG; + + /* Verify correct installation of the FreeRTOS handlers for SVCall and + * PendSV. Do not check the installation of the SysTick handler because + * the application may provide the OS tick without using the SysTick + * timer by overriding the weak function vPortSetupTimerInterrupt(). + * + * Assertion failures here can be caused by incorrect installation of + * the FreeRTOS handlers. For help installing the handlers, see + * https://www.FreeRTOS.org/FAQHelp.html + * + * Systems with a configurable address for the interrupt vector table + * can also encounter assertion failures or even system faults here if + * VTOR is not set correctly to point to the application's vector table. */ + configASSERT( pxVectorTable[ portVECTOR_INDEX_SVC ] == SVC_Handler ); + configASSERT( pxVectorTable[ portVECTOR_INDEX_PENDSV ] == PendSV_Handler ); + } + #endif /* configCHECK_HANDLER_INSTALLATION */ + #if ( ( configASSERT_DEFINED == 1 ) && ( portHAS_ARMV8M_MAIN_EXTENSION == 1 ) ) { - volatile uint32_t ulOriginalPriority; volatile uint32_t ulImplementedPrioBits = 0; volatile uint8_t ucMaxPriorityValue; /* Determine the maximum priority from which ISR safe FreeRTOS API - * functions can be called. ISR safe functions are those that end in - * "FromISR". FreeRTOS maintains separate thread and ISR API functions to + * functions can be called. ISR safe functions are those that end in + * "FromISR". FreeRTOS maintains separate thread and ISR API functions to * ensure interrupt entry is as fast and simple as possible. * - * Save the interrupt priority value that is about to be clobbered. */ - ulOriginalPriority = portNVIC_SHPR2_REG; - - /* Determine the number of priority bits available. First write to all - * possible bits. */ + * First, determine the number of priority bits available. Write to all + * possible bits in the priority setting for SVCall. */ portNVIC_SHPR2_REG = 0xFF000000; /* Read the value back to see how many bits stuck. */ @@ -1717,7 +1753,6 @@ BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ /* Calculate the maximum acceptable priority group value for the number * of bits read back. */ - while( ( ucMaxPriorityValue & portTOP_BIT_OF_BYTE ) == portTOP_BIT_OF_BYTE ) { ulImplementedPrioBits++; @@ -1755,16 +1790,14 @@ BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ * register. */ ulMaxPRIGROUPValue <<= portPRIGROUP_SHIFT; ulMaxPRIGROUPValue &= portPRIORITY_GROUP_MASK; - - /* Restore the clobbered interrupt priority register to its original - * value. */ - portNVIC_SHPR2_REG = ulOriginalPriority; } #endif /* #if ( ( configASSERT_DEFINED == 1 ) && ( portHAS_ARMV8M_MAIN_EXTENSION == 1 ) ) */ - /* Make PendSV, CallSV and SysTick the same priority as the kernel. */ + /* Make PendSV and SysTick the lowest priority interrupts, and make SVCall + * the highest priority. */ portNVIC_SHPR3_REG |= portNVIC_PENDSV_PRI; portNVIC_SHPR3_REG |= portNVIC_SYSTICK_PRI; + portNVIC_SHPR2_REG = 0; #if ( configENABLE_MPU == 1 ) { diff --git a/portable/IAR/ARM_CM85/non_secure/portmacrocommon.h b/portable/IAR/ARM_CM85/non_secure/portmacrocommon.h index 60ef37380a..083eea5cf0 100644 --- a/portable/IAR/ARM_CM85/non_secure/portmacrocommon.h +++ b/portable/IAR/ARM_CM85/non_secure/portmacrocommon.h @@ -370,6 +370,20 @@ extern void vClearInterruptMask( uint32_t ulMask ) /* __attribute__(( naked )) P #define portEXIT_CRITICAL() vPortExitCritical() /*-----------------------------------------------------------*/ +/* Runtime checks on port configuration */ +#ifndef configCHECK_HANDLER_INSTALLATION + #if ( configASSERT_DEFINED == 1 ) + #define configCHECK_HANDLER_INSTALLATION 1 + #else + #define configCHECK_HANDLER_INSTALLATION 0 + #endif +#else + #if ( configCHECK_HANDLER_INSTALLATION == 1 && configASSERT_DEFINED == 0 ) + #error You must define configASSERT() when configCHECK_HANDLER_INSTALLATION is 1. + #endif +#endif +/*-----------------------------------------------------------*/ + /** * @brief Tickless idle/low power functionality. */ diff --git a/portable/IAR/ARM_CM85_NTZ/non_secure/port.c b/portable/IAR/ARM_CM85_NTZ/non_secure/port.c index 52d68d3eaf..617e0c8689 100644 --- a/portable/IAR/ARM_CM85_NTZ/non_secure/port.c +++ b/portable/IAR/ARM_CM85_NTZ/non_secure/port.c @@ -79,6 +79,12 @@ #endif /*-----------------------------------------------------------*/ +/** + * @brief Prototype to which all Interrupt Service Routines conform. + */ +typedef void (* portISR_t)( void ); +/*-----------------------------------------------------------*/ + /** * @brief Constants required to manipulate the NVIC. */ @@ -100,10 +106,18 @@ /** * @brief Constants required to manipulate the SCB. */ -#define portSCB_SYS_HANDLER_CTRL_STATE_REG ( *( volatile uint32_t * ) 0xe000ed24 ) +#define portSCB_VTOR_REG ( *( ( portISR_t ** ) 0xe000ed08 ) ) +#define portSCB_SYS_HANDLER_CTRL_STATE_REG ( *( ( volatile uint32_t * ) 0xe000ed24 ) ) #define portSCB_MEM_FAULT_ENABLE_BIT ( 1UL << 16UL ) /*-----------------------------------------------------------*/ +/** + * @brief Constants used to check the installation of the FreeRTOS interrupt handlers. + */ +#define portVECTOR_INDEX_SVC ( 11 ) +#define portVECTOR_INDEX_PENDSV ( 14 ) +/*-----------------------------------------------------------*/ + /** * @brief Constants required to check the validity of an interrupt priority. */ @@ -1679,22 +1693,44 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ { + /* Applications that route program control to the FreeRTOS interrupt + * handlers through intermediate handlers (indirect routing) should set + * configCHECK_HANDLER_INSTALLATION to 0 in FreeRTOSConfig.h. Direct + * routing, which is validated here when configCHECK_HANDLER_INSTALLATION + * is 1, is preferred when possible. */ + #if ( configCHECK_HANDLER_INSTALLATION == 1 ) + { + const portISR_t * const pxVectorTable = portSCB_VTOR_REG; + + /* Verify correct installation of the FreeRTOS handlers for SVCall and + * PendSV. Do not check the installation of the SysTick handler because + * the application may provide the OS tick without using the SysTick + * timer by overriding the weak function vPortSetupTimerInterrupt(). + * + * Assertion failures here can be caused by incorrect installation of + * the FreeRTOS handlers. For help installing the handlers, see + * https://www.FreeRTOS.org/FAQHelp.html + * + * Systems with a configurable address for the interrupt vector table + * can also encounter assertion failures or even system faults here if + * VTOR is not set correctly to point to the application's vector table. */ + configASSERT( pxVectorTable[ portVECTOR_INDEX_SVC ] == SVC_Handler ); + configASSERT( pxVectorTable[ portVECTOR_INDEX_PENDSV ] == PendSV_Handler ); + } + #endif /* configCHECK_HANDLER_INSTALLATION */ + #if ( ( configASSERT_DEFINED == 1 ) && ( portHAS_ARMV8M_MAIN_EXTENSION == 1 ) ) { - volatile uint32_t ulOriginalPriority; volatile uint32_t ulImplementedPrioBits = 0; volatile uint8_t ucMaxPriorityValue; /* Determine the maximum priority from which ISR safe FreeRTOS API - * functions can be called. ISR safe functions are those that end in - * "FromISR". FreeRTOS maintains separate thread and ISR API functions to + * functions can be called. ISR safe functions are those that end in + * "FromISR". FreeRTOS maintains separate thread and ISR API functions to * ensure interrupt entry is as fast and simple as possible. * - * Save the interrupt priority value that is about to be clobbered. */ - ulOriginalPriority = portNVIC_SHPR2_REG; - - /* Determine the number of priority bits available. First write to all - * possible bits. */ + * First, determine the number of priority bits available. Write to all + * possible bits in the priority setting for SVCall. */ portNVIC_SHPR2_REG = 0xFF000000; /* Read the value back to see how many bits stuck. */ @@ -1717,7 +1753,6 @@ BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ /* Calculate the maximum acceptable priority group value for the number * of bits read back. */ - while( ( ucMaxPriorityValue & portTOP_BIT_OF_BYTE ) == portTOP_BIT_OF_BYTE ) { ulImplementedPrioBits++; @@ -1755,16 +1790,14 @@ BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ * register. */ ulMaxPRIGROUPValue <<= portPRIGROUP_SHIFT; ulMaxPRIGROUPValue &= portPRIORITY_GROUP_MASK; - - /* Restore the clobbered interrupt priority register to its original - * value. */ - portNVIC_SHPR2_REG = ulOriginalPriority; } #endif /* #if ( ( configASSERT_DEFINED == 1 ) && ( portHAS_ARMV8M_MAIN_EXTENSION == 1 ) ) */ - /* Make PendSV, CallSV and SysTick the same priority as the kernel. */ + /* Make PendSV and SysTick the lowest priority interrupts, and make SVCall + * the highest priority. */ portNVIC_SHPR3_REG |= portNVIC_PENDSV_PRI; portNVIC_SHPR3_REG |= portNVIC_SYSTICK_PRI; + portNVIC_SHPR2_REG = 0; #if ( configENABLE_MPU == 1 ) { diff --git a/portable/IAR/ARM_CM85_NTZ/non_secure/portmacrocommon.h b/portable/IAR/ARM_CM85_NTZ/non_secure/portmacrocommon.h index 60ef37380a..083eea5cf0 100644 --- a/portable/IAR/ARM_CM85_NTZ/non_secure/portmacrocommon.h +++ b/portable/IAR/ARM_CM85_NTZ/non_secure/portmacrocommon.h @@ -370,6 +370,20 @@ extern void vClearInterruptMask( uint32_t ulMask ) /* __attribute__(( naked )) P #define portEXIT_CRITICAL() vPortExitCritical() /*-----------------------------------------------------------*/ +/* Runtime checks on port configuration */ +#ifndef configCHECK_HANDLER_INSTALLATION + #if ( configASSERT_DEFINED == 1 ) + #define configCHECK_HANDLER_INSTALLATION 1 + #else + #define configCHECK_HANDLER_INSTALLATION 0 + #endif +#else + #if ( configCHECK_HANDLER_INSTALLATION == 1 && configASSERT_DEFINED == 0 ) + #error You must define configASSERT() when configCHECK_HANDLER_INSTALLATION is 1. + #endif +#endif +/*-----------------------------------------------------------*/ + /** * @brief Tickless idle/low power functionality. */ From 9f58ab67ff77a261b9f1a98a62c972fe9e226fe2 Mon Sep 17 00:00:00 2001 From: Jeff Tenney Date: Wed, 25 Oct 2023 14:09:44 -0700 Subject: [PATCH 17/23] Move macro check to FreeRTOS.h and simplify --- include/FreeRTOS.h | 10 ++++++++++ portable/ARMv8M/non_secure/portmacrocommon.h | 14 -------------- portable/GCC/ARM_CM0/portmacro.h | 14 -------------- portable/GCC/ARM_CM23/non_secure/portmacrocommon.h | 14 -------------- .../GCC/ARM_CM23_NTZ/non_secure/portmacrocommon.h | 14 -------------- portable/GCC/ARM_CM3/portmacro.h | 14 -------------- portable/GCC/ARM_CM33/non_secure/portmacrocommon.h | 14 -------------- .../GCC/ARM_CM33_NTZ/non_secure/portmacrocommon.h | 14 -------------- .../GCC/ARM_CM35P/non_secure/portmacrocommon.h | 14 -------------- .../GCC/ARM_CM35P_NTZ/non_secure/portmacrocommon.h | 14 -------------- portable/GCC/ARM_CM3_MPU/portmacro.h | 14 -------------- portable/GCC/ARM_CM4F/portmacro.h | 14 -------------- portable/GCC/ARM_CM4_MPU/portmacro.h | 14 -------------- portable/GCC/ARM_CM55/non_secure/portmacrocommon.h | 14 -------------- .../GCC/ARM_CM55_NTZ/non_secure/portmacrocommon.h | 14 -------------- portable/GCC/ARM_CM85/non_secure/portmacrocommon.h | 14 -------------- .../GCC/ARM_CM85_NTZ/non_secure/portmacrocommon.h | 14 -------------- portable/IAR/ARM_CM0/portmacro.h | 14 -------------- portable/IAR/ARM_CM23/non_secure/portmacrocommon.h | 14 -------------- .../IAR/ARM_CM23_NTZ/non_secure/portmacrocommon.h | 14 -------------- portable/IAR/ARM_CM3/portmacro.h | 14 -------------- portable/IAR/ARM_CM33/non_secure/portmacrocommon.h | 14 -------------- .../IAR/ARM_CM33_NTZ/non_secure/portmacrocommon.h | 14 -------------- .../IAR/ARM_CM35P/non_secure/portmacrocommon.h | 14 -------------- .../IAR/ARM_CM35P_NTZ/non_secure/portmacrocommon.h | 14 -------------- portable/IAR/ARM_CM4F/portmacro.h | 14 -------------- portable/IAR/ARM_CM4F_MPU/portmacro.h | 14 -------------- portable/IAR/ARM_CM55/non_secure/portmacrocommon.h | 14 -------------- .../IAR/ARM_CM55_NTZ/non_secure/portmacrocommon.h | 14 -------------- portable/IAR/ARM_CM85/non_secure/portmacrocommon.h | 14 -------------- .../IAR/ARM_CM85_NTZ/non_secure/portmacrocommon.h | 14 -------------- 31 files changed, 10 insertions(+), 420 deletions(-) diff --git a/include/FreeRTOS.h b/include/FreeRTOS.h index b8153ac64d..8fcd932f22 100644 --- a/include/FreeRTOS.h +++ b/include/FreeRTOS.h @@ -365,6 +365,16 @@ #define configPRECONDITION_DEFINED 1 #endif +#ifndef configCHECK_HANDLER_INSTALLATION + #define configCHECK_HANDLER_INSTALLATION 1 +#else + /* The application has explicitly defined configCHECK_HANDLER_INSTALLATION + * to 1. The checks work only if configASSERT() is defined. */ + #if ( configCHECK_HANDLER_INSTALLATION == 1 && configASSERT_DEFINED == 0 ) + #error You must define configASSERT() when configCHECK_HANDLER_INSTALLATION is 1. + #endif +#endif + #ifndef portMEMORY_BARRIER #define portMEMORY_BARRIER() #endif diff --git a/portable/ARMv8M/non_secure/portmacrocommon.h b/portable/ARMv8M/non_secure/portmacrocommon.h index 083eea5cf0..60ef37380a 100644 --- a/portable/ARMv8M/non_secure/portmacrocommon.h +++ b/portable/ARMv8M/non_secure/portmacrocommon.h @@ -370,20 +370,6 @@ extern void vClearInterruptMask( uint32_t ulMask ) /* __attribute__(( naked )) P #define portEXIT_CRITICAL() vPortExitCritical() /*-----------------------------------------------------------*/ -/* Runtime checks on port configuration */ -#ifndef configCHECK_HANDLER_INSTALLATION - #if ( configASSERT_DEFINED == 1 ) - #define configCHECK_HANDLER_INSTALLATION 1 - #else - #define configCHECK_HANDLER_INSTALLATION 0 - #endif -#else - #if ( configCHECK_HANDLER_INSTALLATION == 1 && configASSERT_DEFINED == 0 ) - #error You must define configASSERT() when configCHECK_HANDLER_INSTALLATION is 1. - #endif -#endif -/*-----------------------------------------------------------*/ - /** * @brief Tickless idle/low power functionality. */ diff --git a/portable/GCC/ARM_CM0/portmacro.h b/portable/GCC/ARM_CM0/portmacro.h index f967a70a75..3c55b5d0c4 100644 --- a/portable/GCC/ARM_CM0/portmacro.h +++ b/portable/GCC/ARM_CM0/portmacro.h @@ -143,20 +143,6 @@ extern void vClearInterruptMaskFromISR( uint32_t ulMask ) __attribute__( ( nake /*-----------------------------------------------------------*/ -/* Runtime checks on port configuration */ -#ifndef configCHECK_HANDLER_INSTALLATION - #if ( configASSERT_DEFINED == 1 ) - #define configCHECK_HANDLER_INSTALLATION 1 - #else - #define configCHECK_HANDLER_INSTALLATION 0 - #endif -#else - #if ( configCHECK_HANDLER_INSTALLATION == 1 && configASSERT_DEFINED == 0 ) - #error You must define configASSERT() when configCHECK_HANDLER_INSTALLATION is 1. - #endif -#endif -/*-----------------------------------------------------------*/ - portFORCE_INLINE static BaseType_t xPortIsInsideInterrupt( void ) { uint32_t ulCurrentInterrupt; diff --git a/portable/GCC/ARM_CM23/non_secure/portmacrocommon.h b/portable/GCC/ARM_CM23/non_secure/portmacrocommon.h index 083eea5cf0..60ef37380a 100644 --- a/portable/GCC/ARM_CM23/non_secure/portmacrocommon.h +++ b/portable/GCC/ARM_CM23/non_secure/portmacrocommon.h @@ -370,20 +370,6 @@ extern void vClearInterruptMask( uint32_t ulMask ) /* __attribute__(( naked )) P #define portEXIT_CRITICAL() vPortExitCritical() /*-----------------------------------------------------------*/ -/* Runtime checks on port configuration */ -#ifndef configCHECK_HANDLER_INSTALLATION - #if ( configASSERT_DEFINED == 1 ) - #define configCHECK_HANDLER_INSTALLATION 1 - #else - #define configCHECK_HANDLER_INSTALLATION 0 - #endif -#else - #if ( configCHECK_HANDLER_INSTALLATION == 1 && configASSERT_DEFINED == 0 ) - #error You must define configASSERT() when configCHECK_HANDLER_INSTALLATION is 1. - #endif -#endif -/*-----------------------------------------------------------*/ - /** * @brief Tickless idle/low power functionality. */ diff --git a/portable/GCC/ARM_CM23_NTZ/non_secure/portmacrocommon.h b/portable/GCC/ARM_CM23_NTZ/non_secure/portmacrocommon.h index 083eea5cf0..60ef37380a 100644 --- a/portable/GCC/ARM_CM23_NTZ/non_secure/portmacrocommon.h +++ b/portable/GCC/ARM_CM23_NTZ/non_secure/portmacrocommon.h @@ -370,20 +370,6 @@ extern void vClearInterruptMask( uint32_t ulMask ) /* __attribute__(( naked )) P #define portEXIT_CRITICAL() vPortExitCritical() /*-----------------------------------------------------------*/ -/* Runtime checks on port configuration */ -#ifndef configCHECK_HANDLER_INSTALLATION - #if ( configASSERT_DEFINED == 1 ) - #define configCHECK_HANDLER_INSTALLATION 1 - #else - #define configCHECK_HANDLER_INSTALLATION 0 - #endif -#else - #if ( configCHECK_HANDLER_INSTALLATION == 1 && configASSERT_DEFINED == 0 ) - #error You must define configASSERT() when configCHECK_HANDLER_INSTALLATION is 1. - #endif -#endif -/*-----------------------------------------------------------*/ - /** * @brief Tickless idle/low power functionality. */ diff --git a/portable/GCC/ARM_CM3/portmacro.h b/portable/GCC/ARM_CM3/portmacro.h index ac843131fd..5d91d2139e 100644 --- a/portable/GCC/ARM_CM3/portmacro.h +++ b/portable/GCC/ARM_CM3/portmacro.h @@ -130,20 +130,6 @@ extern void vPortExitCritical( void ); #define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void * pvParameters ) /*-----------------------------------------------------------*/ -/* Runtime checks on port configuration */ -#ifndef configCHECK_HANDLER_INSTALLATION - #if ( configASSERT_DEFINED == 1 ) - #define configCHECK_HANDLER_INSTALLATION 1 - #else - #define configCHECK_HANDLER_INSTALLATION 0 - #endif -#else - #if ( configCHECK_HANDLER_INSTALLATION == 1 && configASSERT_DEFINED == 0 ) - #error You must define configASSERT() when configCHECK_HANDLER_INSTALLATION is 1. - #endif -#endif -/*-----------------------------------------------------------*/ - /* Tickless idle/low power functionality. */ #ifndef portSUPPRESS_TICKS_AND_SLEEP extern void vPortSuppressTicksAndSleep( TickType_t xExpectedIdleTime ); diff --git a/portable/GCC/ARM_CM33/non_secure/portmacrocommon.h b/portable/GCC/ARM_CM33/non_secure/portmacrocommon.h index 083eea5cf0..60ef37380a 100644 --- a/portable/GCC/ARM_CM33/non_secure/portmacrocommon.h +++ b/portable/GCC/ARM_CM33/non_secure/portmacrocommon.h @@ -370,20 +370,6 @@ extern void vClearInterruptMask( uint32_t ulMask ) /* __attribute__(( naked )) P #define portEXIT_CRITICAL() vPortExitCritical() /*-----------------------------------------------------------*/ -/* Runtime checks on port configuration */ -#ifndef configCHECK_HANDLER_INSTALLATION - #if ( configASSERT_DEFINED == 1 ) - #define configCHECK_HANDLER_INSTALLATION 1 - #else - #define configCHECK_HANDLER_INSTALLATION 0 - #endif -#else - #if ( configCHECK_HANDLER_INSTALLATION == 1 && configASSERT_DEFINED == 0 ) - #error You must define configASSERT() when configCHECK_HANDLER_INSTALLATION is 1. - #endif -#endif -/*-----------------------------------------------------------*/ - /** * @brief Tickless idle/low power functionality. */ diff --git a/portable/GCC/ARM_CM33_NTZ/non_secure/portmacrocommon.h b/portable/GCC/ARM_CM33_NTZ/non_secure/portmacrocommon.h index 083eea5cf0..60ef37380a 100644 --- a/portable/GCC/ARM_CM33_NTZ/non_secure/portmacrocommon.h +++ b/portable/GCC/ARM_CM33_NTZ/non_secure/portmacrocommon.h @@ -370,20 +370,6 @@ extern void vClearInterruptMask( uint32_t ulMask ) /* __attribute__(( naked )) P #define portEXIT_CRITICAL() vPortExitCritical() /*-----------------------------------------------------------*/ -/* Runtime checks on port configuration */ -#ifndef configCHECK_HANDLER_INSTALLATION - #if ( configASSERT_DEFINED == 1 ) - #define configCHECK_HANDLER_INSTALLATION 1 - #else - #define configCHECK_HANDLER_INSTALLATION 0 - #endif -#else - #if ( configCHECK_HANDLER_INSTALLATION == 1 && configASSERT_DEFINED == 0 ) - #error You must define configASSERT() when configCHECK_HANDLER_INSTALLATION is 1. - #endif -#endif -/*-----------------------------------------------------------*/ - /** * @brief Tickless idle/low power functionality. */ diff --git a/portable/GCC/ARM_CM35P/non_secure/portmacrocommon.h b/portable/GCC/ARM_CM35P/non_secure/portmacrocommon.h index 083eea5cf0..60ef37380a 100644 --- a/portable/GCC/ARM_CM35P/non_secure/portmacrocommon.h +++ b/portable/GCC/ARM_CM35P/non_secure/portmacrocommon.h @@ -370,20 +370,6 @@ extern void vClearInterruptMask( uint32_t ulMask ) /* __attribute__(( naked )) P #define portEXIT_CRITICAL() vPortExitCritical() /*-----------------------------------------------------------*/ -/* Runtime checks on port configuration */ -#ifndef configCHECK_HANDLER_INSTALLATION - #if ( configASSERT_DEFINED == 1 ) - #define configCHECK_HANDLER_INSTALLATION 1 - #else - #define configCHECK_HANDLER_INSTALLATION 0 - #endif -#else - #if ( configCHECK_HANDLER_INSTALLATION == 1 && configASSERT_DEFINED == 0 ) - #error You must define configASSERT() when configCHECK_HANDLER_INSTALLATION is 1. - #endif -#endif -/*-----------------------------------------------------------*/ - /** * @brief Tickless idle/low power functionality. */ diff --git a/portable/GCC/ARM_CM35P_NTZ/non_secure/portmacrocommon.h b/portable/GCC/ARM_CM35P_NTZ/non_secure/portmacrocommon.h index 083eea5cf0..60ef37380a 100644 --- a/portable/GCC/ARM_CM35P_NTZ/non_secure/portmacrocommon.h +++ b/portable/GCC/ARM_CM35P_NTZ/non_secure/portmacrocommon.h @@ -370,20 +370,6 @@ extern void vClearInterruptMask( uint32_t ulMask ) /* __attribute__(( naked )) P #define portEXIT_CRITICAL() vPortExitCritical() /*-----------------------------------------------------------*/ -/* Runtime checks on port configuration */ -#ifndef configCHECK_HANDLER_INSTALLATION - #if ( configASSERT_DEFINED == 1 ) - #define configCHECK_HANDLER_INSTALLATION 1 - #else - #define configCHECK_HANDLER_INSTALLATION 0 - #endif -#else - #if ( configCHECK_HANDLER_INSTALLATION == 1 && configASSERT_DEFINED == 0 ) - #error You must define configASSERT() when configCHECK_HANDLER_INSTALLATION is 1. - #endif -#endif -/*-----------------------------------------------------------*/ - /** * @brief Tickless idle/low power functionality. */ diff --git a/portable/GCC/ARM_CM3_MPU/portmacro.h b/portable/GCC/ARM_CM3_MPU/portmacro.h index bdb528f802..d0822e1443 100644 --- a/portable/GCC/ARM_CM3_MPU/portmacro.h +++ b/portable/GCC/ARM_CM3_MPU/portmacro.h @@ -215,20 +215,6 @@ extern void vPortExitCritical( void ); #define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void * pvParameters ) /*-----------------------------------------------------------*/ -/* Runtime checks on port configuration */ -#ifndef configCHECK_HANDLER_INSTALLATION - #if ( configASSERT_DEFINED == 1 ) - #define configCHECK_HANDLER_INSTALLATION 1 - #else - #define configCHECK_HANDLER_INSTALLATION 0 - #endif -#else - #if ( configCHECK_HANDLER_INSTALLATION == 1 && configASSERT_DEFINED == 0 ) - #error You must define configASSERT() when configCHECK_HANDLER_INSTALLATION is 1. - #endif -#endif -/*-----------------------------------------------------------*/ - /* Architecture specific optimisations. */ #ifndef configUSE_PORT_OPTIMISED_TASK_SELECTION #define configUSE_PORT_OPTIMISED_TASK_SELECTION 1 diff --git a/portable/GCC/ARM_CM4F/portmacro.h b/portable/GCC/ARM_CM4F/portmacro.h index 25089af391..40b2d03e91 100644 --- a/portable/GCC/ARM_CM4F/portmacro.h +++ b/portable/GCC/ARM_CM4F/portmacro.h @@ -133,20 +133,6 @@ extern void vPortExitCritical( void ); #define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void * pvParameters ) /*-----------------------------------------------------------*/ -/* Runtime checks on port configuration */ -#ifndef configCHECK_HANDLER_INSTALLATION - #if ( configASSERT_DEFINED == 1 ) - #define configCHECK_HANDLER_INSTALLATION 1 - #else - #define configCHECK_HANDLER_INSTALLATION 0 - #endif -#else - #if ( configCHECK_HANDLER_INSTALLATION == 1 && configASSERT_DEFINED == 0 ) - #error You must define configASSERT() when configCHECK_HANDLER_INSTALLATION is 1. - #endif -#endif -/*-----------------------------------------------------------*/ - /* Tickless idle/low power functionality. */ #ifndef portSUPPRESS_TICKS_AND_SLEEP extern void vPortSuppressTicksAndSleep( TickType_t xExpectedIdleTime ); diff --git a/portable/GCC/ARM_CM4_MPU/portmacro.h b/portable/GCC/ARM_CM4_MPU/portmacro.h index c532ce2781..1f62279b04 100644 --- a/portable/GCC/ARM_CM4_MPU/portmacro.h +++ b/portable/GCC/ARM_CM4_MPU/portmacro.h @@ -309,20 +309,6 @@ extern void vPortExitCritical( void ); #define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void * pvParameters ) /*-----------------------------------------------------------*/ -/* Runtime checks on port configuration */ -#ifndef configCHECK_HANDLER_INSTALLATION - #if ( configASSERT_DEFINED == 1 ) - #define configCHECK_HANDLER_INSTALLATION 1 - #else - #define configCHECK_HANDLER_INSTALLATION 0 - #endif -#else - #if ( configCHECK_HANDLER_INSTALLATION == 1 && configASSERT_DEFINED == 0 ) - #error You must define configASSERT() when configCHECK_HANDLER_INSTALLATION is 1. - #endif -#endif -/*-----------------------------------------------------------*/ - /* Architecture specific optimisations. */ #ifndef configUSE_PORT_OPTIMISED_TASK_SELECTION #define configUSE_PORT_OPTIMISED_TASK_SELECTION 1 diff --git a/portable/GCC/ARM_CM55/non_secure/portmacrocommon.h b/portable/GCC/ARM_CM55/non_secure/portmacrocommon.h index 083eea5cf0..60ef37380a 100644 --- a/portable/GCC/ARM_CM55/non_secure/portmacrocommon.h +++ b/portable/GCC/ARM_CM55/non_secure/portmacrocommon.h @@ -370,20 +370,6 @@ extern void vClearInterruptMask( uint32_t ulMask ) /* __attribute__(( naked )) P #define portEXIT_CRITICAL() vPortExitCritical() /*-----------------------------------------------------------*/ -/* Runtime checks on port configuration */ -#ifndef configCHECK_HANDLER_INSTALLATION - #if ( configASSERT_DEFINED == 1 ) - #define configCHECK_HANDLER_INSTALLATION 1 - #else - #define configCHECK_HANDLER_INSTALLATION 0 - #endif -#else - #if ( configCHECK_HANDLER_INSTALLATION == 1 && configASSERT_DEFINED == 0 ) - #error You must define configASSERT() when configCHECK_HANDLER_INSTALLATION is 1. - #endif -#endif -/*-----------------------------------------------------------*/ - /** * @brief Tickless idle/low power functionality. */ diff --git a/portable/GCC/ARM_CM55_NTZ/non_secure/portmacrocommon.h b/portable/GCC/ARM_CM55_NTZ/non_secure/portmacrocommon.h index 083eea5cf0..60ef37380a 100644 --- a/portable/GCC/ARM_CM55_NTZ/non_secure/portmacrocommon.h +++ b/portable/GCC/ARM_CM55_NTZ/non_secure/portmacrocommon.h @@ -370,20 +370,6 @@ extern void vClearInterruptMask( uint32_t ulMask ) /* __attribute__(( naked )) P #define portEXIT_CRITICAL() vPortExitCritical() /*-----------------------------------------------------------*/ -/* Runtime checks on port configuration */ -#ifndef configCHECK_HANDLER_INSTALLATION - #if ( configASSERT_DEFINED == 1 ) - #define configCHECK_HANDLER_INSTALLATION 1 - #else - #define configCHECK_HANDLER_INSTALLATION 0 - #endif -#else - #if ( configCHECK_HANDLER_INSTALLATION == 1 && configASSERT_DEFINED == 0 ) - #error You must define configASSERT() when configCHECK_HANDLER_INSTALLATION is 1. - #endif -#endif -/*-----------------------------------------------------------*/ - /** * @brief Tickless idle/low power functionality. */ diff --git a/portable/GCC/ARM_CM85/non_secure/portmacrocommon.h b/portable/GCC/ARM_CM85/non_secure/portmacrocommon.h index 083eea5cf0..60ef37380a 100644 --- a/portable/GCC/ARM_CM85/non_secure/portmacrocommon.h +++ b/portable/GCC/ARM_CM85/non_secure/portmacrocommon.h @@ -370,20 +370,6 @@ extern void vClearInterruptMask( uint32_t ulMask ) /* __attribute__(( naked )) P #define portEXIT_CRITICAL() vPortExitCritical() /*-----------------------------------------------------------*/ -/* Runtime checks on port configuration */ -#ifndef configCHECK_HANDLER_INSTALLATION - #if ( configASSERT_DEFINED == 1 ) - #define configCHECK_HANDLER_INSTALLATION 1 - #else - #define configCHECK_HANDLER_INSTALLATION 0 - #endif -#else - #if ( configCHECK_HANDLER_INSTALLATION == 1 && configASSERT_DEFINED == 0 ) - #error You must define configASSERT() when configCHECK_HANDLER_INSTALLATION is 1. - #endif -#endif -/*-----------------------------------------------------------*/ - /** * @brief Tickless idle/low power functionality. */ diff --git a/portable/GCC/ARM_CM85_NTZ/non_secure/portmacrocommon.h b/portable/GCC/ARM_CM85_NTZ/non_secure/portmacrocommon.h index 083eea5cf0..60ef37380a 100644 --- a/portable/GCC/ARM_CM85_NTZ/non_secure/portmacrocommon.h +++ b/portable/GCC/ARM_CM85_NTZ/non_secure/portmacrocommon.h @@ -370,20 +370,6 @@ extern void vClearInterruptMask( uint32_t ulMask ) /* __attribute__(( naked )) P #define portEXIT_CRITICAL() vPortExitCritical() /*-----------------------------------------------------------*/ -/* Runtime checks on port configuration */ -#ifndef configCHECK_HANDLER_INSTALLATION - #if ( configASSERT_DEFINED == 1 ) - #define configCHECK_HANDLER_INSTALLATION 1 - #else - #define configCHECK_HANDLER_INSTALLATION 0 - #endif -#else - #if ( configCHECK_HANDLER_INSTALLATION == 1 && configASSERT_DEFINED == 0 ) - #error You must define configASSERT() when configCHECK_HANDLER_INSTALLATION is 1. - #endif -#endif -/*-----------------------------------------------------------*/ - /** * @brief Tickless idle/low power functionality. */ diff --git a/portable/IAR/ARM_CM0/portmacro.h b/portable/IAR/ARM_CM0/portmacro.h index 8f4cb30c52..fa8438fecf 100644 --- a/portable/IAR/ARM_CM0/portmacro.h +++ b/portable/IAR/ARM_CM0/portmacro.h @@ -141,20 +141,6 @@ extern void vClearInterruptMaskFromISR( uint32_t ulMask ); /*-----------------------------------------------------------*/ -/* Runtime checks on port configuration */ -#ifndef configCHECK_HANDLER_INSTALLATION - #if ( configASSERT_DEFINED == 1 ) - #define configCHECK_HANDLER_INSTALLATION 1 - #else - #define configCHECK_HANDLER_INSTALLATION 0 - #endif -#else - #if ( configCHECK_HANDLER_INSTALLATION == 1 && configASSERT_DEFINED == 0 ) - #error You must define configASSERT() when configCHECK_HANDLER_INSTALLATION is 1. - #endif -#endif -/*-----------------------------------------------------------*/ - portFORCE_INLINE static BaseType_t xPortIsInsideInterrupt( void ) { uint32_t ulCurrentInterrupt; diff --git a/portable/IAR/ARM_CM23/non_secure/portmacrocommon.h b/portable/IAR/ARM_CM23/non_secure/portmacrocommon.h index 083eea5cf0..60ef37380a 100644 --- a/portable/IAR/ARM_CM23/non_secure/portmacrocommon.h +++ b/portable/IAR/ARM_CM23/non_secure/portmacrocommon.h @@ -370,20 +370,6 @@ extern void vClearInterruptMask( uint32_t ulMask ) /* __attribute__(( naked )) P #define portEXIT_CRITICAL() vPortExitCritical() /*-----------------------------------------------------------*/ -/* Runtime checks on port configuration */ -#ifndef configCHECK_HANDLER_INSTALLATION - #if ( configASSERT_DEFINED == 1 ) - #define configCHECK_HANDLER_INSTALLATION 1 - #else - #define configCHECK_HANDLER_INSTALLATION 0 - #endif -#else - #if ( configCHECK_HANDLER_INSTALLATION == 1 && configASSERT_DEFINED == 0 ) - #error You must define configASSERT() when configCHECK_HANDLER_INSTALLATION is 1. - #endif -#endif -/*-----------------------------------------------------------*/ - /** * @brief Tickless idle/low power functionality. */ diff --git a/portable/IAR/ARM_CM23_NTZ/non_secure/portmacrocommon.h b/portable/IAR/ARM_CM23_NTZ/non_secure/portmacrocommon.h index 083eea5cf0..60ef37380a 100644 --- a/portable/IAR/ARM_CM23_NTZ/non_secure/portmacrocommon.h +++ b/portable/IAR/ARM_CM23_NTZ/non_secure/portmacrocommon.h @@ -370,20 +370,6 @@ extern void vClearInterruptMask( uint32_t ulMask ) /* __attribute__(( naked )) P #define portEXIT_CRITICAL() vPortExitCritical() /*-----------------------------------------------------------*/ -/* Runtime checks on port configuration */ -#ifndef configCHECK_HANDLER_INSTALLATION - #if ( configASSERT_DEFINED == 1 ) - #define configCHECK_HANDLER_INSTALLATION 1 - #else - #define configCHECK_HANDLER_INSTALLATION 0 - #endif -#else - #if ( configCHECK_HANDLER_INSTALLATION == 1 && configASSERT_DEFINED == 0 ) - #error You must define configASSERT() when configCHECK_HANDLER_INSTALLATION is 1. - #endif -#endif -/*-----------------------------------------------------------*/ - /** * @brief Tickless idle/low power functionality. */ diff --git a/portable/IAR/ARM_CM3/portmacro.h b/portable/IAR/ARM_CM3/portmacro.h index cf1aaa668e..c90a952e2b 100644 --- a/portable/IAR/ARM_CM3/portmacro.h +++ b/portable/IAR/ARM_CM3/portmacro.h @@ -173,20 +173,6 @@ extern void vPortExitCritical( void ); #define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void * pvParameters ) /*-----------------------------------------------------------*/ -/* Runtime checks on port configuration */ -#ifndef configCHECK_HANDLER_INSTALLATION - #if ( configASSERT_DEFINED == 1 ) - #define configCHECK_HANDLER_INSTALLATION 1 - #else - #define configCHECK_HANDLER_INSTALLATION 0 - #endif -#else - #if ( configCHECK_HANDLER_INSTALLATION == 1 && configASSERT_DEFINED == 0 ) - #error You must define configASSERT() when configCHECK_HANDLER_INSTALLATION is 1. - #endif -#endif -/*-----------------------------------------------------------*/ - #ifdef configASSERT void vPortValidateInterruptPriority( void ); #define portASSERT_IF_INTERRUPT_PRIORITY_INVALID() vPortValidateInterruptPriority() diff --git a/portable/IAR/ARM_CM33/non_secure/portmacrocommon.h b/portable/IAR/ARM_CM33/non_secure/portmacrocommon.h index 083eea5cf0..60ef37380a 100644 --- a/portable/IAR/ARM_CM33/non_secure/portmacrocommon.h +++ b/portable/IAR/ARM_CM33/non_secure/portmacrocommon.h @@ -370,20 +370,6 @@ extern void vClearInterruptMask( uint32_t ulMask ) /* __attribute__(( naked )) P #define portEXIT_CRITICAL() vPortExitCritical() /*-----------------------------------------------------------*/ -/* Runtime checks on port configuration */ -#ifndef configCHECK_HANDLER_INSTALLATION - #if ( configASSERT_DEFINED == 1 ) - #define configCHECK_HANDLER_INSTALLATION 1 - #else - #define configCHECK_HANDLER_INSTALLATION 0 - #endif -#else - #if ( configCHECK_HANDLER_INSTALLATION == 1 && configASSERT_DEFINED == 0 ) - #error You must define configASSERT() when configCHECK_HANDLER_INSTALLATION is 1. - #endif -#endif -/*-----------------------------------------------------------*/ - /** * @brief Tickless idle/low power functionality. */ diff --git a/portable/IAR/ARM_CM33_NTZ/non_secure/portmacrocommon.h b/portable/IAR/ARM_CM33_NTZ/non_secure/portmacrocommon.h index 083eea5cf0..60ef37380a 100644 --- a/portable/IAR/ARM_CM33_NTZ/non_secure/portmacrocommon.h +++ b/portable/IAR/ARM_CM33_NTZ/non_secure/portmacrocommon.h @@ -370,20 +370,6 @@ extern void vClearInterruptMask( uint32_t ulMask ) /* __attribute__(( naked )) P #define portEXIT_CRITICAL() vPortExitCritical() /*-----------------------------------------------------------*/ -/* Runtime checks on port configuration */ -#ifndef configCHECK_HANDLER_INSTALLATION - #if ( configASSERT_DEFINED == 1 ) - #define configCHECK_HANDLER_INSTALLATION 1 - #else - #define configCHECK_HANDLER_INSTALLATION 0 - #endif -#else - #if ( configCHECK_HANDLER_INSTALLATION == 1 && configASSERT_DEFINED == 0 ) - #error You must define configASSERT() when configCHECK_HANDLER_INSTALLATION is 1. - #endif -#endif -/*-----------------------------------------------------------*/ - /** * @brief Tickless idle/low power functionality. */ diff --git a/portable/IAR/ARM_CM35P/non_secure/portmacrocommon.h b/portable/IAR/ARM_CM35P/non_secure/portmacrocommon.h index 083eea5cf0..60ef37380a 100644 --- a/portable/IAR/ARM_CM35P/non_secure/portmacrocommon.h +++ b/portable/IAR/ARM_CM35P/non_secure/portmacrocommon.h @@ -370,20 +370,6 @@ extern void vClearInterruptMask( uint32_t ulMask ) /* __attribute__(( naked )) P #define portEXIT_CRITICAL() vPortExitCritical() /*-----------------------------------------------------------*/ -/* Runtime checks on port configuration */ -#ifndef configCHECK_HANDLER_INSTALLATION - #if ( configASSERT_DEFINED == 1 ) - #define configCHECK_HANDLER_INSTALLATION 1 - #else - #define configCHECK_HANDLER_INSTALLATION 0 - #endif -#else - #if ( configCHECK_HANDLER_INSTALLATION == 1 && configASSERT_DEFINED == 0 ) - #error You must define configASSERT() when configCHECK_HANDLER_INSTALLATION is 1. - #endif -#endif -/*-----------------------------------------------------------*/ - /** * @brief Tickless idle/low power functionality. */ diff --git a/portable/IAR/ARM_CM35P_NTZ/non_secure/portmacrocommon.h b/portable/IAR/ARM_CM35P_NTZ/non_secure/portmacrocommon.h index 083eea5cf0..60ef37380a 100644 --- a/portable/IAR/ARM_CM35P_NTZ/non_secure/portmacrocommon.h +++ b/portable/IAR/ARM_CM35P_NTZ/non_secure/portmacrocommon.h @@ -370,20 +370,6 @@ extern void vClearInterruptMask( uint32_t ulMask ) /* __attribute__(( naked )) P #define portEXIT_CRITICAL() vPortExitCritical() /*-----------------------------------------------------------*/ -/* Runtime checks on port configuration */ -#ifndef configCHECK_HANDLER_INSTALLATION - #if ( configASSERT_DEFINED == 1 ) - #define configCHECK_HANDLER_INSTALLATION 1 - #else - #define configCHECK_HANDLER_INSTALLATION 0 - #endif -#else - #if ( configCHECK_HANDLER_INSTALLATION == 1 && configASSERT_DEFINED == 0 ) - #error You must define configASSERT() when configCHECK_HANDLER_INSTALLATION is 1. - #endif -#endif -/*-----------------------------------------------------------*/ - /** * @brief Tickless idle/low power functionality. */ diff --git a/portable/IAR/ARM_CM4F/portmacro.h b/portable/IAR/ARM_CM4F/portmacro.h index 7b82c0c939..20467efcbb 100644 --- a/portable/IAR/ARM_CM4F/portmacro.h +++ b/portable/IAR/ARM_CM4F/portmacro.h @@ -172,20 +172,6 @@ extern void vPortExitCritical( void ); #define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void * pvParameters ) /*-----------------------------------------------------------*/ -/* Runtime checks on port configuration */ -#ifndef configCHECK_HANDLER_INSTALLATION - #if ( configASSERT_DEFINED == 1 ) - #define configCHECK_HANDLER_INSTALLATION 1 - #else - #define configCHECK_HANDLER_INSTALLATION 0 - #endif -#else - #if ( configCHECK_HANDLER_INSTALLATION == 1 && configASSERT_DEFINED == 0 ) - #error You must define configASSERT() when configCHECK_HANDLER_INSTALLATION is 1. - #endif -#endif -/*-----------------------------------------------------------*/ - #ifdef configASSERT void vPortValidateInterruptPriority( void ); #define portASSERT_IF_INTERRUPT_PRIORITY_INVALID() vPortValidateInterruptPriority() diff --git a/portable/IAR/ARM_CM4F_MPU/portmacro.h b/portable/IAR/ARM_CM4F_MPU/portmacro.h index 6dad44d93e..98b087e11f 100644 --- a/portable/IAR/ARM_CM4F_MPU/portmacro.h +++ b/portable/IAR/ARM_CM4F_MPU/portmacro.h @@ -288,20 +288,6 @@ typedef struct MPU_SETTINGS #define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x ) /*-----------------------------------------------------------*/ -/* Runtime checks on port configuration */ -#ifndef configCHECK_HANDLER_INSTALLATION - #if ( configASSERT_DEFINED == 1 ) - #define configCHECK_HANDLER_INSTALLATION 1 - #else - #define configCHECK_HANDLER_INSTALLATION 0 - #endif -#else - #if ( configCHECK_HANDLER_INSTALLATION == 1 && configASSERT_DEFINED == 0 ) - #error You must define configASSERT() when configCHECK_HANDLER_INSTALLATION is 1. - #endif -#endif -/*-----------------------------------------------------------*/ - /* Architecture specific optimisations. */ #ifndef configUSE_PORT_OPTIMISED_TASK_SELECTION #define configUSE_PORT_OPTIMISED_TASK_SELECTION 1 diff --git a/portable/IAR/ARM_CM55/non_secure/portmacrocommon.h b/portable/IAR/ARM_CM55/non_secure/portmacrocommon.h index 083eea5cf0..60ef37380a 100644 --- a/portable/IAR/ARM_CM55/non_secure/portmacrocommon.h +++ b/portable/IAR/ARM_CM55/non_secure/portmacrocommon.h @@ -370,20 +370,6 @@ extern void vClearInterruptMask( uint32_t ulMask ) /* __attribute__(( naked )) P #define portEXIT_CRITICAL() vPortExitCritical() /*-----------------------------------------------------------*/ -/* Runtime checks on port configuration */ -#ifndef configCHECK_HANDLER_INSTALLATION - #if ( configASSERT_DEFINED == 1 ) - #define configCHECK_HANDLER_INSTALLATION 1 - #else - #define configCHECK_HANDLER_INSTALLATION 0 - #endif -#else - #if ( configCHECK_HANDLER_INSTALLATION == 1 && configASSERT_DEFINED == 0 ) - #error You must define configASSERT() when configCHECK_HANDLER_INSTALLATION is 1. - #endif -#endif -/*-----------------------------------------------------------*/ - /** * @brief Tickless idle/low power functionality. */ diff --git a/portable/IAR/ARM_CM55_NTZ/non_secure/portmacrocommon.h b/portable/IAR/ARM_CM55_NTZ/non_secure/portmacrocommon.h index 083eea5cf0..60ef37380a 100644 --- a/portable/IAR/ARM_CM55_NTZ/non_secure/portmacrocommon.h +++ b/portable/IAR/ARM_CM55_NTZ/non_secure/portmacrocommon.h @@ -370,20 +370,6 @@ extern void vClearInterruptMask( uint32_t ulMask ) /* __attribute__(( naked )) P #define portEXIT_CRITICAL() vPortExitCritical() /*-----------------------------------------------------------*/ -/* Runtime checks on port configuration */ -#ifndef configCHECK_HANDLER_INSTALLATION - #if ( configASSERT_DEFINED == 1 ) - #define configCHECK_HANDLER_INSTALLATION 1 - #else - #define configCHECK_HANDLER_INSTALLATION 0 - #endif -#else - #if ( configCHECK_HANDLER_INSTALLATION == 1 && configASSERT_DEFINED == 0 ) - #error You must define configASSERT() when configCHECK_HANDLER_INSTALLATION is 1. - #endif -#endif -/*-----------------------------------------------------------*/ - /** * @brief Tickless idle/low power functionality. */ diff --git a/portable/IAR/ARM_CM85/non_secure/portmacrocommon.h b/portable/IAR/ARM_CM85/non_secure/portmacrocommon.h index 083eea5cf0..60ef37380a 100644 --- a/portable/IAR/ARM_CM85/non_secure/portmacrocommon.h +++ b/portable/IAR/ARM_CM85/non_secure/portmacrocommon.h @@ -370,20 +370,6 @@ extern void vClearInterruptMask( uint32_t ulMask ) /* __attribute__(( naked )) P #define portEXIT_CRITICAL() vPortExitCritical() /*-----------------------------------------------------------*/ -/* Runtime checks on port configuration */ -#ifndef configCHECK_HANDLER_INSTALLATION - #if ( configASSERT_DEFINED == 1 ) - #define configCHECK_HANDLER_INSTALLATION 1 - #else - #define configCHECK_HANDLER_INSTALLATION 0 - #endif -#else - #if ( configCHECK_HANDLER_INSTALLATION == 1 && configASSERT_DEFINED == 0 ) - #error You must define configASSERT() when configCHECK_HANDLER_INSTALLATION is 1. - #endif -#endif -/*-----------------------------------------------------------*/ - /** * @brief Tickless idle/low power functionality. */ diff --git a/portable/IAR/ARM_CM85_NTZ/non_secure/portmacrocommon.h b/portable/IAR/ARM_CM85_NTZ/non_secure/portmacrocommon.h index 083eea5cf0..60ef37380a 100644 --- a/portable/IAR/ARM_CM85_NTZ/non_secure/portmacrocommon.h +++ b/portable/IAR/ARM_CM85_NTZ/non_secure/portmacrocommon.h @@ -370,20 +370,6 @@ extern void vClearInterruptMask( uint32_t ulMask ) /* __attribute__(( naked )) P #define portEXIT_CRITICAL() vPortExitCritical() /*-----------------------------------------------------------*/ -/* Runtime checks on port configuration */ -#ifndef configCHECK_HANDLER_INSTALLATION - #if ( configASSERT_DEFINED == 1 ) - #define configCHECK_HANDLER_INSTALLATION 1 - #else - #define configCHECK_HANDLER_INSTALLATION 0 - #endif -#else - #if ( configCHECK_HANDLER_INSTALLATION == 1 && configASSERT_DEFINED == 0 ) - #error You must define configASSERT() when configCHECK_HANDLER_INSTALLATION is 1. - #endif -#endif -/*-----------------------------------------------------------*/ - /** * @brief Tickless idle/low power functionality. */ From 84b6981fe54f300561e8d49841753c5a32ff481b Mon Sep 17 00:00:00 2001 From: Jeff Tenney Date: Wed, 25 Oct 2023 14:10:25 -0700 Subject: [PATCH 18/23] Replicate to Cortex-M7 r0p1 --- portable/GCC/ARM_CM7/r0p1/port.c | 39 +++++++++++++++++++++++++++++++- portable/IAR/ARM_CM7/r0p1/port.c | 39 +++++++++++++++++++++++++++++++- 2 files changed, 76 insertions(+), 2 deletions(-) diff --git a/portable/GCC/ARM_CM7/r0p1/port.c b/portable/GCC/ARM_CM7/r0p1/port.c index c22a3592b7..a34b8067a9 100644 --- a/portable/GCC/ARM_CM7/r0p1/port.c +++ b/portable/GCC/ARM_CM7/r0p1/port.c @@ -38,10 +38,14 @@ #error This port can only be used when the project options are configured to enable hardware floating point support. #endif +/* Prototype to which all Interrupt Service Routines conform. */ +typedef void (* portISR_t)( void ); + /* Constants required to manipulate the core. Registers first... */ #define portNVIC_SYSTICK_CTRL_REG ( *( ( volatile uint32_t * ) 0xe000e010 ) ) #define portNVIC_SYSTICK_LOAD_REG ( *( ( volatile uint32_t * ) 0xe000e014 ) ) #define portNVIC_SYSTICK_CURRENT_VALUE_REG ( *( ( volatile uint32_t * ) 0xe000e018 ) ) +#define portNVIC_SHPR2_REG ( *( ( volatile uint32_t * ) 0xe000ed1c ) ) #define portNVIC_SHPR3_REG ( *( ( volatile uint32_t * ) 0xe000ed20 ) ) /* ...then bits in the registers. */ #define portNVIC_SYSTICK_CLK_BIT ( 1UL << 2UL ) @@ -56,6 +60,11 @@ #define portNVIC_PENDSV_PRI ( ( ( uint32_t ) portMIN_INTERRUPT_PRIORITY ) << 16UL ) #define portNVIC_SYSTICK_PRI ( ( ( uint32_t ) portMIN_INTERRUPT_PRIORITY ) << 24UL ) +/* Constants used to check the installation of the FreeRTOS interrupt handlers. */ +#define portSCB_VTOR_REG ( *( ( portISR_t ** ) 0xE000ED08 ) ) +#define portVECTOR_INDEX_SVC ( 11 ) +#define portVECTOR_INDEX_PENDSV ( 14 ) + /* Constants required to check the validity of an interrupt priority. */ #define portFIRST_USER_INTERRUPT_NUMBER ( 16 ) #define portNVIC_IP_REGISTERS_OFFSET_16 ( 0xE000E3F0 ) @@ -290,6 +299,32 @@ static void prvPortStartFirstTask( void ) */ BaseType_t xPortStartScheduler( void ) { + /* Applications that route program control to the FreeRTOS interrupt + * handlers through intermediate handlers (indirect routing) should set + * configCHECK_HANDLER_INSTALLATION to 0 in FreeRTOSConfig.h. Direct + * routing, which is validated here when configCHECK_HANDLER_INSTALLATION + * is 1, is preferred when possible. */ + #if ( configCHECK_HANDLER_INSTALLATION == 1 ) + { + const portISR_t * const pxVectorTable = portSCB_VTOR_REG; + + /* Verify correct installation of the FreeRTOS handlers for SVCall and + * PendSV. Do not check the installation of the SysTick handler because + * the application may provide the OS tick without using the SysTick + * timer by overriding the weak function vPortSetupTimerInterrupt(). + * + * Assertion failures here can be caused by incorrect installation of + * the FreeRTOS handlers. For help installing the handlers, see + * https://www.FreeRTOS.org/FAQHelp.html + * + * Systems with a configurable address for the interrupt vector table + * can also encounter assertion failures or even system faults here if + * VTOR is not set correctly to point to the application's vector table. */ + configASSERT( pxVectorTable[ portVECTOR_INDEX_SVC ] == vPortSVCHandler ); + configASSERT( pxVectorTable[ portVECTOR_INDEX_PENDSV ] == xPortPendSVHandler ); + } + #endif /* configCHECK_HANDLER_INSTALLATION */ + #if ( configASSERT_DEFINED == 1 ) { volatile uint8_t ucOriginalPriority; @@ -374,9 +409,11 @@ BaseType_t xPortStartScheduler( void ) } #endif /* configASSERT_DEFINED */ - /* Make PendSV and SysTick the lowest priority interrupts. */ + /* Make PendSV and SysTick the lowest priority interrupts, and make SVCall + * the highest priority. */ portNVIC_SHPR3_REG |= portNVIC_PENDSV_PRI; portNVIC_SHPR3_REG |= portNVIC_SYSTICK_PRI; + portNVIC_SHPR2_REG = 0; /* Start the timer that generates the tick ISR. Interrupts are disabled * here already. */ diff --git a/portable/IAR/ARM_CM7/r0p1/port.c b/portable/IAR/ARM_CM7/r0p1/port.c index 58129a4dfc..2ae2292787 100644 --- a/portable/IAR/ARM_CM7/r0p1/port.c +++ b/portable/IAR/ARM_CM7/r0p1/port.c @@ -45,10 +45,14 @@ #error configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to 0. See http: /*www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */ #endif +/* Prototype to which all Interrupt Service Routines conform. */ +typedef void (* portISR_t)( void ); + /* Constants required to manipulate the core. Registers first... */ #define portNVIC_SYSTICK_CTRL_REG ( *( ( volatile uint32_t * ) 0xe000e010 ) ) #define portNVIC_SYSTICK_LOAD_REG ( *( ( volatile uint32_t * ) 0xe000e014 ) ) #define portNVIC_SYSTICK_CURRENT_VALUE_REG ( *( ( volatile uint32_t * ) 0xe000e018 ) ) +#define portNVIC_SHPR2_REG ( *( ( volatile uint32_t * ) 0xe000ed1c ) ) #define portNVIC_SHPR3_REG ( *( ( volatile uint32_t * ) 0xe000ed20 ) ) /* ...then bits in the registers. */ #define portNVIC_SYSTICK_CLK_BIT ( 1UL << 2UL ) @@ -63,6 +67,11 @@ #define portNVIC_PENDSV_PRI ( ( ( uint32_t ) portMIN_INTERRUPT_PRIORITY ) << 16UL ) #define portNVIC_SYSTICK_PRI ( ( ( uint32_t ) portMIN_INTERRUPT_PRIORITY ) << 24UL ) +/* Constants used to check the installation of the FreeRTOS interrupt handlers. */ +#define portSCB_VTOR_REG ( *( ( portISR_t ** ) 0xE000ED08 ) ) +#define portVECTOR_INDEX_SVC ( 11 ) +#define portVECTOR_INDEX_PENDSV ( 14 ) + /* Constants required to check the validity of an interrupt priority. */ #define portFIRST_USER_INTERRUPT_NUMBER ( 16 ) #define portNVIC_IP_REGISTERS_OFFSET_16 ( 0xE000E3F0 ) @@ -234,6 +243,32 @@ static void prvTaskExitError( void ) */ BaseType_t xPortStartScheduler( void ) { + /* Applications that route program control to the FreeRTOS interrupt + * handlers through intermediate handlers (indirect routing) should set + * configCHECK_HANDLER_INSTALLATION to 0 in FreeRTOSConfig.h. Direct + * routing, which is validated here when configCHECK_HANDLER_INSTALLATION + * is 1, is preferred when possible. */ + #if ( configCHECK_HANDLER_INSTALLATION == 1 ) + { + const portISR_t * const pxVectorTable = portSCB_VTOR_REG; + + /* Verify correct installation of the FreeRTOS handlers for SVCall and + * PendSV. Do not check the installation of the SysTick handler because + * the application may provide the OS tick without using the SysTick + * timer by overriding the weak function vPortSetupTimerInterrupt(). + * + * Assertion failures here can be caused by incorrect installation of + * the FreeRTOS handlers. For help installing the handlers, see + * https://www.FreeRTOS.org/FAQHelp.html + * + * Systems with a configurable address for the interrupt vector table + * can also encounter assertion failures or even system faults here if + * VTOR is not set correctly to point to the application's vector table. */ + configASSERT( pxVectorTable[ portVECTOR_INDEX_SVC ] == vPortSVCHandler ); + configASSERT( pxVectorTable[ portVECTOR_INDEX_PENDSV ] == xPortPendSVHandler ); + } + #endif /* configCHECK_HANDLER_INSTALLATION */ + #if ( configASSERT_DEFINED == 1 ) { volatile uint8_t ucOriginalPriority; @@ -318,9 +353,11 @@ BaseType_t xPortStartScheduler( void ) } #endif /* configASSERT_DEFINED */ - /* Make PendSV and SysTick the lowest priority interrupts. */ + /* Make PendSV and SysTick the lowest priority interrupts, and make SVCall + * the highest priority. */ portNVIC_SHPR3_REG |= portNVIC_PENDSV_PRI; portNVIC_SHPR3_REG |= portNVIC_SYSTICK_PRI; + portNVIC_SHPR2_REG = 0; /* Start the timer that generates the tick ISR. Interrupts are disabled * here already. */ From 869f78e2b080f3d3b5550f26747c3c5b8b724a66 Mon Sep 17 00:00:00 2001 From: Jeff Tenney Date: Wed, 25 Oct 2023 14:19:18 -0700 Subject: [PATCH 19/23] uncrustify --- include/FreeRTOS.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/FreeRTOS.h b/include/FreeRTOS.h index 8fcd932f22..8edb991205 100644 --- a/include/FreeRTOS.h +++ b/include/FreeRTOS.h @@ -368,8 +368,9 @@ #ifndef configCHECK_HANDLER_INSTALLATION #define configCHECK_HANDLER_INSTALLATION 1 #else - /* The application has explicitly defined configCHECK_HANDLER_INSTALLATION - * to 1. The checks work only if configASSERT() is defined. */ + +/* The application has explicitly defined configCHECK_HANDLER_INSTALLATION + * to 1. The checks work only if configASSERT() is defined. */ #if ( configCHECK_HANDLER_INSTALLATION == 1 && configASSERT_DEFINED == 0 ) #error You must define configASSERT() when configCHECK_HANDLER_INSTALLATION is 1. #endif From 2e6494b691e4904fa3cbf4addaa06b0b5da5ed97 Mon Sep 17 00:00:00 2001 From: Jeff Tenney Date: Thu, 26 Oct 2023 08:51:52 -0700 Subject: [PATCH 20/23] Set SVC priority to zero in ARMv7-M MPU ports --- portable/GCC/ARM_CM3_MPU/port.c | 9 ++++----- portable/GCC/ARM_CM4_MPU/port.c | 8 +++----- portable/IAR/ARM_CM4F_MPU/port.c | 6 +++--- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/portable/GCC/ARM_CM3_MPU/port.c b/portable/GCC/ARM_CM3_MPU/port.c index 916b84e823..63de0573a0 100644 --- a/portable/GCC/ARM_CM3_MPU/port.c +++ b/portable/GCC/ARM_CM3_MPU/port.c @@ -89,7 +89,6 @@ typedef void (* portISR_t)( void ); #define portMIN_INTERRUPT_PRIORITY ( 255UL ) #define portNVIC_PENDSV_PRI ( ( ( uint32_t ) portMIN_INTERRUPT_PRIORITY ) << 16UL ) #define portNVIC_SYSTICK_PRI ( ( ( uint32_t ) portMIN_INTERRUPT_PRIORITY ) << 24UL ) -#define portNVIC_SVC_PRI ( ( ( uint32_t ) configMAX_SYSCALL_INTERRUPT_PRIORITY - 1UL ) << 24UL ) /* Constants required to set up the initial stack. */ #define portINITIAL_XPSR ( 0x01000000 ) @@ -420,7 +419,6 @@ void vSVCHandler_C( uint32_t * pulParam ) /* PRIVILEGED_FUNCTION */ switch( ucSVCNumber ) { case portSVC_START_SCHEDULER: - portNVIC_SHPR2_REG |= portNVIC_SVC_PRI; prvRestoreContextOfFirstTask(); break; @@ -905,11 +903,12 @@ BaseType_t xPortStartScheduler( void ) } #endif /* configASSERT_DEFINED */ - /* Make PendSV and SysTick the same priority as the kernel, and the SVC - * handler higher priority so it can be used to exit a critical section (where - * lower priorities are masked). */ + /* Make PendSV and SysTick the lowest priority interrupts, and make SVCall + * the highest priority. */ portNVIC_SHPR3_REG |= portNVIC_PENDSV_PRI; portNVIC_SHPR3_REG |= portNVIC_SYSTICK_PRI; + portNVIC_SHPR2_REG = 0; + /* Configure the regions in the MPU that are common to all tasks. */ prvSetupMPU(); diff --git a/portable/GCC/ARM_CM4_MPU/port.c b/portable/GCC/ARM_CM4_MPU/port.c index 710838d4a3..668ec6c0d7 100644 --- a/portable/GCC/ARM_CM4_MPU/port.c +++ b/portable/GCC/ARM_CM4_MPU/port.c @@ -99,7 +99,6 @@ typedef void (* portISR_t)( void ); #define portMIN_INTERRUPT_PRIORITY ( 255UL ) #define portNVIC_PENDSV_PRI ( ( ( uint32_t ) portMIN_INTERRUPT_PRIORITY ) << 16UL ) #define portNVIC_SYSTICK_PRI ( ( ( uint32_t ) portMIN_INTERRUPT_PRIORITY ) << 24UL ) -#define portNVIC_SVC_PRI ( ( ( uint32_t ) configMAX_SYSCALL_INTERRUPT_PRIORITY - 1UL ) << 24UL ) /* Constants required to manipulate the VFP. */ #define portFPCCR ( ( volatile uint32_t * ) 0xe000ef34UL ) /* Floating point context control register. */ @@ -460,7 +459,6 @@ void vSVCHandler_C( uint32_t * pulParam ) /* PRIVILEGED_FUNCTION */ switch( ucSVCNumber ) { case portSVC_START_SCHEDULER: - portNVIC_SHPR2_REG |= portNVIC_SVC_PRI; prvRestoreContextOfFirstTask(); break; @@ -1013,11 +1011,11 @@ BaseType_t xPortStartScheduler( void ) } #endif /* configASSERT_DEFINED */ - /* Make PendSV and SysTick the same priority as the kernel, and the SVC - * handler higher priority so it can be used to exit a critical section (where - * lower priorities are masked). */ + /* Make PendSV and SysTick the lowest priority interrupts, and make SVCall + * the highest priority. */ portNVIC_SHPR3_REG |= portNVIC_PENDSV_PRI; portNVIC_SHPR3_REG |= portNVIC_SYSTICK_PRI; + portNVIC_SHPR2_REG = 0; /* Configure the regions in the MPU that are common to all tasks. */ prvSetupMPU(); diff --git a/portable/IAR/ARM_CM4F_MPU/port.c b/portable/IAR/ARM_CM4F_MPU/port.c index 0a9d8272c5..a8359a8465 100644 --- a/portable/IAR/ARM_CM4F_MPU/port.c +++ b/portable/IAR/ARM_CM4F_MPU/port.c @@ -110,7 +110,6 @@ typedef void (* portISR_t)( void ); #define portMIN_INTERRUPT_PRIORITY ( 255UL ) #define portNVIC_PENDSV_PRI ( ( ( uint32_t ) portMIN_INTERRUPT_PRIORITY ) << 16UL ) #define portNVIC_SYSTICK_PRI ( ( ( uint32_t ) portMIN_INTERRUPT_PRIORITY ) << 24UL ) -#define portNVIC_SVC_PRI ( ( ( uint32_t ) configMAX_SYSCALL_INTERRUPT_PRIORITY - 1UL ) << 24UL ) /* Constants used to check the installation of the FreeRTOS interrupt handlers. */ #define portSCB_VTOR_REG ( *( ( portISR_t ** ) 0xE000ED08 ) ) @@ -389,7 +388,6 @@ void vPortSVCHandler_C( uint32_t * pulParam ) /* PRIVILEGED_FUNCTION */ switch( ucSVCNumber ) { case portSVC_START_SCHEDULER: - portNVIC_SHPR2_REG |= portNVIC_SVC_PRI; vPortRestoreContextOfFirstTask(); break; @@ -895,9 +893,11 @@ BaseType_t xPortStartScheduler( void ) } #endif /* configASSERT_DEFINED */ - /* Make PendSV and SysTick the lowest priority interrupts. */ + /* Make PendSV and SysTick the lowest priority interrupts, and make SVCall + * the highest priority. */ portNVIC_SHPR3_REG |= portNVIC_PENDSV_PRI; portNVIC_SHPR3_REG |= portNVIC_SYSTICK_PRI; + portNVIC_SHPR2_REG = 0; /* Configure the regions in the MPU that are common to all tasks. */ prvSetupMPU(); From cdf8cc5206a5a805f45b0687e736616846904d7b Mon Sep 17 00:00:00 2001 From: Gaurav Aggarwal Date: Sat, 9 Dec 2023 17:51:21 +0530 Subject: [PATCH 21/23] Update comments Also update the only remaining MPU port RVDS/ARM_CM4_MPU. Signed-off-by: Gaurav Aggarwal --- include/FreeRTOS.h | 4 +- portable/ARMv8M/non_secure/port.c | 32 ++++++++----- portable/GCC/ARM_CM0/port.c | 47 +++++++++++-------- portable/GCC/ARM_CM23/non_secure/port.c | 32 ++++++++----- portable/GCC/ARM_CM23_NTZ/non_secure/port.c | 32 ++++++++----- portable/GCC/ARM_CM3/port.c | 32 ++++++++----- portable/GCC/ARM_CM33/non_secure/port.c | 32 ++++++++----- portable/GCC/ARM_CM33_NTZ/non_secure/port.c | 32 ++++++++----- portable/GCC/ARM_CM35P/non_secure/port.c | 32 ++++++++----- portable/GCC/ARM_CM35P_NTZ/non_secure/port.c | 32 ++++++++----- portable/GCC/ARM_CM3_MPU/port.c | 32 ++++++++----- portable/GCC/ARM_CM4F/port.c | 32 ++++++++----- portable/GCC/ARM_CM4_MPU/port.c | 32 ++++++++----- portable/GCC/ARM_CM55/non_secure/port.c | 32 ++++++++----- portable/GCC/ARM_CM55_NTZ/non_secure/port.c | 32 ++++++++----- portable/GCC/ARM_CM7/r0p1/port.c | 32 ++++++++----- portable/GCC/ARM_CM85/non_secure/port.c | 32 ++++++++----- portable/GCC/ARM_CM85_NTZ/non_secure/port.c | 32 ++++++++----- portable/IAR/ARM_CM0/port.c | 39 +++++++++------- portable/IAR/ARM_CM23/non_secure/port.c | 32 ++++++++----- portable/IAR/ARM_CM23_NTZ/non_secure/port.c | 32 ++++++++----- portable/IAR/ARM_CM3/port.c | 32 ++++++++----- portable/IAR/ARM_CM33/non_secure/port.c | 32 ++++++++----- portable/IAR/ARM_CM33_NTZ/non_secure/port.c | 32 ++++++++----- portable/IAR/ARM_CM35P/non_secure/port.c | 32 ++++++++----- portable/IAR/ARM_CM35P_NTZ/non_secure/port.c | 32 ++++++++----- portable/IAR/ARM_CM4F/port.c | 32 ++++++++----- portable/IAR/ARM_CM4F_MPU/port.c | 32 ++++++++----- portable/IAR/ARM_CM55/non_secure/port.c | 32 ++++++++----- portable/IAR/ARM_CM55_NTZ/non_secure/port.c | 32 ++++++++----- portable/IAR/ARM_CM7/r0p1/port.c | 32 ++++++++----- portable/IAR/ARM_CM85/non_secure/port.c | 32 ++++++++----- portable/IAR/ARM_CM85_NTZ/non_secure/port.c | 32 ++++++++----- portable/RVDS/ARM_CM4_MPU/port.c | 49 ++++++++++++++++++-- 34 files changed, 697 insertions(+), 402 deletions(-) diff --git a/include/FreeRTOS.h b/include/FreeRTOS.h index cc02666e4b..b6caec77f7 100644 --- a/include/FreeRTOS.h +++ b/include/FreeRTOS.h @@ -370,8 +370,8 @@ #else /* The application has explicitly defined configCHECK_HANDLER_INSTALLATION - * to 1. The checks work only if configASSERT() is defined. */ - #if ( configCHECK_HANDLER_INSTALLATION == 1 && configASSERT_DEFINED == 0 ) + * to 1. The checks requires configASSERT() to be defined. */ + #if ( ( configCHECK_HANDLER_INSTALLATION == 1 ) && ( configASSERT_DEFINED == 0 ) ) #error You must define configASSERT() when configCHECK_HANDLER_INSTALLATION is 1. #endif #endif diff --git a/portable/ARMv8M/non_secure/port.c b/portable/ARMv8M/non_secure/port.c index 865b583c27..e7f7a6501e 100644 --- a/portable/ARMv8M/non_secure/port.c +++ b/portable/ARMv8M/non_secure/port.c @@ -81,9 +81,9 @@ /*-----------------------------------------------------------*/ /** - * @brief Prototype to which all Interrupt Service Routines conform. + * @brief Prototype of all Interrupt Service Routines (ISRs). */ -typedef void (* portISR_t)( void ); +typedef void ( *portISR_t )( void ); /*-----------------------------------------------------------*/ /** @@ -1612,23 +1612,31 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ { - /* Applications that route program control to the FreeRTOS interrupt - * handlers through intermediate handlers (indirect routing) should set - * configCHECK_HANDLER_INSTALLATION to 0 in FreeRTOSConfig.h. Direct + /* An application can install FreeRTOS interrupt handlers in one of the + * folllowing ways: + * 1. Direct Routing - Install the functions SVC_Handler and PendSV_Handler + * for SVCall and PendSV interrupts respectively. + * 2. Indirect Routing - Install separate handlers for SVCall and PendSV + * interrupts and route program control from those handlers to + * SVC_Handler and PendSV_Handler functions. + * + * Applications that use Indirect Routing must set + * configCHECK_HANDLER_INSTALLATION to 0 in their FreeRTOSConfig.h. Direct * routing, which is validated here when configCHECK_HANDLER_INSTALLATION - * is 1, is preferred when possible. */ + * is 1, should be preferred when possible. */ #if ( configCHECK_HANDLER_INSTALLATION == 1 ) { const portISR_t * const pxVectorTable = portSCB_VTOR_REG; - /* Verify correct installation of the FreeRTOS handlers for SVCall and - * PendSV. Do not check the installation of the SysTick handler because - * the application may provide the OS tick without using the SysTick + /* Validate that the application has correctly installed the FreeRTOS + * handlers for SVCall and PendSV interrupts. We do not check the + * installation of the SysTick handler because the application may + * choose to drive the RTOS tick using a timer other than the SysTick * timer by overriding the weak function vPortSetupTimerInterrupt(). * - * Assertion failures here can be caused by incorrect installation of - * the FreeRTOS handlers. For help installing the handlers, see - * https://www.FreeRTOS.org/FAQHelp.html + * Assertion failures here indicate incorrect installation of the + * FreeRTOS handlers. For help installing the FreeRTOS handlers, see + * https://www.FreeRTOS.org/FAQHelp.html. * * Systems with a configurable address for the interrupt vector table * can also encounter assertion failures or even system faults here if diff --git a/portable/GCC/ARM_CM0/port.c b/portable/GCC/ARM_CM0/port.c index d7ccee29ac..53bc33a410 100644 --- a/portable/GCC/ARM_CM0/port.c +++ b/portable/GCC/ARM_CM0/port.c @@ -34,8 +34,8 @@ #include "FreeRTOS.h" #include "task.h" -/* Prototype to which all Interrupt Service Routines conform. */ -typedef void (* portISR_t)( void ); +/* Prototype of all Interrupt Service Routines (ISRs). */ +typedef void ( * portISR_t )( void ); /* Constants required to manipulate the NVIC. */ #define portNVIC_SYSTICK_CTRL_REG ( *( ( volatile uint32_t * ) 0xe000e010 ) ) @@ -215,12 +215,12 @@ void vPortStartFirstTask( void ) " ldr r2, pxCurrentTCBConst2 \n" /* Obtain location of pxCurrentTCB. */ " ldr r3, [r2] \n" " ldr r0, [r3] \n" /* The first item in pxCurrentTCB is the task top of stack. */ - " adds r0, #32 \n" /* Discard everything up to r0. */ - " msr psp, r0 \n" /* This is now the new top of stack to use in the task. */ + " adds r0, #32 \n" /* Discard everything up to r0. */ + " msr psp, r0 \n" /* This is now the new top of stack to use in the task. */ " movs r0, #2 \n" /* Switch to the psp stack. */ - " msr CONTROL, r0 \n" + " msr CONTROL, r0 \n" " isb \n" - " pop {r0-r5} \n" /* Pop the registers that are saved automatically. */ + " pop {r0-r5} \n" /* Pop the registers that are saved automatically. */ " mov lr, r5 \n" /* lr is now in r5. */ " pop {r3} \n" /* Return address is now in r3. */ " pop {r2} \n" /* Pop and discard XPSR. */ @@ -238,26 +238,33 @@ void vPortStartFirstTask( void ) */ BaseType_t xPortStartScheduler( void ) { - /* Applications that route program control to the FreeRTOS interrupt - * handlers through intermediate handlers (indirect routing) should set - * configCHECK_HANDLER_INSTALLATION to 0 in FreeRTOSConfig.h. Direct + /* An application can install FreeRTOS interrupt handlers in one of the + * folllowing ways: + * 1. Direct Routing - Install the function xPortPendSVHandler for PendSV + * interrupt. + * 2. Indirect Routing - Install separate handler for PendSV interrupt and + * route program control from that handler to xPortPendSVHandler function. + * + * Applications that use Indirect Routing must set + * configCHECK_HANDLER_INSTALLATION to 0 in their FreeRTOSConfig.h. Direct * routing, which is validated here when configCHECK_HANDLER_INSTALLATION - * is 1, is preferred when possible. */ + * is 1, should be preferred when possible. */ #if ( configCHECK_HANDLER_INSTALLATION == 1 ) { - /* Point pxVectorTable at the interrupt vector table. Systems without - * a VTOR register provide the value zero in place of the VTOR register - * and provide the vector table itself at address 0x00000000. */ + /* Point pxVectorTable to the interrupt vector table. Systems without + * a VTOR register provide the value zero in the VTOR register and + * the vector table itself is located at the address 0x00000000. */ const portISR_t * const pxVectorTable = portSCB_VTOR_REG; - /* Verify correct installation of the FreeRTOS handler for PendSV. Do - * not check the installation of the SysTick handler because the - * application may provide the OS tick without using the SysTick timer - * by overriding the weak function vPortSetupTimerInterrupt(). + /* Validate that the application has correctly installed the FreeRTOS + * handler for PendSV interrupt. We do not check the installation of the + * SysTick handler because the application may choose to drive the RTOS + * tick using a timer other than the SysTick timer by overriding the + * weak function vPortSetupTimerInterrupt(). * - * Assertion failures here can be caused by incorrect installation of - * the FreeRTOS handlers. For help installing the handlers, see - * https://www.FreeRTOS.org/FAQHelp.html + * Assertion failures here indicate incorrect installation of the + * FreeRTOS handler. For help installing the FreeRTOS handler, see + * https://www.FreeRTOS.org/FAQHelp.html. * * Systems with a configurable address for the interrupt vector table * can also encounter assertion failures or even system faults here if diff --git a/portable/GCC/ARM_CM23/non_secure/port.c b/portable/GCC/ARM_CM23/non_secure/port.c index 865b583c27..e7f7a6501e 100644 --- a/portable/GCC/ARM_CM23/non_secure/port.c +++ b/portable/GCC/ARM_CM23/non_secure/port.c @@ -81,9 +81,9 @@ /*-----------------------------------------------------------*/ /** - * @brief Prototype to which all Interrupt Service Routines conform. + * @brief Prototype of all Interrupt Service Routines (ISRs). */ -typedef void (* portISR_t)( void ); +typedef void ( *portISR_t )( void ); /*-----------------------------------------------------------*/ /** @@ -1612,23 +1612,31 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ { - /* Applications that route program control to the FreeRTOS interrupt - * handlers through intermediate handlers (indirect routing) should set - * configCHECK_HANDLER_INSTALLATION to 0 in FreeRTOSConfig.h. Direct + /* An application can install FreeRTOS interrupt handlers in one of the + * folllowing ways: + * 1. Direct Routing - Install the functions SVC_Handler and PendSV_Handler + * for SVCall and PendSV interrupts respectively. + * 2. Indirect Routing - Install separate handlers for SVCall and PendSV + * interrupts and route program control from those handlers to + * SVC_Handler and PendSV_Handler functions. + * + * Applications that use Indirect Routing must set + * configCHECK_HANDLER_INSTALLATION to 0 in their FreeRTOSConfig.h. Direct * routing, which is validated here when configCHECK_HANDLER_INSTALLATION - * is 1, is preferred when possible. */ + * is 1, should be preferred when possible. */ #if ( configCHECK_HANDLER_INSTALLATION == 1 ) { const portISR_t * const pxVectorTable = portSCB_VTOR_REG; - /* Verify correct installation of the FreeRTOS handlers for SVCall and - * PendSV. Do not check the installation of the SysTick handler because - * the application may provide the OS tick without using the SysTick + /* Validate that the application has correctly installed the FreeRTOS + * handlers for SVCall and PendSV interrupts. We do not check the + * installation of the SysTick handler because the application may + * choose to drive the RTOS tick using a timer other than the SysTick * timer by overriding the weak function vPortSetupTimerInterrupt(). * - * Assertion failures here can be caused by incorrect installation of - * the FreeRTOS handlers. For help installing the handlers, see - * https://www.FreeRTOS.org/FAQHelp.html + * Assertion failures here indicate incorrect installation of the + * FreeRTOS handlers. For help installing the FreeRTOS handlers, see + * https://www.FreeRTOS.org/FAQHelp.html. * * Systems with a configurable address for the interrupt vector table * can also encounter assertion failures or even system faults here if diff --git a/portable/GCC/ARM_CM23_NTZ/non_secure/port.c b/portable/GCC/ARM_CM23_NTZ/non_secure/port.c index 865b583c27..e7f7a6501e 100644 --- a/portable/GCC/ARM_CM23_NTZ/non_secure/port.c +++ b/portable/GCC/ARM_CM23_NTZ/non_secure/port.c @@ -81,9 +81,9 @@ /*-----------------------------------------------------------*/ /** - * @brief Prototype to which all Interrupt Service Routines conform. + * @brief Prototype of all Interrupt Service Routines (ISRs). */ -typedef void (* portISR_t)( void ); +typedef void ( *portISR_t )( void ); /*-----------------------------------------------------------*/ /** @@ -1612,23 +1612,31 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ { - /* Applications that route program control to the FreeRTOS interrupt - * handlers through intermediate handlers (indirect routing) should set - * configCHECK_HANDLER_INSTALLATION to 0 in FreeRTOSConfig.h. Direct + /* An application can install FreeRTOS interrupt handlers in one of the + * folllowing ways: + * 1. Direct Routing - Install the functions SVC_Handler and PendSV_Handler + * for SVCall and PendSV interrupts respectively. + * 2. Indirect Routing - Install separate handlers for SVCall and PendSV + * interrupts and route program control from those handlers to + * SVC_Handler and PendSV_Handler functions. + * + * Applications that use Indirect Routing must set + * configCHECK_HANDLER_INSTALLATION to 0 in their FreeRTOSConfig.h. Direct * routing, which is validated here when configCHECK_HANDLER_INSTALLATION - * is 1, is preferred when possible. */ + * is 1, should be preferred when possible. */ #if ( configCHECK_HANDLER_INSTALLATION == 1 ) { const portISR_t * const pxVectorTable = portSCB_VTOR_REG; - /* Verify correct installation of the FreeRTOS handlers for SVCall and - * PendSV. Do not check the installation of the SysTick handler because - * the application may provide the OS tick without using the SysTick + /* Validate that the application has correctly installed the FreeRTOS + * handlers for SVCall and PendSV interrupts. We do not check the + * installation of the SysTick handler because the application may + * choose to drive the RTOS tick using a timer other than the SysTick * timer by overriding the weak function vPortSetupTimerInterrupt(). * - * Assertion failures here can be caused by incorrect installation of - * the FreeRTOS handlers. For help installing the handlers, see - * https://www.FreeRTOS.org/FAQHelp.html + * Assertion failures here indicate incorrect installation of the + * FreeRTOS handlers. For help installing the FreeRTOS handlers, see + * https://www.FreeRTOS.org/FAQHelp.html. * * Systems with a configurable address for the interrupt vector table * can also encounter assertion failures or even system faults here if diff --git a/portable/GCC/ARM_CM3/port.c b/portable/GCC/ARM_CM3/port.c index 88246336e8..8ce6fa6c4c 100644 --- a/portable/GCC/ARM_CM3/port.c +++ b/portable/GCC/ARM_CM3/port.c @@ -34,8 +34,8 @@ #include "FreeRTOS.h" #include "task.h" -/* Prototype to which all Interrupt Service Routines conform. */ -typedef void (* portISR_t)( void ); +/* Prototype of all Interrupt Service Routines (ISRs). */ +typedef void ( * portISR_t )( void ); /* Constants required to manipulate the core. Registers first... */ #define portNVIC_SYSTICK_CTRL_REG ( *( ( volatile uint32_t * ) 0xe000e010 ) ) @@ -268,23 +268,31 @@ static void prvPortStartFirstTask( void ) */ BaseType_t xPortStartScheduler( void ) { - /* Applications that route program control to the FreeRTOS interrupt - * handlers through intermediate handlers (indirect routing) should set - * configCHECK_HANDLER_INSTALLATION to 0 in FreeRTOSConfig.h. Direct + /* An application can install FreeRTOS interrupt handlers in one of the + * folllowing ways: + * 1. Direct Routing - Install the functions vPortSVCHandler and + * xPortPendSVHandler for SVCall and PendSV interrupts respectively. + * 2. Indirect Routing - Install separate handlers for SVCall and PendSV + * interrupts and route program control from those handlers to + * vPortSVCHandler and xPortPendSVHandler functions. + * + * Applications that use Indirect Routing must set + * configCHECK_HANDLER_INSTALLATION to 0 in their FreeRTOSConfig.h. Direct * routing, which is validated here when configCHECK_HANDLER_INSTALLATION - * is 1, is preferred when possible. */ + * is 1, should be preferred when possible. */ #if ( configCHECK_HANDLER_INSTALLATION == 1 ) { const portISR_t * const pxVectorTable = portSCB_VTOR_REG; - /* Verify correct installation of the FreeRTOS handlers for SVCall and - * PendSV. Do not check the installation of the SysTick handler because - * the application may provide the OS tick without using the SysTick + /* Validate that the application has correctly installed the FreeRTOS + * handlers for SVCall and PendSV interrupts. We do not check the + * installation of the SysTick handler because the application may + * choose to drive the RTOS tick using a timer other than the SysTick * timer by overriding the weak function vPortSetupTimerInterrupt(). * - * Assertion failures here can be caused by incorrect installation of - * the FreeRTOS handlers. For help installing the handlers, see - * https://www.FreeRTOS.org/FAQHelp.html + * Assertion failures here indicate incorrect installation of the + * FreeRTOS handlers. For help installing the FreeRTOS handlers, see + * https://www.FreeRTOS.org/FAQHelp.html. * * Systems with a configurable address for the interrupt vector table * can also encounter assertion failures or even system faults here if diff --git a/portable/GCC/ARM_CM33/non_secure/port.c b/portable/GCC/ARM_CM33/non_secure/port.c index 865b583c27..e7f7a6501e 100644 --- a/portable/GCC/ARM_CM33/non_secure/port.c +++ b/portable/GCC/ARM_CM33/non_secure/port.c @@ -81,9 +81,9 @@ /*-----------------------------------------------------------*/ /** - * @brief Prototype to which all Interrupt Service Routines conform. + * @brief Prototype of all Interrupt Service Routines (ISRs). */ -typedef void (* portISR_t)( void ); +typedef void ( *portISR_t )( void ); /*-----------------------------------------------------------*/ /** @@ -1612,23 +1612,31 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ { - /* Applications that route program control to the FreeRTOS interrupt - * handlers through intermediate handlers (indirect routing) should set - * configCHECK_HANDLER_INSTALLATION to 0 in FreeRTOSConfig.h. Direct + /* An application can install FreeRTOS interrupt handlers in one of the + * folllowing ways: + * 1. Direct Routing - Install the functions SVC_Handler and PendSV_Handler + * for SVCall and PendSV interrupts respectively. + * 2. Indirect Routing - Install separate handlers for SVCall and PendSV + * interrupts and route program control from those handlers to + * SVC_Handler and PendSV_Handler functions. + * + * Applications that use Indirect Routing must set + * configCHECK_HANDLER_INSTALLATION to 0 in their FreeRTOSConfig.h. Direct * routing, which is validated here when configCHECK_HANDLER_INSTALLATION - * is 1, is preferred when possible. */ + * is 1, should be preferred when possible. */ #if ( configCHECK_HANDLER_INSTALLATION == 1 ) { const portISR_t * const pxVectorTable = portSCB_VTOR_REG; - /* Verify correct installation of the FreeRTOS handlers for SVCall and - * PendSV. Do not check the installation of the SysTick handler because - * the application may provide the OS tick without using the SysTick + /* Validate that the application has correctly installed the FreeRTOS + * handlers for SVCall and PendSV interrupts. We do not check the + * installation of the SysTick handler because the application may + * choose to drive the RTOS tick using a timer other than the SysTick * timer by overriding the weak function vPortSetupTimerInterrupt(). * - * Assertion failures here can be caused by incorrect installation of - * the FreeRTOS handlers. For help installing the handlers, see - * https://www.FreeRTOS.org/FAQHelp.html + * Assertion failures here indicate incorrect installation of the + * FreeRTOS handlers. For help installing the FreeRTOS handlers, see + * https://www.FreeRTOS.org/FAQHelp.html. * * Systems with a configurable address for the interrupt vector table * can also encounter assertion failures or even system faults here if diff --git a/portable/GCC/ARM_CM33_NTZ/non_secure/port.c b/portable/GCC/ARM_CM33_NTZ/non_secure/port.c index 865b583c27..e7f7a6501e 100644 --- a/portable/GCC/ARM_CM33_NTZ/non_secure/port.c +++ b/portable/GCC/ARM_CM33_NTZ/non_secure/port.c @@ -81,9 +81,9 @@ /*-----------------------------------------------------------*/ /** - * @brief Prototype to which all Interrupt Service Routines conform. + * @brief Prototype of all Interrupt Service Routines (ISRs). */ -typedef void (* portISR_t)( void ); +typedef void ( *portISR_t )( void ); /*-----------------------------------------------------------*/ /** @@ -1612,23 +1612,31 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ { - /* Applications that route program control to the FreeRTOS interrupt - * handlers through intermediate handlers (indirect routing) should set - * configCHECK_HANDLER_INSTALLATION to 0 in FreeRTOSConfig.h. Direct + /* An application can install FreeRTOS interrupt handlers in one of the + * folllowing ways: + * 1. Direct Routing - Install the functions SVC_Handler and PendSV_Handler + * for SVCall and PendSV interrupts respectively. + * 2. Indirect Routing - Install separate handlers for SVCall and PendSV + * interrupts and route program control from those handlers to + * SVC_Handler and PendSV_Handler functions. + * + * Applications that use Indirect Routing must set + * configCHECK_HANDLER_INSTALLATION to 0 in their FreeRTOSConfig.h. Direct * routing, which is validated here when configCHECK_HANDLER_INSTALLATION - * is 1, is preferred when possible. */ + * is 1, should be preferred when possible. */ #if ( configCHECK_HANDLER_INSTALLATION == 1 ) { const portISR_t * const pxVectorTable = portSCB_VTOR_REG; - /* Verify correct installation of the FreeRTOS handlers for SVCall and - * PendSV. Do not check the installation of the SysTick handler because - * the application may provide the OS tick without using the SysTick + /* Validate that the application has correctly installed the FreeRTOS + * handlers for SVCall and PendSV interrupts. We do not check the + * installation of the SysTick handler because the application may + * choose to drive the RTOS tick using a timer other than the SysTick * timer by overriding the weak function vPortSetupTimerInterrupt(). * - * Assertion failures here can be caused by incorrect installation of - * the FreeRTOS handlers. For help installing the handlers, see - * https://www.FreeRTOS.org/FAQHelp.html + * Assertion failures here indicate incorrect installation of the + * FreeRTOS handlers. For help installing the FreeRTOS handlers, see + * https://www.FreeRTOS.org/FAQHelp.html. * * Systems with a configurable address for the interrupt vector table * can also encounter assertion failures or even system faults here if diff --git a/portable/GCC/ARM_CM35P/non_secure/port.c b/portable/GCC/ARM_CM35P/non_secure/port.c index 865b583c27..e7f7a6501e 100644 --- a/portable/GCC/ARM_CM35P/non_secure/port.c +++ b/portable/GCC/ARM_CM35P/non_secure/port.c @@ -81,9 +81,9 @@ /*-----------------------------------------------------------*/ /** - * @brief Prototype to which all Interrupt Service Routines conform. + * @brief Prototype of all Interrupt Service Routines (ISRs). */ -typedef void (* portISR_t)( void ); +typedef void ( *portISR_t )( void ); /*-----------------------------------------------------------*/ /** @@ -1612,23 +1612,31 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ { - /* Applications that route program control to the FreeRTOS interrupt - * handlers through intermediate handlers (indirect routing) should set - * configCHECK_HANDLER_INSTALLATION to 0 in FreeRTOSConfig.h. Direct + /* An application can install FreeRTOS interrupt handlers in one of the + * folllowing ways: + * 1. Direct Routing - Install the functions SVC_Handler and PendSV_Handler + * for SVCall and PendSV interrupts respectively. + * 2. Indirect Routing - Install separate handlers for SVCall and PendSV + * interrupts and route program control from those handlers to + * SVC_Handler and PendSV_Handler functions. + * + * Applications that use Indirect Routing must set + * configCHECK_HANDLER_INSTALLATION to 0 in their FreeRTOSConfig.h. Direct * routing, which is validated here when configCHECK_HANDLER_INSTALLATION - * is 1, is preferred when possible. */ + * is 1, should be preferred when possible. */ #if ( configCHECK_HANDLER_INSTALLATION == 1 ) { const portISR_t * const pxVectorTable = portSCB_VTOR_REG; - /* Verify correct installation of the FreeRTOS handlers for SVCall and - * PendSV. Do not check the installation of the SysTick handler because - * the application may provide the OS tick without using the SysTick + /* Validate that the application has correctly installed the FreeRTOS + * handlers for SVCall and PendSV interrupts. We do not check the + * installation of the SysTick handler because the application may + * choose to drive the RTOS tick using a timer other than the SysTick * timer by overriding the weak function vPortSetupTimerInterrupt(). * - * Assertion failures here can be caused by incorrect installation of - * the FreeRTOS handlers. For help installing the handlers, see - * https://www.FreeRTOS.org/FAQHelp.html + * Assertion failures here indicate incorrect installation of the + * FreeRTOS handlers. For help installing the FreeRTOS handlers, see + * https://www.FreeRTOS.org/FAQHelp.html. * * Systems with a configurable address for the interrupt vector table * can also encounter assertion failures or even system faults here if diff --git a/portable/GCC/ARM_CM35P_NTZ/non_secure/port.c b/portable/GCC/ARM_CM35P_NTZ/non_secure/port.c index 865b583c27..e7f7a6501e 100644 --- a/portable/GCC/ARM_CM35P_NTZ/non_secure/port.c +++ b/portable/GCC/ARM_CM35P_NTZ/non_secure/port.c @@ -81,9 +81,9 @@ /*-----------------------------------------------------------*/ /** - * @brief Prototype to which all Interrupt Service Routines conform. + * @brief Prototype of all Interrupt Service Routines (ISRs). */ -typedef void (* portISR_t)( void ); +typedef void ( *portISR_t )( void ); /*-----------------------------------------------------------*/ /** @@ -1612,23 +1612,31 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ { - /* Applications that route program control to the FreeRTOS interrupt - * handlers through intermediate handlers (indirect routing) should set - * configCHECK_HANDLER_INSTALLATION to 0 in FreeRTOSConfig.h. Direct + /* An application can install FreeRTOS interrupt handlers in one of the + * folllowing ways: + * 1. Direct Routing - Install the functions SVC_Handler and PendSV_Handler + * for SVCall and PendSV interrupts respectively. + * 2. Indirect Routing - Install separate handlers for SVCall and PendSV + * interrupts and route program control from those handlers to + * SVC_Handler and PendSV_Handler functions. + * + * Applications that use Indirect Routing must set + * configCHECK_HANDLER_INSTALLATION to 0 in their FreeRTOSConfig.h. Direct * routing, which is validated here when configCHECK_HANDLER_INSTALLATION - * is 1, is preferred when possible. */ + * is 1, should be preferred when possible. */ #if ( configCHECK_HANDLER_INSTALLATION == 1 ) { const portISR_t * const pxVectorTable = portSCB_VTOR_REG; - /* Verify correct installation of the FreeRTOS handlers for SVCall and - * PendSV. Do not check the installation of the SysTick handler because - * the application may provide the OS tick without using the SysTick + /* Validate that the application has correctly installed the FreeRTOS + * handlers for SVCall and PendSV interrupts. We do not check the + * installation of the SysTick handler because the application may + * choose to drive the RTOS tick using a timer other than the SysTick * timer by overriding the weak function vPortSetupTimerInterrupt(). * - * Assertion failures here can be caused by incorrect installation of - * the FreeRTOS handlers. For help installing the handlers, see - * https://www.FreeRTOS.org/FAQHelp.html + * Assertion failures here indicate incorrect installation of the + * FreeRTOS handlers. For help installing the FreeRTOS handlers, see + * https://www.FreeRTOS.org/FAQHelp.html. * * Systems with a configurable address for the interrupt vector table * can also encounter assertion failures or even system faults here if diff --git a/portable/GCC/ARM_CM3_MPU/port.c b/portable/GCC/ARM_CM3_MPU/port.c index 99260cbd42..d8c18325c4 100644 --- a/portable/GCC/ARM_CM3_MPU/port.c +++ b/portable/GCC/ARM_CM3_MPU/port.c @@ -58,8 +58,8 @@ #define configALLOW_UNPRIVILEGED_CRITICAL_SECTIONS 1 #endif -/* Prototype to which all Interrupt Service Routines conform. */ -typedef void (* portISR_t)( void ); +/* Prototype of all Interrupt Service Routines (ISRs). */ +typedef void ( * portISR_t )( void ); /* Constants required to access and manipulate the NVIC. */ #define portNVIC_SYSTICK_CTRL_REG ( *( ( volatile uint32_t * ) 0xe000e010 ) ) @@ -743,23 +743,31 @@ static void prvRestoreContextOfFirstTask( void ) */ BaseType_t xPortStartScheduler( void ) { - /* Applications that route program control to the FreeRTOS interrupt - * handlers through intermediate handlers (indirect routing) should set - * configCHECK_HANDLER_INSTALLATION to 0 in FreeRTOSConfig.h. Direct + /* An application can install FreeRTOS interrupt handlers in one of the + * folllowing ways: + * 1. Direct Routing - Install the functions vPortSVCHandler and + * xPortPendSVHandler for SVCall and PendSV interrupts respectively. + * 2. Indirect Routing - Install separate handlers for SVCall and PendSV + * interrupts and route program control from those handlers to + * vPortSVCHandler and xPortPendSVHandler functions. + * + * Applications that use Indirect Routing must set + * configCHECK_HANDLER_INSTALLATION to 0 in their FreeRTOSConfig.h. Direct * routing, which is validated here when configCHECK_HANDLER_INSTALLATION - * is 1, is preferred when possible. */ + * is 1, should be preferred when possible. */ #if ( configCHECK_HANDLER_INSTALLATION == 1 ) { const portISR_t * const pxVectorTable = portSCB_VTOR_REG; - /* Verify correct installation of the FreeRTOS handlers for SVCall and - * PendSV. Do not check the installation of the SysTick handler because - * the application may provide the OS tick without using the SysTick + /* Validate that the application has correctly installed the FreeRTOS + * handlers for SVCall and PendSV interrupts. We do not check the + * installation of the SysTick handler because the application may + * choose to drive the RTOS tick using a timer other than the SysTick * timer by overriding the weak function vPortSetupTimerInterrupt(). * - * Assertion failures here can be caused by incorrect installation of - * the FreeRTOS handlers. For help installing the handlers, see - * https://www.FreeRTOS.org/FAQHelp.html + * Assertion failures here indicate incorrect installation of the + * FreeRTOS handlers. For help installing the FreeRTOS handlers, see + * https://www.FreeRTOS.org/FAQHelp.html. * * Systems with a configurable address for the interrupt vector table * can also encounter assertion failures or even system faults here if diff --git a/portable/GCC/ARM_CM4F/port.c b/portable/GCC/ARM_CM4F/port.c index 4d92bb3a68..3e5151bdc5 100644 --- a/portable/GCC/ARM_CM4F/port.c +++ b/portable/GCC/ARM_CM4F/port.c @@ -38,8 +38,8 @@ #error This port can only be used when the project options are configured to enable hardware floating point support. #endif -/* Prototype to which all Interrupt Service Routines conform. */ -typedef void (* portISR_t)( void ); +/* Prototype of all Interrupt Service Routines (ISRs). */ +typedef void ( * portISR_t )( void ); /* Constants required to manipulate the core. Registers first... */ #define portNVIC_SYSTICK_CTRL_REG ( *( ( volatile uint32_t * ) 0xe000e010 ) ) @@ -311,23 +311,31 @@ BaseType_t xPortStartScheduler( void ) configASSERT( portCPUID != portCORTEX_M7_r0p1_ID ); configASSERT( portCPUID != portCORTEX_M7_r0p0_ID ); - /* Applications that route program control to the FreeRTOS interrupt - * handlers through intermediate handlers (indirect routing) should set - * configCHECK_HANDLER_INSTALLATION to 0 in FreeRTOSConfig.h. Direct + /* An application can install FreeRTOS interrupt handlers in one of the + * folllowing ways: + * 1. Direct Routing - Install the functions vPortSVCHandler and + * xPortPendSVHandler for SVCall and PendSV interrupts respectively. + * 2. Indirect Routing - Install separate handlers for SVCall and PendSV + * interrupts and route program control from those handlers to + * vPortSVCHandler and xPortPendSVHandler functions. + * + * Applications that use Indirect Routing must set + * configCHECK_HANDLER_INSTALLATION to 0 in their FreeRTOSConfig.h. Direct * routing, which is validated here when configCHECK_HANDLER_INSTALLATION - * is 1, is preferred when possible. */ + * is 1, should be preferred when possible. */ #if ( configCHECK_HANDLER_INSTALLATION == 1 ) { const portISR_t * const pxVectorTable = portSCB_VTOR_REG; - /* Verify correct installation of the FreeRTOS handlers for SVCall and - * PendSV. Do not check the installation of the SysTick handler because - * the application may provide the OS tick without using the SysTick + /* Validate that the application has correctly installed the FreeRTOS + * handlers for SVCall and PendSV interrupts. We do not check the + * installation of the SysTick handler because the application may + * choose to drive the RTOS tick using a timer other than the SysTick * timer by overriding the weak function vPortSetupTimerInterrupt(). * - * Assertion failures here can be caused by incorrect installation of - * the FreeRTOS handlers. For help installing the handlers, see - * https://www.FreeRTOS.org/FAQHelp.html + * Assertion failures here indicate incorrect installation of the + * FreeRTOS handlers. For help installing the FreeRTOS handlers, see + * https://www.FreeRTOS.org/FAQHelp.html. * * Systems with a configurable address for the interrupt vector table * can also encounter assertion failures or even system faults here if diff --git a/portable/GCC/ARM_CM4_MPU/port.c b/portable/GCC/ARM_CM4_MPU/port.c index f7e19d3ecb..0775cfbf89 100644 --- a/portable/GCC/ARM_CM4_MPU/port.c +++ b/portable/GCC/ARM_CM4_MPU/port.c @@ -62,8 +62,8 @@ #define configALLOW_UNPRIVILEGED_CRITICAL_SECTIONS 1 #endif -/* Prototype to which all Interrupt Service Routines conform. */ -typedef void (* portISR_t)( void ); +/* Prototype of all Interrupt Service Routines (ISRs). */ +typedef void ( * portISR_t )( void ); /* Constants required to access and manipulate the NVIC. */ #define portNVIC_SYSTICK_CTRL_REG ( *( ( volatile uint32_t * ) 0xe000e010 ) ) @@ -829,23 +829,31 @@ BaseType_t xPortStartScheduler( void ) configASSERT( portCPUID != portCORTEX_M7_r0p0_ID ); #endif - /* Applications that route program control to the FreeRTOS interrupt - * handlers through intermediate handlers (indirect routing) should set - * configCHECK_HANDLER_INSTALLATION to 0 in FreeRTOSConfig.h. Direct + /* An application can install FreeRTOS interrupt handlers in one of the + * folllowing ways: + * 1. Direct Routing - Install the functions vPortSVCHandler and + * xPortPendSVHandler for SVCall and PendSV interrupts respectively. + * 2. Indirect Routing - Install separate handlers for SVCall and PendSV + * interrupts and route program control from those handlers to + * vPortSVCHandler and xPortPendSVHandler functions. + * + * Applications that use Indirect Routing must set + * configCHECK_HANDLER_INSTALLATION to 0 in their FreeRTOSConfig.h. Direct * routing, which is validated here when configCHECK_HANDLER_INSTALLATION - * is 1, is preferred when possible. */ + * is 1, should be preferred when possible. */ #if ( configCHECK_HANDLER_INSTALLATION == 1 ) { const portISR_t * const pxVectorTable = portSCB_VTOR_REG; - /* Verify correct installation of the FreeRTOS handlers for SVCall and - * PendSV. Do not check the installation of the SysTick handler because - * the application may provide the OS tick without using the SysTick + /* Validate that the application has correctly installed the FreeRTOS + * handlers for SVCall and PendSV interrupts. We do not check the + * installation of the SysTick handler because the application may + * choose to drive the RTOS tick using a timer other than the SysTick * timer by overriding the weak function vPortSetupTimerInterrupt(). * - * Assertion failures here can be caused by incorrect installation of - * the FreeRTOS handlers. For help installing the handlers, see - * https://www.FreeRTOS.org/FAQHelp.html + * Assertion failures here indicate incorrect installation of the + * FreeRTOS handlers. For help installing the FreeRTOS handlers, see + * https://www.FreeRTOS.org/FAQHelp.html. * * Systems with a configurable address for the interrupt vector table * can also encounter assertion failures or even system faults here if diff --git a/portable/GCC/ARM_CM55/non_secure/port.c b/portable/GCC/ARM_CM55/non_secure/port.c index 865b583c27..e7f7a6501e 100644 --- a/portable/GCC/ARM_CM55/non_secure/port.c +++ b/portable/GCC/ARM_CM55/non_secure/port.c @@ -81,9 +81,9 @@ /*-----------------------------------------------------------*/ /** - * @brief Prototype to which all Interrupt Service Routines conform. + * @brief Prototype of all Interrupt Service Routines (ISRs). */ -typedef void (* portISR_t)( void ); +typedef void ( *portISR_t )( void ); /*-----------------------------------------------------------*/ /** @@ -1612,23 +1612,31 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ { - /* Applications that route program control to the FreeRTOS interrupt - * handlers through intermediate handlers (indirect routing) should set - * configCHECK_HANDLER_INSTALLATION to 0 in FreeRTOSConfig.h. Direct + /* An application can install FreeRTOS interrupt handlers in one of the + * folllowing ways: + * 1. Direct Routing - Install the functions SVC_Handler and PendSV_Handler + * for SVCall and PendSV interrupts respectively. + * 2. Indirect Routing - Install separate handlers for SVCall and PendSV + * interrupts and route program control from those handlers to + * SVC_Handler and PendSV_Handler functions. + * + * Applications that use Indirect Routing must set + * configCHECK_HANDLER_INSTALLATION to 0 in their FreeRTOSConfig.h. Direct * routing, which is validated here when configCHECK_HANDLER_INSTALLATION - * is 1, is preferred when possible. */ + * is 1, should be preferred when possible. */ #if ( configCHECK_HANDLER_INSTALLATION == 1 ) { const portISR_t * const pxVectorTable = portSCB_VTOR_REG; - /* Verify correct installation of the FreeRTOS handlers for SVCall and - * PendSV. Do not check the installation of the SysTick handler because - * the application may provide the OS tick without using the SysTick + /* Validate that the application has correctly installed the FreeRTOS + * handlers for SVCall and PendSV interrupts. We do not check the + * installation of the SysTick handler because the application may + * choose to drive the RTOS tick using a timer other than the SysTick * timer by overriding the weak function vPortSetupTimerInterrupt(). * - * Assertion failures here can be caused by incorrect installation of - * the FreeRTOS handlers. For help installing the handlers, see - * https://www.FreeRTOS.org/FAQHelp.html + * Assertion failures here indicate incorrect installation of the + * FreeRTOS handlers. For help installing the FreeRTOS handlers, see + * https://www.FreeRTOS.org/FAQHelp.html. * * Systems with a configurable address for the interrupt vector table * can also encounter assertion failures or even system faults here if diff --git a/portable/GCC/ARM_CM55_NTZ/non_secure/port.c b/portable/GCC/ARM_CM55_NTZ/non_secure/port.c index 865b583c27..e7f7a6501e 100644 --- a/portable/GCC/ARM_CM55_NTZ/non_secure/port.c +++ b/portable/GCC/ARM_CM55_NTZ/non_secure/port.c @@ -81,9 +81,9 @@ /*-----------------------------------------------------------*/ /** - * @brief Prototype to which all Interrupt Service Routines conform. + * @brief Prototype of all Interrupt Service Routines (ISRs). */ -typedef void (* portISR_t)( void ); +typedef void ( *portISR_t )( void ); /*-----------------------------------------------------------*/ /** @@ -1612,23 +1612,31 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ { - /* Applications that route program control to the FreeRTOS interrupt - * handlers through intermediate handlers (indirect routing) should set - * configCHECK_HANDLER_INSTALLATION to 0 in FreeRTOSConfig.h. Direct + /* An application can install FreeRTOS interrupt handlers in one of the + * folllowing ways: + * 1. Direct Routing - Install the functions SVC_Handler and PendSV_Handler + * for SVCall and PendSV interrupts respectively. + * 2. Indirect Routing - Install separate handlers for SVCall and PendSV + * interrupts and route program control from those handlers to + * SVC_Handler and PendSV_Handler functions. + * + * Applications that use Indirect Routing must set + * configCHECK_HANDLER_INSTALLATION to 0 in their FreeRTOSConfig.h. Direct * routing, which is validated here when configCHECK_HANDLER_INSTALLATION - * is 1, is preferred when possible. */ + * is 1, should be preferred when possible. */ #if ( configCHECK_HANDLER_INSTALLATION == 1 ) { const portISR_t * const pxVectorTable = portSCB_VTOR_REG; - /* Verify correct installation of the FreeRTOS handlers for SVCall and - * PendSV. Do not check the installation of the SysTick handler because - * the application may provide the OS tick without using the SysTick + /* Validate that the application has correctly installed the FreeRTOS + * handlers for SVCall and PendSV interrupts. We do not check the + * installation of the SysTick handler because the application may + * choose to drive the RTOS tick using a timer other than the SysTick * timer by overriding the weak function vPortSetupTimerInterrupt(). * - * Assertion failures here can be caused by incorrect installation of - * the FreeRTOS handlers. For help installing the handlers, see - * https://www.FreeRTOS.org/FAQHelp.html + * Assertion failures here indicate incorrect installation of the + * FreeRTOS handlers. For help installing the FreeRTOS handlers, see + * https://www.FreeRTOS.org/FAQHelp.html. * * Systems with a configurable address for the interrupt vector table * can also encounter assertion failures or even system faults here if diff --git a/portable/GCC/ARM_CM7/r0p1/port.c b/portable/GCC/ARM_CM7/r0p1/port.c index a34b8067a9..3070445ab2 100644 --- a/portable/GCC/ARM_CM7/r0p1/port.c +++ b/portable/GCC/ARM_CM7/r0p1/port.c @@ -38,8 +38,8 @@ #error This port can only be used when the project options are configured to enable hardware floating point support. #endif -/* Prototype to which all Interrupt Service Routines conform. */ -typedef void (* portISR_t)( void ); +/* Prototype of all Interrupt Service Routines (ISRs). */ +typedef void ( * portISR_t )( void ); /* Constants required to manipulate the core. Registers first... */ #define portNVIC_SYSTICK_CTRL_REG ( *( ( volatile uint32_t * ) 0xe000e010 ) ) @@ -299,23 +299,31 @@ static void prvPortStartFirstTask( void ) */ BaseType_t xPortStartScheduler( void ) { - /* Applications that route program control to the FreeRTOS interrupt - * handlers through intermediate handlers (indirect routing) should set - * configCHECK_HANDLER_INSTALLATION to 0 in FreeRTOSConfig.h. Direct + /* An application can install FreeRTOS interrupt handlers in one of the + * folllowing ways: + * 1. Direct Routing - Install the functions vPortSVCHandler and + * xPortPendSVHandler for SVCall and PendSV interrupts respectively. + * 2. Indirect Routing - Install separate handlers for SVCall and PendSV + * interrupts and route program control from those handlers to + * vPortSVCHandler and xPortPendSVHandler functions. + * + * Applications that use Indirect Routing must set + * configCHECK_HANDLER_INSTALLATION to 0 in their FreeRTOSConfig.h. Direct * routing, which is validated here when configCHECK_HANDLER_INSTALLATION - * is 1, is preferred when possible. */ + * is 1, should be preferred when possible. */ #if ( configCHECK_HANDLER_INSTALLATION == 1 ) { const portISR_t * const pxVectorTable = portSCB_VTOR_REG; - /* Verify correct installation of the FreeRTOS handlers for SVCall and - * PendSV. Do not check the installation of the SysTick handler because - * the application may provide the OS tick without using the SysTick + /* Validate that the application has correctly installed the FreeRTOS + * handlers for SVCall and PendSV interrupts. We do not check the + * installation of the SysTick handler because the application may + * choose to drive the RTOS tick using a timer other than the SysTick * timer by overriding the weak function vPortSetupTimerInterrupt(). * - * Assertion failures here can be caused by incorrect installation of - * the FreeRTOS handlers. For help installing the handlers, see - * https://www.FreeRTOS.org/FAQHelp.html + * Assertion failures here indicate incorrect installation of the + * FreeRTOS handlers. For help installing the FreeRTOS handlers, see + * https://www.FreeRTOS.org/FAQHelp.html. * * Systems with a configurable address for the interrupt vector table * can also encounter assertion failures or even system faults here if diff --git a/portable/GCC/ARM_CM85/non_secure/port.c b/portable/GCC/ARM_CM85/non_secure/port.c index 865b583c27..e7f7a6501e 100644 --- a/portable/GCC/ARM_CM85/non_secure/port.c +++ b/portable/GCC/ARM_CM85/non_secure/port.c @@ -81,9 +81,9 @@ /*-----------------------------------------------------------*/ /** - * @brief Prototype to which all Interrupt Service Routines conform. + * @brief Prototype of all Interrupt Service Routines (ISRs). */ -typedef void (* portISR_t)( void ); +typedef void ( *portISR_t )( void ); /*-----------------------------------------------------------*/ /** @@ -1612,23 +1612,31 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ { - /* Applications that route program control to the FreeRTOS interrupt - * handlers through intermediate handlers (indirect routing) should set - * configCHECK_HANDLER_INSTALLATION to 0 in FreeRTOSConfig.h. Direct + /* An application can install FreeRTOS interrupt handlers in one of the + * folllowing ways: + * 1. Direct Routing - Install the functions SVC_Handler and PendSV_Handler + * for SVCall and PendSV interrupts respectively. + * 2. Indirect Routing - Install separate handlers for SVCall and PendSV + * interrupts and route program control from those handlers to + * SVC_Handler and PendSV_Handler functions. + * + * Applications that use Indirect Routing must set + * configCHECK_HANDLER_INSTALLATION to 0 in their FreeRTOSConfig.h. Direct * routing, which is validated here when configCHECK_HANDLER_INSTALLATION - * is 1, is preferred when possible. */ + * is 1, should be preferred when possible. */ #if ( configCHECK_HANDLER_INSTALLATION == 1 ) { const portISR_t * const pxVectorTable = portSCB_VTOR_REG; - /* Verify correct installation of the FreeRTOS handlers for SVCall and - * PendSV. Do not check the installation of the SysTick handler because - * the application may provide the OS tick without using the SysTick + /* Validate that the application has correctly installed the FreeRTOS + * handlers for SVCall and PendSV interrupts. We do not check the + * installation of the SysTick handler because the application may + * choose to drive the RTOS tick using a timer other than the SysTick * timer by overriding the weak function vPortSetupTimerInterrupt(). * - * Assertion failures here can be caused by incorrect installation of - * the FreeRTOS handlers. For help installing the handlers, see - * https://www.FreeRTOS.org/FAQHelp.html + * Assertion failures here indicate incorrect installation of the + * FreeRTOS handlers. For help installing the FreeRTOS handlers, see + * https://www.FreeRTOS.org/FAQHelp.html. * * Systems with a configurable address for the interrupt vector table * can also encounter assertion failures or even system faults here if diff --git a/portable/GCC/ARM_CM85_NTZ/non_secure/port.c b/portable/GCC/ARM_CM85_NTZ/non_secure/port.c index 865b583c27..e7f7a6501e 100644 --- a/portable/GCC/ARM_CM85_NTZ/non_secure/port.c +++ b/portable/GCC/ARM_CM85_NTZ/non_secure/port.c @@ -81,9 +81,9 @@ /*-----------------------------------------------------------*/ /** - * @brief Prototype to which all Interrupt Service Routines conform. + * @brief Prototype of all Interrupt Service Routines (ISRs). */ -typedef void (* portISR_t)( void ); +typedef void ( *portISR_t )( void ); /*-----------------------------------------------------------*/ /** @@ -1612,23 +1612,31 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ { - /* Applications that route program control to the FreeRTOS interrupt - * handlers through intermediate handlers (indirect routing) should set - * configCHECK_HANDLER_INSTALLATION to 0 in FreeRTOSConfig.h. Direct + /* An application can install FreeRTOS interrupt handlers in one of the + * folllowing ways: + * 1. Direct Routing - Install the functions SVC_Handler and PendSV_Handler + * for SVCall and PendSV interrupts respectively. + * 2. Indirect Routing - Install separate handlers for SVCall and PendSV + * interrupts and route program control from those handlers to + * SVC_Handler and PendSV_Handler functions. + * + * Applications that use Indirect Routing must set + * configCHECK_HANDLER_INSTALLATION to 0 in their FreeRTOSConfig.h. Direct * routing, which is validated here when configCHECK_HANDLER_INSTALLATION - * is 1, is preferred when possible. */ + * is 1, should be preferred when possible. */ #if ( configCHECK_HANDLER_INSTALLATION == 1 ) { const portISR_t * const pxVectorTable = portSCB_VTOR_REG; - /* Verify correct installation of the FreeRTOS handlers for SVCall and - * PendSV. Do not check the installation of the SysTick handler because - * the application may provide the OS tick without using the SysTick + /* Validate that the application has correctly installed the FreeRTOS + * handlers for SVCall and PendSV interrupts. We do not check the + * installation of the SysTick handler because the application may + * choose to drive the RTOS tick using a timer other than the SysTick * timer by overriding the weak function vPortSetupTimerInterrupt(). * - * Assertion failures here can be caused by incorrect installation of - * the FreeRTOS handlers. For help installing the handlers, see - * https://www.FreeRTOS.org/FAQHelp.html + * Assertion failures here indicate incorrect installation of the + * FreeRTOS handlers. For help installing the FreeRTOS handlers, see + * https://www.FreeRTOS.org/FAQHelp.html. * * Systems with a configurable address for the interrupt vector table * can also encounter assertion failures or even system faults here if diff --git a/portable/IAR/ARM_CM0/port.c b/portable/IAR/ARM_CM0/port.c index 62c0adcf8e..571af1f96e 100644 --- a/portable/IAR/ARM_CM0/port.c +++ b/portable/IAR/ARM_CM0/port.c @@ -37,8 +37,8 @@ #include "FreeRTOS.h" #include "task.h" -/* Prototype to which all Interrupt Service Routines conform. */ -typedef void (* portISR_t)( void ); +/* Prototype of all Interrupt Service Routines (ISRs). */ +typedef void ( * portISR_t )( void ); /* Constants required to manipulate the NVIC. */ #define portNVIC_SYSTICK_CTRL_REG ( *( ( volatile uint32_t * ) 0xe000e010 ) ) @@ -175,26 +175,33 @@ static void prvTaskExitError( void ) */ BaseType_t xPortStartScheduler( void ) { - /* Applications that route program control to the FreeRTOS interrupt - * handlers through intermediate handlers (indirect routing) should set - * configCHECK_HANDLER_INSTALLATION to 0 in FreeRTOSConfig.h. Direct + /* An application can install FreeRTOS interrupt handlers in one of the + * folllowing ways: + * 1. Direct Routing - Install the function xPortPendSVHandler for PendSV + * interrupt. + * 2. Indirect Routing - Install separate handler for PendSV interrupt and + * route program control from that handler to xPortPendSVHandler function. + * + * Applications that use Indirect Routing must set + * configCHECK_HANDLER_INSTALLATION to 0 in their FreeRTOSConfig.h. Direct * routing, which is validated here when configCHECK_HANDLER_INSTALLATION - * is 1, is preferred when possible. */ + * is 1, should be preferred when possible. */ #if ( configCHECK_HANDLER_INSTALLATION == 1 ) { - /* Point pxVectorTable at the interrupt vector table. Systems without - * a VTOR register provide the value zero in place of the VTOR register - * and provide the vector table itself at address 0x00000000. */ + /* Point pxVectorTable to the interrupt vector table. Systems without + * a VTOR register provide the value zero in the VTOR register and + * the vector table itself is located at the address 0x00000000. */ const portISR_t * const pxVectorTable = portSCB_VTOR_REG; - /* Verify correct installation of the FreeRTOS handler for PendSV. Do - * not check the installation of the SysTick handler because the - * application may provide the OS tick without using the SysTick timer - * by overriding the weak function vPortSetupTimerInterrupt(). + /* Validate that the application has correctly installed the FreeRTOS + * handler for PendSV interrupt. We do not check the installation of the + * SysTick handler because the application may choose to drive the RTOS + * tick using a timer other than the SysTick timer by overriding the + * weak function vPortSetupTimerInterrupt(). * - * Assertion failures here can be caused by incorrect installation of - * the FreeRTOS handlers. For help installing the handlers, see - * https://www.FreeRTOS.org/FAQHelp.html + * Assertion failures here indicate incorrect installation of the + * FreeRTOS handler. For help installing the FreeRTOS handler, see + * https://www.FreeRTOS.org/FAQHelp.html. * * Systems with a configurable address for the interrupt vector table * can also encounter assertion failures or even system faults here if diff --git a/portable/IAR/ARM_CM23/non_secure/port.c b/portable/IAR/ARM_CM23/non_secure/port.c index 865b583c27..e7f7a6501e 100644 --- a/portable/IAR/ARM_CM23/non_secure/port.c +++ b/portable/IAR/ARM_CM23/non_secure/port.c @@ -81,9 +81,9 @@ /*-----------------------------------------------------------*/ /** - * @brief Prototype to which all Interrupt Service Routines conform. + * @brief Prototype of all Interrupt Service Routines (ISRs). */ -typedef void (* portISR_t)( void ); +typedef void ( *portISR_t )( void ); /*-----------------------------------------------------------*/ /** @@ -1612,23 +1612,31 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ { - /* Applications that route program control to the FreeRTOS interrupt - * handlers through intermediate handlers (indirect routing) should set - * configCHECK_HANDLER_INSTALLATION to 0 in FreeRTOSConfig.h. Direct + /* An application can install FreeRTOS interrupt handlers in one of the + * folllowing ways: + * 1. Direct Routing - Install the functions SVC_Handler and PendSV_Handler + * for SVCall and PendSV interrupts respectively. + * 2. Indirect Routing - Install separate handlers for SVCall and PendSV + * interrupts and route program control from those handlers to + * SVC_Handler and PendSV_Handler functions. + * + * Applications that use Indirect Routing must set + * configCHECK_HANDLER_INSTALLATION to 0 in their FreeRTOSConfig.h. Direct * routing, which is validated here when configCHECK_HANDLER_INSTALLATION - * is 1, is preferred when possible. */ + * is 1, should be preferred when possible. */ #if ( configCHECK_HANDLER_INSTALLATION == 1 ) { const portISR_t * const pxVectorTable = portSCB_VTOR_REG; - /* Verify correct installation of the FreeRTOS handlers for SVCall and - * PendSV. Do not check the installation of the SysTick handler because - * the application may provide the OS tick without using the SysTick + /* Validate that the application has correctly installed the FreeRTOS + * handlers for SVCall and PendSV interrupts. We do not check the + * installation of the SysTick handler because the application may + * choose to drive the RTOS tick using a timer other than the SysTick * timer by overriding the weak function vPortSetupTimerInterrupt(). * - * Assertion failures here can be caused by incorrect installation of - * the FreeRTOS handlers. For help installing the handlers, see - * https://www.FreeRTOS.org/FAQHelp.html + * Assertion failures here indicate incorrect installation of the + * FreeRTOS handlers. For help installing the FreeRTOS handlers, see + * https://www.FreeRTOS.org/FAQHelp.html. * * Systems with a configurable address for the interrupt vector table * can also encounter assertion failures or even system faults here if diff --git a/portable/IAR/ARM_CM23_NTZ/non_secure/port.c b/portable/IAR/ARM_CM23_NTZ/non_secure/port.c index 865b583c27..e7f7a6501e 100644 --- a/portable/IAR/ARM_CM23_NTZ/non_secure/port.c +++ b/portable/IAR/ARM_CM23_NTZ/non_secure/port.c @@ -81,9 +81,9 @@ /*-----------------------------------------------------------*/ /** - * @brief Prototype to which all Interrupt Service Routines conform. + * @brief Prototype of all Interrupt Service Routines (ISRs). */ -typedef void (* portISR_t)( void ); +typedef void ( *portISR_t )( void ); /*-----------------------------------------------------------*/ /** @@ -1612,23 +1612,31 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ { - /* Applications that route program control to the FreeRTOS interrupt - * handlers through intermediate handlers (indirect routing) should set - * configCHECK_HANDLER_INSTALLATION to 0 in FreeRTOSConfig.h. Direct + /* An application can install FreeRTOS interrupt handlers in one of the + * folllowing ways: + * 1. Direct Routing - Install the functions SVC_Handler and PendSV_Handler + * for SVCall and PendSV interrupts respectively. + * 2. Indirect Routing - Install separate handlers for SVCall and PendSV + * interrupts and route program control from those handlers to + * SVC_Handler and PendSV_Handler functions. + * + * Applications that use Indirect Routing must set + * configCHECK_HANDLER_INSTALLATION to 0 in their FreeRTOSConfig.h. Direct * routing, which is validated here when configCHECK_HANDLER_INSTALLATION - * is 1, is preferred when possible. */ + * is 1, should be preferred when possible. */ #if ( configCHECK_HANDLER_INSTALLATION == 1 ) { const portISR_t * const pxVectorTable = portSCB_VTOR_REG; - /* Verify correct installation of the FreeRTOS handlers for SVCall and - * PendSV. Do not check the installation of the SysTick handler because - * the application may provide the OS tick without using the SysTick + /* Validate that the application has correctly installed the FreeRTOS + * handlers for SVCall and PendSV interrupts. We do not check the + * installation of the SysTick handler because the application may + * choose to drive the RTOS tick using a timer other than the SysTick * timer by overriding the weak function vPortSetupTimerInterrupt(). * - * Assertion failures here can be caused by incorrect installation of - * the FreeRTOS handlers. For help installing the handlers, see - * https://www.FreeRTOS.org/FAQHelp.html + * Assertion failures here indicate incorrect installation of the + * FreeRTOS handlers. For help installing the FreeRTOS handlers, see + * https://www.FreeRTOS.org/FAQHelp.html. * * Systems with a configurable address for the interrupt vector table * can also encounter assertion failures or even system faults here if diff --git a/portable/IAR/ARM_CM3/port.c b/portable/IAR/ARM_CM3/port.c index 91fe02fe53..72f51debac 100644 --- a/portable/IAR/ARM_CM3/port.c +++ b/portable/IAR/ARM_CM3/port.c @@ -41,8 +41,8 @@ #error configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to 0. See http: /*www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */ #endif -/* Prototype to which all Interrupt Service Routines conform. */ -typedef void (* portISR_t)( void ); +/* Prototype of all Interrupt Service Routines (ISRs). */ +typedef void ( * portISR_t )( void ); /* Constants required to manipulate the core. Registers first... */ #define portNVIC_SYSTICK_CTRL_REG ( *( ( volatile uint32_t * ) 0xe000e010 ) ) @@ -217,23 +217,31 @@ static void prvTaskExitError( void ) */ BaseType_t xPortStartScheduler( void ) { - /* Applications that route program control to the FreeRTOS interrupt - * handlers through intermediate handlers (indirect routing) should set - * configCHECK_HANDLER_INSTALLATION to 0 in FreeRTOSConfig.h. Direct + /* An application can install FreeRTOS interrupt handlers in one of the + * folllowing ways: + * 1. Direct Routing - Install the functions vPortSVCHandler and + * xPortPendSVHandler for SVCall and PendSV interrupts respectively. + * 2. Indirect Routing - Install separate handlers for SVCall and PendSV + * interrupts and route program control from those handlers to + * vPortSVCHandler and xPortPendSVHandler functions. + * + * Applications that use Indirect Routing must set + * configCHECK_HANDLER_INSTALLATION to 0 in their FreeRTOSConfig.h. Direct * routing, which is validated here when configCHECK_HANDLER_INSTALLATION - * is 1, is preferred when possible. */ + * is 1, should be preferred when possible. */ #if ( configCHECK_HANDLER_INSTALLATION == 1 ) { const portISR_t * const pxVectorTable = portSCB_VTOR_REG; - /* Verify correct installation of the FreeRTOS handlers for SVCall and - * PendSV. Do not check the installation of the SysTick handler because - * the application may provide the OS tick without using the SysTick + /* Validate that the application has correctly installed the FreeRTOS + * handlers for SVCall and PendSV interrupts. We do not check the + * installation of the SysTick handler because the application may + * choose to drive the RTOS tick using a timer other than the SysTick * timer by overriding the weak function vPortSetupTimerInterrupt(). * - * Assertion failures here can be caused by incorrect installation of - * the FreeRTOS handlers. For help installing the handlers, see - * https://www.FreeRTOS.org/FAQHelp.html + * Assertion failures here indicate incorrect installation of the + * FreeRTOS handlers. For help installing the FreeRTOS handlers, see + * https://www.FreeRTOS.org/FAQHelp.html. * * Systems with a configurable address for the interrupt vector table * can also encounter assertion failures or even system faults here if diff --git a/portable/IAR/ARM_CM33/non_secure/port.c b/portable/IAR/ARM_CM33/non_secure/port.c index 865b583c27..e7f7a6501e 100644 --- a/portable/IAR/ARM_CM33/non_secure/port.c +++ b/portable/IAR/ARM_CM33/non_secure/port.c @@ -81,9 +81,9 @@ /*-----------------------------------------------------------*/ /** - * @brief Prototype to which all Interrupt Service Routines conform. + * @brief Prototype of all Interrupt Service Routines (ISRs). */ -typedef void (* portISR_t)( void ); +typedef void ( *portISR_t )( void ); /*-----------------------------------------------------------*/ /** @@ -1612,23 +1612,31 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ { - /* Applications that route program control to the FreeRTOS interrupt - * handlers through intermediate handlers (indirect routing) should set - * configCHECK_HANDLER_INSTALLATION to 0 in FreeRTOSConfig.h. Direct + /* An application can install FreeRTOS interrupt handlers in one of the + * folllowing ways: + * 1. Direct Routing - Install the functions SVC_Handler and PendSV_Handler + * for SVCall and PendSV interrupts respectively. + * 2. Indirect Routing - Install separate handlers for SVCall and PendSV + * interrupts and route program control from those handlers to + * SVC_Handler and PendSV_Handler functions. + * + * Applications that use Indirect Routing must set + * configCHECK_HANDLER_INSTALLATION to 0 in their FreeRTOSConfig.h. Direct * routing, which is validated here when configCHECK_HANDLER_INSTALLATION - * is 1, is preferred when possible. */ + * is 1, should be preferred when possible. */ #if ( configCHECK_HANDLER_INSTALLATION == 1 ) { const portISR_t * const pxVectorTable = portSCB_VTOR_REG; - /* Verify correct installation of the FreeRTOS handlers for SVCall and - * PendSV. Do not check the installation of the SysTick handler because - * the application may provide the OS tick without using the SysTick + /* Validate that the application has correctly installed the FreeRTOS + * handlers for SVCall and PendSV interrupts. We do not check the + * installation of the SysTick handler because the application may + * choose to drive the RTOS tick using a timer other than the SysTick * timer by overriding the weak function vPortSetupTimerInterrupt(). * - * Assertion failures here can be caused by incorrect installation of - * the FreeRTOS handlers. For help installing the handlers, see - * https://www.FreeRTOS.org/FAQHelp.html + * Assertion failures here indicate incorrect installation of the + * FreeRTOS handlers. For help installing the FreeRTOS handlers, see + * https://www.FreeRTOS.org/FAQHelp.html. * * Systems with a configurable address for the interrupt vector table * can also encounter assertion failures or even system faults here if diff --git a/portable/IAR/ARM_CM33_NTZ/non_secure/port.c b/portable/IAR/ARM_CM33_NTZ/non_secure/port.c index 865b583c27..e7f7a6501e 100644 --- a/portable/IAR/ARM_CM33_NTZ/non_secure/port.c +++ b/portable/IAR/ARM_CM33_NTZ/non_secure/port.c @@ -81,9 +81,9 @@ /*-----------------------------------------------------------*/ /** - * @brief Prototype to which all Interrupt Service Routines conform. + * @brief Prototype of all Interrupt Service Routines (ISRs). */ -typedef void (* portISR_t)( void ); +typedef void ( *portISR_t )( void ); /*-----------------------------------------------------------*/ /** @@ -1612,23 +1612,31 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ { - /* Applications that route program control to the FreeRTOS interrupt - * handlers through intermediate handlers (indirect routing) should set - * configCHECK_HANDLER_INSTALLATION to 0 in FreeRTOSConfig.h. Direct + /* An application can install FreeRTOS interrupt handlers in one of the + * folllowing ways: + * 1. Direct Routing - Install the functions SVC_Handler and PendSV_Handler + * for SVCall and PendSV interrupts respectively. + * 2. Indirect Routing - Install separate handlers for SVCall and PendSV + * interrupts and route program control from those handlers to + * SVC_Handler and PendSV_Handler functions. + * + * Applications that use Indirect Routing must set + * configCHECK_HANDLER_INSTALLATION to 0 in their FreeRTOSConfig.h. Direct * routing, which is validated here when configCHECK_HANDLER_INSTALLATION - * is 1, is preferred when possible. */ + * is 1, should be preferred when possible. */ #if ( configCHECK_HANDLER_INSTALLATION == 1 ) { const portISR_t * const pxVectorTable = portSCB_VTOR_REG; - /* Verify correct installation of the FreeRTOS handlers for SVCall and - * PendSV. Do not check the installation of the SysTick handler because - * the application may provide the OS tick without using the SysTick + /* Validate that the application has correctly installed the FreeRTOS + * handlers for SVCall and PendSV interrupts. We do not check the + * installation of the SysTick handler because the application may + * choose to drive the RTOS tick using a timer other than the SysTick * timer by overriding the weak function vPortSetupTimerInterrupt(). * - * Assertion failures here can be caused by incorrect installation of - * the FreeRTOS handlers. For help installing the handlers, see - * https://www.FreeRTOS.org/FAQHelp.html + * Assertion failures here indicate incorrect installation of the + * FreeRTOS handlers. For help installing the FreeRTOS handlers, see + * https://www.FreeRTOS.org/FAQHelp.html. * * Systems with a configurable address for the interrupt vector table * can also encounter assertion failures or even system faults here if diff --git a/portable/IAR/ARM_CM35P/non_secure/port.c b/portable/IAR/ARM_CM35P/non_secure/port.c index 865b583c27..e7f7a6501e 100644 --- a/portable/IAR/ARM_CM35P/non_secure/port.c +++ b/portable/IAR/ARM_CM35P/non_secure/port.c @@ -81,9 +81,9 @@ /*-----------------------------------------------------------*/ /** - * @brief Prototype to which all Interrupt Service Routines conform. + * @brief Prototype of all Interrupt Service Routines (ISRs). */ -typedef void (* portISR_t)( void ); +typedef void ( *portISR_t )( void ); /*-----------------------------------------------------------*/ /** @@ -1612,23 +1612,31 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ { - /* Applications that route program control to the FreeRTOS interrupt - * handlers through intermediate handlers (indirect routing) should set - * configCHECK_HANDLER_INSTALLATION to 0 in FreeRTOSConfig.h. Direct + /* An application can install FreeRTOS interrupt handlers in one of the + * folllowing ways: + * 1. Direct Routing - Install the functions SVC_Handler and PendSV_Handler + * for SVCall and PendSV interrupts respectively. + * 2. Indirect Routing - Install separate handlers for SVCall and PendSV + * interrupts and route program control from those handlers to + * SVC_Handler and PendSV_Handler functions. + * + * Applications that use Indirect Routing must set + * configCHECK_HANDLER_INSTALLATION to 0 in their FreeRTOSConfig.h. Direct * routing, which is validated here when configCHECK_HANDLER_INSTALLATION - * is 1, is preferred when possible. */ + * is 1, should be preferred when possible. */ #if ( configCHECK_HANDLER_INSTALLATION == 1 ) { const portISR_t * const pxVectorTable = portSCB_VTOR_REG; - /* Verify correct installation of the FreeRTOS handlers for SVCall and - * PendSV. Do not check the installation of the SysTick handler because - * the application may provide the OS tick without using the SysTick + /* Validate that the application has correctly installed the FreeRTOS + * handlers for SVCall and PendSV interrupts. We do not check the + * installation of the SysTick handler because the application may + * choose to drive the RTOS tick using a timer other than the SysTick * timer by overriding the weak function vPortSetupTimerInterrupt(). * - * Assertion failures here can be caused by incorrect installation of - * the FreeRTOS handlers. For help installing the handlers, see - * https://www.FreeRTOS.org/FAQHelp.html + * Assertion failures here indicate incorrect installation of the + * FreeRTOS handlers. For help installing the FreeRTOS handlers, see + * https://www.FreeRTOS.org/FAQHelp.html. * * Systems with a configurable address for the interrupt vector table * can also encounter assertion failures or even system faults here if diff --git a/portable/IAR/ARM_CM35P_NTZ/non_secure/port.c b/portable/IAR/ARM_CM35P_NTZ/non_secure/port.c index 865b583c27..e7f7a6501e 100644 --- a/portable/IAR/ARM_CM35P_NTZ/non_secure/port.c +++ b/portable/IAR/ARM_CM35P_NTZ/non_secure/port.c @@ -81,9 +81,9 @@ /*-----------------------------------------------------------*/ /** - * @brief Prototype to which all Interrupt Service Routines conform. + * @brief Prototype of all Interrupt Service Routines (ISRs). */ -typedef void (* portISR_t)( void ); +typedef void ( *portISR_t )( void ); /*-----------------------------------------------------------*/ /** @@ -1612,23 +1612,31 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ { - /* Applications that route program control to the FreeRTOS interrupt - * handlers through intermediate handlers (indirect routing) should set - * configCHECK_HANDLER_INSTALLATION to 0 in FreeRTOSConfig.h. Direct + /* An application can install FreeRTOS interrupt handlers in one of the + * folllowing ways: + * 1. Direct Routing - Install the functions SVC_Handler and PendSV_Handler + * for SVCall and PendSV interrupts respectively. + * 2. Indirect Routing - Install separate handlers for SVCall and PendSV + * interrupts and route program control from those handlers to + * SVC_Handler and PendSV_Handler functions. + * + * Applications that use Indirect Routing must set + * configCHECK_HANDLER_INSTALLATION to 0 in their FreeRTOSConfig.h. Direct * routing, which is validated here when configCHECK_HANDLER_INSTALLATION - * is 1, is preferred when possible. */ + * is 1, should be preferred when possible. */ #if ( configCHECK_HANDLER_INSTALLATION == 1 ) { const portISR_t * const pxVectorTable = portSCB_VTOR_REG; - /* Verify correct installation of the FreeRTOS handlers for SVCall and - * PendSV. Do not check the installation of the SysTick handler because - * the application may provide the OS tick without using the SysTick + /* Validate that the application has correctly installed the FreeRTOS + * handlers for SVCall and PendSV interrupts. We do not check the + * installation of the SysTick handler because the application may + * choose to drive the RTOS tick using a timer other than the SysTick * timer by overriding the weak function vPortSetupTimerInterrupt(). * - * Assertion failures here can be caused by incorrect installation of - * the FreeRTOS handlers. For help installing the handlers, see - * https://www.FreeRTOS.org/FAQHelp.html + * Assertion failures here indicate incorrect installation of the + * FreeRTOS handlers. For help installing the FreeRTOS handlers, see + * https://www.FreeRTOS.org/FAQHelp.html. * * Systems with a configurable address for the interrupt vector table * can also encounter assertion failures or even system faults here if diff --git a/portable/IAR/ARM_CM4F/port.c b/portable/IAR/ARM_CM4F/port.c index d75e48492d..112d657ce1 100644 --- a/portable/IAR/ARM_CM4F/port.c +++ b/portable/IAR/ARM_CM4F/port.c @@ -45,8 +45,8 @@ #error configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to 0. See http: /*www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */ #endif -/* Prototype to which all Interrupt Service Routines conform. */ -typedef void (* portISR_t)( void ); +/* Prototype of all Interrupt Service Routines (ISRs). */ +typedef void ( * portISR_t )( void ); /* Constants required to manipulate the core. Registers first... */ #define portNVIC_SYSTICK_CTRL_REG ( *( ( volatile uint32_t * ) 0xe000e010 ) ) @@ -255,23 +255,31 @@ BaseType_t xPortStartScheduler( void ) configASSERT( portCPUID != portCORTEX_M7_r0p1_ID ); configASSERT( portCPUID != portCORTEX_M7_r0p0_ID ); - /* Applications that route program control to the FreeRTOS interrupt - * handlers through intermediate handlers (indirect routing) should set - * configCHECK_HANDLER_INSTALLATION to 0 in FreeRTOSConfig.h. Direct + /* An application can install FreeRTOS interrupt handlers in one of the + * folllowing ways: + * 1. Direct Routing - Install the functions vPortSVCHandler and + * xPortPendSVHandler for SVCall and PendSV interrupts respectively. + * 2. Indirect Routing - Install separate handlers for SVCall and PendSV + * interrupts and route program control from those handlers to + * vPortSVCHandler and xPortPendSVHandler functions. + * + * Applications that use Indirect Routing must set + * configCHECK_HANDLER_INSTALLATION to 0 in their FreeRTOSConfig.h. Direct * routing, which is validated here when configCHECK_HANDLER_INSTALLATION - * is 1, is preferred when possible. */ + * is 1, should be preferred when possible. */ #if ( configCHECK_HANDLER_INSTALLATION == 1 ) { const portISR_t * const pxVectorTable = portSCB_VTOR_REG; - /* Verify correct installation of the FreeRTOS handlers for SVCall and - * PendSV. Do not check the installation of the SysTick handler because - * the application may provide the OS tick without using the SysTick + /* Validate that the application has correctly installed the FreeRTOS + * handlers for SVCall and PendSV interrupts. We do not check the + * installation of the SysTick handler because the application may + * choose to drive the RTOS tick using a timer other than the SysTick * timer by overriding the weak function vPortSetupTimerInterrupt(). * - * Assertion failures here can be caused by incorrect installation of - * the FreeRTOS handlers. For help installing the handlers, see - * https://www.FreeRTOS.org/FAQHelp.html + * Assertion failures here indicate incorrect installation of the + * FreeRTOS handlers. For help installing the FreeRTOS handlers, see + * https://www.FreeRTOS.org/FAQHelp.html. * * Systems with a configurable address for the interrupt vector table * can also encounter assertion failures or even system faults here if diff --git a/portable/IAR/ARM_CM4F_MPU/port.c b/portable/IAR/ARM_CM4F_MPU/port.c index 6f8ef49897..e03699f996 100644 --- a/portable/IAR/ARM_CM4F_MPU/port.c +++ b/portable/IAR/ARM_CM4F_MPU/port.c @@ -69,8 +69,8 @@ #define configALLOW_UNPRIVILEGED_CRITICAL_SECTIONS 1 #endif -/* Prototype to which all Interrupt Service Routines conform. */ -typedef void (* portISR_t)( void ); +/* Prototype of all Interrupt Service Routines (ISRs). */ +typedef void ( * portISR_t )( void ); /* Constants required to manipulate the core. Registers first... */ #define portNVIC_SYSTICK_CTRL_REG ( *( ( volatile uint32_t * ) 0xe000e010 ) ) @@ -719,23 +719,31 @@ BaseType_t xPortStartScheduler( void ) configASSERT( portCPUID != portCORTEX_M7_r0p0_ID ); #endif - /* Applications that route program control to the FreeRTOS interrupt - * handlers through intermediate handlers (indirect routing) should set - * configCHECK_HANDLER_INSTALLATION to 0 in FreeRTOSConfig.h. Direct + /* An application can install FreeRTOS interrupt handlers in one of the + * folllowing ways: + * 1. Direct Routing - Install the functions vPortSVCHandler and + * xPortPendSVHandler for SVCall and PendSV interrupts respectively. + * 2. Indirect Routing - Install separate handlers for SVCall and PendSV + * interrupts and route program control from those handlers to + * vPortSVCHandler and xPortPendSVHandler functions. + * + * Applications that use Indirect Routing must set + * configCHECK_HANDLER_INSTALLATION to 0 in their FreeRTOSConfig.h. Direct * routing, which is validated here when configCHECK_HANDLER_INSTALLATION - * is 1, is preferred when possible. */ + * is 1, should be preferred when possible. */ #if ( configCHECK_HANDLER_INSTALLATION == 1 ) { const portISR_t * const pxVectorTable = portSCB_VTOR_REG; - /* Verify correct installation of the FreeRTOS handlers for SVCall and - * PendSV. Do not check the installation of the SysTick handler because - * the application may provide the OS tick without using the SysTick + /* Validate that the application has correctly installed the FreeRTOS + * handlers for SVCall and PendSV interrupts. We do not check the + * installation of the SysTick handler because the application may + * choose to drive the RTOS tick using a timer other than the SysTick * timer by overriding the weak function vPortSetupTimerInterrupt(). * - * Assertion failures here can be caused by incorrect installation of - * the FreeRTOS handlers. For help installing the handlers, see - * https://www.FreeRTOS.org/FAQHelp.html + * Assertion failures here indicate incorrect installation of the + * FreeRTOS handlers. For help installing the FreeRTOS handlers, see + * https://www.FreeRTOS.org/FAQHelp.html. * * Systems with a configurable address for the interrupt vector table * can also encounter assertion failures or even system faults here if diff --git a/portable/IAR/ARM_CM55/non_secure/port.c b/portable/IAR/ARM_CM55/non_secure/port.c index 865b583c27..e7f7a6501e 100644 --- a/portable/IAR/ARM_CM55/non_secure/port.c +++ b/portable/IAR/ARM_CM55/non_secure/port.c @@ -81,9 +81,9 @@ /*-----------------------------------------------------------*/ /** - * @brief Prototype to which all Interrupt Service Routines conform. + * @brief Prototype of all Interrupt Service Routines (ISRs). */ -typedef void (* portISR_t)( void ); +typedef void ( *portISR_t )( void ); /*-----------------------------------------------------------*/ /** @@ -1612,23 +1612,31 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ { - /* Applications that route program control to the FreeRTOS interrupt - * handlers through intermediate handlers (indirect routing) should set - * configCHECK_HANDLER_INSTALLATION to 0 in FreeRTOSConfig.h. Direct + /* An application can install FreeRTOS interrupt handlers in one of the + * folllowing ways: + * 1. Direct Routing - Install the functions SVC_Handler and PendSV_Handler + * for SVCall and PendSV interrupts respectively. + * 2. Indirect Routing - Install separate handlers for SVCall and PendSV + * interrupts and route program control from those handlers to + * SVC_Handler and PendSV_Handler functions. + * + * Applications that use Indirect Routing must set + * configCHECK_HANDLER_INSTALLATION to 0 in their FreeRTOSConfig.h. Direct * routing, which is validated here when configCHECK_HANDLER_INSTALLATION - * is 1, is preferred when possible. */ + * is 1, should be preferred when possible. */ #if ( configCHECK_HANDLER_INSTALLATION == 1 ) { const portISR_t * const pxVectorTable = portSCB_VTOR_REG; - /* Verify correct installation of the FreeRTOS handlers for SVCall and - * PendSV. Do not check the installation of the SysTick handler because - * the application may provide the OS tick without using the SysTick + /* Validate that the application has correctly installed the FreeRTOS + * handlers for SVCall and PendSV interrupts. We do not check the + * installation of the SysTick handler because the application may + * choose to drive the RTOS tick using a timer other than the SysTick * timer by overriding the weak function vPortSetupTimerInterrupt(). * - * Assertion failures here can be caused by incorrect installation of - * the FreeRTOS handlers. For help installing the handlers, see - * https://www.FreeRTOS.org/FAQHelp.html + * Assertion failures here indicate incorrect installation of the + * FreeRTOS handlers. For help installing the FreeRTOS handlers, see + * https://www.FreeRTOS.org/FAQHelp.html. * * Systems with a configurable address for the interrupt vector table * can also encounter assertion failures or even system faults here if diff --git a/portable/IAR/ARM_CM55_NTZ/non_secure/port.c b/portable/IAR/ARM_CM55_NTZ/non_secure/port.c index 865b583c27..e7f7a6501e 100644 --- a/portable/IAR/ARM_CM55_NTZ/non_secure/port.c +++ b/portable/IAR/ARM_CM55_NTZ/non_secure/port.c @@ -81,9 +81,9 @@ /*-----------------------------------------------------------*/ /** - * @brief Prototype to which all Interrupt Service Routines conform. + * @brief Prototype of all Interrupt Service Routines (ISRs). */ -typedef void (* portISR_t)( void ); +typedef void ( *portISR_t )( void ); /*-----------------------------------------------------------*/ /** @@ -1612,23 +1612,31 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ { - /* Applications that route program control to the FreeRTOS interrupt - * handlers through intermediate handlers (indirect routing) should set - * configCHECK_HANDLER_INSTALLATION to 0 in FreeRTOSConfig.h. Direct + /* An application can install FreeRTOS interrupt handlers in one of the + * folllowing ways: + * 1. Direct Routing - Install the functions SVC_Handler and PendSV_Handler + * for SVCall and PendSV interrupts respectively. + * 2. Indirect Routing - Install separate handlers for SVCall and PendSV + * interrupts and route program control from those handlers to + * SVC_Handler and PendSV_Handler functions. + * + * Applications that use Indirect Routing must set + * configCHECK_HANDLER_INSTALLATION to 0 in their FreeRTOSConfig.h. Direct * routing, which is validated here when configCHECK_HANDLER_INSTALLATION - * is 1, is preferred when possible. */ + * is 1, should be preferred when possible. */ #if ( configCHECK_HANDLER_INSTALLATION == 1 ) { const portISR_t * const pxVectorTable = portSCB_VTOR_REG; - /* Verify correct installation of the FreeRTOS handlers for SVCall and - * PendSV. Do not check the installation of the SysTick handler because - * the application may provide the OS tick without using the SysTick + /* Validate that the application has correctly installed the FreeRTOS + * handlers for SVCall and PendSV interrupts. We do not check the + * installation of the SysTick handler because the application may + * choose to drive the RTOS tick using a timer other than the SysTick * timer by overriding the weak function vPortSetupTimerInterrupt(). * - * Assertion failures here can be caused by incorrect installation of - * the FreeRTOS handlers. For help installing the handlers, see - * https://www.FreeRTOS.org/FAQHelp.html + * Assertion failures here indicate incorrect installation of the + * FreeRTOS handlers. For help installing the FreeRTOS handlers, see + * https://www.FreeRTOS.org/FAQHelp.html. * * Systems with a configurable address for the interrupt vector table * can also encounter assertion failures or even system faults here if diff --git a/portable/IAR/ARM_CM7/r0p1/port.c b/portable/IAR/ARM_CM7/r0p1/port.c index 2ae2292787..5b42ac93aa 100644 --- a/portable/IAR/ARM_CM7/r0p1/port.c +++ b/portable/IAR/ARM_CM7/r0p1/port.c @@ -45,8 +45,8 @@ #error configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to 0. See http: /*www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */ #endif -/* Prototype to which all Interrupt Service Routines conform. */ -typedef void (* portISR_t)( void ); +/* Prototype of all Interrupt Service Routines (ISRs). */ +typedef void ( * portISR_t )( void ); /* Constants required to manipulate the core. Registers first... */ #define portNVIC_SYSTICK_CTRL_REG ( *( ( volatile uint32_t * ) 0xe000e010 ) ) @@ -243,23 +243,31 @@ static void prvTaskExitError( void ) */ BaseType_t xPortStartScheduler( void ) { - /* Applications that route program control to the FreeRTOS interrupt - * handlers through intermediate handlers (indirect routing) should set - * configCHECK_HANDLER_INSTALLATION to 0 in FreeRTOSConfig.h. Direct + /* An application can install FreeRTOS interrupt handlers in one of the + * folllowing ways: + * 1. Direct Routing - Install the functions vPortSVCHandler and + * xPortPendSVHandler for SVCall and PendSV interrupts respectively. + * 2. Indirect Routing - Install separate handlers for SVCall and PendSV + * interrupts and route program control from those handlers to + * vPortSVCHandler and xPortPendSVHandler functions. + * + * Applications that use Indirect Routing must set + * configCHECK_HANDLER_INSTALLATION to 0 in their FreeRTOSConfig.h. Direct * routing, which is validated here when configCHECK_HANDLER_INSTALLATION - * is 1, is preferred when possible. */ + * is 1, should be preferred when possible. */ #if ( configCHECK_HANDLER_INSTALLATION == 1 ) { const portISR_t * const pxVectorTable = portSCB_VTOR_REG; - /* Verify correct installation of the FreeRTOS handlers for SVCall and - * PendSV. Do not check the installation of the SysTick handler because - * the application may provide the OS tick without using the SysTick + /* Validate that the application has correctly installed the FreeRTOS + * handlers for SVCall and PendSV interrupts. We do not check the + * installation of the SysTick handler because the application may + * choose to drive the RTOS tick using a timer other than the SysTick * timer by overriding the weak function vPortSetupTimerInterrupt(). * - * Assertion failures here can be caused by incorrect installation of - * the FreeRTOS handlers. For help installing the handlers, see - * https://www.FreeRTOS.org/FAQHelp.html + * Assertion failures here indicate incorrect installation of the + * FreeRTOS handlers. For help installing the FreeRTOS handlers, see + * https://www.FreeRTOS.org/FAQHelp.html. * * Systems with a configurable address for the interrupt vector table * can also encounter assertion failures or even system faults here if diff --git a/portable/IAR/ARM_CM85/non_secure/port.c b/portable/IAR/ARM_CM85/non_secure/port.c index 865b583c27..e7f7a6501e 100644 --- a/portable/IAR/ARM_CM85/non_secure/port.c +++ b/portable/IAR/ARM_CM85/non_secure/port.c @@ -81,9 +81,9 @@ /*-----------------------------------------------------------*/ /** - * @brief Prototype to which all Interrupt Service Routines conform. + * @brief Prototype of all Interrupt Service Routines (ISRs). */ -typedef void (* portISR_t)( void ); +typedef void ( *portISR_t )( void ); /*-----------------------------------------------------------*/ /** @@ -1612,23 +1612,31 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ { - /* Applications that route program control to the FreeRTOS interrupt - * handlers through intermediate handlers (indirect routing) should set - * configCHECK_HANDLER_INSTALLATION to 0 in FreeRTOSConfig.h. Direct + /* An application can install FreeRTOS interrupt handlers in one of the + * folllowing ways: + * 1. Direct Routing - Install the functions SVC_Handler and PendSV_Handler + * for SVCall and PendSV interrupts respectively. + * 2. Indirect Routing - Install separate handlers for SVCall and PendSV + * interrupts and route program control from those handlers to + * SVC_Handler and PendSV_Handler functions. + * + * Applications that use Indirect Routing must set + * configCHECK_HANDLER_INSTALLATION to 0 in their FreeRTOSConfig.h. Direct * routing, which is validated here when configCHECK_HANDLER_INSTALLATION - * is 1, is preferred when possible. */ + * is 1, should be preferred when possible. */ #if ( configCHECK_HANDLER_INSTALLATION == 1 ) { const portISR_t * const pxVectorTable = portSCB_VTOR_REG; - /* Verify correct installation of the FreeRTOS handlers for SVCall and - * PendSV. Do not check the installation of the SysTick handler because - * the application may provide the OS tick without using the SysTick + /* Validate that the application has correctly installed the FreeRTOS + * handlers for SVCall and PendSV interrupts. We do not check the + * installation of the SysTick handler because the application may + * choose to drive the RTOS tick using a timer other than the SysTick * timer by overriding the weak function vPortSetupTimerInterrupt(). * - * Assertion failures here can be caused by incorrect installation of - * the FreeRTOS handlers. For help installing the handlers, see - * https://www.FreeRTOS.org/FAQHelp.html + * Assertion failures here indicate incorrect installation of the + * FreeRTOS handlers. For help installing the FreeRTOS handlers, see + * https://www.FreeRTOS.org/FAQHelp.html. * * Systems with a configurable address for the interrupt vector table * can also encounter assertion failures or even system faults here if diff --git a/portable/IAR/ARM_CM85_NTZ/non_secure/port.c b/portable/IAR/ARM_CM85_NTZ/non_secure/port.c index 865b583c27..e7f7a6501e 100644 --- a/portable/IAR/ARM_CM85_NTZ/non_secure/port.c +++ b/portable/IAR/ARM_CM85_NTZ/non_secure/port.c @@ -81,9 +81,9 @@ /*-----------------------------------------------------------*/ /** - * @brief Prototype to which all Interrupt Service Routines conform. + * @brief Prototype of all Interrupt Service Routines (ISRs). */ -typedef void (* portISR_t)( void ); +typedef void ( *portISR_t )( void ); /*-----------------------------------------------------------*/ /** @@ -1612,23 +1612,31 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ { - /* Applications that route program control to the FreeRTOS interrupt - * handlers through intermediate handlers (indirect routing) should set - * configCHECK_HANDLER_INSTALLATION to 0 in FreeRTOSConfig.h. Direct + /* An application can install FreeRTOS interrupt handlers in one of the + * folllowing ways: + * 1. Direct Routing - Install the functions SVC_Handler and PendSV_Handler + * for SVCall and PendSV interrupts respectively. + * 2. Indirect Routing - Install separate handlers for SVCall and PendSV + * interrupts and route program control from those handlers to + * SVC_Handler and PendSV_Handler functions. + * + * Applications that use Indirect Routing must set + * configCHECK_HANDLER_INSTALLATION to 0 in their FreeRTOSConfig.h. Direct * routing, which is validated here when configCHECK_HANDLER_INSTALLATION - * is 1, is preferred when possible. */ + * is 1, should be preferred when possible. */ #if ( configCHECK_HANDLER_INSTALLATION == 1 ) { const portISR_t * const pxVectorTable = portSCB_VTOR_REG; - /* Verify correct installation of the FreeRTOS handlers for SVCall and - * PendSV. Do not check the installation of the SysTick handler because - * the application may provide the OS tick without using the SysTick + /* Validate that the application has correctly installed the FreeRTOS + * handlers for SVCall and PendSV interrupts. We do not check the + * installation of the SysTick handler because the application may + * choose to drive the RTOS tick using a timer other than the SysTick * timer by overriding the weak function vPortSetupTimerInterrupt(). * - * Assertion failures here can be caused by incorrect installation of - * the FreeRTOS handlers. For help installing the handlers, see - * https://www.FreeRTOS.org/FAQHelp.html + * Assertion failures here indicate incorrect installation of the + * FreeRTOS handlers. For help installing the FreeRTOS handlers, see + * https://www.FreeRTOS.org/FAQHelp.html. * * Systems with a configurable address for the interrupt vector table * can also encounter assertion failures or even system faults here if diff --git a/portable/RVDS/ARM_CM4_MPU/port.c b/portable/RVDS/ARM_CM4_MPU/port.c index 566d4f7373..cc28db85dc 100644 --- a/portable/RVDS/ARM_CM4_MPU/port.c +++ b/portable/RVDS/ARM_CM4_MPU/port.c @@ -51,6 +51,9 @@ #define configALLOW_UNPRIVILEGED_CRITICAL_SECTIONS 1 #endif +/* Prototype of all Interrupt Service Routines (ISRs). */ +typedef void ( * portISR_t )( void ); + /* Constants required to access and manipulate the NVIC. */ #define portNVIC_SYSTICK_CTRL_REG ( *( ( volatile uint32_t * ) 0xe000e010 ) ) #define portNVIC_SYSTICK_LOAD_REG ( *( ( volatile uint32_t * ) 0xe000e014 ) ) @@ -87,7 +90,6 @@ #define portMIN_INTERRUPT_PRIORITY ( 255UL ) #define portNVIC_PENDSV_PRI ( ( ( uint32_t ) portMIN_INTERRUPT_PRIORITY ) << 16UL ) #define portNVIC_SYSTICK_PRI ( ( ( uint32_t ) portMIN_INTERRUPT_PRIORITY ) << 24UL ) -#define portNVIC_SVC_PRI ( ( ( uint32_t ) configMAX_SYSCALL_INTERRUPT_PRIORITY - 1UL ) << 24UL ) /* Constants required to manipulate the VFP. */ #define portFPCCR ( ( volatile uint32_t * ) 0xe000ef34UL ) /* Floating point context control register. */ @@ -99,6 +101,11 @@ #define portINITIAL_CONTROL_IF_UNPRIVILEGED ( 0x03 ) #define portINITIAL_CONTROL_IF_PRIVILEGED ( 0x02 ) +/* Constants used to check the installation of the FreeRTOS interrupt handlers. */ +#define portSCB_VTOR_REG ( *( ( portISR_t ** ) 0xE000ED08 ) ) +#define portVECTOR_INDEX_SVC ( 11 ) +#define portVECTOR_INDEX_PENDSV ( 14 ) + /* Constants required to check the validity of an interrupt priority. */ #define portFIRST_USER_INTERRUPT_NUMBER ( 16 ) #define portNVIC_IP_REGISTERS_OFFSET_16 ( 0xE000E3F0 ) @@ -386,7 +393,6 @@ void vSVCHandler_C( uint32_t * pulParam ) switch( ucSVCNumber ) { case portSVC_START_SCHEDULER: - portNVIC_SHPR2_REG |= portNVIC_SVC_PRI; prvRestoreContextOfFirstTask(); break; @@ -822,6 +828,40 @@ BaseType_t xPortStartScheduler( void ) configASSERT( portCPUID != portCORTEX_M7_r0p0_ID ); #endif + /* An application can install FreeRTOS interrupt handlers in one of the + * folllowing ways: + * 1. Direct Routing - Install the functions vPortSVCHandler and + * xPortPendSVHandler for SVCall and PendSV interrupts respectively. + * 2. Indirect Routing - Install separate handlers for SVCall and PendSV + * interrupts and route program control from those handlers to + * vPortSVCHandler and xPortPendSVHandler functions. + * + * Applications that use Indirect Routing must set + * configCHECK_HANDLER_INSTALLATION to 0 in their FreeRTOSConfig.h. Direct + * routing, which is validated here when configCHECK_HANDLER_INSTALLATION + * is 1, should be preferred when possible. */ + #if ( configCHECK_HANDLER_INSTALLATION == 1 ) + { + const portISR_t * const pxVectorTable = portSCB_VTOR_REG; + + /* Validate that the application has correctly installed the FreeRTOS + * handlers for SVCall and PendSV interrupts. We do not check the + * installation of the SysTick handler because the application may + * choose to drive the RTOS tick using a timer other than the SysTick + * timer by overriding the weak function vPortSetupTimerInterrupt(). + * + * Assertion failures here indicate incorrect installation of the + * FreeRTOS handlers. For help installing the FreeRTOS handlers, see + * https://www.FreeRTOS.org/FAQHelp.html. + * + * Systems with a configurable address for the interrupt vector table + * can also encounter assertion failures or even system faults here if + * VTOR is not set correctly to point to the application's vector table. */ + configASSERT( pxVectorTable[ portVECTOR_INDEX_SVC ] == vPortSVCHandler ); + configASSERT( pxVectorTable[ portVECTOR_INDEX_PENDSV ] == xPortPendSVHandler ); + } + #endif /* configCHECK_HANDLER_INSTALLATION */ + #if ( configASSERT_DEFINED == 1 ) { volatile uint8_t ucOriginalPriority; @@ -907,10 +947,11 @@ BaseType_t xPortStartScheduler( void ) #endif /* configASSERT_DEFINED */ /* Make PendSV and SysTick the same priority as the kernel, and the SVC - * handler higher priority so it can be used to exit a critical section (where - * lower priorities are masked). */ + * handler highest priority so it can be used to exit a critical section + * (where lower priorities are masked). */ portNVIC_SHPR3_REG |= portNVIC_PENDSV_PRI; portNVIC_SHPR3_REG |= portNVIC_SYSTICK_PRI; + portNVIC_SHPR2_REG = 0; /* Configure the regions in the MPU that are common to all tasks. */ prvSetupMPU(); From eb825c9c050c16700e011894108699d5f2a66801 Mon Sep 17 00:00:00 2001 From: Gaurav Aggarwal Date: Sat, 9 Dec 2023 18:25:34 +0530 Subject: [PATCH 22/23] Fix build errors Signed-off-by: Gaurav Aggarwal --- portable/IAR/ARM_CM0/port.c | 4 ++++ portable/IAR/ARM_CM3/port.c | 5 +++++ portable/IAR/ARM_CM4F/port.c | 5 +++++ portable/IAR/ARM_CM4F_MPU/port.c | 5 +++++ portable/IAR/ARM_CM7/r0p1/port.c | 5 +++++ portable/RVDS/ARM_CM4_MPU/port.c | 1 + 6 files changed, 25 insertions(+) diff --git a/portable/IAR/ARM_CM0/port.c b/portable/IAR/ARM_CM0/port.c index 571af1f96e..1b9caa13ae 100644 --- a/portable/IAR/ARM_CM0/port.c +++ b/portable/IAR/ARM_CM0/port.c @@ -128,6 +128,10 @@ extern void vPortStartFirstTask( void ); */ static void prvTaskExitError( void ); +/* + * FreeRTOS handlers implemented in assembly. + */ +extern void xPortPendSVHandler( void ); /*-----------------------------------------------------------*/ /* diff --git a/portable/IAR/ARM_CM3/port.c b/portable/IAR/ARM_CM3/port.c index 72f51debac..4608268720 100644 --- a/portable/IAR/ARM_CM3/port.c +++ b/portable/IAR/ARM_CM3/port.c @@ -130,6 +130,11 @@ extern void vPortStartFirstTask( void ); */ static void prvTaskExitError( void ); +/* + * FreeRTOS handlers implemented in assembly. + */ +extern void vPortSVCHandler( void ); +extern void xPortPendSVHandler( void ); /*-----------------------------------------------------------*/ /* Each task maintains its own interrupt status in the critical nesting diff --git a/portable/IAR/ARM_CM4F/port.c b/portable/IAR/ARM_CM4F/port.c index 112d657ce1..763ff2a5cb 100644 --- a/portable/IAR/ARM_CM4F/port.c +++ b/portable/IAR/ARM_CM4F/port.c @@ -150,6 +150,11 @@ extern void vPortEnableVFP( void ); */ static void prvTaskExitError( void ); +/* + * FreeRTOS handlers implemented in assembly. + */ +extern void vPortSVCHandler( void ); +extern void xPortPendSVHandler( void ); /*-----------------------------------------------------------*/ /* Each task maintains its own interrupt status in the critical nesting diff --git a/portable/IAR/ARM_CM4F_MPU/port.c b/portable/IAR/ARM_CM4F_MPU/port.c index e03699f996..c3bab2671c 100644 --- a/portable/IAR/ARM_CM4F_MPU/port.c +++ b/portable/IAR/ARM_CM4F_MPU/port.c @@ -289,6 +289,11 @@ BaseType_t xPortIsTaskPrivileged( void ) PRIVILEGED_FUNCTION; */ void vPortSwitchToUserMode( void ); +/* + * FreeRTOS handlers implemented in assembly. + */ +extern void vPortSVCHandler( void ) PRIVILEGED_FUNCTION; +extern void xPortPendSVHandler( void ) PRIVILEGED_FUNCTION; /*-----------------------------------------------------------*/ /* Each task maintains its own interrupt status in the critical nesting diff --git a/portable/IAR/ARM_CM7/r0p1/port.c b/portable/IAR/ARM_CM7/r0p1/port.c index 5b42ac93aa..2790028f42 100644 --- a/portable/IAR/ARM_CM7/r0p1/port.c +++ b/portable/IAR/ARM_CM7/r0p1/port.c @@ -144,6 +144,11 @@ extern void vPortEnableVFP( void ); */ static void prvTaskExitError( void ); +/* + * FreeRTOS handlers implemented in assembly. + */ +extern void vPortSVCHandler( void ); +extern void xPortPendSVHandler( void ); /*-----------------------------------------------------------*/ /* Each task maintains its own interrupt status in the critical nesting diff --git a/portable/RVDS/ARM_CM4_MPU/port.c b/portable/RVDS/ARM_CM4_MPU/port.c index cc28db85dc..af4ea632f0 100644 --- a/portable/RVDS/ARM_CM4_MPU/port.c +++ b/portable/RVDS/ARM_CM4_MPU/port.c @@ -1237,6 +1237,7 @@ __asm void vPortEnableVFP( void ) orr r1, r1, #( 0xf << 20 ) /* Enable CP10 and CP11 coprocessors, then save back. */ str r1, [ r0 ] bx r14 + nop /* *INDENT-ON* */ } /*-----------------------------------------------------------*/ From 53cfc6d234ac1d97743a7b0887f08f87373b038a Mon Sep 17 00:00:00 2001 From: Gaurav Aggarwal Date: Sun, 10 Dec 2023 23:15:16 +0530 Subject: [PATCH 23/23] Fix formatting Signed-off-by: Gaurav Aggarwal --- portable/ARMv8M/non_secure/port.c | 2 +- portable/GCC/ARM_CM23/non_secure/port.c | 2 +- portable/GCC/ARM_CM23_NTZ/non_secure/port.c | 2 +- portable/GCC/ARM_CM33/non_secure/port.c | 2 +- portable/GCC/ARM_CM33_NTZ/non_secure/port.c | 2 +- portable/GCC/ARM_CM35P/non_secure/port.c | 2 +- portable/GCC/ARM_CM35P_NTZ/non_secure/port.c | 2 +- portable/GCC/ARM_CM55/non_secure/port.c | 2 +- portable/GCC/ARM_CM55_NTZ/non_secure/port.c | 2 +- portable/GCC/ARM_CM85/non_secure/port.c | 2 +- portable/GCC/ARM_CM85_NTZ/non_secure/port.c | 2 +- portable/IAR/ARM_CM23/non_secure/port.c | 2 +- portable/IAR/ARM_CM23_NTZ/non_secure/port.c | 2 +- portable/IAR/ARM_CM33/non_secure/port.c | 2 +- portable/IAR/ARM_CM33_NTZ/non_secure/port.c | 2 +- portable/IAR/ARM_CM35P/non_secure/port.c | 2 +- portable/IAR/ARM_CM35P_NTZ/non_secure/port.c | 2 +- portable/IAR/ARM_CM55/non_secure/port.c | 2 +- portable/IAR/ARM_CM55_NTZ/non_secure/port.c | 2 +- portable/IAR/ARM_CM85/non_secure/port.c | 2 +- portable/IAR/ARM_CM85_NTZ/non_secure/port.c | 2 +- 21 files changed, 21 insertions(+), 21 deletions(-) diff --git a/portable/ARMv8M/non_secure/port.c b/portable/ARMv8M/non_secure/port.c index e7f7a6501e..a5ed7004a6 100644 --- a/portable/ARMv8M/non_secure/port.c +++ b/portable/ARMv8M/non_secure/port.c @@ -83,7 +83,7 @@ /** * @brief Prototype of all Interrupt Service Routines (ISRs). */ -typedef void ( *portISR_t )( void ); +typedef void ( * portISR_t )( void ); /*-----------------------------------------------------------*/ /** diff --git a/portable/GCC/ARM_CM23/non_secure/port.c b/portable/GCC/ARM_CM23/non_secure/port.c index e7f7a6501e..a5ed7004a6 100644 --- a/portable/GCC/ARM_CM23/non_secure/port.c +++ b/portable/GCC/ARM_CM23/non_secure/port.c @@ -83,7 +83,7 @@ /** * @brief Prototype of all Interrupt Service Routines (ISRs). */ -typedef void ( *portISR_t )( void ); +typedef void ( * portISR_t )( void ); /*-----------------------------------------------------------*/ /** diff --git a/portable/GCC/ARM_CM23_NTZ/non_secure/port.c b/portable/GCC/ARM_CM23_NTZ/non_secure/port.c index e7f7a6501e..a5ed7004a6 100644 --- a/portable/GCC/ARM_CM23_NTZ/non_secure/port.c +++ b/portable/GCC/ARM_CM23_NTZ/non_secure/port.c @@ -83,7 +83,7 @@ /** * @brief Prototype of all Interrupt Service Routines (ISRs). */ -typedef void ( *portISR_t )( void ); +typedef void ( * portISR_t )( void ); /*-----------------------------------------------------------*/ /** diff --git a/portable/GCC/ARM_CM33/non_secure/port.c b/portable/GCC/ARM_CM33/non_secure/port.c index e7f7a6501e..a5ed7004a6 100644 --- a/portable/GCC/ARM_CM33/non_secure/port.c +++ b/portable/GCC/ARM_CM33/non_secure/port.c @@ -83,7 +83,7 @@ /** * @brief Prototype of all Interrupt Service Routines (ISRs). */ -typedef void ( *portISR_t )( void ); +typedef void ( * portISR_t )( void ); /*-----------------------------------------------------------*/ /** diff --git a/portable/GCC/ARM_CM33_NTZ/non_secure/port.c b/portable/GCC/ARM_CM33_NTZ/non_secure/port.c index e7f7a6501e..a5ed7004a6 100644 --- a/portable/GCC/ARM_CM33_NTZ/non_secure/port.c +++ b/portable/GCC/ARM_CM33_NTZ/non_secure/port.c @@ -83,7 +83,7 @@ /** * @brief Prototype of all Interrupt Service Routines (ISRs). */ -typedef void ( *portISR_t )( void ); +typedef void ( * portISR_t )( void ); /*-----------------------------------------------------------*/ /** diff --git a/portable/GCC/ARM_CM35P/non_secure/port.c b/portable/GCC/ARM_CM35P/non_secure/port.c index e7f7a6501e..a5ed7004a6 100644 --- a/portable/GCC/ARM_CM35P/non_secure/port.c +++ b/portable/GCC/ARM_CM35P/non_secure/port.c @@ -83,7 +83,7 @@ /** * @brief Prototype of all Interrupt Service Routines (ISRs). */ -typedef void ( *portISR_t )( void ); +typedef void ( * portISR_t )( void ); /*-----------------------------------------------------------*/ /** diff --git a/portable/GCC/ARM_CM35P_NTZ/non_secure/port.c b/portable/GCC/ARM_CM35P_NTZ/non_secure/port.c index e7f7a6501e..a5ed7004a6 100644 --- a/portable/GCC/ARM_CM35P_NTZ/non_secure/port.c +++ b/portable/GCC/ARM_CM35P_NTZ/non_secure/port.c @@ -83,7 +83,7 @@ /** * @brief Prototype of all Interrupt Service Routines (ISRs). */ -typedef void ( *portISR_t )( void ); +typedef void ( * portISR_t )( void ); /*-----------------------------------------------------------*/ /** diff --git a/portable/GCC/ARM_CM55/non_secure/port.c b/portable/GCC/ARM_CM55/non_secure/port.c index e7f7a6501e..a5ed7004a6 100644 --- a/portable/GCC/ARM_CM55/non_secure/port.c +++ b/portable/GCC/ARM_CM55/non_secure/port.c @@ -83,7 +83,7 @@ /** * @brief Prototype of all Interrupt Service Routines (ISRs). */ -typedef void ( *portISR_t )( void ); +typedef void ( * portISR_t )( void ); /*-----------------------------------------------------------*/ /** diff --git a/portable/GCC/ARM_CM55_NTZ/non_secure/port.c b/portable/GCC/ARM_CM55_NTZ/non_secure/port.c index e7f7a6501e..a5ed7004a6 100644 --- a/portable/GCC/ARM_CM55_NTZ/non_secure/port.c +++ b/portable/GCC/ARM_CM55_NTZ/non_secure/port.c @@ -83,7 +83,7 @@ /** * @brief Prototype of all Interrupt Service Routines (ISRs). */ -typedef void ( *portISR_t )( void ); +typedef void ( * portISR_t )( void ); /*-----------------------------------------------------------*/ /** diff --git a/portable/GCC/ARM_CM85/non_secure/port.c b/portable/GCC/ARM_CM85/non_secure/port.c index e7f7a6501e..a5ed7004a6 100644 --- a/portable/GCC/ARM_CM85/non_secure/port.c +++ b/portable/GCC/ARM_CM85/non_secure/port.c @@ -83,7 +83,7 @@ /** * @brief Prototype of all Interrupt Service Routines (ISRs). */ -typedef void ( *portISR_t )( void ); +typedef void ( * portISR_t )( void ); /*-----------------------------------------------------------*/ /** diff --git a/portable/GCC/ARM_CM85_NTZ/non_secure/port.c b/portable/GCC/ARM_CM85_NTZ/non_secure/port.c index e7f7a6501e..a5ed7004a6 100644 --- a/portable/GCC/ARM_CM85_NTZ/non_secure/port.c +++ b/portable/GCC/ARM_CM85_NTZ/non_secure/port.c @@ -83,7 +83,7 @@ /** * @brief Prototype of all Interrupt Service Routines (ISRs). */ -typedef void ( *portISR_t )( void ); +typedef void ( * portISR_t )( void ); /*-----------------------------------------------------------*/ /** diff --git a/portable/IAR/ARM_CM23/non_secure/port.c b/portable/IAR/ARM_CM23/non_secure/port.c index e7f7a6501e..a5ed7004a6 100644 --- a/portable/IAR/ARM_CM23/non_secure/port.c +++ b/portable/IAR/ARM_CM23/non_secure/port.c @@ -83,7 +83,7 @@ /** * @brief Prototype of all Interrupt Service Routines (ISRs). */ -typedef void ( *portISR_t )( void ); +typedef void ( * portISR_t )( void ); /*-----------------------------------------------------------*/ /** diff --git a/portable/IAR/ARM_CM23_NTZ/non_secure/port.c b/portable/IAR/ARM_CM23_NTZ/non_secure/port.c index e7f7a6501e..a5ed7004a6 100644 --- a/portable/IAR/ARM_CM23_NTZ/non_secure/port.c +++ b/portable/IAR/ARM_CM23_NTZ/non_secure/port.c @@ -83,7 +83,7 @@ /** * @brief Prototype of all Interrupt Service Routines (ISRs). */ -typedef void ( *portISR_t )( void ); +typedef void ( * portISR_t )( void ); /*-----------------------------------------------------------*/ /** diff --git a/portable/IAR/ARM_CM33/non_secure/port.c b/portable/IAR/ARM_CM33/non_secure/port.c index e7f7a6501e..a5ed7004a6 100644 --- a/portable/IAR/ARM_CM33/non_secure/port.c +++ b/portable/IAR/ARM_CM33/non_secure/port.c @@ -83,7 +83,7 @@ /** * @brief Prototype of all Interrupt Service Routines (ISRs). */ -typedef void ( *portISR_t )( void ); +typedef void ( * portISR_t )( void ); /*-----------------------------------------------------------*/ /** diff --git a/portable/IAR/ARM_CM33_NTZ/non_secure/port.c b/portable/IAR/ARM_CM33_NTZ/non_secure/port.c index e7f7a6501e..a5ed7004a6 100644 --- a/portable/IAR/ARM_CM33_NTZ/non_secure/port.c +++ b/portable/IAR/ARM_CM33_NTZ/non_secure/port.c @@ -83,7 +83,7 @@ /** * @brief Prototype of all Interrupt Service Routines (ISRs). */ -typedef void ( *portISR_t )( void ); +typedef void ( * portISR_t )( void ); /*-----------------------------------------------------------*/ /** diff --git a/portable/IAR/ARM_CM35P/non_secure/port.c b/portable/IAR/ARM_CM35P/non_secure/port.c index e7f7a6501e..a5ed7004a6 100644 --- a/portable/IAR/ARM_CM35P/non_secure/port.c +++ b/portable/IAR/ARM_CM35P/non_secure/port.c @@ -83,7 +83,7 @@ /** * @brief Prototype of all Interrupt Service Routines (ISRs). */ -typedef void ( *portISR_t )( void ); +typedef void ( * portISR_t )( void ); /*-----------------------------------------------------------*/ /** diff --git a/portable/IAR/ARM_CM35P_NTZ/non_secure/port.c b/portable/IAR/ARM_CM35P_NTZ/non_secure/port.c index e7f7a6501e..a5ed7004a6 100644 --- a/portable/IAR/ARM_CM35P_NTZ/non_secure/port.c +++ b/portable/IAR/ARM_CM35P_NTZ/non_secure/port.c @@ -83,7 +83,7 @@ /** * @brief Prototype of all Interrupt Service Routines (ISRs). */ -typedef void ( *portISR_t )( void ); +typedef void ( * portISR_t )( void ); /*-----------------------------------------------------------*/ /** diff --git a/portable/IAR/ARM_CM55/non_secure/port.c b/portable/IAR/ARM_CM55/non_secure/port.c index e7f7a6501e..a5ed7004a6 100644 --- a/portable/IAR/ARM_CM55/non_secure/port.c +++ b/portable/IAR/ARM_CM55/non_secure/port.c @@ -83,7 +83,7 @@ /** * @brief Prototype of all Interrupt Service Routines (ISRs). */ -typedef void ( *portISR_t )( void ); +typedef void ( * portISR_t )( void ); /*-----------------------------------------------------------*/ /** diff --git a/portable/IAR/ARM_CM55_NTZ/non_secure/port.c b/portable/IAR/ARM_CM55_NTZ/non_secure/port.c index e7f7a6501e..a5ed7004a6 100644 --- a/portable/IAR/ARM_CM55_NTZ/non_secure/port.c +++ b/portable/IAR/ARM_CM55_NTZ/non_secure/port.c @@ -83,7 +83,7 @@ /** * @brief Prototype of all Interrupt Service Routines (ISRs). */ -typedef void ( *portISR_t )( void ); +typedef void ( * portISR_t )( void ); /*-----------------------------------------------------------*/ /** diff --git a/portable/IAR/ARM_CM85/non_secure/port.c b/portable/IAR/ARM_CM85/non_secure/port.c index e7f7a6501e..a5ed7004a6 100644 --- a/portable/IAR/ARM_CM85/non_secure/port.c +++ b/portable/IAR/ARM_CM85/non_secure/port.c @@ -83,7 +83,7 @@ /** * @brief Prototype of all Interrupt Service Routines (ISRs). */ -typedef void ( *portISR_t )( void ); +typedef void ( * portISR_t )( void ); /*-----------------------------------------------------------*/ /** diff --git a/portable/IAR/ARM_CM85_NTZ/non_secure/port.c b/portable/IAR/ARM_CM85_NTZ/non_secure/port.c index e7f7a6501e..a5ed7004a6 100644 --- a/portable/IAR/ARM_CM85_NTZ/non_secure/port.c +++ b/portable/IAR/ARM_CM85_NTZ/non_secure/port.c @@ -83,7 +83,7 @@ /** * @brief Prototype of all Interrupt Service Routines (ISRs). */ -typedef void ( *portISR_t )( void ); +typedef void ( * portISR_t )( void ); /*-----------------------------------------------------------*/ /**