Skip to content

Commit

Permalink
Code review suggestions
Browse files Browse the repository at this point in the history
Signed-off-by: Gaurav Aggarwal <[email protected]>
  • Loading branch information
aggarg committed Sep 25, 2023
1 parent abc3849 commit 20d52fc
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 36 deletions.
16 changes: 9 additions & 7 deletions portable/GCC/ARM_CM3_MPU/port.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,11 @@ BaseType_t xIsPrivileged( void ) __attribute__( ( naked ) );
*/
void vResetPrivilege( void ) __attribute__( ( naked ) );

/**
* @brief Make a task unprivileged.
*/
void vPortSwitchToUserMode( void );

/**
* @brief Enter critical section.
*/
Expand Down Expand Up @@ -1211,16 +1216,13 @@ void vResetPrivilege( void ) /* __attribute__ (( naked )) */

void vPortSwitchToUserMode( void )
{
/* Load the current task's MPU settings from its TCB */
/* Load the current task's MPU settings from its TCB. */
xMPU_SETTINGS * xTaskMpuSettings = xTaskGetMPUSettings( NULL );

/* Determine if the task that is running is marked as privileged or not */
if( ( xTaskMpuSettings->ulTaskFlags & portTASK_IS_PRIVILEGED_FLAG ) == portTASK_IS_PRIVILEGED_FLAG )
{
xTaskMpuSettings->ulTaskFlags &= ( ~( portTASK_IS_PRIVILEGED_FLAG ) );
}
/* Mark the task as unprivileged. */
xTaskMpuSettings->ulTaskFlags &= ( ~( portTASK_IS_PRIVILEGED_FLAG ) );

/* Set the privilege bit of the processor low */
/* Lower the processor's privilege level. */
vResetPrivilege();
}
/*-----------------------------------------------------------*/
Expand Down
3 changes: 1 addition & 2 deletions portable/GCC/ARM_CM3_MPU/portmacro.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,7 @@ extern void vPortSwitchToUserMode( void );
#define portRESET_PRIVILEGE() vResetPrivilege()

/**
* @brief Mark the ulTaskFlags in the task's TCB as unprivileged. Then use
* vResetPrivilege() to lower the processor's privilege bit.
* @brief Make a task unprivileged.
*/
#define portSWITCH_TO_USER_MODE() vPortSwitchToUserMode()
/*-----------------------------------------------------------*/
Expand Down
16 changes: 9 additions & 7 deletions portable/GCC/ARM_CM4_MPU/port.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,11 @@ BaseType_t xIsPrivileged( void ) __attribute__( ( naked ) );
*/
void vResetPrivilege( void ) __attribute__( ( naked ) );

/**
* @brief Make a task unprivileged.
*/
void vPortSwitchToUserMode( void );

/**
* @brief Enter critical section.
*/
Expand Down Expand Up @@ -1392,16 +1397,13 @@ void vResetPrivilege( void ) /* __attribute__ (( naked )) */

void vPortSwitchToUserMode( void )
{
/* Load the current task's MPU settings from its TCB */
/* Load the current task's MPU settings from its TCB. */
xMPU_SETTINGS * xTaskMpuSettings = xTaskGetMPUSettings( NULL );

/* Determine if the task that is running is marked as privileged or not */
if( ( xTaskMpuSettings->ulTaskFlags & portTASK_IS_PRIVILEGED_FLAG ) == portTASK_IS_PRIVILEGED_FLAG )
{
xTaskMpuSettings->ulTaskFlags &= ( ~( portTASK_IS_PRIVILEGED_FLAG ) );
}
/* Mark the task as unprivileged. */
xTaskMpuSettings->ulTaskFlags &= ( ~( portTASK_IS_PRIVILEGED_FLAG ) );

/* Set the privilege bit of the processor low */
/* Lower the processor's privilege level. */
vResetPrivilege();
}
/*-----------------------------------------------------------*/
Expand Down
3 changes: 1 addition & 2 deletions portable/GCC/ARM_CM4_MPU/portmacro.h
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,7 @@ extern void vPortSwitchToUserMode( void );
#define portRESET_PRIVILEGE() vResetPrivilege()

