1 /*
2 * Copyright (c) 2020 - 2024 Renesas Electronics Corporation and/or its affiliates
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7 #ifndef BSP_SECURITY_H
8 #define BSP_SECURITY_H
9
10 /** Common macro for FSP header files. There is also a corresponding FSP_FOOTER macro at the end of this file. */
11 FSP_HEADER
12
13 /***********************************************************************************************************************
14 * Macro definitions
15 **********************************************************************************************************************/
16
17 /***********************************************************************************************************************
18 * Typedef definitions
19 **********************************************************************************************************************/
20
21 /***********************************************************************************************************************
22 * Exported global variables
23 **********************************************************************************************************************/
24
25 /***********************************************************************************************************************
26 * Exported global functions (to be accessed by other files)
27 **********************************************************************************************************************/
28 void R_BSP_NonSecureEnter(void);
29 void R_BSP_RegisterProtectDisable (bsp_reg_protect_t regs_to_unprotect);
30 void R_BSP_RegisterProtectEnable (bsp_reg_protect_t regs_to_protect);
31
32 /*******************************************************************************************************************//**
33 * Initialize security features for TrustZone.
34 *
35 * This function initializes ARM security register and Renesas SAR registers for secure projects.
36 *
37 * @note IDAU settings must be configured to match project settings with a separate configuration tool.
38 **********************************************************************************************************************/
R_BSP_SecurityInit(void)39 __STATIC_INLINE void R_BSP_SecurityInit (void)
40 {
41 #if FSP_PRIV_TZ_USE_SECURE_REGS
42 /* Disable protection using PRCR register. */
43 R_BSP_RegisterProtectDisable(BSP_REG_PROTECT_SAR);
44
45 /* Initialize peripherals to secure mode for flat projects */
46 R_PSCU->PSARB = 0;
47 R_PSCU->PSARC = 0;
48 R_PSCU->PSARD = 0;
49 R_PSCU->PSARE = 0;
50
51 R_CPSCU->ICUSARG = 0;
52 R_CPSCU->ICUSARH = 0;
53 R_CPSCU->ICUSARI = 0;
54
55 /* Enable protection using PRCR register. */
56 R_BSP_RegisterProtectEnable(BSP_REG_PROTECT_SAR);
57 #endif
58 }
59
60 /** Common macro for FSP header files. There is also a corresponding FSP_HEADER macro at the top of this file. */
61 FSP_FOOTER
62
63 #endif
64