@@ -166,73 +166,79 @@ typedef void ( * portISR_t )( void );
166166/**
167167 * @brief Constants required to manipulate the MPU.
168168 */
169- #define portMPU_TYPE_REG ( *( ( volatile uint32_t * ) 0xe000ed90 ) )
170- #define portMPU_CTRL_REG ( *( ( volatile uint32_t * ) 0xe000ed94 ) )
171- #define portMPU_RNR_REG ( *( ( volatile uint32_t * ) 0xe000ed98 ) )
169+ #define portMPU_TYPE_REG ( *( ( volatile uint32_t * ) 0xe000ed90 ) )
170+ #define portMPU_CTRL_REG ( *( ( volatile uint32_t * ) 0xe000ed94 ) )
171+ #define portMPU_RNR_REG ( *( ( volatile uint32_t * ) 0xe000ed98 ) )
172172
173- #define portMPU_RBAR_REG ( *( ( volatile uint32_t * ) 0xe000ed9c ) )
174- #define portMPU_RLAR_REG ( *( ( volatile uint32_t * ) 0xe000eda0 ) )
173+ #define portMPU_RBAR_REG ( *( ( volatile uint32_t * ) 0xe000ed9c ) )
174+ #define portMPU_RLAR_REG ( *( ( volatile uint32_t * ) 0xe000eda0 ) )
175175
176- #define portMPU_RBAR_A1_REG ( *( ( volatile uint32_t * ) 0xe000eda4 ) )
177- #define portMPU_RLAR_A1_REG ( *( ( volatile uint32_t * ) 0xe000eda8 ) )
176+ #define portMPU_RBAR_A1_REG ( *( ( volatile uint32_t * ) 0xe000eda4 ) )
177+ #define portMPU_RLAR_A1_REG ( *( ( volatile uint32_t * ) 0xe000eda8 ) )
178178
179- #define portMPU_RBAR_A2_REG ( *( ( volatile uint32_t * ) 0xe000edac ) )
180- #define portMPU_RLAR_A2_REG ( *( ( volatile uint32_t * ) 0xe000edb0 ) )
179+ #define portMPU_RBAR_A2_REG ( *( ( volatile uint32_t * ) 0xe000edac ) )
180+ #define portMPU_RLAR_A2_REG ( *( ( volatile uint32_t * ) 0xe000edb0 ) )
181181
182- #define portMPU_RBAR_A3_REG ( *( ( volatile uint32_t * ) 0xe000edb4 ) )
183- #define portMPU_RLAR_A3_REG ( *( ( volatile uint32_t * ) 0xe000edb8 ) )
182+ #define portMPU_RBAR_A3_REG ( *( ( volatile uint32_t * ) 0xe000edb4 ) )
183+ #define portMPU_RLAR_A3_REG ( *( ( volatile uint32_t * ) 0xe000edb8 ) )
184184
185- #define portMPU_MAIR0_REG ( *( ( volatile uint32_t * ) 0xe000edc0 ) )
186- #define portMPU_MAIR1_REG ( *( ( volatile uint32_t * ) 0xe000edc4 ) )
185+ #define portMPU_MAIR0_REG ( *( ( volatile uint32_t * ) 0xe000edc0 ) )
186+ #define portMPU_MAIR1_REG ( *( ( volatile uint32_t * ) 0xe000edc4 ) )
187187
188- #define portMPU_RBAR_ADDRESS_MASK ( 0xffffffe0 ) /* Must be 32-byte aligned. */
189- #define portMPU_RLAR_ADDRESS_MASK ( 0xffffffe0 ) /* Must be 32-byte aligned. */
188+ #define portMPU_RBAR_ADDRESS_MASK ( 0xffffffe0 ) /* Must be 32-byte aligned. */
189+ #define portMPU_RLAR_ADDRESS_MASK ( 0xffffffe0 ) /* Must be 32-byte aligned. */
190190
191- #define portMPU_RBAR_ACCESS_PERMISSIONS_MASK ( 3UL << 1UL )
191+ #define portMPU_RBAR_ACCESS_PERMISSIONS_MASK ( 3UL << 1UL )
192192
193- #define portMPU_MAIR_ATTR0_POS ( 0UL )
194- #define portMPU_MAIR_ATTR0_MASK ( 0x000000ff )
193+ #define portMPU_MAIR_ATTR0_POS ( 0UL )
194+ #define portMPU_MAIR_ATTR0_MASK ( 0x000000ff )
195195
196- #define portMPU_MAIR_ATTR1_POS ( 8UL )
197- #define portMPU_MAIR_ATTR1_MASK ( 0x0000ff00 )
196+ #define portMPU_MAIR_ATTR1_POS ( 8UL )
197+ #define portMPU_MAIR_ATTR1_MASK ( 0x0000ff00 )
198198
199- #define portMPU_MAIR_ATTR2_POS ( 16UL )
200- #define portMPU_MAIR_ATTR2_MASK ( 0x00ff0000 )
199+ #define portMPU_MAIR_ATTR2_POS ( 16UL )
200+ #define portMPU_MAIR_ATTR2_MASK ( 0x00ff0000 )
201201
202- #define portMPU_MAIR_ATTR3_POS ( 24UL )
203- #define portMPU_MAIR_ATTR3_MASK ( 0xff000000 )
202+ #define portMPU_MAIR_ATTR3_POS ( 24UL )
203+ #define portMPU_MAIR_ATTR3_MASK ( 0xff000000 )
204204
205- #define portMPU_MAIR_ATTR4_POS ( 0UL )
206- #define portMPU_MAIR_ATTR4_MASK ( 0x000000ff )
205+ #define portMPU_MAIR_ATTR4_POS ( 0UL )
206+ #define portMPU_MAIR_ATTR4_MASK ( 0x000000ff )
207207
208- #define portMPU_MAIR_ATTR5_POS ( 8UL )
209- #define portMPU_MAIR_ATTR5_MASK ( 0x0000ff00 )
208+ #define portMPU_MAIR_ATTR5_POS ( 8UL )
209+ #define portMPU_MAIR_ATTR5_MASK ( 0x0000ff00 )
210210
211- #define portMPU_MAIR_ATTR6_POS ( 16UL )
212- #define portMPU_MAIR_ATTR6_MASK ( 0x00ff0000 )
211+ #define portMPU_MAIR_ATTR6_POS ( 16UL )
212+ #define portMPU_MAIR_ATTR6_MASK ( 0x00ff0000 )
213213
214- #define portMPU_MAIR_ATTR7_POS ( 24UL )
215- #define portMPU_MAIR_ATTR7_MASK ( 0xff000000 )
214+ #define portMPU_MAIR_ATTR7_POS ( 24UL )
215+ #define portMPU_MAIR_ATTR7_MASK ( 0xff000000 )
216216
217- #define portMPU_RLAR_ATTR_INDEX0 ( 0UL << 1UL )
218- #define portMPU_RLAR_ATTR_INDEX1 ( 1UL << 1UL )
219- #define portMPU_RLAR_ATTR_INDEX2 ( 2UL << 1UL )
220- #define portMPU_RLAR_ATTR_INDEX3 ( 3UL << 1UL )
221- #define portMPU_RLAR_ATTR_INDEX4 ( 4UL << 1UL )
222- #define portMPU_RLAR_ATTR_INDEX5 ( 5UL << 1UL )
223- #define portMPU_RLAR_ATTR_INDEX6 ( 6UL << 1UL )
224- #define portMPU_RLAR_ATTR_INDEX7 ( 7UL << 1UL )
217+ #define portMPU_RLAR_ATTR_INDEX0 ( 0UL << 1UL )
218+ #define portMPU_RLAR_ATTR_INDEX1 ( 1UL << 1UL )
219+ #define portMPU_RLAR_ATTR_INDEX2 ( 2UL << 1UL )
220+ #define portMPU_RLAR_ATTR_INDEX3 ( 3UL << 1UL )
221+ #define portMPU_RLAR_ATTR_INDEX4 ( 4UL << 1UL )
222+ #define portMPU_RLAR_ATTR_INDEX5 ( 5UL << 1UL )
223+ #define portMPU_RLAR_ATTR_INDEX6 ( 6UL << 1UL )
224+ #define portMPU_RLAR_ATTR_INDEX7 ( 7UL << 1UL )
225225
226- #define portMPU_RLAR_REGION_ENABLE ( 1UL )
226+ #define portMPU_RLAR_REGION_ENABLE ( 1UL )
227+
228+ #if ( portARMV8M_MINOR_VERSION >= 1 )
229+ /* Enable Privileged eXecute Never MPU attribute for the selected memory
230+ * region. */
231+ #define portMPU_RLAR_PRIVILEGED_EXECUTE_NEVER ( 1UL << 4UL )
232+ #endif /* portARMV8M_MINOR_VERSION >= 1 */
227233
228234/* Enable privileged access to unmapped region. */
229- #define portMPU_PRIV_BACKGROUND_ENABLE_BIT ( 1UL << 2UL )
235+ #define portMPU_PRIV_BACKGROUND_ENABLE_BIT ( 1UL << 2UL )
230236
231237/* Enable MPU. */
232- #define portMPU_ENABLE_BIT ( 1UL << 0UL )
238+ #define portMPU_ENABLE_BIT ( 1UL << 0UL )
233239
234240/* Expected value of the portMPU_TYPE register. */
235- #define portEXPECTED_MPU_TYPE_VALUE ( configTOTAL_MPU_REGIONS << 8UL )
241+ #define portEXPECTED_MPU_TYPE_VALUE ( configTOTAL_MPU_REGIONS << 8UL )
236242
237243/* Extract first address of the MPU region as encoded in the
238244 * RBAR (Region Base Address Register) value. */
@@ -1880,6 +1886,16 @@ void vPortEndScheduler( void ) /* PRIVILEGED_FUNCTION */
18801886 xMPUSettings -> xRegionsSettings [ ulRegionNumber ].ulRLAR = ( ulRegionEndAddress ) |
18811887 ( portMPU_RLAR_REGION_ENABLE );
18821888
1889+ /* PXN. */
1890+ #if ( portARMV8M_MINOR_VERSION >= 1 )
1891+ {
1892+ if ( ( xRegions [ lIndex ].ulParameters & tskMPU_REGION_PRIVILEGED_EXECUTE_NEVER ) != 0 )
1893+ {
1894+ xMPUSettings -> xRegionsSettings [ ulRegionNumber ].ulRLAR |= ( portMPU_RLAR_PRIVILEGED_EXECUTE_NEVER );
1895+ }
1896+ }
1897+ #endif /* portARMV8M_MINOR_VERSION >= 1 */
1898+
18831899 /* Normal memory/ Device memory. */
18841900 if ( ( xRegions [ lIndex ].ulParameters & tskMPU_REGION_DEVICE_MEMORY ) != 0 )
18851901 {
0 commit comments