Skip to content

Commit 8abb13d

Browse files
thenguyenyfduynguyenxa
authored andcommitted
hal: renesas: ra: add a portable for bsp_security.h
Add new implementation for R_BSP_SecurityInit on Zephyr Signed-off-by: The Nguyen <[email protected]>
1 parent f969ed4 commit 8abb13d

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

zephyr/ra/portable/bsp_api.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,14 @@
5656
#include "bsp_group_irq.h"
5757
#include "bsp_clocks.h"
5858
#include "bsp_module_stop.h"
59-
#include "bsp_security.h"
60-
59+
6160
/* Factory MCU information. */
6261
#include "fsp_features.h"
6362

6463
/* BSP Common Includes (Other than bsp_common.h) */
6564
#include "bsp_delay.h"
6665
#include "bsp_mcu_api.h"
67-
66+
#include "bsp_security.h"
6867
#endif
6968

7069
/** Common macro for FSP header files. There is also a corresponding FSP_FOOTER macro at the end of this file. */

drivers/ra/fsp/src/bsp/mcu/all/bsp_security.h renamed to zephyr/ra/portable/bsp_security.h

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,36 @@ FSP_HEADER
2626
* Exported global functions (to be accessed by other files)
2727
**********************************************************************************************************************/
2828
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+
**********************************************************************************************************************/
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+
}
2959

3060
/** Common macro for FSP header files. There is also a corresponding FSP_HEADER macro at the top of this file. */
3161
FSP_FOOTER

0 commit comments

Comments
 (0)