From cdbccf3475f01aebfb85d07bfe30778357932668 Mon Sep 17 00:00:00 2001 From: Soren Ptak Date: Fri, 1 Mar 2024 12:16:00 -0800 Subject: [PATCH] Remove un-neccsary #if 1, and then re-order the MPU Regions to make the diff better. Fix incorrect comment in portasm.c, fix an incorrect variable name in the port.c file --- portable/GCC/ARM_CM23_NTZ/non_secure/port.c | 14 +++++++------- portable/GCC/ARM_CM23_NTZ/non_secure/portasm.c | 6 ++---- .../GCC/ARM_CM23_NTZ/non_secure/portmacrocommon.h | 3 ++- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/portable/GCC/ARM_CM23_NTZ/non_secure/port.c b/portable/GCC/ARM_CM23_NTZ/non_secure/port.c index a21e10e145b..fdcd5be2472 100644 --- a/portable/GCC/ARM_CM23_NTZ/non_secure/port.c +++ b/portable/GCC/ARM_CM23_NTZ/non_secure/port.c @@ -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 ) @@ -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 ); } diff --git a/portable/GCC/ARM_CM23_NTZ/non_secure/portasm.c b/portable/GCC/ARM_CM23_NTZ/non_secure/portasm.c index af25f763074..6de590cdf5a 100644 --- a/portable/GCC/ARM_CM23_NTZ/non_secure/portasm.c +++ b/portable/GCC/ARM_CM23_NTZ/non_secure/portasm.c @@ -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. */ @@ -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" diff --git a/portable/GCC/ARM_CM23_NTZ/non_secure/portmacrocommon.h b/portable/GCC/ARM_CM23_NTZ/non_secure/portmacrocommon.h index d6aae199f9d..69583186e55 100644 --- a/portable/GCC/ARM_CM23_NTZ/non_secure/portmacrocommon.h +++ b/portable/GCC/ARM_CM23_NTZ/non_secure/portmacrocommon.h @@ -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. */