1 /**
2 ******************************************************************************
3 * @file partition_stm32u599xx.h
4 * @author MCD Application Team
5 * @brief CMSIS STM32U599xx Device Initial Setup for Secure / Non-Secure Zones
6 * for ARMCM33 based on CMSIS CORE partition_ARMCM33.h Template.
7 *
8 * This file contains:
9 * - Initialize Security Attribution Unit (SAU) CTRL register
10 * - Setup behavior of Sleep and Exception Handling
11 * - Setup behavior of Floating Point Unit
12 * - Setup Interrupt Target
13 *
14 ******************************************************************************/
15 /**
16 * Copyright (c) 2009-2016 ARM Limited. All rights reserved.
17 * Portions Copyright (c) 2022 STMicroelectronics, all rights reserved
18 *
19 * SPDX-License-Identifier: Apache-2.0
20 *
21 * Licensed under the Apache License, Version 2.0 (the License); you may
22 * not use this file except in compliance with the License.
23 * You may obtain a copy of the License at
24 *
25 * http://www.apache.org/licenses/LICENSE-2.0
26 *
27 * Unless required by applicable law or agreed to in writing, software
28 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
29 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
30 * See the License for the specific language governing permissions and
31 * limitations under the License.
32 */
33
34 #ifndef PARTITION_STM32U599XX_H
35 #define PARTITION_STM32U599XX_H
36
37 /*
38 //-------- <<< Use Configuration Wizard in Context Menu >>> -----------------
39 */
40
41 /*
42 // <e>Initialize Security Attribution Unit (SAU) CTRL register
43 */
44 #define SAU_INIT_CTRL 1
45
46 /*
47 // <q> Enable SAU
48 // <i> Value for SAU->CTRL register bit ENABLE
49 */
50 #define SAU_INIT_CTRL_ENABLE 0
51
52 /*
53 // <o> When SAU is disabled
54 // <0=> All Memory is Secure
55 // <1=> All Memory is Non-Secure
56 // <i> Value for SAU->CTRL register bit ALLNS
57 // <i> When all Memory is Non-Secure (ALLNS is 1), IDAU can override memory map configuration.
58 */
59 #define SAU_INIT_CTRL_ALLNS 1
60
61 /*
62 // </e>
63 */
64
65 /*
66 // <h>Initialize Security Attribution Unit (SAU) Address Regions
67 // <i>SAU configuration specifies regions to be one of:
68 // <i> - Secure and Non-Secure Callable
69 // <i> - Non-Secure
70 // <i>Note: All memory regions not configured by SAU are Secure
71 */
72 #define SAU_REGIONS_MAX 8 /* Max. number of SAU regions */
73
74 /*
75 // <e>Initialize SAU Region 0
76 // <i> Setup SAU Region 0 memory attributes
77 */
78 #define SAU_INIT_REGION0 0
79
80 /*
81 // <o>Start Address <0-0xFFFFFFE0>
82 */
83 #define SAU_INIT_START0 0x0C1FE000 /* start address of SAU region 0 */
84
85 /*
86 // <o>End Address <0x1F-0xFFFFFFFF>
87 */
88 #define SAU_INIT_END0 0x0C1FFFFF /* end address of SAU region 0 */
89
90 /*
91 // <o>Region is
92 // <0=>Non-Secure
93 // <1=>Secure, Non-Secure Callable
94 */
95 #define SAU_INIT_NSC0 1
96 /*
97 // </e>
98 */
99
100 /*
101 // <e>Initialize SAU Region 1
102 // <i> Setup SAU Region 1 memory attributes
103 */
104 #define SAU_INIT_REGION1 0
105
106 /*
107 // <o>Start Address <0-0xFFFFFFE0>
108 */
109 #define SAU_INIT_START1 0x08200000 /* start address of SAU region 1 */
110
111 /*
112 // <o>End Address <0x1F-0xFFFFFFFF>
113 */
114 #define SAU_INIT_END1 0x083FFFFF /* end address of SAU region 1 */
115
116 /*
117 // <o>Region is
118 // <0=>Non-Secure
119 // <1=>Secure, Non-Secure Callable
120 */
121 #define SAU_INIT_NSC1 0
122 /*
123 // </e>
124 */
125
126 /*
127 // <e>Initialize SAU Region 2
128 // <i> Setup SAU Region 2 memory attributes
129 */
130 #define SAU_INIT_REGION2 0
131
132 /*
133 // <o>Start Address <0-0xFFFFFFE0>
134 */
135 #define SAU_INIT_START2 0x200D0000 /* start address of SAU region 2 */
136
137 /*
138 // <o>End Address <0x1F-0xFFFFFFFF>
139 */
140 #define SAU_INIT_END2 0x2026FFFF /* end address of SAU region 2 */
141
142 /*
143 // <o>Region is
144 // <0=>Non-Secure
145 // <1=>Secure, Non-Secure Callable
146 */
147 #define SAU_INIT_NSC2 0
148 /*
149 // </e>
150 */
151
152 /*
153 // <e>Initialize SAU Region 3
154 // <i> Setup SAU Region 3 memory attributes
155 */
156 #define SAU_INIT_REGION3 0
157
158 /*
159 // <o>Start Address <0-0xFFFFFFE0>
160 */
161 #define SAU_INIT_START3 0x40000000 /* start address of SAU region 3 */
162
163 /*
164 // <o>End Address <0x1F-0xFFFFFFFF>
165 */
166 #define SAU_INIT_END3 0x4FFFFFFF /* end address of SAU region 3 */
167
168 /*
169 // <o>Region is
170 // <0=>Non-Secure
171 // <1=>Secure, Non-Secure Callable
172 */
173 #define SAU_INIT_NSC3 0
174 /*
175 // </e>
176 */
177
178 /*
179 // <e>Initialize SAU Region 4
180 // <i> Setup SAU Region 4 memory attributes
181 */
182 #define SAU_INIT_REGION4 0
183
184 /*
185 // <o>Start Address <0-0xFFFFFFE0>
186 */
187 #define SAU_INIT_START4 0x60000000 /* start address of SAU region 4 */
188
189 /*
190 // <o>End Address <0x1F-0xFFFFFFFF>
191 */
192 #define SAU_INIT_END4 0xAFFFFFFF /* end address of SAU region 4 */
193
194 /*
195 // <o>Region is
196 // <0=>Non-Secure
197 // <1=>Secure, Non-Secure Callable
198 */
199 #define SAU_INIT_NSC4 0
200 /*
201 // </e>
202 */
203
204 /*
205 // <e>Initialize SAU Region 5
206 // <i> Setup SAU Region 5 memory attributes
207 */
208 #define SAU_INIT_REGION5 0
209
210 /*
211 // <o>Start Address <0-0xFFFFFFE0>
212 */
213 #define SAU_INIT_START5 0x0BF90000 /* start address of SAU region 5 */
214
215 /*
216 // <o>End Address <0x1F-0xFFFFFFFF>
217 */
218 #define SAU_INIT_END5 0x0BFA8FFF /* end address of SAU region 5 */
219
220 /*
221 // <o>Region is
222 // <0=>Non-Secure
223 // <1=>Secure, Non-Secure Callable
224 */
225 #define SAU_INIT_NSC5 0
226 /*
227 // </e>
228 */
229
230 /*
231 // <e>Initialize SAU Region 6
232 // <i> Setup SAU Region 6 memory attributes
233 */
234 #define SAU_INIT_REGION6 0
235
236 /*
237 // <o>Start Address <0-0xFFFFFFE0>
238 */
239 #define SAU_INIT_START6 0x00000000 /* start address of SAU region 6 */
240
241 /*
242 // <o>End Address <0x1F-0xFFFFFFFF>
243 */
244 #define SAU_INIT_END6 0x00000000 /* end address of SAU region 6 */
245
246 /*
247 // <o>Region is
248 // <0=>Non-Secure
249 // <1=>Secure, Non-Secure Callable
250 */
251 #define SAU_INIT_NSC6 0
252 /*
253 // </e>
254 */
255
256 /*
257 // <e>Initialize SAU Region 7
258 // <i> Setup SAU Region 7 memory attributes
259 */
260 #define SAU_INIT_REGION7 0
261
262 /*
263 // <o>Start Address <0-0xFFFFFFE0>
264 */
265 #define SAU_INIT_START7 0x00000000 /* start address of SAU region 7 */
266
267 /*
268 // <o>End Address <0x1F-0xFFFFFFFF>
269 */
270 #define SAU_INIT_END7 0x00000000 /* end address of SAU region 7 */
271
272 /*
273 // <o>Region is
274 // <0=>Non-Secure
275 // <1=>Secure, Non-Secure Callable
276 */
277 #define SAU_INIT_NSC7 0
278 /*
279 // </e>
280 */
281
282 /*
283 // </h>
284 */
285
286 /*
287 // <e>Setup behaviour of Sleep and Exception Handling
288 */
289 #define SCB_CSR_AIRCR_INIT 0
290
291 /*
292 // <o> Deep Sleep can be enabled by
293 // <0=>Secure and Non-Secure state
294 // <1=>Secure state only
295 // <i> Value for SCB->CSR register bit DEEPSLEEPS
296 */
297 #define SCB_CSR_DEEPSLEEPS_VAL 0
298
299 /*
300 // <o>System reset request accessible from
301 // <0=> Secure and Non-Secure state
302 // <1=> Secure state only
303 // <i> Value for SCB->AIRCR register bit SYSRESETREQS
304 */
305 #define SCB_AIRCR_SYSRESETREQS_VAL 0
306
307 /*
308 // <o>Priority of Non-Secure exceptions is
309 // <0=> Not altered
310 // <1=> Lowered to 0x04-0x07
311 // <i> Value for SCB->AIRCR register bit PRIS
312 */
313 #define SCB_AIRCR_PRIS_VAL 0
314
315 /*
316 // <o>BusFault, HardFault, and NMI target
317 // <0=> Secure state
318 // <1=> Non-Secure state
319 // <i> Value for SCB->AIRCR register bit BFHFNMINS
320 */
321 #define SCB_AIRCR_BFHFNMINS_VAL 0
322
323 /*
324 // </e>
325 */
326
327 /*
328 // <e>Setup behaviour of Floating Point Unit
329 */
330 #define TZ_FPU_NS_USAGE 1
331
332 /*
333 // <o>Floating Point Unit usage
334 // <0=> Secure state only
335 // <3=> Secure and Non-Secure state
336 // <i> Value for SCB->NSACR register bits CP10, CP11
337 */
338 #define SCB_NSACR_CP10_11_VAL 3
339
340 /*
341 // <o>Treat floating-point registers as Secure
342 // <0=> Disabled
343 // <1=> Enabled
344 // <i> Value for FPU->FPCCR register bit TS
345 */
346 #define FPU_FPCCR_TS_VAL 0
347
348 /*
349 // <o>Clear on return (CLRONRET) accessibility
350 // <0=> Secure and Non-Secure state
351 // <1=> Secure state only
352 // <i> Value for FPU->FPCCR register bit CLRONRETS
353 */
354 #define FPU_FPCCR_CLRONRETS_VAL 0
355
356 /*
357 // <o>Clear floating-point caller saved registers on exception return
358 // <0=> Disabled
359 // <1=> Enabled
360 // <i> Value for FPU->FPCCR register bit CLRONRET
361 */
362 #define FPU_FPCCR_CLRONRET_VAL 1
363
364 /*
365 // </e>
366 */
367
368 /*
369 // <h>Setup Interrupt Target
370 */
371
372 /*
373 // <e>Initialize ITNS 0 (Interrupts 0..31)
374 */
375 #define NVIC_INIT_ITNS0 1
376
377 /*
378 // Interrupts 0..31
379 // <o.0> WWDG_IRQn <0=> Secure state <1=> Non-Secure state
380 // <o.1> PVD_PVM_IRQn <0=> Secure state <1=> Non-Secure state
381 // <o.2> RTC_IRQn <0=> Secure state <1=> Non-Secure state
382 // <o.3> RTC_S_IRQn <0=> Secure state <1=> Non-Secure state
383 // <o.4> TAMP_IRQn <0=> Secure state <1=> Non-Secure state
384 // <o.5> RAMCFG_IRQn <0=> Secure state <1=> Non-Secure state
385 // <o.6> FLASH_IRQn <0=> Secure state <1=> Non-Secure state
386 // <o.7> FLASH_S_IRQn <0=> Secure state <1=> Non-Secure state
387 // <o.8> GTZC_IRQn <0=> Secure state <1=> Non-Secure state
388 // <o.9> RCC_IRQn <0=> Secure state <1=> Non-Secure state
389 // <o.10> RCC_S_IRQn <0=> Secure state <1=> Non-Secure state
390 // <o.11> EXTI0_IRQn <0=> Secure state <1=> Non-Secure state
391 // <o.12> EXTI1_IRQn <0=> Secure state <1=> Non-Secure state
392 // <o.13> EXTI2_IRQn <0=> Secure state <1=> Non-Secure state
393 // <o.14> EXTI3_IRQn <0=> Secure state <1=> Non-Secure state
394 // <o.15> EXTI4_IRQn <0=> Secure state <1=> Non-Secure state
395 // <o.16> EXTI5_IRQn <0=> Secure state <1=> Non-Secure state
396 // <o.17> EXTI6_IRQn <0=> Secure state <1=> Non-Secure state
397 // <o.18> EXTI7_IRQn <0=> Secure state <1=> Non-Secure state
398 // <o.19> EXTI8_IRQn <0=> Secure state <1=> Non-Secure state
399 // <o.20> EXTI9_IRQn <0=> Secure state <1=> Non-Secure state
400 // <o.21> EXTI10_IRQn <0=> Secure state <1=> Non-Secure state
401 // <o.22> EXTI11_IRQn <0=> Secure state <1=> Non-Secure state
402 // <o.23> EXTI12_IRQn <0=> Secure state <1=> Non-Secure state
403 // <o.24> EXTI13_IRQn <0=> Secure state <1=> Non-Secure state
404 // <o.25> EXTI14_IRQn <0=> Secure state <1=> Non-Secure state
405 // <o.26> EXTI15_IRQn <0=> Secure state <1=> Non-Secure state
406 // <o.27> IWDG_IRQn <0=> Secure state <1=> Non-Secure state
407 // <o.29> GPDMA1_Channel0_IRQn <0=> Secure state <1=> Non-Secure state
408 // <o.30> GPDMA1_Channel1_IRQn <0=> Secure state <1=> Non-Secure state
409 // <o.31> GPDMA1_Channel2_IRQn <0=> Secure state <1=> Non-Secure state
410 */
411 #define NVIC_INIT_ITNS0_VAL 0x00000000
412
413 /*
414 // </e>
415 */
416
417 /*
418 // <e>Initialize ITNS 1 (Interrupts 32..63)
419 */
420 #define NVIC_INIT_ITNS1 1
421
422 /*
423 // Interrupts 32..63
424 // <o.0> GPDMA1_Channel3_IRQn <0=> Secure state <1=> Non-Secure state
425 // <o.1> GPDMA1_Channel4_IRQn <0=> Secure state <1=> Non-Secure state
426 // <o.2> GPDMA1_Channel5_IRQn <0=> Secure state <1=> Non-Secure state
427 // <o.3> GPDMA1_Channel6_IRQn <0=> Secure state <1=> Non-Secure state
428 // <o.4> GPDMA1_Channel7_IRQn <0=> Secure state <1=> Non-Secure state
429 // <o.5> ADC1_IRQn <0=> Secure state <1=> Non-Secure state
430 // <o.6> DAC1_IRQn <0=> Secure state <1=> Non-Secure state
431 // <o.7> FDCAN1_IT0_IRQn <0=> Secure state <1=> Non-Secure state
432 // <o.8> FDCAN1_IT1_IRQn <0=> Secure state <1=> Non-Secure state
433 // <o.9> TIM1_BRK_IRQn <0=> Secure state <1=> Non-Secure state
434 // <o.10> TIM1_UP_IRQn <0=> Secure state <1=> Non-Secure state
435 // <o.11> TIM1_TRG_COM_IRQn <0=> Secure state <1=> Non-Secure state
436 // <o.12> TIM1_CC_IRQn <0=> Secure state <1=> Non-Secure state
437 // <o.13> TIM2_IRQn <0=> Secure state <1=> Non-Secure state
438 // <o.14> TIM3_IRQn <0=> Secure state <1=> Non-Secure state
439 // <o.15> TIM4_IRQn <0=> Secure state <1=> Non-Secure state
440 // <o.16> TIM5_IRQn <0=> Secure state <1=> Non-Secure state
441 // <o.17> TIM6_IRQn <0=> Secure state <1=> Non-Secure state
442 // <o.18> TIM7_IRQn <0=> Secure state <1=> Non-Secure state
443 // <o.19> TIM8_BRK_IRQn <0=> Secure state <1=> Non-Secure state
444 // <o.20> TIM8_UP_IRQn <0=> Secure state <1=> Non-Secure state
445 // <o.21> TIM8_TRG_COM_IRQn <0=> Secure state <1=> Non-Secure state
446 // <o.22> TIM8_CC_IRQn <0=> Secure state <1=> Non-Secure state
447 // <o.23> I2C1_EV_IRQn <0=> Secure state <1=> Non-Secure state
448 // <o.24> I2C1_ER_IRQn <0=> Secure state <1=> Non-Secure state
449 // <o.25> I2C2_EV_IRQn <0=> Secure state <1=> Non-Secure state
450 // <o.26> I2C2_ER_IRQn <0=> Secure state <1=> Non-Secure state
451 // <o.27> SPI1_IRQn <0=> Secure state <1=> Non-Secure state
452 // <o.28> SPI2_IRQn <0=> Secure state <1=> Non-Secure state
453 // <o.29> USART1_IRQn <0=> Secure state <1=> Non-Secure state
454 // <o.30> USART2_IRQn <0=> Secure state <1=> Non-Secure state
455 // <o.31> USART3_IRQn <0=> Secure state <1=> Non-Secure state
456 */
457 #define NVIC_INIT_ITNS1_VAL 0x00000000
458
459 /*
460 // </e>
461 */
462
463 /*
464 // <e>Initialize ITNS 2 (Interrupts 64..95)
465 */
466 #define NVIC_INIT_ITNS2 1
467
468 /*
469 // Interrupts 64..95
470 // <o.0> UART4_IRQn <0=> Secure state <1=> Non-Secure state
471 // <o.1> UART5_IRQn <0=> Secure state <1=> Non-Secure state
472 // <o.2> LPUART1_IRQn <0=> Secure state <1=> Non-Secure state
473 // <o.3> LPTIM1_IRQn <0=> Secure state <1=> Non-Secure state
474 // <o.4> LPTIM2_IRQn <0=> Secure state <1=> Non-Secure state
475 // <o.5> TIM15_IRQn <0=> Secure state <1=> Non-Secure state
476 // <o.6> TIM16_IRQn <0=> Secure state <1=> Non-Secure state
477 // <o.7> TIM17_IRQn <0=> Secure state <1=> Non-Secure state
478 // <o.8> COMP_IRQn <0=> Secure state <1=> Non-Secure state
479 // <o.9> OTG_HS_IRQn <0=> Secure state <1=> Non-Secure state
480 // <o.10> CRS_IRQn <0=> Secure state <1=> Non-Secure state
481 // <o.11> FMC_IRQn <0=> Secure state <1=> Non-Secure state
482 // <o.12> OCTOSPI1_IRQn <0=> Secure state <1=> Non-Secure state
483 // <o.13> PWR_S3WU_IRQn <0=> Secure state <1=> Non-Secure state
484 // <o.14> SDMMC1_IRQn <0=> Secure state <1=> Non-Secure state
485 // <o.15> SDMMC2_IRQn <0=> Secure state <1=> Non-Secure state
486 // <o.16> GPDMA1_Channel8_IRQn <0=> Secure state <1=> Non-Secure state
487 // <o.17> GPDMA1_Channel9_IRQn <0=> Secure state <1=> Non-Secure state
488 // <o.18> GPDMA1_Channel10_IRQn <0=> Secure state <1=> Non-Secure state
489 // <o.19> GPDMA1_Channel11_IRQn <0=> Secure state <1=> Non-Secure state
490 // <o.20> GPDMA1_Channel12_IRQn <0=> Secure state <1=> Non-Secure state
491 // <o.21> GPDMA1_Channel13_IRQn <0=> Secure state <1=> Non-Secure state
492 // <o.22> GPDMA1_Channel14_IRQn <0=> Secure state <1=> Non-Secure state
493 // <o.23> GPDMA1_Channel15_IRQn <0=> Secure state <1=> Non-Secure state
494 // <o.24> I2C3_EV_IRQn <0=> Secure state <1=> Non-Secure state
495 // <o.25> I2C3_ER_IRQn <0=> Secure state <1=> Non-Secure state
496 // <o.26> SAI1_IRQn <0=> Secure state <1=> Non-Secure state
497 // <o.27> SAI2_IRQn <0=> Secure state <1=> Non-Secure state
498 // <o.28> TSC_IRQn <0=> Secure state <1=> Non-Secure state
499 // <o.30> RNG_IRQn <0=> Secure state <1=> Non-Secure state
500 // <o.31> FPU_IRQn <0=> Secure state <1=> Non-Secure state
501 */
502 #define NVIC_INIT_ITNS2_VAL 0x00000000
503
504 /*
505 // </e>
506 */
507
508 /*
509 // <e>Initialize ITNS 3 (Interrupts 96..127)
510 */
511 #define NVIC_INIT_ITNS3 1
512
513 /*
514 // Interrupts 96..127
515 // <o.0> HASH_IRQn <0=> Secure state <1=> Non-Secure state
516 // <o.2> LPTIM3_IRQn <0=> Secure state <1=> Non-Secure state
517 // <o.3> SPI3_IRQn <0=> Secure state <1=> Non-Secure state
518 // <o.4> I2C4_ER_IRQn <0=> Secure state <1=> Non-Secure state
519 // <o.5> I2C4_EV_IRQn <0=> Secure state <1=> Non-Secure state
520 // <o.6> MDF1_FLT0_IRQn <0=> Secure state <1=> Non-Secure state
521 // <o.7> MDF1_FLT1_IRQn <0=> Secure state <1=> Non-Secure state
522 // <o.8> MDF1_FLT2_IRQn <0=> Secure state <1=> Non-Secure state
523 // <o.9> MDF1_FLT3_IRQn <0=> Secure state <1=> Non-Secure state
524 // <o.10> UCPD1_IRQn <0=> Secure state <1=> Non-Secure state
525 // <o.11> ICACHE_IRQn <0=> Secure state <1=> Non-Secure state
526 // <o.14> LPTIM4_IRQn <0=> Secure state <1=> Non-Secure state
527 // <o.15> DCACHE1_IRQn <0=> Secure state <1=> Non-Secure state
528 // <o.16> ADF1_IRQn <0=> Secure state <1=> Non-Secure state
529 // <o.17> ADC4_IRQn <0=> Secure state <1=> Non-Secure state
530 // <o.18> LPDMA1_Channel0_IRQn <0=> Secure state <1=> Non-Secure state
531 // <o.19> LPDMA1_Channel1_IRQn <0=> Secure state <1=> Non-Secure state
532 // <o.20> LPDMA1_Channel2_IRQn <0=> Secure state <1=> Non-Secure state
533 // <o.21> LPDMA1_Channel3_IRQn <0=> Secure state <1=> Non-Secure state
534 // <o.22> DMA2D_IRQn <0=> Secure state <1=> Non-Secure state
535 // <o.23> DCMI_PSSI_IRQn <0=> Secure state <1=> Non-Secure state
536 // <o.24> OCTOSPI2_IRQn <0=> Secure state <1=> Non-Secure state
537 // <o.25> MDF1_FLT4_IRQn <0=> Secure state <1=> Non-Secure state
538 // <o.26> MDF1_FLT5_IRQn <0=> Secure state <1=> Non-Secure state
539 // <o.27> CORDIC_IRQn <0=> Secure state <1=> Non-Secure state
540 // <o.28> FMAC_IRQn <0=> Secure state <1=> Non-Secure state
541 // <o.29> LSECSSD_IRQn <0=> Secure state <1=> Non-Secure state
542 // <o.30> USART6_IRQn <0=> Secure state <1=> Non-Secure state
543 // <o.31> I2C5_ER_IRQn <0=> Secure state <1=> Non-Secure state
544 */
545 #define NVIC_INIT_ITNS3_VAL 0x00000000
546
547 /*
548 // </e>
549 */
550
551 /*
552 // <e>Initialize ITNS 4 (Interrupts 128..138)
553 */
554 #define NVIC_INIT_ITNS4 1
555
556 /*
557 // Interrupts 128..138
558 // <o.0> I2C5_EV_IRQn <0=> Secure state <1=> Non-Secure state
559 // <o.1> I2C6_ER_IRQn <0=> Secure state <1=> Non-Secure state
560 // <o.2> I2C6_EV_IRQn <0=> Secure state <1=> Non-Secure state
561 // <o.3> HSPI1_IRQn <0=> Secure state <1=> Non-Secure state
562 // <o.4> GPU2D_IRQn <0=> Secure state <1=> Non-Secure state
563 // <o.5> GPU2D_ER_IRQn <0=> Secure state <1=> Non-Secure state
564 // <o.6> GFXMMU_IRQn <0=> Secure state <1=> Non-Secure state
565 // <o.7> LTDC_IRQn <0=> Secure state <1=> Non-Secure state
566 // <o.8> LTDC_ER_IRQn <0=> Secure state <1=> Non-Secure state
567 // <o.9> DSI_IRQn <0=> Secure state <1=> Non-Secure state
568 // <o.10> DCACHE2_IRQn <0=> Secure state <1=> Non-Secure state
569 */
570 #define NVIC_INIT_ITNS4_VAL 0x00000000
571
572 /*
573 // </e>
574 */
575
576 /*
577 // </h>
578 */
579
580 /*
581 max 8 SAU regions.
582 SAU regions are defined in partition.h
583 */
584
585 #define SAU_INIT_REGION(n) \
586 SAU->RNR = (n & SAU_RNR_REGION_Msk); \
587 SAU->RBAR = (SAU_INIT_START##n & SAU_RBAR_BADDR_Msk); \
588 SAU->RLAR = (SAU_INIT_END##n & SAU_RLAR_LADDR_Msk) | \
589 ((SAU_INIT_NSC##n << SAU_RLAR_NSC_Pos) & SAU_RLAR_NSC_Msk) | 1U
590
591 /**
592 \brief Setup a SAU Region
593 \details Writes the region information contained in SAU_Region to the
594 registers SAU_RNR, SAU_RBAR, and SAU_RLAR
595 */
TZ_SAU_Setup(void)596 __STATIC_INLINE void TZ_SAU_Setup (void)
597 {
598
599 #if defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U)
600
601 #if defined (SAU_INIT_REGION0) && (SAU_INIT_REGION0 == 1U)
602 SAU_INIT_REGION(0);
603 #endif
604
605 #if defined (SAU_INIT_REGION1) && (SAU_INIT_REGION1 == 1U)
606 SAU_INIT_REGION(1);
607 #endif
608
609 #if defined (SAU_INIT_REGION2) && (SAU_INIT_REGION2 == 1U)
610 SAU_INIT_REGION(2);
611 #endif
612
613 #if defined (SAU_INIT_REGION3) && (SAU_INIT_REGION3 == 1U)
614 SAU_INIT_REGION(3);
615 #endif
616
617 #if defined (SAU_INIT_REGION4) && (SAU_INIT_REGION4 == 1U)
618 SAU_INIT_REGION(4);
619 #endif
620
621 #if defined (SAU_INIT_REGION5) && (SAU_INIT_REGION5 == 1U)
622 SAU_INIT_REGION(5);
623 #endif
624
625 #if defined (SAU_INIT_REGION6) && (SAU_INIT_REGION6 == 1U)
626 SAU_INIT_REGION(6);
627 #endif
628
629 #if defined (SAU_INIT_REGION7) && (SAU_INIT_REGION7 == 1U)
630 SAU_INIT_REGION(7);
631 #endif
632
633 /* repeat this for all possible SAU regions */
634
635 #endif /* defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) */
636
637
638 #if defined (SAU_INIT_CTRL) && (SAU_INIT_CTRL == 1U)
639 SAU->CTRL = ((SAU_INIT_CTRL_ENABLE << SAU_CTRL_ENABLE_Pos) & SAU_CTRL_ENABLE_Msk) |
640 ((SAU_INIT_CTRL_ALLNS << SAU_CTRL_ALLNS_Pos) & SAU_CTRL_ALLNS_Msk) ;
641 #endif
642
643 #if defined (SCB_CSR_AIRCR_INIT) && (SCB_CSR_AIRCR_INIT == 1U)
644 SCB->SCR = (SCB->SCR & ~(SCB_SCR_SLEEPDEEPS_Msk )) |
645 ((SCB_CSR_DEEPSLEEPS_VAL << SCB_SCR_SLEEPDEEPS_Pos) & SCB_SCR_SLEEPDEEPS_Msk);
646
647 SCB->AIRCR = (SCB->AIRCR & ~(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_SYSRESETREQS_Msk |
648 SCB_AIRCR_BFHFNMINS_Msk | SCB_AIRCR_PRIS_Msk) ) |
649 ((0x05FAU << SCB_AIRCR_VECTKEY_Pos) & SCB_AIRCR_VECTKEY_Msk) |
650 ((SCB_AIRCR_SYSRESETREQS_VAL << SCB_AIRCR_SYSRESETREQS_Pos) & SCB_AIRCR_SYSRESETREQS_Msk) |
651 ((SCB_AIRCR_PRIS_VAL << SCB_AIRCR_PRIS_Pos) & SCB_AIRCR_PRIS_Msk) |
652 ((SCB_AIRCR_BFHFNMINS_VAL << SCB_AIRCR_BFHFNMINS_Pos) & SCB_AIRCR_BFHFNMINS_Msk);
653 #endif /* defined (SCB_CSR_AIRCR_INIT) && (SCB_CSR_AIRCR_INIT == 1U) */
654
655 #if defined (__FPU_USED) && (__FPU_USED == 1U) && \
656 defined (TZ_FPU_NS_USAGE) && (TZ_FPU_NS_USAGE == 1U)
657
658 SCB->NSACR = (SCB->NSACR & ~(SCB_NSACR_CP10_Msk | SCB_NSACR_CP11_Msk)) |
659 ((SCB_NSACR_CP10_11_VAL << SCB_NSACR_CP10_Pos) & (SCB_NSACR_CP10_Msk | SCB_NSACR_CP11_Msk));
660
661 FPU->FPCCR = (FPU->FPCCR & ~(FPU_FPCCR_TS_Msk | FPU_FPCCR_CLRONRETS_Msk | FPU_FPCCR_CLRONRET_Msk)) |
662 ((FPU_FPCCR_TS_VAL << FPU_FPCCR_TS_Pos ) & FPU_FPCCR_TS_Msk ) |
663 ((FPU_FPCCR_CLRONRETS_VAL << FPU_FPCCR_CLRONRETS_Pos) & FPU_FPCCR_CLRONRETS_Msk) |
664 ((FPU_FPCCR_CLRONRET_VAL << FPU_FPCCR_CLRONRET_Pos ) & FPU_FPCCR_CLRONRET_Msk );
665 #endif
666
667 #if defined (NVIC_INIT_ITNS0) && (NVIC_INIT_ITNS0 == 1U)
668 NVIC->ITNS[0] = NVIC_INIT_ITNS0_VAL;
669 #endif
670
671 #if defined (NVIC_INIT_ITNS1) && (NVIC_INIT_ITNS1 == 1U)
672 NVIC->ITNS[1] = NVIC_INIT_ITNS1_VAL;
673 #endif
674
675 #if defined (NVIC_INIT_ITNS2) && (NVIC_INIT_ITNS2 == 1U)
676 NVIC->ITNS[2] = NVIC_INIT_ITNS2_VAL;
677 #endif
678
679 #if defined (NVIC_INIT_ITNS3) && (NVIC_INIT_ITNS3 == 1U)
680 NVIC->ITNS[3] = NVIC_INIT_ITNS3_VAL;
681 #endif
682
683 #if defined (NVIC_INIT_ITNS4) && (NVIC_INIT_ITNS4 == 1U)
684 NVIC->ITNS[4] = NVIC_INIT_ITNS4_VAL;
685 #endif
686
687 }
688
689 #endif /* PARTITION_STM32U599XX_H */
690