Skip to content

Commit 20d52fc

Browse files
committed
Code review suggestions
Signed-off-by: Gaurav Aggarwal <[email protected]>
1 parent abc3849 commit 20d52fc

File tree

8 files changed

+40
-36
lines changed

8 files changed

+40
-36
lines changed

portable/GCC/ARM_CM3_MPU/port.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,11 @@ BaseType_t xIsPrivileged( void ) __attribute__( ( naked ) );
185185
*/
186186
void vResetPrivilege( void ) __attribute__( ( naked ) );
187187

188+
/**
189+
* @brief Make a task unprivileged.
190+
*/
191+
void vPortSwitchToUserMode( void );
192+
188193
/**
189194
* @brief Enter critical section.
190195
*/
@@ -1211,16 +1216,13 @@ void vResetPrivilege( void ) /* __attribute__ (( naked )) */
12111216

12121217
void vPortSwitchToUserMode( void )
12131218
{
1214-
/* Load the current task's MPU settings from its TCB */
1219+
/* Load the current task's MPU settings from its TCB. */
12151220
xMPU_SETTINGS * xTaskMpuSettings = xTaskGetMPUSettings( NULL );
12161221

1217-
/* Determine if the task that is running is marked as privileged or not */
1218-
if( ( xTaskMpuSettings->ulTaskFlags & portTASK_IS_PRIVILEGED_FLAG ) == portTASK_IS_PRIVILEGED_FLAG )
1219-
{
1220-
xTaskMpuSettings->ulTaskFlags &= ( ~( portTASK_IS_PRIVILEGED_FLAG ) );
1221-
}
1222+
/* Mark the task as unprivileged. */
1223+
xTaskMpuSettings->ulTaskFlags &= ( ~( portTASK_IS_PRIVILEGED_FLAG ) );
12221224

1223-
/* Set the privilege bit of the processor low */
1225+
/* Lower the processor's privilege level. */
12241226
vResetPrivilege();
12251227
}
12261228
/*-----------------------------------------------------------*/

portable/GCC/ARM_CM3_MPU/portmacro.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,7 @@ extern void vPortSwitchToUserMode( void );
288288
#define portRESET_PRIVILEGE() vResetPrivilege()
289289

290290
/**
291-
* @brief Mark the ulTaskFlags in the task's TCB as unprivileged. Then use
292-
* vResetPrivilege() to lower the processor's privilege bit.
291+
* @brief Make a task unprivileged.
293292
*/
294293
#define portSWITCH_TO_USER_MODE() vPortSwitchToUserMode()
295294
/*-----------------------------------------------------------*/

portable/GCC/ARM_CM4_MPU/port.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,11 @@ BaseType_t xIsPrivileged( void ) __attribute__( ( naked ) );
206206
*/
207207
void vResetPrivilege( void ) __attribute__( ( naked ) );
208208

209+
/**
210+
* @brief Make a task unprivileged.
211+
*/
212+
void vPortSwitchToUserMode( void );
213+
209214
/**
210215
* @brief Enter critical section.
211216
*/
@@ -1392,16 +1397,13 @@ void vResetPrivilege( void ) /* __attribute__ (( naked )) */
13921397

13931398
void vPortSwitchToUserMode( void )
13941399
{
1395-
/* Load the current task's MPU settings from its TCB */
1400+
/* Load the current task's MPU settings from its TCB. */
13961401
xMPU_SETTINGS * xTaskMpuSettings = xTaskGetMPUSettings( NULL );
13971402

1398-
/* Determine if the task that is running is marked as privileged or not */
1399-
if( ( xTaskMpuSettings->ulTaskFlags & portTASK_IS_PRIVILEGED_FLAG ) == portTASK_IS_PRIVILEGED_FLAG )
1400-
{
1401-
xTaskMpuSettings->ulTaskFlags &= ( ~( portTASK_IS_PRIVILEGED_FLAG ) );
1402-
}
1403+
/* Mark the task as unprivileged. */
1404+
xTaskMpuSettings->ulTaskFlags &= ( ~( portTASK_IS_PRIVILEGED_FLAG ) );
14031405

1404-
/* Set the privilege bit of the processor low */
1406+
/* Lower the processor's privilege level. */
14051407
vResetPrivilege();
14061408
}
14071409
/*-----------------------------------------------------------*/

portable/GCC/ARM_CM4_MPU/portmacro.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,8 +382,7 @@ extern void vPortSwitchToUserMode( void );
382382
#define portRESET_PRIVILEGE() vResetPrivilege()
383383