/**
* @brief Mark the ulTaskFlags in the task's TCB as unprivileged. Then use
* vResetPrivilege() to lower the processor's privilege bit.
* @brief Make a task unprivileged.
*/
#define portSWITCH_TO_USER_MODE() vPortSwitchToUserMode()
/*-----------------------------------------------------------*/
Expand Down
16 changes: 9 additions & 7 deletions portable/IAR/ARM_CM4F_MPU/port.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,11 @@ extern void vPortRestoreContextOfFirstTask( void ) PRIVILEGED_FUNCTION;
*/
BaseType_t xPortIsTaskPrivileged( void ) PRIVILEGED_FUNCTION;

/**
* @brief Make a task unprivileged.
*/
void vPortSwitchToUserMode( void );

/*-----------------------------------------------------------*/

/* Each task maintains its own interrupt status in the critical nesting
Expand Down Expand Up @@ -743,16 +748,13 @@ BaseType_t xPortIsTaskPrivileged( void ) /* PRIVILEGED_FUNCTION */

void vPortSwitchToUserMode( void )
{
/* Load the current task's MPU settings from its TCB */
/* Load the current task's MPU settings from its TCB. */
xMPU_SETTINGS * xTaskMpuSettings = xTaskGetMPUSettings( NULL );

/* Determine if the task that is running is marked as privileged or not */
if( ( xTaskMpuSettings->ulTaskFlags & portTASK_IS_PRIVILEGED_FLAG ) == portTASK_IS_PRIVILEGED_FLAG )
{
xTaskMpuSettings->ulTaskFlags &= ( ~( portTASK_IS_PRIVILEGED_FLAG ) );
}
/* Mark the task as unprivileged. */
xTaskMpuSettings->ulTaskFlags &= ( ~( portTASK_IS_PRIVILEGED_FLAG ) );

/* Set the privilege bit of the processor low */
/* Lower the processor's privilege level. */
vResetPrivilege();
}
/*-----------------------------------------------------------*/
Expand Down
3 changes: 1 addition & 2 deletions portable/IAR/ARM_CM4F_MPU/portmacro.h
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,7 @@ extern void vPortSwitchToUserMode( void );
#define portRESET_PRIVILEGE() vResetPrivilege()

/**
* @brief Mark the ulTaskFlags in the task's TCB as unprivileged. Then use
* vResetPrivilege() to lower the processor's privilege bit.
* @brief Make a task unprivileged.
*/
#define portSWITCH_TO_USER_MODE() vPortSwitchToUserMode()
/*-----------------------------------------------------------*/
Expand Down
16 changes: 9 additions & 7 deletions portable/RVDS/ARM_CM4_MPU/port.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,11 @@ BaseType_t xIsPrivileged( void );
*/
void vResetPrivilege( void );

/**
* @brief Make a task unprivileged.
*/
void vPortSwitchToUserMode( void );

/**
* @brief Enter critical section.
*/
Expand Down Expand Up @@ -1360,16 +1365,13 @@ __asm void vResetPrivilege( void )

void vPortSwitchToUserMode( void )
{
/* Load the current task's MPU settings from its TCB */
/* Load the current task's MPU settings from its TCB. */
xMPU_SETTINGS * xTaskMpuSettings = xTaskGetMPUSettings( NULL );

/* Determine if the task that is running is marked as privileged or not */
if( ( xTaskMpuSettings->ulTaskFlags & portTASK_IS_PRIVILEGED_FLAG ) == portTASK_IS_PRIVILEGED_FLAG )
{
xTaskMpuSettings->ulTaskFlags &= ( ~( portTASK_IS_PRIVILEGED_FLAG ) );
}
/* Mark the task as unprivileged. */
xTaskMpuSettings->ulTaskFlags &= ( ~( portTASK_IS_PRIVILEGED_FLAG ) );

/* Set the privilege bit of the processor low */
/* Lower the processor's privilege level. */
vResetPrivilege();
}
/*-----------------------------------------------------------*/
Expand Down
3 changes: 1 addition & 2 deletions portable/RVDS/ARM_CM4_MPU/portmacro.h
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,7 @@ extern void vPortSwitchToUserMode( void );
#define portRESET_PRIVILEGE() vResetPrivilege()

/**
* @brief Mark the ulTaskFlags in the task's TCB as unprivileged. Then use
* vResetPrivilege() to lower the processor's privilege bit.
* @brief Make a task unprivileged.
*/
#define portSWITCH_TO_USER_MODE() vPortSwitchToUserMode()
/*-----------------------------------------------------------*/
Expand Down

0 comments on commit 20d52fc

Please sign in to comment.