Skip to content

Commit

Permalink
Remove un-neccsary #if 1, and then re-order the MPU Regions to make t…
Browse files Browse the repository at this point in the history
…he diff better. Fix incorrect comment in portasm.c, fix an incorrect variable name in the port.c file
  • Loading branch information
Skptak committed Mar 1, 2024
1 parent 1541593 commit cdbccf3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
14 changes: 7 additions & 7 deletions portable/GCC/ARM_CM23_NTZ/non_secure/port.c
Original file line number Diff line number Diff line change
Expand Up @@ -383,14 +383,14 @@ static void prvTaskExitError( void );
#if ( configENABLE_MPU == 1 )

/**
* @brief Extract MPU region's access permissions from the Region Base Address
* Register (RBAR) value.
* @brief Extract MPU region's access permissions from the Region Attribute and Size
* Register (RASR) value.
*
* @param ulRBARValue RBAR value for the MPU region.
* @param ulRASRValue RASR value for the MPU region.
*
* @return uint32_t Access permissions.
*/
static uint32_t prvGetRegionAccessPermissions( uint32_t ulRBARValue ) PRIVILEGED_FUNCTION;
static uint32_t prvGetRegionAccessPermissions( uint32_t ulRASRValue ) PRIVILEGED_FUNCTION;
#endif /* configENABLE_MPU */

#if ( configENABLE_MPU == 1 )
Expand Down Expand Up @@ -832,16 +832,16 @@ static void prvTaskExitError( void )
/*-----------------------------------------------------------*/

#if ( configENABLE_MPU == 1 )
static uint32_t prvGetRegionAccessPermissions( uint32_t ulRBARValue ) /* PRIVILEGED_FUNCTION */
static uint32_t prvGetRegionAccessPermissions( uint32_t ulRASRValue ) /* PRIVILEGED_FUNCTION */
{
uint32_t ulAccessPermissions = 0;

if( ( ulRBARValue & portMPU_RASR_ACCESS_PERMISSIONS_MASK ) == portMPU_REGION_READ_ONLY )
if( ( ulRASRValue & portMPU_RASR_ACCESS_PERMISSIONS_MASK ) == portMPU_REGION_READ_ONLY )
{
ulAccessPermissions = tskMPU_READ_PERMISSION;
}

if( ( ulRBARValue & portMPU_RASR_ACCESS_PERMISSIONS_MASK ) == portMPU_REGION_READ_WRITE )
if( ( ulRASRValue & portMPU_RASR_ACCESS_PERMISSIONS_MASK ) == portMPU_REGION_READ_WRITE )
{
ulAccessPermissions = ( tskMPU_READ_PERMISSION | tskMPU_WRITE_PERMISSION );
}
Expand Down
6 changes: 2 additions & 4 deletions portable/GCC/ARM_CM23_NTZ/non_secure/portasm.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,12 @@
" str r5, [r2] \n" /* r2 = 0xe000ed9c [Location of RBAR]. */
" str r6, [r3] \n" /* r3 = 0xe000eda0 [Location of RASR]. */
" \n"
#if 1
" ldr r1, =0xe000ed94 \n" /* MPU_CTRL register. */
" ldr r2, [r1] \n" /* Read the value of MPU_CTRL. */
" movs r3, #1 \n" /* r3 = 1. */
" orrs r2, r3 \n" /* r2 = r2 | r3 i.e. Set the bit 0 in r2. */
" str r2, [r1] \n" /* Enable MPU. */
" dsb \n" /* Force memory writes before continuing. */
#endif
" \n"
" restore_context_first_task: \n"
" ldr r2, =pxCurrentTCB \n" /* r2 = &pxCurrentTCB. */
Expand Down Expand Up @@ -364,8 +362,8 @@ void vClearInterruptMask( __attribute__( ( unused ) ) uint32_t ulMask ) /* __att
" str r6, [r3] \n" /* r3 = 0xe000eda0 [Location of RASR]. */
" \n"
" ldr r2, [r1] \n" /* Read the value of MPU_CTRL. */
" movs r3, #0x1 \n"
" orrs r2, r2, r3 \n" /* r2 = r2 & ~1 i.e. Clear the bit 0 in r2. */
" movs r3, #1 \n"
" orrs r2, r2, r3 \n" /* r2 = r2 | r3 i.e. Set the bit 0 in r2. */
" str r2, [r1] \n" /* Enable MPU. */
" dsb \n" /* Force memory writes before continuing. */
" \n"
Expand Down
3 changes: 2 additions & 1 deletion portable/GCC/ARM_CM23_NTZ/non_secure/portmacrocommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,11 @@ extern void vClearInterruptMask( uint32_t ulMask ) /* __attribute__(( naked )) P
/* MPU regions. */
#define portPRIVILEGED_FLASH_REGION ( 6UL )
#define portUNPRIVILEGED_FLASH_REGION ( 5UL )
#define portLAST_CONFIGURABLE_REGION ( 3UL )
#define portUNPRIVILEGED_SYSCALLS_REGION ( 2UL )
#define portPRIVILEGED_RAM_REGION ( 7UL )
#define portSTACK_REGION ( 4UL )
#define portFIRST_CONFIGURABLE_REGION ( 0UL )
#define portLAST_CONFIGURABLE_REGION ( 3UL )
#define portNUM_CONFIGURABLE_REGIONS ( ( portLAST_CONFIGURABLE_REGION - portFIRST_CONFIGURABLE_REGION ) + 1 )
#define portTOTAL_NUM_REGIONS ( portNUM_CONFIGURABLE_REGIONS + 1 ) /* Plus one to make space for the stack region. */

Expand Down

0 comments on commit cdbccf3

Please sign in to comment.