384384
/**
385-
* @brief Mark the ulTaskFlags in the task's TCB as unprivileged. Then use
386-
* vResetPrivilege() to lower the processor's privilege bit.
385+
* @brief Make a task unprivileged.
387386
*/
388387
#define portSWITCH_TO_USER_MODE() vPortSwitchToUserMode()
389388
/*-----------------------------------------------------------*/

portable/IAR/ARM_CM4F_MPU/port.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,11 @@ extern void vPortRestoreContextOfFirstTask( void ) PRIVILEGED_FUNCTION;
283283
*/
284284
BaseType_t xPortIsTaskPrivileged( void ) PRIVILEGED_FUNCTION;
285285

286+
/**
287+
* @brief Make a task unprivileged.
288+
*/
289+
void vPortSwitchToUserMode( void );
290+
286291
/*-----------------------------------------------------------*/
287292

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

744749
void vPortSwitchToUserMode( void )
745750
{
746-
/* Load the current task's MPU settings from its TCB */
751+
/* Load the current task's MPU settings from its TCB. */
747752
xMPU_SETTINGS * xTaskMpuSettings = xTaskGetMPUSettings( NULL );
748753

749-
/* Determine if the task that is running is marked as privileged or not */
750-
if( ( xTaskMpuSettings->ulTaskFlags & portTASK_IS_PRIVILEGED_FLAG ) == portTASK_IS_PRIVILEGED_FLAG )
751-
{
752-
xTaskMpuSettings->ulTaskFlags &= ( ~( portTASK_IS_PRIVILEGED_FLAG ) );
753-
}
754+
/* Mark the task as unprivileged. */
755+
xTaskMpuSettings->ulTaskFlags &= ( ~( portTASK_IS_PRIVILEGED_FLAG ) );
754756

755-
/* Set the privilege bit of the processor low */
757+
/* Lower the processor's privilege level. */
756758
vResetPrivilege();
757759
}
758760
/*-----------------------------------------------------------*/

portable/IAR/ARM_CM4F_MPU/portmacro.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,8 +410,7 @@ extern void vPortSwitchToUserMode( void );
410410
#define portRESET_PRIVILEGE() vResetPrivilege()
411411

412412
/**
413-
* @brief Mark the ulTaskFlags in the task's TCB as unprivileged. Then use
414-
* vResetPrivilege() to lower the processor's privilege bit.
413+
* @brief Make a task unprivileged.
415414
*/
416415
#define portSWITCH_TO_USER_MODE() vPortSwitchToUserMode()
417416
/*-----------------------------------------------------------*/

portable/RVDS/ARM_CM4_MPU/port.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,11 @@ BaseType_t xIsPrivileged( void );
219219
*/
220220
void vResetPrivilege( void );
221221

222+
/**
223+
* @brief Make a task unprivileged.
224+
*/
225+
void vPortSwitchToUserMode( void );
226+
222227
/**
223228
* @brief Enter critical section.
224229
*/
@@ -1360,16 +1365,13 @@ __asm void vResetPrivilege( void )
13601365

13611366
void vPortSwitchToUserMode( void )
13621367
{
1363-
/* Load the current task's MPU settings from its TCB */
1368+
/* Load the current task's MPU settings from its TCB. */
13641369
xMPU_SETTINGS * xTaskMpuSettings = xTaskGetMPUSettings( NULL );
13651370

1366-
/* Determine if the task that is running is marked as privileged or not */
1367-
if( ( xTaskMpuSettings->ulTaskFlags & portTASK_IS_PRIVILEGED_FLAG ) == portTASK_IS_PRIVILEGED_FLAG )
1368-
{
1369-
xTaskMpuSettings->ulTaskFlags &= ( ~( portTASK_IS_PRIVILEGED_FLAG ) );
1370-
}
1371+
/* Mark the task as unprivileged. */
1372+
xTaskMpuSettings->ulTaskFlags &= ( ~( portTASK_IS_PRIVILEGED_FLAG ) );
13711373

1372-
/* Set the privilege bit of the processor low */
1374+
/* Lower the processor's privilege level. */
13731375
vResetPrivilege();
13741376
}
13751377
/*-----------------------------------------------------------*/

portable/RVDS/ARM_CM4_MPU/portmacro.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,8 +375,7 @@ extern void vPortSwitchToUserMode( void );
375375
#define portRESET_PRIVILEGE() vResetPrivilege()
376376

377377
/**
378-
* @brief Mark the ulTaskFlags in the task's TCB as unprivileged. Then use
379-
* vResetPrivilege() to lower the processor's privilege bit.
378+
* @brief Make a task unprivileged.
380379
*/
381380
#define portSWITCH_TO_USER_MODE() vPortSwitchToUserMode()
382381
/*-----------------------------------------------------------*/

0 commit comments

Comments
 (0)