tzc400.h 6.6 KB
Newer Older
Harry Liebel's avatar
Harry Liebel committed
1
/*
2
 * Copyright (c) 2014-2016, ARM Limited and Contributors. All rights reserved.
Harry Liebel's avatar
Harry Liebel committed
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice, this
 * list of conditions and the following disclaimer.
 *
 * Redistributions in binary form must reproduce the above copyright notice,
 * this list of conditions and the following disclaimer in the documentation
 * and/or other materials provided with the distribution.
 *
 * Neither the name of ARM nor the names of its contributors may be used
 * to endorse or promote products derived from this software without specific
 * prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

#ifndef __TZC400_H__
#define __TZC400_H__

34
#include <tzc_common.h>
Harry Liebel's avatar
Harry Liebel committed
35

36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#define BUILD_CONFIG_OFF			0x000
#define GATE_KEEPER_OFF				0x008
#define SPECULATION_CTRL_OFF			0x00c
#define INT_STATUS				0x010
#define INT_CLEAR				0x014

#define FAIL_ADDRESS_LOW_OFF			0x020
#define FAIL_ADDRESS_HIGH_OFF			0x024
#define FAIL_CONTROL_OFF			0x028
#define FAIL_ID					0x02c

/* ID registers not common across different varieties of TZC */
#define PID5					0xFD4
#define PID6					0xFD8
#define PID7					0xFDC

#define BUILD_CONFIG_NF_SHIFT			24
#define BUILD_CONFIG_NF_MASK			0x3
#define BUILD_CONFIG_AW_SHIFT			8
#define BUILD_CONFIG_AW_MASK			0x3f
#define BUILD_CONFIG_NR_SHIFT			0
#define BUILD_CONFIG_NR_MASK			0x1f
Harry Liebel's avatar
Harry Liebel committed
58
59
60
61
62

/*
 * Number of gate keepers is implementation defined. But we know the max for
 * this device is 4. Get implementation details from BUILD_CONFIG.
 */
63
64
65
66
67
#define GATE_KEEPER_OS_SHIFT			16
#define GATE_KEEPER_OS_MASK			0xf
#define GATE_KEEPER_OR_SHIFT			0
#define GATE_KEEPER_OR_MASK			0xf
#define GATE_KEEPER_FILTER_MASK			0x1
Harry Liebel's avatar
Harry Liebel committed
68
69

/* Speculation is enabled by default. */
70
71
#define SPECULATION_CTRL_WRITE_DISABLE		(1 << 1)
#define SPECULATION_CTRL_READ_DISABLE		(1 << 0)
Harry Liebel's avatar
Harry Liebel committed
72
73

/* Max number of filters allowed is 4. */
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#define INT_STATUS_OVERLAP_SHIFT		16
#define INT_STATUS_OVERLAP_MASK			0xf
#define INT_STATUS_OVERRUN_SHIFT		8
#define INT_STATUS_OVERRUN_MASK			0xf
#define INT_STATUS_STATUS_SHIFT			0
#define INT_STATUS_STATUS_MASK			0xf

#define INT_CLEAR_CLEAR_SHIFT			0
#define INT_CLEAR_CLEAR_MASK			0xf

#define FAIL_CONTROL_DIR_SHIFT			(1 << 24)
#define FAIL_CONTROL_DIR_READ			0x0
#define FAIL_CONTROL_DIR_WRITE			0x1
#define FAIL_CONTROL_NS_SHIFT			(1 << 21)
#define FAIL_CONTROL_NS_SECURE			0x0
#define FAIL_CONTROL_NS_NONSECURE		0x1
#define FAIL_CONTROL_PRIV_SHIFT			(1 << 20)
#define FAIL_CONTROL_PRIV_PRIV			0x0
#define FAIL_CONTROL_PRIV_UNPRIV		0x1
Harry Liebel's avatar
Harry Liebel committed
93
94
95
96
97

/*
 * FAIL_ID_ID_MASK depends on AID_WIDTH which is platform specific.
 * Platform should provide the value on initialisation.
 */
98
99
100
#define FAIL_ID_VNET_SHIFT			24
#define FAIL_ID_VNET_MASK			0xf
#define FAIL_ID_ID_SHIFT			0
Harry Liebel's avatar
Harry Liebel committed
101

102
#define TZC_400_PERIPHERAL_ID			0x460
Harry Liebel's avatar
Harry Liebel committed
103

