@@ -169,79 +169,80 @@ typedef void ( * portISR_t )( void );
169
169
/**
170
170
* @brief Constants required to manipulate the MPU.
171
171
*/
172
- #define portMPU_TYPE_REG ( *( ( volatile uint32_t * ) 0xe000ed90 ) )
173
- #define portMPU_CTRL_REG ( *( ( volatile uint32_t * ) 0xe000ed94 ) )
174
- #define portMPU_RNR_REG ( *( ( volatile uint32_t * ) 0xe000ed98 ) )
172
+ #define portMPU_TYPE_REG ( *( ( volatile uint32_t * ) 0xe000ed90 ) )
173
+ #define portMPU_CTRL_REG ( *( ( volatile uint32_t * ) 0xe000ed94 ) )
174
+ #define portMPU_RNR_REG ( *( ( volatile uint32_t * ) 0xe000ed98 ) )
175
175
176
- #define portMPU_RBAR_REG ( *( ( volatile uint32_t * ) 0xe000ed9c ) )
177
- #define portMPU_RLAR_REG ( *( ( volatile uint32_t * ) 0xe000eda0 ) )
176
+ #define portMPU_RBAR_REG ( *( ( volatile uint32_t * ) 0xe000ed9c ) )
177
+ #define portMPU_RLAR_REG ( *( ( volatile uint32_t * ) 0xe000eda0 ) )
178
178
179
- #define portMPU_RBAR_A1_REG ( *( ( volatile uint32_t * ) 0xe000eda4 ) )
180
- #define portMPU_RLAR_A1_REG ( *( ( volatile uint32_t * ) 0xe000eda8 ) )
179
+ #define portMPU_RBAR_A1_REG ( *( ( volatile uint32_t * ) 0xe000eda4 ) )
180
+ #define portMPU_RLAR_A1_REG ( *( ( volatile uint32_t * ) 0xe000eda8 ) )
181
181
182
- #define portMPU_RBAR_A2_REG ( *( ( volatile uint32_t * ) 0xe000edac ) )
183
- #define portMPU_RLAR_A2_REG ( *( ( volatile uint32_t * ) 0xe000edb0 ) )
182
+ #define portMPU_RBAR_A2_REG ( *( ( volatile uint32_t * ) 0xe000edac ) )
183
+ #define portMPU_RLAR_A2_REG ( *( ( volatile uint32_t * ) 0xe000edb0 ) )
184
184
185
- #define portMPU_RBAR_A3_REG ( *( ( volatile uint32_t * ) 0xe000edb4 ) )
186
- #define portMPU_RLAR_A3_REG ( *( ( volatile uint32_t * ) 0xe000edb8 ) )
185
+ #define portMPU_RBAR_A3_REG ( *( ( volatile uint32_t * ) 0xe000edb4 ) )
186
+ #define portMPU_RLAR_A3_REG ( *( ( volatile uint32_t * ) 0xe000edb8 ) )
187
187
188
- #define portMPU_MAIR0_REG ( *( ( volatile uint32_t * ) 0xe000edc0 ) )
189
- #define portMPU_MAIR1_REG ( *( ( volatile uint32_t * ) 0xe000edc4 ) )
188
+ #define portMPU_MAIR0_REG ( *( ( volatile uint32_t * ) 0xe000edc0 ) )
189
+ #define portMPU_MAIR1_REG ( *( ( volatile uint32_t * ) 0xe000edc4 ) )
190
190
191
- #define portMPU_RBAR_ADDRESS_MASK ( 0xffffffe0 ) /* Must be 32-byte aligned. */
192
- #define portMPU_RLAR_ADDRESS_MASK ( 0xffffffe0 ) /* Must be 32-byte aligned. */
191
+ #define portMPU_RBAR_ADDRESS_MASK ( 0xffffffe0 ) /* Must be 32-byte aligned. */
192
+ #define portMPU_RLAR_ADDRESS_MASK ( 0xffffffe0 ) /* Must be 32-byte aligned. */
193
193
194
- #define portMPU_RBAR_ACCESS_PERMISSIONS_MASK ( 3UL << 1UL )
194
+ #define portMPU_RBAR_ACCESS_PERMISSIONS_MASK ( 3UL << 1UL )
195
195
196
- #define portMPU_MAIR_ATTR0_POS ( 0UL )
197
- #define portMPU_MAIR_ATTR0_MASK ( 0x000000ff )
196
+ #define portMPU_MAIR_ATTR0_POS ( 0UL )
197
+ #define portMPU_MAIR_ATTR0_MASK ( 0x000000ff )
198
198
199
- #define portMPU_MAIR_ATTR1_POS ( 8UL )
200
- #define portMPU_MAIR_ATTR1_MASK ( 0x0000ff00 )
199
+ #define portMPU_MAIR_ATTR1_POS ( 8UL )
200
+ #define portMPU_MAIR_ATTR1_MASK ( 0x0000ff00 )
201
201
202
- #define portMPU_MAIR_ATTR2_POS ( 16UL )
203
- #define portMPU_MAIR_ATTR2_MASK ( 0x00ff0000 )
202
+ #define portMPU_MAIR_ATTR2_POS ( 16UL )
203
+ #define portMPU_MAIR_ATTR2_MASK ( 0x00ff0000 )
204
204
205
- #define portMPU_MAIR_ATTR3_POS ( 24UL )
206
- #define portMPU_MAIR_ATTR3_MASK ( 0xff000000 )
205
+ #define portMPU_MAIR_ATTR3_POS ( 24UL )
206
+ #define portMPU_MAIR_ATTR3_MASK ( 0xff000000 )
207
207
208
- #define portMPU_MAIR_ATTR4_POS ( 0UL )
209
- #define portMPU_MAIR_ATTR4_MASK ( 0x000000ff )
208
+ #define portMPU_MAIR_ATTR4_POS ( 0UL )
209
+ #define portMPU_MAIR_ATTR4_MASK ( 0x000000ff )
210
210
211
- #define portMPU_MAIR_ATTR5_POS ( 8UL )
212
- #define portMPU_MAIR_ATTR5_MASK ( 0x0000ff00 )
211
+ #define portMPU_MAIR_ATTR5_POS ( 8UL )
212
+ #define portMPU_MAIR_ATTR5_MASK ( 0x0000ff00 )
213
213
214
- #define portMPU_MAIR_ATTR6_POS ( 16UL )
215
- #define portMPU_MAIR_ATTR6_MASK ( 0x00ff0000 )
214
+ #define portMPU_MAIR_ATTR6_POS ( 16UL )
215
+ #define portMPU_MAIR_ATTR6_MASK ( 0x00ff0000 )
216
216
217
- #define portMPU_MAIR_ATTR7_POS ( 24UL )
218
- #define portMPU_MAIR_ATTR7_MASK ( 0xff000000 )
217
+ #define portMPU_MAIR_ATTR7_POS ( 24UL )
218
+ #define portMPU_MAIR_ATTR7_MASK ( 0xff000000 )
219
219
220
- #define portMPU_RLAR_ATTR_INDEX0 ( 0UL << 1UL )
221
- #define portMPU_RLAR_ATTR_INDEX1 ( 1UL << 1UL )
222
- #define portMPU_RLAR_ATTR_INDEX2 ( 2UL << 1UL )
223
- #define portMPU_RLAR_ATTR_INDEX3 ( 3UL << 1UL )
224
- #define portMPU_RLAR_ATTR_INDEX4 ( 4UL << 1UL )
225
- #define portMPU_RLAR_ATTR_INDEX5 ( 5UL << 1UL )
226
- #define portMPU_RLAR_ATTR_INDEX6 ( 6UL << 1UL )
227
- #define portMPU_RLAR_ATTR_INDEX7 ( 7UL << 1UL )
220
+ #define portMPU_RLAR_ATTR_INDEX0 ( 0UL << 1UL )
221
+ #define portMPU_RLAR_ATTR_INDEX1 ( 1UL << 1UL )
222
+ #define portMPU_RLAR_ATTR_INDEX2 ( 2UL << 1UL )
223
+ #define portMPU_RLAR_ATTR_INDEX3 ( 3UL << 1UL )
224
+ #define portMPU_RLAR_ATTR_INDEX4 ( 4UL << 1UL )
225
+ #define portMPU_RLAR_ATTR_INDEX5 ( 5UL << 1UL )
226
+ #define portMPU_RLAR_ATTR_INDEX6 ( 6UL << 1UL )
227
+ #define portMPU_RLAR_ATTR_INDEX7 ( 7UL << 1UL )
228
228
229
- #define portMPU_RLAR_REGION_ENABLE ( 1UL )
229
+ #define portMPU_RLAR_REGION_ENABLE ( 1UL )
230
230
231
231
#if ( portARMV8M_MINOR_VERSION >= 1 )
232
- /* Enable Privileged eXecute Never MPU attribute for the selected memory
233
- * region. */
234
- #define portMPU_RLAR_PRIVILEGED_EXECUTE_NEVER ( 1UL << 4UL )
232
+
233
+ /* Enable Privileged eXecute Never MPU attribute for the selected memory
234
+ * region. */
235
+ #define portMPU_RLAR_PRIVILEGED_EXECUTE_NEVER ( 1UL << 4UL )
235
236
#endif /* portARMV8M_MINOR_VERSION >= 1 */
236
237
237
238
/* Enable privileged access to unmapped region. */
238
- #define portMPU_PRIV_BACKGROUND_ENABLE_BIT ( 1UL << 2UL )
239
+ #define portMPU_PRIV_BACKGROUND_ENABLE_BIT ( 1UL << 2UL )
239
240
240
241
/* Enable MPU. */
241
- #define portMPU_ENABLE_BIT ( 1UL << 0UL )
242
+ #define portMPU_ENABLE_BIT ( 1UL << 0UL )
242
243
243
244
/* Expected value of the portMPU_TYPE register. */
244
- #define portEXPECTED_MPU_TYPE_VALUE ( configTOTAL_MPU_REGIONS << 8UL )
245
+ #define portEXPECTED_MPU_TYPE_VALUE ( configTOTAL_MPU_REGIONS << 8UL )
245
246
246
247
/* Extract first address of the MPU region as encoded in the
247
248
* RBAR (Region Base Address Register) value. */
@@ -380,14 +381,14 @@ typedef void ( * portISR_t )( void );
380
381
/**
381
382
* @brief Constants required to check and configure PACBTI security feature implementation.
382
383
*/
383
- #if ( ( configENABLE_PAC == 1 ) || ( configENABLE_BTI == 1 ) )
384
+ #if ( ( configENABLE_PAC == 1 ) || ( configENABLE_BTI == 1 ) )
384
385
385
- #define portID_ISAR5_REG ( *( ( volatile uint32_t * ) 0xe000ed74 ) )
386
+ #define portID_ISAR5_REG ( *( ( volatile uint32_t * ) 0xe000ed74 ) )
386
387
387
- #define portCONTROL_UPAC_EN ( 1UL << 7UL )
388
- #define portCONTROL_PAC_EN ( 1UL << 6UL )
389
- #define portCONTROL_UBTI_EN ( 1UL << 5UL )
390
- #define portCONTROL_BTI_EN ( 1UL << 4UL )
388
+ #define portCONTROL_UPAC_EN ( 1UL << 7UL )
389
+ #define portCONTROL_PAC_EN ( 1UL << 6UL )
390
+ #define portCONTROL_UBTI_EN ( 1UL << 5UL )
391
+ #define portCONTROL_BTI_EN ( 1UL << 4UL )
391
392
392
393
#endif /* configENABLE_PAC == 1 || configENABLE_BTI == 1 */
393
394
/*-----------------------------------------------------------*/
@@ -427,7 +428,7 @@ static void prvTaskExitError( void );
427
428
static void prvSetupFPU ( void ) PRIVILEGED_FUNCTION ;
428
429
#endif /* configENABLE_FPU */
429
430
430
- #if ( ( configENABLE_PAC == 1 ) || ( configENABLE_BTI == 1 ) )
431
+ #if ( ( configENABLE_PAC == 1 ) || ( configENABLE_BTI == 1 ) )
431
432
432
433
/**
433
434
* @brief Configures PACBTI features.
@@ -1212,6 +1213,7 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO
1212
1213
uint32_t ulStackFrameSize , ulSystemCallLocation , i ;
1213
1214
1214
1215
#if defined( __ARMCC_VERSION )
1216
+
1215
1217
/* Declaration when these variable are defined in code instead of being
1216
1218
* exported from linker scripts. */
1217
1219
extern uint32_t * __syscalls_flash_start__ ;
@@ -1282,6 +1284,7 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO
1282
1284
* point (i.e. the caller of the MPU_<API>). We need to restore it
1283
1285
* when we exit from the system call. */
1284
1286
pxMpuSettings -> xSystemCallStackInfo .ulLinkRegisterAtSystemCallEntry = pulTaskStack [ portOFFSET_TO_LR ];
1287
+
1285
1288
/* Store the value of the PSPLIM register before the SVC was raised.
1286
1289
* We need to restore it when we exit from the system call. */
1287
1290
#if ( portUSE_PSPLIM_REGISTER == 1 )
@@ -1300,6 +1303,7 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO
1300
1303
1301
1304
/* Start executing the system call upon returning from this handler. */
1302
1305
pulSystemCallStack [ portOFFSET_TO_PC ] = uxSystemCallImplementations [ ucSystemCallNumber ];
1306
+
1303
1307
/* Raise a request to exit from the system call upon finishing the
1304
1308
* system call. */
1305
1309
pulSystemCallStack [ portOFFSET_TO_LR ] = ( uint32_t ) vRequestSystemCallExit ;
@@ -1359,6 +1363,7 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO
1359
1363
uint32_t ulStackFrameSize , ulSystemCallLocation , i ;
1360
1364
1361
1365
#if defined( __ARMCC_VERSION )
1366
+
1362
1367
/* Declaration when these variable are defined in code instead of being
1363
1368
* exported from linker scripts. */
1364
1369
extern uint32_t * __privileged_functions_start__ ;
@@ -1541,7 +1546,7 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO
1541
1546
xMPUSettings -> ulContext [ ulIndex ] = ( uint32_t ) pxEndOfStack ; /* PSPLIM. */
1542
1547
ulIndex ++ ;
1543
1548
1544
- #if ( ( configENABLE_PAC == 1 ) || ( configENABLE_BTI == 1 ) )
1549
+ #if ( ( configENABLE_PAC == 1 ) || ( configENABLE_BTI == 1 ) )
1545
1550
{
1546
1551
/* Check PACBTI security feature configuration before pushing the
1547
1552
* CONTROL register's value on task's TCB. */
@@ -1814,11 +1819,11 @@ BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */
1814
1819
portNVIC_SHPR3_REG |= portNVIC_SYSTICK_PRI ;
1815
1820
portNVIC_SHPR2_REG = 0 ;
1816
1821
1817
- #if ( ( configENABLE_PAC == 1 ) || ( configENABLE_BTI == 1 ) )
1822
+ #if ( ( configENABLE_PAC == 1 ) || ( configENABLE_BTI == 1 ) )
1818
1823
{
1819
1824
/* Set the CONTROL register value based on PACBTI security feature
1820
1825
* configuration before starting the first task. */
1821
- ( void ) prvConfigurePACBTI ( pdTRUE );
1826
+ ( void ) prvConfigurePACBTI ( pdTRUE );
1822
1827
}
1823
1828
#endif /* configENABLE_PAC == 1 || configENABLE_BTI == 1 */
1824
1829
@@ -2018,9 +2023,9 @@ void vPortEndScheduler( void ) /* PRIVILEGED_FUNCTION */
2018
2023
if ( xSchedulerRunning == pdFALSE )
2019
2024
{
2020
2025
/* Grant access to all the kernel objects before the scheduler
2021
- * is started. It is necessary because there is no task running
2022
- * yet and therefore, we cannot use the permissions of any
2023
- * task. */
2026
+ * is started. It is necessary because there is no task running
2027
+ * yet and therefore, we cannot use the permissions of any
2028
+ * task. */
2024
2029
xAccessGranted = pdTRUE ;
2025
2030
}
2026
2031
else if ( ( xTaskMpuSettings -> ulTaskFlags & portTASK_IS_PRIVILEGED_FLAG ) == portTASK_IS_PRIVILEGED_FLAG )
@@ -2241,7 +2246,7 @@ BaseType_t xPortIsInsideInterrupt( void )
2241
2246
#endif /* #if ( ( configENABLE_MPU == 1 ) && ( configUSE_MPU_WRAPPERS_V1 == 0 ) ) */
2242
2247
/*-----------------------------------------------------------*/
2243
2248
2244
- #if ( ( configENABLE_PAC == 1 ) || ( configENABLE_BTI == 1 ) )
2249
+ #if ( ( configENABLE_PAC == 1 ) || ( configENABLE_BTI == 1 ) )
2245
2250
2246
2251
static uint32_t prvConfigurePACBTI ( BaseType_t xWriteControlRegister )
2247
2252
{
@@ -2253,13 +2258,13 @@ BaseType_t xPortIsInsideInterrupt( void )
2253
2258
/* Enable UsageFault exception. */
2254
2259
portSCB_SYS_HANDLER_CTRL_STATE_REG |= portSCB_USG_FAULT_ENABLE_BIT ;
2255
2260
2256
- #if ( configENABLE_PAC == 1 )
2261
+ #if ( configENABLE_PAC == 1 )
2257
2262
{
2258
2263
ulControl |= ( portCONTROL_UPAC_EN | portCONTROL_PAC_EN );
2259
2264
}
2260
2265
#endif
2261
2266
2262
- #if ( configENABLE_BTI == 1 )
2267
+ #if ( configENABLE_BTI == 1 )
2263
2268
{
2264
2269
ulControl |= ( portCONTROL_UBTI_EN | portCONTROL_BTI_EN );
2265
2270
}
0 commit comments