1 /**
2 ******************************************************************************
3 * @file rtl8721d_trustzone.h
4 * @author
5 * @version V1.0.0
6 * @date 2016-05-17
7 * @brief This file contains all the definations of trustzone.
8 ******************************************************************************
9 * @attention
10 *
11 * This module is a confidential and proprietary property of RealTek and
12 * possession or use of this module requires written permission of RealTek.
13 *
14 * Copyright(c) 2016, Realtek Semiconductor Corporation. All rights reserved.
15 ******************************************************************************
16 */
17 #ifndef _TRUSTZONE_H_
18 #define _TRUSTZONE_H_
19
20 typedef struct
21 {
22 u32 Start;
23 u32 End;
24 u32 NSC;
25 } TZ_CFG_TypeDef;
26
27 /*
28 * <q> Enable SAU
29 * <i> Value for SAU->CTRL register bit ENABLE
30 */
31 #define SAU_INIT_CTRL_ENABLE 1
32
33 /*
34 * <o> When SAU is disabled
35 * <0=> All Memory is Secure
36 * <1=> All Memory is Non-Secure
37 * <i> Value for SAU->CTRL register bit ALLNS
38 * <i> When all Memory is Non-Secure (ALLNS is 1), IDAU can override memory map configuration.
39 */
40 #define SAU_INIT_CTRL_ALLNS 0
41
42 #define SAU_ENTRYS_NUM 8
43 #define IDAU_ENTRYS_NUM 8
44
45 void BOOT_RAM_TZCfg(void);
46
47
48 /* The TT instruction takes a memory address and returns the configuration of the Memory Protection Unit (MPU) at that address.
49 The cmse_address_info_t is declared as following:
50 typedef union {
51 struct cmse_address_info {
52 unsigned mpu_region:8;
53 unsigned :8;
54 unsigned mpu_region_valid:1;
55 unsigned :1;
56 unsigned read_ok:1;
57 unsigned readwrite_ok:1;
58 unsigned :12;
59 } flags;
60 unsigned value;
61 } cmse_address_info_t;
62
63 When executed in the secure state the result of TT instruction is extended to return the SAU and IDAU configurations at the specific address.
64 The extended cmse_address_info_t is declared as following:
65 typedef union {
66 struct cmse_address_info {
67 unsigned mpu_region:8;
68 unsigned sau_region:8;
69 unsigned mpu_region_valid:1;
70 unsigned sau_region_valid:1;
71 unsigned read_ok:1;
72 unsigned readwrite_ok:1;
73 unsigned nonsecure_read_ok:1;
74 unsigned nonsecure_readwrite_ok:1;
75 unsigned secure:1;
76 unsigned idau_region_valid:1;
77 unsigned idau_region:8;
78 } flags;
79 unsigned value;
80 } cmse_address_info_t;
81
82 As a result, these extended bits are only valid when executing in Secure state, and are UNDEFINED if used from Non-secure state.
83 */
TrustZone_IsSecure(void)84 __STATIC_INLINE u32 TrustZone_IsSecure(void)
85 {
86 #if defined (ARM_CORE_CM4)
87 cmse_address_info_t cmse_address_info = cmse_TT((void *)DiagPrintf);
88 return cmse_address_info.flags.secure;
89 #else
90 return 0;
91 #endif
92 }
93
94
95 #endif //_TRUSTZONE_H_
96 /******************* (C) COPYRIGHT 2016 Realtek Semiconductor *****END OF FILE****/
97