@ -464,13 +464,44 @@ void vPortEndScheduler( void )
void vPortEnterCritical ( void )
void vPortEnterCritical ( void )
{
{
# if( configALLOW_UNPRIVILEGED_CRITICAL_SECTIONS == 1 )
# if( configALLOW_UNPRIVILEGED_CRITICAL_SECTIONS == 1 )
BaseType_t xRunningPrivileged ;
if ( portIS_PRIVILEGED ( ) = = pdFALSE )
xPortRaisePrivilege ( xRunningPrivileged ) ;
{
# endif
portRAISE_PRIVILEGE ( ) ;
portMEMORY_BARRIER ( ) ;
portDISABLE_INTERRUPTS ( ) ;
uxCriticalNesting + + ;
/* This is not the interrupt safe version of the enter critical function so
* assert ( ) if it is being called from an interrupt context . Only API
* functions that end in " FromISR " can be used in an interrupt . Only assert if
* the critical nesting count is 1 to protect against recursive calls if the
* assert function also uses a critical section . */
if ( uxCriticalNesting = = 1 )
{
configASSERT ( ( portNVIC_INT_CTRL_REG & portVECTACTIVE_MASK ) = = 0 ) ;
}
portMEMORY_BARRIER ( ) ;
portRESET_PRIVILEGE ( ) ;
portMEMORY_BARRIER ( ) ;
}
else
{
portDISABLE_INTERRUPTS ( ) ;
uxCriticalNesting + + ;
/* This is not the interrupt safe version of the enter critical function so
* assert ( ) if it is being called from an interrupt context . Only API
* functions that end in " FromISR " can be used in an interrupt . Only assert if
* the critical nesting count is 1 to protect against recursive calls if the
* assert function also uses a critical section . */
if ( uxCriticalNesting = = 1 )
{
configASSERT ( ( portNVIC_INT_CTRL_REG & portVECTACTIVE_MASK ) = = 0 ) ;
}
}
# else
portDISABLE_INTERRUPTS ( ) ;
portDISABLE_INTERRUPTS ( ) ;
uxCriticalNesting + + ;
uxCriticalNesting + + ;
/* This is not the interrupt safe version of the enter critical function so
/* This is not the interrupt safe version of the enter critical function so
* assert ( ) if it is being called from an interrupt context . Only API
* assert ( ) if it is being called from an interrupt context . Only API
* functions that end in " FromISR " can be used in an interrupt . Only assert if
* functions that end in " FromISR " can be used in an interrupt . Only assert if
@ -480,9 +511,6 @@ void vPortEnterCritical( void )
{
{
configASSERT ( ( portNVIC_INT_CTRL_REG & portVECTACTIVE_MASK ) = = 0 ) ;
configASSERT ( ( portNVIC_INT_CTRL_REG & portVECTACTIVE_MASK ) = = 0 ) ;
}
}
# if( configALLOW_UNPRIVILEGED_CRITICAL_SECTIONS == 1 )
vPortResetPrivilege ( xRunningPrivileged ) ;
# endif
# endif
}
}
/*-----------------------------------------------------------*/
/*-----------------------------------------------------------*/
@ -490,21 +518,41 @@ void vPortEnterCritical( void )
void vPortExitCritical ( void )
void vPortExitCritical ( void )
{
{
# if( configALLOW_UNPRIVILEGED_CRITICAL_SECTIONS == 1 )
# if( configALLOW_UNPRIVILEGED_CRITICAL_SECTIONS == 1 )
BaseType_t xRunningPrivileged ;
if ( portIS_PRIVILEGED ( ) = = pdFALSE )
xPortRaisePrivilege ( xRunningPrivileged ) ;
{
# endif
portRAISE_PRIVILEGE ( ) ;
portMEMORY_BARRIER ( ) ;
configASSERT ( uxCriticalNesting ) ;
configASSERT ( uxCriticalNesting ) ;
uxCriticalNesting - - ;
if ( uxCriticalNesting = = 0 )
{
portENABLE_INTERRUPTS ( ) ;
}
portMEMORY_BARRIER ( ) ;
portRESET_PRIVILEGE ( ) ;
portMEMORY_BARRIER ( ) ;
}
else
{
configASSERT ( uxCriticalNesting ) ;
uxCriticalNesting - - ;
if ( uxCriticalNesting = = 0 )
{
portENABLE_INTERRUPTS ( ) ;
}
}
# else
configASSERT ( uxCriticalNesting ) ;
uxCriticalNesting - - ;
uxCriticalNesting - - ;
if ( uxCriticalNesting = = 0 )
if ( uxCriticalNesting = = 0 )
{
{
portENABLE_INTERRUPTS ( ) ;
portENABLE_INTERRUPTS ( ) ;
}
}
# if( configALLOW_UNPRIVILEGED_CRITICAL_SECTIONS == 1 )
vPortResetPrivilege ( xRunningPrivileged ) ;
# endif
# endif
}
}
/*-----------------------------------------------------------*/
/*-----------------------------------------------------------*/