From: richardbarry Date: Thu, 11 Jul 2013 10:05:06 +0000 (+0000) Subject: Complete additions of portASSERT_IF_INTERRUPT_PRIORITY_INVALID() for all RX compiler... X-Git-Tag: V7.5.0~20 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=c5a7998713fd42107ea0ffdf92c7a80b2969fbd9;p=freertos Complete additions of portASSERT_IF_INTERRUPT_PRIORITY_INVALID() for all RX compiler ports. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@1970 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- diff --git a/FreeRTOS/Source/portable/GCC/RX100/portmacro.h b/FreeRTOS/Source/portable/GCC/RX100/portmacro.h index f5317c07b..b3cff6084 100644 --- a/FreeRTOS/Source/portable/GCC/RX100/portmacro.h +++ b/FreeRTOS/Source/portable/GCC/RX100/portmacro.h @@ -115,6 +115,10 @@ portSTACK_TYPE and portBASE_TYPE. */ #define portTICK_RATE_MS ( ( portTickType ) 1000 / configTICK_RATE_HZ ) #define portNOP() __asm volatile( "NOP" ) +#ifdef configASSERT + #define portASSERT_IF_INTERRUPT_PRIORITY_INVALID() configASSERT( ( ulPortGetIPL() <= configMAX_SYSCALL_INTERRUPT_PRIORITY ) ) +#endif + /* Save clobbered register, set ITU SWINR (at address 0x872E0), read the value back to ensure it is set before continuing, then restore the clobbered register. */ @@ -131,10 +135,15 @@ register. */ /* * These macros should be called directly, but through the taskENTER_CRITICAL() - * and taskEXIT_CRITICAL() macros. + * and taskEXIT_CRITICAL() macros. If the RTOS is being used correctly then + * the check to ensure the IPL is not being lowered will not be needed. It is + * included to ensure assert()s triggered by using an incorrect interrupt + * priority do not result in the assert() handler inadvertently lowering the + * priority mask, and in so doing allowing the offending interrupt to continue + * triggering until stack space is exhausted. */ #define portENABLE_INTERRUPTS() __asm volatile ( "MVTIPL #0" ); -#define portDISABLE_INTERRUPTS() __asm volatile ( "MVTIPL %0" ::"i"(configMAX_SYSCALL_INTERRUPT_PRIORITY) ) +#define portDISABLE_INTERRUPTS() if( ulPortGetIPL() < configMAX_SYSCALL_INTERRUPT_PRIORITY ) __asm volatile ( "MVTIPL %0" ::"i"(configMAX_SYSCALL_INTERRUPT_PRIORITY) ) /* Critical nesting counts are stored in the TCB. */ #define portCRITICAL_NESTING_IN_TCB ( 1 ) diff --git a/FreeRTOS/Source/portable/GCC/RX600/portmacro.h b/FreeRTOS/Source/portable/GCC/RX600/portmacro.h index f92bf459a..0e6c6d3e3 100644 --- a/FreeRTOS/Source/portable/GCC/RX600/portmacro.h +++ b/FreeRTOS/Source/portable/GCC/RX600/portmacro.h @@ -115,6 +115,11 @@ portSTACK_TYPE and portBASE_TYPE. */ #define portTICK_RATE_MS ( ( portTickType ) 1000 / configTICK_RATE_HZ ) #define portNOP() __asm volatile( "NOP" ) +#ifdef configASSERT + #define portASSERT_IF_INTERRUPT_PRIORITY_INVALID() configASSERT( ( ulPortGetIPL() <= configMAX_SYSCALL_INTERRUPT_PRIORITY ) ) +#endif + + /* Yield equivalent to "*portITU_SWINTR = 0x01; ( void ) *portITU_SWINTR;" where portITU_SWINTR is the location of the software interrupt register (0x000872E0). Don't rely on the assembler to select a register, so instead @@ -133,10 +138,15 @@ save and restore clobbered registers manually. */ /* * These macros should be called directly, but through the taskENTER_CRITICAL() - * and taskEXIT_CRITICAL() macros. + * and taskEXIT_CRITICAL() macros. If the RTOS is being used correctly then + * the check to ensure the IPL is not being lowered will not be needed. It is + * included to ensure assert()s triggered by using an incorrect interrupt + * priority do not result in the assert() handler inadvertently lowering the + * priority mask, and in so doing allowing the offending interrupt to continue + * triggering until stack space is exhausted. */ #define portENABLE_INTERRUPTS() __asm volatile ( "MVTIPL #0" ); -#define portDISABLE_INTERRUPTS() __asm volatile ( "MVTIPL %0" ::"i"(configMAX_SYSCALL_INTERRUPT_PRIORITY) ) +#define portDISABLE_INTERRUPTS() if( ulPortGetIPL() < configMAX_SYSCALL_INTERRUPT_PRIORITY ) __asm volatile ( "MVTIPL %0" ::"i"(configMAX_SYSCALL_INTERRUPT_PRIORITY) ) /* Critical nesting counts are stored in the TCB. */ #define portCRITICAL_NESTING_IN_TCB ( 1 ) diff --git a/FreeRTOS/Source/portable/IAR/RX100/portmacro.h b/FreeRTOS/Source/portable/IAR/RX100/portmacro.h index d8c421fb9..0c50981af 100644 --- a/FreeRTOS/Source/portable/IAR/RX100/portmacro.h +++ b/FreeRTOS/Source/portable/IAR/RX100/portmacro.h @@ -120,6 +120,10 @@ portSTACK_TYPE and portBASE_TYPE. */ #define portTICK_RATE_MS ( ( portTickType ) 1000 / configTICK_RATE_HZ ) #define portNOP() __no_operation() +#ifdef configASSERT + #define portASSERT_IF_INTERRUPT_PRIORITY_INVALID() configASSERT( ( __get_interrupt_level() <= configMAX_SYSCALL_INTERRUPT_PRIORITY ) ) +#endif + #define portYIELD() \ __asm volatile \ ( \ @@ -133,10 +137,15 @@ portSTACK_TYPE and portBASE_TYPE. */ /* * These macros should be called directly, but through the taskENTER_CRITICAL() - * and taskEXIT_CRITICAL() macros. + * and taskEXIT_CRITICAL() macros. If the RTOS is being used correctly then + * the check to ensure the IPL is not being lowered will not be needed. It is + * included to ensure assert()s triggered by using an incorrect interrupt + * priority do not result in the assert() handler inadvertently lowering the + * priority mask, and in so doing allowing the offending interrupt to continue + * triggering until stack space is exhausted. */ #define portENABLE_INTERRUPTS() __set_interrupt_level( ( unsigned char ) 0 ) -#define portDISABLE_INTERRUPTS() __set_interrupt_level( ( unsigned char ) configMAX_SYSCALL_INTERRUPT_PRIORITY ) +#define portDISABLE_INTERRUPTS() if( __get_interrupt_level() < configMAX_SYSCALL_INTERRUPT_PRIORITY ) __set_interrupt_level( ( unsigned char ) configMAX_SYSCALL_INTERRUPT_PRIORITY ) /* Critical nesting counts are stored in the TCB. */ #define portCRITICAL_NESTING_IN_TCB ( 1 ) diff --git a/FreeRTOS/Source/portable/IAR/RX600/portmacro.h b/FreeRTOS/Source/portable/IAR/RX600/portmacro.h index 3f409cf6e..45b373af5 100644 --- a/FreeRTOS/Source/portable/IAR/RX600/portmacro.h +++ b/FreeRTOS/Source/portable/IAR/RX600/portmacro.h @@ -117,6 +117,10 @@ portSTACK_TYPE and portBASE_TYPE. */ #define portTICK_RATE_MS ( ( portTickType ) 1000 / configTICK_RATE_HZ ) #define portNOP() __no_operation() +#ifdef configASSERT + #define portASSERT_IF_INTERRUPT_PRIORITY_INVALID() configASSERT( ( __get_interrupt_level() <= configMAX_SYSCALL_INTERRUPT_PRIORITY ) ) +#endif + /* Yield equivalent to "*portITU_SWINTR = 0x01; ( void ) *portITU_SWINTR;" where portITU_SWINTR is the location of the software interrupt register (0x000872E0). Don't rely on the assembler to select a register, so instead @@ -135,10 +139,15 @@ save and restore clobbered registers manually. */ /* * These macros should be called directly, but through the taskENTER_CRITICAL() - * and taskEXIT_CRITICAL() macros. + * and taskEXIT_CRITICAL() macros. If the RTOS is being used correctly then + * the check to ensure the IPL is not being lowered will not be needed. It is + * included to ensure assert()s triggered by using an incorrect interrupt + * priority do not result in the assert() handler inadvertently lowering the + * priority mask, and in so doing allowing the offending interrupt to continue + * triggering until stack space is exhausted. */ #define portENABLE_INTERRUPTS() __set_interrupt_level( ( unsigned char ) 0 ) -#define portDISABLE_INTERRUPTS() __set_interrupt_level( ( unsigned char ) configMAX_SYSCALL_INTERRUPT_PRIORITY ) +#define portDISABLE_INTERRUPTS() if( __get_interrupt_level() < configMAX_SYSCALL_INTERRUPT_PRIORITY ) __set_interrupt_level( ( unsigned char ) configMAX_SYSCALL_INTERRUPT_PRIORITY ) /* Critical nesting counts are stored in the TCB. */ #define portCRITICAL_NESTING_IN_TCB ( 1 ) diff --git a/FreeRTOS/Source/portable/Renesas/RX100/portmacro.h b/FreeRTOS/Source/portable/Renesas/RX100/portmacro.h index 66a59be34..736375eb1 100644 --- a/FreeRTOS/Source/portable/Renesas/RX100/portmacro.h +++ b/FreeRTOS/Source/portable/Renesas/RX100/portmacro.h @@ -142,10 +142,15 @@ static void vPortYield( void ) /* * These macros should be called directly, but through the taskENTER_CRITICAL() - * and taskEXIT_CRITICAL() macros. + * and taskEXIT_CRITICAL() macros. If the RTOS is being used correctly then + * the check to ensure the IPL is not being lowered will not be needed. It is + * included to ensure assert()s triggered by using an incorrect interrupt + * priority do not result in the assert() handler inadvertently lowering the + * priority mask, and in so doing allowing the offending interrupt to continue + * triggering until stack space is exhausted. */ #define portENABLE_INTERRUPTS() set_ipl( 0 ) -#define portDISABLE_INTERRUPTS() set_ipl( configMAX_SYSCALL_INTERRUPT_PRIORITY ) +#define portDISABLE_INTERRUPTS() if( get_ipl() < configMAX_SYSCALL_INTERRUPT_PRIORITY ) set_ipl( ( unsigned char ) configMAX_SYSCALL_INTERRUPT_PRIORITY ) /* Critical nesting counts are stored in the TCB. */ #define portCRITICAL_NESTING_IN_TCB ( 1 ) diff --git a/FreeRTOS/Source/portable/Renesas/RX200/portmacro.h b/FreeRTOS/Source/portable/Renesas/RX200/portmacro.h index 4c9c88e58..721334a48 100644 --- a/FreeRTOS/Source/portable/Renesas/RX200/portmacro.h +++ b/FreeRTOS/Source/portable/Renesas/RX200/portmacro.h @@ -142,10 +142,15 @@ static void vPortYield( void ) /* * These macros should be called directly, but through the taskENTER_CRITICAL() - * and taskEXIT_CRITICAL() macros. + * and taskEXIT_CRITICAL() macros. If the RTOS is being used correctly then + * the check to ensure the IPL is not being lowered will not be needed. It is + * included to ensure assert()s triggered by using an incorrect interrupt + * priority do not result in the assert() handler inadvertently lowering the + * priority mask, and in so doing allowing the offending interrupt to continue + * triggering until stack space is exhausted. */ #define portENABLE_INTERRUPTS() set_ipl( 0 ) -#define portDISABLE_INTERRUPTS() set_ipl( configMAX_SYSCALL_INTERRUPT_PRIORITY ) +#define portDISABLE_INTERRUPTS() if( get_ipl() < configMAX_SYSCALL_INTERRUPT_PRIORITY ) set_ipl( ( unsigned char ) configMAX_SYSCALL_INTERRUPT_PRIORITY ) /* Critical nesting counts are stored in the TCB. */ #define portCRITICAL_NESTING_IN_TCB ( 1 ) diff --git a/FreeRTOS/Source/portable/Renesas/RX600/portmacro.h b/FreeRTOS/Source/portable/Renesas/RX600/portmacro.h index 4c9c88e58..5a249d371 100644 --- a/FreeRTOS/Source/portable/Renesas/RX600/portmacro.h +++ b/FreeRTOS/Source/portable/Renesas/RX600/portmacro.h @@ -56,19 +56,19 @@ *************************************************************************** - http://www.FreeRTOS.org - Documentation, books, training, latest versions, + http://www.FreeRTOS.org - Documentation, books, training, latest versions, license and Real Time Engineers Ltd. contact details. http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, including FreeRTOS+Trace - an indispensable productivity tool, and our new fully thread aware and reentrant UDP/IP stack. - http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High - Integrity Systems, who sell the code with commercial support, + http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High + Integrity Systems, who sell the code with commercial support, indemnification and middleware, under the OpenRTOS brand. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and + + http://www.SafeRTOS.com - High Integrity Systems also provide a safety + engineered and independently SIL3 certified version for use in safety and mission critical applications that require provable dependability. */ @@ -84,7 +84,7 @@ extern "C" { #include "machine.h" /*----------------------------------------------------------- - * Port specific definitions. + * Port specific definitions. * * The settings in this file configure FreeRTOS correctly for the * given hardware and compiler. @@ -115,7 +115,7 @@ portSTACK_TYPE and portBASE_TYPE. */ /* Hardware specifics. */ #define portBYTE_ALIGNMENT 8 /* Could make four, according to manual. */ #define portSTACK_GROWTH -1 -#define portTICK_RATE_MS ( ( portTickType ) 1000 / configTICK_RATE_HZ ) +#define portTICK_RATE_MS ( ( portTickType ) 1000 / configTICK_RATE_HZ ) #define portNOP() nop() #ifdef configASSERT @@ -142,10 +142,15 @@ static void vPortYield( void ) /* * These macros should be called directly, but through the taskENTER_CRITICAL() - * and taskEXIT_CRITICAL() macros. + * and taskEXIT_CRITICAL() macros. If the RTOS is being used correctly then + * the check to ensure the IPL is not being lowered will not be needed. It is + * included to ensure assert()s triggered by using an incorrect interrupt + * priority do not result in the assert() handler inadvertently lowering the + * priority mask, and in so doing allowing the offending interrupt to continue + * triggering until stack space is exhausted. */ #define portENABLE_INTERRUPTS() set_ipl( 0 ) -#define portDISABLE_INTERRUPTS() set_ipl( configMAX_SYSCALL_INTERRUPT_PRIORITY ) +#define portDISABLE_INTERRUPTS() if( get_ipl() < configMAX_SYSCALL_INTERRUPT_PRIORITY ) set_ipl( ( unsigned char ) configMAX_SYSCALL_INTERRUPT_PRIORITY ) /* Critical nesting counts are stored in the TCB. */ #define portCRITICAL_NESTING_IN_TCB ( 1 )