Skip to content

Commit

Permalink
Make taskYIELD available to unprivileged tasks (#817)
Browse files Browse the repository at this point in the history
Make taskYIELD available to unprivileged tasks on ARMv8-M
ports.
  • Loading branch information
aggarg authored Oct 6, 2023
1 parent d442d79 commit 3d575b5
Show file tree
Hide file tree
Showing 42 changed files with 315 additions and 21 deletions.
6 changes: 6 additions & 0 deletions portable/ARMv8M/non_secure/port.c
Original file line number Diff line number Diff line change
Expand Up @@ -1118,6 +1118,12 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO
break;
#endif /* ( configENABLE_MPU == 1 ) && ( configUSE_MPU_WRAPPERS_V1 == 1 ) */

#if ( configENABLE_MPU == 1 )
case portSVC_YIELD:
vPortYield();
break;
#endif /* configENABLE_MPU == 1 */

default:
/* Incorrect SVC call. */
configASSERT( pdFALSE );
Expand Down
10 changes: 9 additions & 1 deletion portable/ARMv8M/non_secure/portmacrocommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -329,12 +329,20 @@ extern void vClearInterruptMask( uint32_t ulMask ) /* __attribute__(( naked )) P
#define portSVC_SYSTEM_CALL_ENTER 4 /* System calls with upto 4 parameters. */
#define portSVC_SYSTEM_CALL_ENTER_1 5 /* System calls with 5 parameters. */
#define portSVC_SYSTEM_CALL_EXIT 6
#define portSVC_YIELD 7
/*-----------------------------------------------------------*/

/**
* @brief Scheduler utilities.
*/
#define portYIELD() vPortYield()
#if ( configENABLE_MPU == 1 )
#define portYIELD() __asm volatile ( "svc %0" ::"i" ( portSVC_YIELD ) : "memory" )
#define portYIELD_WITHIN_API() vPortYield()
#else
#define portYIELD() vPortYield()
#define portYIELD_WITHIN_API() vPortYield()
#endif

#define portNVIC_INT_CTRL_REG ( *( ( volatile uint32_t * ) 0xe000ed04 ) )
#define portNVIC_PENDSVSET_BIT ( 1UL << 28UL )
#define portEND_SWITCHING_ISR( xSwitchRequired ) \
Expand Down
6 changes: 6 additions & 0 deletions portable/GCC/ARM_CM23/non_secure/port.c
Original file line number Diff line number Diff line change
Expand Up @@ -1118,6 +1118,12 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO
break;
#endif /* ( configENABLE_MPU == 1 ) && ( configUSE_MPU_WRAPPERS_V1 == 1 ) */

#if ( configENABLE_MPU == 1 )
case portSVC_YIELD:
vPortYield();
break;
#endif /* configENABLE_MPU == 1 */

default:
/* Incorrect SVC call. */
configASSERT( pdFALSE );
Expand Down
10 changes: 9 additions & 1 deletion portable/GCC/ARM_CM23/non_secure/portmacrocommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -329,12 +329,20 @@ extern void vClearInterruptMask( uint32_t ulMask ) /* __attribute__(( naked )) P
#define portSVC_SYSTEM_CALL_ENTER 4 /* System calls with upto 4 parameters. */
#define portSVC_SYSTEM_CALL_ENTER_1 5 /* System calls with 5 parameters. */
#define portSVC_SYSTEM_CALL_EXIT 6
#define portSVC_YIELD 7
/*-----------------------------------------------------------*/

/**
* @brief Scheduler utilities.
*/
#define portYIELD() vPortYield()
#if ( configENABLE_MPU == 1 )
#define portYIELD() __asm volatile ( "svc %0" ::"i" ( portSVC_YIELD ) : "memory" )
#define portYIELD_WITHIN_API() vPortYield()
#else
#define portYIELD() vPortYield()
#define portYIELD_WITHIN_API() vPortYield()
#endif

#define portNVIC_INT_CTRL_REG ( *( ( volatile uint32_t * ) 0xe000ed04 ) )
#define portNVIC_PENDSVSET_BIT ( 1UL << 28UL )
#define portEND_SWITCHING_ISR( xSwitchRequired ) \
Expand Down
6 changes: 6 additions & 0 deletions portable/GCC/ARM_CM23_NTZ/non_secure/port.c
Original file line number Diff line number Diff line change
Expand Up @@ -1118,6 +1118,12 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO
break;
#endif /* ( configENABLE_MPU == 1 ) && ( configUSE_MPU_WRAPPERS_V1 == 1 ) */

#if ( configENABLE_MPU == 1 )
case portSVC_YIELD:
vPortYield();
break;
#endif /* configENABLE_MPU == 1 */

default:
/* Incorrect SVC call. */
configASSERT( pdFALSE );
Expand Down
10 changes: 9 additions & 1 deletion portable/GCC/ARM_CM23_NTZ/non_secure/portmacrocommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -329,12 +329,20 @@ extern void vClearInterruptMask( uint32_t ulMask ) /* __attribute__(( naked )) P
#define portSVC_SYSTEM_CALL_ENTER 4 /* System calls with upto 4 parameters. */
#define portSVC_SYSTEM_CALL_ENTER_1 5 /* System calls with 5 parameters. */
#define portSVC_SYSTEM_CALL_EXIT 6
#define portSVC_YIELD 7
/*-----------------------------------------------------------*/

/**
* @brief Scheduler utilities.
*/
#define portYIELD() vPortYield()
#if ( configENABLE_MPU == 1 )
#define portYIELD() __asm volatile ( "svc %0" ::"i" ( portSVC_YIELD ) : "memory" )
#define portYIELD_WITHIN_API() vPortYield()
#else
#define portYIELD() vPortYield()
#define portYIELD_WITHIN_API() vPortYield()
#endif

#define portNVIC_INT_CTRL_REG ( *( ( volatile uint32_t * ) 0xe000ed04 ) )
#define portNVIC_PENDSVSET_BIT ( 1UL << 28UL )
#define portEND_SWITCHING_ISR( xSwitchRequired ) \
Expand Down
6 changes: 6 additions & 0 deletions portable/GCC/ARM_CM33/non_secure/port.c
Original file line number Diff line number Diff line change
Expand Up @@ -1118,6 +1118,12 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO
break;
#endif /* ( configENABLE_MPU == 1 ) && ( configUSE_MPU_WRAPPERS_V1 == 1 ) */

#if ( configENABLE_MPU == 1 )
case portSVC_YIELD:
vPortYield();
break;
#endif /* configENABLE_MPU == 1 */

default:
/* Incorrect SVC call. */
configASSERT( pdFALSE );
Expand Down
10 changes: 9 additions & 1 deletion portable/GCC/ARM_CM33/non_secure/portmacrocommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -329,12 +329,20 @@ extern void vClearInterruptMask( uint32_t ulMask ) /* __attribute__(( naked )) P
#define portSVC_SYSTEM_CALL_ENTER 4 /* System calls with upto 4 parameters. */
#define portSVC_SYSTEM_CALL_ENTER_1 5 /* System calls with 5 parameters. */
#define portSVC_SYSTEM_CALL_EXIT 6
#define portSVC_YIELD 7
/*-----------------------------------------------------------*/

/**
* @brief Scheduler utilities.
*/
#define portYIELD() vPortYield()
#if ( configENABLE_MPU == 1 )
#define portYIELD() __asm volatile ( "svc %0" ::"i" ( portSVC_YIELD ) : "memory" )
#define portYIELD_WITHIN_API() vPortYield()
#else
#define portYIELD() vPortYield()
#define portYIELD_WITHIN_API() vPortYield()
#endif

#define portNVIC_INT_CTRL_REG ( *( ( volatile uint32_t * ) 0xe000ed04 ) )
#define portNVIC_PENDSVSET_BIT ( 1UL << 28UL )
#define portEND_SWITCHING_ISR( xSwitchRequired ) \
Expand Down
6 changes: 6 additions & 0 deletions portable/GCC/ARM_CM33_NTZ/non_secure/port.c
Original file line number Diff line number Diff line change
Expand Up @@ -1118,6 +1118,12 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO
break;
#endif /* ( configENABLE_MPU == 1 ) && ( configUSE_MPU_WRAPPERS_V1 == 1 ) */

#if ( configENABLE_MPU == 1 )
case portSVC_YIELD:
vPortYield();
break;
#endif /* configENABLE_MPU == 1 */

default:
/* Incorrect SVC call. */
configASSERT( pdFALSE );
Expand Down
10 changes: 9 additions & 1 deletion portable/GCC/ARM_CM33_NTZ/non_secure/portmacrocommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -329,12 +329,20 @@ extern void vClearInterruptMask( uint32_t ulMask ) /* __attribute__(( naked )) P
#define portSVC_SYSTEM_CALL_ENTER 4 /* System calls with upto 4 parameters. */
#define portSVC_SYSTEM_CALL_ENTER_1 5 /* System calls with 5 parameters. */
#define portSVC_SYSTEM_CALL_EXIT 6
#define portSVC_YIELD 7
/*-----------------------------------------------------------*/

/**
* @brief Scheduler utilities.
*/
#define portYIELD() vPortYield()
#if ( configENABLE_MPU == 1 )
#define portYIELD() __asm volatile ( "svc %0" ::"i" ( portSVC_YIELD ) : "memory" )
#define portYIELD_WITHIN_API() vPortYield()
#else
#define portYIELD() vPortYield()
#define portYIELD_WITHIN_API() vPortYield()
#endif

#define portNVIC_INT_CTRL_REG ( *( ( volatile uint32_t * ) 0xe000ed04 ) )
#define portNVIC_PENDSVSET_BIT ( 1UL << 28UL )
#define portEND_SWITCHING_ISR( xSwitchRequired ) \
Expand Down
6 changes: 6 additions & 0 deletions portable/GCC/ARM_CM35P/non_secure/port.c
Original file line number Diff line number Diff line change
Expand Up @@ -1118,6 +1118,12 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO
break;
#endif /* ( configENABLE_MPU == 1 ) && ( configUSE_MPU_WRAPPERS_V1 == 1 ) */

#if ( configENABLE_MPU == 1 )
case portSVC_YIELD:
vPortYield();
break;
#endif /* configENABLE_MPU == 1 */

default:
/* Incorrect SVC call. */
configASSERT( pdFALSE );
Expand Down
10 changes: 9 additions & 1 deletion portable/GCC/ARM_CM35P/non_secure/portmacrocommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -329,12 +329,20 @@ extern void vClearInterruptMask( uint32_t ulMask ) /* __attribute__(( naked )) P
#define portSVC_SYSTEM_CALL_ENTER 4 /* System calls with upto 4 parameters. */
#define portSVC_SYSTEM_CALL_ENTER_1 5 /* System calls with 5 parameters. */
#define portSVC_SYSTEM_CALL_EXIT 6
#define portSVC_YIELD 7
/*-----------------------------------------------------------*/

/**
* @brief Scheduler utilities.
*/
#define portYIELD() vPortYield()
#if ( configENABLE_MPU == 1 )
#define portYIELD() __asm volatile ( "svc %0" ::"i" ( portSVC_YIELD ) : "memory" )
#define portYIELD_WITHIN_API() vPortYield()
#else
#define portYIELD() vPortYield()
#define portYIELD_WITHIN_API() vPortYield()
#endif

#define portNVIC_INT_CTRL_REG ( *( ( volatile uint32_t * ) 0xe000ed04 ) )
#define portNVIC_PENDSVSET_BIT ( 1UL << 28UL )
#define portEND_SWITCHING_ISR( xSwitchRequired ) \
Expand Down
6 changes: 6 additions & 0 deletions portable/GCC/ARM_CM35P_NTZ/non_secure/port.c
Original file line number Diff line number Diff line change
Expand Up @@ -1118,6 +1118,12 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO
break;
#endif /* ( configENABLE_MPU == 1 ) && ( configUSE_MPU_WRAPPERS_V1 == 1 ) */

#if ( configENABLE_MPU == 1 )
case portSVC_YIELD:
vPortYield();
break;
#endif /* configENABLE_MPU == 1 */

default:
/* Incorrect SVC call. */
configASSERT( pdFALSE );
Expand Down
10 changes: 9 additions & 1 deletion portable/GCC/ARM_CM35P_NTZ/non_secure/portmacrocommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -329,12 +329,20 @@ extern void vClearInterruptMask( uint32_t ulMask ) /* __attribute__(( naked )) P
#define portSVC_SYSTEM_CALL_ENTER 4 /* System calls with upto 4 parameters. */
#define portSVC_SYSTEM_CALL_ENTER_1 5 /* System calls with 5 parameters. */
#define portSVC_SYSTEM_CALL_EXIT 6
#define portSVC_YIELD 7
/*-----------------------------------------------------------*/

/**
* @brief Scheduler utilities.
*/
#define portYIELD() vPortYield()
#if ( configENABLE_MPU == 1 )
#define portYIELD() __asm volatile ( "svc %0" ::"i" ( portSVC_YIELD ) : "memory" )
#define portYIELD_WITHIN_API() vPortYield()
#else
#define portYIELD() vPortYield()
#define portYIELD_WITHIN_API() vPortYield()
#endif

#define portNVIC_INT_CTRL_REG ( *( ( volatile uint32_t * ) 0xe000ed04 ) )
#define portNVIC_PENDSVSET_BIT ( 1UL << 28UL )
#define portEND_SWITCHING_ISR( xSwitchRequired ) \
Expand Down
6 changes: 6 additions & 0 deletions portable/GCC/ARM_CM55/non_secure/port.c
Original file line number Diff line number Diff line change
Expand Up @@ -1118,6 +1118,12 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO
break;
#endif /* ( configENABLE_MPU == 1 ) && ( configUSE_MPU_WRAPPERS_V1 == 1 ) */

#if ( configENABLE_MPU == 1 )
case portSVC_YIELD:
vPortYield();
break;
#endif /* configENABLE_MPU == 1 */

default:
/* Incorrect SVC call. */
configASSERT( pdFALSE );
Expand Down
10 changes: 9 additions & 1 deletion portable/GCC/ARM_CM55/non_secure/portmacrocommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -329,12 +329,20 @@ extern void vClearInterruptMask( uint32_t ulMask ) /* __attribute__(( naked )) P
#define portSVC_SYSTEM_CALL_ENTER 4 /* System calls with upto 4 parameters. */
#define portSVC_SYSTEM_CALL_ENTER_1 5 /* System calls with 5 parameters. */
#define portSVC_SYSTEM_CALL_EXIT 6
#define portSVC_YIELD 7
/*-----------------------------------------------------------*/

/**
* @brief Scheduler utilities.
*/
#define portYIELD() vPortYield()
#if ( configENABLE_MPU == 1 )
#define portYIELD() __asm volatile ( "svc %0" ::"i" ( portSVC_YIELD ) : "memory" )
#define portYIELD_WITHIN_API() vPortYield()
#else
#define portYIELD() vPortYield()
#define portYIELD_WITHIN_API() vPortYield()
#endif

#define portNVIC_INT_CTRL_REG ( *( ( volatile uint32_t * ) 0xe000ed04 ) )
#define portNVIC_PENDSVSET_BIT ( 1UL << 28UL )
#define portEND_SWITCHING_ISR( xSwitchRequired ) \
Expand Down
6 changes: 6 additions & 0 deletions portable/GCC/ARM_CM55_NTZ/non_secure/port.c
Original file line number Diff line number Diff line change
Expand Up @@ -1118,6 +1118,12 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO
break;
#endif /* ( configENABLE_MPU == 1 ) && ( configUSE_MPU_WRAPPERS_V1 == 1 ) */

#if ( configENABLE_MPU == 1 )
case portSVC_YIELD:
vPortYield();
break;
#endif /* configENABLE_MPU == 1 */

default:
/* Incorrect SVC call. */
configASSERT( pdFALSE );
Expand Down
10 changes: 9 additions & 1 deletion portable/GCC/ARM_CM55_NTZ/non_secure/portmacrocommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -329,12 +329,20 @@ extern void vClearInterruptMask( uint32_t ulMask ) /* __attribute__(( naked )) P
#define portSVC_SYSTEM_CALL_ENTER 4 /* System calls with upto 4 parameters. */
#define portSVC_SYSTEM_CALL_ENTER_1 5 /* System calls with 5 parameters. */
#define portSVC_SYSTEM_CALL_EXIT 6
#define portSVC_YIELD 7
/*-----------------------------------------------------------*/

/**
* @brief Scheduler utilities.
*/
#define portYIELD() vPortYield()
#if ( configENABLE_MPU == 1 )
#define portYIELD() __asm volatile ( "svc %0" ::"i" ( portSVC_YIELD ) : "memory" )
#define portYIELD_WITHIN_API() vPortYield()
#else
#define portYIELD() vPortYield()
#define portYIELD_WITHIN_API() vPortYield()
#endif

#define portNVIC_INT_CTRL_REG ( *( ( volatile uint32_t * ) 0xe000ed04 ) )
#define portNVIC_PENDSVSET_BIT ( 1UL << 28UL )
#define portEND_SWITCHING_ISR( xSwitchRequired ) \
Expand Down
6 changes: 6 additions & 0 deletions portable/GCC/ARM_CM85/non_secure/port.c
Original file line number Diff line number Diff line change
Expand Up @@ -1118,6 +1118,12 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO
break;
#endif /* ( configENABLE_MPU == 1 ) && ( configUSE_MPU_WRAPPERS_V1 == 1 ) */

#if ( configENABLE_MPU == 1 )
case portSVC_YIELD:
vPortYield();
break;
#endif /* configENABLE_MPU == 1 */

default:
/* Incorrect SVC call. */
configASSERT( pdFALSE );
Expand Down
10 changes: 9 additions & 1 deletion portable/GCC/ARM_CM85/non_secure/portmacrocommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -329,12 +329,20 @@ extern void vClearInterruptMask( uint32_t ulMask ) /* __attribute__(( naked )) P
#define portSVC_SYSTEM_CALL_ENTER 4 /* System calls with upto 4 parameters. */
#define portSVC_SYSTEM_CALL_ENTER_1 5 /* System calls with 5 parameters. */
#define portSVC_SYSTEM_CALL_EXIT 6
#define portSVC_YIELD 7
/*-----------------------------------------------------------*/

/**
* @brief Scheduler utilities.
*/
#define portYIELD() vPortYield()
#if ( configENABLE_MPU == 1 )
#define portYIELD() __asm volatile ( "svc %0" ::"i" ( portSVC_YIELD ) : "memory" )
#define portYIELD_WITHIN_API() vPortYield()
#else
#define portYIELD() vPortYield()
#define portYIELD_WITHIN_API() vPortYield()
#endif

#define portNVIC_INT_CTRL_REG ( *( ( volatile uint32_t * ) 0xe000ed04 ) )
#define portNVIC_PENDSVSET_BIT ( 1UL << 28UL )
#define portEND_SWITCHING_ISR( xSwitchRequired ) \
Expand Down
6 changes: 6 additions & 0 deletions portable/GCC/ARM_CM85_NTZ/non_secure/port.c
Original file line number Diff line number Diff line change
Expand Up @@ -1118,6 +1118,12 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO
break;
#endif /* ( configENABLE_MPU == 1 ) && ( configUSE_MPU_WRAPPERS_V1 == 1 ) */

#if ( configENABLE_MPU == 1 )
case portSVC_YIELD:
vPortYield();
break;
#endif /* configENABLE_MPU == 1 */

default:
/* Incorrect SVC call. */
configASSERT( pdFALSE );
Expand Down
10 changes: 9 additions & 1 deletion portable/GCC/ARM_CM85_NTZ/non_secure/portmacrocommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -329,12 +329,20 @@ extern void vClearInterruptMask( uint32_t ulMask ) /* __attribute__(( naked )) P
#define portSVC_SYSTEM_CALL_ENTER 4 /* System calls with upto 4 parameters. */
#define portSVC_SYSTEM_CALL_ENTER_1 5 /* System calls with 5 parameters. */
#define portSVC_SYSTEM_CALL_EXIT 6
#define portSVC_YIELD 7
/*-----------------------------------------------------------*/

/**
* @brief Scheduler utilities.
*/
#define portYIELD() vPortYield()
#if ( configENABLE_MPU == 1 )
#define portYIELD() __asm volatile ( "svc %0" ::"i" ( portSVC_YIELD ) : "memory" )
#define portYIELD_WITHIN_API() vPortYield()
#else
#define portYIELD() vPortYield()
#define portYIELD_WITHIN_API() vPortYield()
#endif

#define portNVIC_INT_CTRL_REG ( *( ( volatile uint32_t * ) 0xe000ed04 ) )
#define portNVIC_PENDSVSET_BIT ( 1UL << 28UL )
#define portEND_SWITCHING_ISR( xSwitchRequired ) \
Expand Down
6 changes: 6 additions & 0 deletions portable/IAR/ARM_CM23/non_secure/port.c
Original file line number Diff line number Diff line change
Expand Up @@ -1118,6 +1118,12 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO
break;
#endif /* ( configENABLE_MPU == 1 ) && ( configUSE_MPU_WRAPPERS_V1 == 1 ) */

#if ( configENABLE_MPU == 1 )
case portSVC_YIELD:
vPortYield();
break;
#endif /* configENABLE_MPU == 1 */

default:
/* Incorrect SVC call. */
configASSERT( pdFALSE );
Expand Down
Loading

0 comments on commit 3d575b5

Please sign in to comment.