104
105
106
107
108
109
110
/* Filter enable bits in a TZC */
#define TZC_400_REGION_ATTR_F_EN_MASK		0xf
#define TZC_400_REGION_ATTR_FILTER_BIT(x)	((1 << x)		\
					<< TZC_REGION_ATTR_F_EN_SHIFT)
#define TZC_400_REGION_ATTR_FILTER_BIT_ALL				\
				(TZC_400_REGION_ATTR_F_EN_MASK <<	\
				TZC_REGION_ATTR_F_EN_SHIFT)
Harry Liebel's avatar
Harry Liebel committed
111

112
113
114
115
116
117
118
119
120
/*
 * Define some macros for backward compatibility with existing tzc400 clients.
 */
#if !ERROR_DEPRECATED
#define REG_ATTR_FILTER_BIT(x)			((1 << x)		\
					<< TZC_REGION_ATTR_F_EN_SHIFT)
#define REG_ATTR_FILTER_BIT_ALL	(TZC_400_REGION_ATTR_F_EN_MASK <<	\
					TZC_REGION_ATTR_F_EN_SHIFT)
#endif /* __ERROR_DEPRECATED__ */
Harry Liebel's avatar
Harry Liebel committed
121

122
123
124
125
126
127
/*
 * All TZC region configuration registers are placed one after another. It
 * depicts size of block of registers for programming each region.
 */
#define TZC_400_REGION_SIZE			0x20
#define TZC_400_ACTION_OFF			0x4
128
129
130

#ifndef __ASSEMBLY__

131
#include <cdefs.h>
132
133
#include <stdint.h>

Harry Liebel's avatar
Harry Liebel committed
134
135
136
/*******************************************************************************
 * Function & variable prototypes
 ******************************************************************************/
137
138
139
140
141
void tzc400_init(uintptr_t base);
void tzc400_configure_region0(tzc_region_attributes_t sec_attr,
			   unsigned int ns_device_access);
void tzc400_configure_region(unsigned int filters,
			  int region,
142
143
			  unsigned long long region_base,
			  unsigned long long region_top,
144
145
146
147
148
			  tzc_region_attributes_t sec_attr,
			  unsigned int ns_device_access);
void tzc400_set_action(tzc_action_t action);
void tzc400_enable_filters(void);
void tzc400_disable_filters(void);
Harry Liebel's avatar
Harry Liebel committed
149
150

/*
151
 * Deprecated APIs
Harry Liebel's avatar
Harry Liebel committed
152
 */
153
154
155
156
157
158
159
static inline void tzc_init(uintptr_t base) __deprecated;
static inline void tzc_configure_region0(
			tzc_region_attributes_t sec_attr,
			unsigned int ns_device_access) __deprecated;
static inline void tzc_configure_region(
			  unsigned int filters,
			  int region,
160
161
			  unsigned long long region_base,
			  unsigned long long region_top,
162
163
164
165
166
167
168
169
170
171
172
173
			  tzc_region_attributes_t sec_attr,
			  unsigned int ns_device_access) __deprecated;
static inline void tzc_set_action(tzc_action_t action) __deprecated;
static inline void tzc_enable_filters(void) __deprecated;
static inline void tzc_disable_filters(void) __deprecated;

static inline void tzc_init(uintptr_t base)
{
	tzc400_init(base);
}

static inline void tzc_configure_region0(
174
			tzc_region_attributes_t sec_attr,
175
176
177
178
179
180
181
182
			unsigned int ns_device_access)
{
	tzc400_configure_region0(sec_attr, ns_device_access);
}

static inline void tzc_configure_region(
			  unsigned int filters,
			  int region,
183
184
			  unsigned long long region_base,
			  unsigned long long region_top,
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
			  tzc_region_attributes_t sec_attr,
			  unsigned int ns_device_access)
{
	tzc400_configure_region(filters, region, region_base,
			region_top, sec_attr, ns_device_access);
}

static inline void tzc_set_action(tzc_action_t action)
{
	tzc400_set_action(action);
}


static inline void tzc_enable_filters(void)
{
	tzc400_enable_filters();
}

static inline void tzc_disable_filters(void)
{
	tzc400_disable_filters();
}
Harry Liebel's avatar
Harry Liebel committed
207

208
#endif /* __ASSEMBLY__ */
Harry Liebel's avatar
Harry Liebel committed
209
210

#endif /* __TZC400__ */