Skip to content

Commit aebb08f

Browse files
thenguyenyfKhiemNguyenT
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 99d268a commit aebb08f

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

drivers/ra/README

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,7 @@ Patch List:
123123
* Disable the priority setting for IRQ in FSP HAL layer so that priority setting will not be override when Open() API is called.
124124
Impacted files:
125125
zephyr/ra/portable/bsp_irq.h
126+
127+
* Add new implementation for R_BSP_SecurityInit on Zephyr.
128+
Impacted files:
129+
zephyr/ra/portable/bsp_security.h

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)